@mux/mux-video 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +3 -3
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +3 -3
- package/dist/mux-video.js +23 -23
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +23 -23
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types-ts3.4/index.d.ts +2 -2
- package/package.json +8 -9
package/dist/mux-video.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
(()=>{var vr=Object.create;var at=Object.defineProperty;var gr=Object.getOwnPropertyDescriptor;var mr=Object.getOwnPropertyNames;var pr=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var Er=(U,D,d)=>D in U?at(U,D,{enumerable:!0,configurable:!0,writable:!0,value:d}):U[D]=d;var Tr=U=>at(U,"__esModule",{value:!0});var Kt=(U,D)=>()=>(D||U((D={exports:{}}).exports,D),D.exports);var Sr=(U,D,d)=>{if(D&&typeof D=="object"||typeof D=="function")for(let b of mr(D))!yr.call(U,b)&&b!=="default"&&at(U,b,{get:()=>D[b],enumerable:!(d=gr(D,b))||d.enumerable});return U},st=U=>Sr(Tr(at(U!=null?vr(pr(U)):{},"default",U&&U.__esModule&&"default"in U?{get:()=>U.default,enumerable:!0}:{value:U,enumerable:!0})),U);var ze=(U,D,d)=>(Er(U,typeof D!="symbol"?D+"":D,d),d),Et=(U,D,d)=>{if(!D.has(U))throw TypeError("Cannot "+d)};var te=(U,D,d)=>(Et(U,D,"read from private field"),d?d.call(U):D.get(U)),me=(U,D,d)=>{if(D.has(U))throw TypeError("Cannot add the same private member more than once");D instanceof WeakSet?D.add(U):D.set(U,d)},De=(U,D,d,b)=>(Et(U,D,"write to private field"),b?b.call(U,d):D.set(U,d),d);var Ae=(U,D,d)=>(Et(U,D,"access private method"),d);var Vt=Kt((lt,St)=>{(function(){var U=!1;(function(D,d){typeof lt=="object"&&typeof St=="object"?St.exports=d():typeof U=="function"&&U.amd?U("mux",[],d):typeof lt=="object"?lt.mux=d():D.mux=d()})(typeof self!="undefined"?self:this,function(){return function(D){function d(y){if(b[y])return b[y].exports;var T=b[y]={i:y,l:!1,exports:{}};return D[y].call(T.exports,T,T.exports,d),T.l=!0,T.exports}var b={};return d.m=D,d.c=b,d.d=function(y,T,I){d.o(y,T)||Object.defineProperty(y,T,{configurable:!1,enumerable:!0,get:I})},d.n=function(y){var T=y&&y.__esModule?function(){return y.default}:function(){return y};return d.d(T,"a",T),T},d.o=function(y,T){return Object.prototype.hasOwnProperty.call(y,T)},d.p="",d(d.s=18)}([function(D,d,b){(function(y){var T;T=typeof window!="undefined"?window:y!==void 0?y:typeof self!="undefined"?self:{},D.exports=T}).call(d,b(20))},function(D,d){function b(C,B,k){switch(k.length){case 0:return C.call(B);case 1:return C.call(B,k[0]);case 2:return C.call(B,k[0],k[1]);case 3:return C.call(B,k[0],k[1],k[2])}return C.apply(B,k)}function y(C,B){for(var k=-1,N=Array(C);++k<C;)N[k]=B(k);return N}function T(C,B){var k=F(C)||v(C)?y(C.length,String):[],N=k.length,W=!!N;for(var j in C)!B&&!l.call(C,j)||W&&(j=="length"||g(j,N))||k.push(j);return k}function I(C,B,k){var N=C[B];l.call(C,B)&&x(N,k)&&(k!==void 0||B in C)||(C[B]=k)}function S(C){if(!L(C))return R(C);var B=[];for(var k in Object(C))l.call(C,k)&&k!="constructor"&&B.push(k);return B}function O(C,B){return B=P(B===void 0?C.length-1:B,0),function(){for(var k=arguments,N=-1,W=P(k.length-B,0),j=Array(W);++N<W;)j[N]=k[B+N];N=-1;for(var K=Array(B+1);++N<B;)K[N]=k[N];return K[B]=j,b(C,this,K)}}function A(C,B,k,N){k||(k={});for(var W=-1,j=B.length;++W<j;){var K=B[W],V=N?N(k[K],C[K],K,k,C):void 0;I(k,K,V===void 0?C[K]:V)}return k}function g(C,B){return!!(B=B==null?n:B)&&(typeof C=="number"||f.test(C))&&C>-1&&C%1==0&&C<B}function _(C,B,k){if(!t(k))return!1;var N=typeof B;return!!(N=="number"?m(k)&&g(B,k.length):N=="string"&&B in k)&&x(k[B],C)}function L(C){var B=C&&C.constructor;return C===(typeof B=="function"&&B.prototype||o)}function x(C,B){return C===B||C!==C&&B!==B}function v(C){return s(C)&&l.call(C,"callee")&&(!p.call(C,"callee")||E.call(C)==h)}function m(C){return C!=null&&i(C.length)&&!e(C)}function s(C){return r(C)&&m(C)}function e(C){var B=t(C)?E.call(C):"";return B==c||B==u}function i(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=n}function t(C){var B=typeof C;return!!C&&(B=="object"||B=="function")}function r(C){return!!C&&typeof C=="object"}function a(C){return m(C)?T(C):S(C)}var n=9007199254740991,h="[object Arguments]",c="[object Function]",u="[object GeneratorFunction]",f=/^(?:0|[1-9]\d*)$/,o=Object.prototype,l=o.hasOwnProperty,E=o.toString,p=o.propertyIsEnumerable,R=function(C,B){return function(k){return C(B(k))}}(Object.keys,Object),P=Math.max,M=!p.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return O(function(B,k){var N=-1,W=k.length,j=W>1?k[W-1]:void 0,K=W>2?k[2]:void 0;for(j=C.length>3&&typeof j=="function"?(W--,j):void 0,K&&_(k[0],k[1],K)&&(j=W<3?void 0:j,W=1),B=Object(B);++N<W;){var V=k[N];V&&C(B,V,N,j)}return B})}(function(C,B){if(M||L(B)||m(B))return void A(B,a(B),C);for(var k in B)l.call(B,k)&&I(C,k,B[k])});D.exports=w},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(0),T=function(S){return S&&S.__esModule?S:{default:S}}(y),I={};I.now=function(){var S=T.default.performance,O=S&&S.timing;return O&&typeof O.navigationStart=="number"&&typeof S.now=="function"?O.navigationStart+S.now():Date.now()},d.default=I},function(D,d,b){"use strict";function y(T,I,S){S=S===void 0?1:S,T[I]=T[I]||0,T[I]+=S}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(21),T=function(S){return S&&S.__esModule?S:{default:S}}(y),I=T.default.methodFactory;T.default.methodFactory=function(S,O,A){var g=I(S,O,A);return function(){for(var _=["[mux]"],L=0;L<arguments.length;L++)_.push(arguments[L]);g.apply(void 0,_)}},T.default.setLevel(T.default.getLevel()),d.default=T.default},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=function(S){return I(S)[0]},T=function(S){return I(S)[1]},I=function(S){if(typeof S!="string"||S==="")return["localhost"];var O=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,A=S.match(O)||[],g=A[4],_=void 0;return g&&(_=(g.match(/[^\.]+\.[^\.]+$/)||[])[0]),[g,_]};d.extractHostnameAndDomain=I,d.extractHostname=y,d.extractDomain=T},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var S=16*Math.random()|0;return(I==="x"?S:3&S|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};d.generateUUID=y,d.generateShortID=T},function(D,d,b){"use strict";function y(I){I=I||"";var S={};return I.trim().split(/[\r\n]+/).forEach(function(O){if(O){var A=O.split(": "),g=A.shift();g&&(T.indexOf(g.toLowerCase())>=0||g.toLowerCase().indexOf("x-litix-")===0)&&(S[g]=A.join(": "))}}),S}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y;var T=["x-cdn","content-type"]},function(D,d,b){"use strict";var y=SyntaxError,T=Function,I=TypeError,S=function(l){try{return T('"use strict"; return ('+l+").constructor;")()}catch{}},O=Object.getOwnPropertyDescriptor;if(O)try{O({},"")}catch{O=null}var A=function(){throw new I},g=O?function(){try{return arguments.callee,A}catch{try{return O(arguments,"callee").get}catch{return A}}}():A,_=b(43)(),L=Object.getPrototypeOf||function(l){return l.__proto__},x={},v=typeof Uint8Array=="undefined"?void 0:L(Uint8Array),m={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":_?L([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":x,"%AsyncGenerator%":x,"%AsyncGeneratorFunction%":x,"%AsyncIteratorPrototype%":x,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":T,"%GeneratorFunction%":x,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":_?L(L([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&_?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"&&_?L(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":_?L(""[Symbol.iterator]()):void 0,"%Symbol%":_?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 l(E){var p;if(E==="%AsyncFunction%")p=S("async function () {}");else if(E==="%GeneratorFunction%")p=S("function* () {}");else if(E==="%AsyncGeneratorFunction%")p=S("async function* () {}");else if(E==="%AsyncGenerator%"){var R=l("%AsyncGeneratorFunction%");R&&(p=R.prototype)}else if(E==="%AsyncIteratorPrototype%"){var P=l("%AsyncGenerator%");P&&(p=L(P.prototype))}return m[E]=p,p},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},i=b(9),t=b(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),c=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,u=/\\(\\)?/g,f=function(l){var E=h(l,0,1),p=h(l,-1);if(E==="%"&&p!=="%")throw new y("invalid intrinsic syntax, expected closing `%`");if(p==="%"&&E!=="%")throw new y("invalid intrinsic syntax, expected opening `%`");var R=[];return n(l,c,function(P,M,F,w){R[R.length]=F?n(w,u,"$1"):M||P}),R},o=function(l,E){var p,R=l;if(t(e,R)&&(p=e[R],R="%"+p[0]+"%"),t(m,R)){var P=m[R];if(P===x&&(P=s(R)),P===void 0&&!E)throw new I("intrinsic "+l+" exists, but is not available. Please file an issue!");return{alias:p,name:R,value:P}}throw new y("intrinsic "+l+" does not exist!")};D.exports=function(l,E){if(typeof l!="string"||l.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 p=f(l),R=p.length>0?p[0]:"",P=o("%"+R+"%",E),M=P.name,F=P.value,w=!1,C=P.alias;C&&(R=C[0],a(p,r([0,1],C)));for(var B=1,k=!0;B<p.length;B+=1){var N=p[B],W=h(N,0,1),j=h(N,-1);if((W==='"'||W==="'"||W==="`"||j==='"'||j==="'"||j==="`")&&W!==j)throw new y("property names with quotes must have matching quotes");if(N!=="constructor"&&k||(w=!0),R+="."+N,M="%"+R+"%",t(m,M))F=m[M];else if(F!=null){if(!(N in F)){if(!E)throw new I("base intrinsic for "+l+" exists, but the property is not available.");return}if(O&&B+1>=p.length){var K=O(F,N);k=!!K,F=k&&"get"in K&&!("originalValue"in K.get)?K.get:F[N]}else k=t(F,N),F=F[N];k&&!w&&(m[M]=F)}}return F}},function(D,d,b){"use strict";var y=b(45);D.exports=Function.prototype.bind||y},function(D,d,b){"use strict";var y=String.prototype.replace,T=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};D.exports={default:I.RFC3986,formatters:{RFC1738:function(S){return y.call(S,T,"+")},RFC3986:function(S){return String(S)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.findMediaElement=d.getMuxPlayerId=void 0;var y=b(6),T=function(S){return S&&S.nodeName!==void 0?(S.muxId||(S.muxId=S.id||(0,y.generateShortID)()),S.muxId):S},I=function(S){var O=void 0;return S&&S.nodeName!==void 0?(O=S,S=T(O)):O=document.querySelector(S),[O,S,O&&O.nodeName?O.nodeName.toLowerCase():""]};d.getMuxPlayerId=T,d.findMediaElement=I},function(D,d,b){"use strict";function y(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y;var T=b(0),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(0),T=function(S){return S&&S.__esModule?S:{default:S}}(y),I={};I.exists=function(){var S=T.default.performance;return(S&&S.timing)!==void 0},I.domContentLoadedEventEnd=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.domContentLoadedEventEnd},I.navigationStart=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.navigationStart},d.default=I},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=function(T){var I={};for(var S in T){var O=T[S];O["DATA-ID"].search("io.litix.data.")!==-1&&(I[O["DATA-ID"].replace("io.litix.data.","")]=O.VALUE)}return I};d.default=y},function(D,d,b){"use strict";var y=b(41),T=b(51),I=b(10);D.exports={formats:I,parse:T,stringify:y}},function(D,d,b){"use strict";var y=b(10),T=Object.prototype.hasOwnProperty,I=Array.isArray,S=function(){for(var t=[],r=0;r<256;++r)t.push("%"+((r<16?"0":"")+r.toString(16)).toUpperCase());return t}(),O=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}}},A=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)||!T.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=A(r,n)),I(r)&&I(a)?(a.forEach(function(c,u){if(T.call(r,u)){var f=r[u];f&&typeof f=="object"&&c&&typeof c=="object"?r[u]=t(f,c,n):r.push(c)}else r[u]=c}),r):Object.keys(a).reduce(function(c,u){var f=a[u];return T.call(c,u)?c[u]=t(c[u],f,n):c[u]=f,c},h)},_=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}},x=function(t,r,a,n,h){if(t.length===0)return t;var c=t;if(typeof t=="symbol"?c=Symbol.prototype.toString.call(t):typeof t!="string"&&(c=String(t)),a==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var u="",f=0;f<c.length;++f){var o=c.charCodeAt(f);o===45||o===46||o===95||o===126||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122||h===y.RFC1738&&(o===40||o===41)?u+=c.charAt(f):o<128?u+=S[o]:o<2048?u+=S[192|o>>6]+S[128|63&o]:o<55296||o>=57344?u+=S[224|o>>12]+S[128|o>>6&63]+S[128|63&o]:(f+=1,o=65536+((1023&o)<<10|1023&c.charCodeAt(f)),u+=S[240|o>>18]+S[128|o>>12&63]+S[128|o>>6&63]+S[128|63&o])}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],c=h.obj[h.prop],u=Object.keys(c),f=0;f<u.length;++f){var o=u[f],l=c[o];typeof l=="object"&&l!==null&&a.indexOf(l)===-1&&(r.push({obj:c,prop:o}),a.push(l))}return O(r),t},m=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)};D.exports={arrayToObject:A,assign:_,combine:e,compact:v,decode:L,encode:x,isBuffer:s,isRegExp:m,maybeMap:i,merge:g}},function(D,d,b){"use strict";function y(m){return m&&m.__esModule?m:{default:m}}function T(m){var s={};for(var e in m)m.hasOwnProperty(e)&&(s[m[e]]=e);return s}function I(m){var s={},e={};return Object.keys(m).forEach(function(i){var t=!1;if(m.hasOwnProperty(i)&&m[i]!==void 0){var r=i.split("_"),a=r[0],n=L[a];n||(O.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:(O.default.info("Data key word `"+h+"` not expected in "+i),n+="_"+h+"_")}),t?e[n]=m[i]:s[n]=m[i]}}),(0,g.default)(s,e)}Object.defineProperty(d,"__esModule",{value:!0}),d.default=I;var S=b(4),O=y(S),A=b(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=T(_),x={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},v=T(x)},function(D,d,b){"use strict";D.exports=b(19).default},function(D,d,b){"use strict";function y(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(d,"__esModule",{value:!0});var T=function(){function u(f,o){var l=[],E=!0,p=!1,R=void 0;try{for(var P,M=f[Symbol.iterator]();!(E=(P=M.next()).done)&&(l.push(P.value),!o||l.length!==o);E=!0);}catch(F){p=!0,R=F}finally{try{!E&&M.return&&M.return()}finally{if(p)throw R}}return l}return function(f,o){if(Array.isArray(f))return f;if(Symbol.iterator in Object(f))return u(f,o);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=b(0),S=y(I),O=b(11),A=b(4),g=y(A),_=b(12),L=y(_),x=b(2),v=y(x),m=b(22),s=y(m),e=b(58),i=y(e),t=b(59),r=y(t),a=b(64),n=y(a),h={},c=function u(f){var o=arguments;typeof f=="string"?u.hasOwnProperty(f)?S.default.setTimeout(function(){o=Array.prototype.splice.call(o,1),u[f].apply(null,o)},0):g.default.warn("`"+f+"` is an unknown task"):typeof f=="function"?S.default.setTimeout(function(){f(u)},0):g.default.warn("`"+f+"` is invalid.")};c.loaded=v.default.now(),c.NAME="mux-embed",c.VERSION="4.8.0",c.API_VERSION="2.1",c.PLAYER_TRACKED=!1,c.monitor=function(u,f){return(0,i.default)(c,u,f)},c.destroyMonitor=function(u){var f=(0,O.findMediaElement)(u),o=T(f,1),l=o[0];l&&l.mux&&typeof l.mux.destroy=="function"?l.mux.destroy():g.default.error("A video element monitor for `"+u+"` has not been initialized via `mux.monitor`.")},c.addHLSJS=function(u,f){var o=(0,O.getMuxPlayerId)(u);h[o]?h[o].addHLSJS(f):g.default.error("A monitor for `"+o+"` has not been initialized.")},c.addDashJS=function(u,f){var o=(0,O.getMuxPlayerId)(u);h[o]?h[o].addDashJS(f):g.default.error("A monitor for `"+o+"` has not been initialized.")},c.removeHLSJS=function(u){var f=(0,O.getMuxPlayerId)(u);h[f]?h[f].removeHLSJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},c.removeDashJS=function(u){var f=(0,O.getMuxPlayerId)(u);h[f]?h[f].removeDashJS():g.default.error("A monitor for `"+f+"` has not been initialized.")},c.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 o=(0,O.getMuxPlayerId)(u);h[o]=new s.default(c,o,f)},c.emit=function(u,f,o){var l=(0,O.getMuxPlayerId)(u);h[l]?(h[l].emit(f,o),f==="destroy"&&delete h[l]):g.default.error("A monitor for `"+l+"` has not been initialized.")},S.default!==void 0&&typeof S.default.addEventListener=="function"&&S.default.addEventListener("pagehide",function(u){u.persisted||(c.WINDOW_UNLOADING=!0)},!1),c.checkDoNotTrack=L.default,c.log=g.default,c.utils=r.default,c.events=n.default,d.default=c},function(D,d){var b;b=function(){return this}();try{b=b||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(b=window)}D.exports=b},function(D,d,b){var y,T;(function(I,S){"use strict";y=S,(T=typeof y=="function"?y.call(d,b,d,D):y)!==void 0&&(D.exports=T)})(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 S(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function O(r){return r==="debug"&&(r="log"),typeof console!==v&&(r==="trace"&&m?S:console[r]!==void 0?I(console,r):console.log!==void 0?I(console,"log"):x)}function A(r,a){for(var n=0;n<s.length;n++){var h=s[n];this[h]=n<r?x:this.methodFactory(h,r,a)}this.log=this.debug}function g(r,a,n){return function(){typeof console!==v&&(A.call(this,a,n),this[r].apply(this,arguments))}}function _(r,a,n){return O(r)||g.apply(this,arguments)}function L(r,a,n){function h(p){var R=(s[p]||"silent").toUpperCase();if(typeof window!==v&&l){try{return void(window.localStorage[l]=R)}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+R+";"}catch{}}}function c(){var p;if(typeof window!==v&&l){try{p=window.localStorage[l]}catch{}if(typeof p===v)try{var R=window.document.cookie,P=R.indexOf(encodeURIComponent(l)+"=");P!==-1&&(p=/^([^;]+)/.exec(R.slice(P))[1])}catch{}return o.levels[p]===void 0&&(p=void 0),p}}function u(){if(typeof window!==v&&l){try{return void window.localStorage.removeItem(l)}catch{}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var f,o=this;a=a==null?"WARN":a;var l="loglevel";typeof r=="string"?l+=":"+r:typeof r=="symbol"&&(l=void 0),o.name=r,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=n||_,o.getLevel=function(){return f},o.setLevel=function(p,R){if(typeof p=="string"&&o.levels[p.toUpperCase()]!==void 0&&(p=o.levels[p.toUpperCase()]),!(typeof p=="number"&&p>=0&&p<=o.levels.SILENT))throw"log.setLevel() called with invalid level: "+p;if(f=p,R!==!1&&h(p),A.call(o,p,r),typeof console===v&&p<o.levels.SILENT)return"No console available for logging"},o.setDefaultLevel=function(p){a=p,c()||o.setLevel(p,!1)},o.resetLevel=function(){o.setLevel(a,!1),u()},o.enableAll=function(p){o.setLevel(o.levels.TRACE,p)},o.disableAll=function(p){o.setLevel(o.levels.SILENT,p)};var E=c();E==null&&(E=a),o.setLevel(E,!1)}var x=function(){},v="undefined",m=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(D,d,b){"use strict";function y(Z){return Z&&Z.__esModule?Z:{default:Z}}Object.defineProperty(d,"__esModule",{value:!0});var T=function(){function Z(q,$){var ue=[],ie=!0,de=!1,he=void 0;try{for(var ye,Se=q[Symbol.iterator]();!(ie=(ye=Se.next()).done)&&(ue.push(ye.value),!$||ue.length!==$);ie=!0);}catch(fe){de=!0,he=fe}finally{try{!ie&&Se.return&&Se.return()}finally{if(de)throw he}}return ue}return function(q,$){if(Array.isArray(q))return q;if(Symbol.iterator in Object(q))return Z(q,$);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=b(4),S=y(I),O=b(1),A=y(O),g=b(6),_=b(5),L=b(0),x=y(L),v=b(13),m=y(v),s=b(3),e=y(s),i=b(23),t=b(24),r=b(25),a=y(r),n=b(26),h=y(n),c=b(27),u=y(c),f=b(28),o=y(f),l=b(29),E=y(l),p=b(30),R=y(p),P=b(31),M=y(P),F=b(32),w=y(F),C=b(33),B=y(C),k=b(34),N=y(k),W=b(35),j=y(W),K=b(36),V=y(K),Y=b(37),Q=y(Y),z=b(38),re=y(z),X=b(39),J=y(X),se=b(57),ne=y(se),pe=["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"],ee=function(Z,q,$){var ue=this;this.DOM_CONTENT_LOADED_EVENT_END=m.default.domContentLoadedEventEnd(),this.NAVIGATION_START=m.default.navigationStart();var ie={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(fe){return fe}};this.mux=Z,this.id=q,$=(0,A.default)(ie,$),$.data=$.data||{},$.data.property_key&&($.data.env_key=$.data.property_key,delete $.data.property_key),S.default.setLevel($.debug?"debug":"warn"),this.getPlayheadTime=$.getPlayheadTime,this.getStateData=$.getStateData||function(){},this.getAdData=$.getAdData||function(){},this.minimumRebufferDuration=$.minimumRebufferDuration,this.sustainedRebufferThreshold=$.sustainedRebufferThreshold,this.playbackHeartbeatTime=$.playbackHeartbeatTime,this.disableRebufferTracking=$.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=$.errorTranslator,this.playbackEventDispatcher=new J.default(Z,$.data.env_key,$),this.data={player_instance_id:(0,g.generateUUID)(),mux_sample_rate:$.sampleRate,beacon_domain:$.beaconCollectionDomain?$.beaconCollectionDomain:$.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(fe,ve){ve=(0,A.default)({viewer_time:this.mux.utils.now()},ve),this.oldEmit(fe,ve)};var de=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(fe,ve){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,A.default)(this.data,ve),this._initializeViewData(),this.one("play",de),this.one("adbreakstart",de)});var he=function(fe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",fe)}.bind(this);if(this.on("videochange",function(fe,ve){he(ve)}),this.on("programchange",function(fe,ve){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."),he((0,A.default)(ve,{view_program_changed:!0})),de(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(fe,ve){this.currentFragmentPDT=ve.currentFragmentPDT,this.currentFragmentStart=ve.currentFragmentStart}),this.on("destroy",this.destroy),x.default!==void 0&&typeof x.default.addEventListener=="function"&&typeof x.default.removeEventListener=="function"){var ye=function(fe){fe.persisted||ue.destroy()};x.default.addEventListener("pagehide",ye,!1),this.on("destroy",function(){x.default.removeEventListener("pagehide",ye)})}this.on("playerready",function(fe,ve){(0,A.default)(this.data,ve)}),pe.forEach(function(fe){ue.on(fe,function(ve,_e){fe.indexOf("ad")!==0&&this._updateStateData(),(0,A.default)(this.data,_e),this._sanitizeData()}),ue.on("after"+fe,function(){(fe!=="error"||this.viewErrored)&&this.send(fe)})}),this.on("viewend",function(fe,ve){(0,A.default)(ue.data,ve)});var Se=function(fe){var ve=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=ve-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",Se),u.default.apply(this),re.default.apply(this),j.default.apply(this),R.default.apply(this),h.default.apply(this),N.default.apply(this),o.default.apply(this),E.default.apply(this),V.default.apply(this),M.default.apply(this),w.default.apply(this),B.default.apply(this),Q.default.apply(this),ne.default.apply(this),$.hlsjs&&this.addHLSJS($),$.dashjs&&this.addDashJS($),this.emit("viewinit",$.data)};(0,A.default)(ee.prototype,a.default.prototype),(0,A.default)(ee.prototype,R.default.prototype),(0,A.default)(ee.prototype,j.default.prototype),(0,A.default)(ee.prototype,h.default.prototype),(0,A.default)(ee.prototype,o.default.prototype),(0,A.default)(ee.prototype,E.default.prototype),(0,A.default)(ee.prototype,V.default.prototype),(0,A.default)(ee.prototype,w.default.prototype),(0,A.default)(ee.prototype,B.default.prototype),ee.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),x.default.clearTimeout(this._heartBeatTimeout))},ee.prototype.send=function(Z){var q=(0,A.default)({},this.data),$=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(q.video_source_is_live===void 0&&(q.player_source_duration===1/0||q.video_source_duration===1/0?q.video_source_is_live=!0:(q.player_source_duration>0||q.video_source_duration>0)&&(q.video_source_is_live=!1)),q.video_source_is_live||$.forEach(function(ye){q[ye]=void 0}),q.video_source_url=q.video_source_url||q.player_source_url,q.video_source_url){var ue=(0,_.extractHostnameAndDomain)(q.video_source_url),ie=T(ue,2),de=ie[0],he=ie[1];q.video_source_domain=he,q.video_source_hostname=de}delete q.ad_request_id,this.playbackEventDispatcher.send(Z,q),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},ee.prototype._updateStateData=function(){(0,A.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},ee.prototype._sanitizeData=function(){var Z=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(q){var $=parseInt(Z.data[q],10);Z.data[q]=isNaN($)?void 0:$}),["player_source_url","video_source_url"].forEach(function(q){if(Z.data[q]){var $=Z.data[q].toLowerCase();$.indexOf("data:")!==0&&$.indexOf("blob:")!==0||(Z.data[q]="MSE style URL")}})},ee.prototype._resetVideoData=function(Z,q){var $=this;Object.keys(this.data).forEach(function(ue){ue.indexOf("video_")===0&&delete $.data[ue]})},ee.prototype._resetViewData=function(){var Z=this;Object.keys(this.data).forEach(function(q){q.indexOf("view_")===0&&delete Z.data[q]}),this.data.view_sequence_number=1},ee.prototype._resetErrorData=function(Z,q){delete this.data.player_error_code,delete this.data.player_error_message},ee.prototype._initializeViewData=function(){var Z=this,q=this.data.view_id=(0,g.generateUUID)(),$=function(){q===Z.data.view_id&&(0,e.default)(Z.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",$):$()},ee.prototype._restartHeartBeat=function(){var Z=this;x.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=x.default.setTimeout(function(){Z.data.player_is_paused||Z.emit("hb")},1e4))},ee.prototype.addHLSJS=function(Z){return Z.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=Z.hlsjs,void(0,i.monitorHlsJs)(this.mux,this.id,Z.hlsjs,{},Z.Hls||x.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},ee.prototype.removeHLSJS=function(){this.hlsjs&&((0,i.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},ee.prototype.addDashJS=function(Z){return Z.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=Z.dashjs,void(0,t.monitorDashJS)(this.mux,this.id,Z.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},ee.prototype.removeDashJS=function(){this.dashjs&&((0,t.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},d.default=ee},function(D,d,b){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(d,"__esModule",{value:!0}),d.stopMonitoringHlsJs=d.monitorHlsJs=void 0;var T=b(7),I=y(T),S=b(13),O=y(S),A=b(5),g=b(14),_=y(g),L=function(s){if(!s)return{};var e=O.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)}},x=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(!O.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)},c=function(P,M){var F=M.levels,w=M.audioTracks,C=M.url,B=M.stats,k=M.networkDetails,N=M.sessionData,W={},j={},K={};K=(0,_.default)(N),F.forEach(function(X,J){W[J]={width:X.width,height:X.height,bitrate:X.bitrate,attrs:X.attrs}}),w.forEach(function(X,J){j[J]={name:X.name,language:X.lang,bitrate:X.bitrate}});var V=L(B),Y=V.bytesLoaded,Q=V.requestStart,z=V.responseStart,re=V.responseEnd;K.request_event_type=P,K.request_bytes_loaded=Y,K.request_start=Q,K.request_response_start=z,K.request_response_end=re,K.request_type="manifest",K.request_hostname=(0,A.extractHostname)(C),K.request_response_headers=x(k),K.request_rendition_lists={media:W,audio:j,video:{}},h("requestcompleted",K)};i.on(t.Events.MANIFEST_LOADED,c);var u=function(P,M){var F=M.details,w=M.level,C=M.networkDetails,B=M.stats,k=L(B),N=k.bytesLoaded,W=k.requestStart,j=k.responseStart,K=k.responseEnd,V=F.fragments[F.fragments.length-1],Y=n(V)+a(V.duration);h("requestcompleted",{request_event_type:P,request_bytes_loaded:N,request_start:W,request_response_start:j,request_response_end:K,request_current_level:w,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:x(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(Y)?void 0:Y})};i.on(t.Events.LEVEL_LOADED,u);var f=function(P,M){var F=M.details,w=M.networkDetails,C=M.stats,B=L(C),k=B.bytesLoaded,N=B.requestStart,W=B.responseStart,j=B.responseEnd;h("requestcompleted",{request_event_type:P,request_bytes_loaded:k,request_start:N,request_response_start:W,request_response_end:j,request_type:"manifest",request_hostname:(0,A.extractHostname)(F.url),request_response_headers:x(w)})};i.on(t.Events.AUDIO_TRACK_LOADED,f);var o=function(P,M){var F=M.stats,w=M.networkDetails,C=M.frag,B=L(F),k=B.bytesLoaded,N=B.requestStart,W=B.responseStart,j=B.responseEnd,K={request_event_type:P,request_bytes_loaded:k,request_start:N,request_response_start:W,request_response_end:j,request_hostname:w?(0,A.extractHostname)(w.responseURL):void 0,request_response_headers:x(w),request_media_duration:C.duration};C.type==="main"?(K.request_type="media",K.request_current_level=C.level,K.request_video_width=(i.levels[C.level]||{}).width,K.request_video_height=(i.levels[C.level]||{}).height):K.request_type=C.type,h("requestcompleted",K)};i.on(t.Events.FRAG_LOADED,o);var l=function(P,M){var F=M.frag,w=F.start,C=n(F),B={currentFragmentPDT:C,currentFragmentStart:a(w)};h("fragmentchange",B)};i.on(t.Events.FRAG_CHANGED,l);var E=function(P,M){var F=M.type,w=M.details,C=M.response,B=M.fatal,k=M.context,N=M.frag;if(w===t.ErrorDetails.MANIFEST_LOAD_ERROR||w===t.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===t.ErrorDetails.FRAG_LOAD_ERROR||w===t.ErrorDetails.FRAG_LOAD_TIMEOUT||w===t.ErrorDetails.LEVEL_LOAD_ERROR||w===t.ErrorDetails.LEVEL_LOAD_TIMEOUT){var W=N&&N.url||k&&k.url||"";h("requestfailed",{request_error:w,request_url:W,request_hostname:(0,A.extractHostname)(W),request_type:w===t.ErrorDetails.FRAG_LOAD_ERROR||w===t.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}B&&h("error",{player_error_code:F,player_error_message:w})};i.on(t.Events.ERROR,E);var p=function(P,M){var F=M.frag,w=F&&F._url||"";h("requestcanceled",{request_cancel:P,request_url:w,request_type:"media",request_hostname:(0,A.extractHostname)(w)})};i.on(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,p);var R=function(P,M){var F=M.level,w=i.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?h("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};i.on(t.Events.LEVEL_SWITCHED,R),i._stopMuxMonitor=function(){i.off(t.Events.MANIFEST_LOADED,c),i.off(t.Events.LEVEL_LOADED,u),i.off(t.Events.AUDIO_TRACK_LOADED,f),i.off(t.Events.FRAG_LOADED,o),i.off(t.Events.FRAG_CHANGED,l),i.off(t.Events.ERROR,E),i.off(t.Events.FRAG_LOAD_EMERGENCY_ABORTED,p),i.off(t.Events.LEVEL_SWITCHED,R),i.off(t.Events.DESTROYING,i._stopMuxMonitor),delete i._stopMuxMonitor},i.on(t.Events.DESTROYING,i._stopMuxMonitor)},m=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};d.monitorHlsJs=v,d.stopMonitoringHlsJs=m},function(D,d,b){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(d,"__esModule",{value:!0}),d.stopMonitoringDashJS=d.monitorDashJS=void 0;var T=b(0),I=y(T),S=b(7),O=y(S),A=b(5),g=function(v,m){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,A.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,c=typeof m.getMetricsFor=="function"?m.getMetricsFor(e.mediaType).HttpList:m.getDashMetrics().getHttpRequests(e.mediaType),u=void 0;return c.length>0&&(u=(0,O.default)(c[c.length-1]._responseHeaders||"")),{requestStart:r,requestResponseStart:a,requestResponseEnd:n,requestBytesLoaded:t,requestResponseHeaders:u,requestMediaDuration:h,requestHostname:i}},_=function(v,m){var s=m.getQualityFor(v),e=m.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,m,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(o,l){return v.emit(m,o,l)},t=function(o){var l=o.type,E=o.data,p=E||{},R=p.url;i("requestcompleted",{request_event_type:l,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,A.extractHostname)(R)})};s.on("manifestLoaded",t);var r={},a=function(o){var l=o.type,E=o.fragmentModel,p=o.chunk,R=p||{},P=R.mediaInfo,M=P||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(Y,Q){C[Q]={},C[Q].width=Y.width,C[Q].height=Y.height,C[Q].bitrate=Y.bandwidth,C[Q].attrs={}}),F==="video"?r.video=C:F==="audio"?r.audio=C:r.media=C;var B=g(E,s),k=B.requestStart,N=B.requestResponseStart,W=B.requestResponseEnd,j=B.requestResponseHeaders,K=B.requestMediaDuration,V=B.requestHostname;i("requestcompleted",{request_event_type:l,request_start:k,request_response_start:N,request_response_end:W,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:j,request_hostname:V,request_media_duration:K,request_rendition_lists:r})};s.on("initFragmentLoaded",a);var n=function(o){var l=o.type,E=o.fragmentModel,p=o.chunk,R=p||{},P=R.mediaInfo,M=R.start,F=P||{},w=F.type,C=g(E,s),B=C.requestStart,k=C.requestResponseStart,N=C.requestResponseEnd,W=C.requestBytesLoaded,j=C.requestResponseHeaders,K=C.requestMediaDuration,V=C.requestHostname,Y=_(w,s),Q=Y.currentLevel,z=Y.renditionWidth,re=Y.renditionHeight,X=Y.renditionBitrate;i("requestcompleted",{request_event_type:l,request_start:B,request_response_start:k,request_response_end:N,request_bytes_loaded:W,request_type:w,request_response_headers:j,request_hostname:V,request_media_start_time:M,request_media_duration:K,request_current_level:Q,request_labeled_bitrate:X,request_video_width:z,request_video_height:re})};s.on("mediaFragmentLoaded",n);var h={video:void 0,audio:void 0,totalBitrate:void 0},c=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 o=h.video.bitrate;return h.audio&&typeof h.audio.bitrate=="number"&&(o+=h.audio.bitrate),o!==h.totalBitrate?(h.totalBitrate=o,{video_source_bitrate:o,video_source_height:h.video.height,video_source_width:h.video.width}):void 0}},u=function(o,l,E){if(typeof o.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",o);var p=o.mediaType;if(p==="audio"||p==="video"){var R=s.getBitrateInfoListFor(p).find(function(M){return M.qualityIndex===o.newQuality});if(!R||typeof R.bitrate!="number")return void e.warn("missing bitrate info for "+p);h[p]=R;var P=c();P&&i("renditionchange",P)}};s.on("qualityChangeRendered",u);var f=function(o){var l=o.error,E=o.event;E=E||{};var p=E.request||{},R=I.default.event&&I.default.event.currentTarget||{};i("requestfailed",{request_error:l+"_"+E.id+"_"+p.type,request_url:E.url,request_hostname:(0,A.extractHostname)(E.url),request_type:p.mediaType,request_error_code:R.status,request_error_type:R.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}},x=function(v){v&&typeof v._stopMuxMonitor=="function"&&v._stopMuxMonitor()};d.monitorDashJS=L,d.stopMonitoringDashJS=x},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=function(){},T=0;y.prototype.on=function(I,S,O){return S._eventEmitterGuid=S._eventEmitterGuid||++T,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],O&&(S=S.bind(O)),this._listeners[I].push(S),S},y.prototype.off=function(I,S){var O=this._listeners&&this._listeners[I];O&&O.forEach(function(A,g){A._eventEmitterGuid===S._eventEmitterGuid&&O.splice(g,1)})},y.prototype.one=function(I,S,O){var A=this;S._eventEmitterGuid=S._eventEmitterGuid||++T;var g=function _(){A.off(I,_),S.apply(O||this,arguments)};g._eventEmitterGuid=S._eventEmitterGuid,this.on(I,g)},y.prototype.emit=function(I,S){var O=this;if(this._listeners){S=S||{};var A=this._listeners["before*"]||[],g=this._listeners[I]||[],_=this._listeners["after"+I]||[],L=function(x,v){x=x.slice(),x.forEach(function(m){m.call(O,{type:I},v)})};L(A,S),L(g,S),L(_,S)}},d.default=y},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(0),T=function(S){return S&&S.__esModule?S:{default:S}}(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(S,O){this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:O.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var S=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=T.default.setInterval(function(){S.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},d.default=I},function(D,d,b){"use strict";function y(){var T=this;this.on("viewinit",function(){T.viewErrored=!1}),this.on("error",function(){try{var I=T.errorTranslator({player_error_code:T.data.player_error_code,player_error_message:T.data.player_error_message});I?(T.data.player_error_code=I.player_error_code,T.data.player_error_message=I.player_error_message,T.viewErrored=!0):(delete T.data.player_error_code,delete T.data.player_error_message)}catch(S){T.mux.log.warn("Exception in error translator callback.",S),T.viewErrored=!0}})}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(3),T=function(S){return S&&S.__esModule?S:{default:S}}(y),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(S,O){var A=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=A),(0,T.default)(this.data,"view_watch_time",A-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=A},I.prototype._clearWatchTimeState=function(S,O){this._updateWatchTime(S,O),this._watchTimeTrackerLastCheckedTime=null},d.default=I},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(3),T=function(S){return S&&S.__esModule?S:{default:S}}(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 S=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&S>this._playbackTimeTrackerLastPlayheadPosition){var O=S-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&(0,T.default)(this.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=S},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},d.default=I},function(D,d,b){"use strict";Object.defineProperty(d,"__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(T,I){var S=this,O=function(){S.currentFragmentPDT&&S.currentFragmentStart&&(S.data.player_program_time=S.currentFragmentPDT+S.data.player_playhead_time-S.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,O(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var A=this.getPlayheadTime();A!==void 0&&(this.data.player_playhead_time=A,O(),this._updateMaxPlayheadPosition())}},d.default=y},function(D,d,b){"use strict";function y(){var S=this;if(!this.disableRebufferTracking){var O=void 0,A=function(){if(O){var g=S.data.viewer_time-O;(0,I.default)(S.data,"view_rebuffer_duration",g),O=S.data.viewer_time}S.data.view_watch_time>=0&&S.data.view_rebuffer_count>0&&(S.data.view_rebuffer_frequency=S.data.view_rebuffer_count/S.data.view_watch_time,S.data.view_rebuffer_percentage=S.data.view_rebuffer_duration/S.data.view_watch_time)};this.on("playbackheartbeat",function(){return A()}),this.on("rebufferstart",function(){O||((0,I.default)(S.data,"view_rebuffer_count",1),O=S.data.viewer_time,S.one("rebufferend",function(){A(),O=void 0}))})}}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y;var T=b(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(2),T=function(S){return S&&S.__esModule?S:{default:S}}(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:T.default.now()})}))};I.prototype._checkIfRebuffering=function(S,O){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(S,O):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(O.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(S,O,!0):(O.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=O.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(S){this._lastCheckedTime=S,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=S},I.prototype._cleanupRebufferTracker=function(S,O){var A=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:O.viewer_time});else{if(this._lastCheckedTime===null)return;var g=this.data.player_playhead_time-this._lastPlayheadTime,_=O.viewer_time-this._lastPlayheadTimeUpdatedTime;g>0&&_-g>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+_-g}))}A?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()},d.default=I},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(2),T=function(S){return S&&S.__esModule?S:{default:S}}(y),I=function(){this.on("viewinit",function(){var S=this.data,O=S.view_id;if(!S.view_program_changed){var A=function(g,_){var L=_.viewer_time;g.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(L||T.default.now(),O):g.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(L||T.default.now(),O)};this.one("playing",A),this.one("adplaying",A),this.one("viewend",function(){this.off("playing",A),this.off("adplaying",A)})}})};I.prototype.calculateTimeToFirstFrame=function(S,O){O===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:S}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},d.default=I},function(D,d,b){"use strict";function y(){var S=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var O=["pause","rebufferstart","seeking","error","adbreakstart","hb"],A=["playing","hb"];O.forEach(function(g){S.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 _=this.data.player_playhead_time-this._lastPlayheadPosition;if(_<0)return void(this._lastPlayheadPosition=-1);var L=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),x=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,x),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",_),(0,I.default)(this.data,"view_total_upscaling",x*_),(0,I.default)(this.data,"view_total_downscaling",v*_)}this._lastPlayheadPosition=-1})}),A.forEach(function(g){S.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(d,"__esModule",{value:!0}),d.default=y;var T=b(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(D,d,b){"use strict";function y(L){return L&&L.__esModule?L:{default:L}}function T(){this.isSeeking=!1,this.on("seeking",function(L,x){(0,_.default)(this.data,x),this._lastSeekingTime=S.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var L=this._lastSeekingTime||S.default.now(),x=S.default.now()-L;(0,A.default)(this.data,"view_seek_count",1),(0,A.default)(this.data,"view_seek_duration",x);var v=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(v,x)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(d,"__esModule",{value:!0}),d.default=T;var I=b(2),S=y(I),O=b(3),A=y(O),g=b(1),_=y(g)},function(D,d,b){"use strict";function y(v){return v&&v.__esModule?v:{default:v}}Object.defineProperty(d,"__esModule",{value:!0});var T=function(){function v(m,s){var e=[],i=!0,t=!1,r=void 0;try{for(var a,n=m[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(m,s){if(Array.isArray(m))return m;if(Symbol.iterator in Object(m))return v(m,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=b(3),S=y(I),O=b(5),A=b(1),g=y(A),_=function(v,m){v.push(m),v.sort(function(s,e){return s.viewer_time-e.viewer_time})},L=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],x=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 m=function(){v.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",m),this.on("playing",m),this.on("viewend",m),this.on("adrequest",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),_(this._adRequests,e),(0,S.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,S.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(s,e){e=(0,g.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),_(this._adResponses,e);var i=this.findAdRequest(e.ad_request_id);i&&(0,S.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,S.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(s,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};x.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},x.prototype.findAdRequest=function(v){for(var m=0;m<this._adRequests.length;m++)if(this._adRequests[m].ad_request_id===v)return this._adRequests[m]},x.prototype._updateAdData=function(v,m){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&m.ad_tag_url){var s=(0,O.extractHostnameAndDomain)(m.ad_tag_url),e=T(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&&m.ad_asset_url){var r=(0,O.extractHostnameAndDomain)(m.ad_asset_url),a=T(r,2),n=a[0],h=a[1];this.data.view_preroll_ad_asset_domain=h,this.data.view_preroll_ad_asset_hostname=n}}},d.default=x},function(D,d,b){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}function T(){var g=this,_=void 0,L=void 0,x=function(){g.disableRebufferTracking||((0,A.default)(g.data,"view_waiting_rebuffer_count",1),_=S.default.now(),L=window.setInterval(function(){if(_){var i=S.default.now();(0,A.default)(g.data,"view_waiting_rebuffer_duration",i-_),_=i}},250))},v=function(){g.disableRebufferTracking||_&&((0,A.default)(g.data,"view_waiting_rebuffer_duration",S.default.now()-_),_=!1,window.clearInterval(L))},m=!1,s=function(){m=!0},e=function(){m=!1,v()};this.on("waiting",function(){m&&x()}),this.on("playing",function(){v(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(d,"__esModule",{value:!0}),d.default=T;var I=b(2),S=y(I),O=b(3),A=y(O)},function(D,d,b){"use strict";function y(L){return L&&L.__esModule?L:{default:L}}function T(){var L=this;this.one("playbackheartbeat",g),this.on("playbackheartbeatend",function(){L.off("before*",_),L.one("playbackheartbeat",g)})}Object.defineProperty(d,"__esModule",{value:!0}),d.default=T;var I=b(1),S=y(I),O=b(2),A=y(O),g=function(){this.lastWallClockTime=A.default.now(),this.on("before*",_)},_=function(L){var x=A.default.now(),v=this.lastWallClockTime;this.lastWallClockTime=x,x-v>3e4&&(this.emit("devicesleep",{viewer_time:v}),(0,S.default)(this.data,{viewer_time:v}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:x}),(0,S.default)(this.data,{viewer_time:x}),this.send("devicewake"))}},function(D,d,b){"use strict";function y(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(d,"__esModule",{value:!0});var T=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},I=b(0),S=y(I),O=b(40),A=b(4),g=y(A),_=b(53),L=y(_),x=b(12),v=y(x),m=b(54),s=y(m),e=b(17),i=y(e),t=b(55),r=y(t),a=b(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"],c=["viewstart","error","ended","viewend"],u=function(l,E){var p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=l,this.envKey=E,this.eventQueue=new r.default((0,L.default)(E,p)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=p.sampleRate,this.disableCookies=p.disableCookies,this.respectDoNotTrack=p.respectDoNotTrack;var R=p.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:R.name,viewer_application_version:R.version,viewer_application_engine:R.layout,viewer_device_name:R.product,viewer_device_category:"",viewer_device_manufacturer:R.manufacturer,viewer_os_family:R.os&&R.os.family,viewer_os_architecture:R.os&&R.os.architecture,viewer_os_version:R.os&&R.os.version};var P=(0,s.default)();P&&(this.pageLevelData=(0,n.default)(this.pageLevelData,{viewer_connection_type:P})),S.default!==void 0&&S.default.location&&S.default.location.href&&(this.pageLevelData.page_url=S.default.location.href),this.viewerData=this.disableCookies?{}:(0,O.getAndUpdateViewerData)()};u.prototype.send=function(l,E){if(l){if(this.respectDoNotTrack&&(0,v.default)())return g.default.info("Not sending `"+l+"` because Do Not Track is enabled");if(!E||(E===void 0?"undefined":T(E))!=="object")return g.default.error("A data object was expected in send() but was not provided");var p=this.disableCookies?{}:(0,O.getAndUpdateSessionData)(),R={};(0,n.default)(R,this.pageLevelData),(0,n.default)(R,E),(0,n.default)(R,p),(0,n.default)(R,this.viewerData),R.event=l,R.env_key=this.envKey,R.user_id&&(R.viewer_user_id=R.user_id,delete R.user_id);var P=R.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(l,R),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",l,R,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",l,R,F),!this.rateLimited){if(g.default.info("Sending event",l,R,F),this.rateLimited=!this.eventQueue.queueEvent(l,F),this.mux.WINDOW_UNLOADING&&l==="viewend")this.eventQueue.destroy(!0);else if((c.indexOf(l)>=0||this.mux.WINDOW_VISIBLE===!1&&l==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return R.event="eventrateexceeded",F=(0,i.default)(R),this.eventQueue.queueEvent(R.event,F),g.default.error("Beaconing disabled due to rate limit.")}}},u.prototype.destroy=function(){this.eventQueue.destroy(!1)};var f=function(l,E,p,R){return!(!l||E.indexOf("request_")!==0)&&(E==="request_response_headers"||(p===void 0?"undefined":T(p))!=="object"||(R===void 0?"undefined":T(R))!=="object"||Object.keys(p||{}).length!==Object.keys(R||{}).length)},o=function(l,E){return l==="renditionchange"&&E.indexOf("video_source_")===0};u.prototype._deduplicateBeaconData=function(l,E){var p=this,R={},P=E.view_id;if(!P||l==="viewstart"||l==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)R=(0,n.default)({},E),P&&(this.previousBeaconData=R),P&&l==="viewend"&&(this.previousBeaconData=null);else{var M=l.indexOf("request")===0;Object.keys(E).forEach(function(F){var w=E[F];(w!==p.previousBeaconData[F]||h.indexOf(F)>-1||f(M,F,w,p.previousBeaconData[F])||o(l,F))&&(R[F]=w,p.previousBeaconData[F]=w)})}return R},d.default=u},function(D,d,b){"use strict";function y(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(d,"__esModule",{value:!0}),d.getAndUpdateSessionData=d.getAndUpdateViewerData=void 0;var T=b(15),I=y(T),S=b(52),O=y(S),A=b(6),g=b(2),_=y(g),L=function(){var s=void 0;try{s=I.default.parse(O.default.get("muxData")||"")}catch{s={}}return s},x=function(s){try{O.default.set("muxData",I.default.stringify(s),{expires:7300})}catch{}},v=function(){var s=L();return s.mux_viewer_id=s.mux_viewer_id||(0,A.generateUUID)(),s.msn=s.msn||Math.random(),x(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},m=function(){var s=L(),e=_.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,A.generateUUID)(),s.sst=e),s.sex=e+15e5,x(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};d.getAndUpdateViewerData=v,d.getAndUpdateSessionData=m},function(D,d,b){"use strict";var y=b(42),T=b(16),I=b(10),S=Object.prototype.hasOwnProperty,O={brackets:function(r){return r+"[]"},comma:"comma",indices:function(r,a){return r+"["+a+"]"},repeat:function(r){return r}},A=Array.isArray,g=String.prototype.split,_=Array.prototype.push,L=function(r,a){_.apply(r,A(a)?a:[a])},x=Date.prototype.toISOString,v=I.default,m={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:T.encode,encodeValuesOnly:!1,format:v,formatter:I.formatters[v],indices:!1,serializeDate:function(r){return x.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,c,u,f,o,l,E,p,R,P,M,F,w){for(var C=a,B=w,k=0,N=!1;(B=B.get(e))!==void 0&&!N;){var W=B.get(a);if(k+=1,W!==void 0){if(W===k)throw new RangeError("Cyclic object value");N=!0}B.get(e)===void 0&&(k=0)}if(typeof o=="function"?C=o(n,C):C instanceof Date?C=p(C):h==="comma"&&A(C)&&(C=T.maybeMap(C,function(ee){return ee instanceof Date?p(ee):ee})),C===null){if(c)return f&&!M?f(n,m.encoder,F,"key",R):n;C=""}if(s(C)||T.isBuffer(C)){if(f){var j=M?n:f(n,m.encoder,F,"key",R);if(h==="comma"&&M){for(var K=g.call(String(C),","),V="",Y=0;Y<K.length;++Y)V+=(Y===0?"":",")+P(f(K[Y],m.encoder,F,"value",R));return[P(j)+"="+V]}return[P(j)+"="+P(f(C,m.encoder,F,"value",R))]}return[P(n)+"="+P(String(C))]}var Q=[];if(C===void 0)return Q;var z;if(h==="comma"&&A(C))z=[{value:C.length>0?C.join(",")||null:void 0}];else if(A(o))z=o;else{var re=Object.keys(C);z=l?re.sort(l):re}for(var X=0;X<z.length;++X){var J=z[X],se=typeof J=="object"&&J.value!==void 0?J.value:C[J];if(!u||se!==null){var ne=A(C)?typeof h=="function"?h(n,J):n:n+(E?"."+J:"["+J+"]");w.set(a,k);var pe=y();pe.set(e,w),L(Q,r(se,ne,h,c,u,f,o,l,E,p,R,P,M,F,pe))}}return Q},t=function(r){if(!r)return m;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||m.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(!S.call(I.formatters,r.format))throw new TypeError("Unknown format option provided.");n=r.format}var h=I.formatters[n],c=m.filter;return(typeof r.filter=="function"||A(r.filter))&&(c=r.filter),{addQueryPrefix:typeof r.addQueryPrefix=="boolean"?r.addQueryPrefix:m.addQueryPrefix,allowDots:r.allowDots===void 0?m.allowDots:!!r.allowDots,charset:a,charsetSentinel:typeof r.charsetSentinel=="boolean"?r.charsetSentinel:m.charsetSentinel,delimiter:r.delimiter===void 0?m.delimiter:r.delimiter,encode:typeof r.encode=="boolean"?r.encode:m.encode,encoder:typeof r.encoder=="function"?r.encoder:m.encoder,encodeValuesOnly:typeof r.encodeValuesOnly=="boolean"?r.encodeValuesOnly:m.encodeValuesOnly,filter:c,format:n,formatter:h,serializeDate:typeof r.serializeDate=="function"?r.serializeDate:m.serializeDate,skipNulls:typeof r.skipNulls=="boolean"?r.skipNulls:m.skipNulls,sort:typeof r.sort=="function"?r.sort:null,strictNullHandling:typeof r.strictNullHandling=="boolean"?r.strictNullHandling:m.strictNullHandling}};D.exports=function(r,a){var n,h,c=r,u=t(a);typeof u.filter=="function"?(h=u.filter,c=h("",c)):A(u.filter)&&(h=u.filter,n=h);var f=[];if(typeof c!="object"||c===null)return"";var o;o=a&&a.arrayFormat in O?a.arrayFormat:a&&"indices"in a?a.indices?"indices":"repeat":"indices";var l=O[o];n||(n=Object.keys(c)),u.sort&&n.sort(u.sort);for(var E=y(),p=0;p<n.length;++p){var R=n[p];u.skipNulls&&c[R]===null||L(f,i(c[R],R,l,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(D,d,b){"use strict";var y=b(8),T=b(47),I=b(49),S=y("%TypeError%"),O=y("%WeakMap%",!0),A=y("%Map%",!0),g=T("WeakMap.prototype.get",!0),_=T("WeakMap.prototype.set",!0),L=T("WeakMap.prototype.has",!0),x=T("Map.prototype.get",!0),v=T("Map.prototype.set",!0),m=T("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)};D.exports=function(){var r,a,n,h={assert:function(c){if(!h.has(c))throw new S("Side channel does not contain "+I(c))},get:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(r)return g(r,c)}else if(A){if(a)return x(a,c)}else if(n)return e(n,c)},has:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(r)return L(r,c)}else if(A){if(a)return m(a,c)}else if(n)return t(n,c);return!1},set:function(c,u){O&&c&&(typeof c=="object"||typeof c=="function")?(r||(r=new O),_(r,c,u)):A?(a||(a=new A),v(a,c,u)):(n||(n={key:{},next:null}),i(n,c,u))}};return h}},function(D,d,b){"use strict";var y=typeof Symbol!="undefined"&&Symbol,T=b(44);D.exports=function(){return typeof y=="function"&&typeof Symbol=="function"&&typeof y("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&T()}},function(D,d,b){"use strict";D.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var y={},T=Symbol("test"),I=Object(T);if(typeof T=="string"||Object.prototype.toString.call(T)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;y[T]=42;for(T 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 S=Object.getOwnPropertySymbols(y);if(S.length!==1||S[0]!==T||!Object.prototype.propertyIsEnumerable.call(y,T))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var O=Object.getOwnPropertyDescriptor(y,T);if(O.value!==42||O.enumerable!==!0)return!1}return!0}},function(D,d,b){"use strict";var y=Array.prototype.slice,T=Object.prototype.toString;D.exports=function(I){var S=this;if(typeof S!="function"||T.call(S)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+S);for(var O,A=y.call(arguments,1),g=function(){if(this instanceof O){var m=S.apply(this,A.concat(y.call(arguments)));return Object(m)===m?m:this}return S.apply(I,A.concat(y.call(arguments)))},_=Math.max(0,S.length-A.length),L=[],x=0;x<_;x++)L.push("$"+x);if(O=Function("binder","return function ("+L.join(",")+"){ return binder.apply(this,arguments); }")(g),S.prototype){var v=function(){};v.prototype=S.prototype,O.prototype=new v,v.prototype=null}return O}},function(D,d,b){"use strict";var y=b(9);D.exports=y.call(Function.call,Object.prototype.hasOwnProperty)},function(D,d,b){"use strict";var y=b(8),T=b(48),I=T(y("String.prototype.indexOf"));D.exports=function(S,O){var A=y(S,!!O);return typeof A=="function"&&I(S,".prototype.")>-1?T(A):A}},function(D,d,b){"use strict";var y=b(9),T=b(8),I=T("%Function.prototype.apply%"),S=T("%Function.prototype.call%"),O=T("%Reflect.apply%",!0)||y.call(S,I),A=T("%Object.getOwnPropertyDescriptor%",!0),g=T("%Object.defineProperty%",!0),_=T("%Math.max%");if(g)try{g({},"a",{value:1})}catch{g=null}D.exports=function(x){var v=O(y,S,arguments);return A&&g&&A(v,"length").configurable&&g(v,"length",{value:1+_(0,x.length-(arguments.length-1))}),v};var L=function(){return O(y,I,arguments)};g?g(D.exports,"apply",{value:L}):D.exports.apply=L},function(D,d,b){function y(G,H){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||ue.call(/e/,H))return H;var oe=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var le=G<0?-ye(-G):ye(G);if(le!==G){var Ee=String(le),Te=ee.call(H,Ee.length+1);return Z.call(Ee,oe,"$&_")+"."+Z.call(Z.call(Te,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Z.call(H,oe,"$&_")}function T(G,H,oe){var le=(oe.quoteStyle||H)==="double"?'"':"'";return le+G+le}function I(G){return Z.call(String(G),/"/g,""")}function S(G){return!(e(G)!=="[object Array]"||ge&&typeof G=="object"&&ge in G)}function O(G){return!(e(G)!=="[object Date]"||ge&&typeof G=="object"&&ge in G)}function A(G){return!(e(G)!=="[object RegExp]"||ge&&typeof G=="object"&&ge in G)}function g(G){return!(e(G)!=="[object Error]"||ge&&typeof G=="object"&&ge in G)}function _(G){return!(e(G)!=="[object String]"||ge&&typeof G=="object"&&ge in G)}function L(G){return!(e(G)!=="[object Number]"||ge&&typeof G=="object"&&ge in G)}function x(G){return!(e(G)!=="[object Boolean]"||ge&&typeof G=="object"&&ge in G)}function v(G){if(_e)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!ve)return!1;try{return ve.call(G),!0}catch{}return!1}function m(G){if(!G||typeof G!="object"||!Se)return!1;try{return Se.call(G),!0}catch{}return!1}function s(G,H){return Me.call(G,H)}function e(G){return se.call(G)}function i(G){if(G.name)return G.name;var H=pe.call(ne.call(G),/^function\s*([\w$]+)/);return H?H[1]:null}function t(G,H){if(G.indexOf)return G.indexOf(H);for(var oe=0,le=G.length;oe<le;oe++)if(G[oe]===H)return oe;return-1}function r(G){if(!B||!G||typeof G!="object")return!1;try{B.call(G);try{j.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function a(G){if(!Y||!G||typeof G!="object")return!1;try{Y.call(G,Y);try{z.call(G,z)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function n(G){if(!X||!G||typeof G!="object")return!1;try{return X.call(G),!0}catch{}return!1}function h(G){if(!j||!G||typeof G!="object")return!1;try{j.call(G);try{B.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function c(G){if(!z||!G||typeof G!="object")return!1;try{z.call(G,z);try{Y.call(G,Y)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function u(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function f(G,H){if(G.length>H.maxStringLength){var oe=G.length-H.maxStringLength,le="... "+oe+" more character"+(oe>1?"s":"");return f(ee.call(G,0,H.maxStringLength),H)+le}return T(Z.call(Z.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,o),"single",H)}function o(G){var H=G.charCodeAt(0),oe={8:"b",9:"t",10:"n",12:"f",13:"r"}[H];return oe?"\\"+oe:"\\x"+(H<16?"0":"")+q.call(H.toString(16))}function l(G){return"Object("+G+")"}function E(G){return G+" { ? }"}function p(G,H,oe,le){return G+" ("+H+") {"+(le?M(oe,le):de.call(oe,", "))+"}"}function R(G){for(var H=0;H<G.length;H++)if(t(G[H],`
|
|
2
|
-
`)>=0)return!1;return!0}function
|
|
3
|
-
`+
|
|
4
|
-
`+H.prev}function F(G,H){var oe=S(G),le=[];if(oe){le.length=G.length;for(var Ee=0;Ee<G.length;Ee++)le[Ee]=s(G,Ee)?H(G[Ee],G):""}var Te,ae=typeof fe=="function"?fe(G):[];if(_e){Te={};for(var be=0;be<ae.length;be++)Te["$"+ae[be]]=ae[be]}for(var Le in G)s(G,Le)&&(oe&&String(Number(Le))===Le&&Le<G.length||_e&&Te["$"+Le]instanceof Symbol||(ue.call(/[^\w$]/,Le)?le.push(H(Le,G)+": "+H(G[Le],G)):le.push(Le+": "+H(G[Le],G))));if(typeof fe=="function")for(var Ce=0;Ce<ae.length;Ce++)Pe.call(G,ae[Ce])&&le.push("["+H(ae[Ce])+"]: "+H(G[ae[Ce]],G));return le}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,B=w&&C&&typeof C.get=="function"?C.get:null,k=w&&Map.prototype.forEach,N=typeof Set=="function"&&Set.prototype,W=Object.getOwnPropertyDescriptor&&N?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,j=N&&W&&typeof W.get=="function"?W.get:null,K=N&&Set.prototype.forEach,V=typeof WeakMap=="function"&&WeakMap.prototype,Y=V?WeakMap.prototype.has:null,Q=typeof WeakSet=="function"&&WeakSet.prototype,z=Q?WeakSet.prototype.has:null,re=typeof WeakRef=="function"&&WeakRef.prototype,X=re?WeakRef.prototype.deref:null,J=Boolean.prototype.valueOf,se=Object.prototype.toString,ne=Function.prototype.toString,pe=String.prototype.match,ee=String.prototype.slice,Z=String.prototype.replace,q=String.prototype.toUpperCase,$=String.prototype.toLowerCase,ue=RegExp.prototype.test,ie=Array.prototype.concat,de=Array.prototype.join,he=Array.prototype.slice,ye=Math.floor,Se=typeof BigInt=="function"?BigInt.prototype.valueOf:null,fe=Object.getOwnPropertySymbols,ve=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,_e=typeof Symbol=="function"&&typeof Symbol.iterator=="object",ge=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===_e?"object":"symbol")?Symbol.toStringTag:null,Pe=Object.prototype.propertyIsEnumerable,xe=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),Oe=b(50).custom,Ie=Oe&&v(Oe)?Oe:null;D.exports=function G(H,oe,le,Ee){function Te(je,nt,hr){if(nt&&(Ee=he.call(Ee),Ee.push(nt)),hr){var Nt={depth:ae.depth};return s(ae,"quoteStyle")&&(Nt.quoteStyle=ae.quoteStyle),G(je,Nt,le+1,Ee)}return G(je,ae,le+1,Ee)}var ae=oe||{};if(s(ae,"quoteStyle")&&ae.quoteStyle!=="single"&&ae.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(ae,"maxStringLength")&&(typeof ae.maxStringLength=="number"?ae.maxStringLength<0&&ae.maxStringLength!==1/0:ae.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var be=!s(ae,"customInspect")||ae.customInspect;if(typeof be!="boolean"&&be!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(ae,"indent")&&ae.indent!==null&&ae.indent!==" "&&!(parseInt(ae.indent,10)===ae.indent&&ae.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(ae,"numericSeparator")&&typeof ae.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Le=ae.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,ae);if(typeof H=="number"){if(H===0)return 1/0/H>0?"0":"-0";var Ce=String(H);return Le?y(H,Ce):Ce}if(typeof H=="bigint"){var Ve=String(H)+"n";return Le?y(H,Ve):Ve}var tt=ae.depth===void 0?5:ae.depth;if(le===void 0&&(le=0),le>=tt&&tt>0&&typeof H=="object")return S(H)?"[Array]":"[Object]";var Be=P(ae,le);if(Ee===void 0)Ee=[];else if(t(Ee,H)>=0)return"[Circular]";if(typeof H=="function"){var rt=i(H),Ne=F(H,Te);return"[Function"+(rt?": "+rt:" (anonymous)")+"]"+(Ne.length>0?" { "+de.call(Ne,", ")+" }":"")}if(v(H)){var Ye=_e?Z.call(String(H),/^(Symbol\(.*\))_[^)]*$/,"$1"):ve.call(H);return typeof H!="object"||_e?Ye:l(Ye)}if(u(H)){for(var Ke="<"+$.call(String(H.nodeName)),Xe=H.attributes||[],it=0;it<Xe.length;it++)Ke+=" "+Xe[it].name+"="+T(I(Xe[it].value),"double",ae);return Ke+=">",H.childNodes&&H.childNodes.length&&(Ke+="..."),Ke+="</"+$.call(String(H.nodeName))+">"}if(S(H)){if(H.length===0)return"[]";var vt=F(H,Te);return Be&&!R(vt)?"["+M(vt,Be)+"]":"[ "+de.call(vt,", ")+" ]"}if(g(H)){var gt=F(H,Te);return"cause"in H&&!Pe.call(H,"cause")?"{ ["+String(H)+"] "+de.call(ie.call("[cause]: "+Te(H.cause),gt),", ")+" }":gt.length===0?"["+String(H)+"]":"{ ["+String(H)+"] "+de.call(gt,", ")+" }"}if(typeof H=="object"&&be){if(Ie&&typeof H[Ie]=="function")return H[Ie]();if(be!=="symbol"&&typeof H.inspect=="function")return H.inspect()}if(r(H)){var wt=[];return k.call(H,function(je,nt){wt.push(Te(nt,H,!0)+" => "+Te(je,H))}),p("Map",B.call(H),wt,Be)}if(h(H)){var Bt=[];return K.call(H,function(je){Bt.push(Te(je,H))}),p("Set",j.call(H),Bt,Be)}if(a(H))return E("WeakMap");if(c(H))return E("WeakSet");if(n(H))return E("WeakRef");if(L(H))return l(Te(Number(H)));if(m(H))return l(Te(Se.call(H)));if(x(H))return l(J.call(H));if(_(H))return l(Te(String(H)));if(!O(H)&&!A(H)){var mt=F(H,Te),kt=xe?xe(H)===Object.prototype:H instanceof Object||H.constructor===Object,pt=H instanceof Object?"":"null prototype",Ut=!kt&&ge&&Object(H)===H&&ge in H?ee.call(e(H),8,-1):pt?"Object":"",cr=kt||typeof H.constructor!="function"?"":H.constructor.name?H.constructor.name+" ":"",yt=cr+(Ut||pt?"["+de.call(ie.call([],Ut||[],pt||[]),": ")+"] ":"");return mt.length===0?yt+"{}":Be?yt+"{"+M(mt,Be)+"}":yt+"{ "+de.call(mt,", ")+" }"}return String(H)};var Me=Object.prototype.hasOwnProperty||function(G){return G in this}},function(D,d){},function(D,d,b){"use strict";var y=b(16),T=Object.prototype.hasOwnProperty,I=Array.isArray,S={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:y.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},O=function(v){return v.replace(/&#(\d+);/g,function(m,s){return String.fromCharCode(parseInt(s,10))})},A=function(v,m){return v&&typeof v=="string"&&m.comma&&v.indexOf(",")>-1?v.split(","):v},g=function(v,m){var s,e={},i=m.ignoreQueryPrefix?v.replace(/^\?/,""):v,t=m.parameterLimit===1/0?void 0:m.parameterLimit,r=i.split(m.delimiter,t),a=-1,n=m.charset;if(m.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,c,u=r[s],f=u.indexOf("]="),o=f===-1?u.indexOf("="):f+1;o===-1?(h=m.decoder(u,S.decoder,n,"key"),c=m.strictNullHandling?null:""):(h=m.decoder(u.slice(0,o),S.decoder,n,"key"),c=y.maybeMap(A(u.slice(o+1),m),function(l){return m.decoder(l,S.decoder,n,"value")})),c&&m.interpretNumericEntities&&n==="iso-8859-1"&&(c=O(c)),u.indexOf("[]=")>-1&&(c=I(c)?[c]:c),T.call(e,h)?e[h]=y.combine(e[h],c):e[h]=c}return e},_=function(v,m,s,e){for(var i=e?m:A(m,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,m,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&&T.call(Object.prototype,n)&&!s.allowPrototypes)return;h.push(n)}for(var c=0;s.depth>0&&(a=r.exec(i))!==null&&c<s.depth;){if(c+=1,!s.plainObjects&&T.call(Object.prototype,a[1].slice(1,-1))&&!s.allowPrototypes)return;h.push(a[1])}return a&&h.push("["+i.slice(a.index)+"]"),_(h,m,s,e)}},x=function(v){if(!v)return S;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 m=v.charset===void 0?S.charset:v.charset;return{allowDots:v.allowDots===void 0?S.allowDots:!!v.allowDots,allowPrototypes:typeof v.allowPrototypes=="boolean"?v.allowPrototypes:S.allowPrototypes,allowSparse:typeof v.allowSparse=="boolean"?v.allowSparse:S.allowSparse,arrayLimit:typeof v.arrayLimit=="number"?v.arrayLimit:S.arrayLimit,charset:m,charsetSentinel:typeof v.charsetSentinel=="boolean"?v.charsetSentinel:S.charsetSentinel,comma:typeof v.comma=="boolean"?v.comma:S.comma,decoder:typeof v.decoder=="function"?v.decoder:S.decoder,delimiter:typeof v.delimiter=="string"||y.isRegExp(v.delimiter)?v.delimiter:S.delimiter,depth:typeof v.depth=="number"||v.depth===!1?+v.depth:S.depth,ignoreQueryPrefix:v.ignoreQueryPrefix===!0,interpretNumericEntities:typeof v.interpretNumericEntities=="boolean"?v.interpretNumericEntities:S.interpretNumericEntities,parameterLimit:typeof v.parameterLimit=="number"?v.parameterLimit:S.parameterLimit,parseArrays:v.parseArrays!==!1,plainObjects:typeof v.plainObjects=="boolean"?v.plainObjects:S.plainObjects,strictNullHandling:typeof v.strictNullHandling=="boolean"?v.strictNullHandling:S.strictNullHandling}};D.exports=function(v,m){var s=x(m);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(D,d,b){"use strict";var y,T,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S};(function(S){var O=!1;if(y=S,(T=typeof y=="function"?y.call(d,b,d,D):y)!==void 0&&(D.exports=T),O=!0,I(d)==="object"&&(D.exports=S(),O=!0),!O){var A=window.Cookies,g=window.Cookies=S();g.noConflict=function(){return window.Cookies=A,g}}})(function(){function S(A){function g(_,L,x){var v;if(typeof document!="undefined"){if(arguments.length>1){if(x=O({path:"/"},g.defaults,x),typeof x.expires=="number"){var m=new Date;m.setMilliseconds(m.getMilliseconds()+864e5*x.expires),x.expires=m}try{v=JSON.stringify(L),/^[\{\[]/.test(v)&&(L=v)}catch{}return L=A.write?A.write(L,_):encodeURIComponent(String(L)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),_=encodeURIComponent(String(_)),_=_.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),_=_.replace(/[\(\)]/g,escape),document.cookie=[_,"=",L,x.expires?"; expires="+x.expires.toUTCString():"",x.path?"; path="+x.path:"",x.domain?"; domain="+x.domain:"",x.secure?"; secure":""].join("")}_||(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=A.read?A.read(r,a):A(r,a)||r.replace(e,decodeURIComponent),this.json)try{r=JSON.parse(r)}catch{}if(_===a){v=r;break}_||(v[a]=r)}catch{}}return v}}return g.set=g,g.get=function(_){return g.call(g,_)},g.getJSON=function(){return g.apply({json:!0},[].slice.call(arguments))},g.defaults={},g.remove=function(_,L){g(_,"",O(L,{expires:-1}))},g.withConverter=S,g}var O=function(){for(var A=0,g={};A<arguments.length;A++){var _=arguments[A];for(var L in _)g[L]=_[L]}return g};return S(function(){})})},function(D,d,b){"use strict";function y(T,I){var S=I.beaconCollectionDomain,O=I.beaconDomain;if(S)return"https://"+S;T=T||"inferred";var A=O||"litix.io";return T.match(/^[a-z0-9]+$/)?"https://"+T+"."+A:"https://img.litix.io/a.gif"}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y},function(D,d,b){"use strict";Object.defineProperty(d,"__esModule",{value:!0});var y=b(0),T=function(O){return O&&O.__esModule?O:{default:O}}(y),I=function(){var O=void 0;switch(S()){case"cellular":O="cellular";break;case"ethernet":O="wired";break;case"wifi":O="wifi";break;case void 0:break;default:O="other"}return O},S=function(){var O=T.default.navigator,A=O&&(O.connection||O.mozConnection||O.webkitConnection);return A&&A.type};d.default=I},function(D,d,b){"use strict";function y(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(d,"__esModule",{value:!0});var T=b(0),I=y(T),S=b(4),O=y(S),A=b(56),g=y(A),_=b(1),L=y(_),x=b(17),v=y(x),m=b(2),s=y(m),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 c=new I.default.XMLHttpRequest;c.open("POST",this._beaconUrl),c.setRequestHeader("Content-Type","application/json"),c.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,O.default.info("Error sending beacon: "+a.status),O.default.info(a.responseText)):r._failureCount=0,r._roundTripTime=s.default.now()-c,r._postInFlight=!1)},a.open("POST",this._beaconUrl),a.setRequestHeader("Content-Type","application/json");var h=this._createPayload(n),c=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})},d.default=t},function(D,d,b){"use strict";function y(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(d,"__esModule",{value:!0});var T=b(15),I=y(T),S=b(0),O=y(S),A={};A.send=function(g,_){function L(){x.src=m+(v?"&rc="+v:"")}var x=new Image,v=0,m=g+"?"+I.default.stringify(_);return x.addEventListener("error",function(){v>3||O.default.setTimeout(function(){v++,L()},5e3*v)}),L(),x},d.default=A},function(D,d,b){"use strict";function y(){function T(m,s){var e=s.request_start,i=s.request_response_start,t=s.request_response_end,r=s.request_bytes_loaded;_++;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++,A+=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=A/g*8e3,this.data.view_request_count=_,a>0&&(O+=a,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,a),this.data.view_average_request_latency=O/L)}}function I(m,s){_++,x++,this.data.view_request_count=_,this.data.view_request_failed_count=x}function S(m,s){_++,v++,this.data.view_request_count=_,this.data.view_request_canceled_count=v}var O=0,A=0,g=0,_=0,L=0,x=0,v=0;this.on("requestcompleted",T),this.on("requestfailed",I),this.on("requestcanceled",S)}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y},function(D,d,b){"use strict";function y(L,x,v){var m=(0,A.findMediaElement)(x),s=I(m,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,O.default)(h,v),v.data=(0,O.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&&T(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 c=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=c,e.mux.swapElement=c,e.mux.emit=c,e.mux.addHLSJS=c,e.mux.addDashJS=c,e.mux.removeHLSJS=c,e.mux.removeDashJS=c,e.mux.deleted=!0,L.emit(i,"destroy")},e.mux.swapElement=function(u){var f=(0,A.findMediaElement)(u),o=I(f,3),l=o[0],E=o[1],p=o[2];return l?p!=="video"&&p!=="audio"?L.log.error("The element of `"+E+"` was not a media element."):(l.muxId=e.muxId,delete e.muxId,l.mux=l.mux||{},l.mux.listeners=(0,O.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(l.mux.listeners).forEach(function(R){e.removeEventListener(R,l.mux.listeners[R],!1),l.addEventListener(R,l.mux.listeners[R],!1)}),l.mux.swapElement=e.mux.swapElement,l.mux.destroy=e.mux.destroy,delete e.mux,void(e=l)):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=_[e.error.code]||e.error.message}L.emit(i,u,f)},e.addEventListener(u,e.mux.listeners[u],!1))})}Object.defineProperty(d,"__esModule",{value:!0});var T=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(L){return typeof L}:function(L){return L&&typeof Symbol=="function"&&L.constructor===Symbol&&L!==Symbol.prototype?"symbol":typeof L},I=function(){function L(x,v){var m=[],s=!0,e=!1,i=void 0;try{for(var t,r=x[Symbol.iterator]();!(s=(t=r.next()).done)&&(m.push(t.value),!v||m.length!==v);s=!0);}catch(a){e=!0,i=a}finally{try{!s&&r.return&&r.return()}finally{if(e)throw i}}return m}return function(x,v){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return L(x,v);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();d.default=y;var S=b(1),O=function(L){return L&&L.__esModule?L:{default:L}}(S),A=b(11),g=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],_={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(D,d,b){"use strict";function y(h){return h&&h.__esModule?h:{default:h}}Object.defineProperty(d,"__esModule",{value:!0});var T=b(60),I=y(T),S=b(3),O=y(S),A=b(61),g=y(A),_=b(62),L=y(_),x=b(1),v=y(x),m=b(7),s=y(m),e=b(5),i=b(2),t=y(i),r=b(63),a=y(r),n={};n.safeCall=I.default,n.safeIncrement=O.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,d.default=n},function(D,d,b){"use strict";function y(S,O,A,g){var _=g;if(S&&typeof S[O]=="function")try{_=S[O].apply(S,A)}catch(L){I.default.info("safeCall error",L)}return _}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y;var T=b(4),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(D,d,b){"use strict";function y(O,A){if(O&&A&&I.default&&typeof I.default.getComputedStyle=="function"){var g=void 0;return S&&S.has(O)&&(g=S.get(O)),g||(g=I.default.getComputedStyle(O,null),S&&S.set(O,g)),g.getPropertyValue(A)}}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y;var T=b(0),I=function(O){return O&&O.__esModule?O:{default:O}}(T),S=void 0;I.default&&I.default.WeakMap&&(S=new WeakMap)},function(D,d,b){"use strict";function y(T){return Math.floor(1e3*T)}Object.defineProperty(d,"__esModule",{value:!0}),d.default=y},function(D,d,b){"use strict";function y(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(d,"__esModule",{value:!0});var T=b(1),I=y(T),S=b(14),O=y(S),A={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},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
|
-
`);
|
|
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?x(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 A.TARGET_DURATION:if(!isFinite(h)||h<0)return;this.manifest.targetDuration=h,this.setHoldBack();break;case A.PART_INF:_(this.manifest,a),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case A.SERVER_CONTROL:_(this.manifest,a),this.setHoldBack();break;case A.INF:h===0?this.currentUri.duration=.01:h>0&&(this.currentUri.duration=h);break;case A.PROGRAM_DATE_TIME:var c=h,u=new Date(c);this.manifest.dateTimeString||(this.manifest.dateTimeString=c,this.manifest.dateTimeObject=u),this.currentUri.dateTimeString=c,this.currentUri.dateTimeObject=u;break;case A.VERSION:_(this.manifest,a);break;case A.SESSION_DATA:var f=i(a[1]),o=(0,O.default)(f);(0,I.default)(this.manifest.sessionData,o)}},g.prototype.setHoldBack=function(){var t=this.manifest,r=t.serverControl,a=t.targetDuration,n=t.partTargetDuration;if(r){var h="holdBack",c="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(c)&&(r[c]=3*n),n&&r[c]<f&&(r[c]=f)}};var _=function(t,r){var a=L(r[0].replace("#EXT-X-","")),n=void 0;s(r[1])?(n={},n=(0,I.default)(m(r[1]),n)):n=x(r[1]),t[a]=n},L=function(t){return t.toLowerCase().replace(/-(\w)/g,function(r){return r[1].toUpperCase()})},x=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])]=x(a[1])),r},m=function(t){for(var r=t.split(","),a={},n=0;r.length>n;n++){var h=r[n],c=v(h);a=(0,I.default)(c,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 c=n.replace(/['"]+/g,"").split("="),u=0;u<c.length;u++)c[u]==="DATA-ID"&&(r["DATA-ID"]=c[1-u]),c[u]==="VALUE"&&(r.VALUE=c[1-u])}),{data:r}}};d.default=g},function(D,d,b){"use strict";Object.defineProperty(d,"__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"};d.default=y}])})})()});var ut=Kt((Je,xt)=>{typeof window!="undefined"&&function(D,d){typeof Je=="object"&&typeof xt=="object"?xt.exports=d():typeof define=="function"&&define.amd?define([],d):typeof Je=="object"?Je.Hls=d():D.Hls=d()}(Je,function(){return function(U){var D={};function d(b){if(D[b])return D[b].exports;var y=D[b]={i:b,l:!1,exports:{}};return U[b].call(y.exports,y,y.exports,d),y.l=!0,y.exports}return d.m=U,d.c=D,d.d=function(b,y,T){d.o(b,y)||Object.defineProperty(b,y,{enumerable:!0,get:T})},d.r=function(b){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(b,"__esModule",{value:!0})},d.t=function(b,y){if(y&1&&(b=d(b)),y&8||y&4&&typeof b=="object"&&b&&b.__esModule)return b;var T=Object.create(null);if(d.r(T),Object.defineProperty(T,"default",{enumerable:!0,value:b}),y&2&&typeof b!="string")for(var I in b)d.d(T,I,function(S){return b[S]}.bind(null,I));return T},d.n=function(b){var y=b&&b.__esModule?function(){return b.default}:function(){return b};return d.d(y,"a",y),y},d.o=function(b,y){return Object.prototype.hasOwnProperty.call(b,y)},d.p="/dist/",d(d.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(U,D,d){"use strict";var b=Object.prototype.hasOwnProperty,y="~";function T(){}Object.create&&(T.prototype=Object.create(null),new T().__proto__||(y=!1));function I(g,_,L){this.fn=g,this.context=_,this.once=L||!1}function S(g,_,L,x,v){if(typeof L!="function")throw new TypeError("The listener must be a function");var m=new I(L,x||g,v),s=y?y+_:_;return g._events[s]?g._events[s].fn?g._events[s]=[g._events[s],m]:g._events[s].push(m):(g._events[s]=m,g._eventsCount++),g}function O(g,_){--g._eventsCount==0?g._events=new T:delete g._events[_]}function A(){this._events=new T,this._eventsCount=0}A.prototype.eventNames=function(){var _=[],L,x;if(this._eventsCount===0)return _;for(x in L=this._events)b.call(L,x)&&_.push(y?x.slice(1):x);return Object.getOwnPropertySymbols?_.concat(Object.getOwnPropertySymbols(L)):_},A.prototype.listeners=function(_){var L=y?y+_:_,x=this._events[L];if(!x)return[];if(x.fn)return[x.fn];for(var v=0,m=x.length,s=new Array(m);v<m;v++)s[v]=x[v].fn;return s},A.prototype.listenerCount=function(_){var L=y?y+_:_,x=this._events[L];return x?x.fn?1:x.length:0},A.prototype.emit=function(_,L,x,v,m,s){var e=y?y+_:_;if(!this._events[e])return!1;var i=this._events[e],t=arguments.length,r,a;if(i.fn){switch(i.once&&this.removeListener(_,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,x),!0;case 4:return i.fn.call(i.context,L,x,v),!0;case 5:return i.fn.call(i.context,L,x,v,m),!0;case 6:return i.fn.call(i.context,L,x,v,m,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(_,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,x);break;case 4:i[a].fn.call(i[a].context,L,x,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},A.prototype.on=function(_,L,x){return S(this,_,L,x,!1)},A.prototype.once=function(_,L,x){return S(this,_,L,x,!0)},A.prototype.removeListener=function(_,L,x,v){var m=y?y+_:_;if(!this._events[m])return this;if(!L)return O(this,m),this;var s=this._events[m];if(s.fn)s.fn===L&&(!v||s.once)&&(!x||s.context===x)&&O(this,m);else{for(var e=0,i=[],t=s.length;e<t;e++)(s[e].fn!==L||v&&!s[e].once||x&&s[e].context!==x)&&i.push(s[e]);i.length?this._events[m]=i.length===1?i[0]:i:O(this,m)}return this},A.prototype.removeAllListeners=function(_){var L;return _?(L=y?y+_:_,this._events[L]&&O(this,L)):(this._events=new T,this._eventsCount=0),this},A.prototype.off=A.prototype.removeListener,A.prototype.addListener=A.prototype.on,A.prefixed=y,A.EventEmitter=A,U.exports=A},"./node_modules/url-toolkit/src/url-toolkit.js":function(U,D,d){(function(b){var y=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,T=/^([^\/?#]*)([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,S=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(A,g,_){if(_=_||{},A=A.trim(),g=g.trim(),!g){if(!_.alwaysNormalize)return A;var L=O.parseURL(A);if(!L)throw new Error("Error trying to parse base URL.");return L.path=O.normalizePath(L.path),O.buildURLFromParts(L)}var x=O.parseURL(g);if(!x)throw new Error("Error trying to parse relative URL.");if(x.scheme)return _.alwaysNormalize?(x.path=O.normalizePath(x.path),O.buildURLFromParts(x)):g;var v=O.parseURL(A);if(!v)throw new Error("Error trying to parse base URL.");if(!v.netLoc&&v.path&&v.path[0]!=="/"){var m=T.exec(v.path);v.netLoc=m[1],v.path=m[2]}v.netLoc&&!v.path&&(v.path="/");var s={scheme:v.scheme,netLoc:x.netLoc,path:null,params:x.params,query:x.query,fragment:x.fragment};if(!x.netLoc&&(s.netLoc=v.netLoc,x.path[0]!=="/"))if(!x.path)s.path=v.path,x.params||(s.params=v.params,x.query||(s.query=v.query));else{var e=v.path,i=e.substring(0,e.lastIndexOf("/")+1)+x.path;s.path=O.normalizePath(i)}return s.path===null&&(s.path=_.alwaysNormalize?O.normalizePath(x.path):x.path),O.buildURLFromParts(s)},parseURL:function(A){var g=y.exec(A);return g?{scheme:g[1]||"",netLoc:g[2]||"",path:g[3]||"",params:g[4]||"",query:g[5]||"",fragment:g[6]||""}:null},normalizePath:function(A){for(A=A.split("").reverse().join("").replace(I,"");A.length!==(A=A.replace(S,"")).length;);return A.split("").reverse().join("")},buildURLFromParts:function(A){return A.scheme+A.netLoc+A.path+A.params+A.query+A.fragment}};U.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(U,D,d){function b(_){var L={};function x(m){if(L[m])return L[m].exports;var s=L[m]={i:m,l:!1,exports:{}};return _[m].call(s.exports,s,s.exports,x),s.l=!0,s.exports}x.m=_,x.c=L,x.i=function(m){return m},x.d=function(m,s,e){x.o(m,s)||Object.defineProperty(m,s,{configurable:!1,enumerable:!0,get:e})},x.r=function(m){Object.defineProperty(m,"__esModule",{value:!0})},x.n=function(m){var s=m&&m.__esModule?function(){return m.default}:function(){return m};return x.d(s,"a",s),s},x.o=function(m,s){return Object.prototype.hasOwnProperty.call(m,s)},x.p="/",x.oe=function(m){throw console.error(m),m};var v=x(x.s=ENTRY_MODULE);return v.default||v}var y="[\\.|\\-|\\+|\\w|/|@]+",T="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+y+").*?\\)";function I(_){return(_+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function S(_){return!isNaN(1*_)}function O(_,L,x){var v={};v[x]=[];var m=L.toString(),s=m.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)+T,"g"),t;t=i.exec(m);)t[3]!=="dll-reference"&&v[x].push(t[3]);for(i=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+y+'))"\\)\\)'+T,"g");t=i.exec(m);)_[t[2]]||(v[x].push(t[1]),_[t[2]]=d(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++)S(v[r[a]][n])&&(v[r[a]][n]=1*v[r[a]][n]);return v}function A(_){var L=Object.keys(_);return L.reduce(function(x,v){return x||_[v].length>0},!1)}function g(_,L){for(var x={main:[L]},v={main:[]},m={main:{}};A(x);)for(var s=Object.keys(x),e=0;e<s.length;e++){var i=s[e],t=x[i],r=t.pop();if(m[i]=m[i]||{},!(m[i][r]||!_[i][r])){m[i][r]=!0,v[i]=v[i]||[],v[i].push(r);for(var a=O(_,_[i][r],i),n=Object.keys(a),h=0;h<n.length;h++)x[n[h]]=x[n[h]]||[],x[n[h]]=x[n[h]].concat(a[n[h]])}}return v}U.exports=function(_,L){L=L||{};var x={main:d.m},v=L.all?{main:Object.keys(x.main)}:g(x,_),m="";Object.keys(v).filter(function(r){return r!=="main"}).forEach(function(r){for(var a=0;v[r][a];)a++;v[r].push(a),x[r][a]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",m=m+"var "+r+" = ("+b.toString().replace("ENTRY_MODULE",JSON.stringify(a))+")({"+v[r].map(function(n){return""+JSON.stringify(n)+": "+x[r][n].toString()}).join(",")+`});
|
|
7
|
-
`}),
|
|
8
|
-
Current BW estimate: `+(Object(
|
|
9
|
-
Estimated load time for current fragment: `+
|
|
1
|
+
"use strict";(()=>{var br=Object.create;var Lt=Object.defineProperty;var Rr=Object.getOwnPropertyDescriptor;var Pr=Object.getOwnPropertyNames;var Ir=Object.getPrototypeOf,Mr=Object.prototype.hasOwnProperty;var Cr=(B,P,n)=>P in B?Lt(B,P,{enumerable:!0,configurable:!0,writable:!0,value:n}):B[P]=n;var Qt=(B,P)=>()=>(P||B((P={exports:{}}).exports,P),P.exports);var Fr=(B,P,n,R)=>{if(P&&typeof P=="object"||typeof P=="function")for(let p of Pr(P))!Mr.call(B,p)&&p!==n&&Lt(B,p,{get:()=>P[p],enumerable:!(R=Rr(P,p))||R.enumerable});return B};var yt=(B,P,n)=>(n=B!=null?br(Ir(B)):{},Fr(P||!B||!B.__esModule?Lt(n,"default",{value:B,enumerable:!0}):n,B));var at=(B,P,n)=>(Cr(B,typeof P!="symbol"?P+"":P,n),n),Ot=(B,P,n)=>{if(!P.has(B))throw TypeError("Cannot "+n)};var ne=(B,P,n)=>(Ot(B,P,"read from private field"),n?n.call(B):P.get(B)),ve=(B,P,n)=>{if(P.has(B))throw TypeError("Cannot add the same private member more than once");P instanceof WeakSet?P.add(B):P.set(B,n)},Pe=(B,P,n,R)=>(Ot(B,P,"write to private field"),R?R.call(B,n):P.set(B,n),n);var be=(B,P,n)=>(Ot(B,P,"access private method"),n);var Zt=Qt((Et,It)=>{(function(){var B=!1;(function(P,n){typeof Et=="object"&&typeof It=="object"?It.exports=n():typeof B=="function"&&B.amd?B("mux",[],n):typeof Et=="object"?Et.mux=n():P.mux=n()})(typeof self!="undefined"?self:this,function(){return function(P){function n(p){if(R[p])return R[p].exports;var T=R[p]={i:p,l:!1,exports:{}};return P[p].call(T.exports,T,T.exports,n),T.l=!0,T.exports}var R={};return n.m=P,n.c=R,n.d=function(p,T,I){n.o(p,T)||Object.defineProperty(p,T,{configurable:!1,enumerable:!0,get:I})},n.n=function(p){var T=p&&p.__esModule?function(){return p.default}:function(){return p};return n.d(T,"a",T),T},n.o=function(p,T){return Object.prototype.hasOwnProperty.call(p,T)},n.p="",n(n.s=18)}([function(P,n,R){(function(p){var T;T=typeof window!="undefined"?window:p!==void 0?p:typeof self!="undefined"?self:{},P.exports=T}).call(n,R(20))},function(P,n){function R(C,U,k){switch(k.length){case 0:return C.call(U);case 1:return C.call(U,k[0]);case 2:return C.call(U,k[0],k[1]);case 3:return C.call(U,k[0],k[1],k[2])}return C.apply(U,k)}function p(C,U){for(var k=-1,j=Array(C);++k<C;)j[k]=U(k);return j}function T(C,U){var k=F(C)||g(C)?p(C.length,String):[],j=k.length,N=!!j;for(var W in C)!U&&!l.call(C,W)||N&&(W=="length"||E(W,j))||k.push(W);return k}function I(C,U,k){var j=C[U];l.call(C,U)&&x(j,k)&&(k!==void 0||U in C)||(C[U]=k)}function S(C){if(!D(C))return L(C);var U=[];for(var k in Object(C))l.call(C,k)&&k!="constructor"&&U.push(k);return U}function O(C,U){return U=b(U===void 0?C.length-1:U,0),function(){for(var k=arguments,j=-1,N=b(k.length-U,0),W=Array(N);++j<N;)W[j]=k[U+j];j=-1;for(var Y=Array(U+1);++j<U;)Y[j]=k[j];return Y[U]=W,R(C,this,Y)}}function _(C,U,k,j){k||(k={});for(var N=-1,W=U.length;++N<W;){var Y=U[N],K=j?j(k[Y],C[Y],Y,k,C):void 0;I(k,Y,K===void 0?C[Y]:K)}return k}function E(C,U){return!!(U=U==null?t:U)&&(typeof C=="number"||h.test(C))&&C>-1&&C%1==0&&C<U}function A(C,U,k){if(!f(k))return!1;var j=typeof U;return!!(j=="number"?y(k)&&E(U,k.length):j=="string"&&U in k)&&x(k[U],C)}function D(C){var U=C&&C.constructor;return C===(typeof U=="function"&&U.prototype||d)}function x(C,U){return C===U||C!==C&&U!==U}function g(C){return s(C)&&l.call(C,"callee")&&(!m.call(C,"callee")||v.call(C)==u)}function y(C){return C!=null&&o(C.length)&&!e(C)}function s(C){return a(C)&&y(C)}function e(C){var U=f(C)?v.call(C):"";return U==c||U==r}function o(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=t}function f(C){var U=typeof C;return!!C&&(U=="object"||U=="function")}function a(C){return!!C&&typeof C=="object"}function i(C){return y(C)?T(C):S(C)}var t=9007199254740991,u="[object Arguments]",c="[object Function]",r="[object GeneratorFunction]",h=/^(?:0|[1-9]\d*)$/,d=Object.prototype,l=d.hasOwnProperty,v=d.toString,m=d.propertyIsEnumerable,L=function(C,U){return function(k){return C(U(k))}}(Object.keys,Object),b=Math.max,M=!m.call({valueOf:1},"valueOf"),F=Array.isArray,w=function(C){return O(function(U,k){var j=-1,N=k.length,W=N>1?k[N-1]:void 0,Y=N>2?k[2]:void 0;for(W=C.length>3&&typeof W=="function"?(N--,W):void 0,Y&&A(k[0],k[1],Y)&&(W=N<3?void 0:W,N=1),U=Object(U);++j<N;){var K=k[j];K&&C(U,K,j,W)}return U})}(function(C,U){if(M||D(U)||y(U))return void _(U,i(U),C);for(var k in U)l.call(U,k)&&I(C,k,U[k])});P.exports=w},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I={};I.now=function(){var S=T.default.performance,O=S&&S.timing;return O&&typeof O.navigationStart=="number"&&typeof S.now=="function"?O.navigationStart+S.now():Date.now()},n.default=I},function(P,n,R){"use strict";function p(T,I,S){S=S===void 0?1:S,T[I]=T[I]||0,T[I]+=S}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(21),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=T.default.methodFactory;T.default.methodFactory=function(S,O,_){var E=I(S,O,_);return function(){for(var A=["[mux]"],D=0;D<arguments.length;D++)A.push(arguments[D]);E.apply(void 0,A)}},T.default.setLevel(T.default.getLevel()),n.default=T.default},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(S){return I(S)[0]},T=function(S){return I(S)[1]},I=function(S){if(typeof S!="string"||S==="")return["localhost"];var O=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,_=S.match(O)||[],E=_[4],A=void 0;return E&&(A=(E.match(/[^\.]+\.[^\.]+$/)||[])[0]),[E,A]};n.extractHostnameAndDomain=I,n.extractHostname=p,n.extractDomain=T},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(I){var S=16*Math.random()|0;return(I==="x"?S:3&S|8).toString(16)})},T=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)};n.generateUUID=p,n.generateShortID=T},function(P,n,R){"use strict";function p(I){I=I||"";var S={};return I.trim().split(/[\r\n]+/).forEach(function(O){if(O){var _=O.split(": "),E=_.shift();E&&(T.indexOf(E.toLowerCase())>=0||E.toLowerCase().indexOf("x-litix-")===0)&&(S[E]=_.join(": "))}}),S}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=["x-cdn","content-type"]},function(P,n,R){"use strict";var p=SyntaxError,T=Function,I=TypeError,S=function(l){try{return T('"use strict"; return ('+l+").constructor;")()}catch{}},O=Object.getOwnPropertyDescriptor;if(O)try{O({},"")}catch{O=null}var _=function(){throw new I},E=O?function(){try{return arguments.callee,_}catch{try{return O(arguments,"callee").get}catch{return _}}}():_,A=R(43)(),D=Object.getPrototypeOf||function(l){return l.__proto__},x={},g=typeof Uint8Array=="undefined"?void 0:D(Uint8Array),y={"%AggregateError%":typeof AggregateError=="undefined"?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer=="undefined"?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":A?D([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":x,"%AsyncGenerator%":x,"%AsyncGeneratorFunction%":x,"%AsyncIteratorPrototype%":x,"%Atomics%":typeof Atomics=="undefined"?void 0:Atomics,"%BigInt%":typeof BigInt=="undefined"?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":typeof DataView=="undefined"?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":typeof Float32Array=="undefined"?void 0:Float32Array,"%Float64Array%":typeof Float64Array=="undefined"?void 0:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry,"%Function%":T,"%GeneratorFunction%":x,"%Int8Array%":typeof Int8Array=="undefined"?void 0:Int8Array,"%Int16Array%":typeof Int16Array=="undefined"?void 0:Int16Array,"%Int32Array%":typeof Int32Array=="undefined"?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":A?D(D([][Symbol.iterator]())):void 0,"%JSON%":typeof JSON=="object"?JSON:void 0,"%Map%":typeof Map=="undefined"?void 0:Map,"%MapIteratorPrototype%":typeof Map!="undefined"&&A?D(new Map()[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise=="undefined"?void 0:Promise,"%Proxy%":typeof Proxy=="undefined"?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":typeof Reflect=="undefined"?void 0:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set=="undefined"?void 0:Set,"%SetIteratorPrototype%":typeof Set!="undefined"&&A?D(new Set()[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":typeof SharedArrayBuffer=="undefined"?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":A?D(""[Symbol.iterator]()):void 0,"%Symbol%":A?Symbol:void 0,"%SyntaxError%":p,"%ThrowTypeError%":E,"%TypedArray%":g,"%TypeError%":I,"%Uint8Array%":typeof Uint8Array=="undefined"?void 0:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray=="undefined"?void 0:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array=="undefined"?void 0:Uint16Array,"%Uint32Array%":typeof Uint32Array=="undefined"?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":typeof WeakMap=="undefined"?void 0:WeakMap,"%WeakRef%":typeof WeakRef=="undefined"?void 0:WeakRef,"%WeakSet%":typeof WeakSet=="undefined"?void 0:WeakSet},s=function l(v){var m;if(v==="%AsyncFunction%")m=S("async function () {}");else if(v==="%GeneratorFunction%")m=S("function* () {}");else if(v==="%AsyncGeneratorFunction%")m=S("async function* () {}");else if(v==="%AsyncGenerator%"){var L=l("%AsyncGeneratorFunction%");L&&(m=L.prototype)}else if(v==="%AsyncIteratorPrototype%"){var b=l("%AsyncGenerator%");b&&(m=D(b.prototype))}return y[v]=m,m},e={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},o=R(9),f=R(46),a=o.call(Function.call,Array.prototype.concat),i=o.call(Function.apply,Array.prototype.splice),t=o.call(Function.call,String.prototype.replace),u=o.call(Function.call,String.prototype.slice),c=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,r=/\\(\\)?/g,h=function(l){var v=u(l,0,1),m=u(l,-1);if(v==="%"&&m!=="%")throw new p("invalid intrinsic syntax, expected closing `%`");if(m==="%"&&v!=="%")throw new p("invalid intrinsic syntax, expected opening `%`");var L=[];return t(l,c,function(b,M,F,w){L[L.length]=F?t(w,r,"$1"):M||b}),L},d=function(l,v){var m,L=l;if(f(e,L)&&(m=e[L],L="%"+m[0]+"%"),f(y,L)){var b=y[L];if(b===x&&(b=s(L)),b===void 0&&!v)throw new I("intrinsic "+l+" exists, but is not available. Please file an issue!");return{alias:m,name:L,value:b}}throw new p("intrinsic "+l+" does not exist!")};P.exports=function(l,v){if(typeof l!="string"||l.length===0)throw new I("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof v!="boolean")throw new I('"allowMissing" argument must be a boolean');var m=h(l),L=m.length>0?m[0]:"",b=d("%"+L+"%",v),M=b.name,F=b.value,w=!1,C=b.alias;C&&(L=C[0],i(m,a([0,1],C)));for(var U=1,k=!0;U<m.length;U+=1){var j=m[U],N=u(j,0,1),W=u(j,-1);if((N==='"'||N==="'"||N==="`"||W==='"'||W==="'"||W==="`")&&N!==W)throw new p("property names with quotes must have matching quotes");if(j!=="constructor"&&k||(w=!0),L+="."+j,M="%"+L+"%",f(y,M))F=y[M];else if(F!=null){if(!(j in F)){if(!v)throw new I("base intrinsic for "+l+" exists, but the property is not available.");return}if(O&&U+1>=m.length){var Y=O(F,j);k=!!Y,F=k&&"get"in Y&&!("originalValue"in Y.get)?Y.get:F[j]}else k=f(F,j),F=F[j];k&&!w&&(y[M]=F)}}return F}},function(P,n,R){"use strict";var p=R(45);P.exports=Function.prototype.bind||p},function(P,n,R){"use strict";var p=String.prototype.replace,T=/%20/g,I={RFC1738:"RFC1738",RFC3986:"RFC3986"};P.exports={default:I.RFC3986,formatters:{RFC1738:function(S){return p.call(S,T,"+")},RFC3986:function(S){return String(S)}},RFC1738:I.RFC1738,RFC3986:I.RFC3986}},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.findMediaElement=n.getMuxPlayerId=void 0;var p=R(6),T=function(S){return S&&S.nodeName!==void 0?(S.muxId||(S.muxId=S.id||(0,p.generateShortID)()),S.muxId):S},I=function(S){var O=void 0;return S&&S.nodeName!==void 0?(O=S,S=T(O)):O=document.querySelector(S),[O,S,O&&O.nodeName?O.nodeName.toLowerCase():""]};n.getMuxPlayerId=T,n.findMediaElement=I},function(P,n,R){"use strict";function p(){return(I.default.doNotTrack||I.default.navigator&&(I.default.navigator.doNotTrack||I.default.navigator.msDoNotTrack))==="1"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(0),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I={};I.exists=function(){var S=T.default.performance;return(S&&S.timing)!==void 0},I.domContentLoadedEventEnd=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.domContentLoadedEventEnd},I.navigationStart=function(){var S=T.default.performance,O=S&&S.timing;return O&&O.navigationStart},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(T){var I={};for(var S in T){var O=T[S];O["DATA-ID"].search("io.litix.data.")!==-1&&(I[O["DATA-ID"].replace("io.litix.data.","")]=O.VALUE)}return I};n.default=p},function(P,n,R){"use strict";var p=R(41),T=R(51),I=R(10);P.exports={formats:I,parse:T,stringify:p}},function(P,n,R){"use strict";var p=R(10),T=Object.prototype.hasOwnProperty,I=Array.isArray,S=function(){for(var f=[],a=0;a<256;++a)f.push("%"+((a<16?"0":"")+a.toString(16)).toUpperCase());return f}(),O=function(f){for(;f.length>1;){var a=f.pop(),i=a.obj[a.prop];if(I(i)){for(var t=[],u=0;u<i.length;++u)i[u]!==void 0&&t.push(i[u]);a.obj[a.prop]=t}}},_=function(f,a){for(var i=a&&a.plainObjects?Object.create(null):{},t=0;t<f.length;++t)f[t]!==void 0&&(i[t]=f[t]);return i},E=function f(a,i,t){if(!i)return a;if(typeof i!="object"){if(I(a))a.push(i);else{if(!a||typeof a!="object")return[a,i];(t&&(t.plainObjects||t.allowPrototypes)||!T.call(Object.prototype,i))&&(a[i]=!0)}return a}if(!a||typeof a!="object")return[a].concat(i);var u=a;return I(a)&&!I(i)&&(u=_(a,t)),I(a)&&I(i)?(i.forEach(function(c,r){if(T.call(a,r)){var h=a[r];h&&typeof h=="object"&&c&&typeof c=="object"?a[r]=f(h,c,t):a.push(c)}else a[r]=c}),a):Object.keys(i).reduce(function(c,r){var h=i[r];return T.call(c,r)?c[r]=f(c[r],h,t):c[r]=h,c},u)},A=function(f,a){return Object.keys(a).reduce(function(i,t){return i[t]=a[t],i},f)},D=function(f,a,i){var t=f.replace(/\+/g," ");if(i==="iso-8859-1")return t.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(t)}catch{return t}},x=function(f,a,i,t,u){if(f.length===0)return f;var c=f;if(typeof f=="symbol"?c=Symbol.prototype.toString.call(f):typeof f!="string"&&(c=String(f)),i==="iso-8859-1")return escape(c).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});for(var r="",h=0;h<c.length;++h){var d=c.charCodeAt(h);d===45||d===46||d===95||d===126||d>=48&&d<=57||d>=65&&d<=90||d>=97&&d<=122||u===p.RFC1738&&(d===40||d===41)?r+=c.charAt(h):d<128?r+=S[d]:d<2048?r+=S[192|d>>6]+S[128|63&d]:d<55296||d>=57344?r+=S[224|d>>12]+S[128|d>>6&63]+S[128|63&d]:(h+=1,d=65536+((1023&d)<<10|1023&c.charCodeAt(h)),r+=S[240|d>>18]+S[128|d>>12&63]+S[128|d>>6&63]+S[128|63&d])}return r},g=function(f){for(var a=[{obj:{o:f},prop:"o"}],i=[],t=0;t<a.length;++t)for(var u=a[t],c=u.obj[u.prop],r=Object.keys(c),h=0;h<r.length;++h){var d=r[h],l=c[d];typeof l=="object"&&l!==null&&i.indexOf(l)===-1&&(a.push({obj:c,prop:d}),i.push(l))}return O(a),f},y=function(f){return Object.prototype.toString.call(f)==="[object RegExp]"},s=function(f){return!(!f||typeof f!="object")&&!!(f.constructor&&f.constructor.isBuffer&&f.constructor.isBuffer(f))},e=function(f,a){return[].concat(f,a)},o=function(f,a){if(I(f)){for(var i=[],t=0;t<f.length;t+=1)i.push(a(f[t]));return i}return a(f)};P.exports={arrayToObject:_,assign:A,combine:e,compact:g,decode:D,encode:x,isBuffer:s,isRegExp:y,maybeMap:o,merge:E}},function(P,n,R){"use strict";function p(y){return y&&y.__esModule?y:{default:y}}function T(y){var s={};for(var e in y)y.hasOwnProperty(e)&&(s[y[e]]=e);return s}function I(y){var s={},e={};return Object.keys(y).forEach(function(o){var f=!1;if(y.hasOwnProperty(o)&&y[o]!==void 0){var a=o.split("_"),i=a[0],t=D[i];t||(O.default.info("Data key word `"+a[0]+"` not expected in "+o),t=i+"_"),a.splice(1).forEach(function(u){u==="url"&&(f=!0),g[u]?t+=g[u]:Number(u)&&Math.floor(Number(u))===Number(u)?t+=u:(O.default.info("Data key word `"+u+"` not expected in "+o),t+="_"+u+"_")}),f?e[t]=y[o]:s[t]=y[o]}}),(0,E.default)(s,e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=I;var S=R(4),O=p(S),_=R(1),E=p(_),A={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},D=T(A),x={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",ca:"cached",cb:"cancel",cd:"code",cg:"category",ch:"changed",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ep:"experiments",fi:"first",fm:"family",ft:"format",fq:"frequency",fr:"frame",fs:"fullscreen",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},g=T(x)},function(P,n,R){"use strict";P.exports=R(19).default},function(P,n,R){"use strict";function p(r){return r&&r.__esModule?r:{default:r}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function r(h,d){var l=[],v=!0,m=!1,L=void 0;try{for(var b,M=h[Symbol.iterator]();!(v=(b=M.next()).done)&&(l.push(b.value),!d||l.length!==d);v=!0);}catch(F){m=!0,L=F}finally{try{!v&&M.return&&M.return()}finally{if(m)throw L}}return l}return function(h,d){if(Array.isArray(h))return h;if(Symbol.iterator in Object(h))return r(h,d);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(0),S=p(I),O=R(11),_=R(4),E=p(_),A=R(12),D=p(A),x=R(2),g=p(x),y=R(22),s=p(y),e=R(58),o=p(e),f=R(59),a=p(f),i=R(64),t=p(i),u={},c=function r(h){var d=arguments;typeof h=="string"?r.hasOwnProperty(h)?S.default.setTimeout(function(){d=Array.prototype.splice.call(d,1),r[h].apply(null,d)},0):E.default.warn("`"+h+"` is an unknown task"):typeof h=="function"?S.default.setTimeout(function(){h(r)},0):E.default.warn("`"+h+"` is invalid.")};c.loaded=g.default.now(),c.NAME="mux-embed",c.VERSION="4.8.0",c.API_VERSION="2.1",c.PLAYER_TRACKED=!1,c.monitor=function(r,h){return(0,o.default)(c,r,h)},c.destroyMonitor=function(r){var h=(0,O.findMediaElement)(r),d=T(h,1),l=d[0];l&&l.mux&&typeof l.mux.destroy=="function"?l.mux.destroy():E.default.error("A video element monitor for `"+r+"` has not been initialized via `mux.monitor`.")},c.addHLSJS=function(r,h){var d=(0,O.getMuxPlayerId)(r);u[d]?u[d].addHLSJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.addDashJS=function(r,h){var d=(0,O.getMuxPlayerId)(r);u[d]?u[d].addDashJS(h):E.default.error("A monitor for `"+d+"` has not been initialized.")},c.removeHLSJS=function(r){var h=(0,O.getMuxPlayerId)(r);u[h]?u[h].removeHLSJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.removeDashJS=function(r){var h=(0,O.getMuxPlayerId)(r);u[h]?u[h].removeDashJS():E.default.error("A monitor for `"+h+"` has not been initialized.")},c.init=function(r,h){(0,D.default)()&&h&&h.respectDoNotTrack&&E.default.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var d=(0,O.getMuxPlayerId)(r);u[d]=new s.default(c,d,h)},c.emit=function(r,h,d){var l=(0,O.getMuxPlayerId)(r);u[l]?(u[l].emit(h,d),h==="destroy"&&delete u[l]):E.default.error("A monitor for `"+l+"` has not been initialized.")},S.default!==void 0&&typeof S.default.addEventListener=="function"&&S.default.addEventListener("pagehide",function(r){r.persisted||(c.WINDOW_UNLOADING=!0)},!1),c.checkDoNotTrack=D.default,c.log=E.default,c.utils=a.default,c.events=t.default,n.default=c},function(P,n){var R;R=function(){return this}();try{R=R||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(R=window)}P.exports=R},function(P,n,R){var p,T;(function(I,S){"use strict";p=S,(T=typeof p=="function"?p.call(n,R,n,P):p)!==void 0&&(P.exports=T)})(0,function(){"use strict";function I(a,i){var t=a[i];if(typeof t.bind=="function")return t.bind(a);try{return Function.prototype.bind.call(t,a)}catch{return function(){return Function.prototype.apply.apply(t,[a,arguments])}}}function S(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function O(a){return a==="debug"&&(a="log"),typeof console!==g&&(a==="trace"&&y?S:console[a]!==void 0?I(console,a):console.log!==void 0?I(console,"log"):x)}function _(a,i){for(var t=0;t<s.length;t++){var u=s[t];this[u]=t<a?x:this.methodFactory(u,a,i)}this.log=this.debug}function E(a,i,t){return function(){typeof console!==g&&(_.call(this,i,t),this[a].apply(this,arguments))}}function A(a,i,t){return O(a)||E.apply(this,arguments)}function D(a,i,t){function u(m){var L=(s[m]||"silent").toUpperCase();if(typeof window!==g&&l){try{return void(window.localStorage[l]=L)}catch{}try{window.document.cookie=encodeURIComponent(l)+"="+L+";"}catch{}}}function c(){var m;if(typeof window!==g&&l){try{m=window.localStorage[l]}catch{}if(typeof m===g)try{var L=window.document.cookie,b=L.indexOf(encodeURIComponent(l)+"=");b!==-1&&(m=/^([^;]+)/.exec(L.slice(b))[1])}catch{}return d.levels[m]===void 0&&(m=void 0),m}}function r(){if(typeof window!==g&&l){try{return void window.localStorage.removeItem(l)}catch{}try{window.document.cookie=encodeURIComponent(l)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}var h,d=this;i=i==null?"WARN":i;var l="loglevel";typeof a=="string"?l+=":"+a:typeof a=="symbol"&&(l=void 0),d.name=a,d.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},d.methodFactory=t||A,d.getLevel=function(){return h},d.setLevel=function(m,L){if(typeof m=="string"&&d.levels[m.toUpperCase()]!==void 0&&(m=d.levels[m.toUpperCase()]),!(typeof m=="number"&&m>=0&&m<=d.levels.SILENT))throw"log.setLevel() called with invalid level: "+m;if(h=m,L!==!1&&u(m),_.call(d,m,a),typeof console===g&&m<d.levels.SILENT)return"No console available for logging"},d.setDefaultLevel=function(m){i=m,c()||d.setLevel(m,!1)},d.resetLevel=function(){d.setLevel(i,!1),r()},d.enableAll=function(m){d.setLevel(d.levels.TRACE,m)},d.disableAll=function(m){d.setLevel(d.levels.SILENT,m)};var v=c();v==null&&(v=i),d.setLevel(v,!1)}var x=function(){},g="undefined",y=typeof window!==g&&typeof window.navigator!==g&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],e=new D,o={};e.getLogger=function(a){if(typeof a!="symbol"&&typeof a!="string"||a==="")throw new TypeError("You must supply a name when creating a logger.");var i=o[a];return i||(i=o[a]=new D(a,e.getLevel(),e.methodFactory)),i};var f=typeof window!==g?window.log:void 0;return e.noConflict=function(){return typeof window!==g&&window.log===e&&(window.log=f),e},e.getLoggers=function(){return o},e.default=e,e})},function(P,n,R){"use strict";function p(ee){return ee&&ee.__esModule?ee:{default:ee}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function ee(Z,q){var fe=[],ge=!0,ie=!1,me=void 0;try{for(var ye,Te=Z[Symbol.iterator]();!(ge=(ye=Te.next()).done)&&(fe.push(ye.value),!q||fe.length!==q);ge=!0);}catch(oe){ie=!0,me=oe}finally{try{!ge&&Te.return&&Te.return()}finally{if(ie)throw me}}return fe}return function(Z,q){if(Array.isArray(Z))return Z;if(Symbol.iterator in Object(Z))return ee(Z,q);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(4),S=p(I),O=R(1),_=p(O),E=R(6),A=R(5),D=R(0),x=p(D),g=R(13),y=p(g),s=R(3),e=p(s),o=R(23),f=R(24),a=R(25),i=p(a),t=R(26),u=p(t),c=R(27),r=p(c),h=R(28),d=p(h),l=R(29),v=p(l),m=R(30),L=p(m),b=R(31),M=p(b),F=R(32),w=p(F),C=R(33),U=p(C),k=R(34),j=p(k),N=R(35),W=p(N),Y=R(36),K=p(Y),H=R(37),z=p(H),$=R(38),X=p($),J=R(39),te=p(J),Q=R(57),ae=p(Q),se=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],re=function(ee,Z,q){var fe=this;this.DOM_CONTENT_LOADED_EVENT_END=y.default.domContentLoadedEventEnd(),this.NAVIGATION_START=y.default.navigationStart();var ge={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(oe){return oe}};this.mux=ee,this.id=Z,q=(0,_.default)(ge,q),q.data=q.data||{},q.data.property_key&&(q.data.env_key=q.data.property_key,delete q.data.property_key),S.default.setLevel(q.debug?"debug":"warn"),this.getPlayheadTime=q.getPlayheadTime,this.getStateData=q.getStateData||function(){},this.getAdData=q.getAdData||function(){},this.minimumRebufferDuration=q.minimumRebufferDuration,this.sustainedRebufferThreshold=q.sustainedRebufferThreshold,this.playbackHeartbeatTime=q.playbackHeartbeatTime,this.disableRebufferTracking=q.disableRebufferTracking,this.disableRebufferTracking&&this.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),this.errorTranslator=q.errorTranslator,this.playbackEventDispatcher=new te.default(ee,q.data.env_key,q),this.data={player_instance_id:(0,E.generateUUID)(),mux_sample_rate:q.sampleRate,beacon_domain:q.beaconCollectionDomain?q.beaconCollectionDomain:q.beaconDomain},this.data.view_sequence_number=1,this.data.player_sequence_number=1,this.oldEmit=this.emit,this.emit=function(oe,de){de=(0,_.default)({viewer_time:this.mux.utils.now()},de),this.oldEmit(oe,de)};var ie=function(){this.data.view_start===void 0&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}.bind(this);this.on("viewinit",function(oe,de){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),(0,_.default)(this.data,de),this._initializeViewData(),this.one("play",ie),this.one("adbreakstart",ie)});var me=function(oe){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",oe)}.bind(this);if(this.on("videochange",function(oe,de){me(de)}),this.on("programchange",function(oe,de){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),me((0,_.default)(de,{view_program_changed:!0})),ie(),this.emit("play"),this.emit("playing")}),this.on("fragmentchange",function(oe,de){this.currentFragmentPDT=de.currentFragmentPDT,this.currentFragmentStart=de.currentFragmentStart}),this.on("destroy",this.destroy),x.default!==void 0&&typeof x.default.addEventListener=="function"&&typeof x.default.removeEventListener=="function"){var ye=function(oe){oe.persisted||fe.destroy()};x.default.addEventListener("pagehide",ye,!1),this.on("destroy",function(){x.default.removeEventListener("pagehide",ye)})}this.on("playerready",function(oe,de){(0,_.default)(this.data,de)}),se.forEach(function(oe){fe.on(oe,function(de,Se){oe.indexOf("ad")!==0&&this._updateStateData(),(0,_.default)(this.data,Se),this._sanitizeData()}),fe.on("after"+oe,function(){(oe!=="error"||this.viewErrored)&&this.send(oe)})}),this.on("viewend",function(oe,de){(0,_.default)(fe.data,de)});var Te=function(oe){var de=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=de-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};this.one("playerready",Te),r.default.apply(this),X.default.apply(this),W.default.apply(this),L.default.apply(this),u.default.apply(this),j.default.apply(this),d.default.apply(this),v.default.apply(this),K.default.apply(this),M.default.apply(this),w.default.apply(this),U.default.apply(this),z.default.apply(this),ae.default.apply(this),q.hlsjs&&this.addHLSJS(q),q.dashjs&&this.addDashJS(q),this.emit("viewinit",q.data)};(0,_.default)(re.prototype,i.default.prototype),(0,_.default)(re.prototype,L.default.prototype),(0,_.default)(re.prototype,W.default.prototype),(0,_.default)(re.prototype,u.default.prototype),(0,_.default)(re.prototype,d.default.prototype),(0,_.default)(re.prototype,v.default.prototype),(0,_.default)(re.prototype,K.default.prototype),(0,_.default)(re.prototype,w.default.prototype),(0,_.default)(re.prototype,U.default.prototype),re.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,this.data.view_start!==void 0&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),x.default.clearTimeout(this._heartBeatTimeout))},re.prototype.send=function(ee){var Z=(0,_.default)({},this.data),q=["player_program_time","player_manifest_newest_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(Z.video_source_is_live===void 0&&(Z.player_source_duration===1/0||Z.video_source_duration===1/0?Z.video_source_is_live=!0:(Z.player_source_duration>0||Z.video_source_duration>0)&&(Z.video_source_is_live=!1)),Z.video_source_is_live||q.forEach(function(ye){Z[ye]=void 0}),Z.video_source_url=Z.video_source_url||Z.player_source_url,Z.video_source_url){var fe=(0,A.extractHostnameAndDomain)(Z.video_source_url),ge=T(fe,2),ie=ge[0],me=ge[1];Z.video_source_domain=me,Z.video_source_hostname=ie}delete Z.ad_request_id,this.playbackEventDispatcher.send(ee,Z),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat()},re.prototype._updateStateData=function(){(0,_.default)(this.data,this.getStateData()),this._updatePlayheadTime(),this._sanitizeData()},re.prototype._sanitizeData=function(){var ee=this;["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"].forEach(function(Z){var q=parseInt(ee.data[Z],10);ee.data[Z]=isNaN(q)?void 0:q}),["player_source_url","video_source_url"].forEach(function(Z){if(ee.data[Z]){var q=ee.data[Z].toLowerCase();q.indexOf("data:")!==0&&q.indexOf("blob:")!==0||(ee.data[Z]="MSE style URL")}})},re.prototype._resetVideoData=function(ee,Z){var q=this;Object.keys(this.data).forEach(function(fe){fe.indexOf("video_")===0&&delete q.data[fe]})},re.prototype._resetViewData=function(){var ee=this;Object.keys(this.data).forEach(function(Z){Z.indexOf("view_")===0&&delete ee.data[Z]}),this.data.view_sequence_number=1},re.prototype._resetErrorData=function(ee,Z){delete this.data.player_error_code,delete this.data.player_error_message},re.prototype._initializeViewData=function(){var ee=this,Z=this.data.view_id=(0,E.generateUUID)(),q=function(){Z===ee.data.view_id&&(0,e.default)(ee.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",q):q()},re.prototype._restartHeartBeat=function(){var ee=this;x.default.clearTimeout(this._heartBeatTimeout),this.viewErrored||(this._heartBeatTimeout=x.default.setTimeout(function(){ee.data.player_is_paused||ee.emit("hb")},1e4))},re.prototype.addHLSJS=function(ee){return ee.hlsjs?this.hlsjs?void this.mux.log.warn("An instance of HLS.js is already being monitored for this player."):(this.hlsjs=ee.hlsjs,void(0,o.monitorHlsJs)(this.mux,this.id,ee.hlsjs,{},ee.Hls||x.default.Hls)):void this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.")},re.prototype.removeHLSJS=function(){this.hlsjs&&((0,o.stopMonitoringHlsJs)(this.hlsjs),this.hlsjs=void 0)},re.prototype.addDashJS=function(ee){return ee.dashjs?this.dashjs?void this.mux.log.warn("An instance of Dash.js is already being monitored for this player."):(this.dashjs=ee.dashjs,void(0,f.monitorDashJS)(this.mux,this.id,ee.dashjs)):void this.mux.log.warn("You must pass a valid dashjs instance in order to track it.")},re.prototype.removeDashJS=function(){this.dashjs&&((0,f.stopMonitoringDashJS)(this.dashjs),this.dashjs=void 0)},n.default=re},function(P,n,R){"use strict";function p(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringHlsJs=n.monitorHlsJs=void 0;var T=R(7),I=p(T),S=R(13),O=p(S),_=R(5),E=R(14),A=p(E),D=function(s){if(!s)return{};var e=O.default.navigationStart(),o=s.loading,f=o?o.start:s.trequest,a=o?o.first:s.tfirst,i=o?o.end:s.tload;return{bytesLoaded:s.total,requestStart:Math.round(e+f),responseStart:Math.round(e+a),responseEnd:Math.round(e+i)}},x=function(s){if(s&&typeof s.getAllResponseHeaders=="function")return(0,I.default)(s.getAllResponseHeaders())},g=function(s,e,o){var f=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],arguments[4]),a=s.log,i=s.utils.secondsToMs,t=function(b){var M=parseInt(f.version),F=void 0;return M===1&&b.programDateTime!==null&&(F=b.programDateTime),M===0&&b.pdt!==null&&(F=b.pdt),F};if(!O.default.exists())return void a.warn("performance timing not supported. Not tracking HLS.js.");var u=function(b,M){return s.emit(e,b,M)},c=function(b,M){var F=M.levels,w=M.audioTracks,C=M.url,U=M.stats,k=M.networkDetails,j=M.sessionData,N={},W={},Y={};Y=(0,A.default)(j),F.forEach(function(J,te){N[te]={width:J.width,height:J.height,bitrate:J.bitrate,attrs:J.attrs}}),w.forEach(function(J,te){W[te]={name:J.name,language:J.lang,bitrate:J.bitrate}});var K=D(U),H=K.bytesLoaded,z=K.requestStart,$=K.responseStart,X=K.responseEnd;Y.request_event_type=b,Y.request_bytes_loaded=H,Y.request_start=z,Y.request_response_start=$,Y.request_response_end=X,Y.request_type="manifest",Y.request_hostname=(0,_.extractHostname)(C),Y.request_response_headers=x(k),Y.request_rendition_lists={media:N,audio:W,video:{}},u("requestcompleted",Y)};o.on(f.Events.MANIFEST_LOADED,c);var r=function(b,M){var F=M.details,w=M.level,C=M.networkDetails,U=M.stats,k=D(U),j=k.bytesLoaded,N=k.requestStart,W=k.responseStart,Y=k.responseEnd,K=F.fragments[F.fragments.length-1],H=t(K)+i(K.duration);u("requestcompleted",{request_event_type:b,request_bytes_loaded:j,request_start:N,request_response_start:W,request_response_end:Y,request_current_level:w,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(C),video_holdback:F.holdBack&&i(F.holdBack),video_part_holdback:F.partHoldBack&&i(F.partHoldBack),video_part_target_duration:F.partTarget&&i(F.partTarget),video_target_duration:F.targetduration&&i(F.targetduration),video_source_is_live:F.live,player_manifest_newest_program_time:isNaN(H)?void 0:H})};o.on(f.Events.LEVEL_LOADED,r);var h=function(b,M){var F=M.details,w=M.networkDetails,C=M.stats,U=D(C),k=U.bytesLoaded,j=U.requestStart,N=U.responseStart,W=U.responseEnd;u("requestcompleted",{request_event_type:b,request_bytes_loaded:k,request_start:j,request_response_start:N,request_response_end:W,request_type:"manifest",request_hostname:(0,_.extractHostname)(F.url),request_response_headers:x(w)})};o.on(f.Events.AUDIO_TRACK_LOADED,h);var d=function(b,M){var F=M.stats,w=M.networkDetails,C=M.frag,U=D(F),k=U.bytesLoaded,j=U.requestStart,N=U.responseStart,W=U.responseEnd,Y={request_event_type:b,request_bytes_loaded:k,request_start:j,request_response_start:N,request_response_end:W,request_hostname:w?(0,_.extractHostname)(w.responseURL):void 0,request_response_headers:x(w),request_media_duration:C.duration};C.type==="main"?(Y.request_type="media",Y.request_current_level=C.level,Y.request_video_width=(o.levels[C.level]||{}).width,Y.request_video_height=(o.levels[C.level]||{}).height):Y.request_type=C.type,u("requestcompleted",Y)};o.on(f.Events.FRAG_LOADED,d);var l=function(b,M){var F=M.frag,w=F.start,C=t(F),U={currentFragmentPDT:C,currentFragmentStart:i(w)};u("fragmentchange",U)};o.on(f.Events.FRAG_CHANGED,l);var v=function(b,M){var F=M.type,w=M.details,C=M.response,U=M.fatal,k=M.context,j=M.frag;if(w===f.ErrorDetails.MANIFEST_LOAD_ERROR||w===f.ErrorDetails.MANIFEST_LOAD_TIMEOUT||w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT||w===f.ErrorDetails.LEVEL_LOAD_ERROR||w===f.ErrorDetails.LEVEL_LOAD_TIMEOUT){var N=j&&j.url||k&&k.url||"";u("requestfailed",{request_error:w,request_url:N,request_hostname:(0,_.extractHostname)(N),request_type:w===f.ErrorDetails.FRAG_LOAD_ERROR||w===f.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":"manifest",request_error_code:C&&C.code,request_error_text:C&&C.text})}U&&u("error",{player_error_code:F,player_error_message:w})};o.on(f.Events.ERROR,v);var m=function(b,M){var F=M.frag,w=F&&F._url||"";u("requestcanceled",{request_cancel:b,request_url:w,request_type:"media",request_hostname:(0,_.extractHostname)(w)})};o.on(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var L=function(b,M){var F=M.level,w=o.levels[F];if(w&&w.attrs&&w.attrs.BANDWIDTH){var C=w.attrs.BANDWIDTH;C?u("renditionchange",{video_source_bitrate:C,video_source_width:w.width,video_source_height:w.height}):a.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};o.on(f.Events.LEVEL_SWITCHED,L),o._stopMuxMonitor=function(){o.off(f.Events.MANIFEST_LOADED,c),o.off(f.Events.LEVEL_LOADED,r),o.off(f.Events.AUDIO_TRACK_LOADED,h),o.off(f.Events.FRAG_LOADED,d),o.off(f.Events.FRAG_CHANGED,l),o.off(f.Events.ERROR,v),o.off(f.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),o.off(f.Events.LEVEL_SWITCHED,L),o.off(f.Events.DESTROYING,o._stopMuxMonitor),delete o._stopMuxMonitor},o.on(f.Events.DESTROYING,o._stopMuxMonitor)},y=function(s){s&&typeof s._stopMuxMonitor=="function"&&s._stopMuxMonitor()};n.monitorHlsJs=g,n.stopMonitoringHlsJs=y},function(P,n,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0}),n.stopMonitoringDashJS=n.monitorDashJS=void 0;var T=R(0),I=p(T),S=R(7),O=p(S),_=R(5),E=function(g,y){if(!g||typeof g.getRequests!="function")return{};var s=g.getRequests({state:"executed"});if(s.length===0)return{};var e=s[s.length-1],o=(0,_.extractHostname)(e.url),f=e.bytesLoaded,a=new Date(e.requestStartDate).getTime(),i=new Date(e.firstByteDate).getTime(),t=new Date(e.requestEndDate).getTime(),u=isNaN(e.duration)?0:e.duration,c=typeof y.getMetricsFor=="function"?y.getMetricsFor(e.mediaType).HttpList:y.getDashMetrics().getHttpRequests(e.mediaType),r=void 0;return c.length>0&&(r=(0,O.default)(c[c.length-1]._responseHeaders||"")),{requestStart:a,requestResponseStart:i,requestResponseEnd:t,requestBytesLoaded:f,requestResponseHeaders:r,requestMediaDuration:u,requestHostname:o}},A=function(g,y){var s=y.getQualityFor(g),e=y.getCurrentTrackFor(g),o=e.bitrateList;return o?{currentLevel:s,renditionWidth:o[s].width||null,renditionHeight:o[s].height||null,renditionBitrate:o[s].bandwidth}:{}},D=function(g,y,s){var e=(arguments.length>3&&arguments[3]!==void 0&&arguments[3],g.log);if(!s||!s.on)return void e.warn("Invalid dash.js player reference. Monitoring blocked.");var o=function(d,l){return g.emit(y,d,l)},f=function(d){var l=d.type,v=d.data,m=v||{},L=m.url;o("requestcompleted",{request_event_type:l,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:(0,_.extractHostname)(L)})};s.on("manifestLoaded",f);var a={},i=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,L=m||{},b=L.mediaInfo,M=b||{},F=M.type,w=M.bitrateList;w=w||[];var C={};w.forEach(function(H,z){C[z]={},C[z].width=H.width,C[z].height=H.height,C[z].bitrate=H.bandwidth,C[z].attrs={}}),F==="video"?a.video=C:F==="audio"?a.audio=C:a.media=C;var U=E(v,s),k=U.requestStart,j=U.requestResponseStart,N=U.requestResponseEnd,W=U.requestResponseHeaders,Y=U.requestMediaDuration,K=U.requestHostname;o("requestcompleted",{request_event_type:l,request_start:k,request_response_start:j,request_response_end:N,request_bytes_loaded:-1,request_type:F+"_init",request_response_headers:W,request_hostname:K,request_media_duration:Y,request_rendition_lists:a})};s.on("initFragmentLoaded",i);var t=function(d){var l=d.type,v=d.fragmentModel,m=d.chunk,L=m||{},b=L.mediaInfo,M=L.start,F=b||{},w=F.type,C=E(v,s),U=C.requestStart,k=C.requestResponseStart,j=C.requestResponseEnd,N=C.requestBytesLoaded,W=C.requestResponseHeaders,Y=C.requestMediaDuration,K=C.requestHostname,H=A(w,s),z=H.currentLevel,$=H.renditionWidth,X=H.renditionHeight,J=H.renditionBitrate;o("requestcompleted",{request_event_type:l,request_start:U,request_response_start:k,request_response_end:j,request_bytes_loaded:N,request_type:w,request_response_headers:W,request_hostname:K,request_media_start_time:M,request_media_duration:Y,request_current_level:z,request_labeled_bitrate:J,request_video_width:$,request_video_height:X})};s.on("mediaFragmentLoaded",t);var u={video:void 0,audio:void 0,totalBitrate:void 0},c=function(){if(u.video&&typeof u.video.bitrate=="number"){if(!u.video.width||!u.video.height)return void e.warn("have bitrate info for video but missing width/height");var d=u.video.bitrate;return u.audio&&typeof u.audio.bitrate=="number"&&(d+=u.audio.bitrate),d!==u.totalBitrate?(u.totalBitrate=d,{video_source_bitrate:d,video_source_height:u.video.height,video_source_width:u.video.width}):void 0}},r=function(d,l,v){if(typeof d.newQuality!="number")return void e.warn("missing evt.newQuality in qualityChangeRendered event",d);var m=d.mediaType;if(m==="audio"||m==="video"){var L=s.getBitrateInfoListFor(m).find(function(M){return M.qualityIndex===d.newQuality});if(!L||typeof L.bitrate!="number")return void e.warn("missing bitrate info for "+m);u[m]=L;var b=c();b&&o("renditionchange",b)}};s.on("qualityChangeRendered",r);var h=function(d){var l=d.error,v=d.event;v=v||{};var m=v.request||{},L=I.default.event&&I.default.event.currentTarget||{};o("requestfailed",{request_error:l+"_"+v.id+"_"+m.type,request_url:v.url,request_hostname:(0,_.extractHostname)(v.url),request_type:m.mediaType,request_error_code:L.status,request_error_type:L.statusText})};s.on("error",h),s._stopMuxMonitor=function(){s.off("manifestLoaded",f),s.off("initFragmentLoaded",i),s.off("mediaFragmentLoaded",t),s.off("qualityChangeRendered",r),s.off("error",h),delete s._stopMuxMonitor}},x=function(g){g&&typeof g._stopMuxMonitor=="function"&&g._stopMuxMonitor()};n.monitorDashJS=D,n.stopMonitoringDashJS=x},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(){},T=0;p.prototype.on=function(I,S,O){return S._eventEmitterGuid=S._eventEmitterGuid||++T,this._listeners=this._listeners||{},this._listeners[I]=this._listeners[I]||[],O&&(S=S.bind(O)),this._listeners[I].push(S),S},p.prototype.off=function(I,S){var O=this._listeners&&this._listeners[I];O&&O.forEach(function(_,E){_._eventEmitterGuid===S._eventEmitterGuid&&O.splice(E,1)})},p.prototype.one=function(I,S,O){var _=this;S._eventEmitterGuid=S._eventEmitterGuid||++T;var E=function A(){_.off(I,A),S.apply(O||this,arguments)};E._eventEmitterGuid=S._eventEmitterGuid,this.on(I,E)},p.prototype.emit=function(I,S){var O=this;if(this._listeners){S=S||{};var _=this._listeners["before*"]||[],E=this._listeners[I]||[],A=this._listeners["after"+I]||[],D=function(x,g){x=x.slice(),x.forEach(function(y){y.call(O,{type:I},g)})};D(_,S),D(E,S),D(A,S)}},n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,this.on("playing",function(){this._playheadShouldBeProgressing=!0}),this.on("play",this._startPlaybackHeartbeatInterval),this.on("playing",this._startPlaybackHeartbeatInterval),this.on("adbreakstart",this._startPlaybackHeartbeatInterval),this.on("adplay",this._startPlaybackHeartbeatInterval),this.on("adplaying",this._startPlaybackHeartbeatInterval),this.on("seeking",this._startPlaybackHeartbeatInterval),this.on("devicewake",this._startPlaybackHeartbeatInterval),this.on("viewstart",this._startPlaybackHeartbeatInterval),this.on("rebufferstart",this._startPlaybackHeartbeatInterval),this.on("pause",this._stopPlaybackHeartbeatInterval),this.on("ended",this._stopPlaybackHeartbeatInterval),this.on("viewend",this._stopPlaybackHeartbeatInterval),this.on("error",this._stopPlaybackHeartbeatInterval),this.on("aderror",this._stopPlaybackHeartbeatInterval),this.on("adpause",this._stopPlaybackHeartbeatInterval),this.on("adended",this._stopPlaybackHeartbeatInterval),this.on("adbreakend",this._stopPlaybackHeartbeatInterval),this.on("seeked",function(){this.data.player_is_paused?this._stopPlaybackHeartbeatInterval():this._startPlaybackHeartbeatInterval()}),this.on("timeupdate",function(){this._playbackHeartbeatInterval!==null&&this.emit("playbackheartbeat")}),this.on("devicesleep",function(S,O){this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend",{viewer_time:O.viewer_time}),this._playbackHeartbeatInterval=null)})};I.prototype._startPlaybackHeartbeatInterval=function(){var S=this;this._playbackHeartbeatInterval===null&&(this.emit("playbackheartbeat"),this._playbackHeartbeatInterval=T.default.setInterval(function(){S.emit("playbackheartbeat")},this.playbackHeartbeatTime))},I.prototype._stopPlaybackHeartbeatInterval=function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(T.default.clearInterval(this._playbackHeartbeatInterval),this.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)},n.default=I},function(P,n,R){"use strict";function p(){var T=this;this.on("viewinit",function(){T.viewErrored=!1}),this.on("error",function(){try{var I=T.errorTranslator({player_error_code:T.data.player_error_code,player_error_message:T.data.player_error_message});I?(T.data.player_error_code=I.player_error_code,T.data.player_error_message=I.player_error_message,T.viewErrored=!0):(delete T.data.player_error_code,delete T.data.player_error_message)}catch(S){T.mux.log.warn("Exception in error translator callback.",S),T.viewErrored=!0}})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(3),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this._watchTimeTrackerLastCheckedTime=null,this.on("playbackheartbeat",this._updateWatchTime),this.on("playbackheartbeatend",this._clearWatchTimeState)};I.prototype._updateWatchTime=function(S,O){var _=O.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=_),(0,T.default)(this.data,"view_watch_time",_-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=_},I.prototype._clearWatchTimeState=function(S,O){this._updateWatchTime(S,O),this._watchTimeTrackerLastCheckedTime=null},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(3),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this._playbackTimeTrackerLastPlayheadPosition=-1,this.on("playbackheartbeat",this._updatePlaybackTime),this.on("playbackheartbeatend",this._clearPlaybackTimeState),this.on("seeking",this._clearPlaybackTimeState)};I.prototype._updatePlaybackTime=function(){var S=this.data.player_playhead_time;if(this._playbackTimeTrackerLastPlayheadPosition>=0&&S>this._playbackTimeTrackerLastPlayheadPosition){var O=S-this._playbackTimeTrackerLastPlayheadPosition;O<=1e3&&(0,T.default)(this.data,"view_content_playback_time",O)}this._playbackTimeTrackerLastPlayheadPosition=S},I.prototype._clearPlaybackTimeState=function(){this._updatePlaybackTime(),this._playbackTimeTrackerLastPlayheadPosition=-1},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=function(){this.on("playbackheartbeat",this._updatePlayheadTime),this.on("playbackheartbeatend",this._updatePlayheadTime),this.on("timeupdate",this._updatePlayheadTime),this.on("destroy",function(){this.off("timeupdate",this._updatePlayheadTime)})};p.prototype._updateMaxPlayheadPosition=function(){this.data.view_max_playhead_position=this.data.view_max_playhead_position===void 0?this.data.player_playhead_time:Math.max(this.data.view_max_playhead_position,this.data.player_playhead_time)},p.prototype._updatePlayheadTime=function(T,I){var S=this,O=function(){S.currentFragmentPDT&&S.currentFragmentStart&&(S.data.player_program_time=S.currentFragmentPDT+S.data.player_playhead_time-S.currentFragmentStart)};if(I&&I.player_playhead_time)this.data.player_playhead_time=I.player_playhead_time,O(),this._updateMaxPlayheadPosition();else if(this.getPlayheadTime){var _=this.getPlayheadTime();_!==void 0&&(this.data.player_playhead_time=_,O(),this._updateMaxPlayheadPosition())}},n.default=p},function(P,n,R){"use strict";function p(){var S=this;if(!this.disableRebufferTracking){var O=void 0,_=function(){if(O){var E=S.data.viewer_time-O;(0,I.default)(S.data,"view_rebuffer_duration",E),O=S.data.viewer_time}S.data.view_watch_time>=0&&S.data.view_rebuffer_count>0&&(S.data.view_rebuffer_frequency=S.data.view_rebuffer_count/S.data.view_watch_time,S.data.view_rebuffer_percentage=S.data.view_rebuffer_duration/S.data.view_watch_time)};this.on("playbackheartbeat",function(){return _()}),this.on("rebufferstart",function(){O||((0,I.default)(S.data,"view_rebuffer_count",1),O=S.data.viewer_time,S.one("rebufferend",function(){_(),O=void 0}))})}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(2),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this.disableRebufferTracking||this.disablePlayheadRebufferTracking||(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,this.on("playbackheartbeat",this._checkIfRebuffering),this.on("playbackheartbeatend",this._cleanupRebufferTracker),this.on("seeking",function(){this._cleanupRebufferTracker(null,{viewer_time:T.default.now()})}))};I.prototype._checkIfRebuffering=function(S,O){return this.isSeeking||this.isAdBreak||!this._playheadShouldBeProgressing?void this._cleanupRebufferTracker(S,O):this._lastCheckedTime===null?void this._prepareRebufferTrackerState(O.viewer_time):this._lastPlayheadTime!==this.data.player_playhead_time?void this._cleanupRebufferTracker(S,O,!0):(O.viewer_time-this._lastPlayheadTimeUpdatedTime>=this.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),void(this._lastCheckedTime=O.viewer_time))},I.prototype._clearRebufferTrackerState=function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null},I.prototype._prepareRebufferTrackerState=function(S){this._lastCheckedTime=S,this._lastPlayheadTime=this.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=S},I.prototype._cleanupRebufferTracker=function(S,O){var _=arguments.length>2&&arguments[2]!==void 0&&arguments[2];if(this._rebuffering)this._rebuffering=!1,this.emit("rebufferend",{viewer_time:O.viewer_time});else{if(this._lastCheckedTime===null)return;var E=this.data.player_playhead_time-this._lastPlayheadTime,A=O.viewer_time-this._lastPlayheadTimeUpdatedTime;E>0&&A-E>this.minimumRebufferDuration&&(this.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+A-E}))}_?this._prepareRebufferTrackerState(O.viewer_time):this._clearRebufferTrackerState()},n.default=I},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(2),T=function(S){return S&&S.__esModule?S:{default:S}}(p),I=function(){this.on("viewinit",function(){var S=this.data,O=S.view_id;if(!S.view_program_changed){var _=function(E,A){var D=A.viewer_time;E.type==="playing"&&this.data.view_time_to_first_frame===void 0?this.calculateTimeToFirstFrame(D||T.default.now(),O):E.type!=="adplaying"||this.data.view_time_to_first_frame!==void 0&&!this.inPrerollPosition()||this.calculateTimeToFirstFrame(D||T.default.now(),O)};this.one("playing",_),this.one("adplaying",_),this.one("viewend",function(){this.off("playing",_),this.off("adplaying",_)})}})};I.prototype.calculateTimeToFirstFrame=function(S,O){O===this.data.view_id&&(this._updateWatchTime(null,{viewer_time:S}),this.data.view_time_to_first_frame=this.data.view_watch_time,(this.data.player_autoplay_on||this.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.data.view_aggregate_startup_time=this.data.view_start+this.data.view_watch_time-this.NAVIGATION_START))},n.default=I},function(P,n,R){"use strict";function p(){var S=this;this.on("viewinit",function(){this._lastPlayheadPosition=-1});var O=["pause","rebufferstart","seeking","error","adbreakstart","hb"],_=["playing","hb"];O.forEach(function(E){S.on(E,function(){if(this._lastPlayheadPosition>=0&&this.data.player_playhead_time>=0&&this._lastPlayerWidth>=0&&this._lastSourceWidth>0&&this._lastPlayerHeight>=0&&this._lastSourceHeight>0){var A=this.data.player_playhead_time-this._lastPlayheadPosition;if(A<0)return void(this._lastPlayheadPosition=-1);var D=Math.min(this._lastPlayerWidth/this._lastSourceWidth,this._lastPlayerHeight/this._lastSourceHeight),x=Math.max(0,D-1),g=Math.max(0,1-D);this.data.view_max_upscale_percentage=Math.max(this.data.view_max_upscale_percentage||0,x),this.data.view_max_downscale_percentage=Math.max(this.data.view_max_downscale_percentage||0,g),(0,I.default)(this.data,"view_total_content_playback_time",A),(0,I.default)(this.data,"view_total_upscaling",x*A),(0,I.default)(this.data,"view_total_downscaling",g*A)}this._lastPlayheadPosition=-1})}),_.forEach(function(E){S.on(E,function(){this._lastPlayheadPosition=this.data.player_playhead_time,this._lastPlayerWidth=this.data.player_width,this._lastPlayerHeight=this.data.player_height,this._lastSourceWidth=this.data.video_source_width,this._lastSourceHeight=this.data.video_source_height})})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(3),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";function p(D){return D&&D.__esModule?D:{default:D}}function T(){this.isSeeking=!1,this.on("seeking",function(D,x){(0,A.default)(this.data,x),this._lastSeekingTime=S.default.now(),this.isSeeking===!1&&(this.isSeeking=!0,this.send("seeking"))}),this.on("seeked",function(){this.isSeeking=!1;var D=this._lastSeekingTime||S.default.now(),x=S.default.now()-D;(0,_.default)(this.data,"view_seek_count",1),(0,_.default)(this.data,"view_seek_duration",x);var g=this.data.view_max_seek_time||0;this.data.view_max_seek_time=Math.max(g,x)}),this.on("viewend",function(){this.isSeeking=!1})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(2),S=p(I),O=R(3),_=p(O),E=R(1),A=p(E)},function(P,n,R){"use strict";function p(g){return g&&g.__esModule?g:{default:g}}Object.defineProperty(n,"__esModule",{value:!0});var T=function(){function g(y,s){var e=[],o=!0,f=!1,a=void 0;try{for(var i,t=y[Symbol.iterator]();!(o=(i=t.next()).done)&&(e.push(i.value),!s||e.length!==s);o=!0);}catch(u){f=!0,a=u}finally{try{!o&&t.return&&t.return()}finally{if(f)throw a}}return e}return function(y,s){if(Array.isArray(y))return y;if(Symbol.iterator in Object(y))return g(y,s);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),I=R(3),S=p(I),O=R(5),_=R(1),E=p(_),A=function(g,y){g.push(y),g.sort(function(s,e){return s.viewer_time-e.viewer_time})},D=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror"],x=function(){var g=this;this.on("viewinit",function(){this.isAdBreak=!1,this._currentAdRequestNumber=0,this._currentAdResponseNumber=0,this._adRequests=[],this._adResponses=[],this._adHasPlayed=!1,this._wouldBeNewAdPlay=!0,this._prerollPlayTime=void 0}),D.forEach(function(s){return g.on(s,g._updateAdData)});var y=function(){g.isAdBreak=!1};this.on("adbreakstart",function(){this.isAdBreak=!0}),this.on("play",y),this.on("playing",y),this.on("viewend",y),this.on("adrequest",function(s,e){e=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdRequestNumber++},e),A(this._adRequests,e),(0,S.default)(this.data,"view_ad_request_count"),this.inPrerollPosition()&&(this.data.view_preroll_requested=!0,this._adHasPlayed||(0,S.default)(this.data,"view_preroll_request_count"))}),this.on("adresponse",function(s,e){e=(0,E.default)({ad_request_id:"generatedAdRequestId"+this._currentAdResponseNumber++},e),A(this._adResponses,e);var o=this.findAdRequest(e.ad_request_id);o&&(0,S.default)(this.data,"view_ad_request_time",Math.max(0,e.viewer_time-o.viewer_time))}),this.on("adplay",function(s,e){this._adHasPlayed=!0,this._wouldBeNewAdPlay&&(this._wouldBeNewAdPlay=!1,(0,S.default)(this.data,"view_ad_played_count")),this.inPrerollPosition()&&!this.data.view_preroll_played&&(this.data.view_preroll_played=!0,this._adRequests.length>0&&(this.data.view_preroll_request_time=Math.max(0,e.viewer_time-this._adRequests[0].viewer_time)),this.data.view_start&&(this.data.view_startup_preroll_request_time=Math.max(0,e.viewer_time-this.data.view_start)),this._prerollPlayTime=e.viewer_time)}),this.on("adplaying",function(s,e){this.inPrerollPosition()&&this.data.view_preroll_load_time===void 0&&this._prerollPlayTime!==void 0&&(this.data.view_preroll_load_time=e.viewer_time-this._prerollPlayTime,this.data.view_startup_preroll_load_time=e.viewer_time-this._prerollPlayTime)}),this.on("adended",function(){this._wouldBeNewAdPlay=!0}),this.on("aderror",function(){this._wouldBeNewAdPlay=!0})};x.prototype.inPrerollPosition=function(){return this.data.view_content_playback_time===void 0||this.data.view_content_playback_time<=1e3},x.prototype.findAdRequest=function(g){for(var y=0;y<this._adRequests.length;y++)if(this._adRequests[y].ad_request_id===g)return this._adRequests[y]},x.prototype._updateAdData=function(g,y){if(this.inPrerollPosition()){if(!this.data.view_preroll_ad_tag_hostname&&y.ad_tag_url){var s=(0,O.extractHostnameAndDomain)(y.ad_tag_url),e=T(s,2),o=e[0],f=e[1];this.data.view_preroll_ad_tag_domain=f,this.data.view_preroll_ad_tag_hostname=o}if(!this.data.view_preroll_ad_asset_hostname&&y.ad_asset_url){var a=(0,O.extractHostnameAndDomain)(y.ad_asset_url),i=T(a,2),t=i[0],u=i[1];this.data.view_preroll_ad_asset_domain=u,this.data.view_preroll_ad_asset_hostname=t}}},n.default=x},function(P,n,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}function T(){var E=this,A=void 0,D=void 0,x=function(){E.disableRebufferTracking||((0,_.default)(E.data,"view_waiting_rebuffer_count",1),A=S.default.now(),D=window.setInterval(function(){if(A){var o=S.default.now();(0,_.default)(E.data,"view_waiting_rebuffer_duration",o-A),A=o}},250))},g=function(){E.disableRebufferTracking||A&&((0,_.default)(E.data,"view_waiting_rebuffer_duration",S.default.now()-A),A=!1,window.clearInterval(D))},y=!1,s=function(){y=!0},e=function(){y=!1,g()};this.on("waiting",function(){y&&x()}),this.on("playing",function(){g(),s()}),this.on("pause",e),this.on("seeking",e)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(2),S=p(I),O=R(3),_=p(O)},function(P,n,R){"use strict";function p(D){return D&&D.__esModule?D:{default:D}}function T(){var D=this;this.one("playbackheartbeat",E),this.on("playbackheartbeatend",function(){D.off("before*",A),D.one("playbackheartbeat",E)})}Object.defineProperty(n,"__esModule",{value:!0}),n.default=T;var I=R(1),S=p(I),O=R(2),_=p(O),E=function(){this.lastWallClockTime=_.default.now(),this.on("before*",A)},A=function(D){var x=_.default.now(),g=this.lastWallClockTime;this.lastWallClockTime=x,x-g>3e4&&(this.emit("devicesleep",{viewer_time:g}),(0,S.default)(this.data,{viewer_time:g}),this.send("devicesleep"),this.emit("devicewake",{viewer_time:x}),(0,S.default)(this.data,{viewer_time:x}),this.send("devicewake"))}},function(P,n,R){"use strict";function p(l){return l&&l.__esModule?l:{default:l}}Object.defineProperty(n,"__esModule",{value:!0});var T=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(l){return typeof l}:function(l){return l&&typeof Symbol=="function"&&l.constructor===Symbol&&l!==Symbol.prototype?"symbol":typeof l},I=R(0),S=p(I),O=R(40),_=R(4),E=p(_),A=R(53),D=p(A),x=R(12),g=p(x),y=R(54),s=p(y),e=R(17),o=p(e),f=R(55),a=p(f),i=R(1),t=p(i),u=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id"],c=["viewstart","error","ended","viewend"],r=function(l,v){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.mux=l,this.envKey=v,this.eventQueue=new a.default((0,D.default)(v,m)),this.previousBeaconData=null,this.lastEventTime=null,this.sampleRate=m.sampleRate,this.disableCookies=m.disableCookies,this.respectDoNotTrack=m.respectDoNotTrack;var L=m.platform||{};this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:L.name,viewer_application_version:L.version,viewer_application_engine:L.layout,viewer_device_name:L.product,viewer_device_category:"",viewer_device_manufacturer:L.manufacturer,viewer_os_family:L.os&&L.os.family,viewer_os_architecture:L.os&&L.os.architecture,viewer_os_version:L.os&&L.os.version};var b=(0,s.default)();b&&(this.pageLevelData=(0,t.default)(this.pageLevelData,{viewer_connection_type:b})),S.default!==void 0&&S.default.location&&S.default.location.href&&(this.pageLevelData.page_url=S.default.location.href),this.viewerData=this.disableCookies?{}:(0,O.getAndUpdateViewerData)()};r.prototype.send=function(l,v){if(l){if(this.respectDoNotTrack&&(0,g.default)())return E.default.info("Not sending `"+l+"` because Do Not Track is enabled");if(!v||(v===void 0?"undefined":T(v))!=="object")return E.default.error("A data object was expected in send() but was not provided");var m=this.disableCookies?{}:(0,O.getAndUpdateSessionData)(),L={};(0,t.default)(L,this.pageLevelData),(0,t.default)(L,v),(0,t.default)(L,m),(0,t.default)(L,this.viewerData),L.event=l,L.env_key=this.envKey,L.user_id&&(L.viewer_user_id=L.user_id,delete L.user_id);var b=L.mux_sample_number>=this.sampleRate,M=this._deduplicateBeaconData(l,L),F=(0,o.default)(M);if(this.lastEventTime=this.mux.utils.now(),b)return E.default.info("Not sending event due to sample rate restriction",l,L,F);if(this.envKey||E.default.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",l,L,F),!this.rateLimited){if(E.default.info("Sending event",l,L,F),this.rateLimited=!this.eventQueue.queueEvent(l,F),this.mux.WINDOW_UNLOADING&&l==="viewend")this.eventQueue.destroy(!0);else if((c.indexOf(l)>=0||this.mux.WINDOW_VISIBLE===!1&&l==="hb")&&this.eventQueue.flushEvents(),this.rateLimited)return L.event="eventrateexceeded",F=(0,o.default)(L),this.eventQueue.queueEvent(L.event,F),E.default.error("Beaconing disabled due to rate limit.")}}},r.prototype.destroy=function(){this.eventQueue.destroy(!1)};var h=function(l,v,m,L){return!(!l||v.indexOf("request_")!==0)&&(v==="request_response_headers"||(m===void 0?"undefined":T(m))!=="object"||(L===void 0?"undefined":T(L))!=="object"||Object.keys(m||{}).length!==Object.keys(L||{}).length)},d=function(l,v){return l==="renditionchange"&&v.indexOf("video_source_")===0};r.prototype._deduplicateBeaconData=function(l,v){var m=this,L={},b=v.view_id;if(!b||l==="viewstart"||l==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=6e5)L=(0,t.default)({},v),b&&(this.previousBeaconData=L),b&&l==="viewend"&&(this.previousBeaconData=null);else{var M=l.indexOf("request")===0;Object.keys(v).forEach(function(F){var w=v[F];(w!==m.previousBeaconData[F]||u.indexOf(F)>-1||h(M,F,w,m.previousBeaconData[F])||d(l,F))&&(L[F]=w,m.previousBeaconData[F]=w)})}return L},n.default=r},function(P,n,R){"use strict";function p(s){return s&&s.__esModule?s:{default:s}}Object.defineProperty(n,"__esModule",{value:!0}),n.getAndUpdateSessionData=n.getAndUpdateViewerData=void 0;var T=R(15),I=p(T),S=R(52),O=p(S),_=R(6),E=R(2),A=p(E),D=function(){var s=void 0;try{s=I.default.parse(O.default.get("muxData")||"")}catch{s={}}return s},x=function(s){try{O.default.set("muxData",I.default.stringify(s),{expires:7300})}catch{}},g=function(){var s=D();return s.mux_viewer_id=s.mux_viewer_id||(0,_.generateUUID)(),s.msn=s.msn||Math.random(),x(s),{mux_viewer_id:s.mux_viewer_id,mux_sample_number:s.msn}},y=function(){var s=D(),e=A.default.now();return s.session_start&&(s.sst=s.session_start,delete s.session_start),s.session_id&&(s.sid=s.session_id,delete s.session_id),s.session_expires&&(s.sex=s.session_expires,delete s.session_expires),(!s.sex||s.sex<e)&&(s.sid=(0,_.generateUUID)(),s.sst=e),s.sex=e+15e5,x(s),{session_id:s.sid,session_start:s.sst,session_expires:s.sex}};n.getAndUpdateViewerData=g,n.getAndUpdateSessionData=y},function(P,n,R){"use strict";var p=R(42),T=R(16),I=R(10),S=Object.prototype.hasOwnProperty,O={brackets:function(a){return a+"[]"},comma:"comma",indices:function(a,i){return a+"["+i+"]"},repeat:function(a){return a}},_=Array.isArray,E=String.prototype.split,A=Array.prototype.push,D=function(a,i){A.apply(a,_(i)?i:[i])},x=Date.prototype.toISOString,g=I.default,y={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:T.encode,encodeValuesOnly:!1,format:g,formatter:I.formatters[g],indices:!1,serializeDate:function(a){return x.call(a)},skipNulls:!1,strictNullHandling:!1},s=function(a){return typeof a=="string"||typeof a=="number"||typeof a=="boolean"||typeof a=="symbol"||typeof a=="bigint"},e={},o=function a(i,t,u,c,r,h,d,l,v,m,L,b,M,F,w){for(var C=i,U=w,k=0,j=!1;(U=U.get(e))!==void 0&&!j;){var N=U.get(i);if(k+=1,N!==void 0){if(N===k)throw new RangeError("Cyclic object value");j=!0}U.get(e)===void 0&&(k=0)}if(typeof d=="function"?C=d(t,C):C instanceof Date?C=m(C):u==="comma"&&_(C)&&(C=T.maybeMap(C,function(re){return re instanceof Date?m(re):re})),C===null){if(c)return h&&!M?h(t,y.encoder,F,"key",L):t;C=""}if(s(C)||T.isBuffer(C)){if(h){var W=M?t:h(t,y.encoder,F,"key",L);if(u==="comma"&&M){for(var Y=E.call(String(C),","),K="",H=0;H<Y.length;++H)K+=(H===0?"":",")+b(h(Y[H],y.encoder,F,"value",L));return[b(W)+"="+K]}return[b(W)+"="+b(h(C,y.encoder,F,"value",L))]}return[b(t)+"="+b(String(C))]}var z=[];if(C===void 0)return z;var $;if(u==="comma"&&_(C))$=[{value:C.length>0?C.join(",")||null:void 0}];else if(_(d))$=d;else{var X=Object.keys(C);$=l?X.sort(l):X}for(var J=0;J<$.length;++J){var te=$[J],Q=typeof te=="object"&&te.value!==void 0?te.value:C[te];if(!r||Q!==null){var ae=_(C)?typeof u=="function"?u(t,te):t:t+(v?"."+te:"["+te+"]");w.set(i,k);var se=p();se.set(e,w),D(z,a(Q,ae,u,c,r,h,d,l,v,m,L,b,M,F,se))}}return z},f=function(a){if(!a)return y;if(a.encoder!==null&&a.encoder!==void 0&&typeof a.encoder!="function")throw new TypeError("Encoder has to be a function.");var i=a.charset||y.charset;if(a.charset!==void 0&&a.charset!=="utf-8"&&a.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var t=I.default;if(a.format!==void 0){if(!S.call(I.formatters,a.format))throw new TypeError("Unknown format option provided.");t=a.format}var u=I.formatters[t],c=y.filter;return(typeof a.filter=="function"||_(a.filter))&&(c=a.filter),{addQueryPrefix:typeof a.addQueryPrefix=="boolean"?a.addQueryPrefix:y.addQueryPrefix,allowDots:a.allowDots===void 0?y.allowDots:!!a.allowDots,charset:i,charsetSentinel:typeof a.charsetSentinel=="boolean"?a.charsetSentinel:y.charsetSentinel,delimiter:a.delimiter===void 0?y.delimiter:a.delimiter,encode:typeof a.encode=="boolean"?a.encode:y.encode,encoder:typeof a.encoder=="function"?a.encoder:y.encoder,encodeValuesOnly:typeof a.encodeValuesOnly=="boolean"?a.encodeValuesOnly:y.encodeValuesOnly,filter:c,format:t,formatter:u,serializeDate:typeof a.serializeDate=="function"?a.serializeDate:y.serializeDate,skipNulls:typeof a.skipNulls=="boolean"?a.skipNulls:y.skipNulls,sort:typeof a.sort=="function"?a.sort:null,strictNullHandling:typeof a.strictNullHandling=="boolean"?a.strictNullHandling:y.strictNullHandling}};P.exports=function(a,i){var t,u,c=a,r=f(i);typeof r.filter=="function"?(u=r.filter,c=u("",c)):_(r.filter)&&(u=r.filter,t=u);var h=[];if(typeof c!="object"||c===null)return"";var d;d=i&&i.arrayFormat in O?i.arrayFormat:i&&"indices"in i?i.indices?"indices":"repeat":"indices";var l=O[d];t||(t=Object.keys(c)),r.sort&&t.sort(r.sort);for(var v=p(),m=0;m<t.length;++m){var L=t[m];r.skipNulls&&c[L]===null||D(h,o(c[L],L,l,r.strictNullHandling,r.skipNulls,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,v))}var b=h.join(r.delimiter),M=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?M+="utf8=%26%2310003%3B&":M+="utf8=%E2%9C%93&"),b.length>0?M+b:""}},function(P,n,R){"use strict";var p=R(8),T=R(47),I=R(49),S=p("%TypeError%"),O=p("%WeakMap%",!0),_=p("%Map%",!0),E=T("WeakMap.prototype.get",!0),A=T("WeakMap.prototype.set",!0),D=T("WeakMap.prototype.has",!0),x=T("Map.prototype.get",!0),g=T("Map.prototype.set",!0),y=T("Map.prototype.has",!0),s=function(a,i){for(var t,u=a;(t=u.next)!==null;u=t)if(t.key===i)return u.next=t.next,t.next=a.next,a.next=t,t},e=function(a,i){var t=s(a,i);return t&&t.value},o=function(a,i,t){var u=s(a,i);u?u.value=t:a.next={key:i,next:a.next,value:t}},f=function(a,i){return!!s(a,i)};P.exports=function(){var a,i,t,u={assert:function(c){if(!u.has(c))throw new S("Side channel does not contain "+I(c))},get:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(a)return E(a,c)}else if(_){if(i)return x(i,c)}else if(t)return e(t,c)},has:function(c){if(O&&c&&(typeof c=="object"||typeof c=="function")){if(a)return D(a,c)}else if(_){if(i)return y(i,c)}else if(t)return f(t,c);return!1},set:function(c,r){O&&c&&(typeof c=="object"||typeof c=="function")?(a||(a=new O),A(a,c,r)):_?(i||(i=new _),g(i,c,r)):(t||(t={key:{},next:null}),o(t,c,r))}};return u}},function(P,n,R){"use strict";var p=typeof Symbol!="undefined"&&Symbol,T=R(44);P.exports=function(){return typeof p=="function"&&typeof Symbol=="function"&&typeof p("foo")=="symbol"&&typeof Symbol("bar")=="symbol"&&T()}},function(P,n,R){"use strict";P.exports=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var p={},T=Symbol("test"),I=Object(T);if(typeof T=="string"||Object.prototype.toString.call(T)!=="[object Symbol]"||Object.prototype.toString.call(I)!=="[object Symbol]")return!1;p[T]=42;for(T in p)return!1;if(typeof Object.keys=="function"&&Object.keys(p).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(p).length!==0)return!1;var S=Object.getOwnPropertySymbols(p);if(S.length!==1||S[0]!==T||!Object.prototype.propertyIsEnumerable.call(p,T))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var O=Object.getOwnPropertyDescriptor(p,T);if(O.value!==42||O.enumerable!==!0)return!1}return!0}},function(P,n,R){"use strict";var p=Array.prototype.slice,T=Object.prototype.toString;P.exports=function(I){var S=this;if(typeof S!="function"||T.call(S)!=="[object Function]")throw new TypeError("Function.prototype.bind called on incompatible "+S);for(var O,_=p.call(arguments,1),E=function(){if(this instanceof O){var y=S.apply(this,_.concat(p.call(arguments)));return Object(y)===y?y:this}return S.apply(I,_.concat(p.call(arguments)))},A=Math.max(0,S.length-_.length),D=[],x=0;x<A;x++)D.push("$"+x);if(O=Function("binder","return function ("+D.join(",")+"){ return binder.apply(this,arguments); }")(E),S.prototype){var g=function(){};g.prototype=S.prototype,O.prototype=new g,g.prototype=null}return O}},function(P,n,R){"use strict";var p=R(9);P.exports=p.call(Function.call,Object.prototype.hasOwnProperty)},function(P,n,R){"use strict";var p=R(8),T=R(48),I=T(p("String.prototype.indexOf"));P.exports=function(S,O){var _=p(S,!!O);return typeof _=="function"&&I(S,".prototype.")>-1?T(_):_}},function(P,n,R){"use strict";var p=R(9),T=R(8),I=T("%Function.prototype.apply%"),S=T("%Function.prototype.call%"),O=T("%Reflect.apply%",!0)||p.call(S,I),_=T("%Object.getOwnPropertyDescriptor%",!0),E=T("%Object.defineProperty%",!0),A=T("%Math.max%");if(E)try{E({},"a",{value:1})}catch{E=null}P.exports=function(x){var g=O(p,S,arguments);return _&&E&&_(g,"length").configurable&&E(g,"length",{value:1+A(0,x.length-(arguments.length-1))}),g};var D=function(){return O(p,I,arguments)};E?E(P.exports,"apply",{value:D}):P.exports.apply=D},function(P,n,R){function p(G,V){if(G===1/0||G===-1/0||G!==G||G&&G>-1e3&&G<1e3||fe.call(/e/,V))return V;var ue=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof G=="number"){var he=G<0?-ye(-G):ye(G);if(he!==G){var pe=String(he),_e=re.call(V,pe.length+1);return ee.call(pe,ue,"$&_")+"."+ee.call(ee.call(_e,/([0-9]{3})/g,"$&_"),/_$/,"")}}return ee.call(V,ue,"$&_")}function T(G,V,ue){var he=(ue.quoteStyle||V)==="double"?'"':"'";return he+G+he}function I(G){return ee.call(String(G),/"/g,""")}function S(G){return!(e(G)!=="[object Array]"||Ee&&typeof G=="object"&&Ee in G)}function O(G){return!(e(G)!=="[object Date]"||Ee&&typeof G=="object"&&Ee in G)}function _(G){return!(e(G)!=="[object RegExp]"||Ee&&typeof G=="object"&&Ee in G)}function E(G){return!(e(G)!=="[object Error]"||Ee&&typeof G=="object"&&Ee in G)}function A(G){return!(e(G)!=="[object String]"||Ee&&typeof G=="object"&&Ee in G)}function D(G){return!(e(G)!=="[object Number]"||Ee&&typeof G=="object"&&Ee in G)}function x(G){return!(e(G)!=="[object Boolean]"||Ee&&typeof G=="object"&&Ee in G)}function g(G){if(Se)return G&&typeof G=="object"&&G instanceof Symbol;if(typeof G=="symbol")return!0;if(!G||typeof G!="object"||!de)return!1;try{return de.call(G),!0}catch{}return!1}function y(G){if(!G||typeof G!="object"||!Te)return!1;try{return Te.call(G),!0}catch{}return!1}function s(G,V){return xe.call(G,V)}function e(G){return Q.call(G)}function o(G){if(G.name)return G.name;var V=se.call(ae.call(G),/^function\s*([\w$]+)/);return V?V[1]:null}function f(G,V){if(G.indexOf)return G.indexOf(V);for(var ue=0,he=G.length;ue<he;ue++)if(G[ue]===V)return ue;return-1}function a(G){if(!U||!G||typeof G!="object")return!1;try{U.call(G);try{W.call(G)}catch{return!0}return G instanceof Map}catch{}return!1}function i(G){if(!H||!G||typeof G!="object")return!1;try{H.call(G,H);try{$.call(G,$)}catch{return!0}return G instanceof WeakMap}catch{}return!1}function t(G){if(!J||!G||typeof G!="object")return!1;try{return J.call(G),!0}catch{}return!1}function u(G){if(!W||!G||typeof G!="object")return!1;try{W.call(G);try{U.call(G)}catch{return!0}return G instanceof Set}catch{}return!1}function c(G){if(!$||!G||typeof G!="object")return!1;try{$.call(G,$);try{H.call(G,H)}catch{return!0}return G instanceof WeakSet}catch{}return!1}function r(G){return!(!G||typeof G!="object")&&(typeof HTMLElement!="undefined"&&G instanceof HTMLElement||typeof G.nodeName=="string"&&typeof G.getAttribute=="function")}function h(G,V){if(G.length>V.maxStringLength){var ue=G.length-V.maxStringLength,he="... "+ue+" more character"+(ue>1?"s":"");return h(re.call(G,0,V.maxStringLength),V)+he}return T(ee.call(ee.call(G,/(['\\])/g,"\\$1"),/[\x00-\x1f]/g,d),"single",V)}function d(G){var V=G.charCodeAt(0),ue={8:"b",9:"t",10:"n",12:"f",13:"r"}[V];return ue?"\\"+ue:"\\x"+(V<16?"0":"")+Z.call(V.toString(16))}function l(G){return"Object("+G+")"}function v(G){return G+" { ? }"}function m(G,V,ue,he){return G+" ("+V+") {"+(he?M(ue,he):ie.call(ue,", "))+"}"}function L(G){for(var V=0;V<G.length;V++)if(f(G[V],`
|
|
2
|
+
`)>=0)return!1;return!0}function b(G,V){var ue;if(G.indent===" ")ue=" ";else{if(!(typeof G.indent=="number"&&G.indent>0))return null;ue=ie.call(Array(G.indent+1)," ")}return{base:ue,prev:ie.call(Array(V+1),ue)}}function M(G,V){if(G.length===0)return"";var ue=`
|
|
3
|
+
`+V.prev+V.base;return ue+ie.call(G,","+ue)+`
|
|
4
|
+
`+V.prev}function F(G,V){var ue=S(G),he=[];if(ue){he.length=G.length;for(var pe=0;pe<G.length;pe++)he[pe]=s(G,pe)?V(G[pe],G):""}var _e,le=typeof oe=="function"?oe(G):[];if(Se){_e={};for(var Re=0;Re<le.length;Re++)_e["$"+le[Re]]=le[Re]}for(var Le in G)s(G,Le)&&(ue&&String(Number(Le))===Le&&Le<G.length||Se&&_e["$"+Le]instanceof Symbol||(fe.call(/[^\w$]/,Le)?he.push(V(Le,G)+": "+V(G[Le],G)):he.push(Le+": "+V(G[Le],G))));if(typeof oe=="function")for(var Ie=0;Ie<le.length;Ie++)Ae.call(G,le[Ie])&&he.push("["+V(le[Ie])+"]: "+V(G[le[Ie]],G));return he}var w=typeof Map=="function"&&Map.prototype,C=Object.getOwnPropertyDescriptor&&w?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,U=w&&C&&typeof C.get=="function"?C.get:null,k=w&&Map.prototype.forEach,j=typeof Set=="function"&&Set.prototype,N=Object.getOwnPropertyDescriptor&&j?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,W=j&&N&&typeof N.get=="function"?N.get:null,Y=j&&Set.prototype.forEach,K=typeof WeakMap=="function"&&WeakMap.prototype,H=K?WeakMap.prototype.has:null,z=typeof WeakSet=="function"&&WeakSet.prototype,$=z?WeakSet.prototype.has:null,X=typeof WeakRef=="function"&&WeakRef.prototype,J=X?WeakRef.prototype.deref:null,te=Boolean.prototype.valueOf,Q=Object.prototype.toString,ae=Function.prototype.toString,se=String.prototype.match,re=String.prototype.slice,ee=String.prototype.replace,Z=String.prototype.toUpperCase,q=String.prototype.toLowerCase,fe=RegExp.prototype.test,ge=Array.prototype.concat,ie=Array.prototype.join,me=Array.prototype.slice,ye=Math.floor,Te=typeof BigInt=="function"?BigInt.prototype.valueOf:null,oe=Object.getOwnPropertySymbols,de=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol.prototype.toString:null,Se=typeof Symbol=="function"&&typeof Symbol.iterator=="object",Ee=typeof Symbol=="function"&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Se?"object":"symbol")?Symbol.toStringTag:null,Ae=Object.prototype.propertyIsEnumerable,Oe=(typeof Reflect=="function"?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(G){return G.__proto__}:null),Me=R(50).custom,De=Me&&g(Me)?Me:null;P.exports=function G(V,ue,he,pe){function _e(ze,pt,Or){if(pt&&(pe=me.call(pe),pe.push(pt)),Or){var Xt={depth:le.depth};return s(le,"quoteStyle")&&(Xt.quoteStyle=le.quoteStyle),G(ze,Xt,he+1,pe)}return G(ze,le,he+1,pe)}var le=ue||{};if(s(le,"quoteStyle")&&le.quoteStyle!=="single"&&le.quoteStyle!=="double")throw new TypeError('option "quoteStyle" must be "single" or "double"');if(s(le,"maxStringLength")&&(typeof le.maxStringLength=="number"?le.maxStringLength<0&&le.maxStringLength!==1/0:le.maxStringLength!==null))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var Re=!s(le,"customInspect")||le.customInspect;if(typeof Re!="boolean"&&Re!=="symbol")throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(s(le,"indent")&&le.indent!==null&&le.indent!==" "&&!(parseInt(le.indent,10)===le.indent&&le.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(s(le,"numericSeparator")&&typeof le.numericSeparator!="boolean")throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var Le=le.numericSeparator;if(V===void 0)return"undefined";if(V===null)return"null";if(typeof V=="boolean")return V?"true":"false";if(typeof V=="string")return h(V,le);if(typeof V=="number"){if(V===0)return 1/0/V>0?"0":"-0";var Ie=String(V);return Le?p(V,Ie):Ie}if(typeof V=="bigint"){var je=String(V)+"n";return Le?p(V,je):je}var ke=le.depth===void 0?5:le.depth;if(he===void 0&&(he=0),he>=ke&&ke>0&&typeof V=="object")return S(V)?"[Array]":"[Object]";var Be=b(le,he);if(pe===void 0)pe=[];else if(f(pe,V)>=0)return"[Circular]";if(typeof V=="function"){var et=o(V),He=F(V,_e);return"[Function"+(et?": "+et:" (anonymous)")+"]"+(He.length>0?" { "+ie.call(He,", ")+" }":"")}if(g(V)){var Ce=Se?ee.call(String(V),/^(Symbol\(.*\))_[^)]*$/,"$1"):de.call(V);return typeof V!="object"||Se?Ce:l(Ce)}if(r(V)){for(var Ke="<"+q.call(String(V.nodeName)),Ve=V.attributes||[],Ye=0;Ye<Ve.length;Ye++)Ke+=" "+Ve[Ye].name+"="+T(I(Ve[Ye].value),"double",le);return Ke+=">",V.childNodes&&V.childNodes.length&&(Ke+="..."),Ke+="</"+q.call(String(V.nodeName))+">"}if(S(V)){if(V.length===0)return"[]";var tt=F(V,_e);return Be&&!L(tt)?"["+M(tt,Be)+"]":"[ "+ie.call(tt,", ")+" ]"}if(E(V)){var rt=F(V,_e);return"cause"in V&&!Ae.call(V,"cause")?"{ ["+String(V)+"] "+ie.call(ge.call("[cause]: "+_e(V.cause),rt),", ")+" }":rt.length===0?"["+String(V)+"]":"{ ["+String(V)+"] "+ie.call(rt,", ")+" }"}if(typeof V=="object"&&Re){if(De&&typeof V[De]=="function")return V[De]();if(Re!=="symbol"&&typeof V.inspect=="function")return V.inspect()}if(a(V)){var vt=[];return k.call(V,function(ze,pt){vt.push(_e(pt,V,!0)+" => "+_e(ze,V))}),m("Map",U.call(V),vt,Be)}if(u(V)){var gt=[];return Y.call(V,function(ze){gt.push(_e(ze,V))}),m("Set",W.call(V),gt,Be)}if(i(V))return v("WeakMap");if(c(V))return v("WeakSet");if(t(V))return v("WeakRef");if(D(V))return l(_e(Number(V)));if(y(V))return l(_e(Te.call(V)));if(x(V))return l(te.call(V));if(A(V))return l(_e(String(V)));if(!O(V)&&!_(V)){var We=F(V,_e),it=Oe?Oe(V)===Object.prototype:V instanceof Object||V.constructor===Object,nt=V instanceof Object?"":"null prototype",mt=!it&&Ee&&Object(V)===V&&Ee in V?re.call(e(V),8,-1):nt?"Object":"",Lr=it||typeof V.constructor!="function"?"":V.constructor.name?V.constructor.name+" ":"",_t=Lr+(mt||nt?"["+ie.call(ge.call([],mt||[],nt||[]),": ")+"] ":"");return We.length===0?_t+"{}":Be?_t+"{"+M(We,Be)+"}":_t+"{ "+ie.call(We,", ")+" }"}return String(V)};var xe=Object.prototype.hasOwnProperty||function(G){return G in this}},function(P,n){},function(P,n,R){"use strict";var p=R(16),T=Object.prototype.hasOwnProperty,I=Array.isArray,S={allowDots:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decoder:p.decode,delimiter:"&",depth:5,ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},O=function(g){return g.replace(/&#(\d+);/g,function(y,s){return String.fromCharCode(parseInt(s,10))})},_=function(g,y){return g&&typeof g=="string"&&y.comma&&g.indexOf(",")>-1?g.split(","):g},E=function(g,y){var s,e={},o=y.ignoreQueryPrefix?g.replace(/^\?/,""):g,f=y.parameterLimit===1/0?void 0:y.parameterLimit,a=o.split(y.delimiter,f),i=-1,t=y.charset;if(y.charsetSentinel)for(s=0;s<a.length;++s)a[s].indexOf("utf8=")===0&&(a[s]==="utf8=%E2%9C%93"?t="utf-8":a[s]==="utf8=%26%2310003%3B"&&(t="iso-8859-1"),i=s,s=a.length);for(s=0;s<a.length;++s)if(s!==i){var u,c,r=a[s],h=r.indexOf("]="),d=h===-1?r.indexOf("="):h+1;d===-1?(u=y.decoder(r,S.decoder,t,"key"),c=y.strictNullHandling?null:""):(u=y.decoder(r.slice(0,d),S.decoder,t,"key"),c=p.maybeMap(_(r.slice(d+1),y),function(l){return y.decoder(l,S.decoder,t,"value")})),c&&y.interpretNumericEntities&&t==="iso-8859-1"&&(c=O(c)),r.indexOf("[]=")>-1&&(c=I(c)?[c]:c),T.call(e,u)?e[u]=p.combine(e[u],c):e[u]=c}return e},A=function(g,y,s,e){for(var o=e?y:_(y,s),f=g.length-1;f>=0;--f){var a,i=g[f];if(i==="[]"&&s.parseArrays)a=[].concat(o);else{a=s.plainObjects?Object.create(null):{};var t=i.charAt(0)==="["&&i.charAt(i.length-1)==="]"?i.slice(1,-1):i,u=parseInt(t,10);s.parseArrays||t!==""?!isNaN(u)&&i!==t&&String(u)===t&&u>=0&&s.parseArrays&&u<=s.arrayLimit?(a=[],a[u]=o):t!=="__proto__"&&(a[t]=o):a={0:o}}o=a}return o},D=function(g,y,s,e){if(g){var o=s.allowDots?g.replace(/\.([^.[]+)/g,"[$1]"):g,f=/(\[[^[\]]*])/,a=/(\[[^[\]]*])/g,i=s.depth>0&&f.exec(o),t=i?o.slice(0,i.index):o,u=[];if(t){if(!s.plainObjects&&T.call(Object.prototype,t)&&!s.allowPrototypes)return;u.push(t)}for(var c=0;s.depth>0&&(i=a.exec(o))!==null&&c<s.depth;){if(c+=1,!s.plainObjects&&T.call(Object.prototype,i[1].slice(1,-1))&&!s.allowPrototypes)return;u.push(i[1])}return i&&u.push("["+o.slice(i.index)+"]"),A(u,y,s,e)}},x=function(g){if(!g)return S;if(g.decoder!==null&&g.decoder!==void 0&&typeof g.decoder!="function")throw new TypeError("Decoder has to be a function.");if(g.charset!==void 0&&g.charset!=="utf-8"&&g.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var y=g.charset===void 0?S.charset:g.charset;return{allowDots:g.allowDots===void 0?S.allowDots:!!g.allowDots,allowPrototypes:typeof g.allowPrototypes=="boolean"?g.allowPrototypes:S.allowPrototypes,allowSparse:typeof g.allowSparse=="boolean"?g.allowSparse:S.allowSparse,arrayLimit:typeof g.arrayLimit=="number"?g.arrayLimit:S.arrayLimit,charset:y,charsetSentinel:typeof g.charsetSentinel=="boolean"?g.charsetSentinel:S.charsetSentinel,comma:typeof g.comma=="boolean"?g.comma:S.comma,decoder:typeof g.decoder=="function"?g.decoder:S.decoder,delimiter:typeof g.delimiter=="string"||p.isRegExp(g.delimiter)?g.delimiter:S.delimiter,depth:typeof g.depth=="number"||g.depth===!1?+g.depth:S.depth,ignoreQueryPrefix:g.ignoreQueryPrefix===!0,interpretNumericEntities:typeof g.interpretNumericEntities=="boolean"?g.interpretNumericEntities:S.interpretNumericEntities,parameterLimit:typeof g.parameterLimit=="number"?g.parameterLimit:S.parameterLimit,parseArrays:g.parseArrays!==!1,plainObjects:typeof g.plainObjects=="boolean"?g.plainObjects:S.plainObjects,strictNullHandling:typeof g.strictNullHandling=="boolean"?g.strictNullHandling:S.strictNullHandling}};P.exports=function(g,y){var s=x(y);if(g===""||g===null||g===void 0)return s.plainObjects?Object.create(null):{};for(var e=typeof g=="string"?E(g,s):g,o=s.plainObjects?Object.create(null):{},f=Object.keys(e),a=0;a<f.length;++a){var i=f[a],t=D(i,e[i],s,typeof g=="string");o=p.merge(o,t,s)}return s.allowSparse===!0?o:p.compact(o)}},function(P,n,R){"use strict";var p,T,I=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(S){return typeof S}:function(S){return S&&typeof Symbol=="function"&&S.constructor===Symbol&&S!==Symbol.prototype?"symbol":typeof S};(function(S){var O=!1;if(p=S,(T=typeof p=="function"?p.call(n,R,n,P):p)!==void 0&&(P.exports=T),O=!0,I(n)==="object"&&(P.exports=S(),O=!0),!O){var _=window.Cookies,E=window.Cookies=S();E.noConflict=function(){return window.Cookies=_,E}}})(function(){function S(_){function E(A,D,x){var g;if(typeof document!="undefined"){if(arguments.length>1){if(x=O({path:"/"},E.defaults,x),typeof x.expires=="number"){var y=new Date;y.setMilliseconds(y.getMilliseconds()+864e5*x.expires),x.expires=y}try{g=JSON.stringify(D),/^[\{\[]/.test(g)&&(D=g)}catch{}return D=_.write?_.write(D,A):encodeURIComponent(String(D)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),A=encodeURIComponent(String(A)),A=A.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),A=A.replace(/[\(\)]/g,escape),document.cookie=[A,"=",D,x.expires?"; expires="+x.expires.toUTCString():"",x.path?"; path="+x.path:"",x.domain?"; domain="+x.domain:"",x.secure?"; secure":""].join("")}A||(g={});for(var s=document.cookie?document.cookie.split("; "):[],e=/(%[0-9A-Z]{2})+/g,o=0;o<s.length;o++){var f=s[o].split("="),a=f.slice(1).join("=");a.charAt(0)==='"'&&(a=a.slice(1,-1));try{var i=f[0].replace(e,decodeURIComponent);if(a=_.read?_.read(a,i):_(a,i)||a.replace(e,decodeURIComponent),this.json)try{a=JSON.parse(a)}catch{}if(A===i){g=a;break}A||(g[i]=a)}catch{}}return g}}return E.set=E,E.get=function(A){return E.call(E,A)},E.getJSON=function(){return E.apply({json:!0},[].slice.call(arguments))},E.defaults={},E.remove=function(A,D){E(A,"",O(D,{expires:-1}))},E.withConverter=S,E}var O=function(){for(var _=0,E={};_<arguments.length;_++){var A=arguments[_];for(var D in A)E[D]=A[D]}return E};return S(function(){})})},function(P,n,R){"use strict";function p(T,I){var S=I.beaconCollectionDomain,O=I.beaconDomain;if(S)return"https://"+S;T=T||"inferred";var _=O||"litix.io";return T.match(/^[a-z0-9]+$/)?"https://"+T+"."+_:"https://img.litix.io/a.gif"}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p=R(0),T=function(O){return O&&O.__esModule?O:{default:O}}(p),I=function(){var O=void 0;switch(S()){case"cellular":O="cellular";break;case"ethernet":O="wired";break;case"wifi":O="wifi";break;case void 0:break;default:O="other"}return O},S=function(){var O=T.default.navigator,_=O&&(O.connection||O.mozConnection||O.webkitConnection);return _&&_.type};n.default=I},function(P,n,R){"use strict";function p(a){return a&&a.__esModule?a:{default:a}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(0),I=p(T),S=R(4),O=p(S),_=R(56),E=p(_),A=R(1),D=p(A),x=R(17),g=p(x),y=R(2),s=p(y),e=!!I.default.XMLHttpRequest&&"withCredentials"in new I.default.XMLHttpRequest,o={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4},f=function(a,i){this._beaconUrl=a||"https://img.litix.io",this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=(0,D.default)({},o,i)};f.prototype.queueEvent=function(a,i){var t=(0,D.default)({},i);return e?(this._eventQueue.length<=this._options.maxQueueLength||a==="eventrateexceeded")&&(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):(E.default.send(this._beaconUrl,t),!0)},f.prototype.flushEvents=function(){e&&(this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending())},f.prototype.destroy=function(){var a=arguments.length>0&&arguments[0]!==void 0&&arguments[0];this.destroyed=!0,a?this._clearBeaconQueue():this.flushEvents(),I.default.clearTimeout(this._sendTimeout)},f.prototype._clearBeaconQueue=function(){var a=I.default.navigator,i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,t=this._eventQueue.slice(i);i>0&&(0,D.default)(t[t.length-1],(0,g.default)({mux_view_message:"event queue truncated"}));var u=this._createPayload(t);if(a.sendBeacon)a.sendBeacon(this._beaconUrl,u);else if(I.default.XMLHttpRequest){var c=new I.default.XMLHttpRequest;c.open("POST",this._beaconUrl),c.setRequestHeader("Content-Type","application/json"),c.send(u)}else E.default.send(this._beaconUrl,t[t.length-1])},f.prototype._sendBeaconQueue=function(){var a=this;if(I.default.XMLHttpRequest&&!this._postInFlight){var i=new I.default.XMLHttpRequest,t=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0,i.onreadystatechange=function(){i.readyState===4&&(i.status!==200?(a._eventQueue=t.concat(a._eventQueue),a._failureCount+=1,O.default.info("Error sending beacon: "+i.status),O.default.info(i.responseText)):a._failureCount=0,a._roundTripTime=s.default.now()-c,a._postInFlight=!1)},i.open("POST",this._beaconUrl),i.setRequestHeader("Content-Type","application/json");var u=this._createPayload(t),c=s.default.now();i.send(u)}},f.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var a=Math.pow(2,this._failureCount-1);return(1+(a*=Math.random()))*this._options.baseTimeBetweenBeacons},f.prototype._startBeaconSending=function(){var a=this;I.default.clearTimeout(this._sendTimeout),this.destroyed||(this._sendTimeout=I.default.setTimeout(function(){a._eventQueue.length&&a._sendBeaconQueue(),a._startBeaconSending()},this._getNextBeaconTime()))},f.prototype._createPayload=function(a){var i={transmission_timestamp:Math.round(s.default.now())};return this._roundTripTime&&(i.rtt_ms=Math.round(this._roundTripTime)),JSON.stringify({metadata:i,events:a})},n.default=f},function(P,n,R){"use strict";function p(E){return E&&E.__esModule?E:{default:E}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(15),I=p(T),S=R(0),O=p(S),_={};_.send=function(E,A){function D(){x.src=y+(g?"&rc="+g:"")}var x=new Image,g=0,y=E+"?"+I.default.stringify(A);return x.addEventListener("error",function(){g>3||O.default.setTimeout(function(){g++,D()},5e3*g)}),D(),x},n.default=_},function(P,n,R){"use strict";function p(){function T(y,s){var e=s.request_start,o=s.request_response_start,f=s.request_response_end,a=s.request_bytes_loaded;A++;var i=void 0,t=void 0;if(o?(i=o-e,t=f-o):t=f-e,t>0&&a>0){var u=a/t*8e3;D++,_+=a,E+=t,this.data.view_min_request_throughput=Math.min(this.data.view_min_request_throughput||1/0,u),this.data.view_average_request_throughput=_/E*8e3,this.data.view_request_count=A,i>0&&(O+=i,this.data.view_max_request_latency=Math.max(this.data.view_max_request_latency||0,i),this.data.view_average_request_latency=O/D)}}function I(y,s){A++,x++,this.data.view_request_count=A,this.data.view_request_failed_count=x}function S(y,s){A++,g++,this.data.view_request_count=A,this.data.view_request_canceled_count=g}var O=0,_=0,E=0,A=0,D=0,x=0,g=0;this.on("requestcompleted",T),this.on("requestfailed",I),this.on("requestcanceled",S)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";function p(D,x,g){var y=(0,_.findMediaElement)(x),s=I(y,3),e=s[0],o=s[1],f=s[2],a=D.log,i=D.utils.getComputedStyle,t=D.utils.secondsToMs,u={automaticErrorTracking:!0};if(!e)return a.error("No element was found with the `"+o+"` query selector.");if(f!=="video"&&f!=="audio")return a.error("The element of `"+o+"` was not a media element.");g=(0,O.default)(u,g),g.data=(0,O.default)({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:"4.8.0"},g.data),g.getPlayheadTime=function(){return t(e.currentTime)},g.getStateData=function(){var r=this.hlsjs&&this.hlsjs.url,h=this.dashjs&&T(this.dashjs.getSource==="function")&&this.dashjs.getSource();return{player_is_paused:e.paused,player_playhead_time:t(e.currentTime),player_width:parseInt(i(e,"width")),player_height:parseInt(i(e,"height")),player_autoplay_on:e.autoplay,player_preload_on:e.preload,video_poster_url:e.poster,video_source_url:r||h||e.currentSrc,video_source_duration:t(e.duration),video_source_height:e.videoHeight,video_source_width:e.videoWidth}},e.mux=e.mux||{},e.mux.deleted=!1,e.mux.emit=function(r,h){D.emit(o,r,h)};var c=function(){a.error("The monitor for this video element has already been destroyed.")};e.mux.destroy=function(){Object.keys(e.mux.listeners).forEach(function(r){e.removeEventListener(r,e.mux.listeners[r],!1)}),delete e.mux.listeners,e.mux.destroy=c,e.mux.swapElement=c,e.mux.emit=c,e.mux.addHLSJS=c,e.mux.addDashJS=c,e.mux.removeHLSJS=c,e.mux.removeDashJS=c,e.mux.deleted=!0,D.emit(o,"destroy")},e.mux.swapElement=function(r){var h=(0,_.findMediaElement)(r),d=I(h,3),l=d[0],v=d[1],m=d[2];return l?m!=="video"&&m!=="audio"?D.log.error("The element of `"+v+"` was not a media element."):(l.muxId=e.muxId,delete e.muxId,l.mux=l.mux||{},l.mux.listeners=(0,O.default)({},e.mux.listeners),delete e.mux.listeners,Object.keys(l.mux.listeners).forEach(function(L){e.removeEventListener(L,l.mux.listeners[L],!1),l.addEventListener(L,l.mux.listeners[L],!1)}),l.mux.swapElement=e.mux.swapElement,l.mux.destroy=e.mux.destroy,delete e.mux,void(e=l)):D.log.error("No element was found with the `"+v+"` query selector.")},e.mux.addHLSJS=function(r){D.addHLSJS(o,r)},e.mux.addDashJS=function(r){D.addDashJS(o,r)},e.mux.removeHLSJS=function(){D.removeHLSJS(o)},e.mux.removeDashJS=function(){D.removeDashJS(o)},D.init(o,g),D.emit(o,"playerready"),e.paused||(D.emit(o,"play"),e.readyState>2&&D.emit(o,"playing")),e.mux.listeners={},E.forEach(function(r){(r!=="error"||g.automaticErrorTracking)&&(e.mux.listeners[r]=function(){var h={};if(r==="error"){if(!e.error||e.error.code===1)return;h.player_error_code=e.error.code,h.player_error_message=A[e.error.code]||e.error.message}D.emit(o,r,h)},e.addEventListener(r,e.mux.listeners[r],!1))})}Object.defineProperty(n,"__esModule",{value:!0});var T=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(D){return typeof D}:function(D){return D&&typeof Symbol=="function"&&D.constructor===Symbol&&D!==Symbol.prototype?"symbol":typeof D},I=function(){function D(x,g){var y=[],s=!0,e=!1,o=void 0;try{for(var f,a=x[Symbol.iterator]();!(s=(f=a.next()).done)&&(y.push(f.value),!g||y.length!==g);s=!0);}catch(i){e=!0,o=i}finally{try{!s&&a.return&&a.return()}finally{if(e)throw o}}return y}return function(x,g){if(Array.isArray(x))return x;if(Symbol.iterator in Object(x))return D(x,g);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.default=p;var S=R(1),O=function(D){return D&&D.__esModule?D:{default:D}}(S),_=R(11),E=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],A={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"}},function(P,n,R){"use strict";function p(u){return u&&u.__esModule?u:{default:u}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(60),I=p(T),S=R(3),O=p(S),_=R(61),E=p(_),A=R(62),D=p(A),x=R(1),g=p(x),y=R(7),s=p(y),e=R(5),o=R(2),f=p(o),a=R(63),i=p(a),t={};t.safeCall=I.default,t.safeIncrement=O.default,t.getComputedStyle=E.default,t.secondsToMs=D.default,t.assign=g.default,t.headersStringToObject=s.default,t.extractHostnameAndDomain=e.extractHostnameAndDomain,t.extractHostname=e.extractHostname,t.now=f.default.now,t.manifestParser=i.default,n.default=t},function(P,n,R){"use strict";function p(S,O,_,E){var A=E;if(S&&typeof S[O]=="function")try{A=S[O].apply(S,_)}catch(D){I.default.info("safeCall error",D)}return A}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(4),I=function(S){return S&&S.__esModule?S:{default:S}}(T)},function(P,n,R){"use strict";function p(O,_){if(O&&_&&I.default&&typeof I.default.getComputedStyle=="function"){var E=void 0;return S&&S.has(O)&&(E=S.get(O)),E||(E=I.default.getComputedStyle(O,null),S&&S.set(O,E)),E.getPropertyValue(_)}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p;var T=R(0),I=function(O){return O&&O.__esModule?O:{default:O}}(T),S=void 0;I.default&&I.default.WeakMap&&(S=new WeakMap)},function(P,n,R){"use strict";function p(T){return Math.floor(1e3*T)}Object.defineProperty(n,"__esModule",{value:!0}),n.default=p},function(P,n,R){"use strict";function p(f){return f&&f.__esModule?f:{default:f}}Object.defineProperty(n,"__esModule",{value:!0});var T=R(1),I=p(T),S=R(14),O=p(S),_={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},E=function(f){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(f),this.manifest};E.prototype.process=function(f){var a=void 0;for(this.buffer+=f,a=this.buffer.indexOf(`
|
|
5
|
+
`);a>-1;a=this.buffer.indexOf(`
|
|
6
|
+
`))this.processLine(this.buffer.substring(0,a)),this.buffer=this.buffer.substring(a+1)},E.prototype.processLine=function(f){var a=f.indexOf(":"),i=e(f,a),t=i[0],u=i.length===2?x(i[1]):void 0;if(t[0]!=="#")this.currentUri.uri=t,this.manifest.segments.push(this.currentUri),!this.manifest.targetDuration||"duration"in this.currentUri||(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(t){case _.TARGET_DURATION:if(!isFinite(u)||u<0)return;this.manifest.targetDuration=u,this.setHoldBack();break;case _.PART_INF:A(this.manifest,i),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break;case _.SERVER_CONTROL:A(this.manifest,i),this.setHoldBack();break;case _.INF:u===0?this.currentUri.duration=.01:u>0&&(this.currentUri.duration=u);break;case _.PROGRAM_DATE_TIME:var c=u,r=new Date(c);this.manifest.dateTimeString||(this.manifest.dateTimeString=c,this.manifest.dateTimeObject=r),this.currentUri.dateTimeString=c,this.currentUri.dateTimeObject=r;break;case _.VERSION:A(this.manifest,i);break;case _.SESSION_DATA:var h=o(i[1]),d=(0,O.default)(h);(0,I.default)(this.manifest.sessionData,d)}},E.prototype.setHoldBack=function(){var f=this.manifest,a=f.serverControl,i=f.targetDuration,t=f.partTargetDuration;if(a){var u="holdBack",c="partHoldBack",r=i&&3*i,h=t&&2*t;i&&!a.hasOwnProperty(u)&&(a[u]=r),r&&a[u]<r&&(a[u]=r),t&&!a.hasOwnProperty(c)&&(a[c]=3*t),t&&a[c]<h&&(a[c]=h)}};var A=function(f,a){var i=D(a[0].replace("#EXT-X-","")),t=void 0;s(a[1])?(t={},t=(0,I.default)(y(a[1]),t)):t=x(a[1]),f[i]=t},D=function(f){return f.toLowerCase().replace(/-(\w)/g,function(a){return a[1].toUpperCase()})},x=function(f){if(f.toLowerCase()==="yes"||f.toLowerCase()==="no")return f.toLowerCase()==="yes";var a=f.indexOf(":")!==-1?f:parseFloat(f);return isNaN(a)?f:a},g=function(f){var a={},i=f.split("=");return i.length>1&&(a[D(i[0])]=x(i[1])),a},y=function(f){for(var a=f.split(","),i={},t=0;a.length>t;t++){var u=a[t],c=g(u);i=(0,I.default)(c,i)}return i},s=function(f){return f.indexOf("=")>-1},e=function(f,a){return a===-1?[f]:[f.substring(0,a),f.substring(a+1)]},o=function(f){var a={};if(f){var i=f.search(",");return[f.slice(0,i),f.slice(i+1)].forEach(function(t,u){for(var c=t.replace(/['"]+/g,"").split("="),r=0;r<c.length;r++)c[r]==="DATA-ID"&&(a["DATA-ID"]=c[1-r]),c[r]==="VALUE"&&(a.VALUE=c[1-r])}),{data:a}}};n.default=E},function(P,n,R){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var p={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"};n.default=p}])})})()});var Tt=Qt((lt,Mt)=>{typeof window!="undefined"&&function(P,n){typeof lt=="object"&&typeof Mt=="object"?Mt.exports=n():typeof define=="function"&&define.amd?define([],n):typeof lt=="object"?lt.Hls=n():P.Hls=n()}(lt,function(){return function(B){var P={};function n(R){if(P[R])return P[R].exports;var p=P[R]={i:R,l:!1,exports:{}};return B[R].call(p.exports,p,p.exports,n),p.l=!0,p.exports}return n.m=B,n.c=P,n.d=function(R,p,T){n.o(R,p)||Object.defineProperty(R,p,{enumerable:!0,get:T})},n.r=function(R){typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(R,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(R,"__esModule",{value:!0})},n.t=function(R,p){if(p&1&&(R=n(R)),p&8||p&4&&typeof R=="object"&&R&&R.__esModule)return R;var T=Object.create(null);if(n.r(T),Object.defineProperty(T,"default",{enumerable:!0,value:R}),p&2&&typeof R!="string")for(var I in R)n.d(T,I,function(S){return R[S]}.bind(null,I));return T},n.n=function(R){var p=R&&R.__esModule?function(){return R.default}:function(){return R};return n.d(p,"a",p),p},n.o=function(R,p){return Object.prototype.hasOwnProperty.call(R,p)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":function(B,P,n){"use strict";var R=Object.prototype.hasOwnProperty,p="~";function T(){}Object.create&&(T.prototype=Object.create(null),new T().__proto__||(p=!1));function I(E,A,D){this.fn=E,this.context=A,this.once=D||!1}function S(E,A,D,x,g){if(typeof D!="function")throw new TypeError("The listener must be a function");var y=new I(D,x||E,g),s=p?p+A:A;return E._events[s]?E._events[s].fn?E._events[s]=[E._events[s],y]:E._events[s].push(y):(E._events[s]=y,E._eventsCount++),E}function O(E,A){--E._eventsCount===0?E._events=new T:delete E._events[A]}function _(){this._events=new T,this._eventsCount=0}_.prototype.eventNames=function(){var A=[],D,x;if(this._eventsCount===0)return A;for(x in D=this._events)R.call(D,x)&&A.push(p?x.slice(1):x);return Object.getOwnPropertySymbols?A.concat(Object.getOwnPropertySymbols(D)):A},_.prototype.listeners=function(A){var D=p?p+A:A,x=this._events[D];if(!x)return[];if(x.fn)return[x.fn];for(var g=0,y=x.length,s=new Array(y);g<y;g++)s[g]=x[g].fn;return s},_.prototype.listenerCount=function(A){var D=p?p+A:A,x=this._events[D];return x?x.fn?1:x.length:0},_.prototype.emit=function(A,D,x,g,y,s){var e=p?p+A:A;if(!this._events[e])return!1;var o=this._events[e],f=arguments.length,a,i;if(o.fn){switch(o.once&&this.removeListener(A,o.fn,void 0,!0),f){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,D),!0;case 3:return o.fn.call(o.context,D,x),!0;case 4:return o.fn.call(o.context,D,x,g),!0;case 5:return o.fn.call(o.context,D,x,g,y),!0;case 6:return o.fn.call(o.context,D,x,g,y,s),!0}for(i=1,a=new Array(f-1);i<f;i++)a[i-1]=arguments[i];o.fn.apply(o.context,a)}else{var t=o.length,u;for(i=0;i<t;i++)switch(o[i].once&&this.removeListener(A,o[i].fn,void 0,!0),f){case 1:o[i].fn.call(o[i].context);break;case 2:o[i].fn.call(o[i].context,D);break;case 3:o[i].fn.call(o[i].context,D,x);break;case 4:o[i].fn.call(o[i].context,D,x,g);break;default:if(!a)for(u=1,a=new Array(f-1);u<f;u++)a[u-1]=arguments[u];o[i].fn.apply(o[i].context,a)}}return!0},_.prototype.on=function(A,D,x){return S(this,A,D,x,!1)},_.prototype.once=function(A,D,x){return S(this,A,D,x,!0)},_.prototype.removeListener=function(A,D,x,g){var y=p?p+A:A;if(!this._events[y])return this;if(!D)return O(this,y),this;var s=this._events[y];if(s.fn)s.fn===D&&(!g||s.once)&&(!x||s.context===x)&&O(this,y);else{for(var e=0,o=[],f=s.length;e<f;e++)(s[e].fn!==D||g&&!s[e].once||x&&s[e].context!==x)&&o.push(s[e]);o.length?this._events[y]=o.length===1?o[0]:o:O(this,y)}return this},_.prototype.removeAllListeners=function(A){var D;return A?(D=p?p+A:A,this._events[D]&&O(this,D)):(this._events=new T,this._eventsCount=0),this},_.prototype.off=_.prototype.removeListener,_.prototype.addListener=_.prototype.on,_.prefixed=p,_.EventEmitter=_,B.exports=_},"./node_modules/url-toolkit/src/url-toolkit.js":function(B,P,n){(function(R){var p=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,T=/^(?=([^\/?#]*))\1([^]*)$/,I=/(?:\/|^)\.(?=\/)/g,S=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,O={buildAbsoluteURL:function(_,E,A){if(A=A||{},_=_.trim(),E=E.trim(),!E){if(!A.alwaysNormalize)return _;var D=O.parseURL(_);if(!D)throw new Error("Error trying to parse base URL.");return D.path=O.normalizePath(D.path),O.buildURLFromParts(D)}var x=O.parseURL(E);if(!x)throw new Error("Error trying to parse relative URL.");if(x.scheme)return A.alwaysNormalize?(x.path=O.normalizePath(x.path),O.buildURLFromParts(x)):E;var g=O.parseURL(_);if(!g)throw new Error("Error trying to parse base URL.");if(!g.netLoc&&g.path&&g.path[0]!=="/"){var y=T.exec(g.path);g.netLoc=y[1],g.path=y[2]}g.netLoc&&!g.path&&(g.path="/");var s={scheme:g.scheme,netLoc:x.netLoc,path:null,params:x.params,query:x.query,fragment:x.fragment};if(!x.netLoc&&(s.netLoc=g.netLoc,x.path[0]!=="/"))if(!x.path)s.path=g.path,x.params||(s.params=g.params,x.query||(s.query=g.query));else{var e=g.path,o=e.substring(0,e.lastIndexOf("/")+1)+x.path;s.path=O.normalizePath(o)}return s.path===null&&(s.path=A.alwaysNormalize?O.normalizePath(x.path):x.path),O.buildURLFromParts(s)},parseURL:function(_){var E=p.exec(_);return E?{scheme:E[1]||"",netLoc:E[2]||"",path:E[3]||"",params:E[4]||"",query:E[5]||"",fragment:E[6]||""}:null},normalizePath:function(_){for(_=_.split("").reverse().join("").replace(I,"");_.length!==(_=_.replace(S,"")).length;);return _.split("").reverse().join("")},buildURLFromParts:function(_){return _.scheme+_.netLoc+_.path+_.params+_.query+_.fragment}};B.exports=O})(this)},"./node_modules/webworkify-webpack/index.js":function(B,P,n){function R(A){var D={};function x(y){if(D[y])return D[y].exports;var s=D[y]={i:y,l:!1,exports:{}};return A[y].call(s.exports,s,s.exports,x),s.l=!0,s.exports}x.m=A,x.c=D,x.i=function(y){return y},x.d=function(y,s,e){x.o(y,s)||Object.defineProperty(y,s,{configurable:!1,enumerable:!0,get:e})},x.r=function(y){Object.defineProperty(y,"__esModule",{value:!0})},x.n=function(y){var s=y&&y.__esModule?function(){return y.default}:function(){return y};return x.d(s,"a",s),s},x.o=function(y,s){return Object.prototype.hasOwnProperty.call(y,s)},x.p="/",x.oe=function(y){throw console.error(y),y};var g=x(x.s=ENTRY_MODULE);return g.default||g}var p="[\\.|\\-|\\+|\\w|/|@]+",T="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+p+").*?\\)";function I(A){return(A+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function S(A){return!isNaN(1*A)}function O(A,D,x){var g={};g[x]=[];var y=D.toString(),s=y.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!s)return g;for(var e=s[1],o=new RegExp("(\\\\n|\\W)"+I(e)+T,"g"),f;f=o.exec(y);)f[3]!=="dll-reference"&&g[x].push(f[3]);for(o=new RegExp("\\("+I(e)+'\\("(dll-reference\\s('+p+'))"\\)\\)'+T,"g");f=o.exec(y);)A[f[2]]||(g[x].push(f[1]),A[f[2]]=n(f[1]).m),g[f[2]]=g[f[2]]||[],g[f[2]].push(f[4]);for(var a=Object.keys(g),i=0;i<a.length;i++)for(var t=0;t<g[a[i]].length;t++)S(g[a[i]][t])&&(g[a[i]][t]=1*g[a[i]][t]);return g}function _(A){var D=Object.keys(A);return D.reduce(function(x,g){return x||A[g].length>0},!1)}function E(A,D){for(var x={main:[D]},g={main:[]},y={main:{}};_(x);)for(var s=Object.keys(x),e=0;e<s.length;e++){var o=s[e],f=x[o],a=f.pop();if(y[o]=y[o]||{},!(y[o][a]||!A[o][a])){y[o][a]=!0,g[o]=g[o]||[],g[o].push(a);for(var i=O(A,A[o][a],o),t=Object.keys(i),u=0;u<t.length;u++)x[t[u]]=x[t[u]]||[],x[t[u]]=x[t[u]].concat(i[t[u]])}}return g}B.exports=function(A,D){D=D||{};var x={main:n.m},g=D.all?{main:Object.keys(x.main)}:E(x,A),y="";Object.keys(g).filter(function(a){return a!=="main"}).forEach(function(a){for(var i=0;g[a][i];)i++;g[a].push(i),x[a][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",y=y+"var "+a+" = ("+R.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+g[a].map(function(t){return""+JSON.stringify(t)+": "+x[a][t].toString()}).join(",")+`});
|
|
7
|
+
`}),y=y+"new (("+R.toString().replace("ENTRY_MODULE",JSON.stringify(A))+")({"+g.main.map(function(a){return""+JSON.stringify(a)+": "+x.main[a].toString()}).join(",")+"}))(self);";var s=new window.Blob([y],{type:"text/javascript"});if(D.bare)return s;var e=window.URL||window.webkitURL||window.mozURL||window.msURL,o=e.createObjectURL(s),f=new window.Worker(o);return f.objectURL=o,f}},"./src/config.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"hlsDefaultConfig",function(){return u}),n.d(P,"mergeConfig",function(){return r}),n.d(P,"enableStreamingMode",function(){return h});var R=n("./src/controller/abr-controller.ts"),p=n("./src/controller/audio-stream-controller.ts"),T=n("./src/controller/audio-track-controller.ts"),I=n("./src/controller/subtitle-stream-controller.ts"),S=n("./src/controller/subtitle-track-controller.ts"),O=n("./src/controller/buffer-controller.ts"),_=n("./src/controller/timeline-controller.ts"),E=n("./src/controller/cap-level-controller.ts"),A=n("./src/controller/fps-controller.ts"),D=n("./src/controller/eme-controller.ts"),x=n("./src/controller/cmcd-controller.ts"),g=n("./src/utils/xhr-loader.ts"),y=n("./src/utils/fetch-loader.ts"),s=n("./src/utils/cues.ts"),e=n("./src/utils/mediakeys-helper.ts"),o=n("./src/utils/logger.ts");function f(){return f=Object.assign?Object.assign.bind():function(d){for(var l=1;l<arguments.length;l++){var v=arguments[l];for(var m in v)Object.prototype.hasOwnProperty.call(v,m)&&(d[m]=v[m])}return d},f.apply(this,arguments)}function a(d,l){var v=Object.keys(d);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(d);l&&(m=m.filter(function(L){return Object.getOwnPropertyDescriptor(d,L).enumerable})),v.push.apply(v,m)}return v}function i(d){for(var l=1;l<arguments.length;l++){var v=arguments[l]!=null?arguments[l]:{};l%2?a(Object(v),!0).forEach(function(m){t(d,m,v[m])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(v)):a(Object(v)).forEach(function(m){Object.defineProperty(d,m,Object.getOwnPropertyDescriptor(v,m))})}return d}function t(d,l,v){return l in d?Object.defineProperty(d,l,{value:v,enumerable:!0,configurable:!0,writable:!0}):d[l]=v,d}var u=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:g.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:R.default,bufferController:O.default,capLevelController:E.default,fpsController:A.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:e.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0},c()),{},{subtitleStreamController:I.SubtitleStreamController,subtitleTrackController:S.default,timelineController:_.TimelineController,audioStreamController:p.default,audioTrackController:T.default,emeController:D.default,cmcdController:x.default});function c(){return{cueHandler:s.default,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function r(d,l){if((l.liveSyncDurationCount||l.liveMaxLatencyDurationCount)&&(l.liveSyncDuration||l.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(l.liveMaxLatencyDurationCount!==void 0&&(l.liveSyncDurationCount===void 0||l.liveMaxLatencyDurationCount<=l.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(l.liveMaxLatencyDuration!==void 0&&(l.liveSyncDuration===void 0||l.liveMaxLatencyDuration<=l.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return f({},d,l)}function h(d){var l=d.loader;if(l!==y.default&&l!==g.default)o.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),d.progressive=!1;else{var v=Object(y.fetchSupported)();v&&(d.loader=y.default,d.progressive=!0,d.enableSoftwareAES=!0,o.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}}},"./src/controller/abr-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/utils/ewma-bandwidth-estimator.ts"),T=n("./src/events.ts"),I=n("./src/utils/buffer-helper.ts"),S=n("./src/errors.ts"),O=n("./src/types/loader.ts"),_=n("./src/utils/logger.ts");function E(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function A(x,g,y){return g&&E(x.prototype,g),y&&E(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}var D=function(){function x(y){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=y;var s=y.config;this.bwEstimator=new p.default(s.abrEwmaSlowVoD,s.abrEwmaFastVoD,s.abrEwmaDefaultEstimate),this.registerListeners()}var g=x.prototype;return g.registerListeners=function(){var s=this.hls;s.on(T.Events.FRAG_LOADING,this.onFragLoading,this),s.on(T.Events.FRAG_LOADED,this.onFragLoaded,this),s.on(T.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.on(T.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var s=this.hls;s.off(T.Events.FRAG_LOADING,this.onFragLoading,this),s.off(T.Events.FRAG_LOADED,this.onFragLoaded,this),s.off(T.Events.FRAG_BUFFERED,this.onFragBuffered,this),s.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),s.off(T.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},g.onFragLoading=function(s,e){var o=e.frag;if(o.type===O.PlaylistLevelType.MAIN&&!this.timer){var f;this.fragCurrent=o,this.partCurrent=(f=e.part)!=null?f:null,this.timer=self.setInterval(this.onCheck,100)}},g.onLevelLoaded=function(s,e){var o=this.hls.config;e.details.live?this.bwEstimator.update(o.abrEwmaSlowLive,o.abrEwmaFastLive):this.bwEstimator.update(o.abrEwmaSlowVoD,o.abrEwmaFastVoD)},g._abandonRulesCheck=function(){var s=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.autoLevelEnabled,a=o.config,i=o.media;if(!(!s||!i)){var t=e?e.stats:s.stats,u=e?e.duration:s.duration;if(t.aborted){_.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),this._nextAutoLevel=-1;return}if(!(!f||i.paused||!i.playbackRate||!i.readyState)){var c=performance.now()-t.loading.start,r=Math.abs(i.playbackRate);if(!(c<=500*u/r)){var h=o.levels,d=o.minAutoLevel,l=h[s.level],v=t.total||Math.max(t.loaded,Math.round(u*l.maxBitrate/8)),m=Math.max(1,t.bwEstimate?t.bwEstimate/8:t.loaded*1e3/c),L=(v-t.loaded)/m,b=i.currentTime,M=(I.BufferHelper.bufferInfo(i,b,a.maxBufferHole).end-b)/r;if(!(M>=2*u/r||L<=M)){var F=Number.POSITIVE_INFINITY,w;for(w=s.level-1;w>d;w--){var C=h[w].maxBitrate;if(F=u*C/(8*.8*m),F<M)break}if(!(F>=L)){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 "+w+`
|
|
8
|
+
Current BW estimate: `+(Object(R.isFiniteNumber)(U)?(U/1024).toFixed(3):"Unknown")+` Kb/s
|
|
9
|
+
Estimated load time for current fragment: `+L.toFixed(3)+` s
|
|
10
10
|
Estimated load time for the next fragment: `+F.toFixed(3)+` s
|
|
11
|
-
Time to underbuffer: `+M.toFixed(3)+" s"),i.nextLoadLevel=w,this.bwEstimator.sample(c,n.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),i.trigger(T.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===O.PlaylistLevelType.MAIN&&Object(b.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,c=(n.loaded?n.loaded.duration:0)+a;n.loaded={bytes:h,duration:c},n.realBitrate=Math.round(8*h/c)}if(i.bitrateTest){var u={stats:r,frag:i,part:t,id:i.type};this.onFragBuffered(T.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!==O.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 S.ErrorDetails.FRAG_LOAD_ERROR:case S.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,c=n?n.currentTime:0,u=n&&n.playbackRate!==0?Math.abs(n.playbackRate):1,f=this.bwEstimator?this.bwEstimator.getEstimate():r.abrEwmaDefaultEstimate,o=(I.BufferHelper.bufferInfo(n,c,r.maxBufferHole).end-c)/u,l=this.findBestLevel(f,a,t,o,r.abrBandWidthFactor,r.abrBandWidthUpFactor);if(l>=0)return l;A.logger.trace((o?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var E=h?Math.min(h,r.maxStarvationDelay):r.maxStarvationDelay,p=r.abrBandWidthFactor,R=r.abrBandWidthUpFactor;if(!o){var P=this.bitrateTestDelay;if(P){var M=h?Math.min(h,r.maxLoadingDelay):r.maxLoadingDelay;E=M-P,A.logger.trace("bitrate test took "+Math.round(1e3*P)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*E)+" ms"),p=R=1}}return l=this.findBestLevel(f,a,t,o+E,p,R),Math.max(l,0)},v.findBestLevel=function(s,e,i,t,r,a){for(var n,h=this.fragCurrent,c=this.partCurrent,u=this.lastLoadedFragLevel,f=this.hls.levels,o=f[u],l=!!(o!=null&&(n=o.details)!==null&&n!==void 0&&n.live),E=o==null?void 0:o.codecSet,p=c?c.duration:h?h.duration:0,R=i;R>=e;R--){var P=f[R];if(!(!P||E&&P.codecSet!==E)){var M=P.details,F=(c?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||p,w=void 0;R<=u?w=r*s:w=a*s;var C=f[R].maxBitrate,B=C*F/w;if(A.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+R+"/"+Math.round(w)+"/"+C+"/"+F+"/"+t+"/"+B),w>C&&(!B||l&&!this.bitrateTestDelay||B<t))return R}}return-1},_(x,[{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}}]),x}();D.default=L},"./src/controller/audio-stream-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/polyfills/number.ts"),y=d("./src/controller/base-stream-controller.ts"),T=d("./src/events.ts"),I=d("./src/utils/buffer-helper.ts"),S=d("./src/controller/fragment-tracker.ts"),O=d("./src/types/level.ts"),A=d("./src/types/loader.ts"),g=d("./src/loader/fragment.ts"),_=d("./src/demux/chunk-cache.ts"),L=d("./src/demux/transmuxer-interface.ts"),x=d("./src/types/transmuxer.ts"),v=d("./src/controller/fragment-finders.ts"),m=d("./src/utils/discontinuities.ts"),s=d("./src/errors.ts"),e=d("./src/utils/logger.ts");function i(){return i=Object.assign||function(h){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},i.apply(this,arguments)}function t(h,c){h.prototype=Object.create(c.prototype),h.prototype.constructor=h,r(h,c)}function r(h,c){return r=Object.setPrototypeOf||function(f,o){return f.__proto__=o,f},r(h,c)}var a=100,n=function(h){t(c,h);function c(f,o){var l;return l=h.call(this,f,o,"[audio-stream-controller]")||this,l.videoBuffer=null,l.videoTrackCC=-1,l.waitingVideoCC=-1,l.audioSwitch=!1,l.trackId=-1,l.waitingData=null,l.mainDetails=null,l.bufferFlushed=!1,l._registerListeners(),l}var u=c.prototype;return u.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},u._registerListeners=function(){var o=this.hls;o.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.on(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),o.on(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),o.on(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.on(T.Events.ERROR,this.onError,this),o.on(T.Events.BUFFER_RESET,this.onBufferReset,this),o.on(T.Events.BUFFER_CREATED,this.onBufferCreated,this),o.on(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),o.on(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.on(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var o=this.hls;o.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),o.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),o.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),o.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),o.off(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),o.off(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),o.off(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),o.off(T.Events.ERROR,this.onError,this),o.off(T.Events.BUFFER_RESET,this.onBufferReset,this),o.off(T.Events.BUFFER_CREATED,this.onBufferCreated,this),o.off(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),o.off(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),o.off(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onInitPtsFound=function(o,l){var E=l.frag,p=l.id,R=l.initPTS;if(p==="main"){var P=E.cc;this.initPTS[E.cc]=R,this.log("InitPTS for cc: "+P+" found from main: "+R),this.videoTrackCC=P,this.state===y.State.WAITING_INIT_PTS&&this.tick()}},u.startLoad=function(o){if(!this.levels){this.startPosition=o,this.state=y.State.STOPPED;return}var l=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,l>0&&o===-1?(this.log("Override startPosition with lastCurrentTime @"+l.toFixed(3)),this.state=y.State.IDLE):(this.loadedmetadata=!1,this.state=y.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=o,this.tick()},u.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_TRACK:{var o,l=this.levels,E=this.trackId,p=l==null||(o=l[E])===null||o===void 0?void 0:o.details;if(p){if(this.waitForCdnTuneIn(p))break;this.state=y.State.WAITING_INIT_PTS}break}case y.State.FRAG_LOADING_WAITING_RETRY:{var R,P=performance.now(),M=this.retryDate;(!M||P>=M||(R=this.media)!==null&&R!==void 0&&R.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 w=F.frag,C=F.part,B=F.cache,k=F.complete;if(this.initPTS[w.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.FRAG_LOADING;var N=B.flush(),W={frag:w,part:C,payload:N,networkDetails:null};this._handleFragmentLoadProgress(W),k&&h.prototype._handleFragmentLoadComplete.call(this,W)}else if(this.videoTrackCC!==this.waitingVideoCC)e.logger.log("Waiting fragment cc ("+w.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var j=this.getLoadPosition(),K=I.BufferHelper.bufferInfo(this.mediaBuffer,j,this.config.maxBufferHole),V=Object(v.fragmentWithinToleranceTest)(K.end,this.config.maxFragLookUpTolerance,w);V<0&&(e.logger.log("Waiting fragment cc ("+w.cc+") @ "+w.start+" cancelled because another fragment at "+K.end+" is needed"),this.clearWaitingFragment())}}else this.state=y.State.IDLE}}this.onTickEnd()},u.clearWaitingFragment=function(){var o=this.waitingData;o&&(this.fragmentTracker.removeFragment(o.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=y.State.IDLE)},u.onTickEnd=function(){var o=this.media;if(!(!o||!o.readyState)){var l=this.mediaBuffer?this.mediaBuffer:o,E=l.buffered;!this.loadedmetadata&&E.length&&(this.loadedmetadata=!0),this.lastCurrentTime=o.currentTime}},u.doTickIdle=function(){var o,l,E=this.hls,p=this.levels,R=this.media,P=this.trackId,M=E.config;if(!(!p||!p[P])&&!(!R&&(this.startFragRequested||!M.startFragPrefetch))){var F=p[P],w=F.details;if(!w||w.live&&this.levelLastLoaded!==P||this.waitForCdnTuneIn(w)){this.state=y.State.WAITING_TRACK;return}this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,g.ElementaryStreamTypes.AUDIO,A.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,A.PlaylistLevelType.AUDIO);if(C!==null){var B=C.len,k=this.getMaxBufferLength(),N=this.audioSwitch;if(!(B>=k&&!N)){if(!N&&this._streamEnded(C,w)){E.trigger(T.Events.BUFFER_EOS,{type:"audio"}),this.state=y.State.ENDED;return}var W=w.fragments,j=W[0].start,K=C.end;if(N){var V=this.getLoadPosition();K=V,w.PTSKnown&&V<j&&(C.end>j||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),R.currentTime=j+.05)}var Y=this.getNextFragment(K,w);if(!Y){this.bufferFlushed=!0;return}((o=Y.decryptdata)===null||o===void 0?void 0:o.keyFormat)==="identity"&&!((l=Y.decryptdata)!==null&&l!==void 0&&l.key)?this.loadKey(Y,w):this.loadFragment(Y,w,K)}}}},u.getMaxBufferLength=function(){var o=h.prototype.getMaxBufferLength.call(this),l=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,A.PlaylistLevelType.MAIN);return l===null?o:Math.max(o,l.len)},u.onMediaDetaching=function(){this.videoBuffer=null,h.prototype.onMediaDetaching.call(this)},u.onAudioTracksUpdated=function(o,l){var E=l.audioTracks;this.resetTransmuxer(),this.levels=E.map(function(p){return new O.Level(p)})},u.onAudioTrackSwitching=function(o,l){var E=!!l.url;this.trackId=l.id;var p=this.fragCurrent;p!=null&&p.loader&&p.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(o,l){this.mainDetails=l.details},u.onAudioTrackLoaded=function(o,l){var E,p=this.levels,R=l.details,P=l.id;if(!p){this.warn("Audio tracks were reset while loading level "+P);return}this.log("Track "+P+" loaded ["+R.startSN+","+R.endSN+"],duration:"+R.totalduration);var M=p[P],F=0;if(R.live||(E=M.details)!==null&&E!==void 0&&E.live){var w=this.mainDetails;if(R.fragments[0]||(R.deltaUpdateFailed=!0),R.deltaUpdateFailed||!w)return;!M.details&&R.hasProgramDateTime&&w.hasProgramDateTime?(Object(m.alignMediaPlaylistByPDT)(R,w),F=R.fragments[0].start):F=this.alignPlaylists(R,M.details)}M.details=R,this.levelLastLoaded=P,!this.startFragRequested&&(this.mainDetails||!R.live)&&this.setStartPosition(M.details,F),this.state===y.State.WAITING_TRACK&&!this.waitForCdnTuneIn(R)&&(this.state=y.State.IDLE),this.tick()},u._handleFragmentLoadProgress=function(o){var l,E=o.frag,p=o.part,R=o.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 w=F[M];console.assert(w,"Audio track is defined on fragment load progress");var C=w.details;console.assert(C,"Audio track details are defined on fragment load progress");var B=P.defaultAudioCodec||w.audioCodec||"mp4a.40.2",k=this.transmuxer;k||(k=this.transmuxer=new L.default(this.hls,A.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var N=this.initPTS[E.cc],W=(l=E.initSegment)===null||l===void 0?void 0:l.data;if(N!==void 0){var j=!1,K=p?p.index:-1,V=K!==-1,Y=new x.ChunkMetadata(E.level,E.sn,E.stats.chunkCount,R.byteLength,K,V);k.push(R,W,B,"",E,p,C.totalduration,j,Y,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 Q=this.waitingData=this.waitingData||{frag:E,part:p,cache:new _.default,complete:!1},z=Q.cache;z.push(new Uint8Array(R)),this.waitingVideoCC=this.videoTrackCC,this.state=y.State.WAITING_INIT_PTS}},u._handleFragmentLoadComplete=function(o){if(this.waitingData){this.waitingData.complete=!0;return}h.prototype._handleFragmentLoadComplete.call(this,o)},u.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},u.onBufferCreated=function(o,l){var E=l.tracks.audio;E&&(this.mediaBuffer=E.buffer),l.tracks.video&&(this.videoBuffer=l.tracks.video.buffer)},u.onFragBuffered=function(o,l){var E=l.frag,p=l.part;if(E.type===A.PlaylistLevelType.AUDIO){if(this.fragContextChanged(E)){this.warn("Fragment "+E.sn+(p?" p: "+p.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(T.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(E,p)}},u.onError=function(o,l){switch(l.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(A.PlaylistLevelType.AUDIO,l);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=l.fatal?y.State.ERROR:y.State.IDLE,this.warn(l.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(l.parent==="audio"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var E=!0,p=this.getFwdBufferInfo(this.mediaBuffer,A.PlaylistLevelType.AUDIO);p&&p.len>.5&&(E=!this.reduceMaxBufferLength(p.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(o,l){var E=l.type;E===g.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},u._handleTransmuxComplete=function(o){var l,E="audio",p=this.hls,R=o.remuxResult,P=o.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,w=M.part,C=R.audio,B=R.text,k=R.id3,N=R.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),p.trigger(T.Events.FRAG_PARSING_INIT_SEGMENT,{frag:F,id:E,tracks:N.tracks})),C){var W=C.startPTS,j=C.endPTS,K=C.startDTS,V=C.endDTS;w&&(w.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:W,endPTS:j,startDTS:K,endDTS:V}),F.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,W,j,K,V),this.bufferFragmentData(C,F,w,P)}if(k!=null&&(l=k.samples)!==null&&l!==void 0&&l.length){var Y=i({frag:F,id:E},k);p.trigger(T.Events.FRAG_PARSING_METADATA,Y)}if(B){var Q=i({frag:F,id:E},B);p.trigger(T.Events.FRAG_PARSING_USERDATA,Q)}}},u._bufferInitSegment=function(o,l,E){if(this.state===y.State.PARSING){o.video&&delete o.video;var p=o.audio;if(!!p){p.levelCodec=p.codec,p.id="audio",this.log("Init audio buffer, container:"+p.container+", codecs[parsed]=["+p.codec+"]"),this.hls.trigger(T.Events.BUFFER_CODECS,o);var R=p.initSegment;if(R!=null&&R.byteLength){var P={type:"audio",frag:l,part:null,chunkMeta:E,parent:l.type,data:R};this.hls.trigger(T.Events.BUFFER_APPENDING,P)}this.tick()}}},u.loadFragment=function(o,l,E){var p=this.fragmentTracker.getState(o);this.fragCurrent=o,(this.audioSwitch||p===S.FragmentState.NOT_LOADED||p===S.FragmentState.PARTIAL)&&(o.sn==="initSegment"?this._loadInitSegment(o):l.live&&!Object(b.isFiniteNumber)(this.initPTS[o.cc])?(this.log("Waiting for video PTS in continuity counter "+o.cc+" of live stream before loading audio fragment "+o.sn+" of level "+this.trackId),this.state=y.State.WAITING_INIT_PTS):(this.startFragRequested=!0,h.prototype.loadFragment.call(this,o,l,E)))},u.completeAudioSwitch=function(){var o=this.hls,l=this.media,E=this.trackId;l&&(this.log("Switching audio track : flushing all audio"),h.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,o.trigger(T.Events.AUDIO_TRACK_SWITCHED,{id:E})},c}(y.default);D.default=n},"./src/controller/audio-track-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts"),y=d("./src/errors.ts"),T=d("./src/controller/base-playlist-controller.ts"),I=d("./src/types/loader.ts");function S(L,x){for(var v=0;v<x.length;v++){var m=x[v];m.enumerable=m.enumerable||!1,m.configurable=!0,"value"in m&&(m.writable=!0),Object.defineProperty(L,m.key,m)}}function O(L,x,v){return x&&S(L.prototype,x),v&&S(L,v),L}function A(L,x){L.prototype=Object.create(x.prototype),L.prototype.constructor=L,g(L,x)}function g(L,x){return g=Object.setPrototypeOf||function(m,s){return m.__proto__=s,m},g(L,x)}var _=function(L){A(x,L);function x(m){var s;return s=L.call(this,m,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var v=x.prototype;return v.registerListeners=function(){var s=this.hls;s.on(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(b.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(b.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(b.Events.ERROR,this.onError,this)},v.unregisterListeners=function(){var s=this.hls;s.off(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(b.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(b.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(b.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(b.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,c=t.type,u=t.url;if(this.trackId=s,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(b.Events.AUDIO_TRACK_SWITCHING,{id:r,groupId:n,name:h,type:c,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(b.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(b.Events.AUDIO_TRACK_LOADING,{url:r,id:i,groupId:t,deliveryDirectives:s||null})}},O(x,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),x}(T.default);D.default=_},"./src/controller/base-playlist-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return O});var b=d("./src/polyfills/number.ts"),y=d("./src/types/level.ts"),T=d("./src/controller/level-helper.ts"),I=d("./src/utils/logger.ts"),S=d("./src/errors.ts"),O=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=_}var g=A.prototype;return g.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},g.onError=function(L,x){x.fatal&&x.type===S.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,x){var v=x==null?void 0:x.renditionReports;if(v)for(var m=0;m<v.length;m++){var s=v[m],e=""+s.URI;if(e===L.substr(-e.length)){var i=parseInt(s["LAST-MSN"]),t=parseInt(s["LAST-PART"]);if(x&&this.hls.config.lowLatencyMode){var r=Math.min(x.age-x.partTarget,x.targetduration);t!==void 0&&r>x.partTarget&&(t+=1)}if(Object(b.isFiniteNumber)(i))return new y.HlsUrlParameters(i,Object(b.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,x,v){var m=this,s=x.details,e=x.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(T.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,c=s.endSN,u=s.lastPartIndex,f=u!==-1,o=h===c,l=n?0:u;f?(r=o?c+1:h,a=o?l:u+1):r=c+1;var E=s.age,p=E+s.ageHeader,R=Math.min(p-s.partTarget,s.targetduration*1.5);if(R>0){if(v&&R>v.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+v.tuneInGoal+" to: "+R+" with playlist age: "+s.age),R=0;else{var P=Math.floor(R/s.targetduration);if(r+=P,a!==void 0){var M=Math.round(R%s.targetduration/s.partTarget);a+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+E.toFixed(2)+"s goal: "+R+" skip sn "+P+" to part "+a)}s.tuneInGoal=R}if(t=this.getDeliveryDirectives(s,x.deliveryDirectives,r,a),n||!o){this.loadPlaylist(t);return}}else t=this.getDeliveryDirectives(s,x.deliveryDirectives,r,a);var F=Object(T.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 m.loadPlaylist(t)},F)}else this.clearTimer()},g.getDeliveryDirectives=function(L,x,v,m){var s=Object(y.getSkipValue)(L,v);return x!=null&&x.skip&&L.deltaUpdateFailed&&(v=x.msn,m=x.part,s=y.HlsSkip.No),new y.HlsUrlParameters(v,m,s)},g.retryLoadingOrFail=function(L){var x=this,v=this.hls.config,m=this.retryCount<v.levelLoadingMaxRetry;if(m){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 x.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 m},A}()},"./src/controller/base-stream-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"State",function(){return c}),d.d(D,"default",function(){return u});var b=d("./src/polyfills/number.ts"),y=d("./src/task-loop.ts"),T=d("./src/controller/fragment-tracker.ts"),I=d("./src/utils/buffer-helper.ts"),S=d("./src/utils/logger.ts"),O=d("./src/events.ts"),A=d("./src/errors.ts"),g=d("./src/types/transmuxer.ts"),_=d("./src/utils/mp4-tools.ts"),L=d("./src/utils/discontinuities.ts"),x=d("./src/controller/fragment-finders.ts"),v=d("./src/controller/level-helper.ts"),m=d("./src/loader/fragment-loader.ts"),s=d("./src/crypt/decrypter.ts"),e=d("./src/utils/time-ranges.ts"),i=d("./src/types/loader.ts");function t(f,o){for(var l=0;l<o.length;l++){var E=o[l];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(f,E.key,E)}}function r(f,o,l){return o&&t(f.prototype,o),l&&t(f,l),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,o){f.prototype=Object.create(o.prototype),f.prototype.constructor=f,h(f,o)}function h(f,o){return h=Object.setPrototypeOf||function(E,p){return E.__proto__=p,E},h(f,o)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},u=function(f){n(o,f);function o(E,p,R){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=c.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=R,P.log=S.logger.log.bind(S.logger,R+":"),P.warn=S.logger.warn.bind(S.logger,R+":"),P.hls=E,P.fragmentLoader=new m.default(E.config),P.fragmentTracker=p,P.config=E.config,P.decrypter=new s.default(E,E.config),E.on(O.Events.KEY_LOADED,P.onKeyLoaded,a(P)),P}var l=o.prototype;return l.doTick=function(){this.onTickEnd()},l.onTickEnd=function(){},l.startLoad=function(p){},l.stopLoad=function(){this.fragmentLoader.abort();var p=this.fragCurrent;p&&this.fragmentTracker.removeFragment(p),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},l._streamEnded=function(p,R){var P=this.fragCurrent,M=this.fragmentTracker;if(!R.live&&P&&P.sn>=R.endSN&&!p.nextStart){var F=R.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var B=M.getState(P);return B===T.FragmentState.PARTIAL||B===T.FragmentState.OK}return!1},l.onMediaAttached=function(p,R){var P=this.media=this.mediaBuffer=R.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===c.STOPPED&&this.startLoad(M.startPosition)},l.onMediaDetaching=function(){var p=this.media;p!=null&&p.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),p&&(p.removeEventListener("seeking",this.onvseeking),p.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},l.onMediaSeeking=function(){var p=this.config,R=this.fragCurrent,P=this.media,M=this.mediaBuffer,F=this.state,w=P?P.currentTime:0,C=I.BufferHelper.bufferInfo(M||P,w,p.maxBufferHole);if(this.log("media seeking to "+(Object(b.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(R&&!C.len){var B=p.maxFragLookUpTolerance,k=R.start-B,N=R.start+R.duration+B,W=w>N;(w<k||W)&&(W&&R.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),R.loader.abort()),this.resetLoadingState())}P&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(p,R){if(!(this.state!==c.KEY_LOADING||R.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var P=this.levels[R.frag.level].details;P&&this.loadFragment(R.frag,P,R.frag.start)}},l.onHandlerDestroying=function(){this.stopLoad(),f.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(O.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)},l.loadKey=function(p,R){this.log("Loading key for "+p.sn+" of ["+R.startSN+"-"+R.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level),this.state=c.KEY_LOADING,this.fragCurrent=p,this.hls.trigger(O.Events.KEY_LOADING,{frag:p})},l.loadFragment=function(p,R,P){this._loadFragForPlayback(p,R,P)},l._loadFragForPlayback=function(p,R,P){var M=this,F=function(C){if(M.fragContextChanged(p)){M.warn("Fragment "+p.sn+(C.part?" p: "+C.part.index:"")+" of level "+p.level+" was dropped during download."),M.fragmentTracker.removeFragment(p);return}p.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(p,R,P,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(p)){(C===c.FRAG_LOADING||C===c.BACKTRACKING||!M.fragCurrent&&C===c.PARSING)&&(M.fragmentTracker.removeFragment(p),M.state=c.IDLE);return}if("payload"in w&&(M.log("Loaded fragment "+p.sn+" of level "+p.level),M.hls.trigger(O.Events.FRAG_LOADED,w),M.state===c.BACKTRACKING)){M.fragmentTracker.backtrack(p,w),M.resetFragmentLoading(p);return}M._handleFragmentLoadComplete(w)}}).catch(function(w){M.warn(w),M.resetFragmentLoading(p)})},l.flushMainBuffer=function(p,R,P){if(P===void 0&&(P=null),!!(p-R)){var M={startOffset:p,endOffset:R,type:P};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,M)}},l._loadInitSegment=function(p){var R=this;this._doFragLoad(p).then(function(P){if(!P||R.fragContextChanged(p)||!R.levels)throw new Error("init load aborted");return P}).then(function(P){var M=R.hls,F=P.payload,w=p.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return R.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(B){var k=self.performance.now();return M.trigger(O.Events.FRAG_DECRYPTED,{frag:p,payload:B,stats:{tstart:C,tdecrypt:k}}),P.payload=B,P})}return P}).then(function(P){var M=R.fragCurrent,F=R.hls,w=R.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[p.level].details;console.assert(C,"Level details are defined when init segment is loaded");var B=p.stats;R.state=c.IDLE,R.fragLoadError=0,p.data=new Uint8Array(P.payload),B.parsing.start=B.buffering.start=self.performance.now(),B.parsing.end=B.buffering.end=self.performance.now(),P.frag===M&&F.trigger(O.Events.FRAG_BUFFERED,{stats:B,frag:M,part:null,id:p.type}),R.tick()}).catch(function(P){R.warn(P),R.resetFragmentLoading(p)})},l.fragContextChanged=function(p){var R=this.fragCurrent;return!p||!R||p.level!==R.level||p.sn!==R.sn||p.urlId!==R.urlId},l.fragBufferedComplete=function(p,R){var P=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+p.type+" sn: "+p.sn+(R?" part: "+R.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+p.level+" "+e.default.toString(I.BufferHelper.getBuffered(P))),this.state=c.IDLE,this.tick()},l._handleFragmentLoadComplete=function(p){var R=this.transmuxer;if(!!R){var P=p.frag,M=p.part,F=p.partsLoaded,w=!F||F.length===0||F.some(function(B){return!B}),C=new g.ChunkMetadata(P.level,P.sn,P.stats.chunkCount+1,0,M?M.index:-1,!w);R.flush(C)}},l._handleFragmentLoadProgress=function(p){},l._doFragLoad=function(p,R,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(p.start,P||0),this.config.lowLatencyMode&&R){var w=R.partList;if(w&&M){P>p.end&&R.fragmentHint&&(p=R.fragmentHint);var C=this.getNextPart(w,p,P);if(C>-1){var B=w[C];return this.log("Loading part sn: "+p.sn+" p: "+B.index+" cc: "+p.cc+" of playlist ["+R.startSN+"-"+R.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(P.toFixed(3))),this.nextLoadPosition=B.start+B.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:p,part:w[C],targetBufferTime:P}),this.doFragPartsLoad(p,w,C,M).catch(function(k){return F.handleFragLoadError(k)})}else if(!p.url||this.loadedEndOfParts(w,P))return Promise.resolve(null)}}return this.log("Loading fragment "+p.sn+" cc: "+p.cc+" "+(R?"of ["+R.startSN+"-"+R.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+p.level+", target: "+parseFloat(P.toFixed(3))),Object(b.isFiniteNumber)(p.sn)&&!this.bitrateTest&&(this.nextLoadPosition=p.start+p.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:p,targetBufferTime:P}),this.fragmentLoader.load(p,M).catch(function(k){return F.handleFragLoadError(k)})},l.doFragPartsLoad=function(p,R,P,M){var F=this;return new Promise(function(w,C){var B=[],k=function N(W){var j=R[W];F.fragmentLoader.loadPart(p,j,M).then(function(K){B[j.index]=K;var V=K.part;F.hls.trigger(O.Events.FRAG_LOADED,K);var Y=R[W+1];if(Y&&Y.fragment===p)N(W+1);else return w({frag:p,part:V,partsLoaded:B})}).catch(C)};k(P)})},l.handleFragLoadError=function(p){var R=p.data;return R&&R.details===A.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(R.frag,R.part):this.hls.trigger(O.Events.ERROR,R),null},l._handleTransmuxerFlush=function(p){var R=this.getCurrentContext(p);if(!R||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var P=R.frag,M=R.part,F=R.level,w=self.performance.now();P.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(P,M,F,p.partial)},l.getCurrentContext=function(p){var R=this.levels,P=p.level,M=p.sn,F=p.part;if(!R||!R[P])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+P+". The current chunk will not be buffered."),null;var w=R[P],C=F>-1?Object(v.getPartWith)(w,M,F):null,B=C?C.fragment:Object(v.getFragmentWithSN)(w,M,this.fragCurrent);return B?{frag:B,part:C,level:w}:null},l.bufferFragmentData=function(p,R,P,M){if(!(!p||this.state!==c.PARSING)){var F=p.data1,w=p.data2,C=F;if(F&&w&&(C=Object(_.appendUint8Array)(F,w)),!(!C||!C.length)){var B={type:p.type,frag:R,part:P,chunkMeta:M,parent:R.type,data:C};this.hls.trigger(O.Events.BUFFER_APPENDING,B),p.dropped&&p.independent&&!P&&this.flushBufferGap(R)}}},l.flushBufferGap=function(p){var R=this.media;if(!!R){if(!I.BufferHelper.isBuffered(R,R.currentTime)){this.flushMainBuffer(0,p.start);return}var P=R.currentTime,M=I.BufferHelper.bufferInfo(R,P,0),F=p.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(p.start-w,M.end-w),P+w);p.start-C>w&&this.flushMainBuffer(C,p.start)}},l.getFwdBufferInfo=function(p,R){var P=this.config,M=this.getLoadPosition();if(!Object(b.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(p,M,P.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,R);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(p,M,Math.max(F.nextStart,P.maxBufferHole))}return F},l.getMaxBufferLength=function(p){var R=this.config,P;return p?P=Math.max(8*R.maxBufferSize/p,R.maxBufferLength):P=R.maxBufferLength,Math.min(P,R.maxMaxBufferLength)},l.reduceMaxBufferLength=function(p){var R=this.config,P=p||R.maxBufferLength;return R.maxMaxBufferLength>=P?(R.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+R.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(p,R){var P,M,F=R.fragments,w=F.length;if(!w)return null;var C=this.config,B=F[0].start,k;if(R.live){var N=C.initialLiveManifestSize;if(w<N)return this.warn("Not enough fragments to start playback (have: "+w+", need: "+N+")"),null;!R.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(k=this.getInitialLiveFragment(R,F),this.startPosition=k?this.hls.liveSyncPosition||k.start:p)}else p<=B&&(k=F[0]);if(!k){var W=C.lowLatencyMode?R.partEnd:R.fragmentEnd;k=this.getFragmentAtPosition(p,W,R)}return(P=k)!==null&&P!==void 0&&P.initSegment&&!((M=k)!==null&&M!==void 0&&M.initSegment.data)&&!this.bitrateTest&&(k=k.initSegment),k},l.getNextPart=function(p,R,P){for(var M=-1,F=!1,w=!0,C=0,B=p.length;C<B;C++){var k=p[C];if(w=w&&!k.independent,M>-1&&P<k.start)break;var N=k.loaded;!N&&(F||k.independent||w)&&k.fragment===R&&(M=C),F=N}return M},l.loadedEndOfParts=function(p,R){var P=p[p.length-1];return P&&R>P.start&&P.loaded},l.getInitialLiveFragment=function(p,R){var P=this.fragPrevious,M=null;if(P){if(p.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+P.programDateTime),M=Object(x.findFragmentByPDT)(R,P.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=P.sn+1;if(F>=p.startSN&&F<=p.endSN){var w=R[F-p.startSN];P.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(x.findFragWithCC)(R,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?p.fragmentEnd:p.edge,p))}return M},l.getFragmentAtPosition=function(p,R,P){var M=this.config,F=this.fragPrevious,w=P.fragments,C=P.endSN,B=P.fragmentHint,k=M.maxFragLookUpTolerance,N=!!(M.lowLatencyMode&&P.partList&&B);N&&B&&!this.bitrateTest&&(w=w.concat(B),C=B.sn);var W;if(p<R){var j=p>R-k?0:k;W=Object(x.findFragmentByPTS)(F,w,p,j)}else W=w[w.length-1];if(W){var K=W.sn-P.startSN,V=F&&W.level===F.level,Y=w[K+1],Q=this.fragmentTracker.getState(W);if(Q===T.FragmentState.BACKTRACKED){W=null;for(var z=K;w[z]&&this.fragmentTracker.getState(w[z])===T.FragmentState.BACKTRACKED;)F?W=w[z--]:W=w[--z];W||(W=Y)}else F&&W.sn===F.sn&&!N&&V&&(W.sn<C&&this.fragmentTracker.getState(Y)!==T.FragmentState.OK?(this.log("SN "+W.sn+" just loaded, load next one: "+Y.sn),W=Y):W=null)}return W},l.synchronizeToLiveEdge=function(p){var R=this.config,P=this.media;if(!!P){var M=this.hls.liveSyncPosition,F=P.currentTime,w=p.fragments[0].start,C=p.edge,B=F>=w-R.maxFragLookUpTolerance&&F<=C;if(M!==null&&P.duration>M&&(F<M||!B)){var k=R.liveMaxLatencyDuration!==void 0?R.liveMaxLatencyDuration:R.liveMaxLatencyDurationCount*p.targetduration;(!B&&P.readyState<4||F<C-k)&&(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))}}},l.alignPlaylists=function(p,R){var P=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?P[M]:null,C=p.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var B=p.fragments[0].start,k=!R,N=p.alignedSliding&&Object(b.isFiniteNumber)(B);if(k||!N&&!B){Object(L.alignStream)(F,w,p);var W=p.fragments[0].start;return this.log("Live playlist sliding: "+W.toFixed(2)+" start-sn: "+(R?R.startSN:"na")+"->"+p.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),W}return B},l.waitForCdnTuneIn=function(p){var R=3;return p.live&&p.canBlockReload&&p.tuneInGoal>Math.max(p.partHoldBack,p.partTarget*R)},l.setStartPosition=function(p,R){var P=this.startPosition;if(P<R&&(P=-1),P===-1||this.lastCurrentTime===-1){var M=p.startTimeOffset;Object(b.isFiniteNumber)(M)?(P=R+M,M<0&&(P+=p.totalduration),P=Math.min(Math.max(R,P),R+p.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+P),this.startPosition=P):p.live?P=this.hls.liveSyncPosition||R:this.startPosition=P=0,this.lastCurrentTime=P}this.nextLoadPosition=P},l.getLoadPosition=function(){var p=this.media,R=0;return this.loadedmetadata&&p?R=p.currentTime:this.nextLoadPosition&&(R=this.nextLoadPosition),R},l.handleFragLoadAborted=function(p,R){this.transmuxer&&p.sn!=="initSegment"&&p.stats.aborted&&(this.warn("Fragment "+p.sn+(R?" part"+R.index:"")+" of level "+p.level+" was aborted"),this.resetFragmentLoading(p))},l.resetFragmentLoading=function(p){(!this.fragCurrent||!this.fragContextChanged(p))&&(this.state=c.IDLE)},l.onFragmentOrKeyLoadError=function(p,R){if(!R.fatal){var P=R.frag;if(!(!P||P.type!==p)){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 w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+P.sn+" of "+p+" "+P.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else R.levelRetry?(p===i.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(S.logger.error(R.details+" reaches max retry, redispatch as fatal ..."),R.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},l.afterBufferFlushed=function(p,R,P){if(!!p){var M=I.BufferHelper.getBuffered(p);this.fragmentTracker.detectEvictedFragments(R,M,P),this.state===c.ENDED&&this.resetLoadingState()}},l.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},l.resetLiveStartWhenNotLoaded=function(p){if(!this.loadedmetadata){this.startFragRequested=!1;var R=this.levels?this.levels[p].details:null;if(R!=null&&R.live)return this.startPosition=-1,this.setStartPosition(R,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},l.updateLevelTiming=function(p,R,P,M){var F=this,w=P.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(p.elementaryStreams).reduce(function(B,k){var N=p.elementaryStreams[k];if(N){var W=N.endPTS-N.startPTS;if(W<=0)return F.warn("Could not parse fragment "+p.sn+" "+k+" duration reliably ("+W+") resetting transmuxer to fallback to playlist timing"),F.resetTransmuxer(),B||!1;var j=M?0:Object(v.updateFragPTSDTS)(w,p,N.startPTS,N.endPTS,N.startDTS,N.endDTS);return F.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:w,level:P,drift:j,type:k,frag:p,start:N.startPTS,end:N.endPTS}),!0}return B},!1);C?(this.state=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:p,part:R})):this.resetLoadingState()},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r(o,[{key:"state",get:function(){return this._state},set:function(p){var R=this._state;R!==p&&(this._state=p,this.log(R+"->"+p))}}]),o}(y.default)},"./src/controller/buffer-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return x});var b=d("./src/polyfills/number.ts"),y=d("./src/events.ts"),T=d("./src/utils/logger.ts"),I=d("./src/errors.ts"),S=d("./src/utils/buffer-helper.ts"),O=d("./src/utils/mediasource-helper.ts"),A=d("./src/loader/fragment.ts"),g=d("./src/controller/buffer-operation-queue.ts"),_=Object(O.getMediaSource)(),L=/([ha]vc.)(?:\.[^.,]+)+/,x=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;T.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(){T.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){T.logger.log("[buffer-controller]: Media source ended")},this.hls=s,this._initSourceBuffer(),this.registerListeners()}var m=v.prototype;return m.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},m.destroy=function(){this.unregisterListeners(),this.details=null},m.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)},m.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)},m._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new g.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},m.onManifestParsed=function(e,i){var t=2;(i.audio&&!i.video||!i.altAudio)&&(t=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=t,this.details=null,T.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},m.onMediaAttaching=function(e,i){var t=this.media=i.media;if(t&&_){var r=this.mediaSource=new _;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}},m.onMediaDetaching=function(){var e=this.media,i=this.mediaSource,t=this._objectUrl;if(i){if(T.logger.log("[buffer-controller]: media source detaching"),i.readyState==="open")try{i.endOfStream()}catch(r){T.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()):T.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(y.Events.MEDIA_DETACHED,void 0)},m.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){T.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",r)}}),this._initSourceBuffer()},m.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],c=h.codec,u=h.levelCodec,f=h.container,o=(n.levelCodec||n.codec).replace(L,"$1"),l=(u||c).replace(L,"$1");if(o!==l){var E=f+";codecs="+(u||c);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())},m.appendChangeType=function(e,i){var t=this,r=this.operationQueue,a={execute:function(){var h=t.sourceBuffer[e];h&&(T.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+i),h.changeType(i)),r.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(h){T.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",h)}};r.append(a,e)},m.onBufferAppending=function(e,i){var t=this,r=this.hls,a=this.operationQueue,n=this.tracks,h=i.data,c=i.type,u=i.frag,f=i.part,o=i.chunkMeta,l=o.buffering[c],E=self.performance.now();l.start=E;var p=u.stats.buffering,R=f?f.stats.buffering:null;p.start===0&&(p.start=E),R&&R.start===0&&(R.start=E);var P=n.audio,M=c==="audio"&&o.id===1&&(P==null?void 0:P.container)==="audio/mpeg",F={execute:function(){if(l.executeStart=self.performance.now(),M){var C=t.sourceBuffer[c];if(C){var B=u.start-C.timestampOffset;Math.abs(B)>=.1&&(T.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+u.start+" (delta: "+B+") sn: "+u.sn+")"),C.timestampOffset=u.start)}}t.appendExecutor(h,c)},onStart:function(){},onComplete:function(){var C=self.performance.now();l.executeEnd=l.end=C,p.first===0&&(p.first=C),R&&R.first===0&&(R.first=C);var B=t.sourceBuffer,k={};for(var N in B)k[N]=S.BufferHelper.getBuffered(B[N]);t.appendError=0,t.hls.trigger(y.Events.BUFFER_APPENDED,{type:c,frag:u,part:f,chunkMeta:o,parent:u.type,timeRanges:k})},onError:function(C){T.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",C);var B={type:I.ErrorTypes.MEDIA_ERROR,parent:u.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?B.details=I.ErrorDetails.BUFFER_FULL_ERROR:(t.appendError++,B.details=I.ErrorDetails.BUFFER_APPEND_ERROR,t.appendError>r.config.appendErrorMaxRetry&&(T.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),B.fatal=!0)),r.trigger(y.Events.ERROR,B)}};a.append(F,c)},m.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){T.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)})},m.onFragParsed=function(e,i){var t=this,r=i.frag,a=i.part,n=[],h=a?a.elementaryStreams:r.elementaryStreams;h[A.ElementaryStreamTypes.AUDIOVIDEO]?n.push("audiovideo"):(h[A.ElementaryStreamTypes.AUDIO]&&n.push("audio"),h[A.ElementaryStreamTypes.VIDEO]&&n.push("video"));var c=function(){var f=self.performance.now();r.stats.buffering.end=f,a&&(a.stats.buffering.end=f);var o=a?a.stats:r.stats;t.hls.trigger(y.Events.FRAG_BUFFERED,{frag:r,part:a,stats:o,id:r.type})};n.length===0&&T.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers(c,n)},m.onFragChanged=function(e,i){this.flushBackBuffer()},m.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,T.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()})},m.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())},m.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(b.isFiniteNumber)(n)||n<0)){var h=t.currentTime,c=i.levelTargetDuration,u=Math.max(n,c),f=Math.floor(h/c)*c-u;a.forEach(function(o){var l=r[o];if(l){var E=S.BufferHelper.getBuffered(l);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:o}))}})}}}},m.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(b.isFiniteNumber)(r.duration)?r.duration:0;e.live&&i.config.liveDurationInfinity?(T.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(a>h&&a>n||!Object(b.isFiniteNumber)(n))&&(T.logger.log("[buffer-controller]: Updating Media Source duration to "+a.toFixed(3)),r.duration=a)}},m.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)}},m.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)})}},m.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,c=n.container+";codecs="+h;T.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var u=i[a]=t.addSourceBuffer(c),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(o){T.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+o.message),this.hls.trigger(y.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:o,mimeType:c})}}r&&this.hls.trigger(y.Events.BUFFER_CREATED,{tracks:this.tracks})},m._onSBUpdateStart=function(e){var i=this.operationQueue,t=i.current(e);t.onStart()},m._onSBUpdateEnd=function(e){var i=this.operationQueue,t=i.current(e);t.onComplete(),i.shiftAndExecuteNext(e)},m._onSBUpdateError=function(e,i){T.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)},m.removeExecutor=function(e,i,t){var r=this.media,a=this.mediaSource,n=this.operationQueue,h=this.sourceBuffer,c=h[e];if(!r||!a||!c){T.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),n.shiftAndExecuteNext(e);return}var u=Object(b.isFiniteNumber)(r.duration)?r.duration:1/0,f=Object(b.isFiniteNumber)(a.duration)?a.duration:1/0,o=Math.max(0,i),l=Math.min(t,u,f);l>o?(T.logger.log("[buffer-controller]: Removing ["+o+","+l+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(o,l)):n.shiftAndExecuteNext(e)},m.appendExecutor=function(e,i){var t=this.operationQueue,r=this.sourceBuffer,a=r[i];if(!a){T.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)},m.blockBuffers=function(e,i){var t=this;if(i===void 0&&(i=this.getSourceBufferTypes()),!i.length){T.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)})})},m.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},m.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)}},m.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(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return y});var b=d("./src/utils/logger.ts"),y=function(){function T(S){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=S}var I=T.prototype;return I.append=function(O,A){var g=this.queues[A];g.push(O),g.length===1&&this.buffers[A]&&this.executeNext(A)},I.insertAbort=function(O,A){var g=this.queues[A];g.unshift(O),this.executeNext(A)},I.appendBlocker=function(O){var A,g=new Promise(function(L){A=L}),_={execute:A,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(_,O),g},I.executeNext=function(O){var A=this.buffers,g=this.queues,_=A[O],L=g[O];if(L.length){var x=L[0];try{x.execute()}catch(v){b.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),x.onError(v),(!_||!_.updating)&&(L.shift(),this.executeNext(O))}}},I.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},I.current=function(O){return this.queues[O][0]},T}()},"./src/controller/cap-level-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts");function y(S,O){for(var A=0;A<O.length;A++){var g=O[A];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(S,g.key,g)}}function T(S,O,A){return O&&y(S.prototype,O),A&&y(S,A),S}var I=function(){function S(A){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=A,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=S.prototype;return O.setStreamController=function(g){this.streamController=g},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var g=this.hls;g.on(b.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.on(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.on(b.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var g=this.hls;g.off(b.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),g.off(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),g.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),g.off(b.Events.BUFFER_CODECS,this.onBufferCodecs,this),g.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(g,_){S.isLevelAllowed(_.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(_.droppedLevel)},O.onMediaAttaching=function(g,_){this.media=_.media instanceof HTMLVideoElement?_.media:null},O.onManifestParsed=function(g,_){var L=this.hls;this.restrictedLevels=[],this.firstLevel=_.firstLevel,L.config.capLevelToPlayerSize&&_.video&&this.startCapping()},O.onBufferCodecs=function(g,_){var L=this.hls;L.config.capLevelToPlayerSize&&_.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var g=this.hls.levels;if(g.length){var _=this.hls;_.autoLevelCapping=this.getMaxLevel(g.length-1),_.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=_.autoLevelCapping}}},O.getMaxLevel=function(g){var _=this,L=this.hls.levels;if(!L.length)return-1;var x=L.filter(function(v,m){return S.isLevelAllowed(m,_.restrictedLevels)&&m<=g});return this.clientRect=null,S.getMaxLevelByMediaSize(x,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var g=this.media,_={width:0,height:0};if(g){var L=g.getBoundingClientRect();_.width=L.width,_.height=L.height,!_.width&&!_.height&&(_.width=L.right-L.left||g.width||0,_.height=L.bottom-L.top||g.height||0)}return this.clientRect=_,_},S.isLevelAllowed=function(g,_){return _===void 0&&(_=[]),_.indexOf(g)===-1},S.getMaxLevelByMediaSize=function(g,_,L){if(!g||!g.length)return-1;for(var x=function(i,t){return t?i.width!==t.width||i.height!==t.height:!0},v=g.length-1,m=0;m<g.length;m+=1){var s=g[m];if((s.width>=_||s.height>=L)&&x(s,g[m+1])){v=m;break}}return v},T(S,[{key:"mediaWidth",get:function(){return this.getDimensions().width*S.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*S.contentScaleFactor}}],[{key:"contentScaleFactor",get:function(){var g=1;try{g=self.devicePixelRatio}catch{}return g}}]),S}();D.default=I},"./src/controller/cmcd-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return x});var b=d("./src/events.ts"),y=d("./src/types/cmcd.ts"),T=d("./src/utils/buffer-helper.ts"),I=d("./src/utils/logger.ts");function S(v,m){for(var s=0;s<m.length;s++){var e=m[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(v,e.key,e)}}function O(v,m,s){return m&&S(v.prototype,m),s&&S(v,s),v}function A(v,m){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))||m&&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,m){if(!!v){if(typeof v=="string")return _(v,m);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 _(v,m)}}function _(v,m){(m==null||m>v.length)&&(m=v.length);for(var s=0,e=new Array(m);s<m;s++)e[s]=v[s];return e}function L(){return L=Object.assign||function(v){for(var m=1;m<arguments.length;m++){var s=arguments[m];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(v[e]=s[e])}return v},L.apply(this,arguments)}var x=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),c={d:a.duration*1e3,ot:h};(h===y.CMCDObjectType.VIDEO||h===y.CMCDObjectType.AUDIO||h==y.CMCDObjectType.MUXED)&&(c.br=n.bitrate/1e3,c.tb=e.getTopBandwidth(h)/1e3,c.bl=e.getBufferLength(h)),e.apply(r,c)}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 m=v.prototype;return m.registerListeners=function(){var e=this.hls;e.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(b.Events.BUFFER_CREATED,this.onBufferCreated,this)},m.unregisterListeners=function(){var e=this.hls;e.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(b.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},m.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},m.onMediaAttached=function(e,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},m.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},m.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},m.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}},m.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)}},m.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},m.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=A(t),c;!(c=h()).done;){var u=c.value;u.bitrate>i&&(i=u.bitrate)}return i>0?i:NaN},m.getBufferLength=function(e){var i=this.hls.media,t=e===y.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!t||!i)return NaN;var r=T.BufferHelper.bufferInfo(t,i.currentTime,this.config.maxBufferHole);return r.len*1e3},m.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,c,u){i(h),this.loader.load(h,c,u)},O(r,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),r}()},m.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,c,u){i(h),this.loader.load(h,c,u)},O(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},c=Object.keys(e||{}).sort(),u=A(c),f;!(f=u()).done;){var o=f.value,l=e[o];if(!!t(l)&&!(o==="v"&&l===1)&&!(o=="pr"&&l===1)){var E=h[o];E&&(l=E(l));var p=typeof l,R=void 0;o==="ot"||o==="sf"||o==="st"?R=o+"="+l:p==="boolean"?R=o:p==="number"?R=o+"="+l:R=o+"="+JSON.stringify(l),i.push(R)}}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,c=i;h<c.length;h++){var u=c[h],f=n[u]!=null?n[u]:1;a[f][u]=e[u]}for(var o=0;o<a.length;o++){var l=v.serialize(a[o]);l&&(t["CMCD-"+r[o]]=l)}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(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts"),y=d("./src/errors.ts"),T=d("./src/utils/logger.ts"),I=d("./src/utils/mediakeys-helper.ts");function S(x,v){for(var m=0;m<v.length;m++){var s=v[m];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,v,m){return v&&S(x.prototype,v),m&&S(x,m),x}var A=3,g=function(v,m,s){var e={audioCapabilities:[],videoCapabilities:[]};return v.forEach(function(i){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+i+'"',robustness:s.audioRobustness||""})}),m.forEach(function(i){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+i+'"',robustness:s.videoRobustness||""})}),[e]},_=function(v,m,s,e){switch(v){case I.KeySystems.WIDEVINE:return g(m,s,e);default:throw new Error("Unknown key-system: "+v)}},L=function(){function x(m){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=m,this._config=m.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=x.prototype;return v.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},v._registerListeners=function(){this.hls.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(b.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this)},v._unregisterListeners=function(){this.hls.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(b.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(b.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=_(s,e,i,this._drmSystemOptions);T.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){T.logger.error('Failed to obtain key-system "'+s+'" access:',n)})},v._onMediaKeySystemAccessObtained=function(s,e){var i=this;T.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,T.logger.log('Media-keys created for key-system "'+s+'"'),i._onMediaKeysCreated(),a});return r.catch(function(a){T.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;T.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(i){e._onKeySessionMessage(s,i.message)},!1)},v._onKeySessionMessage=function(s,e){T.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(i){T.logger.log("Received license data (length: "+(i&&i.byteLength)+"), updating key-session"),s.update(i)})},v.onMediaEncrypted=function(s){var e=this;if(T.logger.log('Media is encrypted using "'+s.initDataType+'" init data type'),!this.mediaKeysPromise){T.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(b.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){T.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}T.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){T.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(t.mediaKeysSessionInitialized){T.logger.warn("Key-Session already initialized but requested again");return}var r=t.mediaKeysSession;if(!r){T.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){T.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}T.logger.log('Generating key-session request for "'+s+'" init data type'),t.mediaKeysSessionInitialized=!0,r.generateRequest(s,e).then(function(){T.logger.debug("Key-session generation succeeded")}).catch(function(a){T.logger.error("Error generating key-session request:",a),i.hls.trigger(b.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){T.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,T.logger.log("License request succeeded");var r=s.response,a=this._licenseResponseCallback;if(a)try{r=a.call(this.hls,s,e)}catch(h){T.logger.error(h)}t(r)}else{if(T.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>A){this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.KEY_SYSTEM_ERROR,details:y.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var n=A-this._requestLicenseFailureCount+1;T.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){T.logger.log("Requesting content license for key-system");var i=this._mediaKeysList[0];if(!i){T.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(b.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);T.logger.log("Sending license request to URL: "+t);var a=this._generateLicenseRequestChallenge(i,s);r.send(a)}catch(n){T.logger.error("Failure requesting DRM license: "+n),this.hls.trigger(b.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)}},O(x,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),x}();D.default=L},"./src/controller/fps-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts"),y=d("./src/utils/logger.ts"),T=function(){function I(O){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=O,this.registerListeners()}var S=I.prototype;return S.setStreamController=function(A){this.streamController=A},S.registerListeners=function(){this.hls.on(b.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},S.unregisterListeners=function(){this.hls.off(b.Events.MEDIA_ATTACHING,this.onMediaAttaching)},S.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},S.onMediaAttaching=function(A,g){var _=this.hls.config;if(_.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),_.fpsDroppedMonitoringPeriod)}},S.checkFPS=function(A,g,_){var L=performance.now();if(g){if(this.lastTime){var x=L-this.lastTime,v=_-this.lastDroppedFrames,m=g-this.lastDecodedFrames,s=1e3*v/x,e=this.hls;if(e.trigger(b.Events.FPS_DROP,{currentDropped:v,currentDecoded:m,totalDroppedFrames:_}),s>0&&v>e.config.fpsDroppedMonitoringThreshold*m){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(b.Events.FPS_DROP_LEVEL_CAPPING,{level:i,droppedLevel:e.currentLevel}),e.autoLevelCapping=i,this.streamController.nextLevelSwitch())}}this.lastTime=L,this.lastDroppedFrames=_,this.lastDecodedFrames=g}},S.checkFPSInterval=function(){var A=this.media;if(A)if(this.isVideoPlaybackQualityAvailable){var g=A.getVideoPlaybackQuality();this.checkFPS(A,g.totalVideoFrames,g.droppedVideoFrames)}else this.checkFPS(A,A.webkitDecodedFrameCount,A.webkitDroppedFrameCount)},I}();D.default=T},"./src/controller/fragment-finders.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"findFragmentByPDT",function(){return T}),d.d(D,"findFragmentByPTS",function(){return I}),d.d(D,"fragmentWithinToleranceTest",function(){return S}),d.d(D,"pdtWithinToleranceTest",function(){return O}),d.d(D,"findFragWithCC",function(){return A});var b=d("./src/polyfills/number.ts"),y=d("./src/utils/binary-search.ts");function T(g,_,L){if(_===null||!Array.isArray(g)||!g.length||!Object(b.isFiniteNumber)(_))return null;var x=g[0].programDateTime;if(_<(x||0))return null;var v=g[g.length-1].endProgramDateTime;if(_>=(v||0))return null;L=L||0;for(var m=0;m<g.length;++m){var s=g[m];if(O(_,L,s))return s}return null}function I(g,_,L,x){L===void 0&&(L=0),x===void 0&&(x=0);var v=null;if(g?v=_[g.sn-_[0].sn+1]||null:L===0&&_[0].start===0&&(v=_[0]),v&&S(L,x,v)===0)return v;var m=y.default.search(_,S.bind(null,L,x));return m||v}function S(g,_,L){g===void 0&&(g=0),_===void 0&&(_=0);var x=Math.min(_,L.duration+(L.deltaPTS?L.deltaPTS:0));return L.start+L.duration-x<=g?1:L.start-x>g&&L.start?-1:0}function O(g,_,L){var x=Math.min(_,L.duration+(L.deltaPTS?L.deltaPTS:0))*1e3,v=L.endProgramDateTime||0;return v-x>g}function A(g,_){return y.default.search(g,function(L){return L.cc<_?1:L.cc>_?-1:0})}},"./src/controller/fragment-tracker.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"FragmentState",function(){return T}),d.d(D,"FragmentTracker",function(){return I});var b=d("./src/events.ts"),y=d("./src/types/loader.ts"),T;(function(A){A.NOT_LOADED="NOT_LOADED",A.BACKTRACKED="BACKTRACKED",A.APPENDING="APPENDING",A.PARTIAL="PARTIAL",A.OK="OK"})(T||(T={}));var I=function(){function A(_){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=_,this._registerListeners()}var g=A.prototype;return g._registerListeners=function(){var L=this.hls;L.on(b.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.on(b.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.on(b.Events.FRAG_LOADED,this.onFragLoaded,this)},g._unregisterListeners=function(){var L=this.hls;L.off(b.Events.BUFFER_APPENDED,this.onBufferAppended,this),L.off(b.Events.FRAG_BUFFERED,this.onFragBuffered,this),L.off(b.Events.FRAG_LOADED,this.onFragLoaded,this)},g.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},g.getAppendedFrag=function(L,x){if(x===y.PlaylistLevelType.MAIN){var v=this.activeFragment,m=this.activeParts;if(!v)return null;if(m)for(var s=m.length;s--;){var e=m[s],i=e?e.end:v.appendedPTS;if(e.start<=L&&i!==void 0&&L<=i)return s>9&&(this.activeParts=m.slice(s-9)),e}else if(v.start<=L&&v.appendedPTS!==void 0&&L<=v.appendedPTS)return v}return this.getBufferedFrag(L,x)},g.getBufferedFrag=function(L,x){for(var v=this.fragments,m=Object.keys(v),s=m.length;s--;){var e=v[m[s]];if((e==null?void 0:e.body.type)===x&&e.buffered){var i=e.body;if(i.start<=L&&L<=i.end)return i}}return null},g.detectEvictedFragments=function(L,x,v){var m=this;Object.keys(this.fragments).forEach(function(s){var e=m.fragments[s];if(!!e){if(!e.buffered){e.body.type===v&&m.removeFragment(e.body);return}var i=e.range[L];!i||i.time.some(function(t){var r=!m.isTimeBuffered(t.startPTS,t.endPTS,x);return r&&m.removeFragment(e.body),r})}})},g.detectPartialFragments=function(L){var x=this,v=this.timeRanges,m=L.frag,s=L.part;if(!(!v||m.sn==="initSegment")){var e=O(m),i=this.fragments[e];!i||(Object.keys(v).forEach(function(t){var r=m.elementaryStreams[t];if(!!r){var a=v[t],n=s!==null||r.partial===!0;i.range[t]=x.getBufferedTimes(m,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 x=O(L),v=this.fragments[x];v&&(v.backtrack=v.loaded=null,v.buffered=!0)},g.getBufferedTimes=function(L,x,v,m){for(var s={time:[],partial:v},e=x?x.start:L.start,i=x?x.end:L.end,t=L.minEndPTS||i,r=L.maxStartPTS||e,a=0;a<m.length;a++){var n=m.start(a)-this.bufferPadding,h=m.end(a)+this.bufferPadding;if(r>=n&&t<=h){s.time.push({startPTS:Math.max(e,m.start(a)),endPTS:Math.min(i,m.end(a))});break}else if(e<h&&i>n)s.partial=!0,s.time.push({startPTS:Math.max(e,m.start(a)),endPTS:Math.min(i,m.end(a))});else if(i<=n)break}return s},g.getPartialFragment=function(L){var x=null,v,m,s,e=0,i=this.bufferPadding,t=this.fragments;return Object.keys(t).forEach(function(r){var a=t[r];!a||S(a)&&(m=a.body.start-i,s=a.body.end+i,L>=m&&L<=s&&(v=Math.min(L-m,s-L),e<=v&&(x=a.body,e=v)))}),x},g.getState=function(L){var x=O(L),v=this.fragments[x];return v?v.buffered?S(v)?T.PARTIAL:T.OK:v.backtrack?T.BACKTRACKED:T.APPENDING:T.NOT_LOADED},g.backtrack=function(L,x){var v=O(L),m=this.fragments[v];if(!m||m.backtrack)return null;var s=m.backtrack=x||m.loaded;return m.loaded=null,s},g.getBacktrackData=function(L){var x=O(L),v=this.fragments[x];if(v){var m,s=v.backtrack;if(s!=null&&(m=s.payload)!==null&&m!==void 0&&m.byteLength)return s;this.removeFragment(L)}return null},g.isTimeBuffered=function(L,x,v){for(var m,s,e=0;e<v.length;e++){if(m=v.start(e)-this.bufferPadding,s=v.end(e)+this.bufferPadding,L>=m&&x<=s)return!0;if(x<=m)return!1}return!1},g.onFragLoaded=function(L,x){var v=x.frag,m=x.part;if(!(v.sn==="initSegment"||v.bitrateTest||m)){var s=O(v);this.fragments[s]={body:v,loaded:x,backtrack:null,buffered:!1,range:Object.create(null)}}},g.onBufferAppended=function(L,x){var v=this,m=x.frag,s=x.part,e=x.timeRanges;if(m.type===y.PlaylistLevelType.MAIN)if(this.activeFragment=m,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++)m.appendedPTS=Math.max(r.end(a),m.appendedPTS||0)})},g.onFragBuffered=function(L,x){this.detectPartialFragments(x)},g.hasFragment=function(L){var x=O(L);return!!this.fragments[x]},g.removeFragmentsInRange=function(L,x,v){var m=this;Object.keys(this.fragments).forEach(function(s){var e=m.fragments[s];if(!!e&&e.buffered){var i=e.body;i.type===v&&i.start<x&&i.end>L&&m.removeFragment(i)}})},g.removeFragment=function(L){var x=O(L);L.stats.loaded=0,L.clearElementaryStreamInfo(),delete this.fragments[x]},g.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},A}();function S(A){var g,_;return A.buffered&&(((g=A.range.video)===null||g===void 0?void 0:g.partial)||((_=A.range.audio)===null||_===void 0?void 0:_.partial))}function O(A){return A.type+"_"+A.level+"_"+A.urlId+"_"+A.sn}},"./src/controller/gap-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"STALL_MINIMUM_DURATION_MS",function(){return S}),d.d(D,"MAX_START_GAP_JUMP",function(){return O}),d.d(D,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return A}),d.d(D,"SKIP_BUFFER_RANGE_START",function(){return g}),d.d(D,"default",function(){return _});var b=d("./src/utils/buffer-helper.ts"),y=d("./src/errors.ts"),T=d("./src/events.ts"),I=d("./src/utils/logger.ts"),S=250,O=2,A=.1,g=.05,_=function(){function L(v,m,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=m,this.fragmentTracker=s,this.hls=e}var x=L.prototype;return x.destroy=function(){this.hls=this.fragmentTracker=this.media=null},x.poll=function(m){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!==m){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||!b.BufferHelper.getBuffered(e).length)){var c=b.BufferHelper.bufferInfo(e,t,0),u=c.len>0,f=c.nextStart||0;if(!(!u&&!f)){if(r){var o=c.len>O,l=!f||f-t>O&&!this.fragmentTracker.getPartialFragment(t);if(o||l)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E,p=Math.max(f,c.start||0)-t,R=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,P=R==null||(E=R.details)===null||E===void 0?void 0:E.live,M=P?R.details.targetduration*2:O;if(p>0&&p<=M){this._trySkipBufferHole(null);return}}var F=self.performance.now();if(i===null){this.stalled=F;return}var w=F-i;!r&&w>=S&&this._reportStall(c.len);var C=b.BufferHelper.bufferInfo(e,t,s.maxBufferHole);this._tryFixBufferStall(C,w)}}},x._tryFixBufferStall=function(m,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}m.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},x._reportStall=function(m){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="+m+")"),s.trigger(T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:m}))},x._trySkipBufferHole=function(m){for(var s=this.config,e=this.hls,i=this.media,t=i.currentTime,r=0,a=b.BufferHelper.getBuffered(i),n=0;n<a.length;n++){var h=a.start(n);if(t+s.maxBufferHole>=r&&t<h){var c=Math.max(h+g,i.currentTime+A);return I.logger.warn("skipping hole, adjusting currentTime from "+t+" to "+c),this.moved=!0,this.stalled=null,i.currentTime=c,m&&e.trigger(T.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 "+c,frag:m}),c}r=a.end(n)}return 0},x._tryNudgeBuffer=function(){var m=this.config,s=this.hls,e=this.media,i=e.currentTime,t=(this.nudgeRetry||0)+1;if(this.nudgeRetry=t,t<m.nudgeMaxRetry){var r=i+t*m.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+i+" to "+r),e.currentTime=r,s.trigger(T.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 "+m.nudgeMaxRetry+" nudges"),s.trigger(T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},L}()},"./src/controller/id3-track-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts"),y=d("./src/utils/texttrack-utils.ts"),T=d("./src/demux/id3.ts"),I=.25,S=function(){function O(g){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=g,this._registerListeners()}var A=O.prototype;return A.destroy=function(){this._unregisterListeners()},A._registerListeners=function(){var _=this.hls;_.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),_.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),_.on(b.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),_.on(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},A._unregisterListeners=function(){var _=this.hls;_.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),_.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),_.off(b.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),_.off(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},A.onMediaAttached=function(_,L){this.media=L.media},A.onMediaDetaching=function(){!this.id3Track||(Object(y.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},A.getID3Track=function(_){if(!!this.media){for(var L=0;L<_.length;L++){var x=_[L];if(x.kind==="metadata"&&x.label==="id3")return Object(y.sendAddTrackEvent)(x,this.media),x}return this.media.addTextTrack("metadata","id3")}},A.onFragParsingMetadata=function(_,L){if(!!this.media){var x=L.frag,v=L.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var m=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,s=0;s<v.length;s++){var e=T.getID3Frames(v[s].data);if(e){var i=v[s].pts,t=s<v.length-1?v[s+1].pts:x.end,r=t-i;r<=0&&(t=i+I);for(var a=0;a<e.length;a++){var n=e[a];if(!T.isTimeStampFrame(n)){var h=new m(i,t,"");h.value=n,this.id3Track.addCue(h)}}}}}},A.onBufferFlushing=function(_,L){var x=L.startOffset,v=L.endOffset,m=L.type;if(!m||m==="audio"){var s=this.id3Track;s&&Object(y.removeCuesInRange)(s,x,v)}},O}();D.default=S},"./src/controller/latency-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return O});var b=d("./src/errors.ts"),y=d("./src/events.ts"),T=d("./src/utils/logger.ts");function I(A,g){for(var _=0;_<g.length;_++){var L=g[_];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(A,L.key,L)}}function S(A,g,_){return g&&I(A.prototype,g),_&&I(A,_),A}var O=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=_,this.config=_.config,this.registerListeners()}var g=A.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,x){this.media=x.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,x){var v=x.details;this.levelDetails=v,v.advanced&&this.timeupdate(),!v.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},g.onError=function(L,x){x.details===b.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,T.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},g.timeupdate=function(){var L=this.media,x=this.levelDetails;if(!(!L||!x)){this.currentTime=L.currentTime;var v=this.computeLatency();if(v!==null){this._latency=v;var m=this.config,s=m.lowLatencyMode,e=m.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var i=this.targetLatency;if(i!==null){var t=v-i,r=Math.min(this.maxLatency,i+x.targetduration),a=t<r;if(x.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},S(A,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var L=this.config,x=this.levelDetails;return L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:x?L.liveMaxLatencyDurationCount*x.targetduration:0}},{key:"targetLatency",get:function(){var L=this.levelDetails;if(L===null)return null;var x=L.holdBack,v=L.partHoldBack,m=L.targetduration,s=this.config,e=s.liveSyncDuration,i=s.liveSyncDurationCount,t=s.lowLatencyMode,r=this.hls.userConfig,a=t&&v||x;(r.liveSyncDuration||r.liveSyncDurationCount||a===0)&&(a=e!==void 0?e:i*m);var n=m,h=1;return a+Math.min(this.stallCount*h,n)}},{key:"liveSyncPosition",get:function(){var L=this.estimateLiveEdge(),x=this.targetLatency,v=this.levelDetails;if(L===null||x===null||v===null)return null;var m=v.edge,s=L-x-this.edgeStalled,e=m-v.totalduration,i=m-(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 x=(this.config.lowLatencyMode&&L.partTarget||L.targetduration)*3;return Math.max(L.age-x,0)}},{key:"forwardBufferLength",get:function(){var L=this.media,x=this.levelDetails;if(!L||!x)return 0;var v=L.buffered.length;return v?L.buffered.end(v-1):x.edge-this.currentTime}}]),A}()},"./src/controller/level-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return s});var b=d("./src/types/level.ts"),y=d("./src/events.ts"),T=d("./src/errors.ts"),I=d("./src/utils/codecs.ts"),S=d("./src/controller/level-helper.ts"),O=d("./src/controller/base-playlist-controller.ts"),A=d("./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 _(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&&_(e.prototype,i),t&&_(e,t),e}function x(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 m=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){x(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=[],c=[],u=[],f,o={},l,E=!1,p=!1,R=!1;if(n.levels.forEach(function(w){var C=w.attrs;E=E||!!(w.width&&w.height),p=p||!!w.videoCodec,R=R||!!w.audioCodec,m&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var B=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;l=o[B],l?l.url.push(w.url):(l=new b.Level(w),o[B]=l,h.push(l)),C&&(C.AUDIO&&Object(S.addGroupId)(l,"audio",C.AUDIO),C.SUBTITLES&&Object(S.addGroupId)(l,"text",C.SUBTITLES))}),(E||p)&&R&&(h=h.filter(function(w){var C=w.videoCodec,B=w.width,k=w.height;return!!C||!!(B&&k)})),h=h.filter(function(w){var C=w.audioCodec,B=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!B||Object(I.isCodecSupportedInMp4)(B,"video"))}),n.audioTracks&&(c=n.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(S.assignTrackIdsByGroup)(c)),n.subtitles&&(u=n.subtitles,Object(S.assignTrackIdsByGroup)(u)),h.length>0){f=h[0].bitrate,h.sort(function(w,C){return w.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=R&&!p,F={levels:h,audioTracks:c,subtitleTracks:u,firstLevel:this._firstLevel,stats:n.stats,audio:R,video:p,altAudio:!M&&c.some(function(w){return!!w.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:T.ErrorTypes.MEDIA_ERROR,details:T.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,c=this._levels[this.currentLevelIndex];if(h&&(h.type===A.PlaylistContextType.AUDIO_TRACK&&c.audioGroupIds&&h.groupId===c.audioGroupIds[c.urlId]||h.type===A.PlaylistContextType.SUBTITLE_TRACK&&c.textGroupIds&&h.groupId===c.textGroupIds[c.urlId])){this.redundantFailover(this.currentLevelIndex);return}var u=!1,f=!0,o;switch(n.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:case T.ErrorDetails.KEY_LOAD_ERROR:case T.ErrorDetails.KEY_LOAD_TIMEOUT:if(n.frag){var l=this._levels[n.frag.level];l?(l.fragmentError++,l.fragmentError>this.hls.config.fragLoadingMaxRetry&&(o=n.frag.level)):o=n.frag.level}break;case T.ErrorDetails.LEVEL_LOAD_ERROR:case T.ErrorDetails.LEVEL_LOAD_TIMEOUT:h&&(h.deliveryDirectives&&(f=!1),o=h.level),u=!0;break;case T.ErrorDetails.REMUX_ALLOC_ERROR:o=n.level,u=!0;break}o!==void 0&&this.recoverLevel(n,o,u,f)}},t.recoverLevel=function(a,n,h,c){var u=a.details,f=this._levels[n];if(f.loadError++,h){var o=this.retryLoadingOrFail(a);if(o)a.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var l=f.url.length;if(l>1&&f.loadError<l)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 c=(n.urlId+1)%h;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(u){u.urlId=c}),this.level=a}},t.onFragLoaded=function(a,n){var h=n.frag;if(h!==void 0&&h.type===A.PlaylistLevelType.MAIN){var c=this._levels[h.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},t.onLevelLoaded=function(a,n){var h,c=n.level,u=n.details,f=this._levels[c];if(!f){var o;this.warn("Invalid level index "+c),(o=n.deliveryDirectives)!==null&&o!==void 0&&o.skip&&(u.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(f.fragmentError===0&&(f.loadError=0,this.retryCount=0),this.playlistLoaded(c,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 c=-1,u=this.hls.audioTracks[n.id].groupId,f=0;f<h.audioGroupIds.length;f++)if(h.audioGroupIds[f]===u){c=f;break}c!==h.urlId&&(h.urlId=c,this.startLoad())}},t.loadPlaylist=function(a){var n=this.currentLevelIndex,h=this._levels[n];if(this.canLoad&&h&&h.url.length>0){var c=h.urlId,u=h.url[c];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 "+c+" "+u),this.clearTimer(),this.hls.trigger(y.Events.LEVEL_LOADING,{url:u,level:n,id:c,deliveryDirectives:a||null})}},t.removeLevel=function(a,n){var h=function(f,o){return o!==n},c=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 o=u.details;return o!=null&&o.fragments&&o.fragments.forEach(function(l){l.level=f}),u});this._levels=c,this.hls.trigger(y.Events.LEVELS_UPDATED,{levels:c})},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 c=a<0;if(this.hls.trigger(y.Events.ERROR,{type:T.ErrorTypes.OTHER_ERROR,details:T.ErrorDetails.LEVEL_SWITCH_ERROR,level:a,fatal:c,reason:"invalid level idx"}),c)return;a=Math.min(a,h.length-1)}this.clearTimer();var u=this.currentLevelIndex,f=h[u],o=h[a];this.log("switching to level "+a+" from "+u),this.currentLevelIndex=a;var l=g({},o,{level:a,maxBitrate:o.maxBitrate,uri:o.uri,urlId:o.urlId});delete l._urlId,this.hls.trigger(y.Events.LEVEL_SWITCHING,l);var E=o.details;if(!E||E.live){var p=this.switchParams(o.uri,f==null?void 0:f.details);this.loadPlaylist(p)}}}},{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}(O.default)},"./src/controller/level-helper.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"addGroupId",function(){return T}),d.d(D,"assignTrackIdsByGroup",function(){return I}),d.d(D,"updatePTS",function(){return S}),d.d(D,"updateFragPTSDTS",function(){return A}),d.d(D,"mergeDetails",function(){return g}),d.d(D,"mapPartIntersection",function(){return _}),d.d(D,"mapFragmentIntersection",function(){return L}),d.d(D,"adjustSliding",function(){return x}),d.d(D,"addSliding",function(){return v}),d.d(D,"computeReloadInterval",function(){return m}),d.d(D,"getFragmentWithSN",function(){return s}),d.d(D,"getPartWith",function(){return e});var b=d("./src/polyfills/number.ts"),y=d("./src/utils/logger.ts");function T(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 S(i,t,r){var a=i[t],n=i[r];O(a,n)}function O(i,t){var r=t.startPTS;if(Object(b.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 A(i,t,r,a,n,h){var c=a-r;c<=0&&(y.logger.warn("Fragment should have a positive duration",t),a=r+t.duration,h=n+t.duration);var u=r,f=a,o=t.startPTS,l=t.endPTS;if(Object(b.isFiniteNumber)(o)){var E=Math.abs(o-r);Object(b.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(E,t.deltaPTS):t.deltaPTS=E,u=Math.max(r,o),r=Math.min(r,o),n=Math.min(n,t.startDTS),f=Math.min(a,l),a=Math.max(a,l),h=Math.max(h,t.endDTS)}t.duration=a-r;var p=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 R=t.sn;if(!i||R<i.startSN||R>i.endSN)return 0;var P,M=R-i.startSN,F=i.fragments;for(F[M]=t,P=M;P>0;P--)O(F[P],F[P-1]);for(P=M;P<F.length-1;P++)O(F[P],F[P+1]);return i.fragmentHint&&O(F[F.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,p}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 c=0,u;if(L(i,t,function(P,M){P.relurl&&(c=P.cc-M.cc),Object(b.isFiniteNumber)(P.startPTS)&&Object(b.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 o=t.skippedSegments;o--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}var l=t.fragments;if(c){y.logger.warn("discontinuity sliding from playlist, take drift into account");for(var E=0;E<l.length;E++)l[E].cc+=c}t.skippedSegments&&(t.startCC=t.fragments[0].cc),_(i.partList,t.partList,function(P,M){M.elementaryStreams=P.elementaryStreams,M.stats=P.stats}),u?A(t,u,u.startPTS,u.endPTS,u.startDTS,u.endDTS):x(i,t),l.length&&(t.totalduration=t.edge-l[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var p=t.advancedDateTime;if(t.advanced&&p){var R=t.edge;t.driftStart||(t.driftStartTime=p,t.driftStart=R),t.driftEndTime=p,t.driftEnd=R}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function _(i,t,r){if(i&&t)for(var a=0,n=0,h=i.length;n<=h;n++){var c=i[n],u=t[n+a];c&&u&&c.index===u.index&&c.fragment.sn===u.fragment.sn?r(c,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,c=t.startSN-i.startSN,u=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,o=n;o<=h;o++){var l=f[c+o],E=u[o];a&&!E&&o<a&&(E=t.fragments[o]=l),l&&E&&r(l,E)}}function x(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 m(i,t){var r=1e3*i.levelTargetDuration,a=r/2,n=i.age,h=n>0&&n<r*3,c=t.loading.end-t.loading.start,u,f=i.availabilityDelay;if(i.updated===!1)if(h){var o=333*i.misses;u=Math.max(Math.min(a,c*2),o),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-c;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(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return a});var b=d("./src/polyfills/number.ts"),y=d("./src/controller/base-stream-controller.ts"),T=d("./src/is-supported.ts"),I=d("./src/events.ts"),S=d("./src/utils/buffer-helper.ts"),O=d("./src/controller/fragment-tracker.ts"),A=d("./src/types/loader.ts"),g=d("./src/loader/fragment.ts"),_=d("./src/demux/transmuxer-interface.ts"),L=d("./src/types/transmuxer.ts"),x=d("./src/controller/gap-controller.ts"),v=d("./src/errors.ts"),m=d("./src/utils/logger.ts");function s(n,h){for(var c=0;c<h.length;c++){var u=h[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function e(n,h,c){return h&&s(n.prototype,h),c&&s(n,c),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 o;return o=n.call(this,u,f,"[stream-controller]")||this,o.audioCodecSwap=!1,o.gapController=null,o.level=-1,o._forceStartLoad=!1,o.altAudio=!1,o.audioOnly=!1,o.fragPlaying=null,o.onvplaying=null,o.onvseeked=null,o.fragLastKbps=0,o.stalled=!1,o.couldBacktrack=!1,o.audioCodecSwitch=!1,o.videoBuffer=null,o._registerListeners(),o}var c=h.prototype;return c._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)},c._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)},c.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},c.startLoad=function(f){if(this.levels){var o=this.lastCurrentTime,l=this.hls;if(this.stopLoad(),this.setInterval(r),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var E=l.startLevel;E===-1&&(l.config.testBandwidth?(E=0,this.bitrateTest=!0):E=l.nextAutoLevel),this.level=l.nextLoadLevel=E,this.loadedmetadata=!1}o>0&&f===-1&&(this.log("Override startPosition with lastCurrentTime @"+o.toFixed(3)),f=o),this.state=y.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=f,this.tick()}else this._forceStartLoad=!0,this.state=y.State.STOPPED},c.stopLoad=function(){this._forceStartLoad=!1,n.prototype.stopLoad.call(this)},c.doTick=function(){switch(this.state){case y.State.IDLE:this.doTickIdle();break;case y.State.WAITING_LEVEL:{var f,o=this.levels,l=this.level,E=o==null||(f=o[l])===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 p,R=self.performance.now(),P=this.retryDate;(!P||R>=P||(p=this.media)!==null&&p!==void 0&&p.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=y.State.IDLE)}break;default:break}this.onTickEnd()},c.onTickEnd=function(){n.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},c.doTickIdle=function(){var f,o,l=this.hls,E=this.levelLastLoaded,p=this.levels,R=this.media,P=l.config,M=l.nextLoadLevel;if(!(E===null||!R&&(this.startFragRequested||!P.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!p||!p[M])){var F=p[M];this.level=l.nextLoadLevel=M;var w=F.details;if(!w||this.state===y.State.WAITING_LEVEL||w.live&&this.levelLastLoaded!==M){this.state=y.State.WAITING_LEVEL;return}var C=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:R,A.PlaylistLevelType.MAIN);if(C!==null){var B=C.len,k=this.getMaxBufferLength(F.maxBitrate);if(!(B>=k)){if(this._streamEnded(C,w)){var N={};this.altAudio&&(N.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,N),this.state=y.State.ENDED;return}var W=C.end,j=this.getNextFragment(W,w);if(this.couldBacktrack&&!this.fragPrevious&&j&&j.sn!=="initSegment"){var K=j.sn-w.startSN;K>1&&(j=w.fragments[K-1],this.fragmentTracker.removeFragment(j))}if(j&&this.fragmentTracker.getState(j)===O.FragmentState.OK&&this.nextLoadPosition>W){var V=this.audioOnly&&!this.altAudio?g.ElementaryStreamTypes.AUDIO:g.ElementaryStreamTypes.VIDEO;this.afterBufferFlushed(R,V,A.PlaylistLevelType.MAIN),j=this.getNextFragment(this.nextLoadPosition,w)}!j||(j.initSegment&&!j.initSegment.data&&!this.bitrateTest&&(j=j.initSegment),((f=j.decryptdata)===null||f===void 0?void 0:f.keyFormat)==="identity"&&!((o=j.decryptdata)!==null&&o!==void 0&&o.key)?this.loadKey(j,w):this.loadFragment(j,w,W))}}}},c.loadFragment=function(f,o,l){var E,p=this.fragmentTracker.getState(f);if(this.fragCurrent=f,p===O.FragmentState.BACKTRACKED){var R=this.fragmentTracker.getBacktrackData(f);if(R){this._handleFragmentLoadProgress(R),this._handleFragmentLoadComplete(R);return}else p=O.FragmentState.NOT_LOADED}p===O.FragmentState.NOT_LOADED||p===O.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,o,l)):p===O.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()},c.getAppendedFrag=function(f){var o=this.fragmentTracker.getAppendedFrag(f,A.PlaylistLevelType.MAIN);return o&&"fragment"in o?o.fragment:o},c.getBufferedFrag=function(f){return this.fragmentTracker.getBufferedFrag(f,A.PlaylistLevelType.MAIN)},c.followingBufferedFrag=function(f){return f?this.getBufferedFrag(f.end+.5):null},c.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},c.nextLevelSwitch=function(){var f=this.levels,o=this.media;if(o!=null&&o.readyState){var l,E=this.getAppendedFrag(o.currentTime);if(E&&E.start>1&&this.flushMainBuffer(0,E.start-1),!o.paused&&f){var p=this.hls.nextLoadLevel,R=f[p],P=this.fragLastKbps;P&&this.fragCurrent?l=this.fragCurrent.duration*R.maxBitrate/(1e3*P)+1:l=0}else l=0;var M=this.getBufferedFrag(o.currentTime+l);if(M){var F=this.followingBufferedFrag(M);if(F){this.abortCurrentFrag();var w=F.maxStartPTS?F.maxStartPTS:F.start,C=F.duration,B=Math.max(M.end,w+Math.min(Math.max(C-this.config.maxFragLookUpTolerance,C*.5),C*.75));this.flushMainBuffer(B,Number.POSITIVE_INFINITY)}}}},c.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()},c.flushMainBuffer=function(f,o){n.prototype.flushMainBuffer.call(this,f,o,this.altAudio?"video":null)},c.onMediaAttached=function(f,o){n.prototype.onMediaAttached.call(this,f,o);var l=o.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),l.addEventListener("playing",this.onvplaying),l.addEventListener("seeked",this.onvseeked),this.gapController=new x.default(this.config,l,this.fragmentTracker,this.hls)},c.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)},c.onMediaPlaying=function(){this.tick()},c.onMediaSeeked=function(){var f=this.media,o=f?f.currentTime:null;Object(b.isFiniteNumber)(o)&&this.log("Media seeked to "+o.toFixed(3)),this.tick()},c.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},c.onManifestParsed=function(f,o){var l=!1,E=!1,p;o.levels.forEach(function(R){p=R.audioCodec,p&&(p.indexOf("mp4a.40.2")!==-1&&(l=!0),p.indexOf("mp4a.40.5")!==-1&&(E=!0))}),this.audioCodecSwitch=l&&E&&!Object(T.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=o.levels,this.startFragRequested=!1},c.onLevelLoading=function(f,o){var l=this.levels;if(!(!l||this.state!==y.State.IDLE)){var E=l[o.level];(!E.details||E.details.live&&this.levelLastLoaded!==o.level||this.waitForCdnTuneIn(E.details))&&(this.state=y.State.WAITING_LEVEL)}},c.onLevelLoaded=function(f,o){var l,E=this.levels,p=o.level,R=o.details,P=R.totalduration;if(!E){this.warn("Levels were reset while loading level "+p);return}this.log("Level "+p+" loaded ["+R.startSN+","+R.endSN+"], cc ["+R.startCC+", "+R.endCC+"] duration:"+P);var M=this.fragCurrent;M&&(this.state===y.State.FRAG_LOADING||this.state===y.State.FRAG_LOADING_WAITING_RETRY)&&M.level!==o.level&&M.loader&&(this.state=y.State.IDLE,M.loader.abort());var F=E[p],w=0;if(R.live||(l=F.details)!==null&&l!==void 0&&l.live){if(R.fragments[0]||(R.deltaUpdateFailed=!0),R.deltaUpdateFailed)return;w=this.alignPlaylists(R,F.details)}if(F.details=R,this.levelLastLoaded=p,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:R,level:p}),this.state===y.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(R))return;this.state=y.State.IDLE}this.startFragRequested?R.live&&this.synchronizeToLiveEdge(R):this.setStartPosition(R,w),this.tick()},c._handleFragmentLoadProgress=function(f){var o,l=f.frag,E=f.part,p=f.payload,R=this.levels;if(!R){this.warn("Levels were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var P=R[l.level],M=P.details;if(!M){this.warn("Dropping fragment "+l.sn+" of level "+l.level+" after level details were reset");return}var F=P.videoCodec,w=M.PTSKnown||!M.live,C=(o=l.initSegment)===null||o===void 0?void 0:o.data,B=this._getAudioCodec(P),k=this.transmuxer=this.transmuxer||new _.default(this.hls,A.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),N=E?E.index:-1,W=N!==-1,j=new L.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,p.byteLength,N,W),K=this.initPTS[l.cc];k.push(p,C,B,F,l,E,M.totalduration,w,j,K)},c.onAudioTrackSwitching=function(f,o){var l=this.altAudio,E=!!o.url,p=o.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 R=this.fragCurrent;R!=null&&R.loader&&(this.log("Switching to main audio track, cancel main fragment load"),R.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var P=this.hls;l&&P.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),P.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:p})}},c.onAudioTrackSwitched=function(f,o){var l=o.id,E=!!this.hls.audioTracks[l].url;if(E){var p=this.videoBuffer;p&&this.mediaBuffer!==p&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=p)}this.altAudio=E,this.tick()},c.onBufferCreated=function(f,o){var l=o.tracks,E,p,R=!1;for(var P in l){var M=l[P];if(M.id==="main"){if(p=P,E=M,P==="video"){var F=l[P];F&&(this.videoBuffer=F.buffer)}}else R=!0}R&&E?(this.log("Alternate track found, use "+p+".buffered to schedule main fragment loading"),this.mediaBuffer=E.buffer):this.mediaBuffer=this.media},c.onFragBuffered=function(f,o){var l=o.frag,E=o.part;if(!(l&&l.type!==A.PlaylistLevelType.MAIN)){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(E?" p: "+E.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state),this.state===y.State.PARSED&&(this.state=y.State.IDLE);return}var p=E?E.stats:l.stats;this.fragLastKbps=Math.round(8*p.total/(p.buffering.end-p.loading.first)),l.sn!=="initSegment"&&(this.fragPrevious=l),this.fragBufferedComplete(l,E)}},c.onError=function(f,o){switch(o.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(A.PlaylistLevelType.MAIN,o);break;case v.ErrorDetails.LEVEL_LOAD_ERROR:case v.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==y.State.ERROR&&(o.fatal?(this.warn(""+o.details),this.state=y.State.ERROR):!o.levelRetry&&this.state===y.State.WAITING_LEVEL&&(this.state=y.State.IDLE));break;case v.ErrorDetails.BUFFER_FULL_ERROR:if(o.parent==="main"&&(this.state===y.State.PARSING||this.state===y.State.PARSED)){var l=!0,E=this.getFwdBufferInfo(this.media,A.PlaylistLevelType.MAIN);E&&E.len>.5&&(l=!this.reduceMaxBufferLength(E.len)),l&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},c.checkBuffer=function(){var f=this.media,o=this.gapController;if(!(!f||!o||!f.readyState)){var l=S.BufferHelper.getBuffered(f);!this.loadedmetadata&&l.length?(this.loadedmetadata=!0,this.seekToStartPos()):o.poll(this.lastCurrentTime),this.lastCurrentTime=f.currentTime}},c.onFragLoadEmergencyAborted=function(){this.state=y.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},c.onBufferFlushed=function(f,o){var l=o.type;if(l!==g.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var E=(l===g.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(E,l,A.PlaylistLevelType.MAIN)}},c.onLevelsUpdated=function(f,o){this.levels=o.levels},c.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},c.seekToStartPos=function(){var f=this.media,o=f.currentTime,l=this.startPosition;if(l>=0&&o<l){if(f.seeking){m.logger.log("could not seek to "+l+", already seeking at "+o);return}var E=S.BufferHelper.getBuffered(f),p=E.length?E.start(0):0,R=p-l;R>0&&(R<this.config.maxBufferHole||R<this.config.maxFragLookUpTolerance)&&(m.logger.log("adjusting start position by "+R+" to match buffer start"),l+=R,this.startPosition=l),this.log("seek to target start position "+l+" from current time "+o),f.currentTime=l}},c._getAudioCodec=function(f){var o=this.config.defaultAudioCodec||f.audioCodec;return this.audioCodecSwap&&o&&(this.log("Swapping audio codec"),o.indexOf("mp4a.40.5")!==-1?o="mp4a.40.2":o="mp4a.40.5"),o},c._loadBitrateTestFrag=function(f){var o=this;this._doFragLoad(f).then(function(l){var E=o.hls;if(!(!l||E.nextLoadLevel||o.fragContextChanged(f))){o.fragLoadError=0,o.state=y.State.IDLE,o.startFragRequested=!1,o.bitrateTest=!1;var p=f.stats;p.parsing.start=p.parsing.end=p.buffering.start=p.buffering.end=self.performance.now(),E.trigger(I.Events.FRAG_LOADED,l)}})},c._handleTransmuxComplete=function(f){var o,l="main",E=this.hls,p=f.remuxResult,R=f.chunkMeta,P=this.getCurrentContext(R);if(!P){this.warn("The loading context changed while buffering fragment "+R.sn+" of level "+R.level+". This chunk will not be buffered."),this.resetLiveStartWhenNotLoaded(R.level);return}var M=P.frag,F=P.part,w=P.level,C=p.video,B=p.text,k=p.id3,N=p.initSegment,W=this.altAudio?void 0:p.audio;if(!this.fragContextChanged(M)){if(this.state=y.State.PARSING,N){N.tracks&&(this._bufferInitSegment(w,N.tracks,M,R),E.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:l,tracks:N.tracks}));var j=N.initPTS,K=N.timescale;Object(b.isFiniteNumber)(j)&&(this.initPTS[M.cc]=j,E.trigger(I.Events.INIT_PTS_FOUND,{frag:M,id:l,initPTS:j,timescale:K}))}if(C&&p.independent!==!1){if(w.details){var V=C.startPTS,Y=C.endPTS,Q=C.startDTS,z=C.endDTS;if(F)F.elementaryStreams[C.type]={startPTS:V,endPTS:Y,startDTS:Q,endDTS:z};else if(C.firstKeyFrame&&C.independent&&(this.couldBacktrack=!0),C.dropped&&C.independent){var re=this.getLoadPosition()+this.config.maxBufferHole;if(re<V){this.backtrack(M);return}M.setElementaryStreamInfo(C.type,M.start,Y,M.start,z,!0)}M.setElementaryStreamInfo(C.type,V,Y,Q,z),this.bufferFragmentData(C,M,F,R)}}else if(p.independent===!1){this.backtrack(M);return}if(W){var X=W.startPTS,J=W.endPTS,se=W.startDTS,ne=W.endDTS;F&&(F.elementaryStreams[g.ElementaryStreamTypes.AUDIO]={startPTS:X,endPTS:J,startDTS:se,endDTS:ne}),M.setElementaryStreamInfo(g.ElementaryStreamTypes.AUDIO,X,J,se,ne),this.bufferFragmentData(W,M,F,R)}if(k!=null&&(o=k.samples)!==null&&o!==void 0&&o.length){var pe={frag:M,id:l,samples:k.samples};E.trigger(I.Events.FRAG_PARSING_METADATA,pe)}if(B){var ee={frag:M,id:l,samples:B.samples};E.trigger(I.Events.FRAG_PARSING_USERDATA,ee)}}},c._bufferInitSegment=function(f,o,l,E){var p=this;if(this.state===y.State.PARSING){this.audioOnly=!!o.audio&&!o.video,this.altAudio&&!this.audioOnly&&delete o.audio;var R=o.audio,P=o.video,M=o.audiovideo;if(R){var F=f.audioCodec,w=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(F&&(F.indexOf("mp4a.40.5")!==-1?F="mp4a.40.2":F="mp4a.40.5"),R.metadata.channelCount!==1&&w.indexOf("firefox")===-1&&(F="mp4a.40.5")),w.indexOf("android")!==-1&&R.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+'"'),R.levelCodec=F,R.id="main",this.log("Init audio buffer, container:"+R.container+", codecs[selected/level/parsed]=["+(F||"")+"/"+(f.audioCodec||"")+"/"+R.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,o),Object.keys(o).forEach(function(C){var B=o[C],k=B.initSegment;k!=null&&k.byteLength&&p.hls.trigger(I.Events.BUFFER_APPENDING,{type:C,data:k,frag:l,part:null,chunkMeta:E,parent:l.type})}),this.tick()}},c.backtrack=function(f){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(f);var o=this.fragmentTracker.backtrack(f);this.fragPrevious=null,this.nextLoadPosition=f.start,o?this.resetFragmentLoading(f):this.state=y.State.BACKTRACKING},c.checkFragmentChanged=function(){var f=this.media,o=null;if(f&&f.readyState>1&&f.seeking===!1){var l=f.currentTime;if(S.BufferHelper.isBuffered(f,l)?o=this.getAppendedFrag(l):S.BufferHelper.isBuffered(f,l+.1)&&(o=this.getAppendedFrag(l+.1)),o){var E=this.fragPlaying,p=o.level;(!E||o.sn!==E.sn||E.level!==p||o.urlId!==E.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:o}),(!E||E.level!==p)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:p}),this.fragPlaying=o)}}},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 o=this.getAppendedFrag(f.currentTime);if(o)return o.level}return-1}},{key:"nextBufferedFrag",get:function(){var f=this.media;if(f){var o=this.getAppendedFrag(f.currentTime);return this.followingBufferedFrag(o)}else return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),h}(y.default)},"./src/controller/subtitle-stream-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"SubtitleStreamController",function(){return e});var b=d("./src/events.ts"),y=d("./src/utils/buffer-helper.ts"),T=d("./src/controller/fragment-finders.ts"),I=d("./src/utils/discontinuities.ts"),S=d("./src/controller/level-helper.ts"),O=d("./src/controller/fragment-tracker.ts"),A=d("./src/controller/base-stream-controller.ts"),g=d("./src/types/loader.ts"),_=d("./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 x(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,m(i,t)}function m(i,t){return m=Object.setPrototypeOf||function(a,n){return a.__proto__=n,a},m(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(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.on(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.on(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.on(b.Events.ERROR,this.onError,this),n.on(b.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.on(b.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.on(b.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.on(b.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.on(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r._unregisterListeners=function(){var n=this.hls;n.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),n.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),n.off(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),n.off(b.Events.LEVEL_LOADED,this.onLevelLoaded,this),n.off(b.Events.ERROR,this.onError,this),n.off(b.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),n.off(b.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),n.off(b.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),n.off(b.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),n.off(b.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},r.startLoad=function(){this.stopLoad(),this.state=A.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 c=h.frag,u=h.success;if(this.fragPrevious=c,this.state=A.State.IDLE,!!u){var f=this.tracksBuffered[this.currentTrackId];if(!!f){for(var o,l=c.start,E=0;E<f.length;E++)if(l>=f[E].start&&l<=f[E].end){o=f[E];break}var p=c.start+c.duration;o?o.end=p:(o={start:l,end:p},f.push(o)),this.fragmentTracker.fragBuffered(c)}}},r.onBufferFlushing=function(n,h){var c=h.startOffset,u=h.endOffset;if(c===0&&u!==Number.POSITIVE_INFINITY){var f=this.currentTrackId,o=this.levels;if(!o.length||!o[f]||!o[f].details)return;var l=o[f].details,E=l.targetduration,p=u-E;if(p<=0)return;h.endOffsetSubtitles=Math.max(0,p),this.tracksBuffered.forEach(function(R){for(var P=0;P<R.length;){if(R[P].end<=p){R.shift();continue}else if(R[P].start<p)R[P].start=p;else break;P++}}),this.fragmentTracker.removeFragmentsInRange(c,p,g.PlaylistLevelType.SUBTITLE)}},r.onError=function(n,h){var c,u=h.frag;!u||u.type!==g.PlaylistLevelType.SUBTITLE||((c=this.fragCurrent)!==null&&c!==void 0&&c.loader&&this.fragCurrent.loader.abort(),this.state=A.State.IDLE)},r.onSubtitleTracksUpdated=function(n,h){var c=this,u=h.subtitleTracks;this.tracksBuffered=[],this.levels=u.map(function(f){return new _.Level(f)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(f){c.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 c=this.levels[this.currentTrackId];c!=null&&c.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,c&&this.setInterval(s)},r.onSubtitleTrackLoaded=function(n,h){var c,u=h.details,f=h.id,o=this.currentTrackId,l=this.levels;if(!!l.length){var E=l[o];if(!(f>=l.length||f!==o||!E)){if(this.mediaBuffer=this.mediaBufferTimeRanges,u.live||(c=E.details)!==null&&c!==void 0&&c.live){var p=this.mainDetails;if(u.deltaUpdateFailed||!p)return;var R=p.fragments[0];if(!E.details)u.hasProgramDateTime&&p.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(u,p):R&&Object(S.addSliding)(u,R.start);else{var P=this.alignPlaylists(u,E.details);P===0&&R&&Object(S.addSliding)(u,R.start)}}if(E.details=u,this.levelLastLoaded=f,this.tick(),u.live&&!this.fragCurrent&&this.media&&this.state===A.State.IDLE){var M=Object(T.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,c=n.payload,u=h.decryptdata,f=this.hls;if(!this.fragContextChanged(h)&&c&&c.byteLength>0&&u&&u.key&&u.iv&&u.method==="AES-128"){var o=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(c),u.key.buffer,u.iv.buffer).then(function(l){var E=performance.now();f.trigger(b.Events.FRAG_DECRYPTED,{frag:h,payload:l,stats:{tstart:o,tdecrypt:E}})})}},r.doTick=function(){if(!this.media){this.state=A.State.IDLE;return}if(this.state===A.State.IDLE){var n,h=this.currentTrackId,c=this.levels;if(!c.length||!c[h]||!c[h].details)return;var u=c[h].details,f=u.targetduration,o=this.config,l=this.media,E=y.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,l.currentTime-f,o.maxBufferHole),p=E.end,R=E.len,P=this.getMaxBufferLength()+f;if(R>P)return;console.assert(u,"Subtitle track details are defined on idle subtitle stream controller tick");var M=u.fragments,F=M.length,w=u.edge,C,B=this.fragPrevious;if(p<w){var k=o.maxFragLookUpTolerance;C=Object(T.findFragmentByPTS)(B,M,p,k),!C&&B&&B.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)===O.FragmentState.NOT_LOADED&&this.loadFragment(C,u,p)}},r.loadFragment=function(n,h,c){this.fragCurrent=n,i.prototype.loadFragment.call(this,n,h,c)},x(t,[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}]),t}(A.default)},"./src/controller/subtitle-track-controller.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/events.ts"),y=d("./src/utils/texttrack-utils.ts"),T=d("./src/controller/base-playlist-controller.ts"),I=d("./src/types/loader.ts");function S(x,v){for(var m=0;m<v.length;m++){var s=v[m];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,v,m){return v&&S(x.prototype,v),m&&S(x,m),x}function A(x,v){x.prototype=Object.create(v.prototype),x.prototype.constructor=x,g(x,v)}function g(x,v){return g=Object.setPrototypeOf||function(s,e){return s.__proto__=e,s},g(x,v)}var _=function(x){A(v,x);function v(s){var e;return e=x.call(this,s,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e.subtitleDisplay=!0,e.registerListeners(),e}var m=v.prototype;return m.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,x.prototype.destroy.call(this)},m.registerListeners=function(){var e=this.hls;e.on(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(b.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(b.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(b.Events.ERROR,this.onError,this)},m.unregisterListeners=function(){var e=this.hls;e.off(b.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(b.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(b.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(b.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(b.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(b.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(b.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(b.Events.ERROR,this.onError,this)},m.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))},m.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},m.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}},m.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},m.onManifestParsed=function(e,i){this.tracks=i.subtitleTracks},m.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))},m.onLevelLoading=function(e,i){this.switchLevel(i.level)},m.onLevelSwitching=function(e,i){this.switchLevel(i.level)},m.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(c){return!t||c.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(b.Events.SUBTITLE_TRACKS_UPDATED,h),n!==-1&&this.setSubtitleTrack(n,r)}}},m.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},m.onError=function(e,i){x.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)},m.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(b.Events.SUBTITLE_TRACK_LOADING,{url:a,id:t,groupId:r,deliveryDirectives:e||null})}},m.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 c=h[a];c&&(c.mode="disabled")}var u=h[e];u&&(u.mode=r?"showing":"hidden")}},m.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,c=h===void 0?"":h,u=a.name,f=a.type,o=a.url;this.hls.trigger(b.Events.SUBTITLE_TRACK_SWITCH,{id:n,groupId:c,name:u,type:f,url:o});var l=this.switchParams(a.url,i==null?void 0:i.details);this.loadPlaylist(l)}else this.hls.trigger(b.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},m.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)}},O(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}(T.default);function L(x){for(var v=[],m=0;m<x.length;m++){var s=x[m];s.kind==="subtitles"&&s.label&&v.push(x[m])}return v}D.default=_},"./src/controller/timeline-controller.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"TimelineController",function(){return L});var b=d("./src/polyfills/number.ts"),y=d("./src/events.ts"),T=d("./src/utils/cea-608-parser.ts"),I=d("./src/utils/output-filter.ts"),S=d("./src/utils/webvtt-parser.ts"),O=d("./src/utils/texttrack-utils.ts"),A=d("./src/utils/imsc1-ttml-parser.ts"),g=d("./src/types/loader.ts"),_=d("./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=m(),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 T.default(1,t,r),this.cea608Parser2=new T.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 c=!1,u=h.length;u--;){var f=h[u],o=v(f[0],f[1],r,a);if(o>=0&&(f[0]=Math.min(f[0],r),f[1]=Math.max(f[1],a),c=!0,o/(a-r)>.5))return}if(c||h.push([r,a]),this.config.renderTextTracksNatively){var l=this.captionsTracks[t];this.Cues.newCue(l,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,c=r.initPTS,u=r.timescale,f=this.unparsedVttFrags;h==="main"&&(this.initPTS[n.cc]=c,this.timescale[n.cc]=u),f.length&&(this.unparsedVttFrags=[],f.forEach(function(o){a.onFragLoaded(y.Events.FRAG_LOADED,o)}))},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],c=h.label,u=h.languageCode,f=this.getExistingTrack(t);if(f)a[t]=f,Object(O.clearCurrentCues)(a[t]),Object(O.sendAddTrackEvent)(a[t],n);else{var o=this.createTextTrack("captions",c,u);o&&(o[t]=!0,a[t]=o)}}},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(O.clearCurrentCues)(t[r]),delete t[r]}),this.nonNativeCaptionsTracks={}},e.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=m(),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(O.clearCurrentCues)(r[a])}},e.onSubtitleTracksUpdated=function(t,r){var a=this;this.textTracks=[];var n=r.subtitleTracks||[],h=n.some(function(o){return o.textCodec===A.IMSC1_CODEC});if(this.config.enableWebVTT||h&&this.config.enableIMSC1){var c=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(o,l){var E;if(l<u.length){for(var p=null,R=0;R<u.length;R++)if(x(u[R],o)){p=u[R];break}p&&(E=p)}E?Object(O.clearCurrentCues)(E):(E=a.createTextTrack("subtitles",o.name,o.lang),E&&(E.mode="disabled")),E&&(E.groupId=o.groupId,a.textTracks.push(E))})}else if(!c&&this.tracks&&this.tracks.length){var f=this.tracks.map(function(o){return{label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}});this.hls.trigger(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 c="textTrack"+h[1],u=a.captionsProperties[c];!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,c=this.lastPartIndex;if(!(!this.enabled||!(a&&n))&&r.frag.type===g.PlaylistLevelType.MAIN){var u,f,o=r.frag.sn,l=(u=r==null||(f=r.part)===null||f===void 0?void 0:f.index)!=null?u:-1;o===h+1||o===h&&l===c+1||(a.reset(),n.reset()),this.lastSn=o,this.lastPartIndex=l}},e.onFragLoaded=function(t,r){var a=r.frag,n=r.payload,h=this.initPTS,c=this.unparsedVttFrags;if(a.type===g.PlaylistLevelType.SUBTITLE)if(n.byteLength){if(!Object(b.isFiniteNumber)(h[a.cc])){c.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 o=this.tracks[a.level],l=this.vttCCs;l[a.cc]||(l[a.cc]={start:a.start,prevCC:this.prevCC,new:!0},this.prevCC=a.cc),o&&o.textCodec===A.IMSC1_CODEC?this._parseIMSC1(a,n):this._parseVTTs(a,n,l)}}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(A.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){_.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(S.parseWebVTT)(r,this.initPTS[t.cc],this.timescale[t.cc],a,t.cc,t.start,function(c){n._appendCues(c,t.level),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},function(c){n._fallbackToIMSC1(t,r),_.logger.log("Failed to parse VTT cue: "+c),h.trigger(y.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:c})})},e._fallbackToIMSC1=function(t,r){var a=this,n=this.tracks[t.level];n.textCodec||Object(A.parseIMSC1)(r,this.initPTS[t.cc],this.timescale[t.cc],function(){n.textCodec=A.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(O.addCueToTrack)(n,u)})}else{var h=this.tracks[r],c=h.default?"default":"subtitles"+r;a.trigger(y.Events.CUES_PARSED,{type:"subtitles",cues:t,track:c})}},e.onFragDecrypted=function(t,r){var a=r.frag;if(a.type===g.PlaylistLevelType.SUBTITLE){if(!Object(b.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 c=r.samples[h].bytes;if(c){var u=this.extractCea608Data(c);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,c=r.type,u=this.media;if(!(!u||u.currentTime<n)){if(!c||c==="video"){var f=this.captionsTracks;Object.keys(f).forEach(function(l){return Object(O.removeCuesInRange)(f[l],a,n)})}if(this.config.renderTextTracksNatively&&a===0&&h!==void 0){var o=this.textTracks;Object.keys(o).forEach(function(l){return Object(O.removeCuesInRange)(o[l],a,h)})}}},e.extractCea608Data=function(t){for(var r=t[0]&31,a=2,n=[[],[]],h=0;h<r;h++){var c=t[a++],u=127&t[a++],f=127&t[a++],o=(4&c)!=0,l=3&c;u===0&&f===0||o&&(l===0||l===1)&&(n[l].push(u),n[l].push(f))}return n},s}();function x(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 m(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}}}},"./src/crypt/aes-crypto.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return b});var b=function(){function y(I,S){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=S}var T=y.prototype;return T.decrypt=function(S,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,S)},y}()},"./src/crypt/aes-decryptor.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"removePadding",function(){return y}),d.d(D,"default",function(){return T});var b=d("./src/utils/typed-array.ts");function y(I){var S=I.byteLength,O=S&&new DataView(I.buffer).getUint8(S-1);return O?Object(b.sliceUint8)(I,0,S-O):I}var T=function(){function I(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var S=I.prototype;return S.uint8ArrayToUint32Array_=function(A){for(var g=new DataView(A),_=new Uint32Array(4),L=0;L<4;L++)_[L]=g.getUint32(L*4);return _},S.initTable=function(){var A=this.sBox,g=this.invSBox,_=this.subMix,L=_[0],x=_[1],v=_[2],m=_[3],s=this.invSubMix,e=s[0],i=s[1],t=s[2],r=s[3],a=new Uint32Array(256),n=0,h=0,c=0;for(c=0;c<256;c++)c<128?a[c]=c<<1:a[c]=c<<1^283;for(c=0;c<256;c++){var u=h^h<<1^h<<2^h<<3^h<<4;u=u>>>8^u&255^99,A[n]=u,g[u]=n;var f=a[n],o=a[f],l=a[o],E=a[u]*257^u*16843008;L[n]=E<<24|E>>>8,x[n]=E<<16|E>>>16,v[n]=E<<8|E>>>24,m[n]=E,E=l*16843009^o*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[l^f]]],h^=a[a[h]]):n=h=1}},S.expandKey=function(A){for(var g=this.uint8ArrayToUint32Array_(A),_=!0,L=0;L<g.length&&_;)_=g[L]===this.key[L],L++;if(!_){this.key=g;var x=this.keySize=g.length;if(x!==4&&x!==6&&x!==8)throw new Error("Invalid aes key size="+x);var v=this.ksRows=(x+6+1)*4,m,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],c=a[2],u=a[3],f,o;for(m=0;m<v;m++){if(m<x){f=e[m]=g[m];continue}o=f,m%x==0?(o=o<<8|o>>>24,o=t[o>>>24]<<24|t[o>>>16&255]<<16|t[o>>>8&255]<<8|t[o&255],o^=r[m/x|0]<<24):x>6&&m%x==4&&(o=t[o>>>24]<<24|t[o>>>16&255]<<16|t[o>>>8&255]<<8|t[o&255]),e[m]=f=(e[m-x]^o)>>>0}for(s=0;s<v;s++)m=v-s,s&3?o=e[m]:o=e[m-4],s<4||m<=4?i[s]=o:i[s]=n[t[o>>>24]]^h[t[o>>>16&255]]^c[t[o>>>8&255]]^u[t[o&255]],i[s]=i[s]>>>0}},S.networkToHostOrderSwap=function(A){return A<<24|(A&65280)<<8|(A&16711680)>>8|A>>>24},S.decrypt=function(A,g,_){for(var L=this.keySize+6,x=this.invKeySchedule,v=this.invSBox,m=this.invSubMix,s=m[0],e=m[1],i=m[2],t=m[3],r=this.uint8ArrayToUint32Array_(_),a=r[0],n=r[1],h=r[2],c=r[3],u=new Int32Array(A),f=new Int32Array(u.length),o,l,E,p,R,P,M,F,w,C,B,k,N,W,j=this.networkToHostOrderSwap;g<u.length;){for(w=j(u[g]),C=j(u[g+1]),B=j(u[g+2]),k=j(u[g+3]),R=w^x[0],P=k^x[1],M=B^x[2],F=C^x[3],N=4,W=1;W<L;W++)o=s[R>>>24]^e[P>>16&255]^i[M>>8&255]^t[F&255]^x[N],l=s[P>>>24]^e[M>>16&255]^i[F>>8&255]^t[R&255]^x[N+1],E=s[M>>>24]^e[F>>16&255]^i[R>>8&255]^t[P&255]^x[N+2],p=s[F>>>24]^e[R>>16&255]^i[P>>8&255]^t[M&255]^x[N+3],R=o,P=l,M=E,F=p,N=N+4;o=v[R>>>24]<<24^v[P>>16&255]<<16^v[M>>8&255]<<8^v[F&255]^x[N],l=v[P>>>24]<<24^v[M>>16&255]<<16^v[F>>8&255]<<8^v[R&255]^x[N+1],E=v[M>>>24]<<24^v[F>>16&255]<<16^v[R>>8&255]<<8^v[P&255]^x[N+2],p=v[F>>>24]<<24^v[R>>16&255]<<16^v[P>>8&255]<<8^v[M&255]^x[N+3],f[g]=j(o^a),f[g+1]=j(p^n),f[g+2]=j(E^h),f[g+3]=j(l^c),a=w,n=C,h=B,c=k,g=g+4}return f.buffer},I}()},"./src/crypt/decrypter.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return g});var b=d("./src/crypt/aes-crypto.ts"),y=d("./src/crypt/fast-aes-key.ts"),T=d("./src/crypt/aes-decryptor.ts"),I=d("./src/utils/logger.ts"),S=d("./src/utils/mp4-tools.ts"),O=d("./src/utils/typed-array.ts"),A=16,g=function(){function _(x,v,m){var s=m===void 0?{}:m,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=x,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=_.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 m=new Uint8Array(v);return this.reset(),this.removePKCS7Padding?Object(T.removePadding)(m):m},L.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},L.decrypt=function(v,m,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(v),m,s);var i=this.flush();i&&e(i.buffer)}else this.webCryptoDecrypt(new Uint8Array(v),m,s).then(e)},L.softwareDecrypt=function(v,m,s){var e=this.currentIV,i=this.currentResult,t=this.remainderData;this.logOnce("JS AES decrypt"),t&&(v=Object(S.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 T.default),a.expandKey(m);var n=i;return this.currentResult=a.decrypt(r.buffer,0,s),this.currentIV=Object(O.sliceUint8)(r,-16).buffer,n||null},L.webCryptoDecrypt=function(v,m,s){var e=this,i=this.subtle;return(this.key!==m||!this.fastAesKey)&&(this.key=m,this.fastAesKey=new y.default(i,m)),this.fastAesKey.expandKey().then(function(t){if(!i)return Promise.reject(new Error("web crypto not initialized"));var r=new b.default(i,s);return r.decrypt(v.buffer,t)}).catch(function(t){return e.onWebCryptoError(t,v,m,s)})},L.onWebCryptoError=function(v,m,s,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",v),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(m,s,e)},L.getValidChunk=function(v){var m=v,s=v.length-v.length%A;return s!==v.length&&(m=Object(O.sliceUint8)(v,0,s),this.remainderData=Object(O.sliceUint8)(v,s)),m},L.logOnce=function(v){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+v),this.logEnabled=!1)},_}()},"./src/crypt/fast-aes-key.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return b});var b=function(){function y(I,S){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=S}var T=y.prototype;return T.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},y}()},"./src/demux/aacdemuxer.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/demux/base-audio-demuxer.ts"),y=d("./src/demux/adts.ts"),T=d("./src/utils/logger.ts"),I=d("./src/demux/id3.ts");function S(g,_){g.prototype=Object.create(_.prototype),g.prototype.constructor=g,O(g,_)}function O(g,_){return O=Object.setPrototypeOf||function(x,v){return x.__proto__=v,x},O(g,_)}var A=function(g){S(_,g);function _(x,v){var m;return m=g.call(this)||this,m.observer=void 0,m.config=void 0,m.observer=x,m.config=v,m}var L=_.prototype;return L.resetInitSegment=function(v,m,s){g.prototype.resetInitSegment.call(this,v,m,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}},_.probe=function(v){if(!v)return!1;for(var m=I.getID3Data(v,0)||[],s=m.length,e=v.length;s<e;s++)if(y.probe(v,s))return T.logger.log("ADTS sync word found !"),!0;return!1},L.canParse=function(v,m){return y.canParse(v,m)},L.appendFrame=function(v,m,s){y.initTrackConfig(v,this.observer,m,s,v.manifestCodec);var e=y.appendFrame(v,m,s,this.initPTS,this.frameIndex);if(e&&e.missing===0)return e},_}(b.default);A.minProbeByteLength=9,D.default=A},"./src/demux/adts.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"getAudioConfig",function(){return I}),d.d(D,"isHeaderPattern",function(){return S}),d.d(D,"getHeaderLength",function(){return O}),d.d(D,"getFullFrameLength",function(){return A}),d.d(D,"canGetFrameLength",function(){return g}),d.d(D,"isHeader",function(){return _}),d.d(D,"canParse",function(){return L}),d.d(D,"probe",function(){return x}),d.d(D,"initTrackConfig",function(){return v}),d.d(D,"getFrameDuration",function(){return m}),d.d(D,"parseFrameHeader",function(){return s}),d.d(D,"appendFrame",function(){return e});var b=d("./src/utils/logger.ts"),y=d("./src/errors.ts"),T=d("./src/events.ts");function I(i,t,r,a){var n,h,c,u,f=navigator.userAgent.toLowerCase(),o=a,l=[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>l.length-1){i.trigger(T.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+E});return}return c=(t[r+2]&1)<<2,c|=(t[r+3]&192)>>>6,b.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&&c===1||/vivaldi/i.test(f))||!a&&c===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]|=c<<3,n===5&&(u[1]|=(h&14)>>1,u[2]=(h&1)<<7,u[2]|=2<<2,u[3]=0),{config:u,samplerate:l[E],channelCount:c,codec:"mp4a.40."+n,manifestCodec:o}}function S(i,t){return i[t]===255&&(i[t+1]&246)==240}function O(i,t){return i[t+1]&1?7:9}function A(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 _(i,t){return t+1<i.length&&S(i,t)}function L(i,t){return g(i,t)&&S(i,t)&&A(i,t)<=i.length-t}function x(i,t){if(_(i,t)){var r=O(i,t);if(t+r>=i.length)return!1;var a=A(i,t);if(a<=r)return!1;var n=t+a;return n===i.length||_(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,b.logger.log("parsed codec:"+i.codec+", rate:"+h.samplerate+", channels:"+h.channelCount)}}function m(i){return 1024*9e4/i}function s(i,t,r,a,n){var h=O(i,t),c=A(i,t);if(c-=h,c>0){var u=r+a*n;return{headerLength:h,frameLength:c,stamp:u}}}function e(i,t,r,a,n){var h=m(i.samplerate),c=s(t,r,a,n,h);if(c){var u=c.frameLength,f=c.headerLength,o=c.stamp,l=f+u,E=Math.max(0,r+l-t.length),p;E?(p=new Uint8Array(l-f),p.set(t.subarray(r+f,t.length),0)):p=t.subarray(r+f,r+l);var R={unit:p,pts:o};return E||i.samples.push(R),{sample:R,length:l,missing:E}}}},"./src/demux/base-audio-demuxer.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"initPTSFn",function(){return A});var b=d("./src/polyfills/number.ts"),y=d("./src/demux/id3.ts"),T=d("./src/demux/dummy-demuxed-track.ts"),I=d("./src/utils/mp4-tools.ts"),S=d("./src/utils/typed-array.ts"),O=function(){function g(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var _=g.prototype;return _.resetInitSegment=function(x,v,m){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},_.resetTimeStamp=function(){},_.resetContiguity=function(){},_.canParse=function(x,v){return!1},_.appendFrame=function(x,v,m){},_.demux=function(x,v){this.cachedData&&(x=Object(I.appendUint8Array)(this.cachedData,x),this.cachedData=null);var m=y.getID3Data(x,0),s=m?m.length:0,e,i,t=this._audioTrack,r=this._id3Track,a=m?y.getTimeStamp(m):void 0,n=x.length;for((this.frameIndex===0||this.initPTS===null)&&(this.initPTS=A(a,v)),m&&m.length>0&&r.samples.push({pts:this.initPTS,dts:this.initPTS,data:m}),i=this.initPTS;s<n;){if(this.canParse(x,s)){var h=this.appendFrame(t,x,s);h?(this.frameIndex++,i=h.sample.pts,s+=h.length,e=s):s=n}else y.canParse(x,s)?(m=y.getID3Data(x,s),r.samples.push({pts:i,dts:i,data:m}),s+=m.length,e=s):s++;if(s===n&&e!==n){var c=Object(S.sliceUint8)(x,e);this.cachedData?this.cachedData=Object(I.appendUint8Array)(this.cachedData,c):this.cachedData=c}}return{audioTrack:t,avcTrack:Object(T.dummyTrack)(),id3Track:r,textTrack:Object(T.dummyTrack)()}},_.demuxSampleAes=function(x,v,m){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},_.flush=function(x){var v=this.cachedData;return v&&(this.cachedData=null,this.demux(v,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(T.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(T.dummyTrack)()}},_.destroy=function(){},g}(),A=function(_,L){return Object(b.isFiniteNumber)(_)?_*90:L*9e4};D.default=O},"./src/demux/chunk-cache.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return b});var b=function(){function T(){this.chunks=[],this.dataLength=0}var I=T.prototype;return I.push=function(O){this.chunks.push(O),this.dataLength+=O.length},I.flush=function(){var O=this.chunks,A=this.dataLength,g;if(O.length)O.length===1?g=O[0]:g=y(O,A);else return new Uint8Array(0);return this.reset(),g},I.reset=function(){this.chunks.length=0,this.dataLength=0},T}();function y(T,I){for(var S=new Uint8Array(I),O=0,A=0;A<T.length;A++){var g=T[A];S.set(g,O),O+=g.length}return S}},"./src/demux/dummy-demuxed-track.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"dummyTrack",function(){return b});function b(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/utils/logger.ts"),y=function(){function T(S){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=S,this.bytesAvailable=S.byteLength,this.word=0,this.bitsAvailable=0}var I=T.prototype;return I.loadWord=function(){var O=this.data,A=this.bytesAvailable,g=O.byteLength-A,_=new Uint8Array(4),L=Math.min(4,A);if(L===0)throw new Error("no bytes available");_.set(O.subarray(g,g+L)),this.word=new DataView(_.buffer).getUint32(0),this.bitsAvailable=L*8,this.bytesAvailable-=L},I.skipBits=function(O){var A;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,A=O>>3,O-=A>>3,this.bytesAvailable-=A,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},I.readBits=function(O){var A=Math.min(this.bitsAvailable,O),g=this.word>>>32-A;return O>32&&b.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=A,this.bitsAvailable>0?this.word<<=A:this.bytesAvailable>0&&this.loadWord(),A=O-A,A>0&&this.bitsAvailable?g<<A|this.readBits(A):g},I.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!=0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},I.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(O){for(var A=8,g=8,_,L=0;L<O;L++)g!==0&&(_=this.readEG(),g=(A+_+256)%256),A=g===0?A:g},I.readSPS=function(){var O=0,A=0,g=0,_=0,L,x,v,m=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);m();var h=m();if(s(5),t(3),m(),a(),h===100||h===110||h===122||h===244||h===44||h===83||h===86||h===118||h===128){var c=e();if(c===3&&t(1),a(),a(),t(1),i())for(x=c!==3?8:12,v=0;v<x;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(),o=e(),l=s(1);l===0&&t(1),t(1),i()&&(O=e(),A=e(),g=e(),_=e());var E=[1,1];if(i()&&i()){var p=m();switch(p){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=[m()<<8|m(),m()<<8|m()];break}}}return{width:Math.ceil((f+1)*16-O*2-A*2),height:(2-l)*(o+1)*16-(l?2:4)*(g+_),pixelRatio:E}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},T}();D.default=y},"./src/demux/id3.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"isHeader",function(){return b}),d.d(D,"isFooter",function(){return y}),d.d(D,"getID3Data",function(){return T}),d.d(D,"canParse",function(){return S}),d.d(D,"getTimeStamp",function(){return O}),d.d(D,"isTimeStampFrame",function(){return A}),d.d(D,"getID3Frames",function(){return _}),d.d(D,"decodeFrame",function(){return L}),d.d(D,"utf8ArrayToStr",function(){return e}),d.d(D,"testables",function(){return i});var b=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},T=function(n,h){for(var c=h,u=0;b(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(c,c+u)},I=function(n,h){var c=0;return c=(n[h]&127)<<21,c|=(n[h+1]&127)<<14,c|=(n[h+2]&127)<<7,c|=n[h+3]&127,c},S=function(n,h){return b(n,h)&&I(n,h+6)+10<=n.length-h},O=function(n){for(var h=_(n),c=0;c<h.length;c++){var u=h[c];if(A(u))return s(u)}},A=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]),c=I(n,4),u=10;return{type:h,size:c,data:n.subarray(u,u+c)}},_=function(n){for(var h=0,c=[];b(n,h);){var u=I(n,h+6);h+=10;for(var f=h+u;h+8<f;){var o=g(n.subarray(h)),l=L(o);l&&c.push(l),h+=o.size+10}y(n,h)&&(h+=10)}return c},L=function(n){return n.type==="PRIV"?x(n):n.type[0]==="W"?m(n):v(n)},x=function(n){if(!(n.size<2)){var h=e(n.data,!0),c=new Uint8Array(n.data.subarray(h.length+1));return{key:n.type,info:h,data:c.buffer}}},v=function(n){if(!(n.size<2)){if(n.type==="TXXX"){var h=1,c=e(n.data.subarray(h),!0);h+=c.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:c,data:u}}var f=e(n.data.subarray(1));return{key:n.type,data:f}}},m=function(n){if(n.type==="WXXX"){if(n.size<2)return;var h=1,c=e(n.data.subarray(h),!0);h+=c.length+1;var u=e(n.data.subarray(h));return{key:n.type,info:c,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),c=h[3]&1,u=(h[4]<<23)+(h[5]<<15)+(h[6]<<7)+h[7];return u/=45,c&&(u+=4772185884e-2),Math.round(u)}},e=function(n,h){h===void 0&&(h=!1);var c=r();if(c){var u=c.decode(n);if(h){var f=u.indexOf("\0");return f!==-1?u.substring(0,f):u}return u.replace(/\0/g,"")}for(var o=n.length,l,E,p,R="",P=0;P<o;){if(l=n[P++],l===0&&h)return R;if(l===0||l===3)continue;switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:R+=String.fromCharCode(l);break;case 12:case 13:E=n[P++],R+=String.fromCharCode((l&31)<<6|E&63);break;case 14:E=n[P++],p=n[P++],R+=String.fromCharCode((l&15)<<12|(E&63)<<6|(p&63)<<0);break;default:}}return R},i={decodeTextFrame:v},t;function r(){return!t&&typeof self.TextDecoder!="undefined"&&(t=new self.TextDecoder("utf-8")),t}},"./src/demux/mp3demuxer.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/demux/base-audio-demuxer.ts"),y=d("./src/demux/id3.ts"),T=d("./src/utils/logger.ts"),I=d("./src/demux/mpegaudio.ts");function S(g,_){g.prototype=Object.create(_.prototype),g.prototype.constructor=g,O(g,_)}function O(g,_){return O=Object.setPrototypeOf||function(x,v){return x.__proto__=v,x},O(g,_)}var A=function(g){S(_,g);function _(){return g.apply(this,arguments)||this}var L=_.prototype;return L.resetInitSegment=function(v,m,s){g.prototype.resetInitSegment.call(this,v,m,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}},_.probe=function(v){if(!v)return!1;for(var m=y.getID3Data(v,0)||[],s=m.length,e=v.length;s<e;s++)if(I.probe(v,s))return T.logger.log("MPEG Audio sync word found !"),!0;return!1},L.canParse=function(v,m){return I.canParse(v,m)},L.appendFrame=function(v,m,s){if(this.initPTS!==null)return I.appendFrame(v,m,s,this.initPTS,this.frameIndex)},_}(b.default);A.minProbeByteLength=4,D.default=A},"./src/demux/mp4demuxer.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/utils/mp4-tools.ts"),y=d("./src/demux/dummy-demuxed-track.ts"),T=function(){function I(O,A){this.remainderData=null,this.config=void 0,this.config=A}var S=I.prototype;return S.resetTimeStamp=function(){},S.resetInitSegment=function(){},S.resetContiguity=function(){},I.probe=function(A){return Object(b.findBox)({data:A,start:0,end:Math.min(A.length,16384)},["moof"]).length>0},S.demux=function(A){var g=A,_=Object(y.dummyTrack)();if(this.config.progressive){this.remainderData&&(g=Object(b.appendUint8Array)(this.remainderData,A));var L=Object(b.segmentValidRange)(g);this.remainderData=L.remainder,_.samples=L.valid||new Uint8Array}else _.samples=g;return{audioTrack:Object(y.dummyTrack)(),avcTrack:_,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},S.flush=function(){var A=Object(y.dummyTrack)();return A.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(y.dummyTrack)(),avcTrack:A,id3Track:Object(y.dummyTrack)(),textTrack:Object(y.dummyTrack)()}},S.demuxSampleAes=function(A,g,_){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},S.destroy=function(){},I}();T.minProbeByteLength=1024,D.default=T},"./src/demux/mpegaudio.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"appendFrame",function(){return O}),d.d(D,"parseHeader",function(){return A}),d.d(D,"isHeaderPattern",function(){return g}),d.d(D,"isHeader",function(){return _}),d.d(D,"canParse",function(){return L}),d.d(D,"probe",function(){return x});var b=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],T=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],S=[0,1,1,4];function O(v,m,s,e,i){if(!(s+24>m.length)){var t=A(m,s);if(t&&s+t.frameLength<=m.length){var r=t.samplesPerFrame*9e4/t.sampleRate,a=e+i*r,n={unit:m.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 A(v,m){var s=v[m+1]>>3&3,e=v[m+1]>>1&3,i=v[m+2]>>4&15,t=v[m+2]>>2&3;if(s!==1&&i!==0&&i!==15&&t!==3){var r=v[m+2]>>1&1,a=v[m+3]>>6,n=s===3?3-e:e===3?3:4,h=y[n*14+i-1]*1e3,c=s===3?0:s===2?1:2,u=T[c*3+t],f=a===3?1:2,o=I[s][e],l=S[e],E=o*8*l,p=Math.floor(o*h/u+r)*l;if(b===null){var R=navigator.userAgent||"",P=R.match(/Chrome\/(\d+)/i);b=P?parseInt(P[1]):0}var M=!!b&&b<=87;return M&&e===2&&h>=224e3&&a===0&&(v[m+3]=v[m+3]|128),{sampleRate:u,channelCount:f,frameLength:p,samplesPerFrame:E}}}function g(v,m){return v[m]===255&&(v[m+1]&224)==224&&(v[m+1]&6)!=0}function _(v,m){return m+1<v.length&&g(v,m)}function L(v,m){var s=4;return g(v,m)&&s<=v.length-m}function x(v,m){if(m+1<v.length&&g(v,m)){var s=4,e=A(v,m),i=s;e!=null&&e.frameLength&&(i=e.frameLength);var t=m+i;return t===v.length||_(v,t)}return!1}},"./src/demux/sample-aes.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/crypt/decrypter.ts"),y=d("./src/demux/tsdemuxer.ts"),T=function(){function I(O,A,g){this.keyData=void 0,this.decrypter=void 0,this.keyData=g,this.decrypter=new b.default(O,A,{removePKCS7Padding:!1})}var S=I.prototype;return S.decryptBuffer=function(A,g){this.decrypter.decrypt(A,this.keyData.key.buffer,this.keyData.iv.buffer,g)},S.decryptAacSample=function(A,g,_,L){var x=A[g].unit,v=x.subarray(16,x.length-x.length%16),m=v.buffer.slice(v.byteOffset,v.byteOffset+v.length),s=this;this.decryptBuffer(m,function(e){var i=new Uint8Array(e);x.set(i,16),L||s.decryptAacSamples(A,g+1,_)})},S.decryptAacSamples=function(A,g,_){for(;;g++){if(g>=A.length){_();return}if(!(A[g].unit.length<32)){var L=this.decrypter.isSync();if(this.decryptAacSample(A,g,_,L),!L)return}}},S.getAvcEncryptedData=function(A){for(var g=Math.floor((A.length-48)/160)*16+16,_=new Int8Array(g),L=0,x=32;x<A.length-16;x+=160,L+=16)_.set(A.subarray(x,x+16),L);return _},S.getAvcDecryptedUnit=function(A,g){for(var _=new Uint8Array(g),L=0,x=32;x<A.length-16;x+=160,L+=16)A.set(_.subarray(L,L+16),x);return A},S.decryptAvcSample=function(A,g,_,L,x,v){var m=Object(y.discardEPB)(x.data),s=this.getAvcEncryptedData(m),e=this;this.decryptBuffer(s.buffer,function(i){x.data=e.getAvcDecryptedUnit(m,i),v||e.decryptAvcSamples(A,g,_+1,L)})},S.decryptAvcSamples=function(A,g,_,L){if(A instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;g++,_=0){if(g>=A.length){L();return}for(var x=A[g].units;!(_>=x.length);_++){var v=x[_];if(!(v.data.length<=48||v.type!==1&&v.type!==5)){var m=this.decrypter.isSync();if(this.decryptAvcSample(A,g,_,L,v,m),!m)return}}}},I}();D.default=T},"./src/demux/transmuxer-interface.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return x});var b=d("./node_modules/webworkify-webpack/index.js"),y=d.n(b),T=d("./src/events.ts"),I=d("./src/demux/transmuxer.ts"),S=d("./src/utils/logger.ts"),O=d("./src/errors.ts"),A=d("./src/utils/mediasource-helper.ts"),g=d("./node_modules/eventemitter3/index.js"),_=d.n(g),L=Object(A.getMediaSource)()||{isTypeSupported:function(){return!1}},x=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(o,l){l=l||{},l.frag=r.frag,l.id=r.id,s.trigger(o,l)};this.observer=new g.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,n),this.observer.on(T.Events.ERROR,n);var h={mp4:L.isTypeSupported("video/mp4"),mpeg:L.isTypeSupported("audio/mpeg"),mp3:L.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(a.enableWorker&&typeof Worker!="undefined"){S.logger.log("demuxing in webworker");var u;try{u=this.worker=b("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),u.addEventListener("message",this.onwmsg),u.onerror=function(f){s.trigger(T.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(f.message+" ("+f.filename+":"+f.lineno+")")})},u.postMessage({cmd:"init",typeSupported:h,vendor:c,id:e,config:JSON.stringify(a)})}catch(f){S.logger.warn("Error in worker:",f),S.logger.error("Error while initializing DemuxerWorker, fallback to inline"),u&&self.URL.revokeObjectURL(u.objectURL),this.transmuxer=new I.default(this.observer,h,a,c,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,h,a,c,e)}var m=v.prototype;return m.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},m.push=function(e,i,t,r,a,n,h,c,u,f){var o,l,E=this;u.transmuxing.start=self.performance.now();var p=this.transmuxer,R=this.worker,P=n?n.start:a.start,M=a.decryptdata,F=this.frag,w=!(F&&a.cc===F.cc),C=!(F&&u.level===F.level),B=F?u.sn-F.sn:-1,k=this.part?u.part-this.part.index:1,N=!C&&(B===1||B===0&&k===1),W=self.performance.now();(C||B||a.stats.parsing.start===0)&&(a.stats.parsing.start=W),n&&(k||!N)&&(n.stats.parsing.start=W);var j=!(F&&((o=a.initSegment)===null||o===void 0?void 0:o.url)===((l=F.initSegment)===null||l===void 0?void 0:l.url)),K=new I.TransmuxState(w,N,c,C,P,j);if(!N||w||j){S.logger.log("[transmuxer-interface, "+a.type+"]: Starting new transmux session for sn: "+u.sn+" p: "+u.part+" level: "+u.level+" id: "+u.id+`
|
|
11
|
+
Time to underbuffer: `+M.toFixed(3)+" s"),o.nextLoadLevel=w,this.bwEstimator.sample(c,t.loaded),this.clearTimer(),s.loader&&(this.fragCurrent=this.partCurrent=null,s.loader.abort()),o.trigger(T.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:e,stats:t})}}}}}},g.onFragLoaded=function(s,e){var o=e.frag,f=e.part;if(o.type===O.PlaylistLevelType.MAIN&&Object(R.isFiniteNumber)(o.sn)){var a=f?f.stats:o.stats,i=f?f.duration:o.duration;if(this.clearTimer(),this.lastLoadedFragLevel=o.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var t=this.hls.levels[o.level],u=(t.loaded?t.loaded.bytes:0)+a.loaded,c=(t.loaded?t.loaded.duration:0)+i;t.loaded={bytes:u,duration:c},t.realBitrate=Math.round(8*u/c)}if(o.bitrateTest){var r={stats:a,frag:o,part:f,id:o.type};this.onFragBuffered(T.Events.FRAG_BUFFERED,r)}}},g.onFragBuffered=function(s,e){var o=e.frag,f=e.part,a=f?f.stats:o.stats;if(!a.aborted&&!(o.type!==O.PlaylistLevelType.MAIN||o.sn==="initSegment")){var i=a.parsing.end-a.loading.start;this.bwEstimator.sample(i,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),o.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0}},g.onError=function(s,e){switch(e.details){case S.ErrorDetails.FRAG_LOAD_ERROR:case S.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer();break;default:break}},g.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},g.getNextABRAutoLevel=function(){var s=this.fragCurrent,e=this.partCurrent,o=this.hls,f=o.maxAutoLevel,a=o.config,i=o.minAutoLevel,t=o.media,u=e?e.duration:s?s.duration:0,c=t?t.currentTime:0,r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,h=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,d=(I.BufferHelper.bufferInfo(t,c,a.maxBufferHole).end-c)/r,l=this.findBestLevel(h,i,f,d,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(l>=0)return l;_.logger.trace((d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var v=u?Math.min(u,a.maxStarvationDelay):a.maxStarvationDelay,m=a.abrBandWidthFactor,L=a.abrBandWidthUpFactor;if(!d){var b=this.bitrateTestDelay;if(b){var M=u?Math.min(u,a.maxLoadingDelay):a.maxLoadingDelay;v=M-b,_.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*v)+" ms"),m=L=1}}return l=this.findBestLevel(h,i,f,d+v,m,L),Math.max(l,0)},g.findBestLevel=function(s,e,o,f,a,i){for(var t,u=this.fragCurrent,c=this.partCurrent,r=this.lastLoadedFragLevel,h=this.hls.levels,d=h[r],l=!!(d!=null&&(t=d.details)!==null&&t!==void 0&&t.live),v=d==null?void 0:d.codecSet,m=c?c.duration:u?u.duration:0,L=o;L>=e;L--){var b=h[L];if(!(!b||v&&b.codecSet!==v)){var M=b.details,F=(c?M==null?void 0:M.partTarget:M==null?void 0:M.averagetargetduration)||m,w=void 0;L<=r?w=a*s:w=i*s;var C=h[L].maxBitrate,U=C*F/w;if(_.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+L+"/"+Math.round(w)+"/"+C+"/"+F+"/"+f+"/"+U),w>C&&(!U||l&&!this.bitrateTestDelay||U<f))return L}}return-1},A(x,[{key:"nextAutoLevel",get:function(){var s=this._nextAutoLevel,e=this.bwEstimator;if(s!==-1&&!e.canEstimate())return s;var o=this.getNextABRAutoLevel();return s!==-1&&this.hls.levels[o].loadError?s:(s!==-1&&(o=Math.min(s,o)),o)},set:function(s){this._nextAutoLevel=s}}]),x}();P.default=D},"./src/controller/audio-stream-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/controller/base-stream-controller.ts"),T=n("./src/events.ts"),I=n("./src/utils/buffer-helper.ts"),S=n("./src/controller/fragment-tracker.ts"),O=n("./src/types/level.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/chunk-cache.ts"),D=n("./src/demux/transmuxer-interface.ts"),x=n("./src/types/transmuxer.ts"),g=n("./src/controller/fragment-finders.ts"),y=n("./src/utils/discontinuities.ts"),s=n("./src/errors.ts");function e(){return e=Object.assign?Object.assign.bind():function(t){for(var u=1;u<arguments.length;u++){var c=arguments[u];for(var r in c)Object.prototype.hasOwnProperty.call(c,r)&&(t[r]=c[r])}return t},e.apply(this,arguments)}function o(t,u){t.prototype=Object.create(u.prototype),t.prototype.constructor=t,f(t,u)}function f(t,u){return f=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,h){return r.__proto__=h,r},f(t,u)}var a=100,i=function(t){o(u,t);function u(r,h){var d;return d=t.call(this,r,h,"[audio-stream-controller]")||this,d.videoBuffer=null,d.videoTrackCC=-1,d.waitingVideoCC=-1,d.audioSwitch=!1,d.trackId=-1,d.waitingData=null,d.mainDetails=null,d.bufferFlushed=!1,d.cachedTrackLoadedData=null,d._registerListeners(),d}var c=u.prototype;return c.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},c._registerListeners=function(){var h=this.hls;h.on(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.on(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.on(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.on(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.on(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.on(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.on(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.on(T.Events.ERROR,this.onError,this),h.on(T.Events.BUFFER_RESET,this.onBufferReset,this),h.on(T.Events.BUFFER_CREATED,this.onBufferCreated,this),h.on(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.on(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.on(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c._unregisterListeners=function(){var h=this.hls;h.off(T.Events.MEDIA_ATTACHED,this.onMediaAttached,this),h.off(T.Events.MEDIA_DETACHING,this.onMediaDetaching,this),h.off(T.Events.MANIFEST_LOADING,this.onManifestLoading,this),h.off(T.Events.LEVEL_LOADED,this.onLevelLoaded,this),h.off(T.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),h.off(T.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),h.off(T.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),h.off(T.Events.ERROR,this.onError,this),h.off(T.Events.BUFFER_RESET,this.onBufferReset,this),h.off(T.Events.BUFFER_CREATED,this.onBufferCreated,this),h.off(T.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),h.off(T.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),h.off(T.Events.FRAG_BUFFERED,this.onFragBuffered,this)},c.onInitPtsFound=function(h,d){var l=d.frag,v=d.id,m=d.initPTS;if(v==="main"){var L=l.cc;this.initPTS[l.cc]=m,this.log("InitPTS for cc: "+L+" found from main: "+m),this.videoTrackCC=L,this.state===p.State.WAITING_INIT_PTS&&this.tick()}},c.startLoad=function(h){if(!this.levels){this.startPosition=h,this.state=p.State.STOPPED;return}var d=this.lastCurrentTime;this.stopLoad(),this.setInterval(a),this.fragLoadError=0,d>0&&h===-1?(this.log("Override startPosition with lastCurrentTime @"+d.toFixed(3)),h=d,this.state=p.State.IDLE):(this.loadedmetadata=!1,this.state=p.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=h,this.tick()},c.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_TRACK:{var h,d=this.levels,l=this.trackId,v=d==null||(h=d[l])===null||h===void 0?void 0:h.details;if(v){if(this.waitForCdnTuneIn(v))break;this.state=p.State.WAITING_INIT_PTS}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var m,L=performance.now(),b=this.retryDate;(!b||L>=b||(m=this.media)!==null&&m!==void 0&&m.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=p.State.IDLE);break}case p.State.WAITING_INIT_PTS:{var M=this.waitingData;if(M){var F=M.frag,w=M.part,C=M.cache,U=M.complete;if(this.initPTS[F.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.FRAG_LOADING;var k=C.flush(),j={frag:F,part:w,payload:k,networkDetails:null};this._handleFragmentLoadProgress(j),U&&t.prototype._handleFragmentLoadComplete.call(this,j)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+F.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var N=this.getLoadPosition(),W=I.BufferHelper.bufferInfo(this.mediaBuffer,N,this.config.maxBufferHole),Y=Object(g.fragmentWithinToleranceTest)(W.end,this.config.maxFragLookUpTolerance,F);Y<0&&(this.log("Waiting fragment cc ("+F.cc+") @ "+F.start+" cancelled because another fragment at "+W.end+" is needed"),this.clearWaitingFragment())}}else this.state=p.State.IDLE}}this.onTickEnd()},c.clearWaitingFragment=function(){var h=this.waitingData;h&&(this.fragmentTracker.removeFragment(h.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=p.State.IDLE)},c.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},c.onTickEnd=function(){var h=this.media;if(!(!h||!h.readyState)){var d=this.mediaBuffer?this.mediaBuffer:h,l=d.buffered;!this.loadedmetadata&&l.length&&(this.loadedmetadata=!0),this.lastCurrentTime=h.currentTime}},c.doTickIdle=function(){var h,d,l=this.hls,v=this.levels,m=this.media,L=this.trackId,b=l.config;if(!(!v||!v[L])&&!(!m&&(this.startFragRequested||!b.startFragPrefetch))){var M=v[L],F=M.details;if(!F||F.live&&this.levelLastLoaded!==L||this.waitForCdnTuneIn(F)){this.state=p.State.WAITING_TRACK;return}var w=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&w&&(this.bufferFlushed=!1,this.afterBufferFlushed(w,E.ElementaryStreamTypes.AUDIO,_.PlaylistLevelType.AUDIO));var C=this.getFwdBufferInfo(w,_.PlaylistLevelType.AUDIO);if(C!==null){var U=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,_.PlaylistLevelType.MAIN),k=C.len,j=this.getMaxBufferLength(U==null?void 0:U.len),N=this.audioSwitch;if(!(k>=j&&!N)){if(!N&&this._streamEnded(C,F)){l.trigger(T.Events.BUFFER_EOS,{type:"audio"}),this.state=p.State.ENDED;return}var W=F.fragments,Y=W[0].start,K=C.end;if(N&&m){var H=this.getLoadPosition();K=H,F.PTSKnown&&H<Y&&(C.end>Y||C.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),m.currentTime=Y+.05)}if(!(U&&K>U.end+F.targetduration)&&!((!U||!U.len)&&C.len)){var z=this.getNextFragment(K,F);if(!z){this.bufferFlushed=!0;return}((h=z.decryptdata)===null||h===void 0?void 0:h.keyFormat)==="identity"&&!((d=z.decryptdata)!==null&&d!==void 0&&d.key)?this.loadKey(z,F):this.loadFragment(z,F,K)}}}}},c.getMaxBufferLength=function(h){var d=t.prototype.getMaxBufferLength.call(this);return h?Math.max(d,h):d},c.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},c.onAudioTracksUpdated=function(h,d){var l=d.audioTracks;this.resetTransmuxer(),this.levels=l.map(function(v){return new O.Level(v)})},c.onAudioTrackSwitching=function(h,d){var l=!!d.url;this.trackId=d.id;var v=this.fragCurrent;v!=null&&v.loader&&v.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),l?this.setInterval(a):this.resetTransmuxer(),l?(this.audioSwitch=!0,this.state=p.State.IDLE):this.state=p.State.STOPPED,this.tick()},c.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},c.onLevelLoaded=function(h,d){this.mainDetails=d.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(T.Events.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)},c.onAudioTrackLoaded=function(h,d){var l;if(this.mainDetails==null){this.cachedTrackLoadedData=d;return}var v=this.levels,m=d.details,L=d.id;if(!v){this.warn("Audio tracks were reset while loading level "+L);return}this.log("Track "+L+" loaded ["+m.startSN+","+m.endSN+"],duration:"+m.totalduration);var b=v[L],M=0;if(m.live||(l=b.details)!==null&&l!==void 0&&l.live){var F=this.mainDetails;if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed||!F)return;!b.details&&m.hasProgramDateTime&&F.hasProgramDateTime?(Object(y.alignMediaPlaylistByPDT)(m,F),M=m.fragments[0].start):M=this.alignPlaylists(m,b.details)}b.details=m,this.levelLastLoaded=L,!this.startFragRequested&&(this.mainDetails||!m.live)&&this.setStartPosition(b.details,M),this.state===p.State.WAITING_TRACK&&!this.waitForCdnTuneIn(m)&&(this.state=p.State.IDLE),this.tick()},c._handleFragmentLoadProgress=function(h){var d,l=h.frag,v=h.part,m=h.payload,L=this.config,b=this.trackId,M=this.levels;if(!M){this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+l.sn+" of level "+l.level+" will not be buffered");return}var F=M[b];console.assert(F,"Audio track is defined on fragment load progress");var w=F.details;console.assert(w,"Audio track details are defined on fragment load progress");var C=L.defaultAudioCodec||F.audioCodec||"mp4a.40.2",U=this.transmuxer;U||(U=this.transmuxer=new D.default(this.hls,_.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var k=this.initPTS[l.cc],j=(d=l.initSegment)===null||d===void 0?void 0:d.data;if(k!==void 0){var N=!1,W=v?v.index:-1,Y=W!==-1,K=new x.ChunkMetadata(l.level,l.sn,l.stats.chunkCount,m.byteLength,W,Y);U.push(m,j,C,"",l,v,w.totalduration,N,K,k)}else{this.log("Unknown video PTS for cc "+l.cc+", waiting for video PTS before demuxing audio frag "+l.sn+" of ["+w.startSN+" ,"+w.endSN+"],track "+b);var H=this.waitingData=this.waitingData||{frag:l,part:v,cache:new A.default,complete:!1},z=H.cache;z.push(new Uint8Array(m)),this.waitingVideoCC=this.videoTrackCC,this.state=p.State.WAITING_INIT_PTS}},c._handleFragmentLoadComplete=function(h){if(this.waitingData){this.waitingData.complete=!0;return}t.prototype._handleFragmentLoadComplete.call(this,h)},c.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},c.onBufferCreated=function(h,d){var l=d.tracks.audio;l&&(this.mediaBuffer=l.buffer||null),d.tracks.video&&(this.videoBuffer=d.tracks.video.buffer||null)},c.onFragBuffered=function(h,d){var l=d.frag,v=d.part;if(l.type===_.PlaylistLevelType.AUDIO){if(this.fragContextChanged(l)){this.warn("Fragment "+l.sn+(v?" p: "+v.index:"")+" of level "+l.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch);return}l.sn!=="initSegment"&&(this.fragPrevious=l,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(T.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(l,v)}},c.onError=function(h,d){switch(d.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.AUDIO,d);break;case s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==p.State.ERROR&&this.state!==p.State.STOPPED&&(this.state=d.fatal?p.State.ERROR:p.State.IDLE,this.warn(d.details+" while loading frag, switching to "+this.state+" state"));break;case s.ErrorDetails.BUFFER_FULL_ERROR:if(d.parent==="audio"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var l=!0,v=this.getFwdBufferInfo(this.mediaBuffer,_.PlaylistLevelType.AUDIO);v&&v.len>.5&&(l=!this.reduceMaxBufferLength(v.len)),l&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}break;default:break}},c.onBufferFlushed=function(h,d){var l=d.type;l===E.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},c._handleTransmuxComplete=function(h){var d,l="audio",v=this.hls,m=h.remuxResult,L=h.chunkMeta,b=this.getCurrentContext(L);if(!b){this.warn("The loading context changed while buffering fragment "+L.sn+" of level "+L.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(L.level);return}var M=b.frag,F=b.part,w=b.level.details,C=m.audio,U=m.text,k=m.id3,j=m.initSegment;if(!(this.fragContextChanged(M)||!w)){if(this.state=p.State.PARSING,this.audioSwitch&&C&&this.completeAudioSwitch(),j!=null&&j.tracks&&(this._bufferInitSegment(j.tracks,M,L),v.trigger(T.Events.FRAG_PARSING_INIT_SEGMENT,{frag:M,id:l,tracks:j.tracks})),C){var N=C.startPTS,W=C.endPTS,Y=C.startDTS,K=C.endDTS;F&&(F.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:N,endPTS:W,startDTS:Y,endDTS:K}),M.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,N,W,Y,K),this.bufferFragmentData(C,M,F,L)}if(k!=null&&(d=k.samples)!==null&&d!==void 0&&d.length){var H=e({id:l,frag:M,details:w},k);v.trigger(T.Events.FRAG_PARSING_METADATA,H)}if(U){var z=e({id:l,frag:M,details:w},U);v.trigger(T.Events.FRAG_PARSING_USERDATA,z)}}},c._bufferInitSegment=function(h,d,l){if(this.state===p.State.PARSING){h.video&&delete h.video;var v=h.audio;if(!!v){v.levelCodec=v.codec,v.id="audio",this.log("Init audio buffer, container:"+v.container+", codecs[parsed]=["+v.codec+"]"),this.hls.trigger(T.Events.BUFFER_CODECS,h);var m=v.initSegment;if(m!=null&&m.byteLength){var L={type:"audio",frag:d,part:null,chunkMeta:l,parent:d.type,data:m};this.hls.trigger(T.Events.BUFFER_APPENDING,L)}this.tick()}}},c.loadFragment=function(h,d,l){var v=this.fragmentTracker.getState(h);this.fragCurrent=h,(this.audioSwitch||v===S.FragmentState.NOT_LOADED||v===S.FragmentState.PARTIAL)&&(h.sn==="initSegment"?this._loadInitSegment(h):d.live&&!Object(R.isFiniteNumber)(this.initPTS[h.cc])?(this.log("Waiting for video PTS in continuity counter "+h.cc+" of live stream before loading audio fragment "+h.sn+" of level "+this.trackId),this.state=p.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,h,d,l)))},c.completeAudioSwitch=function(){var h=this.hls,d=this.media,l=this.trackId;d&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,h.trigger(T.Events.AUDIO_TRACK_SWITCHED,{id:l})},u}(p.default);P.default=i},"./src/controller/audio-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function S(D,x){for(var g=0;g<x.length;g++){var y=x[g];y.enumerable=y.enumerable||!1,y.configurable=!0,"value"in y&&(y.writable=!0),Object.defineProperty(D,y.key,y)}}function O(D,x,g){return x&&S(D.prototype,x),g&&S(D,g),Object.defineProperty(D,"prototype",{writable:!1}),D}function _(D,x){D.prototype=Object.create(x.prototype),D.prototype.constructor=D,E(D,x)}function E(D,x){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,s){return y.__proto__=s,y},E(D,x)}var A=function(D){_(x,D);function x(y){var s;return s=D.call(this,y,"[audio-track-controller]")||this,s.tracks=[],s.groupId=null,s.tracksInGroup=[],s.trackId=-1,s.trackName="",s.selectDefaultTrack=!0,s.registerListeners(),s}var g=x.prototype;return g.registerListeners=function(){var s=this.hls;s.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.on(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.on(R.Events.ERROR,this.onError,this)},g.unregisterListeners=function(){var s=this.hls;s.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),s.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),s.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),s.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),s.off(R.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),s.off(R.Events.ERROR,this.onError,this)},g.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,D.prototype.destroy.call(this)},g.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},g.onManifestParsed=function(s,e){this.tracks=e.audioTracks||[]},g.onAudioTrackLoaded=function(s,e){var o=e.id,f=e.details,a=this.tracksInGroup[o];if(!a){this.warn("Invalid audio track id "+o);return}var i=a.details;a.details=e.details,this.log("audioTrack "+o+" loaded ["+f.startSN+"-"+f.endSN+"]"),o===this.trackId&&(this.retryCount=0,this.playlistLoaded(o,e,i))},g.onLevelLoading=function(s,e){this.switchLevel(e.level)},g.onLevelSwitching=function(s,e){this.switchLevel(e.level)},g.switchLevel=function(s){var e=this.hls.levels[s];if(!!(e!=null&&e.audioGroupIds)){var o=e.audioGroupIds[e.urlId];if(this.groupId!==o){this.groupId=o;var f=this.tracks.filter(function(i){return!o||i.groupId===o});this.selectDefaultTrack&&!f.some(function(i){return i.default})&&(this.selectDefaultTrack=!1),this.tracksInGroup=f;var a={audioTracks:f};this.log("Updating audio tracks, "+f.length+' track(s) found in "'+o+'" group-id'),this.hls.trigger(R.Events.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}}},g.onError=function(s,e){D.prototype.onError.call(this,s,e),!(e.fatal||!e.context)&&e.context.type===I.PlaylistContextType.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.retryLoadingOrFail(e)},g.setAudioTrack=function(s){var e=this.tracksInGroup;if(s<0||s>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();var o=e[this.trackId];this.log("Now switching to audio-track index "+s);var f=e[s],a=f.id,i=f.groupId,t=i===void 0?"":i,u=f.name,c=f.type,r=f.url;if(this.trackId=s,this.trackName=u,this.selectDefaultTrack=!1,this.hls.trigger(R.Events.AUDIO_TRACK_SWITCHING,{id:a,groupId:t,name:u,type:c,url:r}),!(f.details&&!f.details.live)){var h=this.switchParams(f.url,o==null?void 0:o.details);this.loadPlaylist(h)}},g.selectInitialTrack=function(){var s=this.tracksInGroup;console.assert(s.length,"Initial audio track should be selected when tracks are known");var e=this.trackName,o=this.findTrackId(e)||this.findTrackId();o!==-1?this.setAudioTrack(o):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},g.findTrackId=function(s){for(var e=this.tracksInGroup,o=0;o<e.length;o++){var f=e[o];if((!this.selectDefaultTrack||f.default)&&(!s||s===f.name))return f.id}return-1},g.loadPlaylist=function(s){var e=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(e)){var o=e.id,f=e.groupId,a=e.url;if(s)try{a=s.addDirectives(a)}catch(i){this.warn("Could not construct new URL with HLS Delivery Directives: "+i)}this.log("loading audio-track playlist for id: "+o),this.clearTimer(),this.hls.trigger(R.Events.AUDIO_TRACK_LOADING,{url:a,id:o,groupId:f,deliveryDirectives:s||null})}},O(x,[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(s){this.selectDefaultTrack=!1,this.setAudioTrack(s)}}]),x}(T.default);P.default=A},"./src/controller/base-playlist-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/polyfills/number.ts"),p=n("./src/types/level.ts"),T=n("./src/controller/level-helper.ts"),I=n("./src/utils/logger.ts"),S=n("./src/errors.ts"),O=function(){function _(A,D){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=I.logger.log.bind(I.logger,D+":"),this.warn=I.logger.warn.bind(I.logger,D+":"),this.hls=A}var E=_.prototype;return E.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},E.onError=function(D,x){x.fatal&&x.type===S.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},E.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},E.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},E.stopLoad=function(){this.canLoad=!1,this.clearTimer()},E.switchParams=function(D,x){var g=x==null?void 0:x.renditionReports;if(g)for(var y=0;y<g.length;y++){var s=g[y],e=""+s.URI;if(e===D.slice(-e.length)){var o=parseInt(s["LAST-MSN"]),f=parseInt(s["LAST-PART"]);if(x&&this.hls.config.lowLatencyMode){var a=Math.min(x.age-x.partTarget,x.targetduration);f!==void 0&&a>x.partTarget&&(f+=1)}if(Object(R.isFiniteNumber)(o))return new p.HlsUrlParameters(o,Object(R.isFiniteNumber)(f)?f:void 0,p.HlsSkip.No)}}},E.loadPlaylist=function(D){},E.shouldLoadTrack=function(D){return this.canLoad&&D&&!!D.url&&(!D.details||D.details.live)},E.playlistLoaded=function(D,x,g){var y=this,s=x.details,e=x.stats,o=e.loading.end?Math.max(0,self.performance.now()-e.loading.end):0;if(s.advancedDateTime=Date.now()-o,s.live||g!=null&&g.live){if(s.reloaded(g),g&&this.log("live playlist "+D+" "+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:"MISSED")),g&&s.fragments.length>0&&Object(T.mergeDetails)(g,s),!this.canLoad||!s.live)return;var f,a=void 0,i=void 0;if(s.canBlockReload&&s.endSN&&s.advanced){var t=this.hls.config.lowLatencyMode,u=s.lastPartSn,c=s.endSN,r=s.lastPartIndex,h=r!==-1,d=u===c,l=t?0:r;h?(a=d?c+1:u,i=d?l:r+1):a=c+1;var v=s.age,m=v+s.ageHeader,L=Math.min(m-s.partTarget,s.targetduration*1.5);if(L>0){if(g&&L>g.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+g.tuneInGoal+" to: "+L+" with playlist age: "+s.age),L=0;else{var b=Math.floor(L/s.targetduration);if(a+=b,i!==void 0){var M=Math.round(L%s.targetduration/s.partTarget);i+=M}this.log("CDN Tune-in age: "+s.ageHeader+"s last advanced "+v.toFixed(2)+"s goal: "+L+" skip sn "+b+" to part "+i)}s.tuneInGoal=L}if(f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i),t||!d){this.loadPlaylist(f);return}}else f=this.getDeliveryDirectives(s,x.deliveryDirectives,a,i);var F=Object(T.computeReloadInterval)(s,e);a!==void 0&&s.canBlockReload&&(F-=s.partTarget||1),this.log("reload live playlist "+D+" in "+Math.round(F)+" ms"),this.timer=self.setTimeout(function(){return y.loadPlaylist(f)},F)}else this.clearTimer()},E.getDeliveryDirectives=function(D,x,g,y){var s=Object(p.getSkipValue)(D,g);return x!=null&&x.skip&&D.deltaUpdateFailed&&(g=x.msn,y=x.part,s=p.HlsSkip.No),new p.HlsUrlParameters(g,y,s)},E.retryLoadingOrFail=function(D){var x=this,g=this.hls.config,y=this.retryCount<g.levelLoadingMaxRetry;if(y){var s;if(this.retryCount++,D.details.indexOf("LoadTimeOut")>-1&&(s=D.context)!==null&&s!==void 0&&s.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+D.details+'"'),this.loadPlaylist();else{var e=Math.min(Math.pow(2,this.retryCount)*g.levelLoadingRetryDelay,g.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout(function(){return x.loadPlaylist()},e),this.warn("retry playlist loading #"+this.retryCount+" in "+e+' ms after "'+D.details+'"')}}else this.warn('cannot recover from error "'+D.details+'"'),this.clearTimer(),D.fatal=!0;return y},_}()},"./src/controller/base-stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"State",function(){return c}),n.d(P,"default",function(){return r});var R=n("./src/polyfills/number.ts"),p=n("./src/task-loop.ts"),T=n("./src/controller/fragment-tracker.ts"),I=n("./src/utils/buffer-helper.ts"),S=n("./src/utils/logger.ts"),O=n("./src/events.ts"),_=n("./src/errors.ts"),E=n("./src/types/transmuxer.ts"),A=n("./src/utils/mp4-tools.ts"),D=n("./src/utils/discontinuities.ts"),x=n("./src/controller/fragment-finders.ts"),g=n("./src/controller/level-helper.ts"),y=n("./src/loader/fragment-loader.ts"),s=n("./src/crypt/decrypter.ts"),e=n("./src/utils/time-ranges.ts"),o=n("./src/types/loader.ts");function f(h,d){for(var l=0;l<d.length;l++){var v=d[l];v.enumerable=v.enumerable||!1,v.configurable=!0,"value"in v&&(v.writable=!0),Object.defineProperty(h,v.key,v)}}function a(h,d,l){return d&&f(h.prototype,d),l&&f(h,l),Object.defineProperty(h,"prototype",{writable:!1}),h}function i(h){if(h===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return h}function t(h,d){h.prototype=Object.create(d.prototype),h.prototype.constructor=h,u(h,d)}function u(h,d){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(v,m){return v.__proto__=m,v},u(h,d)}var c={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},r=function(h){t(d,h);function d(v,m,L){var b;return b=h.call(this)||this,b.hls=void 0,b.fragPrevious=null,b.fragCurrent=null,b.fragmentTracker=void 0,b.transmuxer=null,b._state=c.STOPPED,b.media=null,b.mediaBuffer=null,b.config=void 0,b.bitrateTest=!1,b.lastCurrentTime=0,b.nextLoadPosition=0,b.startPosition=0,b.loadedmetadata=!1,b.fragLoadError=0,b.retryDate=0,b.levels=null,b.fragmentLoader=void 0,b.levelLastLoaded=null,b.startFragRequested=!1,b.decrypter=void 0,b.initPTS=[],b.onvseeking=null,b.onvended=null,b.logPrefix="",b.log=void 0,b.warn=void 0,b.logPrefix=L,b.log=S.logger.log.bind(S.logger,L+":"),b.warn=S.logger.warn.bind(S.logger,L+":"),b.hls=v,b.fragmentLoader=new y.default(v.config),b.fragmentTracker=m,b.config=v.config,b.decrypter=new s.default(v,v.config),v.on(O.Events.KEY_LOADED,b.onKeyLoaded,i(b)),v.on(O.Events.LEVEL_SWITCHING,b.onLevelSwitching,i(b)),b}var l=d.prototype;return l.doTick=function(){this.onTickEnd()},l.onTickEnd=function(){},l.startLoad=function(m){},l.stopLoad=function(){this.fragmentLoader.abort();var m=this.fragCurrent;m&&this.fragmentTracker.removeFragment(m),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=c.STOPPED},l._streamEnded=function(m,L){var b=this.fragCurrent,M=this.fragmentTracker;if(!L.live&&b&&this.media&&b.sn>=L.endSN&&!m.nextStart){var F=L.partList;if(F!=null&&F.length){var w=F[F.length-1],C=I.BufferHelper.isBuffered(this.media,w.start+w.duration/2);return C}var U=M.getState(b);return U===T.FragmentState.PARTIAL||U===T.FragmentState.OK}return!1},l.onMediaAttached=function(m,L){var b=this.media=this.mediaBuffer=L.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),b.addEventListener("seeking",this.onvseeking),b.addEventListener("ended",this.onvended);var M=this.config;this.levels&&M.autoStartLoad&&this.state===c.STOPPED&&this.startLoad(M.startPosition)},l.onMediaDetaching=function(){var m=this.media;m!=null&&m.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),m&&this.onvseeking&&this.onvended&&(m.removeEventListener("seeking",this.onvseeking),m.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},l.onMediaSeeking=function(){var m=this.config,L=this.fragCurrent,b=this.media,M=this.mediaBuffer,F=this.state,w=b?b.currentTime:0,C=I.BufferHelper.bufferInfo(M||b,w,m.maxBufferHole);if(this.log("media seeking to "+(Object(R.isFiniteNumber)(w)?w.toFixed(3):w)+", state: "+F),F===c.ENDED)this.resetLoadingState();else if(L&&!C.len){var U=m.maxFragLookUpTolerance,k=L.start-U,j=L.start+L.duration+U,N=w>j;(w<k||N)&&(N&&L.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),L.loader.abort()),this.resetLoadingState())}b&&(this.lastCurrentTime=w),!this.loadedmetadata&&!C.len&&(this.nextLoadPosition=this.startPosition=w),this.tickImmediate()},l.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},l.onKeyLoaded=function(m,L){if(!(this.state!==c.KEY_LOADING||L.frag!==this.fragCurrent||!this.levels)){this.state=c.IDLE;var b=this.levels[L.frag.level].details;b&&this.loadFragment(L.frag,b,L.frag.start)}},l.onLevelSwitching=function(m,L){this.fragLoadError=0},l.onHandlerDestroying=function(){this.stopLoad(),h.prototype.onHandlerDestroying.call(this)},l.onHandlerDestroyed=function(){this.state=c.STOPPED,this.hls.off(O.Events.KEY_LOADED,this.onKeyLoaded,this),this.hls.off(O.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,h.prototype.onHandlerDestroyed.call(this)},l.loadKey=function(m,L){this.log("Loading key for "+m.sn+" of ["+L.startSN+"-"+L.endSN+"], "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level),this.state=c.KEY_LOADING,this.fragCurrent=m,this.hls.trigger(O.Events.KEY_LOADING,{frag:m})},l.loadFragment=function(m,L,b){this._loadFragForPlayback(m,L,b)},l._loadFragForPlayback=function(m,L,b){var M=this,F=function(C){if(M.fragContextChanged(m)){M.warn("Fragment "+m.sn+(C.part?" p: "+C.part.index:"")+" of level "+m.level+" was dropped during download."),M.fragmentTracker.removeFragment(m);return}m.stats.chunkCount++,M._handleFragmentLoadProgress(C)};this._doFragLoad(m,L,b,F).then(function(w){if(!!w){M.fragLoadError=0;var C=M.state;if(M.fragContextChanged(m)){(C===c.FRAG_LOADING||!M.fragCurrent&&C===c.PARSING)&&(M.fragmentTracker.removeFragment(m),M.state=c.IDLE);return}"payload"in w&&(M.log("Loaded fragment "+m.sn+" of level "+m.level),M.hls.trigger(O.Events.FRAG_LOADED,w)),M._handleFragmentLoadComplete(w)}}).catch(function(w){M.state===c.STOPPED||M.state===c.ERROR||(M.warn(w),M.resetFragmentLoading(m))})},l.flushMainBuffer=function(m,L,b){if(b===void 0&&(b=null),!!(m-L)){var M={startOffset:m,endOffset:L,type:b};this.fragLoadError=0,this.hls.trigger(O.Events.BUFFER_FLUSHING,M)}},l._loadInitSegment=function(m){var L=this;this._doFragLoad(m).then(function(b){if(!b||L.fragContextChanged(m)||!L.levels)throw new Error("init load aborted");return b}).then(function(b){var M=L.hls,F=b.payload,w=m.decryptdata;if(F&&F.byteLength>0&&w&&w.key&&w.iv&&w.method==="AES-128"){var C=self.performance.now();return L.decrypter.webCryptoDecrypt(new Uint8Array(F),w.key.buffer,w.iv.buffer).then(function(U){var k=self.performance.now();return M.trigger(O.Events.FRAG_DECRYPTED,{frag:m,payload:U,stats:{tstart:C,tdecrypt:k}}),b.payload=U,b})}return b}).then(function(b){var M=L.fragCurrent,F=L.hls,w=L.levels;if(!w)throw new Error("init load aborted, missing levels");var C=w[m.level].details;console.assert(C,"Level details are defined when init segment is loaded");var U=m.stats;L.state=c.IDLE,L.fragLoadError=0,m.data=new Uint8Array(b.payload),U.parsing.start=U.buffering.start=self.performance.now(),U.parsing.end=U.buffering.end=self.performance.now(),b.frag===M&&F.trigger(O.Events.FRAG_BUFFERED,{stats:U,frag:M,part:null,id:m.type}),L.tick()}).catch(function(b){L.state===c.STOPPED||L.state===c.ERROR||(L.warn(b),L.resetFragmentLoading(m))})},l.fragContextChanged=function(m){var L=this.fragCurrent;return!m||!L||m.level!==L.level||m.sn!==L.sn||m.urlId!==L.urlId},l.fragBufferedComplete=function(m,L){var b=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+m.type+" sn: "+m.sn+(L?" part: "+L.index:"")+" of "+(this.logPrefix==="[stream-controller]"?"level":"track")+" "+m.level+" "+(b?e.default.toString(I.BufferHelper.getBuffered(b)):"(detached)")),this.state=c.IDLE,b&&(!this.loadedmetadata&&b.buffered.length&&this.fragCurrent===this.fragPrevious&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},l.seekToStartPos=function(){},l._handleFragmentLoadComplete=function(m){var L=this.transmuxer;if(!!L){var b=m.frag,M=m.part,F=m.partsLoaded,w=!F||F.length===0||F.some(function(U){return!U}),C=new E.ChunkMetadata(b.level,b.sn,b.stats.chunkCount+1,0,M?M.index:-1,!w);L.flush(C)}},l._handleFragmentLoadProgress=function(m){},l._doFragLoad=function(m,L,b,M){var F=this;if(b===void 0&&(b=null),!this.levels)throw new Error("frag load aborted, missing levels");if(b=Math.max(m.start,b||0),this.config.lowLatencyMode&&L){var w=L.partList;if(w&&M){b>m.end&&L.fragmentHint&&(m=L.fragmentHint);var C=this.getNextPart(w,m,b);if(C>-1){var U=w[C];return this.log("Loading part sn: "+m.sn+" p: "+U.index+" cc: "+m.cc+" of playlist ["+L.startSN+"-"+L.endSN+"] parts [0-"+C+"-"+(w.length-1)+"] "+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),this.nextLoadPosition=U.start+U.duration,this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:m,part:w[C],targetBufferTime:b}),this.doFragPartsLoad(m,w,C,M).catch(function(k){return F.handleFragLoadError(k)})}else if(!m.url||this.loadedEndOfParts(w,b))return Promise.resolve(null)}}return this.log("Loading fragment "+m.sn+" cc: "+m.cc+" "+(L?"of ["+L.startSN+"-"+L.endSN+"] ":"")+(this.logPrefix==="[stream-controller]"?"level":"track")+": "+m.level+", target: "+parseFloat(b.toFixed(3))),Object(R.isFiniteNumber)(m.sn)&&!this.bitrateTest&&(this.nextLoadPosition=m.start+m.duration),this.state=c.FRAG_LOADING,this.hls.trigger(O.Events.FRAG_LOADING,{frag:m,targetBufferTime:b}),this.fragmentLoader.load(m,M).catch(function(k){return F.handleFragLoadError(k)})},l.doFragPartsLoad=function(m,L,b,M){var F=this;return new Promise(function(w,C){var U=[],k=function j(N){var W=L[N];F.fragmentLoader.loadPart(m,W,M).then(function(Y){U[W.index]=Y;var K=Y.part;F.hls.trigger(O.Events.FRAG_LOADED,Y);var H=L[N+1];if(H&&H.fragment===m)j(N+1);else return w({frag:m,part:K,partsLoaded:U})}).catch(C)};k(b)})},l.handleFragLoadError=function(m){var L=m.data;return L&&L.details===_.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(L.frag,L.part):this.hls.trigger(O.Events.ERROR,L),null},l._handleTransmuxerFlush=function(m){var L=this.getCurrentContext(m);if(!L||this.state!==c.PARSING){this.fragCurrent||(this.state=c.IDLE);return}var b=L.frag,M=L.part,F=L.level,w=self.performance.now();b.stats.parsing.end=w,M&&(M.stats.parsing.end=w),this.updateLevelTiming(b,M,F,m.partial)},l.getCurrentContext=function(m){var L=this.levels,b=m.level,M=m.sn,F=m.part;if(!L||!L[b])return this.warn("Levels object was unset while buffering fragment "+M+" of level "+b+". The current chunk will not be buffered."),null;var w=L[b],C=F>-1?Object(g.getPartWith)(w,M,F):null,U=C?C.fragment:Object(g.getFragmentWithSN)(w,M,this.fragCurrent);return U?{frag:U,part:C,level:w}:null},l.bufferFragmentData=function(m,L,b,M){if(!(!m||this.state!==c.PARSING)){var F=m.data1,w=m.data2,C=F;if(F&&w&&(C=Object(A.appendUint8Array)(F,w)),!(!C||!C.length)){var U={type:m.type,frag:L,part:b,chunkMeta:M,parent:L.type,data:C};this.hls.trigger(O.Events.BUFFER_APPENDING,U),m.dropped&&m.independent&&!b&&this.flushBufferGap(L)}}},l.flushBufferGap=function(m){var L=this.media;if(!!L){if(!I.BufferHelper.isBuffered(L,L.currentTime)){this.flushMainBuffer(0,m.start);return}var b=L.currentTime,M=I.BufferHelper.bufferInfo(L,b,0),F=m.duration,w=Math.min(this.config.maxFragLookUpTolerance*2,F*.25),C=Math.max(Math.min(m.start-w,M.end-w),b+w);m.start-C>w&&this.flushMainBuffer(C,m.start)}},l.getFwdBufferInfo=function(m,L){var b=this.config,M=this.getLoadPosition();if(!Object(R.isFiniteNumber)(M))return null;var F=I.BufferHelper.bufferInfo(m,M,b.maxBufferHole);if(F.len===0&&F.nextStart!==void 0){var w=this.fragmentTracker.getBufferedFrag(M,L);if(w&&F.nextStart<w.end)return I.BufferHelper.bufferInfo(m,M,Math.max(F.nextStart,b.maxBufferHole))}return F},l.getMaxBufferLength=function(m){var L=this.config,b;return m?b=Math.max(8*L.maxBufferSize/m,L.maxBufferLength):b=L.maxBufferLength,Math.min(b,L.maxMaxBufferLength)},l.reduceMaxBufferLength=function(m){var L=this.config,b=m||L.maxBufferLength;return L.maxMaxBufferLength>=b?(L.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+L.maxMaxBufferLength+"s"),!0):!1},l.getNextFragment=function(m,L){var b=L.fragments,M=b.length;if(!M)return null;var F=this.config,w=b[0].start,C;if(L.live){var U=F.initialLiveManifestSize;if(M<U)return this.warn("Not enough fragments to start playback (have: "+M+", need: "+U+")"),null;!L.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(C=this.getInitialLiveFragment(L,b),this.startPosition=C?this.hls.liveSyncPosition||C.start:m)}else m<=w&&(C=b[0]);if(!C){var k=F.lowLatencyMode?L.partEnd:L.fragmentEnd;C=this.getFragmentAtPosition(m,k,L)}return this.mapToInitFragWhenRequired(C)},l.mapToInitFragWhenRequired=function(m){return m!=null&&m.initSegment&&!(m!=null&&m.initSegment.data)&&!this.bitrateTest?m.initSegment:m},l.getNextPart=function(m,L,b){for(var M=-1,F=!1,w=!0,C=0,U=m.length;C<U;C++){var k=m[C];if(w=w&&!k.independent,M>-1&&b<k.start)break;var j=k.loaded;!j&&(F||k.independent||w)&&k.fragment===L&&(M=C),F=j}return M},l.loadedEndOfParts=function(m,L){var b=m[m.length-1];return b&&L>b.start&&b.loaded},l.getInitialLiveFragment=function(m,L){var b=this.fragPrevious,M=null;if(b){if(m.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+b.programDateTime),M=Object(x.findFragmentByPDT)(L,b.endProgramDateTime,this.config.maxFragLookUpTolerance)),!M){var F=b.sn+1;if(F>=m.startSN&&F<=m.endSN){var w=L[F-m.startSN];b.cc===w.cc&&(M=w,this.log("Live playlist, switching playlist, load frag with next SN: "+M.sn))}M||(M=Object(x.findFragWithCC)(L,b.cc),M&&this.log("Live playlist, switching playlist, load frag with same CC: "+M.sn))}}else{var C=this.hls.liveSyncPosition;C!==null&&(M=this.getFragmentAtPosition(C,this.bitrateTest?m.fragmentEnd:m.edge,m))}return M},l.getFragmentAtPosition=function(m,L,b){var M=this.config,F=this.fragPrevious,w=b.fragments,C=b.endSN,U=b.fragmentHint,k=M.maxFragLookUpTolerance,j=!!(M.lowLatencyMode&&b.partList&&U);j&&U&&!this.bitrateTest&&(w=w.concat(U),C=U.sn);var N;if(m<L){var W=m>L-k?0:k;N=Object(x.findFragmentByPTS)(F,w,m,W)}else N=w[w.length-1];if(N){var Y=N.sn-b.startSN;if(F&&N.sn===F.sn&&!j){var K=F&&N.level===F.level;if(K){var H=w[Y+1];N.sn<C&&this.fragmentTracker.getState(H)!==T.FragmentState.OK?(this.log("SN "+N.sn+" just loaded, load next one: "+H.sn),N=H):N=null}}}return N},l.synchronizeToLiveEdge=function(m){var L=this.config,b=this.media;if(!!b){var M=this.hls.liveSyncPosition,F=b.currentTime,w=m.fragments[0].start,C=m.edge,U=F>=w-L.maxFragLookUpTolerance&&F<=C;if(M!==null&&b.duration>M&&(F<M||!U)){var k=L.liveMaxLatencyDuration!==void 0?L.liveMaxLatencyDuration:L.liveMaxLatencyDurationCount*m.targetduration;(!U&&b.readyState<4||F<C-k)&&(this.loadedmetadata||(this.nextLoadPosition=M),b.readyState&&(this.warn("Playback: "+F.toFixed(3)+" is located too far from the end of live sliding playlist: "+C+", reset currentTime to : "+M.toFixed(3)),b.currentTime=M))}}},l.alignPlaylists=function(m,L){var b=this.levels,M=this.levelLastLoaded,F=this.fragPrevious,w=M!==null?b[M]:null,C=m.fragments.length;if(!C)return this.warn("No fragments in live playlist"),0;var U=m.fragments[0].start,k=!L,j=m.alignedSliding&&Object(R.isFiniteNumber)(U);if(k||!j&&!U){Object(D.alignStream)(F,w,m);var N=m.fragments[0].start;return this.log("Live playlist sliding: "+N.toFixed(2)+" start-sn: "+(L?L.startSN:"na")+"->"+m.startSN+" prev-sn: "+(F?F.sn:"na")+" fragments: "+C),N}return U},l.waitForCdnTuneIn=function(m){var L=3;return m.live&&m.canBlockReload&&m.partTarget&&m.tuneInGoal>Math.max(m.partHoldBack,m.partTarget*L)},l.setStartPosition=function(m,L){var b=this.startPosition;if(b<L&&(b=-1),b===-1||this.lastCurrentTime===-1){var M=m.startTimeOffset;Object(R.isFiniteNumber)(M)?(b=L+M,M<0&&(b+=m.totalduration),b=Math.min(Math.max(L,b),L+m.totalduration),this.log("Start time offset "+M+" found in playlist, adjust startPosition to "+b),this.startPosition=b):m.live?b=this.hls.liveSyncPosition||L:this.startPosition=b=0,this.lastCurrentTime=b}this.nextLoadPosition=b},l.getLoadPosition=function(){var m=this.media,L=0;return this.loadedmetadata&&m?L=m.currentTime:this.nextLoadPosition&&(L=this.nextLoadPosition),L},l.handleFragLoadAborted=function(m,L){this.transmuxer&&m.sn!=="initSegment"&&m.stats.aborted&&(this.warn("Fragment "+m.sn+(L?" part"+L.index:"")+" of level "+m.level+" was aborted"),this.resetFragmentLoading(m))},l.resetFragmentLoading=function(m){(!this.fragCurrent||!this.fragContextChanged(m)&&this.state!==c.FRAG_LOADING_WAITING_RETRY)&&(this.state=c.IDLE)},l.onFragmentOrKeyLoadError=function(m,L){if(!L.fatal){var b=L.frag;if(!(!b||b.type!==m)){var M=this.fragCurrent;console.assert(M&&b.sn===M.sn&&b.level===M.level&&b.urlId===M.urlId,"Frag load error must match current frag to retry");var F=this.config;if(this.fragLoadError+1<=F.fragLoadingMaxRetry){this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition);var w=Math.min(Math.pow(2,this.fragLoadError)*F.fragLoadingRetryDelay,F.fragLoadingMaxRetryTimeout);this.warn("Fragment "+b.sn+" of "+m+" "+b.level+" failed to load, retrying in "+w+"ms"),this.retryDate=self.performance.now()+w,this.fragLoadError++,this.state=c.FRAG_LOADING_WAITING_RETRY}else L.levelRetry?(m===o.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=c.IDLE):(S.logger.error(L.details+" reaches max retry, redispatch as fatal ..."),L.fatal=!0,this.hls.stopLoad(),this.state=c.ERROR)}}},l.afterBufferFlushed=function(m,L,b){if(!!m){var M=I.BufferHelper.getBuffered(m);this.fragmentTracker.detectEvictedFragments(L,M,b),this.state===c.ENDED&&this.resetLoadingState()}},l.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=c.IDLE},l.resetStartWhenNotLoaded=function(m){if(!this.loadedmetadata){this.startFragRequested=!1;var L=this.levels?this.levels[m].details:null;L!=null&&L.live?(this.startPosition=-1,this.setStartPosition(L,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},l.updateLevelTiming=function(m,L,b,M){var F=this,w=b.details;console.assert(!!w,"level.details must be defined");var C=Object.keys(m.elementaryStreams).reduce(function(U,k){var j=m.elementaryStreams[k];if(j){var N=j.endPTS-j.startPTS;if(N<=0)return F.warn("Could not parse fragment "+m.sn+" "+k+" duration reliably ("+N+")"),U||!1;var W=M?0:Object(g.updateFragPTSDTS)(w,m,j.startPTS,j.endPTS,j.startDTS,j.endDTS);return F.hls.trigger(O.Events.LEVEL_PTS_UPDATED,{details:w,level:b,drift:W,type:k,frag:m,start:j.startPTS,end:j.endPTS}),!0}return U},!1);C||(this.warn("Found no media in fragment "+m.sn+" of level "+b.id+" resetting transmuxer to fallback to playlist timing"),this.resetTransmuxer()),this.state=c.PARSED,this.hls.trigger(O.Events.FRAG_PARSED,{frag:m,part:L})},l.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},a(d,[{key:"state",get:function(){return this._state},set:function(m){var L=this._state;L!==m&&(this._state=m,this.log(L+"->"+m))}}]),d}(p.default)},"./src/controller/buffer-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts"),I=n("./src/errors.ts"),S=n("./src/utils/buffer-helper.ts"),O=n("./src/utils/mediasource-helper.ts"),_=n("./src/loader/fragment.ts"),E=n("./src/controller/buffer-operation-queue.ts"),A=Object(O.getMediaSource)(),D=/([ha]vc.)(?:\.[^.,]+)+/,x=function(){function g(s){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var o=e.hls,f=e.media,a=e.mediaSource;T.logger.log("[buffer-controller]: Media source opened"),f&&(e.updateMediaElementDuration(),o.trigger(p.Events.MEDIA_ATTACHED,{media:f})),a&&a.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){T.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){T.logger.log("[buffer-controller]: Media source ended")},this.hls=s,this._initSourceBuffer(),this.registerListeners()}var y=g.prototype;return y.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},y.destroy=function(){this.unregisterListeners(),this.details=null},y.registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.Events.BUFFER_RESET,this.onBufferReset,this),e.on(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.Events.BUFFER_EOS,this.onBufferEos,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.Events.FRAG_PARSED,this.onFragParsed,this),e.on(p.Events.FRAG_CHANGED,this.onFragChanged,this)},y.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.Events.BUFFER_RESET,this.onBufferReset,this),e.off(p.Events.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.Events.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.Events.BUFFER_EOS,this.onBufferEos,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.Events.FRAG_PARSED,this.onFragParsed,this),e.off(p.Events.FRAG_CHANGED,this.onFragChanged,this)},y._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new E.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},y.onManifestParsed=function(e,o){var f=2;(o.audio&&!o.video||!o.altAudio)&&(f=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=f,this.details=null,T.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},y.onMediaAttaching=function(e,o){var f=this.media=o.media;if(f&&A){var a=this.mediaSource=new A;a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),f.src=self.URL.createObjectURL(a),this._objectUrl=f.src}},y.onMediaDetaching=function(){var e=this.media,o=this.mediaSource,f=this._objectUrl;if(o){if(T.logger.log("[buffer-controller]: media source detaching"),o.readyState==="open")try{o.endOfStream()}catch(a){T.logger.warn("[buffer-controller]: onMediaDetaching: "+a.message+" while calling endOfStream")}this.onBufferReset(),o.removeEventListener("sourceopen",this._onMediaSourceOpen),o.removeEventListener("sourceended",this._onMediaSourceEnded),o.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(f&&self.URL.revokeObjectURL(f),e.src===f?(e.removeAttribute("src"),e.load()):T.logger.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.Events.MEDIA_DETACHED,void 0)},y.onBufferReset=function(){var e=this;this.getSourceBufferTypes().forEach(function(o){var f=e.sourceBuffer[o];try{f&&(e.removeBufferListeners(o),e.mediaSource&&e.mediaSource.removeSourceBuffer(f),e.sourceBuffer[o]=void 0)}catch(a){T.logger.warn("[buffer-controller]: Failed to reset the "+o+" buffer",a)}}),this._initSourceBuffer()},y.onBufferCodecs=function(e,o){var f=this,a=this.getSourceBufferTypes().length;Object.keys(o).forEach(function(i){if(a){var t=f.tracks[i];if(t&&typeof t.buffer.changeType=="function"){var u=o[i],c=u.id,r=u.codec,h=u.levelCodec,d=u.container,l=u.metadata,v=(t.levelCodec||t.codec).replace(D,"$1"),m=(h||r).replace(D,"$1");if(v!==m){var L=d+";codecs="+(h||r);f.appendChangeType(i,L),T.logger.log("[buffer-controller]: switching codec "+v+" to "+m),f.tracks[i]={buffer:t.buffer,codec:r,container:d,levelCodec:h,metadata:l,id:c}}}}else f.pendingTracks[i]=o[i]}),!a&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())},y.appendChangeType=function(e,o){var f=this,a=this.operationQueue,i={execute:function(){var u=f.sourceBuffer[e];u&&(T.logger.log("[buffer-controller]: changing "+e+" sourceBuffer type to "+o),u.changeType(o)),a.shiftAndExecuteNext(e)},onStart:function(){},onComplete:function(){},onError:function(u){T.logger.warn("[buffer-controller]: Failed to change "+e+" SourceBuffer type",u)}};a.append(i,e)},y.onBufferAppending=function(e,o){var f=this,a=this.hls,i=this.operationQueue,t=this.tracks,u=o.data,c=o.type,r=o.frag,h=o.part,d=o.chunkMeta,l=d.buffering[c],v=self.performance.now();l.start=v;var m=r.stats.buffering,L=h?h.stats.buffering:null;m.start===0&&(m.start=v),L&&L.start===0&&(L.start=v);var b=t.audio,M=c==="audio"&&d.id===1&&(b==null?void 0:b.container)==="audio/mpeg",F={execute:function(){if(l.executeStart=self.performance.now(),M){var C=f.sourceBuffer[c];if(C){var U=r.start-C.timestampOffset;Math.abs(U)>=.1&&(T.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+r.start+" (delta: "+U+") sn: "+r.sn+")"),C.timestampOffset=r.start)}}f.appendExecutor(u,c)},onStart:function(){},onComplete:function(){var C=self.performance.now();l.executeEnd=l.end=C,m.first===0&&(m.first=C),L&&L.first===0&&(L.first=C);var U=f.sourceBuffer,k={};for(var j in U)k[j]=S.BufferHelper.getBuffered(U[j]);f.appendError=0,f.hls.trigger(p.Events.BUFFER_APPENDED,{type:c,frag:r,part:h,chunkMeta:d,parent:r.type,timeRanges:k})},onError:function(C){T.logger.error("[buffer-controller]: Error encountered while trying to append to the "+c+" SourceBuffer",C);var U={type:I.ErrorTypes.MEDIA_ERROR,parent:r.type,details:I.ErrorDetails.BUFFER_APPEND_ERROR,err:C,fatal:!1};C.code===DOMException.QUOTA_EXCEEDED_ERR?U.details=I.ErrorDetails.BUFFER_FULL_ERROR:(f.appendError++,U.details=I.ErrorDetails.BUFFER_APPEND_ERROR,f.appendError>a.config.appendErrorMaxRetry&&(T.logger.error("[buffer-controller]: Failed "+a.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),U.fatal=!0,a.stopLoad())),a.trigger(p.Events.ERROR,U)}};i.append(F,c)},y.onBufferFlushing=function(e,o){var f=this,a=this.operationQueue,i=function(u){return{execute:f.removeExecutor.bind(f,u,o.startOffset,o.endOffset),onStart:function(){},onComplete:function(){f.hls.trigger(p.Events.BUFFER_FLUSHED,{type:u})},onError:function(r){T.logger.warn("[buffer-controller]: Failed to remove from "+u+" SourceBuffer",r)}}};o.type?a.append(i(o.type),o.type):this.getSourceBufferTypes().forEach(function(t){a.append(i(t),t)})},y.onFragParsed=function(e,o){var f=this,a=o.frag,i=o.part,t=[],u=i?i.elementaryStreams:a.elementaryStreams;u[_.ElementaryStreamTypes.AUDIOVIDEO]?t.push("audiovideo"):(u[_.ElementaryStreamTypes.AUDIO]&&t.push("audio"),u[_.ElementaryStreamTypes.VIDEO]&&t.push("video"));var c=function(){var h=self.performance.now();a.stats.buffering.end=h,i&&(i.stats.buffering.end=h);var d=i?i.stats:a.stats;f.hls.trigger(p.Events.FRAG_BUFFERED,{frag:a,part:i,stats:d,id:a.type})};t.length===0&&T.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+a.type+" level: "+a.level+" sn: "+a.sn),this.blockBuffers(c,t)},y.onFragChanged=function(e,o){this.flushBackBuffer()},y.onBufferEos=function(e,o){var f=this,a=this.getSourceBufferTypes().reduce(function(i,t){var u=f.sourceBuffer[t];return(!o.type||o.type===t)&&u&&!u.ended&&(u.ended=!0,T.logger.log("[buffer-controller]: "+t+" sourceBuffer now EOS")),i&&!!(!u||u.ended)},!0);a&&this.blockBuffers(function(){var i=f.mediaSource;!i||i.readyState!=="open"||i.endOfStream()})},y.onLevelUpdated=function(e,o){var f=o.details;!f.fragments.length||(this.details=f,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},y.flushBackBuffer=function(){var e=this.hls,o=this.details,f=this.media,a=this.sourceBuffer;if(!(!f||o===null)){var i=this.getSourceBufferTypes();if(!!i.length){var t=o.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!(!Object(R.isFiniteNumber)(t)||t<0)){var u=f.currentTime,c=o.levelTargetDuration,r=Math.max(t,c),h=Math.floor(u/c)*c-r;i.forEach(function(d){var l=a[d];if(l){var v=S.BufferHelper.getBuffered(l);v.length>0&&h>v.start(0)&&(e.trigger(p.Events.BACK_BUFFER_REACHED,{bufferEnd:h}),o.live&&e.trigger(p.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:h}),e.trigger(p.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:h,type:d}))}})}}}},y.updateMediaElementDuration=function(){if(!(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")){var e=this.details,o=this.hls,f=this.media,a=this.mediaSource,i=e.fragments[0].start+e.totalduration,t=f.duration,u=Object(R.isFiniteNumber)(a.duration)?a.duration:0;e.live&&o.config.liveDurationInfinity?(T.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),a.duration=1/0,this.updateSeekableRange(e)):(i>u&&i>t||!Object(R.isFiniteNumber)(t))&&(T.logger.log("[buffer-controller]: Updating Media Source duration to "+i.toFixed(3)),a.duration=i)}},y.updateSeekableRange=function(e){var o=this.mediaSource,f=e.fragments,a=f.length;if(a&&e.live&&o!==null&&o!==void 0&&o.setLiveSeekableRange){var i=Math.max(0,f[0].start),t=Math.max(i,i+e.totalduration);o.setLiveSeekableRange(i,t)}},y.checkPendingTracks=function(){var e=this.bufferCodecEventsExpected,o=this.operationQueue,f=this.pendingTracks,a=Object.keys(f).length;if(a&&!e||a===2){this.createSourceBuffers(f),this.pendingTracks={};var i=this.getSourceBufferTypes();if(i.length===0){this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});return}i.forEach(function(t){o.executeNext(t)})}},y.createSourceBuffers=function(e){var o=this.sourceBuffer,f=this.mediaSource;if(!f)throw Error("createSourceBuffers called when mediaSource was null");var a=0;for(var i in e)if(!o[i]){var t=e[i];if(!t)throw Error("source buffer exists for track "+i+", however track does not");var u=t.levelCodec||t.codec,c=t.container+";codecs="+u;T.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var r=o[i]=f.addSourceBuffer(c),h=i;this.addBufferListener(h,"updatestart",this._onSBUpdateStart),this.addBufferListener(h,"updateend",this._onSBUpdateEnd),this.addBufferListener(h,"error",this._onSBUpdateError),this.tracks[i]={buffer:r,codec:u,container:t.container,levelCodec:t.levelCodec,metadata:t.metadata,id:t.id},a++}catch(d){T.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+d.message),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,mimeType:c})}}a&&this.hls.trigger(p.Events.BUFFER_CREATED,{tracks:this.tracks})},y._onSBUpdateStart=function(e){var o=this.operationQueue,f=o.current(e);f.onStart()},y._onSBUpdateEnd=function(e){var o=this.operationQueue,f=o.current(e);f.onComplete(),o.shiftAndExecuteNext(e)},y._onSBUpdateError=function(e,o){T.logger.error("[buffer-controller]: "+e+" SourceBuffer error",o),this.hls.trigger(p.Events.ERROR,{type:I.ErrorTypes.MEDIA_ERROR,details:I.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var f=this.operationQueue.current(e);f&&f.onError(o)},y.removeExecutor=function(e,o,f){var a=this.media,i=this.mediaSource,t=this.operationQueue,u=this.sourceBuffer,c=u[e];if(!a||!i||!c){T.logger.warn("[buffer-controller]: Attempting to remove from the "+e+" SourceBuffer, but it does not exist"),t.shiftAndExecuteNext(e);return}var r=Object(R.isFiniteNumber)(a.duration)?a.duration:1/0,h=Object(R.isFiniteNumber)(i.duration)?i.duration:1/0,d=Math.max(0,o),l=Math.min(f,r,h);l>d?(T.logger.log("[buffer-controller]: Removing ["+d+","+l+"] from the "+e+" SourceBuffer"),console.assert(!c.updating,e+" sourceBuffer must not be updating"),c.remove(d,l)):t.shiftAndExecuteNext(e)},y.appendExecutor=function(e,o){var f=this.operationQueue,a=this.sourceBuffer,i=a[o];if(!i){T.logger.warn("[buffer-controller]: Attempting to append to the "+o+" SourceBuffer, but it does not exist"),f.shiftAndExecuteNext(o);return}i.ended=!1,console.assert(!i.updating,o+" sourceBuffer must not be updating"),i.appendBuffer(e)},y.blockBuffers=function(e,o){var f=this;if(o===void 0&&(o=this.getSourceBufferTypes()),!o.length){T.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}var a=this.operationQueue,i=o.map(function(t){return a.appendBlocker(t)});Promise.all(i).then(function(){e(),o.forEach(function(t){var u=f.sourceBuffer[t];(!u||!u.updating)&&a.shiftAndExecuteNext(t)})})},y.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},y.addBufferListener=function(e,o,f){var a=this.sourceBuffer[e];if(!!a){var i=f.bind(this,e);this.listeners[e].push({event:o,listener:i}),a.addEventListener(o,i)}},y.removeBufferListeners=function(e){var o=this.sourceBuffer[e];!o||this.listeners[e].forEach(function(f){o.removeEventListener(f.event,f.listener)})},g}()},"./src/controller/buffer-operation-queue.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return p});var R=n("./src/utils/logger.ts"),p=function(){function T(S){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=S}var I=T.prototype;return I.append=function(O,_){var E=this.queues[_];E.push(O),E.length===1&&this.buffers[_]&&this.executeNext(_)},I.insertAbort=function(O,_){var E=this.queues[_];E.unshift(O),this.executeNext(_)},I.appendBlocker=function(O){var _,E=new Promise(function(D){_=D}),A={execute:_,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(A,O),E},I.executeNext=function(O){var _=this.buffers,E=this.queues,A=_[O],D=E[O];if(D.length){var x=D[0];try{x.execute()}catch(g){R.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),x.onError(g),(!A||!A.updating)&&(D.shift(),this.executeNext(O))}}},I.shiftAndExecuteNext=function(O){this.queues[O].shift(),this.executeNext(O)},I.current=function(O){return this.queues[O][0]},T}()},"./src/controller/cap-level-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts");function p(S,O){for(var _=0;_<O.length;_++){var E=O[_];E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(S,E.key,E)}}function T(S,O,_){return O&&p(S.prototype,O),_&&p(S,_),Object.defineProperty(S,"prototype",{writable:!1}),S}var I=function(){function S(_){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=_,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var O=S.prototype;return O.setStreamController=function(E){this.streamController=E},O.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},O.registerListeners=function(){var E=this.hls;E.on(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.on(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.unregisterListener=function(){var E=this.hls;E.off(R.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),E.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),E.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),E.off(R.Events.BUFFER_CODECS,this.onBufferCodecs,this),E.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},O.onFpsDropLevelCapping=function(E,A){S.isLevelAllowed(A.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(A.droppedLevel)},O.onMediaAttaching=function(E,A){this.media=A.media instanceof HTMLVideoElement?A.media:null},O.onManifestParsed=function(E,A){var D=this.hls;this.restrictedLevels=[],this.firstLevel=A.firstLevel,D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},O.onBufferCodecs=function(E,A){var D=this.hls;D.config.capLevelToPlayerSize&&A.video&&this.startCapping()},O.onMediaDetaching=function(){this.stopCapping()},O.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var E=this.hls.levels;if(E.length){var A=this.hls;A.autoLevelCapping=this.getMaxLevel(E.length-1),A.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=A.autoLevelCapping}}},O.getMaxLevel=function(E){var A=this,D=this.hls.levels;if(!D.length)return-1;var x=D.filter(function(g,y){return S.isLevelAllowed(y,A.restrictedLevels)&&y<=E});return this.clientRect=null,S.getMaxLevelByMediaSize(x,this.mediaWidth,this.mediaHeight)},O.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},O.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},O.getDimensions=function(){if(this.clientRect)return this.clientRect;var E=this.media,A={width:0,height:0};if(E){var D=E.getBoundingClientRect();A.width=D.width,A.height=D.height,!A.width&&!A.height&&(A.width=D.right-D.left||E.width||0,A.height=D.bottom-D.top||E.height||0)}return this.clientRect=A,A},S.isLevelAllowed=function(E,A){return A===void 0&&(A=[]),A.indexOf(E)===-1},S.getMaxLevelByMediaSize=function(E,A,D){if(!E||!E.length)return-1;for(var x=function(o,f){return f?o.width!==f.width||o.height!==f.height:!0},g=E.length-1,y=0;y<E.length;y+=1){var s=E[y];if((s.width>=A||s.height>=D)&&x(s,E[y+1])){g=y;break}}return g},T(S,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var E=1;if(!this.hls.config.ignoreDevicePixelRatio)try{E=self.devicePixelRatio}catch{}return E}}]),S}();P.default=I},"./src/controller/cmcd-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./src/events.ts"),p=n("./src/types/cmcd.ts"),T=n("./src/utils/buffer-helper.ts"),I=n("./src/utils/logger.ts");function S(g,y){for(var s=0;s<y.length;s++){var e=y[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(g,e.key,e)}}function O(g,y,s){return y&&S(g.prototype,y),s&&S(g,s),Object.defineProperty(g,"prototype",{writable:!1}),g}function _(g,y){var s=typeof Symbol!="undefined"&&g[Symbol.iterator]||g["@@iterator"];if(s)return(s=s.call(g)).next.bind(s);if(Array.isArray(g)||(s=E(g))||y&&g&&typeof g.length=="number"){s&&(g=s);var e=0;return function(){return e>=g.length?{done:!0}:{done:!1,value:g[e++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
12
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function E(g,y){if(!!g){if(typeof g=="string")return A(g,y);var s=Object.prototype.toString.call(g).slice(8,-1);if(s==="Object"&&g.constructor&&(s=g.constructor.name),s==="Map"||s==="Set")return Array.from(g);if(s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return A(g,y)}}function A(g,y){(y==null||y>g.length)&&(y=g.length);for(var s=0,e=new Array(y);s<y;s++)e[s]=g[s];return e}function D(){return D=Object.assign?Object.assign.bind():function(g){for(var y=1;y<arguments.length;y++){var s=arguments[y];for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&(g[e]=s[e])}return g},D.apply(this,arguments)}var x=function(){function g(s){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(a){try{e.apply(a,{ot:p.CMCDObjectType.MANIFEST,su:!e.initialized})}catch(i){I.logger.warn("Could not generate manifest CMCD data.",i)}},this.applyFragmentData=function(a){try{var i=a.frag,t=e.hls.levels[i.level],u=e.getObjectType(i),c={d:i.duration*1e3,ot:u};(u===p.CMCDObjectType.VIDEO||u===p.CMCDObjectType.AUDIO||u==p.CMCDObjectType.MUXED)&&(c.br=t.bitrate/1e3,c.tb=e.getTopBandwidth(u)/1e3,c.bl=e.getBufferLength(u)),e.apply(a,c)}catch(r){I.logger.warn("Could not generate segment CMCD data.",r)}},this.hls=s;var o=this.config=s.config,f=o.cmcd;f!=null&&(o.pLoader=this.createPlaylistLoader(),o.fLoader=this.createFragmentLoader(),this.sid=f.sessionId||g.uuid(),this.cid=f.contentId,this.useHeaders=f.useHeaders===!0,this.registerListeners())}var y=g.prototype;return y.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.on(R.Events.BUFFER_CREATED,this.onBufferCreated,this)},y.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),e.off(R.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},y.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},y.onMediaAttached=function(e,o){this.media=o.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},y.onMediaDetached=function(){!this.media||(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},y.onBufferCreated=function(e,o){var f,a;this.audioBuffer=(f=o.tracks.audio)===null||f===void 0?void 0:f.buffer,this.videoBuffer=(a=o.tracks.video)===null||a===void 0?void 0:a.buffer},y.createData=function(){var e;return{v:p.CMCDVersion,sf:p.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)===null||e===void 0?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},y.apply=function(e,o){o===void 0&&(o={}),D(o,this.createData());var f=o.ot===p.CMCDObjectType.INIT||o.ot===p.CMCDObjectType.VIDEO||o.ot===p.CMCDObjectType.MUXED;if(this.starved&&f&&(o.bs=!0,o.su=!0,this.starved=!1),o.su==null&&(o.su=this.buffering),this.useHeaders){var a=g.toHeaders(o);if(!Object.keys(a).length)return;e.headers||(e.headers={}),D(e.headers,a)}else{var i=g.toQuery(o);if(!i)return;e.url=g.appendQueryToUri(e.url,i)}},y.getObjectType=function(e){var o=e.type;if(o==="subtitle")return p.CMCDObjectType.TIMED_TEXT;if(e.sn==="initSegment")return p.CMCDObjectType.INIT;if(o==="audio")return p.CMCDObjectType.AUDIO;if(o==="main")return this.hls.audioTracks.length?p.CMCDObjectType.VIDEO:p.CMCDObjectType.MUXED},y.getTopBandwidth=function(e){var o=0,f,a=this.hls;if(e===p.CMCDObjectType.AUDIO)f=a.audioTracks;else{var i=a.maxAutoLevel,t=i>-1?i+1:a.levels.length;f=a.levels.slice(0,t)}for(var u=_(f),c;!(c=u()).done;){var r=c.value;r.bitrate>o&&(o=r.bitrate)}return o>0?o:NaN},y.getBufferLength=function(e){var o=this.hls.media,f=e===p.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;if(!f||!o)return NaN;var a=T.BufferHelper.bufferInfo(f,o.currentTime,this.config.maxBufferHole);return a.len*1e3},y.createPlaylistLoader=function(){var e=this.config.pLoader,o=this.applyPlaylistData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},O(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},y.createFragmentLoader=function(){var e=this.config.fLoader,o=this.applyFragmentData,f=e||this.config.loader;return function(){function a(t){this.loader=void 0,this.loader=new f(t)}var i=a.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(u,c,r){o(u),this.loader.load(u,c,r)},O(a,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),a}()},g.uuid=function(){var e=URL.createObjectURL(new Blob),o=e.toString();return URL.revokeObjectURL(e),o.slice(o.lastIndexOf("/")+1)},g.serialize=function(e){for(var o=[],f=function(M){return!Number.isNaN(M)&&M!=null&&M!==""&&M!==!1},a=function(M){return Math.round(M)},i=function(M){return a(M/100)*100},t=function(M){return encodeURIComponent(M)},u={br:a,d:a,bl:i,dl:i,mtp:i,nor:t,rtp:i,tb:a},c=Object.keys(e||{}).sort(),r=_(c),h;!(h=r()).done;){var d=h.value,l=e[d];if(!!f(l)&&!(d==="v"&&l===1)&&!(d=="pr"&&l===1)){var v=u[d];v&&(l=v(l));var m=typeof l,L=void 0;d==="ot"||d==="sf"||d==="st"?L=d+"="+l:m==="boolean"?L=d:m==="number"?L=d+"="+l:L=d+"="+JSON.stringify(l),o.push(L)}}return o.join(",")},g.toHeaders=function(e){for(var o=Object.keys(e),f={},a=["Object","Request","Session","Status"],i=[{},{},{},{}],t={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},u=0,c=o;u<c.length;u++){var r=c[u],h=t[r]!=null?t[r]:1;i[h][r]=e[r]}for(var d=0;d<i.length;d++){var l=g.serialize(i[d]);l&&(f["CMCD-"+a[d]]=l)}return f},g.toQuery=function(e){return"CMCD="+encodeURIComponent(g.serialize(e))},g.appendQueryToUri=function(e,o){if(!o)return e;var f=e.includes("?")?"&":"?";return""+e+f+o},g}()},"./src/controller/eme-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/utils/logger.ts"),I=n("./src/utils/mediakeys-helper.ts");function S(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,g,y){return g&&S(x.prototype,g),y&&S(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}var _=3,E=function(g,y,s){var e={audioCapabilities:[],videoCapabilities:[]};return g.forEach(function(o){e.audioCapabilities.push({contentType:'audio/mp4; codecs="'+o+'"',robustness:s.audioRobustness||""})}),y.forEach(function(o){e.videoCapabilities.push({contentType:'video/mp4; codecs="'+o+'"',robustness:s.videoRobustness||""})}),[e]},A=function(g,y,s,e){switch(g){case I.KeySystems.WIDEVINE:return E(y,s,e);default:throw new Error("Unknown key-system: "+g)}},D=function(){function x(y){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=y,this._config=y.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var g=x.prototype;return g.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},g._registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g._unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this)},g.getLicenseServerUrl=function(s){switch(s){case I.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+s+'"')},g._attemptKeySystemAccess=function(s,e,o){var f=this,a=A(s,e,o,this._drmSystemOptions);T.logger.log("Requesting encrypted media key-system access");var i=this.requestMediaKeySystemAccess(s,a);this.mediaKeysPromise=i.then(function(t){return f._onMediaKeySystemAccessObtained(s,t)}),i.catch(function(t){T.logger.error('Failed to obtain key-system "'+s+'" access:',t)})},g._onMediaKeySystemAccessObtained=function(s,e){var o=this;T.logger.log('Access for key-system "'+s+'" obtained');var f={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:e,mediaKeySystemDomain:s};this._mediaKeysList.push(f);var a=Promise.resolve().then(function(){return e.createMediaKeys()}).then(function(i){return f.mediaKeys=i,T.logger.log('Media-keys created for key-system "'+s+'"'),o._onMediaKeysCreated(),i});return a.catch(function(i){T.logger.error("Failed to create media-keys:",i)}),a},g._onMediaKeysCreated=function(){var s=this;this._mediaKeysList.forEach(function(e){e.mediaKeysSession||(e.mediaKeysSession=e.mediaKeys.createSession(),s._onNewMediaKeySession(e.mediaKeysSession))})},g._onNewMediaKeySession=function(s){var e=this;T.logger.log("New key-system session "+s.sessionId),s.addEventListener("message",function(o){e._onKeySessionMessage(s,o.message)},!1)},g._onKeySessionMessage=function(s,e){T.logger.log("Got EME message event, creating license request"),this._requestLicense(e,function(o){T.logger.log("Received license data (length: "+(o&&o.byteLength)+"), updating key-session"),s.update(o).catch(function(f){T.logger.warn("Updating key-session failed: "+f)})})},g.onMediaEncrypted=function(s){var e=this;if(T.logger.log('Media is encrypted using "'+s.initDataType+'" init data type'),!this.mediaKeysPromise){T.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}var o=function(a){!e._media||(e._attemptSetMediaKeys(a),e._generateRequestWithPreferredKeySession(s.initDataType,s.initData))};this.mediaKeysPromise.then(o).catch(o)},g._attemptSetMediaKeys=function(s){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var e=this._mediaKeysList[0];if(!e||!e.mediaKeys){T.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});return}T.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(e.mediaKeys),this._hasSetMediaKeys=!0}},g._generateRequestWithPreferredKeySession=function(s,e){var o=this,f=this._mediaKeysList[0];if(!f){T.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}if(f.mediaKeysSessionInitialized){T.logger.warn("Key-Session already initialized but requested again");return}var a=f.mediaKeysSession;if(!a){T.logger.error("Fatal: Media is encrypted but no key-session existing"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});return}if(!e){T.logger.warn("Fatal: initData required for generating a key session is null"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});return}T.logger.log('Generating key-session request for "'+s+'" init data type'),f.mediaKeysSessionInitialized=!0,a.generateRequest(s,e).then(function(){T.logger.debug("Key-session generation succeeded")}).catch(function(i){T.logger.error("Error generating key-session request:",i),o.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})})},g._createLicenseXhr=function(s,e,o){var f=new XMLHttpRequest;f.responseType="arraybuffer",f.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,f,s,e,o);var a=this._licenseXhrSetup;if(a)try{a.call(this.hls,f,s),a=void 0}catch(i){T.logger.error(i)}try{f.readyState||f.open("POST",s,!0),a&&a.call(this.hls,f,s)}catch(i){throw new Error("issue setting up KeySystem license XHR "+i)}return f},g._onLicenseRequestReadyStageChange=function(s,e,o,f){switch(s.readyState){case 4:if(s.status===200){this._requestLicenseFailureCount=0,T.logger.log("License request succeeded");var a=s.response,i=this._licenseResponseCallback;if(i)try{a=i.call(this.hls,s,e)}catch(u){T.logger.error(u)}f(a)}else{if(T.logger.error("License Request XHR failed ("+e+"). Status: "+s.status+" ("+s.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>_){this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});return}var t=_-this._requestLicenseFailureCount+1;T.logger.warn("Retrying license request, "+t+" attempts left"),this._requestLicense(o,f)}break}},g._generateLicenseRequestChallenge=function(s,e){switch(s.mediaKeySystemDomain){case I.KeySystems.WIDEVINE:return e}throw new Error("unsupported key-system: "+s.mediaKeySystemDomain)},g._requestLicense=function(s,e){T.logger.log("Requesting content license for key-system");var o=this._mediaKeysList[0];if(!o){T.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});return}try{var f=this.getLicenseServerUrl(o.mediaKeySystemDomain),a=this._createLicenseXhr(f,s,e);T.logger.log("Sending license request to URL: "+f);var i=this._generateLicenseRequestChallenge(o,s);a.send(i)}catch(t){T.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.KEY_SYSTEM_ERROR,details:p.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},g.onMediaAttached=function(s,e){if(!!this._emeEnabled){var o=e.media;this._media=o,o.addEventListener("encrypted",this._onMediaEncrypted)}},g.onMediaDetached=function(){var s=this._media,e=this._mediaKeysList;!s||(s.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(e.map(function(o){if(o.mediaKeysSession)return o.mediaKeysSession.close().catch(function(){})})).then(function(){return s.setMediaKeys(null)}).catch(function(){}))},g.onManifestParsed=function(s,e){if(!!this._emeEnabled){var o=e.levels.map(function(a){return a.audioCodec}).filter(function(a){return!!a}),f=e.levels.map(function(a){return a.videoCodec}).filter(function(a){return!!a});this._attemptKeySystemAccess(I.KeySystems.WIDEVINE,o,f)}},O(x,[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}]),x}();P.default=D},"./src/controller/fps-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/utils/logger.ts"),T=function(){function I(O){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=O,this.registerListeners()}var S=I.prototype;return S.setStreamController=function(_){this.streamController=_},S.registerListeners=function(){this.hls.on(R.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},S.unregisterListeners=function(){this.hls.off(R.Events.MEDIA_ATTACHING,this.onMediaAttaching)},S.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},S.onMediaAttaching=function(_,E){var A=this.hls.config;if(A.capLevelOnFPSDrop){var D=E.media instanceof self.HTMLVideoElement?E.media:null;this.media=D,D&&typeof D.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),A.fpsDroppedMonitoringPeriod)}},S.checkFPS=function(_,E,A){var D=performance.now();if(E){if(this.lastTime){var x=D-this.lastTime,g=A-this.lastDroppedFrames,y=E-this.lastDecodedFrames,s=1e3*g/x,e=this.hls;if(e.trigger(R.Events.FPS_DROP,{currentDropped:g,currentDecoded:y,totalDroppedFrames:A}),s>0&&g>e.config.fpsDroppedMonitoringThreshold*y){var o=e.currentLevel;p.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+o),o>0&&(e.autoLevelCapping===-1||e.autoLevelCapping>=o)&&(o=o-1,e.trigger(R.Events.FPS_DROP_LEVEL_CAPPING,{level:o,droppedLevel:e.currentLevel}),e.autoLevelCapping=o,this.streamController.nextLevelSwitch())}}this.lastTime=D,this.lastDroppedFrames=A,this.lastDecodedFrames=E}},S.checkFPSInterval=function(){var _=this.media;if(_)if(this.isVideoPlaybackQualityAvailable){var E=_.getVideoPlaybackQuality();this.checkFPS(_,E.totalVideoFrames,E.droppedVideoFrames)}else this.checkFPS(_,_.webkitDecodedFrameCount,_.webkitDroppedFrameCount)},I}();P.default=T},"./src/controller/fragment-finders.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFragmentByPDT",function(){return T}),n.d(P,"findFragmentByPTS",function(){return I}),n.d(P,"fragmentWithinToleranceTest",function(){return S}),n.d(P,"pdtWithinToleranceTest",function(){return O}),n.d(P,"findFragWithCC",function(){return _});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/binary-search.ts");function T(E,A,D){if(A===null||!Array.isArray(E)||!E.length||!Object(R.isFiniteNumber)(A))return null;var x=E[0].programDateTime;if(A<(x||0))return null;var g=E[E.length-1].endProgramDateTime;if(A>=(g||0))return null;D=D||0;for(var y=0;y<E.length;++y){var s=E[y];if(O(A,D,s))return s}return null}function I(E,A,D,x){D===void 0&&(D=0),x===void 0&&(x=0);var g=null;if(E?g=A[E.sn-A[0].sn+1]||null:D===0&&A[0].start===0&&(g=A[0]),g&&S(D,x,g)===0)return g;var y=p.default.search(A,S.bind(null,D,x));return y||g}function S(E,A,D){E===void 0&&(E=0),A===void 0&&(A=0);var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0));return D.start+D.duration-x<=E?1:D.start-x>E&&D.start?-1:0}function O(E,A,D){var x=Math.min(A,D.duration+(D.deltaPTS?D.deltaPTS:0))*1e3,g=D.endProgramDateTime||0;return g-x>E}function _(E,A){return p.default.search(E,function(D){return D.cc<A?1:D.cc>A?-1:0})}},"./src/controller/fragment-tracker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"FragmentState",function(){return T}),n.d(P,"FragmentTracker",function(){return I});var R=n("./src/events.ts"),p=n("./src/types/loader.ts"),T;(function(_){_.NOT_LOADED="NOT_LOADED",_.APPENDING="APPENDING",_.PARTIAL="PARTIAL",_.OK="OK"})(T||(T={}));var I=function(){function _(A){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=A,this._registerListeners()}var E=_.prototype;return E._registerListeners=function(){var D=this.hls;D.on(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.on(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.on(R.Events.FRAG_LOADED,this.onFragLoaded,this)},E._unregisterListeners=function(){var D=this.hls;D.off(R.Events.BUFFER_APPENDED,this.onBufferAppended,this),D.off(R.Events.FRAG_BUFFERED,this.onFragBuffered,this),D.off(R.Events.FRAG_LOADED,this.onFragLoaded,this)},E.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},E.getAppendedFrag=function(D,x){if(x===p.PlaylistLevelType.MAIN){var g=this.activeFragment,y=this.activeParts;if(!g)return null;if(y)for(var s=y.length;s--;){var e=y[s],o=e?e.end:g.appendedPTS;if(e.start<=D&&o!==void 0&&D<=o)return s>9&&(this.activeParts=y.slice(s-9)),e}else if(g.start<=D&&g.appendedPTS!==void 0&&D<=g.appendedPTS)return g}return this.getBufferedFrag(D,x)},E.getBufferedFrag=function(D,x){for(var g=this.fragments,y=Object.keys(g),s=y.length;s--;){var e=g[y[s]];if((e==null?void 0:e.body.type)===x&&e.buffered){var o=e.body;if(o.start<=D&&D<=o.end)return o}}return null},E.detectEvictedFragments=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e){if(!e.buffered){e.body.type===g&&y.removeFragment(e.body);return}var o=e.range[D];!o||o.time.some(function(f){var a=!y.isTimeBuffered(f.startPTS,f.endPTS,x);return a&&y.removeFragment(e.body),a})}})},E.detectPartialFragments=function(D){var x=this,g=this.timeRanges,y=D.frag,s=D.part;if(!(!g||y.sn==="initSegment")){var e=O(y),o=this.fragments[e];!o||(Object.keys(g).forEach(function(f){var a=y.elementaryStreams[f];if(!!a){var i=g[f],t=s!==null||a.partial===!0;o.range[f]=x.getBufferedTimes(y,s,t,i)}}),o.loaded=null,Object.keys(o.range).length?o.buffered=!0:this.removeFragment(o.body))}},E.fragBuffered=function(D){var x=O(D),g=this.fragments[x];g&&(g.loaded=null,g.buffered=!0)},E.getBufferedTimes=function(D,x,g,y){for(var s={time:[],partial:g},e=x?x.start:D.start,o=x?x.end:D.end,f=D.minEndPTS||o,a=D.maxStartPTS||e,i=0;i<y.length;i++){var t=y.start(i)-this.bufferPadding,u=y.end(i)+this.bufferPadding;if(a>=t&&f<=u){s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});break}else if(e<u&&o>t)s.partial=!0,s.time.push({startPTS:Math.max(e,y.start(i)),endPTS:Math.min(o,y.end(i))});else if(o<=t)break}return s},E.getPartialFragment=function(D){var x=null,g,y,s,e=0,o=this.bufferPadding,f=this.fragments;return Object.keys(f).forEach(function(a){var i=f[a];!i||S(i)&&(y=i.body.start-o,s=i.body.end+o,D>=y&&D<=s&&(g=Math.min(D-y,s-D),e<=g&&(x=i.body,e=g)))}),x},E.getState=function(D){var x=O(D),g=this.fragments[x];return g?g.buffered?S(g)?T.PARTIAL:T.OK:T.APPENDING:T.NOT_LOADED},E.isTimeBuffered=function(D,x,g){for(var y,s,e=0;e<g.length;e++){if(y=g.start(e)-this.bufferPadding,s=g.end(e)+this.bufferPadding,D>=y&&x<=s)return!0;if(x<=y)return!1}return!1},E.onFragLoaded=function(D,x){var g=x.frag,y=x.part;if(!(g.sn==="initSegment"||g.bitrateTest||y)){var s=O(g);this.fragments[s]={body:g,loaded:x,buffered:!1,range:Object.create(null)}}},E.onBufferAppended=function(D,x){var g=this,y=x.frag,s=x.part,e=x.timeRanges;if(y.type===p.PlaylistLevelType.MAIN)if(this.activeFragment=y,s){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(s)}else this.activeParts=null;this.timeRanges=e,Object.keys(e).forEach(function(f){var a=e[f];if(g.detectEvictedFragments(f,a),!s)for(var i=0;i<a.length;i++)y.appendedPTS=Math.max(a.end(i),y.appendedPTS||0)})},E.onFragBuffered=function(D,x){this.detectPartialFragments(x)},E.hasFragment=function(D){var x=O(D);return!!this.fragments[x]},E.removeFragmentsInRange=function(D,x,g){var y=this;Object.keys(this.fragments).forEach(function(s){var e=y.fragments[s];if(!!e&&e.buffered){var o=e.body;o.type===g&&o.start<x&&o.end>D&&y.removeFragment(o)}})},E.removeFragment=function(D){var x=O(D);D.stats.loaded=0,D.clearElementaryStreamInfo(),delete this.fragments[x]},E.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},_}();function S(_){var E,A;return _.buffered&&(((E=_.range.video)===null||E===void 0?void 0:E.partial)||((A=_.range.audio)===null||A===void 0?void 0:A.partial))}function O(_){return _.type+"_"+_.level+"_"+_.urlId+"_"+_.sn}},"./src/controller/gap-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"STALL_MINIMUM_DURATION_MS",function(){return S}),n.d(P,"MAX_START_GAP_JUMP",function(){return O}),n.d(P,"SKIP_BUFFER_HOLE_STEP_SECONDS",function(){return _}),n.d(P,"SKIP_BUFFER_RANGE_START",function(){return E}),n.d(P,"default",function(){return A});var R=n("./src/utils/buffer-helper.ts"),p=n("./src/errors.ts"),T=n("./src/events.ts"),I=n("./src/utils/logger.ts"),S=250,O=2,_=.1,E=.05,A=function(){function D(g,y,s,e){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=g,this.media=y,this.fragmentTracker=s,this.hls=e}var x=D.prototype;return x.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},x.poll=function(y,s){var e=this.config,o=this.media,f=this.stalled;if(o!==null){var a=o.currentTime,i=o.seeking,t=this.seeking&&!i,u=!this.seeking&&i;if(this.seeking=i,a!==y){if(this.moved=!0,f!==null){if(this.stallReported){var c=self.performance.now()-f;I.logger.warn("playback not stuck anymore @"+a+", after "+Math.round(c)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if((u||t)&&(this.stalled=null),!(o.paused&&!i||o.ended||o.playbackRate===0||!R.BufferHelper.getBuffered(o).length)){var r=R.BufferHelper.bufferInfo(o,a,0),h=r.len>0,d=r.nextStart||0;if(!(!h&&!d)){if(i){var l=r.len>O,v=!d||s&&s.start<=a||d-a>O&&!this.fragmentTracker.getPartialFragment(a);if(l||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var m,L=Math.max(d,r.start||0)-a,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,M=b==null||(m=b.details)===null||m===void 0?void 0:m.live,F=M?b.details.targetduration*2:O;if(L>0&&L<=F){this._trySkipBufferHole(null);return}}var w=self.performance.now();if(f===null){this.stalled=w;return}var C=w-f;if(!(!i&&C>=S&&(this._reportStall(r),!this.media))){var U=R.BufferHelper.bufferInfo(o,a,e.maxBufferHole);this._tryFixBufferStall(U,C)}}}}},x._tryFixBufferStall=function(y,s){var e=this.config,o=this.fragmentTracker,f=this.media;if(f!==null){var a=f.currentTime,i=o.getPartialFragment(a);if(i){var t=this._trySkipBufferHole(i);if(t||!this.media)return}y.len>e.maxBufferHole&&s>e.highBufferWatchdogPeriod*1e3&&(I.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},x._reportStall=function(y){var s=this.hls,e=this.media,o=this.stallReported;!o&&e&&(this.stallReported=!0,I.logger.warn("Playback stalling at @"+e.currentTime+" due to low buffer ("+JSON.stringify(y)+")"),s.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:y.len}))},x._trySkipBufferHole=function(y){var s=this.config,e=this.hls,o=this.media;if(o===null)return 0;for(var f=o.currentTime,a=0,i=R.BufferHelper.getBuffered(o),t=0;t<i.length;t++){var u=i.start(t);if(f+s.maxBufferHole>=a&&f<u){var c=Math.max(u+E,o.currentTime+_);return I.logger.warn("skipping hole, adjusting currentTime from "+f+" to "+c),this.moved=!0,this.stalled=null,o.currentTime=c,y&&e.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+f+" to "+c,frag:y}),c}a=i.end(t)}return 0},x._tryNudgeBuffer=function(){var y=this.config,s=this.hls,e=this.media,o=this.nudgeRetry;if(e!==null){var f=e.currentTime;if(this.nudgeRetry++,o<y.nudgeMaxRetry){var a=f+(o+1)*y.nudgeOffset;I.logger.warn("Nudging 'currentTime' from "+f+" to "+a),e.currentTime=a,s.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else I.logger.error("Playhead still not moving while enough data buffered @"+f+" after "+y.nudgeMaxRetry+" nudges"),s.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})}},D}()},"./src/controller/id3-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/texttrack-utils.ts"),I=n("./src/demux/id3.ts"),S=n("./src/loader/date-range.ts"),O=n("./src/types/demuxer.ts"),_=.25;function E(){return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}function A(g,y){return g.getTime()/1e3-y}function D(g){return Uint8Array.from(g.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}var x=function(){function g(s){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=s,this._registerListeners()}var y=g.prototype;return y.destroy=function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null},y._registerListeners=function(){var e=this.hls;e.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},y._unregisterListeners=function(){var e=this.hls;e.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this)},y.onMediaAttached=function(e,o){this.media=o.media},y.onMediaDetaching=function(){!this.id3Track||(Object(T.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})},y.onManifestLoading=function(){this.dateRangeCuesAppended={}},y.createTrack=function(e){var o=this.getID3Track(e.textTracks);return o.mode="hidden",o},y.getID3Track=function(e){if(!!this.media){for(var o=0;o<e.length;o++){var f=e[o];if(f.kind==="metadata"&&f.label==="id3")return Object(T.sendAddTrackEvent)(f,this.media),f}return this.media.addTextTrack("metadata","id3")}},y.onFragParsingMetadata=function(e,o){if(!!this.media){var f=this.hls.config,a=f.enableEmsgMetadataCues,i=f.enableID3MetadataCues;if(!(!a&&!i)){var t=o.frag,u=o.samples,c=o.details;this.id3Track||(this.id3Track=this.createTrack(this.media));for(var r=c.edge||t.end,h=E(),d=!1,l={},v=0;v<u.length;v++){var m=u[v].type;if(!(m===O.MetadataSchema.emsg&&!a||!i)){var L=I.getID3Frames(u[v].data);if(L){var b=u[v].pts,M=r,F=M-b;F<=0&&(M=b+_);for(var w=0;w<L.length;w++){var C=L[w];if(!I.isTimeStampFrame(C)){var U=new h(b,M,"");U.value=C,m&&(U.type=m),this.id3Track.addCue(U),l[C.key]=null,d=!0}}}}}d&&this.updateId3CueEnds(l)}}},y.updateId3CueEnds=function(e){var o,f=(o=this.id3Track)===null||o===void 0?void 0:o.cues;if(f)for(var a=f.length;a--;){var i,t=f[a],u=(i=t.value)===null||i===void 0?void 0:i.key;if(u&&u in e){var c=e[u];c&&t.endTime!==c&&(t.endTime=c),e[u]=t.startTime}}},y.onBufferFlushing=function(e,o){var f=o.startOffset,a=o.endOffset,i=o.type,t=this.id3Track,u=this.hls;if(!!u){var c=u.config,r=c.enableEmsgMetadataCues,h=c.enableID3MetadataCues;if(t&&(r||h)){var d;i==="audio"?d=function(v){return v.type===O.MetadataSchema.audioId3&&h}:i==="video"?d=function(v){return v.type===O.MetadataSchema.emsg&&r}:d=function(v){return v.type===O.MetadataSchema.audioId3&&h||v.type===O.MetadataSchema.emsg&&r},Object(T.removeCuesInRange)(t,f,a,d)}}},y.onLevelUpdated=function(e,o){var f=this,a=o.details;if(!(!this.media||!a.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)){var i=this.dateRangeCuesAppended,t=this.id3Track,u=a.dateRanges,c=Object.keys(u);if(t)for(var r=Object.keys(i).filter(function(F){return!c.includes(F)}),h=function(w){var C=r[w];Object.keys(i[C].cues).forEach(function(U){t.removeCue(i[C].cues[U])}),delete i[C]},d=r.length;d--;)h(d);var l=a.fragments[a.fragments.length-1];if(!(c.length===0||!Object(R.isFiniteNumber)(l==null?void 0:l.programDateTime))){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var v=l.programDateTime/1e3-l.start,m=a.edge||l.end,L=E(),b=function(w){var C=c[w],U=u[C],k=i[C],j=(k==null?void 0:k.cues)||{},N=(k==null?void 0:k.durationKnown)||!1,W=A(U.startDate,v),Y=m,K=U.endDate;if(K)Y=A(K,v),N=!0;else if(U.endOnNext&&!N){var H=c.reduce(function(Q,ae){var se=u[ae];return se.class===U.class&&se.id!==ae&&se.startDate>U.startDate&&Q.push(se),Q},[]).sort(function(Q,ae){return Q.startDate.getTime()-ae.startDate.getTime()})[0];H&&(Y=A(H.startDate,v),N=!0)}for(var z=Object.keys(U.attr),$=0;$<z.length;$++){var X=z[$];if(!(X===S.DateRangeAttribute.ID||X===S.DateRangeAttribute.CLASS||X===S.DateRangeAttribute.START_DATE||X===S.DateRangeAttribute.DURATION||X===S.DateRangeAttribute.END_DATE||X===S.DateRangeAttribute.END_ON_NEXT)){var J=j[X];if(J)N&&!k.durationKnown&&(J.endTime=Y);else{var te=U.attr[X];J=new L(W,Y,""),(X===S.DateRangeAttribute.SCTE35_OUT||X===S.DateRangeAttribute.SCTE35_IN)&&(te=D(te)),J.value={key:X,data:te},J.type=O.MetadataSchema.dateRange,f.id3Track.addCue(J),j[X]=J}}}i[C]={cues:j,dateRange:U,durationKnown:N}},M=0;M<c.length;M++)b(M)}}},g}();P.default=x},"./src/controller/latency-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/errors.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts");function I(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function S(_,E,A){return E&&I(_.prototype,E),A&&I(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var O=function(){function _(A){var D=this;this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=function(){return D.timeupdate()},this.hls=A,this.config=A.config,this.registerListeners()}var E=_.prototype;return E.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},E.registerListeners=function(){this.hls.on(p.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.Events.ERROR,this.onError,this)},E.unregisterListeners=function(){this.hls.off(p.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(p.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(p.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(p.Events.ERROR,this.onError)},E.onMediaAttached=function(D,x){this.media=x.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},E.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},E.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},E.onLevelUpdated=function(D,x){var g=x.details;this.levelDetails=g,g.advanced&&this.timeupdate(),!g.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},E.onError=function(D,x){x.details===R.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,T.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},E.timeupdate=function(){var D=this.media,x=this.levelDetails;if(!(!D||!x)){this.currentTime=D.currentTime;var g=this.computeLatency();if(g!==null){this._latency=g;var y=this.config,s=y.lowLatencyMode,e=y.maxLiveSyncPlaybackRate;if(!(!s||e===1)){var o=this.targetLatency;if(o!==null){var f=g-o,a=Math.min(this.maxLatency,o+x.targetduration),i=f<a;if(x.live&&i&&f>.05&&this.forwardBufferLength>1){var t=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*f-this.edgeStalled))*20)/20;D.playbackRate=Math.min(t,Math.max(1,u))}else D.playbackRate!==1&&D.playbackRate!==0&&(D.playbackRate=1)}}}}},E.estimateLiveEdge=function(){var D=this.levelDetails;return D===null?null:D.edge+D.age},E.computeLatency=function(){var D=this.estimateLiveEdge();return D===null?null:D-this.currentTime},S(_,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var D=this.config,x=this.levelDetails;return D.liveMaxLatencyDuration!==void 0?D.liveMaxLatencyDuration:x?D.liveMaxLatencyDurationCount*x.targetduration:0}},{key:"targetLatency",get:function(){var D=this.levelDetails;if(D===null)return null;var x=D.holdBack,g=D.partHoldBack,y=D.targetduration,s=this.config,e=s.liveSyncDuration,o=s.liveSyncDurationCount,f=s.lowLatencyMode,a=this.hls.userConfig,i=f&&g||x;(a.liveSyncDuration||a.liveSyncDurationCount||i===0)&&(i=e!==void 0?e:o*y);var t=y,u=1;return i+Math.min(this.stallCount*u,t)}},{key:"liveSyncPosition",get:function(){var D=this.estimateLiveEdge(),x=this.targetLatency,g=this.levelDetails;if(D===null||x===null||g===null)return null;var y=g.edge,s=D-x-this.edgeStalled,e=y-g.totalduration,o=y-(this.config.lowLatencyMode&&g.partTarget||g.targetduration);return Math.min(Math.max(e,s),o)}},{key:"drift",get:function(){var D=this.levelDetails;return D===null?1:D.drift}},{key:"edgeStalled",get:function(){var D=this.levelDetails;if(D===null)return 0;var x=(this.config.lowLatencyMode&&D.partTarget||D.targetduration)*3;return Math.max(D.age-x,0)}},{key:"forwardBufferLength",get:function(){var D=this.media,x=this.levelDetails;if(!D||!x)return 0;var g=D.buffered.length;return(g?D.buffered.end(g-1):x.edge)-this.currentTime}}]),_}()},"./src/controller/level-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return s});var R=n("./src/types/level.ts"),p=n("./src/events.ts"),T=n("./src/errors.ts"),I=n("./src/utils/codecs.ts"),S=n("./src/controller/level-helper.ts"),O=n("./src/controller/base-playlist-controller.ts"),_=n("./src/types/loader.ts");function E(){return E=Object.assign?Object.assign.bind():function(e){for(var o=1;o<arguments.length;o++){var f=arguments[o];for(var a in f)Object.prototype.hasOwnProperty.call(f,a)&&(e[a]=f[a])}return e},E.apply(this,arguments)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}function x(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,g(e,o)}function g(e,o){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},g(e,o)}var y=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),s=function(e){x(o,e);function o(a){var i;return i=e.call(this,a,"[level-controller]")||this,i._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.onParsedComplete=void 0,i._registerListeners(),i}var f=o.prototype;return f._registerListeners=function(){var i=this.hls;i.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.on(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.on(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.on(p.Events.ERROR,this.onError,this)},f._unregisterListeners=function(){var i=this.hls;i.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),i.off(p.Events.LEVEL_LOADED,this.onLevelLoaded,this),i.off(p.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),i.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),i.off(p.Events.ERROR,this.onError,this)},f.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,e.prototype.destroy.call(this)},f.startLoad=function(){var i=this._levels;i.forEach(function(t){t.loadError=0}),e.prototype.startLoad.call(this)},f.onManifestLoaded=function(i,t){var u=[],c=[],r=[],h,d={},l,v=!1,m=!1,L=!1;if(t.levels.forEach(function(w){var C=w.attrs;v=v||!!(w.width&&w.height),m=m||!!w.videoCodec,L=L||!!w.audioCodec,y&&w.audioCodec&&w.audioCodec.indexOf("mp4a.40.34")!==-1&&(w.audioCodec=void 0);var U=w.bitrate+"-"+w.attrs.RESOLUTION+"-"+w.attrs.CODECS;l=d[U],l?l.url.push(w.url):(l=new R.Level(w),d[U]=l,u.push(l)),C&&(C.AUDIO&&Object(S.addGroupId)(l,"audio",C.AUDIO),C.SUBTITLES&&Object(S.addGroupId)(l,"text",C.SUBTITLES))}),(v||m)&&L&&(u=u.filter(function(w){var C=w.videoCodec,U=w.width,k=w.height;return!!C||!!(U&&k)})),u=u.filter(function(w){var C=w.audioCodec,U=w.videoCodec;return(!C||Object(I.isCodecSupportedInMp4)(C,"audio"))&&(!U||Object(I.isCodecSupportedInMp4)(U,"video"))}),t.audioTracks&&(c=t.audioTracks.filter(function(w){return!w.audioCodec||Object(I.isCodecSupportedInMp4)(w.audioCodec,"audio")}),Object(S.assignTrackIdsByGroup)(c)),t.subtitles&&(r=t.subtitles,Object(S.assignTrackIdsByGroup)(r)),u.length>0){h=u[0].bitrate,u.sort(function(w,C){return w.bitrate-C.bitrate}),this._levels=u;for(var b=0;b<u.length;b++)if(u[b].bitrate===h){this._firstLevel=b,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+h);break}var M=L&&!m,F={levels:u,audioTracks:c,subtitleTracks:r,firstLevel:this._firstLevel,stats:t.stats,audio:L,video:m,altAudio:!M&&c.some(function(w){return!!w.url})};this.hls.trigger(p.Events.MANIFEST_PARSED,F),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(p.Events.ERROR,{type:T.ErrorTypes.MEDIA_ERROR,details:T.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,reason:"no level with compatible codecs found in manifest"})},f.onError=function(i,t){var u;if(e.prototype.onError.call(this,i,t),!t.fatal){var c=t.context,r=this._levels[this.currentLevelIndex];if(c&&(c.type===_.PlaylistContextType.AUDIO_TRACK&&r.audioGroupIds&&c.groupId===r.audioGroupIds[r.urlId]||c.type===_.PlaylistContextType.SUBTITLE_TRACK&&r.textGroupIds&&c.groupId===r.textGroupIds[r.urlId])){this.redundantFailover(this.currentLevelIndex);return}var h=!1,d=!0,l;switch(t.details){case T.ErrorDetails.FRAG_LOAD_ERROR:case T.ErrorDetails.FRAG_LOAD_TIMEOUT:case T.ErrorDetails.KEY_LOAD_ERROR:case T.ErrorDetails.KEY_LOAD_TIMEOUT:if(t.frag){var v=t.frag.type===_.PlaylistLevelType.MAIN?t.frag.level:this.currentLevelIndex,m=this._levels[v];m?(m.fragmentError++,m.fragmentError>this.hls.config.fragLoadingMaxRetry&&(l=v)):l=v}break;case T.ErrorDetails.LEVEL_LOAD_ERROR:case T.ErrorDetails.LEVEL_LOAD_TIMEOUT:c&&(c.deliveryDirectives&&(d=!1),l=c.level),h=!0;break;case T.ErrorDetails.REMUX_ALLOC_ERROR:l=(u=t.level)!=null?u:this.currentLevelIndex,h=!0;break}l!==void 0&&this.recoverLevel(t,l,h,d)}},f.recoverLevel=function(i,t,u,c){var r=i.details,h=this._levels[t];if(h.loadError++,u){var d=this.retryLoadingOrFail(i);if(d)i.levelRetry=!0;else{this.currentLevelIndex=-1;return}}if(c){var l=h.url.length;if(l>1&&h.loadError<l)i.levelRetry=!0,this.redundantFailover(t);else if(this.manualLevelIndex===-1){for(var v=-1,m=this._levels,L=m.length;L--;){var b=(L+this.currentLevelIndex)%m.length;if(b!==this.currentLevelIndex&&m[b].loadError===0){v=b;break}}v>-1&&this.currentLevelIndex!==v&&(this.warn(r+": switch to "+v),i.levelRetry=!0,this.hls.nextAutoLevel=v)}}},f.redundantFailover=function(i){var t=this._levels[i],u=t.url.length;if(u>1){var c=(t.urlId+1)%u;this.warn("Switching to redundant URL-id "+c),this._levels.forEach(function(r){r.urlId=c}),this.level=i}},f.onFragLoaded=function(i,t){var u=t.frag;if(u!==void 0&&u.type===_.PlaylistLevelType.MAIN){var c=this._levels[u.level];c!==void 0&&(c.fragmentError=0,c.loadError=0)}},f.onLevelLoaded=function(i,t){var u,c=t.level,r=t.details,h=this._levels[c];if(!h){var d;this.warn("Invalid level index "+c),(d=t.deliveryDirectives)!==null&&d!==void 0&&d.skip&&(r.deltaUpdateFailed=!0);return}c===this.currentLevelIndex?(h.fragmentError===0&&(h.loadError=0,this.retryCount=0),this.playlistLoaded(c,t,h.details)):(u=t.deliveryDirectives)!==null&&u!==void 0&&u.skip&&(r.deltaUpdateFailed=!0)},f.onAudioTrackSwitched=function(i,t){var u=this.hls.levels[this.currentLevelIndex];if(!!u&&u.audioGroupIds){for(var c=-1,r=this.hls.audioTracks[t.id].groupId,h=0;h<u.audioGroupIds.length;h++)if(u.audioGroupIds[h]===r){c=h;break}c!==u.urlId&&(u.urlId=c,this.startLoad())}},f.loadPlaylist=function(i){var t=this.currentLevelIndex,u=this._levels[t];if(this.canLoad&&u&&u.url.length>0){var c=u.urlId,r=u.url[c];if(i)try{r=i.addDirectives(r)}catch(h){this.warn("Could not construct new URL with HLS Delivery Directives: "+h)}this.log("Attempt loading level index "+t+(i?" at sn "+i.msn+" part "+i.part:"")+" with URL-id "+c+" "+r),this.clearTimer(),this.hls.trigger(p.Events.LEVEL_LOADING,{url:r,level:t,id:c,deliveryDirectives:i||null})}},f.removeLevel=function(i,t){var u=function(h,d){return d!==t},c=this._levels.filter(function(r,h){return h!==i?!0:r.url.length>1&&t!==void 0?(r.url=r.url.filter(u),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(u)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(u)),r.urlId=0,!0):!1}).map(function(r,h){var d=r.details;return d!=null&&d.fragments&&d.fragments.forEach(function(l){l.level=h}),r});this._levels=c,this.hls.trigger(p.Events.LEVELS_UPDATED,{levels:c})},D(o,[{key:"levels",get:function(){return this._levels.length===0?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(i){var t,u=this._levels;if(u.length!==0&&!(this.currentLevelIndex===i&&(t=u[i])!==null&&t!==void 0&&t.details)){if(i<0||i>=u.length){var c=i<0;if(this.hls.trigger(p.Events.ERROR,{type:T.ErrorTypes.OTHER_ERROR,details:T.ErrorDetails.LEVEL_SWITCH_ERROR,level:i,fatal:c,reason:"invalid level idx"}),c)return;i=Math.min(i,u.length-1)}this.clearTimer();var r=this.currentLevelIndex,h=u[r],d=u[i];this.log("switching to level "+i+" from "+r),this.currentLevelIndex=i;var l=E({},d,{level:i,maxBitrate:d.maxBitrate,uri:d.uri,urlId:d.urlId});delete l._urlId,this.hls.trigger(p.Events.LEVEL_SWITCHING,l);var v=d.details;if(!v||v.live){var m=this.switchParams(d.uri,h==null?void 0:h.details);this.loadPlaylist(m)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(i){this.manualLevelIndex=i,this._startLevel===void 0&&(this._startLevel=i),i!==-1&&(this.level=i)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(i){this._firstLevel=i}},{key:"startLevel",get:function(){if(this._startLevel===void 0){var i=this.hls.config.startLevel;return i!==void 0?i:this._firstLevel}else return this._startLevel},set:function(i){this._startLevel=i}},{key:"nextLoadLevel",get:function(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(i){this.level=i,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=i)}}]),o}(O.default)},"./src/controller/level-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"addGroupId",function(){return S}),n.d(P,"assignTrackIdsByGroup",function(){return O}),n.d(P,"updatePTS",function(){return _}),n.d(P,"updateFragPTSDTS",function(){return A}),n.d(P,"mergeDetails",function(){return D}),n.d(P,"mapPartIntersection",function(){return g}),n.d(P,"mapFragmentIntersection",function(){return y}),n.d(P,"adjustSliding",function(){return s}),n.d(P,"addSliding",function(){return e}),n.d(P,"computeReloadInterval",function(){return o}),n.d(P,"getFragmentWithSN",function(){return f}),n.d(P,"getPartWith",function(){return a});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/logger.ts"),T=n("./src/loader/date-range.ts");function I(){return I=Object.assign?Object.assign.bind():function(i){for(var t=1;t<arguments.length;t++){var u=arguments[t];for(var c in u)Object.prototype.hasOwnProperty.call(u,c)&&(i[c]=u[c])}return i},I.apply(this,arguments)}function S(i,t,u){switch(t){case"audio":i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds.push(u);break;case"text":i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds.push(u);break}}function O(i){var t={};i.forEach(function(u){var c=u.groupId||"";u.id=t[c]=t[c]||0,t[c]++})}function _(i,t,u){var c=i[t],r=i[u];E(c,r)}function E(i,t){var u=t.startPTS;if(Object(R.isFiniteNumber)(u)){var c=0,r;t.sn>i.sn?(c=u-i.start,r=i):(c=i.start-u,r=t),r.duration!==c&&(r.duration=c)}else if(t.sn>i.sn){var h=i.cc===t.cc;h&&i.minEndPTS?t.start=i.start+(i.minEndPTS-i.start):t.start=i.start+i.duration}else t.start=Math.max(i.start-t.duration,0)}function A(i,t,u,c,r,h){var d=c-u;d<=0&&(p.logger.warn("Fragment should have a positive duration",t),c=u+t.duration,h=r+t.duration);var l=u,v=c,m=t.startPTS,L=t.endPTS;if(Object(R.isFiniteNumber)(m)){var b=Math.abs(m-u);Object(R.isFiniteNumber)(t.deltaPTS)?t.deltaPTS=Math.max(b,t.deltaPTS):t.deltaPTS=b,l=Math.max(u,m),u=Math.min(u,m),r=Math.min(r,t.startDTS),v=Math.min(c,L),c=Math.max(c,L),h=Math.max(h,t.endDTS)}t.duration=c-u;var M=u-t.start;t.appendedPTS=c,t.start=t.startPTS=u,t.maxStartPTS=l,t.startDTS=r,t.endPTS=c,t.minEndPTS=v,t.endDTS=h;var F=t.sn;if(!i||F<i.startSN||F>i.endSN)return 0;var w,C=F-i.startSN,U=i.fragments;for(U[C]=t,w=C;w>0;w--)E(U[w],U[w-1]);for(w=C;w<U.length-1;w++)E(U[w],U[w+1]);return i.fragmentHint&&E(U[U.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,M}function D(i,t){for(var u=null,c=i.fragments,r=c.length-1;r>=0;r--){var h=c[r].initSegment;if(h){u=h;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;var d=0,l;if(y(i,t,function(w,C){w.relurl&&(d=w.cc-C.cc),Object(R.isFiniteNumber)(w.startPTS)&&Object(R.isFiniteNumber)(w.endPTS)&&(C.start=C.startPTS=w.startPTS,C.startDTS=w.startDTS,C.appendedPTS=w.appendedPTS,C.maxStartPTS=w.maxStartPTS,C.endPTS=w.endPTS,C.endDTS=w.endDTS,C.minEndPTS=w.minEndPTS,C.duration=w.endPTS-w.startPTS,C.duration&&(l=C),t.PTSKnown=t.alignedSliding=!0),C.elementaryStreams=w.elementaryStreams,C.loader=w.loader,C.stats=w.stats,C.urlId=w.urlId,w.initSegment&&(C.initSegment=w.initSegment,u=w.initSegment)}),u){var v=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;v.forEach(function(w){var C;(!w.initSegment||w.initSegment.relurl===((C=u)===null||C===void 0?void 0:C.relurl))&&(w.initSegment=u)})}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(function(w){return!w}),t.deltaUpdateFailed){p.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var m=t.skippedSegments;m--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=x(i.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));var L=t.fragments;if(d){p.logger.warn("discontinuity sliding from playlist, take drift into account");for(var b=0;b<L.length;b++)L[b].cc+=d}t.skippedSegments&&(t.startCC=t.fragments[0].cc),g(i.partList,t.partList,function(w,C){C.elementaryStreams=w.elementaryStreams,C.stats=w.stats}),l?A(t,l,l.startPTS,l.endPTS,l.startDTS,l.endDTS):s(i,t),L.length&&(t.totalduration=t.edge-L[0].start),t.driftStartTime=i.driftStartTime,t.driftStart=i.driftStart;var M=t.advancedDateTime;if(t.advanced&&M){var F=t.edge;t.driftStart||(t.driftStartTime=M,t.driftStart=F),t.driftEndTime=M,t.driftEnd=F}else t.driftEndTime=i.driftEndTime,t.driftEnd=i.driftEnd,t.advancedDateTime=i.advancedDateTime}function x(i,t,u){var c=I({},i);return u&&u.forEach(function(r){delete c[r]}),Object.keys(t).forEach(function(r){var h=new T.DateRange(t[r].attr,c[r]);h.isValid?c[r]=h:p.logger.warn('Ignoring invalid Playlist Delta Update DATERANGE tag: "'+JSON.stringify(t[r].attr)+'"')}),c}function g(i,t,u){if(i&&t)for(var c=0,r=0,h=i.length;r<=h;r++){var d=i[r],l=t[r+c];d&&l&&d.index===l.index&&d.fragment.sn===l.fragment.sn?u(d,l):c--}}function y(i,t,u){for(var c=t.skippedSegments,r=Math.max(i.startSN,t.startSN)-t.startSN,h=(i.fragmentHint?1:0)+(c?t.endSN:Math.min(i.endSN,t.endSN))-t.startSN,d=t.startSN-i.startSN,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,v=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,m=r;m<=h;m++){var L=v[d+m],b=l[m];c&&!b&&m<c&&(b=t.fragments[m]=L),L&&b&&u(L,b)}}function s(i,t){var u=t.startSN+t.skippedSegments-i.startSN,c=i.fragments;u<0||u>=c.length||e(t,c[u].start)}function e(i,t){if(t){for(var u=i.fragments,c=i.skippedSegments;c<u.length;c++)u[c].start+=t;i.fragmentHint&&(i.fragmentHint.start+=t)}}function o(i,t){var u=1e3*i.levelTargetDuration,c=u/2,r=i.age,h=r>0&&r<u*3,d=t.loading.end-t.loading.start,l,v=i.availabilityDelay;if(i.updated===!1)if(h){var m=333*i.misses;l=Math.max(Math.min(c,d*2),m),i.availabilityDelay=(i.availabilityDelay||0)+l}else l=c;else h?(v=Math.min(v||u/2,r),i.availabilityDelay=v,l=v+u-r):l=u-d;return Math.round(l)}function f(i,t,u){if(!i||!i.details)return null;var c=i.details,r=c.fragments[t-c.startSN];return r||(r=c.fragmentHint,r&&r.sn===t)?r:t<c.startSN&&u&&u.sn===t?u:null}function a(i,t,u){if(!i||!i.details)return null;var c=i.details.partList;if(c)for(var r=c.length;r--;){var h=c[r];if(h.index===u&&h.fragment.sn===t)return h}return null}},"./src/controller/stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return a});var R=n("./src/polyfills/number.ts"),p=n("./src/controller/base-stream-controller.ts"),T=n("./src/is-supported.ts"),I=n("./src/events.ts"),S=n("./src/utils/buffer-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/types/loader.ts"),E=n("./src/loader/fragment.ts"),A=n("./src/demux/transmuxer-interface.ts"),D=n("./src/types/transmuxer.ts"),x=n("./src/controller/gap-controller.ts"),g=n("./src/errors.ts");function y(i,t){for(var u=0;u<t.length;u++){var c=t[u];c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(i,c.key,c)}}function s(i,t,u){return t&&y(i.prototype,t),u&&y(i,u),Object.defineProperty(i,"prototype",{writable:!1}),i}function e(i,t){i.prototype=Object.create(t.prototype),i.prototype.constructor=i,o(i,t)}function o(i,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(c,r){return c.__proto__=r,c},o(i,t)}var f=100,a=function(i){e(t,i);function t(c,r){var h;return h=i.call(this,c,r,"[stream-controller]")||this,h.audioCodecSwap=!1,h.gapController=null,h.level=-1,h._forceStartLoad=!1,h.altAudio=!1,h.audioOnly=!1,h.fragPlaying=null,h.onvplaying=null,h.onvseeked=null,h.fragLastKbps=0,h.couldBacktrack=!1,h.backtrackFragment=null,h.audioCodecSwitch=!1,h.videoBuffer=null,h._registerListeners(),h}var u=t.prototype;return u._registerListeners=function(){var r=this.hls;r.on(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.on(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.on(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.on(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.on(I.Events.LEVEL_LOADING,this.onLevelLoading,this),r.on(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.on(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.on(I.Events.ERROR,this.onError,this),r.on(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.on(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.on(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.on(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.on(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.on(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u._unregisterListeners=function(){var r=this.hls;r.off(I.Events.MEDIA_ATTACHED,this.onMediaAttached,this),r.off(I.Events.MEDIA_DETACHING,this.onMediaDetaching,this),r.off(I.Events.MANIFEST_LOADING,this.onManifestLoading,this),r.off(I.Events.MANIFEST_PARSED,this.onManifestParsed,this),r.off(I.Events.LEVEL_LOADED,this.onLevelLoaded,this),r.off(I.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),r.off(I.Events.ERROR,this.onError,this),r.off(I.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),r.off(I.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),r.off(I.Events.BUFFER_CREATED,this.onBufferCreated,this),r.off(I.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),r.off(I.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),r.off(I.Events.FRAG_BUFFERED,this.onFragBuffered,this)},u.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},u.startLoad=function(r){if(this.levels){var h=this.lastCurrentTime,d=this.hls;if(this.stopLoad(),this.setInterval(f),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var l=d.startLevel;l===-1&&(d.config.testBandwidth&&this.levels.length>1?(l=0,this.bitrateTest=!0):l=d.nextAutoLevel),this.level=d.nextLoadLevel=l,this.loadedmetadata=!1}h>0&&r===-1&&(this.log("Override startPosition with lastCurrentTime @"+h.toFixed(3)),r=h),this.state=p.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=r,this.tick()}else this._forceStartLoad=!0,this.state=p.State.STOPPED},u.stopLoad=function(){this._forceStartLoad=!1,i.prototype.stopLoad.call(this)},u.doTick=function(){switch(this.state){case p.State.IDLE:this.doTickIdle();break;case p.State.WAITING_LEVEL:{var r,h=this.levels,d=this.level,l=h==null||(r=h[d])===null||r===void 0?void 0:r.details;if(l&&(!l.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(l))break;this.state=p.State.IDLE;break}break}case p.State.FRAG_LOADING_WAITING_RETRY:{var v,m=self.performance.now(),L=this.retryDate;(!L||m>=L||(v=this.media)!==null&&v!==void 0&&v.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.level),this.state=p.State.IDLE)}break;default:break}this.onTickEnd()},u.onTickEnd=function(){i.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},u.doTickIdle=function(){var r,h,d=this.hls,l=this.levelLastLoaded,v=this.levels,m=this.media,L=d.config,b=d.nextLoadLevel;if(!(l===null||!m&&(this.startFragRequested||!L.startFragPrefetch))&&!(this.altAudio&&this.audioOnly)&&!(!v||!v[b])){var M=v[b];this.level=d.nextLoadLevel=b;var F=M.details;if(!F||this.state===p.State.WAITING_LEVEL||F.live&&this.levelLastLoaded!==b){this.state=p.State.WAITING_LEVEL;return}var w=this.getMainFwdBufferInfo();if(w!==null){var C=w.len,U=this.getMaxBufferLength(M.maxBitrate);if(!(C>=U)){if(this._streamEnded(w,F)){var k={};this.altAudio&&(k.type="video"),this.hls.trigger(I.Events.BUFFER_EOS,k),this.state=p.State.ENDED;return}this.backtrackFragment&&this.backtrackFragment.start>w.end&&(this.backtrackFragment=null);var j=this.backtrackFragment?this.backtrackFragment.start:w.end,N=this.getNextFragment(j,F);if(this.couldBacktrack&&!this.fragPrevious&&N&&N.sn!=="initSegment"&&this.fragmentTracker.getState(N)!==O.FragmentState.OK){var W,Y=((W=this.backtrackFragment)!=null?W:N).sn,K=Y-F.startSN,H=F.fragments[K-1];H&&N.cc===H.cc&&(N=H,this.fragmentTracker.removeFragment(H))}else this.backtrackFragment&&w.len&&(this.backtrackFragment=null);if(N&&this.fragmentTracker.getState(N)===O.FragmentState.OK&&this.nextLoadPosition>j){var z=this.audioOnly&&!this.altAudio?E.ElementaryStreamTypes.AUDIO:E.ElementaryStreamTypes.VIDEO;m&&this.afterBufferFlushed(m,z,_.PlaylistLevelType.MAIN),N=this.getNextFragment(this.nextLoadPosition,F)}!N||(N.initSegment&&!N.initSegment.data&&!this.bitrateTest&&(N=N.initSegment),((r=N.decryptdata)===null||r===void 0?void 0:r.keyFormat)==="identity"&&!((h=N.decryptdata)!==null&&h!==void 0&&h.key)?this.loadKey(N,F):this.loadFragment(N,F,j))}}}},u.loadFragment=function(r,h,d){var l,v=this.fragmentTracker.getState(r);this.fragCurrent=r,v===O.FragmentState.NOT_LOADED?r.sn==="initSegment"?this._loadInitSegment(r):this.bitrateTest?(this.log("Fragment "+r.sn+" of level "+r.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(r)):(this.startFragRequested=!0,i.prototype.loadFragment.call(this,r,h,d)):v===O.FragmentState.APPENDING?this.reduceMaxBufferLength(r.duration)&&this.fragmentTracker.removeFragment(r):((l=this.media)===null||l===void 0?void 0:l.buffered.length)===0&&this.fragmentTracker.removeAllFragments()},u.getAppendedFrag=function(r){var h=this.fragmentTracker.getAppendedFrag(r,_.PlaylistLevelType.MAIN);return h&&"fragment"in h?h.fragment:h},u.getBufferedFrag=function(r){return this.fragmentTracker.getBufferedFrag(r,_.PlaylistLevelType.MAIN)},u.followingBufferedFrag=function(r){return r?this.getBufferedFrag(r.end+.5):null},u.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},u.nextLevelSwitch=function(){var r=this.levels,h=this.media;if(h!=null&&h.readyState){var d,l=this.getAppendedFrag(h.currentTime);if(l&&l.start>1&&this.flushMainBuffer(0,l.start-1),!h.paused&&r){var v=this.hls.nextLoadLevel,m=r[v],L=this.fragLastKbps;L&&this.fragCurrent?d=this.fragCurrent.duration*m.maxBitrate/(1e3*L)+1:d=0}else d=0;var b=this.getBufferedFrag(h.currentTime+d);if(b){var M=this.followingBufferedFrag(b);if(M){this.abortCurrentFrag();var F=M.maxStartPTS?M.maxStartPTS:M.start,w=M.duration,C=Math.max(b.end,F+Math.min(Math.max(w-this.config.maxFragLookUpTolerance,w*.5),w*.75));this.flushMainBuffer(C,Number.POSITIVE_INFINITY)}}}},u.abortCurrentFrag=function(){var r=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,r!=null&&r.loader&&r.loader.abort(),this.state){case p.State.KEY_LOADING:case p.State.FRAG_LOADING:case p.State.FRAG_LOADING_WAITING_RETRY:case p.State.PARSING:case p.State.PARSED:this.state=p.State.IDLE;break}this.nextLoadPosition=this.getLoadPosition()},u.flushMainBuffer=function(r,h){i.prototype.flushMainBuffer.call(this,r,h,this.altAudio?"video":null)},u.onMediaAttached=function(r,h){i.prototype.onMediaAttached.call(this,r,h);var d=h.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),d.addEventListener("playing",this.onvplaying),d.addEventListener("seeked",this.onvseeked),this.gapController=new x.default(this.config,d,this.fragmentTracker,this.hls)},u.onMediaDetaching=function(){var r=this.media;r&&this.onvplaying&&this.onvseeked&&(r.removeEventListener("playing",this.onvplaying),r.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),i.prototype.onMediaDetaching.call(this)},u.onMediaPlaying=function(){this.tick()},u.onMediaSeeked=function(){var r=this.media,h=r?r.currentTime:null;Object(R.isFiniteNumber)(h)&&this.log("Media seeked to "+h.toFixed(3)),this.tick()},u.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(I.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null,this.backtrackFragment=null},u.onManifestParsed=function(r,h){var d=!1,l=!1,v;h.levels.forEach(function(m){v=m.audioCodec,v&&(v.indexOf("mp4a.40.2")!==-1&&(d=!0),v.indexOf("mp4a.40.5")!==-1&&(l=!0))}),this.audioCodecSwitch=d&&l&&!Object(T.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=h.levels,this.startFragRequested=!1},u.onLevelLoading=function(r,h){var d=this.levels;if(!(!d||this.state!==p.State.IDLE)){var l=d[h.level];(!l.details||l.details.live&&this.levelLastLoaded!==h.level||this.waitForCdnTuneIn(l.details))&&(this.state=p.State.WAITING_LEVEL)}},u.onLevelLoaded=function(r,h){var d,l=this.levels,v=h.level,m=h.details,L=m.totalduration;if(!l){this.warn("Levels were reset while loading level "+v);return}this.log("Level "+v+" loaded ["+m.startSN+","+m.endSN+"], cc ["+m.startCC+", "+m.endCC+"] duration:"+L);var b=this.fragCurrent;b&&(this.state===p.State.FRAG_LOADING||this.state===p.State.FRAG_LOADING_WAITING_RETRY)&&b.level!==h.level&&b.loader&&(this.state=p.State.IDLE,this.backtrackFragment=null,b.loader.abort());var M=l[v],F=0;if(m.live||(d=M.details)!==null&&d!==void 0&&d.live){if(m.fragments[0]||(m.deltaUpdateFailed=!0),m.deltaUpdateFailed)return;F=this.alignPlaylists(m,M.details)}if(M.details=m,this.levelLastLoaded=v,this.hls.trigger(I.Events.LEVEL_UPDATED,{details:m,level:v}),this.state===p.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(m))return;this.state=p.State.IDLE}this.startFragRequested?m.live&&this.synchronizeToLiveEdge(m):this.setStartPosition(m,F),this.tick()},u._handleFragmentLoadProgress=function(r){var h,d=r.frag,l=r.part,v=r.payload,m=this.levels;if(!m){this.warn("Levels were reset while fragment load was in progress. Fragment "+d.sn+" of level "+d.level+" will not be buffered");return}var L=m[d.level],b=L.details;if(!b){this.warn("Dropping fragment "+d.sn+" of level "+d.level+" after level details were reset");return}var M=L.videoCodec,F=b.PTSKnown||!b.live,w=(h=d.initSegment)===null||h===void 0?void 0:h.data,C=this._getAudioCodec(L),U=this.transmuxer=this.transmuxer||new A.default(this.hls,_.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=l?l.index:-1,j=k!==-1,N=new D.ChunkMetadata(d.level,d.sn,d.stats.chunkCount,v.byteLength,k,j),W=this.initPTS[d.cc];U.push(v,w,C,M,d,l,b.totalduration,F,N,W)},u.onAudioTrackSwitching=function(r,h){var d=this.altAudio,l=!!h.url,v=h.id;if(!l){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var m=this.fragCurrent;m!=null&&m.loader&&(this.log("Switching to main audio track, cancel main fragment load"),m.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var L=this.hls;d&&L.trigger(I.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),L.trigger(I.Events.AUDIO_TRACK_SWITCHED,{id:v})}},u.onAudioTrackSwitched=function(r,h){var d=h.id,l=!!this.hls.audioTracks[d].url;if(l){var v=this.videoBuffer;v&&this.mediaBuffer!==v&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=v)}this.altAudio=l,this.tick()},u.onBufferCreated=function(r,h){var d=h.tracks,l,v,m=!1;for(var L in d){var b=d[L];if(b.id==="main"){if(v=L,l=b,L==="video"){var M=d[L];M&&(this.videoBuffer=M.buffer)}}else m=!0}m&&l?(this.log("Alternate track found, use "+v+".buffered to schedule main fragment loading"),this.mediaBuffer=l.buffer):this.mediaBuffer=this.media},u.onFragBuffered=function(r,h){var d=h.frag,l=h.part;if(!(d&&d.type!==_.PlaylistLevelType.MAIN)){if(this.fragContextChanged(d)){this.warn("Fragment "+d.sn+(l?" p: "+l.index:"")+" of level "+d.level+" finished buffering, but was aborted. state: "+this.state),this.state===p.State.PARSED&&(this.state=p.State.IDLE);return}var v=l?l.stats:d.stats;this.fragLastKbps=Math.round(8*v.total/(v.buffering.end-v.loading.first)),d.sn!=="initSegment"&&(this.fragPrevious=d),this.fragBufferedComplete(d,l)}},u.onError=function(r,h){switch(h.details){case g.ErrorDetails.FRAG_LOAD_ERROR:case g.ErrorDetails.FRAG_LOAD_TIMEOUT:case g.ErrorDetails.KEY_LOAD_ERROR:case g.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(_.PlaylistLevelType.MAIN,h);break;case g.ErrorDetails.LEVEL_LOAD_ERROR:case g.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==p.State.ERROR&&(h.fatal?(this.warn(""+h.details),this.state=p.State.ERROR):!h.levelRetry&&this.state===p.State.WAITING_LEVEL&&(this.state=p.State.IDLE));break;case g.ErrorDetails.BUFFER_FULL_ERROR:if(h.parent==="main"&&(this.state===p.State.PARSING||this.state===p.State.PARSED)){var d=!0,l=this.getFwdBufferInfo(this.media,_.PlaylistLevelType.MAIN);l&&l.len>.5&&(d=!this.reduceMaxBufferLength(l.len)),d&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}break;default:break}},u.checkBuffer=function(){var r=this.media,h=this.gapController;if(!(!r||!h||!r.readyState)){if(this.loadedmetadata||!S.BufferHelper.getBuffered(r).length){var d=this.state!==p.State.IDLE?this.fragCurrent:null;h.poll(this.lastCurrentTime,d)}this.lastCurrentTime=r.currentTime}},u.onFragLoadEmergencyAborted=function(){this.state=p.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},u.onBufferFlushed=function(r,h){var d=h.type;if(d!==E.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio){var l=(d===E.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(l,d,_.PlaylistLevelType.MAIN)}},u.onLevelsUpdated=function(r,h){this.levels=h.levels},u.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},u.seekToStartPos=function(){var r=this.media;if(!!r){var h=r.currentTime,d=this.startPosition;if(d>=0&&h<d){if(r.seeking){this.log("could not seek to "+d+", already seeking at "+h);return}var l=S.BufferHelper.getBuffered(r),v=l.length?l.start(0):0,m=v-d;m>0&&(m<this.config.maxBufferHole||m<this.config.maxFragLookUpTolerance)&&(this.log("adjusting start position by "+m+" to match buffer start"),d+=m,this.startPosition=d),this.log("seek to target start position "+d+" from current time "+h),r.currentTime=d}}},u._getAudioCodec=function(r){var h=this.config.defaultAudioCodec||r.audioCodec;return this.audioCodecSwap&&h&&(this.log("Swapping audio codec"),h.indexOf("mp4a.40.5")!==-1?h="mp4a.40.2":h="mp4a.40.5"),h},u._loadBitrateTestFrag=function(r){var h=this;r.bitrateTest=!0,this._doFragLoad(r).then(function(d){var l=h.hls;if(!(!d||l.nextLoadLevel||h.fragContextChanged(r))){h.fragLoadError=0,h.state=p.State.IDLE,h.startFragRequested=!1,h.bitrateTest=!1;var v=r.stats;v.parsing.start=v.parsing.end=v.buffering.start=v.buffering.end=self.performance.now(),l.trigger(I.Events.FRAG_LOADED,d),r.bitrateTest=!1}})},u._handleTransmuxComplete=function(r){var h,d="main",l=this.hls,v=r.remuxResult,m=r.chunkMeta,L=this.getCurrentContext(m);if(!L){this.warn("The loading context changed while buffering fragment "+m.sn+" of level "+m.level+". This chunk will not be buffered."),this.resetStartWhenNotLoaded(m.level);return}var b=L.frag,M=L.part,F=L.level,w=v.video,C=v.text,U=v.id3,k=v.initSegment,j=F.details,N=this.altAudio?void 0:v.audio;if(!this.fragContextChanged(b)){if(this.state=p.State.PARSING,k){k.tracks&&(this._bufferInitSegment(F,k.tracks,b,m),l.trigger(I.Events.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:d,tracks:k.tracks}));var W=k.initPTS,Y=k.timescale;Object(R.isFiniteNumber)(W)&&(this.initPTS[b.cc]=W,l.trigger(I.Events.INIT_PTS_FOUND,{frag:b,id:d,initPTS:W,timescale:Y}))}if(w&&v.independent!==!1){if(j){var K=w.startPTS,H=w.endPTS,z=w.startDTS,$=w.endDTS;if(M)M.elementaryStreams[w.type]={startPTS:K,endPTS:H,startDTS:z,endDTS:$};else if(w.firstKeyFrame&&w.independent&&(this.couldBacktrack=!0),w.dropped&&w.independent){var X=this.getMainFwdBufferInfo(),J=(X?X.end:this.getLoadPosition())+this.config.maxBufferHole,te=w.firstKeyFramePTS?w.firstKeyFramePTS:K;if(J<te-this.config.maxBufferHole){this.backtrack(b);return}b.setElementaryStreamInfo(w.type,b.start,H,b.start,$,!0)}b.setElementaryStreamInfo(w.type,K,H,z,$),this.backtrackFragment&&(this.backtrackFragment=b),this.bufferFragmentData(w,b,M,m)}}else if(v.independent===!1){this.backtrack(b);return}if(N){var Q=N.startPTS,ae=N.endPTS,se=N.startDTS,re=N.endDTS;M&&(M.elementaryStreams[E.ElementaryStreamTypes.AUDIO]={startPTS:Q,endPTS:ae,startDTS:se,endDTS:re}),b.setElementaryStreamInfo(E.ElementaryStreamTypes.AUDIO,Q,ae,se,re),this.bufferFragmentData(N,b,M,m)}if(j&&U!==null&&U!==void 0&&(h=U.samples)!==null&&h!==void 0&&h.length){var ee={id:d,frag:b,details:j,samples:U.samples};l.trigger(I.Events.FRAG_PARSING_METADATA,ee)}if(j&&C){var Z={id:d,frag:b,details:j,samples:C.samples};l.trigger(I.Events.FRAG_PARSING_USERDATA,Z)}}},u._bufferInitSegment=function(r,h,d,l){var v=this;if(this.state===p.State.PARSING){this.audioOnly=!!h.audio&&!h.video,this.altAudio&&!this.audioOnly&&delete h.audio;var m=h.audio,L=h.video,b=h.audiovideo;if(m){var M=r.audioCodec,F=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(M&&(M.indexOf("mp4a.40.5")!==-1?M="mp4a.40.2":M="mp4a.40.5"),m.metadata.channelCount!==1&&F.indexOf("firefox")===-1&&(M="mp4a.40.5")),F.indexOf("android")!==-1&&m.container!=="audio/mpeg"&&(M="mp4a.40.2",this.log("Android: force audio codec to "+M)),r.audioCodec&&r.audioCodec!==M&&this.log('Swapping manifest audio codec "'+r.audioCodec+'" for "'+M+'"'),m.levelCodec=M,m.id="main",this.log("Init audio buffer, container:"+m.container+", codecs[selected/level/parsed]=["+(M||"")+"/"+(r.audioCodec||"")+"/"+m.codec+"]")}L&&(L.levelCodec=r.videoCodec,L.id="main",this.log("Init video buffer, container:"+L.container+", codecs[level/parsed]=["+(r.videoCodec||"")+"/"+L.codec+"]")),b&&this.log("Init audiovideo buffer, container:"+b.container+", codecs[level/parsed]=["+(r.attrs.CODECS||"")+"/"+b.codec+"]"),this.hls.trigger(I.Events.BUFFER_CODECS,h),Object.keys(h).forEach(function(w){var C=h[w],U=C.initSegment;U!=null&&U.byteLength&&v.hls.trigger(I.Events.BUFFER_APPENDING,{type:w,data:U,frag:d,part:null,chunkMeta:l,parent:d.type})}),this.tick()}},u.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,_.PlaylistLevelType.MAIN)},u.backtrack=function(r){this.couldBacktrack=!0,this.backtrackFragment=r,this.resetTransmuxer(),this.flushBufferGap(r),this.fragmentTracker.removeFragment(r),this.fragPrevious=null,this.nextLoadPosition=r.start,this.state=p.State.IDLE},u.checkFragmentChanged=function(){var r=this.media,h=null;if(r&&r.readyState>1&&r.seeking===!1){var d=r.currentTime;if(S.BufferHelper.isBuffered(r,d)?h=this.getAppendedFrag(d):S.BufferHelper.isBuffered(r,d+.1)&&(h=this.getAppendedFrag(d+.1)),h){this.backtrackFragment=null;var l=this.fragPlaying,v=h.level;(!l||h.sn!==l.sn||l.level!==v||h.urlId!==l.urlId)&&(this.hls.trigger(I.Events.FRAG_CHANGED,{frag:h}),(!l||l.level!==v)&&this.hls.trigger(I.Events.LEVEL_SWITCHED,{level:v}),this.fragPlaying=h)}}},s(t,[{key:"nextLevel",get:function(){var r=this.nextBufferedFrag;return r?r.level:-1}},{key:"currentFrag",get:function(){var r=this.media;return r?this.fragPlaying||this.getAppendedFrag(r.currentTime):null}},{key:"currentProgramDateTime",get:function(){var r=this.media;if(r){var h=r.currentTime,d=this.currentFrag;if(d&&Object(R.isFiniteNumber)(h)&&Object(R.isFiniteNumber)(d.programDateTime)){var l=d.programDateTime+(h-d.start)*1e3;return new Date(l)}}return null}},{key:"currentLevel",get:function(){var r=this.currentFrag;return r?r.level:-1}},{key:"nextBufferedFrag",get:function(){var r=this.currentFrag;return r?this.followingBufferedFrag(r):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),t}(p.default)},"./src/controller/subtitle-stream-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"SubtitleStreamController",function(){return e});var R=n("./src/events.ts"),p=n("./src/utils/buffer-helper.ts"),T=n("./src/controller/fragment-finders.ts"),I=n("./src/utils/discontinuities.ts"),S=n("./src/controller/level-helper.ts"),O=n("./src/controller/fragment-tracker.ts"),_=n("./src/controller/base-stream-controller.ts"),E=n("./src/types/loader.ts"),A=n("./src/types/level.ts");function D(f,a){for(var i=0;i<a.length;i++){var t=a[i];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(f,t.key,t)}}function x(f,a,i){return a&&D(f.prototype,a),i&&D(f,i),Object.defineProperty(f,"prototype",{writable:!1}),f}function g(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,y(f,a)}function y(f,a){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},y(f,a)}var s=500,e=function(f){g(a,f);function a(t,u){var c;return c=f.call(this,t,u,"[subtitle-stream-controller]")||this,c.levels=[],c.currentTrackId=-1,c.tracksBuffered=[],c.mainDetails=null,c._registerListeners(),c}var i=a.prototype;return i.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},i._registerListeners=function(){var u=this.hls;u.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.on(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.on(R.Events.ERROR,this.onError,this),u.on(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.on(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.on(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.on(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var u=this.hls;u.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),u.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),u.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),u.off(R.Events.LEVEL_LOADED,this.onLevelLoaded,this),u.off(R.Events.ERROR,this.onError,this),u.off(R.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),u.off(R.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),u.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),u.off(R.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),u.off(R.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.startLoad=function(){this.stopLoad(),this.state=_.State.IDLE,this.setInterval(s),this.tick()},i.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},i.onLevelLoaded=function(u,c){this.mainDetails=c.details},i.onSubtitleFragProcessed=function(u,c){var r=c.frag,h=c.success;if(this.fragPrevious=r,this.state=_.State.IDLE,!!h){var d=this.tracksBuffered[this.currentTrackId];if(!!d){for(var l,v=r.start,m=0;m<d.length;m++)if(v>=d[m].start&&v<=d[m].end){l=d[m];break}var L=r.start+r.duration;l?l.end=L:(l={start:v,end:L},d.push(l)),this.fragmentTracker.fragBuffered(r)}}},i.onBufferFlushing=function(u,c){var r=c.startOffset,h=c.endOffset;if(r===0&&h!==Number.POSITIVE_INFINITY){var d=this.currentTrackId,l=this.levels;if(!l.length||!l[d]||!l[d].details)return;var v=l[d].details,m=v.targetduration,L=h-m;if(L<=0)return;c.endOffsetSubtitles=Math.max(0,L),this.tracksBuffered.forEach(function(b){for(var M=0;M<b.length;){if(b[M].end<=L){b.shift();continue}else if(b[M].start<L)b[M].start=L;else break;M++}}),this.fragmentTracker.removeFragmentsInRange(r,L,E.PlaylistLevelType.SUBTITLE)}},i.onError=function(u,c){var r,h=c.frag;!h||h.type!==E.PlaylistLevelType.SUBTITLE||((r=this.fragCurrent)!==null&&r!==void 0&&r.loader&&this.fragCurrent.loader.abort(),this.state=_.State.IDLE)},i.onSubtitleTracksUpdated=function(u,c){var r=this,h=c.subtitleTracks;this.tracksBuffered=[],this.levels=h.map(function(d){return new A.Level(d)}),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach(function(d){r.tracksBuffered[d.id]=[]}),this.mediaBuffer=null},i.onSubtitleTrackSwitch=function(u,c){if(this.currentTrackId=c.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}var r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(s)},i.onSubtitleTrackLoaded=function(u,c){var r,h=c.details,d=c.id,l=this.currentTrackId,v=this.levels;if(!!v.length){var m=v[l];if(!(d>=v.length||d!==l||!m)){if(this.mediaBuffer=this.mediaBufferTimeRanges,h.live||(r=m.details)!==null&&r!==void 0&&r.live){var L=this.mainDetails;if(h.deltaUpdateFailed||!L)return;var b=L.fragments[0];if(!m.details)h.hasProgramDateTime&&L.hasProgramDateTime?Object(I.alignMediaPlaylistByPDT)(h,L):b&&Object(S.addSliding)(h,b.start);else{var M=this.alignPlaylists(h,m.details);M===0&&b&&Object(S.addSliding)(h,b.start)}}if(m.details=h,this.levelLastLoaded=d,this.tick(),h.live&&!this.fragCurrent&&this.media&&this.state===_.State.IDLE){var F=Object(T.findFragmentByPTS)(null,h.fragments,this.media.currentTime,0);F||(this.warn("Subtitle playlist not aligned with playback"),m.details=void 0)}}}},i._handleFragmentLoadComplete=function(u){var c=u.frag,r=u.payload,h=c.decryptdata,d=this.hls;if(!this.fragContextChanged(c)&&r&&r.byteLength>0&&h&&h.key&&h.iv&&h.method==="AES-128"){var l=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(r),h.key.buffer,h.iv.buffer).then(function(v){var m=performance.now();d.trigger(R.Events.FRAG_DECRYPTED,{frag:c,payload:v,stats:{tstart:l,tdecrypt:m}})})}},i.doTick=function(){if(!this.media){this.state=_.State.IDLE;return}if(this.state===_.State.IDLE){var u=this.currentTrackId,c=this.levels;if(!c.length||!c[u]||!c[u].details)return;var r=c[u].details,h=r.targetduration,d=this.config,l=this.media,v=p.BufferHelper.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],l.currentTime-h,d.maxBufferHole),m=v.end,L=v.len,b=this.getMaxBufferLength()+h;if(L>b)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var M=r.fragments,F=M.length,w=r.edge,C,U=this.fragPrevious;if(m<w){var k=d.maxFragLookUpTolerance;C=Object(T.findFragmentByPTS)(U,M,Math.max(M[0].start,m),k),!C&&U&&U.start<M[0].start&&(C=M[0])}else C=M[F-1];if(C=this.mapToInitFragWhenRequired(C),!C||this.fragmentTracker.getState(C)!==O.FragmentState.NOT_LOADED)return;C.encrypted?this.loadKey(C,r):this.loadFragment(C,r,m)}},i.loadFragment=function(u,c,r){this.fragCurrent=u,u.sn==="initSegment"?this._loadInitSegment(u):f.prototype.loadFragment.call(this,u,c,r)},x(a,[{key:"mediaBufferTimeRanges",get:function(){return new o(this.tracksBuffered[this.currentTrackId]||[])}}]),a}(_.default),o=function(a){this.buffered=void 0;var i=function(u,c,r){if(c=c>>>0,c>r-1)throw new DOMException("Failed to execute '"+u+"' on 'TimeRanges': The index provided ("+c+") is greater than the maximum bound ("+r+")");return a[c][u]};this.buffered={get length(){return a.length},end:function(u){return i("end",u,a.length)},start:function(u){return i("start",u,a.length)}}}},"./src/controller/subtitle-track-controller.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/events.ts"),p=n("./src/utils/texttrack-utils.ts"),T=n("./src/controller/base-playlist-controller.ts"),I=n("./src/types/loader.ts");function S(x,g){for(var y=0;y<g.length;y++){var s=g[y];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(x,s.key,s)}}function O(x,g,y){return g&&S(x.prototype,g),y&&S(x,y),Object.defineProperty(x,"prototype",{writable:!1}),x}function _(x,g){x.prototype=Object.create(g.prototype),x.prototype.constructor=x,E(x,g)}function E(x,g){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,e){return s.__proto__=e,s},E(x,g)}var A=function(x){_(g,x);function g(s){var e;return e=x.call(this,s,"[subtitle-track-controller]")||this,e.media=null,e.tracks=[],e.groupId=null,e.tracksInGroup=[],e.trackId=-1,e.selectDefaultTrack=!0,e.queuedDefaultTrack=-1,e.trackChangeListener=function(){return e.onTextTracksChanged()},e.asyncPollTrackChange=function(){return e.pollTrackChange(0)},e.useTextTrackPolling=!1,e.subtitlePollingInterval=-1,e._subtitleDisplay=!0,e.registerListeners(),e}var y=g.prototype;return y.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,x.prototype.destroy.call(this)},y.registerListeners=function(){var e=this.hls;e.on(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.on(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(R.Events.ERROR,this.onError,this)},y.unregisterListeners=function(){var e=this.hls;e.off(R.Events.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(R.Events.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(R.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(R.Events.MANIFEST_PARSED,this.onManifestParsed,this),e.off(R.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(R.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(R.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(R.Events.ERROR,this.onError,this)},y.onMediaAttached=function(e,o){this.media=o.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},y.pollTrackChange=function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)},y.onMediaDetaching=function(){if(!!this.media){self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);var e=D(this.media.textTracks);e.forEach(function(o){Object(p.clearCurrentCues)(o)}),this.subtitleTrack=-1,this.media=null}},y.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},y.onManifestParsed=function(e,o){this.tracks=o.subtitleTracks},y.onSubtitleTrackLoaded=function(e,o){var f=o.id,a=o.details,i=this.trackId,t=this.tracksInGroup[i];if(!t){this.warn("Invalid subtitle track id "+f);return}var u=t.details;t.details=o.details,this.log("subtitle track "+f+" loaded ["+a.startSN+"-"+a.endSN+"]"),f===this.trackId&&(this.retryCount=0,this.playlistLoaded(f,o,u))},y.onLevelLoading=function(e,o){this.switchLevel(o.level)},y.onLevelSwitching=function(e,o){this.switchLevel(o.level)},y.switchLevel=function(e){var o=this.hls.levels[e];if(!!(o!=null&&o.textGroupIds)){var f=o.textGroupIds[o.urlId];if(this.groupId!==f){var a=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,i=this.tracks.filter(function(c){return!f||c.groupId===f});this.tracksInGroup=i;var t=this.findTrackId(a==null?void 0:a.name)||this.findTrackId();this.groupId=f;var u={subtitleTracks:i};this.log("Updating subtitle tracks, "+i.length+' track(s) found in "'+f+'" group-id'),this.hls.trigger(R.Events.SUBTITLE_TRACKS_UPDATED,u),t!==-1&&this.setSubtitleTrack(t,a)}}},y.findTrackId=function(e){for(var o=this.tracksInGroup,f=0;f<o.length;f++){var a=o[f];if((!this.selectDefaultTrack||a.default)&&(!e||e===a.name))return a.id}return-1},y.onError=function(e,o){x.prototype.onError.call(this,e,o),!(o.fatal||!o.context)&&o.context.type===I.PlaylistContextType.SUBTITLE_TRACK&&o.context.id===this.trackId&&o.context.groupId===this.groupId&&this.retryLoadingOrFail(o)},y.loadPlaylist=function(e){var o=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(o)){var f=o.id,a=o.groupId,i=o.url;if(e)try{i=e.addDirectives(i)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+f),this.hls.trigger(R.Events.SUBTITLE_TRACK_LOADING,{url:i,id:f,groupId:a,deliveryDirectives:e||null})}},y.toggleTrackModes=function(e){var o=this,f=this.media,a=this.trackId;if(!!f){var i=D(f.textTracks),t=i.filter(function(r){return r.groupId===o.groupId});if(e===-1)[].slice.call(i).forEach(function(r){r.mode="disabled"});else{var u=t[a];u&&(u.mode="disabled")}var c=t[e];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}},y.setSubtitleTrack=function(e,o){var f,a=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),!(this.trackId===e&&(e===-1||(f=a[e])!==null&&f!==void 0&&f.details)||e<-1||e>=a.length)){this.clearTimer();var i=a[e];if(this.log("Switching to subtitle track "+e),this.trackId=e,i){var t=i.id,u=i.groupId,c=u===void 0?"":u,r=i.name,h=i.type,d=i.url;this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:t,groupId:c,name:r,type:h,url:d});var l=this.switchParams(i.url,o==null?void 0:o.details);this.loadPlaylist(l)}else this.hls.trigger(R.Events.SUBTITLE_TRACK_SWITCH,{id:e})}},y.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!(!this.media||!this.hls.config.renderTextTracksNatively)){for(var e=-1,o=D(this.media.textTracks),f=0;f<o.length;f++)if(o[f].mode==="hidden")e=f;else if(o[f].mode==="showing"){e=f;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}},O(g,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1;var o=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,o)}}]),g}(T.default);function D(x){for(var g=[],y=0;y<x.length;y++){var s=x[y];s.kind==="subtitles"&&s.label&&g.push(x[y])}return g}P.default=A},"./src/controller/timeline-controller.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"TimelineController",function(){return x});var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/utils/cea-608-parser.ts"),I=n("./src/utils/output-filter.ts"),S=n("./src/utils/webvtt-parser.ts"),O=n("./src/utils/texttrack-utils.ts"),_=n("./src/utils/imsc1-ttml-parser.ts"),E=n("./src/utils/mp4-tools.ts"),A=n("./src/types/loader.ts"),D=n("./src/utils/logger.ts"),x=function(){function e(f){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=s(),this.captionsProperties=void 0,this.hls=f,this.config=f.config,this.Cues=f.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var a=new I.default(this,"textTrack1"),i=new I.default(this,"textTrack2"),t=new I.default(this,"textTrack3"),u=new I.default(this,"textTrack4");this.cea608Parser1=new T.default(1,a,i),this.cea608Parser2=new T.default(3,t,u)}f.on(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),f.on(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),f.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),f.on(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),f.on(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),f.on(p.Events.FRAG_LOADING,this.onFragLoading,this),f.on(p.Events.FRAG_LOADED,this.onFragLoaded,this),f.on(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),f.on(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),f.on(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),f.on(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),f.on(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var o=e.prototype;return o.destroy=function(){var a=this.hls;a.off(p.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),a.off(p.Events.MEDIA_DETACHING,this.onMediaDetaching,this),a.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),a.off(p.Events.MANIFEST_LOADED,this.onManifestLoaded,this),a.off(p.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),a.off(p.Events.FRAG_LOADING,this.onFragLoading,this),a.off(p.Events.FRAG_LOADED,this.onFragLoaded,this),a.off(p.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),a.off(p.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),a.off(p.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),a.off(p.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),a.off(p.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},o.addCues=function(a,i,t,u,c){for(var r=!1,h=c.length;h--;){var d=c[h],l=y(d[0],d[1],i,t);if(l>=0&&(d[0]=Math.min(d[0],i),d[1]=Math.max(d[1],t),r=!0,l/(t-i)>.5))return}if(r||c.push([i,t]),this.config.renderTextTracksNatively){var v=this.captionsTracks[a];this.Cues.newCue(v,i,t,u)}else{var m=this.Cues.newCue(null,i,t,u);this.hls.trigger(p.Events.CUES_PARSED,{type:"captions",cues:m,track:a})}},o.onInitPtsFound=function(a,i){var t=this,u=i.frag,c=i.id,r=i.initPTS,h=i.timescale,d=this.unparsedVttFrags;c==="main"&&(this.initPTS[u.cc]=r,this.timescale[u.cc]=h),d.length&&(this.unparsedVttFrags=[],d.forEach(function(l){t.onFragLoaded(p.Events.FRAG_LOADED,l)}))},o.getExistingTrack=function(a){var i=this.media;if(i)for(var t=0;t<i.textTracks.length;t++){var u=i.textTracks[t];if(u[a])return u}return null},o.createCaptionsTrack=function(a){this.config.renderTextTracksNatively?this.createNativeTrack(a):this.createNonNativeTrack(a)},o.createNativeTrack=function(a){if(!this.captionsTracks[a]){var i=this.captionsProperties,t=this.captionsTracks,u=this.media,c=i[a],r=c.label,h=c.languageCode,d=this.getExistingTrack(a);if(d)t[a]=d,Object(O.clearCurrentCues)(t[a]),Object(O.sendAddTrackEvent)(t[a],u);else{var l=this.createTextTrack("captions",r,h);l&&(l[a]=!0,t[a]=l)}}},o.createNonNativeTrack=function(a){if(!this.nonNativeCaptionsTracks[a]){var i=this.captionsProperties[a];if(!!i){var t=i.label,u={_id:a,label:t,kind:"captions",default:i.media?!!i.media.default:!1,closedCaptions:i.media};this.nonNativeCaptionsTracks[a]=u,this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[u]})}}},o.createTextTrack=function(a,i,t){var u=this.media;if(!!u)return u.addTextTrack(a,i,t)},o.onMediaAttaching=function(a,i){this.media=i.media,this._cleanTracks()},o.onMediaDetaching=function(){var a=this.captionsTracks;Object.keys(a).forEach(function(i){Object(O.clearCurrentCues)(a[i]),delete a[i]}),this.nonNativeCaptionsTracks={}},o.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=s(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},o._cleanTracks=function(){var a=this.media;if(!!a){var i=a.textTracks;if(i)for(var t=0;t<i.length;t++)Object(O.clearCurrentCues)(i[t])}},o.onSubtitleTracksUpdated=function(a,i){var t=this;this.textTracks=[];var u=i.subtitleTracks||[],c=u.some(function(l){return l.textCodec===_.IMSC1_CODEC});if(this.config.enableWebVTT||c&&this.config.enableIMSC1){var r=this.tracks&&u&&this.tracks.length===u.length;if(this.tracks=u||[],this.config.renderTextTracksNatively){var h=this.media?this.media.textTracks:[];this.tracks.forEach(function(l,v){var m;if(v<h.length){for(var L=null,b=0;b<h.length;b++)if(g(h[b],l)){L=h[b];break}L&&(m=L)}if(m)Object(O.clearCurrentCues)(m);else{var M=t._captionsOrSubtitlesFromCharacteristics(l);m=t.createTextTrack(M,l.name,l.lang),m&&(m.mode="disabled")}m&&(m.groupId=l.groupId,t.textTracks.push(m))})}else if(!r&&this.tracks&&this.tracks.length){var d=this.tracks.map(function(l){return{label:l.name,kind:l.type.toLowerCase(),default:l.default,subtitleTrack:l}});this.hls.trigger(p.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:d})}}},o._captionsOrSubtitlesFromCharacteristics=function(a){var i;if((i=a.attrs)!==null&&i!==void 0&&i.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(a.attrs.CHARACTERISTICS),u=/describes-music-and-sound/gi.test(a.attrs.CHARACTERISTICS);if(t&&u)return"captions"}return"subtitles"},o.onManifestLoaded=function(a,i){var t=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach(function(u){var c=/(?:CC|SERVICE)([1-4])/.exec(u.instreamId);if(!!c){var r="textTrack"+c[1],h=t.captionsProperties[r];!h||(h.label=u.name,u.lang&&(h.languageCode=u.lang),h.media=u)}})},o.onFragLoading=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2,c=this.lastSn,r=this.lastPartIndex;if(!(!this.enabled||!(t&&u))&&i.frag.type===A.PlaylistLevelType.MAIN){var h,d,l=i.frag.sn,v=(h=i==null||(d=i.part)===null||d===void 0?void 0:d.index)!=null?h:-1;l===c+1||l===c&&v===r+1||(t.reset(),u.reset()),this.lastSn=l,this.lastPartIndex=v}},o.onFragLoaded=function(a,i){var t=i.frag,u=i.payload,c=this.initPTS,r=this.unparsedVttFrags;if(t.type===A.PlaylistLevelType.SUBTITLE)if(u.byteLength){if(!Object(R.isFiniteNumber)(c[t.cc])){r.push(i),c.length&&this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Missing initial subtitle PTS")});return}var h=t.decryptdata,d="stats"in i;if(h==null||h.key==null||h.method!=="AES-128"||d){var l=this.tracks[t.level],v=this.vttCCs;v[t.cc]||(v[t.cc]={start:t.start,prevCC:this.prevCC,new:!0},this.prevCC=t.cc),l&&l.textCodec===_.IMSC1_CODEC?this._parseIMSC1(t,u):this._parseVTTs(t,u,v)}}else this.hls.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:new Error("Empty subtitle payload")})},o._parseIMSC1=function(a,i){var t=this,u=this.hls;Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(c){t._appendCues(c,a.level),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(c){D.logger.log("Failed to parse IMSC1: "+c),u.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:c})})},o._parseVTTs=function(a,i,t){var u,c=this,r=this.hls,h=(u=a.initSegment)!==null&&u!==void 0&&u.data?Object(E.appendUint8Array)(a.initSegment.data,new Uint8Array(i)):i;Object(S.parseWebVTT)(h,this.initPTS[a.cc],this.timescale[a.cc],t,a.cc,a.start,function(d){c._appendCues(d,a.level),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:a})},function(d){c._fallbackToIMSC1(a,i),D.logger.log("Failed to parse VTT cue: "+d),r.trigger(p.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:a,error:d})})},o._fallbackToIMSC1=function(a,i){var t=this,u=this.tracks[a.level];u.textCodec||Object(_.parseIMSC1)(i,this.initPTS[a.cc],this.timescale[a.cc],function(){u.textCodec=_.IMSC1_CODEC,t._parseIMSC1(a,i)},function(){u.textCodec="wvtt"})},o._appendCues=function(a,i){var t=this.hls;if(this.config.renderTextTracksNatively){var u=this.textTracks[i];if(!u||u.mode==="disabled")return;a.forEach(function(h){return Object(O.addCueToTrack)(u,h)})}else{var c=this.tracks[i];if(!c)return;var r=c.default?"default":"subtitles"+i;t.trigger(p.Events.CUES_PARSED,{type:"subtitles",cues:a,track:r})}},o.onFragDecrypted=function(a,i){var t=i.frag;if(t.type===A.PlaylistLevelType.SUBTITLE){if(!Object(R.isFiniteNumber)(this.initPTS[t.cc])){this.unparsedVttFrags.push(i);return}this.onFragLoaded(p.Events.FRAG_LOADED,i)}},o.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},o.onFragParsingUserdata=function(a,i){var t=this.cea608Parser1,u=this.cea608Parser2;if(!(!this.enabled||!(t&&u)))for(var c=0;c<i.samples.length;c++){var r=i.samples[c].bytes;if(r){var h=this.extractCea608Data(r);t.addData(i.samples[c].pts,h[0]),u.addData(i.samples[c].pts,h[1])}}},o.onBufferFlushing=function(a,i){var t=i.startOffset,u=i.endOffset,c=i.endOffsetSubtitles,r=i.type,h=this.media;if(!(!h||h.currentTime<u)){if(!r||r==="video"){var d=this.captionsTracks;Object.keys(d).forEach(function(v){return Object(O.removeCuesInRange)(d[v],t,u)})}if(this.config.renderTextTracksNatively&&t===0&&c!==void 0){var l=this.textTracks;Object.keys(l).forEach(function(v){return Object(O.removeCuesInRange)(l[v],t,c)})}}},o.extractCea608Data=function(a){for(var i=[[],[]],t=a[0]&31,u=2,c=0;c<t;c++){var r=a[u++],h=127&a[u++],d=127&a[u++];if(!(h===0&&d===0)){var l=(4&r)!==0;if(l){var v=3&r;(v===0||v===1)&&(i[v].push(h),i[v].push(d))}}}return i},e}();function g(e,o){return e&&e.label===o.name&&!(e.textTrack1||e.textTrack2)}function y(e,o,f,a){return Math.min(o,a)-Math.max(e,f)}function s(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}},"./src/crypt/aes-crypto.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.subtle=void 0,this.aesIV=void 0,this.subtle=I,this.aesIV=S}var T=p.prototype;return T.decrypt=function(S,O){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},O,S)},p}()},"./src/crypt/aes-decryptor.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"removePadding",function(){return p}),n.d(P,"default",function(){return T});var R=n("./src/utils/typed-array.ts");function p(I){var S=I.byteLength,O=S&&new DataView(I.buffer).getUint8(S-1);return O?Object(R.sliceUint8)(I,0,S-O):I}var T=function(){function I(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var S=I.prototype;return S.uint8ArrayToUint32Array_=function(_){for(var E=new DataView(_),A=new Uint32Array(4),D=0;D<4;D++)A[D]=E.getUint32(D*4);return A},S.initTable=function(){var _=this.sBox,E=this.invSBox,A=this.subMix,D=A[0],x=A[1],g=A[2],y=A[3],s=this.invSubMix,e=s[0],o=s[1],f=s[2],a=s[3],i=new Uint32Array(256),t=0,u=0,c=0;for(c=0;c<256;c++)c<128?i[c]=c<<1:i[c]=c<<1^283;for(c=0;c<256;c++){var r=u^u<<1^u<<2^u<<3^u<<4;r=r>>>8^r&255^99,_[t]=r,E[r]=t;var h=i[t],d=i[h],l=i[d],v=i[r]*257^r*16843008;D[t]=v<<24|v>>>8,x[t]=v<<16|v>>>16,g[t]=v<<8|v>>>24,y[t]=v,v=l*16843009^d*65537^h*257^t*16843008,e[r]=v<<24|v>>>8,o[r]=v<<16|v>>>16,f[r]=v<<8|v>>>24,a[r]=v,t?(t=h^i[i[i[l^h]]],u^=i[i[u]]):t=u=1}},S.expandKey=function(_){for(var E=this.uint8ArrayToUint32Array_(_),A=!0,D=0;D<E.length&&A;)A=E[D]===this.key[D],D++;if(!A){this.key=E;var x=this.keySize=E.length;if(x!==4&&x!==6&&x!==8)throw new Error("Invalid aes key size="+x);var g=this.ksRows=(x+6+1)*4,y,s,e=this.keySchedule=new Uint32Array(g),o=this.invKeySchedule=new Uint32Array(g),f=this.sBox,a=this.rcon,i=this.invSubMix,t=i[0],u=i[1],c=i[2],r=i[3],h,d;for(y=0;y<g;y++){if(y<x){h=e[y]=E[y];continue}d=h,y%x===0?(d=d<<8|d>>>24,d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255],d^=a[y/x|0]<<24):x>6&&y%x===4&&(d=f[d>>>24]<<24|f[d>>>16&255]<<16|f[d>>>8&255]<<8|f[d&255]),e[y]=h=(e[y-x]^d)>>>0}for(s=0;s<g;s++)y=g-s,s&3?d=e[y]:d=e[y-4],s<4||y<=4?o[s]=d:o[s]=t[f[d>>>24]]^u[f[d>>>16&255]]^c[f[d>>>8&255]]^r[f[d&255]],o[s]=o[s]>>>0}},S.networkToHostOrderSwap=function(_){return _<<24|(_&65280)<<8|(_&16711680)>>8|_>>>24},S.decrypt=function(_,E,A){for(var D=this.keySize+6,x=this.invKeySchedule,g=this.invSBox,y=this.invSubMix,s=y[0],e=y[1],o=y[2],f=y[3],a=this.uint8ArrayToUint32Array_(A),i=a[0],t=a[1],u=a[2],c=a[3],r=new Int32Array(_),h=new Int32Array(r.length),d,l,v,m,L,b,M,F,w,C,U,k,j,N,W=this.networkToHostOrderSwap;E<r.length;){for(w=W(r[E]),C=W(r[E+1]),U=W(r[E+2]),k=W(r[E+3]),L=w^x[0],b=k^x[1],M=U^x[2],F=C^x[3],j=4,N=1;N<D;N++)d=s[L>>>24]^e[b>>16&255]^o[M>>8&255]^f[F&255]^x[j],l=s[b>>>24]^e[M>>16&255]^o[F>>8&255]^f[L&255]^x[j+1],v=s[M>>>24]^e[F>>16&255]^o[L>>8&255]^f[b&255]^x[j+2],m=s[F>>>24]^e[L>>16&255]^o[b>>8&255]^f[M&255]^x[j+3],L=d,b=l,M=v,F=m,j=j+4;d=g[L>>>24]<<24^g[b>>16&255]<<16^g[M>>8&255]<<8^g[F&255]^x[j],l=g[b>>>24]<<24^g[M>>16&255]<<16^g[F>>8&255]<<8^g[L&255]^x[j+1],v=g[M>>>24]<<24^g[F>>16&255]<<16^g[L>>8&255]<<8^g[b&255]^x[j+2],m=g[F>>>24]<<24^g[L>>16&255]<<16^g[b>>8&255]<<8^g[M&255]^x[j+3],h[E]=W(d^i),h[E+1]=W(m^t),h[E+2]=W(v^u),h[E+3]=W(l^c),i=w,t=C,u=U,c=k,E=E+4}return h.buffer},I}()},"./src/crypt/decrypter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return E});var R=n("./src/crypt/aes-crypto.ts"),p=n("./src/crypt/fast-aes-key.ts"),T=n("./src/crypt/aes-decryptor.ts"),I=n("./src/utils/logger.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=16,E=function(){function A(x,g,y){var s=y===void 0?{}:y,e=s.removePKCS7Padding,o=e===void 0?!0:e;if(this.logEnabled=!0,this.observer=void 0,this.config=void 0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.observer=x,this.config=g,this.removePKCS7Padding=o,o)try{var f=self.crypto;f&&(this.subtle=f.subtle||f.webkitSubtle)}catch{}this.subtle===null&&(this.config.enableSoftwareAES=!0)}var D=A.prototype;return D.destroy=function(){this.observer=null},D.isSync=function(){return this.config.enableSoftwareAES},D.flush=function(){var g=this.currentResult;if(!g){this.reset();return}var y=new Uint8Array(g);return this.reset(),this.removePKCS7Padding?Object(T.removePadding)(y):y},D.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},D.decrypt=function(g,y,s,e){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(g),y,s);var o=this.flush();o&&e(o.buffer)}else this.webCryptoDecrypt(new Uint8Array(g),y,s).then(e)},D.softwareDecrypt=function(g,y,s){var e=this.currentIV,o=this.currentResult,f=this.remainderData;this.logOnce("JS AES decrypt"),f&&(g=Object(S.appendUint8Array)(f,g),this.remainderData=null);var a=this.getValidChunk(g);if(!a.length)return null;e&&(s=e);var i=this.softwareDecrypter;i||(i=this.softwareDecrypter=new T.default),i.expandKey(y);var t=o;return this.currentResult=i.decrypt(a.buffer,0,s),this.currentIV=Object(O.sliceUint8)(a,-16).buffer,t||null},D.webCryptoDecrypt=function(g,y,s){var e=this,o=this.subtle;return(this.key!==y||!this.fastAesKey)&&(this.key=y,this.fastAesKey=new p.default(o,y)),this.fastAesKey.expandKey().then(function(f){if(!o)return Promise.reject(new Error("web crypto not initialized"));var a=new R.default(o,s);return a.decrypt(g.buffer,f)}).catch(function(f){return e.onWebCryptoError(f,g,y,s)})},D.onWebCryptoError=function(g,y,s,e){return I.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",g),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(y,s,e)},D.getValidChunk=function(g){var y=g,s=g.length-g.length%_;return s!==g.length&&(y=Object(O.sliceUint8)(g,0,s),this.remainderData=Object(O.sliceUint8)(g,s)),y},D.logOnce=function(g){!this.logEnabled||(I.logger.log("[decrypter.ts]: "+g),this.logEnabled=!1)},A}()},"./src/crypt/fast-aes-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.subtle=void 0,this.key=void 0,this.subtle=I,this.key=S}var T=p.prototype;return T.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},p}()},"./src/demux/aacdemuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),p=n("./src/demux/adts.ts"),T=n("./src/utils/logger.ts"),I=n("./src/demux/id3.ts");function S(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,O(E,A)}function O(E,A){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},O(E,A)}var _=function(E){S(A,E);function A(x,g){var y;return y=E.call(this)||this,y.observer=void 0,y.config=void 0,y.observer=x,y.config=g,y}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=I.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(p.probe(g,s))return T.logger.log("ADTS sync word found !"),!0;return!1},D.canParse=function(g,y){return p.canParse(g,y)},D.appendFrame=function(g,y,s){p.initTrackConfig(g,this.observer,y,s,g.manifestCodec);var e=p.appendFrame(g,y,s,this.basePTS,this.frameIndex);if(e&&e.missing===0)return e},A}(R.default);P.default=_},"./src/demux/adts.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"getAudioConfig",function(){return I}),n.d(P,"isHeaderPattern",function(){return S}),n.d(P,"getHeaderLength",function(){return O}),n.d(P,"getFullFrameLength",function(){return _}),n.d(P,"canGetFrameLength",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x}),n.d(P,"initTrackConfig",function(){return g}),n.d(P,"getFrameDuration",function(){return y}),n.d(P,"parseFrameHeader",function(){return s}),n.d(P,"appendFrame",function(){return e});var R=n("./src/utils/logger.ts"),p=n("./src/errors.ts"),T=n("./src/events.ts");function I(o,f,a,i){var t,u,c,r,h=navigator.userAgent.toLowerCase(),d=i,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];t=((f[a+2]&192)>>>6)+1;var v=(f[a+2]&60)>>>2;if(v>l.length-1){o.trigger(T.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+v});return}return c=(f[a+2]&1)<<2,c|=(f[a+3]&192)>>>6,R.logger.log("manifest codec:"+i+", ADTS type:"+t+", samplingIndex:"+v),/firefox/i.test(h)?v>=6?(t=5,r=new Array(4),u=v-3):(t=2,r=new Array(2),u=v):h.indexOf("android")!==-1?(t=2,r=new Array(2),u=v):(t=5,r=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?u=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(h))||!i&&c===1)&&(t=2,r=new Array(2)),u=v)),r[0]=t<<3,r[0]|=(v&14)>>1,r[1]|=(v&1)<<7,r[1]|=c<<3,t===5&&(r[1]|=(u&14)>>1,r[2]=(u&1)<<7,r[2]|=2<<2,r[3]=0),{config:r,samplerate:l[v],channelCount:c,codec:"mp4a.40."+t,manifestCodec:d}}function S(o,f){return o[f]===255&&(o[f+1]&246)===240}function O(o,f){return o[f+1]&1?7:9}function _(o,f){return(o[f+3]&3)<<11|o[f+4]<<3|(o[f+5]&224)>>>5}function E(o,f){return f+5<o.length}function A(o,f){return f+1<o.length&&S(o,f)}function D(o,f){return E(o,f)&&S(o,f)&&_(o,f)<=o.length-f}function x(o,f){if(A(o,f)){var a=O(o,f);if(f+a>=o.length)return!1;var i=_(o,f);if(i<=a)return!1;var t=f+i;return t===o.length||A(o,t)}return!1}function g(o,f,a,i,t){if(!o.samplerate){var u=I(f,a,i,t);if(!u)return;o.config=u.config,o.samplerate=u.samplerate,o.channelCount=u.channelCount,o.codec=u.codec,o.manifestCodec=u.manifestCodec,R.logger.log("parsed codec:"+o.codec+", rate:"+u.samplerate+", channels:"+u.channelCount)}}function y(o){return 1024*9e4/o}function s(o,f){var a=O(o,f);if(f+a<=o.length){var i=_(o,f)-a;if(i>0)return{headerLength:a,frameLength:i}}}function e(o,f,a,i,t){var u=y(o.samplerate),c=i+t*u,r=s(f,a),h;if(r){var d=r.frameLength,l=r.headerLength,v=l+d,m=Math.max(0,a+v-f.length);m?(h=new Uint8Array(v-l),h.set(f.subarray(a+l,f.length),0)):h=f.subarray(a+l,a+v);var L={unit:h,pts:c};return m||o.samples.push(L),{sample:L,length:v,missing:m}}var b=f.length-a;h=new Uint8Array(b),h.set(f.subarray(a,f.length),0);var M={unit:h,pts:c};return{sample:M,length:b,missing:-1}}},"./src/demux/base-audio-demuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"initPTSFn",function(){return E});var R=n("./src/polyfills/number.ts"),p=n("./src/demux/id3.ts"),T=n("./src/types/demuxer.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/utils/typed-array.ts"),_=function(){function A(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},D.resetTimeStamp=function(g){this.initPTS=g,this.resetContiguity()},D.resetContiguity=function(){this.basePTS=null,this.frameIndex=0},D.canParse=function(g,y){return!1},D.appendFrame=function(g,y,s){},D.demux=function(g,y){this.cachedData&&(g=Object(S.appendUint8Array)(this.cachedData,g),this.cachedData=null);var s=p.getID3Data(g,0),e=s?s.length:0,o,f,a=this._audioTrack,i=this._id3Track,t=s?p.getTimeStamp(s):void 0,u=g.length;for((this.basePTS===null||this.frameIndex===0&&Object(R.isFiniteNumber)(t))&&(this.basePTS=E(t,y,this.initPTS)),s&&s.length>0&&i.samples.push({pts:this.basePTS,dts:this.basePTS,data:s,type:T.MetadataSchema.audioId3}),f=this.basePTS;e<u;){if(this.canParse(g,e)){var c=this.appendFrame(a,g,e);c?(this.frameIndex++,f=c.sample.pts,e+=c.length,o=e):e=u}else p.canParse(g,e)?(s=p.getID3Data(g,e),i.samples.push({pts:f,dts:f,data:s,type:T.MetadataSchema.audioId3}),e+=s.length,o=e):e++;if(e===u&&o!==u){var r=Object(O.sliceUint8)(g,o);this.cachedData?this.cachedData=Object(S.appendUint8Array)(this.cachedData,r):this.cachedData=r}}return{audioTrack:a,videoTrack:Object(I.dummyTrack)(),id3Track:i,textTrack:Object(I.dummyTrack)()}},D.demuxSampleAes=function(g,y,s){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},D.flush=function(g){var y=this.cachedData;return y&&(this.cachedData=null,this.demux(y,0)),{audioTrack:this._audioTrack,videoTrack:Object(I.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(I.dummyTrack)()}},D.destroy=function(){},A}(),E=function(D,x,g){return Object(R.isFiniteNumber)(D)?D*90:x*9e4+(g||0)};P.default=_},"./src/demux/chunk-cache.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function T(){this.chunks=[],this.dataLength=0}var I=T.prototype;return I.push=function(O){this.chunks.push(O),this.dataLength+=O.length},I.flush=function(){var O=this.chunks,_=this.dataLength,E;if(O.length)O.length===1?E=O[0]:E=p(O,_);else return new Uint8Array(0);return this.reset(),E},I.reset=function(){this.chunks.length=0,this.dataLength=0},T}();function p(T,I){for(var S=new Uint8Array(I),O=0,_=0;_<T.length;_++){var E=T[_];S.set(E,O),O+=E.length}return S}},"./src/demux/dummy-demuxed-track.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"dummyTrack",function(){return R});function R(p,T){return p===void 0&&(p=""),T===void 0&&(T=9e4),{type:p,id:-1,pid:-1,inputTimeScale:T,sequenceNumber:-1,samples:[],dropped:0}}},"./src/demux/exp-golomb.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),p=function(){function T(S){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=S,this.bytesAvailable=S.byteLength,this.word=0,this.bitsAvailable=0}var I=T.prototype;return I.loadWord=function(){var O=this.data,_=this.bytesAvailable,E=O.byteLength-_,A=new Uint8Array(4),D=Math.min(4,_);if(D===0)throw new Error("no bytes available");A.set(O.subarray(E,E+D)),this.word=new DataView(A.buffer).getUint32(0),this.bitsAvailable=D*8,this.bytesAvailable-=D},I.skipBits=function(O){var _;this.bitsAvailable>O?(this.word<<=O,this.bitsAvailable-=O):(O-=this.bitsAvailable,_=O>>3,O-=_>>3,this.bytesAvailable-=_,this.loadWord(),this.word<<=O,this.bitsAvailable-=O)},I.readBits=function(O){var _=Math.min(this.bitsAvailable,O),E=this.word>>>32-_;return O>32&&R.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=_,this.bitsAvailable>0?this.word<<=_:this.bytesAvailable>0&&this.loadWord(),_=O-_,_>0&&this.bitsAvailable?E<<_|this.readBits(_):E},I.skipLZ=function(){var O;for(O=0;O<this.bitsAvailable;++O)if((this.word&2147483648>>>O)!==0)return this.word<<=O,this.bitsAvailable-=O,O;return this.loadWord(),O+this.skipLZ()},I.skipUEG=function(){this.skipBits(1+this.skipLZ())},I.skipEG=function(){this.skipBits(1+this.skipLZ())},I.readUEG=function(){var O=this.skipLZ();return this.readBits(O+1)-1},I.readEG=function(){var O=this.readUEG();return 1&O?1+O>>>1:-1*(O>>>1)},I.readBoolean=function(){return this.readBits(1)===1},I.readUByte=function(){return this.readBits(8)},I.readUShort=function(){return this.readBits(16)},I.readUInt=function(){return this.readBits(32)},I.skipScalingList=function(O){for(var _=8,E=8,A,D=0;D<O;D++)E!==0&&(A=this.readEG(),E=(_+A+256)%256),_=E===0?_:E},I.readSPS=function(){var O=0,_=0,E=0,A=0,D,x,g,y=this.readUByte.bind(this),s=this.readBits.bind(this),e=this.readUEG.bind(this),o=this.readBoolean.bind(this),f=this.skipBits.bind(this),a=this.skipEG.bind(this),i=this.skipUEG.bind(this),t=this.skipScalingList.bind(this);y();var u=y();if(s(5),f(3),y(),i(),u===100||u===110||u===122||u===244||u===44||u===83||u===86||u===118||u===128){var c=e();if(c===3&&f(1),i(),i(),f(1),o())for(x=c!==3?8:12,g=0;g<x;g++)o()&&(g<6?t(16):t(64))}i();var r=e();if(r===0)e();else if(r===1)for(f(1),a(),a(),D=e(),g=0;g<D;g++)a();i(),f(1);var h=e(),d=e(),l=s(1);l===0&&f(1),f(1),o()&&(O=e(),_=e(),E=e(),A=e());var v=[1,1];if(o()&&o()){var m=y();switch(m){case 1:v=[1,1];break;case 2:v=[12,11];break;case 3:v=[10,11];break;case 4:v=[16,11];break;case 5:v=[40,33];break;case 6:v=[24,11];break;case 7:v=[20,11];break;case 8:v=[32,11];break;case 9:v=[80,33];break;case 10:v=[18,11];break;case 11:v=[15,11];break;case 12:v=[64,33];break;case 13:v=[160,99];break;case 14:v=[4,3];break;case 15:v=[3,2];break;case 16:v=[2,1];break;case 255:{v=[y()<<8|y(),y()<<8|y()];break}}}return{width:Math.ceil((h+1)*16-O*2-_*2),height:(2-l)*(d+1)*16-(l?2:4)*(E+A),pixelRatio:v}},I.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},T}();P.default=p},"./src/demux/id3.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isHeader",function(){return R}),n.d(P,"isFooter",function(){return p}),n.d(P,"getID3Data",function(){return T}),n.d(P,"canParse",function(){return S}),n.d(P,"getTimeStamp",function(){return O}),n.d(P,"isTimeStampFrame",function(){return _}),n.d(P,"getID3Frames",function(){return A}),n.d(P,"decodeFrame",function(){return D}),n.d(P,"utf8ArrayToStr",function(){return e}),n.d(P,"testables",function(){return o});var R=function(t,u){return u+10<=t.length&&t[u]===73&&t[u+1]===68&&t[u+2]===51&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},p=function(t,u){return u+10<=t.length&&t[u]===51&&t[u+1]===68&&t[u+2]===73&&t[u+3]<255&&t[u+4]<255&&t[u+6]<128&&t[u+7]<128&&t[u+8]<128&&t[u+9]<128},T=function(t,u){for(var c=u,r=0;R(t,u);){r+=10;var h=I(t,u+6);r+=h,p(t,u+10)&&(r+=10),u+=r}if(r>0)return t.subarray(c,c+r)},I=function(t,u){var c=0;return c=(t[u]&127)<<21,c|=(t[u+1]&127)<<14,c|=(t[u+2]&127)<<7,c|=t[u+3]&127,c},S=function(t,u){return R(t,u)&&I(t,u+6)+10<=t.length-u},O=function(t){for(var u=A(t),c=0;c<u.length;c++){var r=u[c];if(_(r))return s(r)}},_=function(t){return t&&t.key==="PRIV"&&t.info==="com.apple.streaming.transportStreamTimestamp"},E=function(t){var u=String.fromCharCode(t[0],t[1],t[2],t[3]),c=I(t,4),r=10;return{type:u,size:c,data:t.subarray(r,r+c)}},A=function(t){for(var u=0,c=[];R(t,u);){var r=I(t,u+6);u+=10;for(var h=u+r;u+8<h;){var d=E(t.subarray(u)),l=D(d);l&&c.push(l),u+=d.size+10}p(t,u)&&(u+=10)}return c},D=function(t){return t.type==="PRIV"?x(t):t.type[0]==="W"?y(t):g(t)},x=function(t){if(!(t.size<2)){var u=e(t.data,!0),c=new Uint8Array(t.data.subarray(u.length+1));return{key:t.type,info:u,data:c.buffer}}},g=function(t){if(!(t.size<2)){if(t.type==="TXXX"){var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data.subarray(1));return{key:t.type,data:h}}},y=function(t){if(t.type==="WXXX"){if(t.size<2)return;var u=1,c=e(t.data.subarray(u),!0);u+=c.length+1;var r=e(t.data.subarray(u));return{key:t.type,info:c,data:r}}var h=e(t.data);return{key:t.type,data:h}},s=function(t){if(t.data.byteLength===8){var u=new Uint8Array(t.data),c=u[3]&1,r=(u[4]<<23)+(u[5]<<15)+(u[6]<<7)+u[7];return r/=45,c&&(r+=4772185884e-2),Math.round(r)}},e=function(t,u){u===void 0&&(u=!1);var c=a();if(c){var r=c.decode(t);if(u){var h=r.indexOf("\0");return h!==-1?r.substring(0,h):r}return r.replace(/\0/g,"")}for(var d=t.length,l,v,m,L="",b=0;b<d;){if(l=t[b++],l===0&&u)return L;if(l===0||l===3)continue;switch(l>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:L+=String.fromCharCode(l);break;case 12:case 13:v=t[b++],L+=String.fromCharCode((l&31)<<6|v&63);break;case 14:v=t[b++],m=t[b++],L+=String.fromCharCode((l&15)<<12|(v&63)<<6|(m&63)<<0);break;default:}}return L},o={decodeTextFrame:g},f;function a(){return!f&&typeof self.TextDecoder!="undefined"&&(f=new self.TextDecoder("utf-8")),f}},"./src/demux/mp3demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/demux/base-audio-demuxer.ts"),p=n("./src/demux/id3.ts"),T=n("./src/utils/logger.ts"),I=n("./src/demux/mpegaudio.ts");function S(E,A){E.prototype=Object.create(A.prototype),E.prototype.constructor=E,O(E,A)}function O(E,A){return O=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(x,g){return x.__proto__=g,x},O(E,A)}var _=function(E){S(A,E);function A(){return E.apply(this,arguments)||this}var D=A.prototype;return D.resetInitSegment=function(g,y,s,e){E.prototype.resetInitSegment.call(this,g,y,s,e),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:y,duration:e,inputTimeScale:9e4,dropped:0}},A.probe=function(g){if(!g)return!1;for(var y=p.getID3Data(g,0)||[],s=y.length,e=g.length;s<e;s++)if(I.probe(g,s))return T.logger.log("MPEG Audio sync word found !"),!0;return!1},D.canParse=function(g,y){return I.canParse(g,y)},D.appendFrame=function(g,y,s){if(this.basePTS!==null)return I.appendFrame(g,y,s,this.basePTS,this.frameIndex)},A}(R.default);P.default=_},"./src/demux/mp4demuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/types/demuxer.ts"),T=n("./src/utils/mp4-tools.ts"),I=n("./src/demux/dummy-demuxed-track.ts"),S=/\/emsg[-/]ID3/i,O=function(){function _(A,D){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=D}var E=_.prototype;return E.resetTimeStamp=function(){},E.resetInitSegment=function(D,x,g,y){var s=Object(T.parseInitSegment)(D),e=this.videoTrack=Object(I.dummyTrack)("video",1),o=this.audioTrack=Object(I.dummyTrack)("audio",1),f=this.txtTrack=Object(I.dummyTrack)("text",1);if(this.id3Track=Object(I.dummyTrack)("id3",1),this.timeOffset=0,s.video){var a=s.video,i=a.id,t=a.timescale,u=a.codec;e.id=i,e.timescale=f.timescale=t,e.codec=u}if(s.audio){var c=s.audio,r=c.id,h=c.timescale,d=c.codec;o.id=r,o.timescale=h,o.codec=d}f.id=T.RemuxerTrackIdConfig.text,e.sampleDuration=0,e.duration=o.duration=y},E.resetContiguity=function(){},_.probe=function(D){return D=D.length>16384?D.subarray(0,16384):D,Object(T.findBox)(D,["moof"]).length>0},E.demux=function(D,x){this.timeOffset=x;var g=D,y=this.videoTrack,s=this.txtTrack;if(this.config.progressive){this.remainderData&&(g=Object(T.appendUint8Array)(this.remainderData,D));var e=Object(T.segmentValidRange)(g);this.remainderData=e.remainder,y.samples=e.valid||new Uint8Array}else y.samples=g;var o=this.extractID3Track(y,x);return s.samples=Object(T.parseSamples)(x,y),{videoTrack:y,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}},E.flush=function(){var D=this.timeOffset,x=this.videoTrack,g=this.txtTrack;x.samples=this.remainderData||new Uint8Array,this.remainderData=null;var y=this.extractID3Track(x,this.timeOffset);return g.samples=Object(T.parseSamples)(D,x),{videoTrack:x,audioTrack:Object(I.dummyTrack)(),id3Track:y,textTrack:Object(I.dummyTrack)()}},E.extractID3Track=function(D,x){var g=this.id3Track;if(D.samples.length){var y=Object(T.findBox)(D.samples,["emsg"]);y&&y.forEach(function(s){var e=Object(T.parseEmsg)(s);if(S.test(e.schemeIdUri)){var o=Object(R.isFiniteNumber)(e.presentationTime)?e.presentationTime/e.timeScale:x+e.presentationTimeDelta/e.timeScale,f=e.payload;g.samples.push({data:f,len:f.byteLength,dts:o,pts:o,type:p.MetadataSchema.emsg})}})}return g},E.demuxSampleAes=function(D,x,g){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},E.destroy=function(){},_}();P.default=O},"./src/demux/mpegaudio.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"appendFrame",function(){return O}),n.d(P,"parseHeader",function(){return _}),n.d(P,"isHeaderPattern",function(){return E}),n.d(P,"isHeader",function(){return A}),n.d(P,"canParse",function(){return D}),n.d(P,"probe",function(){return x});var R=null,p=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],T=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],I=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],S=[0,1,1,4];function O(g,y,s,e,o){if(!(s+24>y.length)){var f=_(y,s);if(f&&s+f.frameLength<=y.length){var a=f.samplesPerFrame*9e4/f.sampleRate,i=e+o*a,t={unit:y.subarray(s,s+f.frameLength),pts:i,dts:i};return g.config=[],g.channelCount=f.channelCount,g.samplerate=f.sampleRate,g.samples.push(t),{sample:t,length:f.frameLength,missing:0}}}}function _(g,y){var s=g[y+1]>>3&3,e=g[y+1]>>1&3,o=g[y+2]>>4&15,f=g[y+2]>>2&3;if(s!==1&&o!==0&&o!==15&&f!==3){var a=g[y+2]>>1&1,i=g[y+3]>>6,t=s===3?3-e:e===3?3:4,u=p[t*14+o-1]*1e3,c=s===3?0:s===2?1:2,r=T[c*3+f],h=i===3?1:2,d=I[s][e],l=S[e],v=d*8*l,m=Math.floor(d*u/r+a)*l;if(R===null){var L=navigator.userAgent||"",b=L.match(/Chrome\/(\d+)/i);R=b?parseInt(b[1]):0}var M=!!R&&R<=87;return M&&e===2&&u>=224e3&&i===0&&(g[y+3]=g[y+3]|128),{sampleRate:r,channelCount:h,frameLength:m,samplesPerFrame:v}}}function E(g,y){return g[y]===255&&(g[y+1]&224)===224&&(g[y+1]&6)!==0}function A(g,y){return y+1<g.length&&E(g,y)}function D(g,y){var s=4;return E(g,y)&&s<=g.length-y}function x(g,y){if(y+1<g.length&&E(g,y)){var s=4,e=_(g,y),o=s;e!=null&&e.frameLength&&(o=e.frameLength);var f=y+o;return f===g.length||A(g,f)}return!1}},"./src/demux/sample-aes.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/crypt/decrypter.ts"),p=n("./src/demux/tsdemuxer.ts"),T=function(){function I(O,_,E){this.keyData=void 0,this.decrypter=void 0,this.keyData=E,this.decrypter=new R.default(O,_,{removePKCS7Padding:!1})}var S=I.prototype;return S.decryptBuffer=function(_,E){this.decrypter.decrypt(_,this.keyData.key.buffer,this.keyData.iv.buffer,E)},S.decryptAacSample=function(_,E,A,D){var x=_[E].unit;if(!(x.length<=16)){var g=x.subarray(16,x.length-x.length%16),y=g.buffer.slice(g.byteOffset,g.byteOffset+g.length),s=this;this.decryptBuffer(y,function(e){var o=new Uint8Array(e);x.set(o,16),D||s.decryptAacSamples(_,E+1,A)})}},S.decryptAacSamples=function(_,E,A){for(;;E++){if(E>=_.length){A();return}if(!(_[E].unit.length<32)){var D=this.decrypter.isSync();if(this.decryptAacSample(_,E,A,D),!D)return}}},S.getAvcEncryptedData=function(_){for(var E=Math.floor((_.length-48)/160)*16+16,A=new Int8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)A.set(_.subarray(x,x+16),D);return A},S.getAvcDecryptedUnit=function(_,E){for(var A=new Uint8Array(E),D=0,x=32;x<_.length-16;x+=160,D+=16)_.set(A.subarray(D,D+16),x);return _},S.decryptAvcSample=function(_,E,A,D,x,g){var y=Object(p.discardEPB)(x.data),s=this.getAvcEncryptedData(y),e=this;this.decryptBuffer(s.buffer,function(o){x.data=e.getAvcDecryptedUnit(y,o),g||e.decryptAvcSamples(_,E,A+1,D)})},S.decryptAvcSamples=function(_,E,A,D){if(_ instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;E++,A=0){if(E>=_.length){D();return}for(var x=_[E].units;!(A>=x.length);A++){var g=x[A];if(!(g.data.length<=48||g.type!==1&&g.type!==5)){var y=this.decrypter.isSync();if(this.decryptAvcSample(_,E,A,D,g,y),!y)return}}}},I}();P.default=T},"./src/demux/transmuxer-interface.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x});var R=n("./node_modules/webworkify-webpack/index.js"),p=n.n(R),T=n("./src/events.ts"),I=n("./src/demux/transmuxer.ts"),S=n("./src/utils/logger.ts"),O=n("./src/errors.ts"),_=n("./src/utils/mediasource-helper.ts"),E=n("./node_modules/eventemitter3/index.js"),A=n.n(E),D=Object(_.getMediaSource)()||{isTypeSupported:function(){return!1}},x=function(){function g(s,e,o,f){var a=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=s,this.id=e,this.onTransmuxComplete=o,this.onFlush=f;var i=s.config,t=function(d,l){l=l||{},l.frag=a.frag,l.id=a.id,s.trigger(d,l)};this.observer=new E.EventEmitter,this.observer.on(T.Events.FRAG_DECRYPTED,t),this.observer.on(T.Events.ERROR,t);var u={mp4:D.isTypeSupported("video/mp4"),mpeg:D.isTypeSupported("audio/mpeg"),mp3:D.isTypeSupported('audio/mp4; codecs="mp3"')},c=navigator.vendor;if(i.enableWorker&&typeof Worker!="undefined"){S.logger.log("demuxing in webworker");var r;try{r=this.worker=R("./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),r.addEventListener("message",this.onwmsg),r.onerror=function(h){s.trigger(T.Events.ERROR,{type:O.ErrorTypes.OTHER_ERROR,details:O.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(h.message+" ("+h.filename+":"+h.lineno+")")})},r.postMessage({cmd:"init",typeSupported:u,vendor:c,id:e,config:JSON.stringify(i)})}catch(h){S.logger.warn("Error in worker:",h),S.logger.error("Error while initializing DemuxerWorker, fallback to inline"),r&&self.URL.revokeObjectURL(r.objectURL),this.transmuxer=new I.default(this.observer,u,i,c,e),this.worker=null}}else this.transmuxer=new I.default(this.observer,u,i,c,e)}var y=g.prototype;return y.destroy=function(){var e=this.worker;if(e)e.removeEventListener("message",this.onwmsg),e.terminate(),this.worker=null,this.onwmsg=void 0;else{var o=this.transmuxer;o&&(o.destroy(),this.transmuxer=null)}var f=this.observer;f&&f.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null},y.push=function(e,o,f,a,i,t,u,c,r,h){var d,l,v=this;r.transmuxing.start=self.performance.now();var m=this.transmuxer,L=this.worker,b=t?t.start:i.start,M=i.decryptdata,F=this.frag,w=!(F&&i.cc===F.cc),C=!(F&&r.level===F.level),U=F?r.sn-F.sn:-1,k=this.part?r.part-this.part.index:-1,j=U===0&&r.id>1&&r.id===(F==null?void 0:F.stats.chunkCount),N=!C&&(U===1||U===0&&(k===1||j&&k<=0)),W=self.performance.now();(C||U||i.stats.parsing.start===0)&&(i.stats.parsing.start=W),t&&(k||!N)&&(t.stats.parsing.start=W);var Y=!(F&&((d=i.initSegment)===null||d===void 0?void 0:d.url)===((l=F.initSegment)===null||l===void 0?void 0:l.url)),K=new I.TransmuxState(w,N,c,C,b,Y);if(!N||w||Y){S.logger.log("[transmuxer-interface, "+i.type+"]: Starting new transmux session for sn: "+r.sn+" p: "+r.part+" level: "+r.level+" id: "+r.id+`
|
|
13
13
|
discontinuity: `+w+`
|
|
14
14
|
trackSwitch: `+C+`
|
|
15
15
|
contiguous: `+N+`
|
|
16
16
|
accurateTimeOffset: `+c+`
|
|
17
|
-
timeOffset: `+
|
|
18
|
-
initSegmentChange: `+j);var V=new I.TransmuxConfig(t,r,i,h,f);this.configureTransmuxer(V)}if(this.frag=a,this.part=n,R)R.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:u,state:K},e instanceof ArrayBuffer?[e]:[]);else if(p){var Y=p.push(e,M,u,K);Object(I.isPromise)(Y)?Y.then(function(Q){E.handleTransmuxComplete(Q)}):this.handleTransmuxComplete(Y)}},m.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)}},m.handleFlushResult=function(e,i){var t=this;e.forEach(function(r){t.handleTransmuxComplete(r)}),this.onFlush(i)},m.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}}},m.configureTransmuxer=function(e){var i=this.worker,t=this.transmuxer;i?i.postMessage({cmd:"configure",config:e}):t&&t.configure(e)},m.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},v}()},"./src/demux/transmuxer-worker.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return O});var b=d("./src/demux/transmuxer.ts"),y=d("./src/events.ts"),T=d("./src/utils/logger.ts"),I=d("./node_modules/eventemitter3/index.js"),S=d.n(I);function O(x){var v=new I.EventEmitter,m=function(e,i){x.postMessage({event:e,data:i})};v.on(y.Events.FRAG_DECRYPTED,m),v.on(y.Events.ERROR,m),x.addEventListener("message",function(s){var e=s.data;switch(e.cmd){case"init":{var i=JSON.parse(e.config);x.transmuxer=new b.default(v,e.typeSupported,i,e.vendor,e.id),Object(T.enableLogs)(i.debug),m("init",null);break}case"configure":{x.transmuxer.configure(e.config);break}case"demux":{var t=x.transmuxer.push(e.data,e.decryptdata,e.chunkMeta,e.state);Object(b.isPromise)(t)?t.then(function(n){A(x,n)}):A(x,t);break}case"flush":{var r=e.chunkMeta,a=x.transmuxer.flush(r);Object(b.isPromise)(a)?a.then(function(n){_(x,n,r)}):_(x,a,r);break}default:break}})}function A(x,v){if(!L(v.remuxResult)){var m=[],s=v.remuxResult,e=s.audio,i=s.video;e&&g(m,e),i&&g(m,i),x.postMessage({event:"transmuxComplete",data:v},m)}}function g(x,v){v.data1&&x.push(v.data1.buffer),v.data2&&x.push(v.data2.buffer)}function _(x,v,m){v.forEach(function(s){A(x,s)}),x.postMessage({event:"flush",data:m})}function L(x){return!x.audio&&!x.video&&!x.text&&!x.id3&&!x.initSegment}},"./src/demux/transmuxer.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return i}),d.d(D,"isPromise",function(){return a}),d.d(D,"TransmuxConfig",function(){return n}),d.d(D,"TransmuxState",function(){return h});var b=d("./src/events.ts"),y=d("./src/errors.ts"),T=d("./src/crypt/decrypter.ts"),I=d("./src/demux/aacdemuxer.ts"),S=d("./src/demux/mp4demuxer.ts"),O=d("./src/demux/tsdemuxer.ts"),A=d("./src/demux/mp3demuxer.ts"),g=d("./src/remux/mp4-remuxer.ts"),_=d("./src/remux/passthrough-remuxer.ts"),L=d("./src/demux/chunk-cache.ts"),x=d("./src/utils/mp4-tools.ts"),v=d("./src/utils/logger.ts"),m;try{m=self.performance.now.bind(self.performance)}catch{v.logger.debug("Unable to use Performance API on this environment"),m=self.Date.now}var s=[{demux:O.default,remux:g.default},{demux:S.default,remux:_.default},{demux:I.default,remux:g.default},{demux:A.default,remux:g.default}],e=1024;s.forEach(function(c){var u=c.demux;e=Math.max(e,u.minProbeByteLength)});var i=function(){function c(f,o,l,E,p){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=o,this.config=l,this.vendor=E,this.id=p}var u=c.prototype;return u.configure=function(o){this.transmuxConfig=o,this.decrypter&&this.decrypter.reset()},u.push=function(o,l,E,p){var R=this,P=E.transmuxing;P.executeStart=m();var M=new Uint8Array(o),F=this.cache,w=this.config,C=this.currentTransmuxState,B=this.transmuxConfig;p&&(this.currentTransmuxState=p);var k=t(M,l);if(k&&k.method==="AES-128"){var N=this.getDecrypter();if(w.enableSoftwareAES){var W=N.softwareDecrypt(M,k.key.buffer,k.iv.buffer);if(!W)return P.executeEnd=m(),r(E);M=new Uint8Array(W)}else return this.decryptionPromise=N.webCryptoDecrypt(M,k.key.buffer,k.iv.buffer).then(function($){var ue=R.push($,null,E);return R.decryptionPromise=null,ue}),this.decryptionPromise}var j=p||C,K=j.contiguous,V=j.discontinuity,Y=j.trackSwitch,Q=j.accurateTimeOffset,z=j.timeOffset,re=j.initSegmentChange,X=B.audioCodec,J=B.videoCodec,se=B.defaultInitPts,ne=B.duration,pe=B.initSegmentData;if((V||Y||re)&&this.resetInitSegment(pe,X,J,ne),(V||re)&&this.resetInitialTimestamp(se),K||this.resetContiguity(),this.needsProbing(M,V,Y)){if(F.dataLength){var ee=F.flush();M=Object(x.appendUint8Array)(ee,M)}this.configureTransmuxer(M,B)}var Z=this.transmux(M,k,z,Q,E),q=this.currentTransmuxState;return q.contiguous=!0,q.discontinuity=!1,q.trackSwitch=!1,P.executeEnd=m(),Z},u.flush=function(o){var l=this,E=o.transmuxing;E.executeStart=m();var p=this.decrypter,R=this.cache,P=this.currentTransmuxState,M=this.decryptionPromise;if(M)return M.then(function(){return l.flush(o)});var F=[],w=P.timeOffset;if(p){var C=p.flush();C&&F.push(this.push(C,null,o))}var B=R.dataLength;R.reset();var k=this.demuxer,N=this.remuxer;if(!k||!N)return B>=e&&this.observer.emit(b.Events.ERROR,b.Events.ERROR,{type:y.ErrorTypes.MEDIA_ERROR,details:y.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),E.executeEnd=m(),[r(o)];var W=k.flush(w);return a(W)?W.then(function(j){return l.flushRemux(F,j,o),F}):(this.flushRemux(F,W,o),F)},u.flushRemux=function(o,l,E){var p=l.audioTrack,R=l.avcTrack,P=l.id3Track,M=l.textTrack,F=this.currentTransmuxState,w=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 B=this.remuxer.remux(p,R,P,M,C,w,!0,this.id);o.push({remuxResult:B,chunkMeta:E}),E.transmuxing.executeEnd=m()},u.resetInitialTimestamp=function(o){var l=this.demuxer,E=this.remuxer;!l||!E||(l.resetTimeStamp(o),E.resetTimeStamp(o))},u.resetContiguity=function(){var o=this.demuxer,l=this.remuxer;!o||!l||(o.resetContiguity(),l.resetNextTimestamp())},u.resetInitSegment=function(o,l,E,p){var R=this.demuxer,P=this.remuxer;!R||!P||(R.resetInitSegment(l,E,p),P.resetInitSegment(o,l,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(o,l,E,p,R){var P;return l&&l.method==="SAMPLE-AES"?P=this.transmuxSampleAes(o,l,E,p,R):P=this.transmuxUnencrypted(o,E,p,R),P},u.transmuxUnencrypted=function(o,l,E,p){var R=this.demuxer.demux(o,l,!1,!this.config.progressive),P=R.audioTrack,M=R.avcTrack,F=R.id3Track,w=R.textTrack,C=this.remuxer.remux(P,M,F,w,l,E,!1,this.id);return{remuxResult:C,chunkMeta:p}},u.transmuxSampleAes=function(o,l,E,p,R){var P=this;return this.demuxer.demuxSampleAes(o,l,E).then(function(M){var F=P.remuxer.remux(M.audioTrack,M.avcTrack,M.id3Track,M.textTrack,E,p,!1,P.id);return{remuxResult:F,chunkMeta:R}})},u.configureTransmuxer=function(o,l){for(var E=this.config,p=this.observer,R=this.typeSupported,P=this.vendor,M=l.audioCodec,F=l.defaultInitPts,w=l.duration,C=l.initSegmentData,B=l.videoCodec,k,N=0,W=s.length;N<W;N++)if(s[N].demux.probe(o)){k=s[N];break}k||(v.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),k={demux:S.default,remux:_.default});var j=this.demuxer,K=this.remuxer,V=k.remux,Y=k.demux;(!K||!(K instanceof V))&&(this.remuxer=new V(p,E,R,P)),(!j||!(j instanceof Y))&&(this.demuxer=new Y(p,E,R),this.probe=Y.probe),this.resetInitSegment(C,M,B,w),this.resetInitialTimestamp(F)},u.needsProbing=function(o,l,E){return!this.demuxer||!this.remuxer||l||E},u.getDecrypter=function(){var o=this.decrypter;return o||(o=this.decrypter=new T.default(this.observer,this.config)),o},c}();function t(c,u){var f=null;return c.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(c){return"then"in c&&c.then instanceof Function}var n=function(u,f,o,l,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=o,this.duration=l,this.defaultInitPts=E},h=function(u,f,o,l,E,p){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=o,this.trackSwitch=l,this.timeOffset=E,this.initSegmentChange=p}},"./src/demux/tsdemuxer.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"discardEPB",function(){return r});var b=d("./src/demux/adts.ts"),y=d("./src/demux/mpegaudio.ts"),T=d("./src/demux/exp-golomb.ts"),I=d("./src/demux/id3.ts"),S=d("./src/demux/sample-aes.ts"),O=d("./src/events.ts"),A=d("./src/utils/mp4-tools.ts"),g=d("./src/utils/logger.ts"),_=d("./src/errors.ts"),L={video:1,audio:2,id3:3,text:4},x=function(){function a(h,c,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=c,this.typeSupported=u}a.probe=function(c){var u=a.syncOffset(c);return u<0?!1:(u&&g.logger.warn("MPEG2-TS detected but first sync word found @ offset "+u+", junk ahead ?"),!0)},a.syncOffset=function(c){for(var u=Math.min(1e3,c.length-3*188),f=0;f<u;){if(c[f]===71&&c[f+188]===71&&c[f+2*188]===71)return f;f++}return-1},a.createTrack=function(c,u){return{container:c==="video"||c==="audio"?"video/mp2t":void 0,type:c,id:L[c],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:c==="audio"?u:void 0}};var n=a.prototype;return n.resetInitSegment=function(c,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=c,this.videoCodec=u,this._duration=f},n.resetTimeStamp=function(){},n.resetContiguity=function(){var c=this._audioTrack,u=this._avcTrack,f=this._id3Track;c&&(c.pesData=null),u&&(u.pesData=null),f&&(f.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},n.demux=function(c,u,f,o){f===void 0&&(f=!1),o===void 0&&(o=!1),f||(this.sampleAes=null);var l,E=this._avcTrack,p=this._audioTrack,R=this._id3Track,P=E.pid,M=E.pesData,F=p.pid,w=R.pid,C=p.pesData,B=R.pesData,k=!1,N=this.pmtParsed,W=this._pmtId,j=c.length;if(this.remainderData&&(c=Object(A.appendUint8Array)(this.remainderData,c),j=c.length,this.remainderData=null),j<188&&!o)return this.remainderData=c,{audioTrack:p,avcTrack:E,id3Track:R,textTrack:this._txtTrack};var K=Math.max(0,a.syncOffset(c));j-=(j+K)%188,j<c.byteLength&&!o&&(this.remainderData=new Uint8Array(c.buffer,j,c.buffer.byteLength-j));for(var V=0,Y=K;Y<j;Y+=188)if(c[Y]===71){var Q=!!(c[Y+1]&64),z=((c[Y+1]&31)<<8)+c[Y+2],re=(c[Y+3]&48)>>4,X=void 0;if(re>1){if(X=Y+5+c[Y+4],X===Y+188)continue}else X=Y+4;switch(z){case P:Q&&(M&&(l=e(M))&&this.parseAVCPES(l,!1),M={data:[],size:0}),M&&(M.data.push(c.subarray(X,Y+188)),M.size+=Y+188-X);break;case F:Q&&(C&&(l=e(C))&&(p.isAAC?this.parseAACPES(l):this.parseMPEGPES(l)),C={data:[],size:0}),C&&(C.data.push(c.subarray(X,Y+188)),C.size+=Y+188-X);break;case w:Q&&(B&&(l=e(B))&&this.parseID3PES(l),B={data:[],size:0}),B&&(B.data.push(c.subarray(X,Y+188)),B.size+=Y+188-X);break;case 0:Q&&(X+=c[X]+1),W=this._pmtId=m(c,X);break;case W:{Q&&(X+=c[X]+1);var J=s(c,X,this.typeSupported.mpeg===!0||this.typeSupported.mp3===!0,f);P=J.avc,P>0&&(E.pid=P),F=J.audio,F>0&&(p.pid=F,p.isAAC=J.isAAC),w=J.id3,w>0&&(R.pid=w),k&&!N&&(g.logger.log("reparse from beginning"),k=!1,Y=K-188),N=this.pmtParsed=!0;break}case 17:case 8191:break;default:k=!0;break}}else V++;V>0&&this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+V+" TS packet/s that do not start with 0x47"}),E.pesData=M,p.pesData=C,R.pesData=B;var se={audioTrack:p,avcTrack:E,id3Track:R,textTrack:this._txtTrack};return o&&this.extractRemainingSamples(se),se},n.flush=function(){var c=this.remainderData;this.remainderData=null;var u;return c?u=this.demux(c,-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(c){var u=c.audioTrack,f=c.avcTrack,o=c.id3Track,l=f.pesData,E=u.pesData,p=o.pesData,R;l&&(R=e(l))?(this.parseAVCPES(R,!0),f.pesData=null):f.pesData=l,E&&(R=e(E))?(u.isAAC?this.parseAACPES(R):this.parseMPEGPES(R),u.pesData=null):(E!=null&&E.size&&g.logger.log("last AAC PES packet truncated,might overlap between fragments"),u.pesData=E),p&&(R=e(p))?(this.parseID3PES(R),o.pesData=null):o.pesData=p},n.demuxSampleAes=function(c,u,f){var o=this.demux(c,f,!0,!this.config.progressive),l=this.sampleAes=new S.default(this.observer,this.config,u);return this.decrypt(o,l)},n.decrypt=function(c,u){return new Promise(function(f){var o=c.audioTrack,l=c.avcTrack;o.samples&&o.isAAC?u.decryptAacSamples(o.samples,0,function(){l.samples?u.decryptAvcSamples(l.samples,0,0,function(){f(c)}):f(c)}):l.samples&&u.decryptAvcSamples(l.samples,0,0,function(){f(c)})})},n.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},n.parseAVCPES=function(c,u){var f=this,o=this._avcTrack,l=this.parseAVCNALu(c.data),E=!1,p=this.avcSample,R,P=!1;c.data=null,p&&l.length&&!o.audFound&&(i(p,o),p=this.avcSample=v(!1,c.pts,c.dts,"")),l.forEach(function(M){switch(M.type){case 1:{R=!0,p||(p=f.avcSample=v(!0,c.pts,c.dts,"")),E&&(p.debug+="NDR "),p.frame=!0;var F=M.data;if(P&&F.length>4){var w=new T.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(p.key=!0)}break}case 5:R=!0,p||(p=f.avcSample=v(!0,c.pts,c.dts,"")),E&&(p.debug+="IDR "),p.key=!0,p.frame=!0;break;case 6:{R=!0,E&&p&&(p.debug+="SEI ");var C=new T.default(r(M.data));C.readUByte();for(var B=0,k=0,N=!1,W=0;!N&&C.bytesAvailable>1;){B=0;do W=C.readUByte(),B+=W;while(W===255);k=0;do W=C.readUByte(),k+=W;while(W===255);if(B===4&&C.bytesAvailable!==0){N=!0;var j=C.readUByte();if(j===181){var K=C.readUShort();if(K===49){var V=C.readUInt();if(V===1195456820){var Y=C.readUByte();if(Y===3){for(var Q=C.readUByte(),z=C.readUByte(),re=31&Q,X=[Q,z],J=0;J<re;J++)X.push(C.readUByte()),X.push(C.readUByte()),X.push(C.readUByte());t(f._txtTrack.samples,{type:3,pts:c.pts,bytes:X})}}}}}else if(B===5&&C.bytesAvailable!==0){if(N=!0,k>16){for(var se=[],ne=0;ne<16;ne++)se.push(C.readUByte().toString(16)),(ne===3||ne===5||ne===7||ne===9)&&se.push("-");for(var pe=k-16,ee=new Uint8Array(pe),Z=0;Z<pe;Z++)ee[Z]=C.readUByte();t(f._txtTrack.samples,{pts:c.pts,payloadType:B,uuid:se.join(""),userData:Object(I.utf8ArrayToStr)(ee),userDataBytes:ee})}}else if(k<C.bytesAvailable)for(var q=0;q<k;q++)C.readUByte()}break}case 7:if(R=!0,P=!0,E&&p&&(p.debug+="SPS "),!o.sps){var $=new T.default(M.data),ue=$.readSPS();o.width=ue.width,o.height=ue.height,o.pixelRatio=ue.pixelRatio,o.sps=[M.data],o.duration=f._duration;for(var ie=M.data.subarray(1,4),de="avc1.",he=0;he<3;he++){var ye=ie[he].toString(16);ye.length<2&&(ye="0"+ye),de+=ye}o.codec=de}break;case 8:R=!0,E&&p&&(p.debug+="PPS "),o.pps||(o.pps=[M.data]);break;case 9:R=!1,o.audFound=!0,p&&i(p,o),p=f.avcSample=v(!1,c.pts,c.dts,E?"AUD ":"");break;case 12:R=!1;break;default:R=!1,p&&(p.debug+="unknown NAL "+M.type+" ");break}if(p&&R){var Se=p.units;Se.push(M)}}),u&&p&&(i(p,o),this.avcSample=null)},n.getLastNalUnit=function(){var c,u=this.avcSample,f;if(!u||u.units.length===0){var o=this._avcTrack.samples;u=o[o.length-1]}if((c=u)!==null&&c!==void 0&&c.units){var l=u.units;f=l[l.length-1]}return f},n.parseAVCNALu=function(c){var u=c.byteLength,f=this._avcTrack,o=f.naluState||0,l=o,E=[],p=0,R,P,M,F=-1,w=0;for(o===-1&&(F=0,w=c[0]&31,o=0,p=1);p<u;){if(R=c[p++],!o){o=R?0:1;continue}if(o===1){o=R?0:2;continue}if(!R)o=3;else if(R===1){if(F>=0){var C={data:c.subarray(F,p-o-1),type:w};E.push(C)}else{var B=this.getLastNalUnit();if(B&&(l&&p<=4-l&&B.state&&(B.data=B.data.subarray(0,B.data.byteLength-l)),P=p-o-1,P>0)){var k=new Uint8Array(B.data.byteLength+P);k.set(B.data,0),k.set(c.subarray(0,P),B.data.byteLength),B.data=k,B.state=0}}p<u?(M=c[p]&31,F=p,w=M,o=0):o=-1}else o=0}if(F>=0&&o>=0){var N={data:c.subarray(F,u),type:w,state:o};E.push(N)}if(E.length===0){var W=this.getLastNalUnit();if(W){var j=new Uint8Array(W.data.byteLength+c.byteLength);j.set(W.data,0),j.set(c,W.data.byteLength),W.data=j}}return f.naluState=o,E},n.parseAACPES=function(c){var u=0,f=this._audioTrack,o=this.aacOverFlow,l=c.data;if(o){this.aacOverFlow=null;var E=o.sample.unit.byteLength,p=Math.min(o.missing,E),R=E-p;o.sample.unit.set(l.subarray(0,p),R),f.samples.push(o.sample),u=o.missing}var P,M;for(P=u,M=l.length;P<M-1&&!b.isHeader(l,P);P++);if(P!==u){var F,w;if(P<M-1?(F="AAC PES did not start with ADTS header,offset:"+P,w=!1):(F="no ADTS header found in AAC PES",w=!0),g.logger.warn("parsing error:"+F),this.observer.emit(O.Events.ERROR,O.Events.ERROR,{type:_.ErrorTypes.MEDIA_ERROR,details:_.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}b.initTrackConfig(f,this.observer,l,P,this.audioCodec);var C;if(c.pts!==void 0)C=c.pts;else if(o){var B=b.getFrameDuration(f.samplerate);C=o.sample.pts+B}else{g.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var k=0;P<M;)if(b.isHeader(l,P)){if(P+5<M){var N=b.appendFrame(f,l,P,C,k);if(N)if(N.missing)this.aacOverFlow=N;else{P+=N.length,k++;continue}}break}else P++},n.parseMPEGPES=function(c){var u=c.data,f=u.length,o=0,l=0,E=c.pts;if(E===void 0){g.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<f;)if(y.isHeader(u,l)){var p=y.appendFrame(this._audioTrack,u,l,E,o);if(p)l+=p.length,o++;else break}else l++},n.parseID3PES=function(c){if(c.pts===void 0){g.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}this._id3Track.samples.push(c)},a}();x.minProbeByteLength=188;function v(a,n,h,c){return{key:a,frame:!1,pts:n,dts:h,units:[],debug:c,length:0}}function m(a,n){return(a[n+10]&31)<<8|a[n+11]}function s(a,n,h,c){var u={audio:-1,avc:-1,id3:-1,isAAC:!0},f=(a[n+1]&15)<<8|a[n+2],o=n+3+f-4,l=(a[n+10]&15)<<8|a[n+11];for(n+=12+l;n<o;){var E=(a[n+1]&31)<<8|a[n+2];switch(a[n]){case 207:if(!c){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(!c){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,c,u,f,o,l=a.data;if(!a||a.size===0)return null;for(;l[0].length<19&&l.length>1;){var E=new Uint8Array(l[0].length+l[1].length);E.set(l[0]),E.set(l[1],l[0].length),l[0]=E,l.splice(1,1)}h=l[0];var p=(h[0]<<16)+(h[1]<<8)+h[2];if(p===1){if(c=(h[4]<<8)+h[5],c&&c>a.size-6)return null;var R=h[7];R&192&&(f=(h[9]&14)*536870912+(h[10]&255)*4194304+(h[11]&254)*16384+(h[12]&255)*128+(h[13]&254)/2,R&64?(o=(h[14]&14)*536870912+(h[15]&255)*4194304+(h[16]&254)*16384+(h[17]&255)*128+(h[18]&254)/2,f-o>60*9e4&&(g.logger.warn(Math.round((f-o)/9e4)+"s delta between PTS and DTS, align them"),f=o)):o=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,w=l.length;F<w;F++){h=l[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 c&&(c-=u+3),{data:M,pts:f,dts:o,len:c}}return null}function i(a,n){if(a.units.length&&a.frame){if(a.pts===void 0){var h=n.samples,c=h.length;if(c){var u=h[c-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 c=h-1;c>=0;c--)if(n.pts<a[c].pts){a.splice(c,0,n);break}}else a.push(n)}function r(a){for(var n=a.byteLength,h=[],c=1;c<n-2;)a[c]===0&&a[c+1]===0&&a[c+2]===3?(h.push(c+2),c+=2):c++;if(h.length===0)return a;var u=n-h.length,f=new Uint8Array(u),o=0;for(c=0;c<u;o++,c++)o===h[0]&&(o++,h.shift()),f[c]=a[o];return f}D.default=x},"./src/errors.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"ErrorTypes",function(){return b}),d.d(D,"ErrorDetails",function(){return y});var b;(function(T){T.NETWORK_ERROR="networkError",T.MEDIA_ERROR="mediaError",T.KEY_SYSTEM_ERROR="keySystemError",T.MUX_ERROR="muxError",T.OTHER_ERROR="otherError"})(b||(b={}));var y;(function(T){T.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",T.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",T.KEY_SYSTEM_NO_SESSION="keySystemNoSession",T.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",T.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",T.MANIFEST_LOAD_ERROR="manifestLoadError",T.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",T.MANIFEST_PARSING_ERROR="manifestParsingError",T.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",T.LEVEL_EMPTY_ERROR="levelEmptyError",T.LEVEL_LOAD_ERROR="levelLoadError",T.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",T.LEVEL_SWITCH_ERROR="levelSwitchError",T.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",T.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",T.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",T.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",T.FRAG_LOAD_ERROR="fragLoadError",T.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",T.FRAG_DECRYPT_ERROR="fragDecryptError",T.FRAG_PARSING_ERROR="fragParsingError",T.REMUX_ALLOC_ERROR="remuxAllocError",T.KEY_LOAD_ERROR="keyLoadError",T.KEY_LOAD_TIMEOUT="keyLoadTimeOut",T.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",T.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",T.BUFFER_APPEND_ERROR="bufferAppendError",T.BUFFER_APPENDING_ERROR="bufferAppendingError",T.BUFFER_STALLED_ERROR="bufferStalledError",T.BUFFER_FULL_ERROR="bufferFullError",T.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",T.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",T.INTERNAL_EXCEPTION="internalException",T.INTERNAL_ABORTED="aborted",T.UNKNOWN="unknown"})(y||(y={}))},"./src/events.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"Events",function(){return b});var b;(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"})(b||(b={}))},"./src/hls.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return a});var b=d("./node_modules/url-toolkit/src/url-toolkit.js"),y=d.n(b),T=d("./src/loader/playlist-loader.ts"),I=d("./src/loader/key-loader.ts"),S=d("./src/controller/id3-track-controller.ts"),O=d("./src/controller/latency-controller.ts"),A=d("./src/controller/level-controller.ts"),g=d("./src/controller/fragment-tracker.ts"),_=d("./src/controller/stream-controller.ts"),L=d("./src/is-supported.ts"),x=d("./src/utils/logger.ts"),v=d("./src/config.ts"),m=d("./node_modules/eventemitter3/index.js"),s=d.n(m),e=d("./src/events.ts"),i=d("./src/errors.ts");function t(n,h){for(var c=0;c<h.length;c++){var u=h[c];u.enumerable=u.enumerable||!1,u.configurable=!0,"value"in u&&(u.writable=!0),Object.defineProperty(n,u.key,u)}}function r(n,h,c){return h&&t(n.prototype,h),c&&t(n,c),n}var a=function(){n.isSupported=function(){return Object(L.isSupported)()};function n(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new m.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,c);this.userConfig=c,Object(x.enableLogs)(u.debug),this._autoLevelCapping=-1,u.progressive&&Object(v.enableStreamingMode)(u);var f=u.abrController,o=u.bufferController,l=u.capLevelController,E=u.fpsController,p=this.abrController=new f(this),R=this.bufferController=new o(this),P=this.capLevelController=new l(this),M=new E(this),F=new T.default(this),w=new I.default(this),C=new S.default(this),B=this.levelController=new A.default(this),k=new g.FragmentTracker(this),N=this.streamController=new _.default(this,k);P.setStreamController(N),M.setStreamController(N);var W=[B,N];this.networkControllers=W;var j=[F,w,p,R,P,M,C,k];this.audioTrackController=this.createController(u.audioTrackController,null,W),this.createController(u.audioStreamController,k,W),this.subtitleTrackController=this.createController(u.subtitleTrackController,null,W),this.createController(u.subtitleStreamController,k,W),this.createController(u.timelineController,null,j),this.emeController=this.createController(u.emeController,null,j),this.cmcdController=this.createController(u.cmcdController,null,j),this.latencyController=this.createController(O.default,null,j),this.coreComponents=j}var h=n.prototype;return h.createController=function(u,f,o){if(u){var l=f?new u(this,f):new u(this);return o&&o.push(l),l}return null},h.on=function(u,f,o){o===void 0&&(o=this),this._emitter.on(u,f,o)},h.once=function(u,f,o){o===void 0&&(o=this),this._emitter.once(u,f,o)},h.removeAllListeners=function(u){this._emitter.removeAllListeners(u)},h.off=function(u,f,o,l){o===void 0&&(o=this),this._emitter.off(u,f,o,l)},h.listeners=function(u){return this._emitter.listeners(u)},h.emit=function(u,f,o){return this._emitter.emit(u,f,o)},h.trigger=function(u,f){if(this.config.debug)return this.emit(u,u,f);try{return this.emit(u,u,f)}catch(o){x.logger.error("An internal error happened while handling event "+u+'. Error message: "'+o.message+'". Here is a stacktrace:',o),this.trigger(e.Events.ERROR,{type:i.ErrorTypes.OTHER_ERROR,details:i.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:u,error:o})}return!1},h.listenerCount=function(u){return this._emitter.listenerCount(u)},h.destroy=function(){x.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(u){return u.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(u){return u.destroy()}),this.coreComponents.length=0},h.attachMedia=function(u){x.logger.log("attachMedia"),this._media=u,this.trigger(e.Events.MEDIA_ATTACHING,{media:u})},h.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},h.loadSource=function(u){this.stopLoad();var f=this.media,o=this.url,l=this.url=b.buildAbsoluteURL(self.location.href,u,{alwaysNormalize:!0});x.logger.log("loadSource:"+l),f&&o&&o!==l&&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),x.logger.log("startLoad("+u+")"),this.networkControllers.forEach(function(f){f.startLoad(u)})},h.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(u){u.stopLoad()})},h.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},h.recoverMediaError=function(){x.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){x.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){x.logger.log("set nextLevel:"+u),this.levelController.manualLevel=u,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(u){x.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){x.logger.log("set firstLevel:"+u),this.levelController.firstLevel=u}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(u){x.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&&(x.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 o=u.length,l=0;l<o;l++)if(u[l].maxBitrate>f)return l;return 0}},{key:"maxAutoLevel",get:function(){var u=this.levels,f=this.autoLevelCapping,o;return f===-1&&u&&u.length?o=u.length-1:o=f,o}},{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(U,D,d){"use strict";d.r(D),d.d(D,"isSupported",function(){return T}),d.d(D,"changeTypeSupported",function(){return I});var b=d("./src/utils/mediasource-helper.ts");function y(){return self.SourceBuffer||self.WebKitSourceBuffer}function T(){var S=Object(b.getMediaSource)();if(!S)return!1;var O=y(),A=S&&typeof S.isTypeSupported=="function"&&S.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),g=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!A&&!!g}function I(){var S,O=y();return typeof(O==null||(S=O.prototype)===null||S===void 0?void 0:S.changeType)=="function"}},"./src/loader/fragment-loader.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return x}),d.d(D,"LoadError",function(){return m});var b=d("./src/polyfills/number.ts"),y=d("./src/errors.ts");function T(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||!A(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 S(t,arguments,_(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),g(r,t)},I(s)}function S(s,e,i){return O()?S=Reflect.construct:S=function(r,a,n){var h=[null];h.push.apply(h,a);var c=Function.bind.apply(r,h),u=new c;return n&&g(u,n.prototype),u},S.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function A(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 _(s){return _=Object.setPrototypeOf?Object.getPrototypeOf:function(i){return i.__proto__||Object.getPrototypeOf(i)},_(s)}var L=Math.pow(2,17),x=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 m({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,c=h.fLoader,u=h.loader;return new Promise(function(f,o){a.loader&&a.loader.destroy();var l=a.loader=t.loader=c?new c(h):new u(h),E=v(t),p={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:L};t.stats=l.stats,l.load(E,p,{onSuccess:function(P,M,F,w){a.resetLoader(t,l),f({frag:t,part:null,payload:P.data,networkDetails:w})},onError:function(P,M,F){a.resetLoader(t,l),o(new m({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,l),o(new m({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:F}))},onTimeout:function(P,M,F){a.resetLoader(t,l),o(new m({type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:F}))},onProgress:function(P,M,F,w){r&&r({frag:t,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(t,r,a){var n=this;this.abort();var h=this.config,c=h.fLoader,u=h.loader;return new Promise(function(f,o){n.loader&&n.loader.destroy();var l=n.loader=t.loader=c?new c(h):new u(h),E=v(t,r),p={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:L};r.stats=l.stats,l.load(E,p,{onSuccess:function(P,M,F,w){n.resetLoader(t,l),n.updateStatsFromPart(t,r);var C={frag:t,part:r,payload:P.data,networkDetails:w};a(C),f(C)},onError:function(P,M,F){n.resetLoader(t,l),o(new m({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,l),o(new m({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,l),o(new m({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 c=Math.round(t.duration/r.duration),u=Math.min(Math.round(a.loaded/h),c),f=c-u,o=f*Math.round(a.loaded/u);a.total=a.loaded+o}else a.total=Math.max(a.loaded,a.total);var l=a.loading,E=n.loading;l.start?l.first+=E.first-E.start:(l.start=E.start,l.first=E.first),l.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(b.isFiniteNumber)(r)&&Object(b.isFiniteNumber)(a)&&(t.rangeStart=r,t.rangeEnd=a),t}var m=function(s){T(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(U,D,d){"use strict";d.r(D),d.d(D,"ElementaryStreamTypes",function(){return x}),d.d(D,"BaseSegment",function(){return v}),d.d(D,"Fragment",function(){return m}),d.d(D,"Part",function(){return s});var b=d("./src/polyfills/number.ts"),y=d("./node_modules/url-toolkit/src/url-toolkit.js"),T=d.n(y),I=d("./src/utils/logger.ts"),S=d("./src/loader/level-key.ts"),O=d("./src/loader/load-stats.ts");function A(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 _(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&&_(e.prototype,i),t&&_(e,t),e}var x;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(x||(x={}));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[x.AUDIO]=null,r[x.VIDEO]=null,r[x.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}(),m=function(e){A(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 O.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=S.LevelKey.fromURI(a.uri),h.method=a.method,h.iv=this.createInitializationVector(n),h.keyFormat="identity"),h},t.setElementaryStreamInfo=function(a,n,h,c,u,f){f===void 0&&(f=!1);var o=this.elementaryStreams,l=o[a];if(!l){o[a]={startPTS:n,endPTS:h,startDTS:c,endDTS:u,partial:f};return}l.startPTS=Math.min(l.startPTS,n),l.endPTS=Math.max(l.endPTS,h),l.startDTS=Math.min(l.startDTS,c),l.endDTS=Math.max(l.endDTS,u)},t.clearElementaryStreamInfo=function(){var a=this.elementaryStreams;a[x.AUDIO]=null,a[x.VIDEO]=null,a[x.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(b.isFiniteNumber)(this.programDateTime))return null;var a=Object(b.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){A(i,e);function i(t,r,a,n,h){var c;c=e.call(this,a)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=t.decimalFloatingPoint("DURATION"),c.gap=t.bool("GAP"),c.independent=t.bool("INDEPENDENT"),c.relurl=t.enumeratedString("URI"),c.fragment=r,c.index=n;var u=t.enumeratedString("BYTERANGE");return u&&c.setByteRange(u,h),h&&(c.fragOffset=h.fragOffset+h.duration),c}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(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return I});var b=d("./src/events.ts"),y=d("./src/errors.ts"),T=d("./src/utils/logger.ts"),I=function(){function S(A){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=A,this._registerListeners()}var O=S.prototype;return O._registerListeners=function(){this.hls.on(b.Events.KEY_LOADING,this.onKeyLoading,this)},O._unregisterListeners=function(){this.hls.off(b.Events.KEY_LOADING,this.onKeyLoading)},O.destroy=function(){this._unregisterListeners();for(var g in this.loaders){var _=this.loaders[g];_&&_.destroy()}this.loaders={}},O.onKeyLoading=function(g,_){var L=_.frag,x=L.type,v=this.loaders[x];if(!L.decryptdata){T.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var m=L.decryptdata.uri;if(m!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(v&&(T.logger.warn("abort previous key loader for type:"+x),v.abort()),!m){T.logger.warn("key uri is falsy");return}var e=s.loader,i=L.loader=this.loaders[x]=new e(s);this.decrypturl=m,this.decryptkey=null;var t={url:m,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(b.Events.KEY_LOADED,{frag:L}))},O.loadsuccess=function(g,_,L){var x=L.frag;if(!x.decryptdata){T.logger.error("after key load, decryptdata unset");return}this.decryptkey=x.decryptdata.key=new Uint8Array(g.data),x.loader=null,delete this.loaders[x.type],this.hls.trigger(b.Events.KEY_LOADED,{frag:x})},O.loaderror=function(g,_){var L=_.frag,x=L.loader;x&&x.abort(),delete this.loaders[L.type],this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:L,response:g})},O.loadtimeout=function(g,_){var L=_.frag,x=L.loader;x&&x.abort(),delete this.loaders[L.type],this.hls.trigger(b.Events.ERROR,{type:y.ErrorTypes.NETWORK_ERROR,details:y.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:L})},S}()},"./src/loader/level-details.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"LevelDetails",function(){return S});var b=d("./src/polyfills/number.ts");function y(O,A){for(var g=0;g<A.length;g++){var _=A[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(O,_.key,_)}}function T(O,A,g){return A&&y(O.prototype,A),g&&y(O,g),O}var I=10,S=function(){function O(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 A=O.prototype;return A.reloaded=function(_){if(!_){this.advanced=!0,this.updated=!0;return}var L=this.lastPartSn-_.lastPartSn,x=this.lastPartIndex-_.lastPartIndex;this.updated=this.endSN!==_.endSN||!!x||!!L,this.advanced=this.endSN>_.endSN||L>0||L===0&&x>0,this.updated||this.advanced?this.misses=Math.floor(_.misses*.6):this.misses=_.misses+1,this.availabilityDelay=_.availabilityDelay},T(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(b.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var _=this.driftEndTime-this.driftStartTime;if(_>0){var L=this.driftEnd-this.driftStart;return L*1e3/_}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var _;return(_=this.partList)!==null&&_!==void 0&&_.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var _;return(_=this.fragments)!==null&&_!==void 0&&_.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 _;return(_=this.partList)!==null&&_!==void 0&&_.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var _;return(_=this.partList)!==null&&_!==void 0&&_.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"LevelKey",function(){return S});var b=d("./node_modules/url-toolkit/src/url-toolkit.js"),y=d.n(b);function T(O,A){for(var g=0;g<A.length;g++){var _=A[g];_.enumerable=_.enumerable||!1,_.configurable=!0,"value"in _&&(_.writable=!0),Object.defineProperty(O,_.key,_)}}function I(O,A,g){return A&&T(O.prototype,A),g&&T(O,g),O}var S=function(){O.fromURL=function(g,_){return new O(g,_)},O.fromURI=function(g){return new O(g)};function O(A,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(b.buildAbsoluteURL)(A,g,{alwaysNormalize:!0}):this._uri=A}return I(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"LoadStats",function(){return b});var b=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(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return i});var b=d("./src/polyfills/number.ts"),y=d("./node_modules/url-toolkit/src/url-toolkit.js"),T=d.n(y),I=d("./src/loader/fragment.ts"),S=d("./src/loader/level-details.ts"),O=d("./src/loader/level-key.ts"),A=d("./src/utils/attr-list.ts"),g=d("./src/utils/logger.ts"),_=d("./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,x=/#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"),m=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 c,u;return s.test((c=(u=y.parseURL(h))===null||u===void 0?void 0:u.path)!=null?c:"")}var i=function(){function h(){}return h.findGroup=function(u,f){for(var o=0;o<u.length;o++){var l=u[o];if(l.id===f)return l}},h.convertAVC1ToAVCOTI=function(u){var f=u.split(".");if(f.length>2){var o=f.shift()+".";return o+=parseInt(f.shift()).toString(16),o+=("000"+parseInt(f.shift()).toString(16)).substr(-4),o}return u},h.resolve=function(u,f){return y.buildAbsoluteURL(f,u,{alwaysNormalize:!0})},h.parseMasterPlaylist=function(u,f){var o=[],l={},E=!1;L.lastIndex=0;for(var p;(p=L.exec(u))!=null;)if(p[1]){var R=new A.AttrList(p[1]),P={attrs:R,bitrate:R.decimalInteger("AVERAGE-BANDWIDTH")||R.decimalInteger("BANDWIDTH"),name:R.NAME,url:h.resolve(p[2],f)},M=R.decimalResolution("RESOLUTION");M&&(P.width=M.width,P.height=M.height),t((R.CODECS||"").split(/[ ,]+/).filter(function(w){return w}),P),P.videoCodec&&P.videoCodec.indexOf("avc1")!==-1&&(P.videoCodec=h.convertAVC1ToAVCOTI(P.videoCodec)),o.push(P)}else if(p[3]){var F=new A.AttrList(p[3]);F["DATA-ID"]&&(E=!0,l[F["DATA-ID"]]=F)}return{levels:o,sessionData:E?l:null}},h.parseMasterPlaylistMedia=function(u,f,o,l){l===void 0&&(l=[]);var E,p=[],R=0;for(x.lastIndex=0;(E=x.exec(u))!==null;){var P=new A.AttrList(E[1]);if(P.TYPE===o){var M={attrs:P,bitrate:0,id:R++,groupId:P["GROUP-ID"],instreamId:P["INSTREAM-ID"],name:P.NAME||P.LANGUAGE||"",type:o,default:P.bool("DEFAULT"),autoselect:P.bool("AUTOSELECT"),forced:P.bool("FORCED"),lang:P.LANGUAGE,url:P.URI?h.resolve(P.URI,f):""};if(l.length){var F=h.findGroup(l,M.groupId)||l[0];r(M,F,"audioCodec"),r(M,F,"textCodec")}p.push(M)}}return p},h.parseLevelPlaylist=function(u,f,o,l,E){var p=new S.LevelDetails(f),R=p.fragments,P=null,M=0,F=0,w=0,C=0,B=null,k=new I.Fragment(l,f),N,W,j,K=-1,V=!1;for(v.lastIndex=0,p.m3u8=u;(N=v.exec(u))!==null;){V&&(V=!1,k=new I.Fragment(l,f),k.start=w,k.sn=M,k.cc=C,k.level=o,P&&(k.initSegment=P,k.rawProgramDateTime=P.rawProgramDateTime));var Y=N[1];if(Y){k.duration=parseFloat(Y);var Q=(" "+N[2]).slice(1);k.title=Q||null,k.tagList.push(Q?["INF",Y,Q]:["INF",Y])}else if(N[3])Object(b.isFiniteNumber)(k.duration)&&(k.start=w,j&&(k.levelkey=j),k.sn=M,k.level=o,k.cc=C,k.urlId=E,R.push(k),k.relurl=(" "+N[3]).slice(1),n(k,B),B=k,w+=k.duration,M++,F=0,V=!0);else if(N[4]){var z=(" "+N[4]).slice(1);B?k.setByteRange(z,B):k.setByteRange(z)}else if(N[5])k.rawProgramDateTime=(" "+N[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),K===-1&&(K=R.length);else{if(N=N[0].match(m),!N){g.logger.warn("No matches on slow regex match for level playlist!");continue}for(W=1;W<N.length&&typeof N[W]=="undefined";W++);var re=(" "+N[W]).slice(1),X=(" "+N[W+1]).slice(1),J=N[W+2]?(" "+N[W+2]).slice(1):"";switch(re){case"PLAYLIST-TYPE":p.type=X.toUpperCase();break;case"MEDIA-SEQUENCE":M=p.startSN=parseInt(X);break;case"SKIP":{var se=new A.AttrList(X),ne=se.decimalInteger("SKIPPED-SEGMENTS");if(Object(b.isFiniteNumber)(ne)){p.skippedSegments=ne;for(var pe=ne;pe--;)R.unshift(null);M+=ne}var ee=se.enumeratedString("RECENTLY-REMOVED-DATERANGES");ee&&(p.recentlyRemovedDateranges=ee.split(" "));break}case"TARGETDURATION":p.targetduration=parseFloat(X);break;case"VERSION":p.version=parseInt(X);break;case"EXTM3U":break;case"ENDLIST":p.live=!1;break;case"#":(X||J)&&k.tagList.push(J?[X,J]:[X]);break;case"DIS":C++;case"GAP":k.tagList.push([re]);break;case"BITRATE":k.tagList.push([re,X]);break;case"DISCONTINUITY-SEQ":C=parseInt(X);break;case"KEY":{var Z,q=new A.AttrList(X),$=q.enumeratedString("METHOD"),ue=q.URI,ie=q.hexadecimalInteger("IV"),de=q.enumeratedString("KEYFORMATVERSIONS"),he=q.enumeratedString("KEYID"),ye=(Z=q.enumeratedString("KEYFORMAT"))!=null?Z:"identity",Se=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Se.indexOf(ye)>-1){g.logger.warn("Keyformat "+ye+" is not supported from the manifest");continue}else if(ye!=="identity")continue;$&&(j=O.LevelKey.fromURL(f,ue),ue&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf($)>=0&&(j.method=$,j.keyFormat=ye,he&&(j.keyID=he),de&&(j.keyFormatVersions=de),j.iv=ie));break}case"START":{var fe=new A.AttrList(X),ve=fe.decimalFloatingPoint("TIME-OFFSET");Object(b.isFiniteNumber)(ve)&&(p.startTimeOffset=ve);break}case"MAP":{var _e=new A.AttrList(X);k.relurl=_e.URI,_e.BYTERANGE&&k.setByteRange(_e.BYTERANGE),k.level=o,k.sn="initSegment",j&&(k.levelkey=j),k.initSegment=null,P=k,V=!0;break}case"SERVER-CONTROL":{var ge=new A.AttrList(X);p.canBlockReload=ge.bool("CAN-BLOCK-RELOAD"),p.canSkipUntil=ge.optionalFloat("CAN-SKIP-UNTIL",0),p.canSkipDateRanges=p.canSkipUntil>0&&ge.bool("CAN-SKIP-DATERANGES"),p.partHoldBack=ge.optionalFloat("PART-HOLD-BACK",0),p.holdBack=ge.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var Pe=new A.AttrList(X);p.partTarget=Pe.decimalFloatingPoint("PART-TARGET");break}case"PART":{var xe=p.partList;xe||(xe=p.partList=[]);var Oe=F>0?xe[xe.length-1]:void 0,Ie=F++,Me=new I.Part(new A.AttrList(X),k,f,Ie,Oe);xe.push(Me),k.duration+=Me.duration;break}case"PRELOAD-HINT":{var G=new A.AttrList(X);p.preloadHint=G;break}case"RENDITION-REPORT":{var H=new A.AttrList(X);p.renditionReports=p.renditionReports||[],p.renditionReports.push(H);break}default:g.logger.warn("line parsed but not handled: "+N);break}}}B&&!B.relurl?(R.pop(),w-=B.duration,p.partList&&(p.fragmentHint=B)):p.partList&&(n(k,B),k.cc=C,p.fragmentHint=k);var oe=R.length,le=R[0],Ee=R[oe-1];if(w+=p.skippedSegments*p.targetduration,w>0&&oe&&Ee){p.averagetargetduration=w/oe;var Te=Ee.sn;p.endSN=Te!=="initSegment"?Te:0,le&&(p.startCC=le.cc,le.initSegment||p.fragments.every(function(ae){return ae.relurl&&e(ae.relurl)})&&(g.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),k=new I.Fragment(l,f),k.relurl=Ee.relurl,k.level=o,k.sn="initSegment",le.initSegment=k,p.needSidxRanges=!0))}else p.endSN=0,p.startCC=0;return p.fragmentHint&&(w+=p.fragmentHint.duration),p.totalduration=w,p.endCC=C,K>0&&a(R,K),p},h}();function t(h,c){["video","audio","text"].forEach(function(u){var f=h.filter(function(l){return Object(_.isCodecType)(l,u)});if(f.length){var o=f.filter(function(l){return l.lastIndexOf("avc1",0)===0||l.lastIndexOf("mp4a",0)===0});c[u+"Codec"]=o.length>0?o[0]:f[0],h=h.filter(function(l){return f.indexOf(l)===-1})}}),c.unknownCodecs=h}function r(h,c,u){var f=c[u];f&&(h[u]=f)}function a(h,c){for(var u=h[c],f=c;f--;){var o=h[f];if(!o)return;o.programDateTime=u.programDateTime-o.duration*1e3,u=o}}function n(h,c){h.rawProgramDateTime?h.programDateTime=Date.parse(h.rawProgramDateTime):c!=null&&c.programDateTime&&(h.programDateTime=c.endProgramDateTime),Object(b.isFiniteNumber)(h.programDateTime)||(h.programDateTime=null,h.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/polyfills/number.ts"),y=d("./src/events.ts"),T=d("./src/errors.ts"),I=d("./src/utils/logger.ts"),S=d("./src/utils/mp4-tools.ts"),O=d("./src/loader/m3u8-parser.ts"),A=d("./src/types/loader.ts"),g=d("./src/utils/attr-list.ts");function _(v){var m=v.type;switch(m){case A.PlaylistContextType.AUDIO_TRACK:return A.PlaylistLevelType.AUDIO;case A.PlaylistContextType.SUBTITLE_TRACK:return A.PlaylistLevelType.SUBTITLE;default:return A.PlaylistLevelType.MAIN}}function L(v,m){var s=v.url;return(s===void 0||s.indexOf("data:")===0)&&(s=m.url),s}var x=function(){function v(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var m=v.prototype;return m.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)},m.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)},m.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},m.getInternalLoader=function(e){return this.loaders[e.type]},m.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},m.destroyInternalLoaders=function(){for(var e in this.loaders){var i=this.loaders[e];i&&i.destroy(),this.resetInternalLoader(e)}},m.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},m.onManifestLoading=function(e,i){var t=i.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:A.PlaylistContextType.MANIFEST,url:t,deliveryDirectives:null})},m.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:A.PlaylistContextType.LEVEL,url:a,deliveryDirectives:n})},m.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:A.PlaylistContextType.AUDIO_TRACK,url:a,deliveryDirectives:n})},m.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:A.PlaylistContextType.SUBTITLE_TRACK,url:a,deliveryDirectives:n})},m.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,c,u;switch(e.type){case A.PlaylistContextType.MANIFEST:n=t.manifestLoadingMaxRetry,h=t.manifestLoadingTimeOut,c=t.manifestLoadingRetryDelay,u=t.manifestLoadingMaxRetryTimeout;break;case A.PlaylistContextType.LEVEL:case A.PlaylistContextType.AUDIO_TRACK:case A.PlaylistContextType.SUBTITLE_TRACK:n=0,h=t.levelLoadingTimeOut;break;default:n=t.levelLoadingMaxRetry,h=t.levelLoadingTimeOut,c=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===A.PlaylistContextType.LEVEL&&e.level!==null?f=this.hls.levels[e.level].details:e.type===A.PlaylistContextType.AUDIO_TRACK&&e.id!==null?f=this.hls.audioTracks[e.id].details:e.type===A.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(f=this.hls.subtitleTracks[e.id].details),f){var o=f.partTarget,l=f.targetduration;o&&l&&(h=Math.min(Math.max(o*3,l*.8)*1e3,h))}}var E={timeout:h,maxRetry:n,retryDelay:c,maxRetryDelay:u,highWaterMark:0},p={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};r.load(e,E,p)},m.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)},m.loaderror=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!1,e)},m.loadtimeout=function(e,i,t){t===void 0&&(t=null),this.handleNetworkError(i,t,!0)},m.handleMasterPlaylist=function(e,i,t,r){var a=this.hls,n=e.data,h=L(e,t),c=O.default.parseMasterPlaylist(n,h),u=c.levels,f=c.sessionData;if(!u.length){this.handleManifestParsingError(e,t,"no level found in manifest",r);return}var o=u.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),l=u.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),E=O.default.parseMasterPlaylistMedia(n,h,"AUDIO",o),p=O.default.parseMasterPlaylistMedia(n,h,"SUBTITLES",l),R=O.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:p,captions:R,url:h,stats:i,networkDetails:r,sessionData:f})},m.handleTrackOrLevelPlaylist=function(e,i,t,r){var a=this.hls,n=t.id,h=t.level,c=t.type,u=L(e,t),f=Object(b.isFiniteNumber)(n)?n:0,o=Object(b.isFiniteNumber)(h)?h:f,l=_(t),E=O.default.parseLevelPlaylist(e.data,u,o,l,f);if(!E.fragments.length){a.trigger(y.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.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(c===A.PlaylistContextType.MANIFEST){var p={attrs:new g.AttrList({}),bitrate:0,details:E,name:"",url:u};a.trigger(y.Events.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:i,networkDetails:r,sessionData:null})}if(i.parsing.end=performance.now(),E.needSidxRanges){var R,P=(R=E.fragments[0].initSegment)===null||R===void 0?void 0:R.url;this.load({url:P,isSidxRequest:!0,type:c,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)},m.handleSidxRequest=function(e,i){var t=Object(S.parseSegmentIndex)(new Uint8Array(e.data));if(!!t){var r=t.references,a=i.levelDetails;r.forEach(function(n,h){var c=n.info,u=a.fragments[h];u.byteRange.length===0&&u.setByteRange(String(1+c.end-c.start)+"@"+String(c.start)),u.initSegment&&u.initSegment.setByteRange(String(t.moovEndOffset)+"@0")})}},m.handleManifestParsingError=function(e,i,t,r){this.hls.trigger(y.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===A.PlaylistContextType.MANIFEST,url:e.url,reason:t,response:e,context:i,networkDetails:r})},m.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=T.ErrorDetails.UNKNOWN,n=!1,h=this.getInternalLoader(e);switch(e.type){case A.PlaylistContextType.MANIFEST:a=t?T.ErrorDetails.MANIFEST_LOAD_TIMEOUT:T.ErrorDetails.MANIFEST_LOAD_ERROR,n=!0;break;case A.PlaylistContextType.LEVEL:a=t?T.ErrorDetails.LEVEL_LOAD_TIMEOUT:T.ErrorDetails.LEVEL_LOAD_ERROR,n=!1;break;case A.PlaylistContextType.AUDIO_TRACK:a=t?T.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:T.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,n=!1;break;case A.PlaylistContextType.SUBTITLE_TRACK:a=t?T.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:T.ErrorDetails.SUBTITLE_LOAD_ERROR,n=!1;break}h&&this.resetInternalLoader(e.type);var c={type:T.ErrorTypes.NETWORK_ERROR,details:a,fatal:n,url:e.url,loader:h,context:e,networkDetails:i};r&&(c.response=r),this.hls.trigger(y.Events.ERROR,c)},m.handlePlaylistLoaded=function(e,i,t,r){var a=t.type,n=t.level,h=t.id,c=t.groupId,u=t.loader,f=t.levelDetails,o=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 A.PlaylistContextType.MANIFEST:case A.PlaylistContextType.LEVEL:this.hls.trigger(y.Events.LEVEL_LOADED,{details:f,level:n||0,id:h||0,stats:i,networkDetails:r,deliveryDirectives:o});break;case A.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(y.Events.AUDIO_TRACK_LOADED,{details:f,id:h||0,groupId:c||"",stats:i,networkDetails:r,deliveryDirectives:o});break;case A.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(y.Events.SUBTITLE_TRACK_LOADED,{details:f,id:h||0,groupId:c||"",stats:i,networkDetails:r,deliveryDirectives:o});break}},v}();D.default=x},"./src/polyfills/number.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"isFiniteNumber",function(){return b}),d.d(D,"MAX_SAFE_INTEGER",function(){return y});var b=Number.isFinite||function(T){return typeof T=="number"&&isFinite(T)},y=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(U,D,d){"use strict";d.r(D);var b=function(){function y(){}return y.getSilentFrame=function(I,S){switch(I){case"mp4a.40.2":if(S===1)return new Uint8Array([0,200,0,128,35,128]);if(S===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(S===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(S===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(S===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(S===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(S===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(S===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(S===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},y}();D.default=b},"./src/remux/mp4-generator.ts":function(U,D,d){"use strict";d.r(D);var b=Math.pow(2,32)-1,y=function(){function T(){}return T.init=function(){T.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var S;for(S in T.types)T.types.hasOwnProperty(S)&&(T.types[S]=[S.charCodeAt(0),S.charCodeAt(1),S.charCodeAt(2),S.charCodeAt(3)]);var O=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),A=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);T.HDLR_TYPES={video:O,audio:A};var g=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),_=new Uint8Array([0,0,0,0,0,0,0,0]);T.STTS=T.STSC=T.STCO=_,T.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),T.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),T.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),T.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var L=new Uint8Array([105,115,111,109]),x=new Uint8Array([97,118,99,49]),v=new Uint8Array([0,0,0,1]);T.FTYP=T.box(T.types.ftyp,L,v,L,x),T.DINF=T.box(T.types.dinf,T.box(T.types.dref,g))},T.box=function(S){for(var O=8,A=arguments.length,g=new Array(A>1?A-1:0),_=1;_<A;_++)g[_-1]=arguments[_];for(var L=g.length,x=L;L--;)O+=g[L].byteLength;var v=new Uint8Array(O);for(v[0]=O>>24&255,v[1]=O>>16&255,v[2]=O>>8&255,v[3]=O&255,v.set(S,4),L=0,O=8;L<x;L++)v.set(g[L],O),O+=g[L].byteLength;return v},T.hdlr=function(S){return T.box(T.types.hdlr,T.HDLR_TYPES[S])},T.mdat=function(S){return T.box(T.types.mdat,S)},T.mdhd=function(S,O){O*=S;var A=Math.floor(O/(b+1)),g=Math.floor(O%(b+1));return T.box(T.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,S>>24&255,S>>16&255,S>>8&255,S&255,A>>24,A>>16&255,A>>8&255,A&255,g>>24,g>>16&255,g>>8&255,g&255,85,196,0,0]))},T.mdia=function(S){return T.box(T.types.mdia,T.mdhd(S.timescale,S.duration),T.hdlr(S.type),T.minf(S))},T.mfhd=function(S){return T.box(T.types.mfhd,new Uint8Array([0,0,0,0,S>>24,S>>16&255,S>>8&255,S&255]))},T.minf=function(S){return S.type==="audio"?T.box(T.types.minf,T.box(T.types.smhd,T.SMHD),T.DINF,T.stbl(S)):T.box(T.types.minf,T.box(T.types.vmhd,T.VMHD),T.DINF,T.stbl(S))},T.moof=function(S,O,A){return T.box(T.types.moof,T.mfhd(S),T.traf(A,O))},T.moov=function(S){for(var O=S.length,A=[];O--;)A[O]=T.trak(S[O]);return T.box.apply(null,[T.types.moov,T.mvhd(S[0].timescale,S[0].duration)].concat(A).concat(T.mvex(S)))},T.mvex=function(S){for(var O=S.length,A=[];O--;)A[O]=T.trex(S[O]);return T.box.apply(null,[T.types.mvex].concat(A))},T.mvhd=function(S,O){O*=S;var A=Math.floor(O/(b+1)),g=Math.floor(O%(b+1)),_=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,S>>24&255,S>>16&255,S>>8&255,S&255,A>>24,A>>16&255,A>>8&255,A&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 T.box(T.types.mvhd,_)},T.sdtp=function(S){var O=S.samples||[],A=new Uint8Array(4+O.length),g,_;for(g=0;g<O.length;g++)_=O[g].flags,A[g+4]=_.dependsOn<<4|_.isDependedOn<<2|_.hasRedundancy;return T.box(T.types.sdtp,A)},T.stbl=function(S){return T.box(T.types.stbl,T.stsd(S),T.box(T.types.stts,T.STTS),T.box(T.types.stsc,T.STSC),T.box(T.types.stsz,T.STSZ),T.box(T.types.stco,T.STCO))},T.avc1=function(S){var O=[],A=[],g,_,L;for(g=0;g<S.sps.length;g++)_=S.sps[g],L=_.byteLength,O.push(L>>>8&255),O.push(L&255),O=O.concat(Array.prototype.slice.call(_));for(g=0;g<S.pps.length;g++)_=S.pps[g],L=_.byteLength,A.push(L>>>8&255),A.push(L&255),A=A.concat(Array.prototype.slice.call(_));var x=T.box(T.types.avcC,new Uint8Array([1,O[3],O[4],O[5],252|3,224|S.sps.length].concat(O).concat([S.pps.length]).concat(A))),v=S.width,m=S.height,s=S.pixelRatio[0],e=S.pixelRatio[1];return T.box(T.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,v>>8&255,v&255,m>>8&255,m&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),x,T.box(T.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),T.box(T.types.pasp,new Uint8Array([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},T.esds=function(S){var O=S.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(S.config).concat([6,1,2]))},T.mp4a=function(S){var O=S.samplerate;return T.box(T.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),T.box(T.types.esds,T.esds(S)))},T.mp3=function(S){var O=S.samplerate;return T.box(T.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},T.stsd=function(S){return S.type==="audio"?!S.isAAC&&S.codec==="mp3"?T.box(T.types.stsd,T.STSD,T.mp3(S)):T.box(T.types.stsd,T.STSD,T.mp4a(S)):T.box(T.types.stsd,T.STSD,T.avc1(S))},T.tkhd=function(S){var O=S.id,A=S.duration*S.timescale,g=S.width,_=S.height,L=Math.floor(A/(b+1)),x=Math.floor(A%(b+1));return T.box(T.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,L>>24,L>>16&255,L>>8&255,L&255,x>>24,x>>16&255,x>>8&255,x&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,g>>8&255,g&255,0,0,_>>8&255,_&255,0,0]))},T.traf=function(S,O){var A=T.sdtp(S),g=S.id,_=Math.floor(O/(b+1)),L=Math.floor(O%(b+1));return T.box(T.types.traf,T.box(T.types.tfhd,new Uint8Array([0,0,0,0,g>>24,g>>16&255,g>>8&255,g&255])),T.box(T.types.tfdt,new Uint8Array([1,0,0,0,_>>24,_>>16&255,_>>8&255,_&255,L>>24,L>>16&255,L>>8&255,L&255])),T.trun(S,A.length+16+20+8+16+8+8),A)},T.trak=function(S){return S.duration=S.duration||4294967295,T.box(T.types.trak,T.tkhd(S),T.mdia(S))},T.trex=function(S){var O=S.id;return T.box(T.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},T.trun=function(S,O){var A=S.samples||[],g=A.length,_=12+16*g,L=new Uint8Array(_),x,v,m,s,e,i;for(O+=8+_,L.set([0,0,15,1,g>>>24&255,g>>>16&255,g>>>8&255,g&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),x=0;x<g;x++)v=A[x],m=v.duration,s=v.size,e=v.flags,i=v.cts,L.set([m>>>24&255,m>>>16&255,m>>>8&255,m&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*x);return T.box(T.types.trun,L)},T.initSegment=function(S){T.types||T.init();var O=T.moov(S),A=new Uint8Array(T.FTYP.byteLength+O.byteLength);return A.set(T.FTYP),A.set(O,T.FTYP.byteLength),A},T}();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,D.default=y},"./src/remux/mp4-remuxer.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return i}),d.d(D,"normalizePts",function(){return t});var b=d("./src/polyfills/number.ts"),y=d("./src/remux/aac-helper.ts"),T=d("./src/remux/mp4-generator.ts"),I=d("./src/events.ts"),S=d("./src/errors.ts"),O=d("./src/utils/logger.ts"),A=d("./src/types/loader.ts"),g=d("./src/utils/timescale-conversion.ts");function _(){return _=Object.assign||function(h){for(var c=1;c<arguments.length;c++){var u=arguments[c];for(var f in u)Object.prototype.hasOwnProperty.call(u,f)&&(h[f]=u[f])}return h},_.apply(this,arguments)}var L=10*1e3,x=1024,v=1152,m=null,s=null,e=!1,i=function(){function h(u,f,o,l){if(l===void 0&&(l=""),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=o,this.ISGenerated=!1,m===null){var E=navigator.userAgent||"",p=E.match(/Chrome\/(\d+)/i);m=p?parseInt(p[1]):0}if(s===null){var R=navigator.userAgent.match(/Safari\/(\d+)/i);s=R?parseInt(R[1]):0}e=!!m&&m<75||!!s&&s<600}var c=h.prototype;return c.destroy=function(){},c.resetTimeStamp=function(f){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=f},c.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},c.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},c.getVideoStartPts=function(f){var o=!1,l=f.reduce(function(E,p){var R=p.pts-E;return R<-4294967296?(o=!0,t(E,p.pts)):R>0?E:p.pts},f[0].pts);return o&&O.logger.debug("PTS rollover detected"),l},c.remux=function(f,o,l,E,p,R,P,M){var F,w,C,B,k,N,W=p,j=p,K=f.pid>-1,V=o.pid>-1,Y=o.samples.length,Q=f.samples.length>0,z=Y>1,re=(!K||Q)&&(!V||z)||this.ISGenerated||P;if(re){this.ISGenerated||(C=this.generateIS(f,o,p));var X=this.isVideoContiguous,J=-1;if(z&&(J=r(o.samples),!X&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,J>0){O.logger.warn("[mp4-remuxer]: Dropped "+J+" out of "+Y+" video samples due to a missing keyframe");var se=this.getVideoStartPts(o.samples);o.samples=o.samples.slice(J),o.dropped+=J,j+=(o.samples[0].pts-se)/(o.timescale||9e4)}else J===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+Y+" video samples"),N=!1);if(this.ISGenerated){if(Q&&z){var ne=this.getVideoStartPts(o.samples),pe=t(f.samples[0].pts,ne)-ne,ee=pe/o.inputTimeScale;W+=Math.max(0,ee),j+=Math.max(0,-ee)}if(Q){if(f.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),C=this.generateIS(f,o,p)),w=this.remuxAudio(f,W,this.isAudioContiguous,R,V||z||M===A.PlaylistLevelType.AUDIO?j:void 0),z){var Z=w?w.endPTS-w.startPTS:0;o.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),C=this.generateIS(f,o,p)),F=this.remuxVideo(o,j,X,Z)}}else z&&(F=this.remuxVideo(o,j,X,0));F&&(F.firstKeyFrame=J,F.independent=J!==-1)}}return this.ISGenerated&&(l.samples.length&&(k=this.remuxID3(l,p)),E.samples.length&&(B=this.remuxText(E,p))),{audio:w,video:F,initSegment:C,independent:N,text:B,id3:k}},c.generateIS=function(f,o,l){var E=f.samples,p=o.samples,R=this.typeSupported,P={},M=!Object(b.isFiniteNumber)(this._initPTS),F="audio/mp4",w,C,B;if(M&&(w=C=1/0),f.config&&E.length&&(f.timescale=f.samplerate,f.isAAC||(R.mpeg?(F="audio/mpeg",f.codec=""):R.mp3&&(f.codec="mp3")),P.audio={id:"audio",container:F,codec:f.codec,initSegment:!f.isAAC&&R.mpeg?new Uint8Array(0):T.default.initSegment([f]),metadata:{channelCount:f.channelCount}},M&&(B=f.inputTimeScale,w=C=E[0].pts-Math.round(B*l))),o.sps&&o.pps&&p.length&&(o.timescale=o.inputTimeScale,P.video={id:"main",container:"video/mp4",codec:o.codec,initSegment:T.default.initSegment([o]),metadata:{width:o.width,height:o.height}},M)){B=o.inputTimeScale;var k=this.getVideoStartPts(p),N=Math.round(B*l);C=Math.min(C,t(p[0].dts,k)-N),w=Math.min(w,k-N)}if(Object.keys(P).length)return this.ISGenerated=!0,M&&(this._initPTS=w,this._initDTS=C),{tracks:P,initPTS:w,timescale:B}},c.remuxVideo=function(f,o,l,E){var p=f.inputTimeScale,R=f.samples,P=[],M=R.length,F=this._initPTS,w=this.nextAvcDts,C=8,B,k,N,W=Number.POSITIVE_INFINITY,j=Number.NEGATIVE_INFINITY,K=0,V=!1;if(!l||w===null){var Y=o*p,Q=R[0].pts-t(R[0].dts,R[0].pts);w=Y-Q}for(var z=0;z<M;z++){var re=R[z];if(re.pts=t(re.pts-F,w),re.dts=t(re.dts-F,w),re.dts>re.pts){var X=9e4*.2;K=Math.max(Math.min(K,re.pts-re.dts),-1*X)}re.dts<R[z>0?z-1:z].dts&&(V=!0)}V&&R.sort(function(Ne,Ye){var Ke=Ne.dts-Ye.dts,Xe=Ne.pts-Ye.pts;return Ke||Xe}),k=R[0].dts,N=R[R.length-1].dts;var J=Math.round((N-k)/(M-1));if(K<0){if(K<J*-2){O.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(g.toMsFromMpegTsClock)(-J,!0)+" ms");for(var se=K,ne=0;ne<M;ne++)R[ne].dts=se=Math.max(se,R[ne].pts-J),R[ne].pts=Math.max(se,R[ne].pts)}else{O.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(g.toMsFromMpegTsClock)(K,!0)+" ms to overcome this issue");for(var pe=0;pe<M;pe++)R[pe].dts=R[pe].dts+K}k=R[0].dts}if(l){var ee=k-w,Z=ee>J,q=ee<-1;if(Z||q){Z?O.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(ee,!0)+" ms ("+ee+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(g.toMsFromMpegTsClock)(-ee,!0)+" ms ("+ee+"dts) overlapping between fragments detected"),k=w;var $=R[0].pts-ee;R[0].dts=k,R[0].pts=$,O.logger.log("Video: First PTS/DTS adjusted: "+Object(g.toMsFromMpegTsClock)($,!0)+"/"+Object(g.toMsFromMpegTsClock)(k,!0)+", delta: "+Object(g.toMsFromMpegTsClock)(ee,!0)+" ms")}}e&&(k=Math.max(0,k));for(var ue=0,ie=0,de=0;de<M;de++){for(var he=R[de],ye=he.units,Se=ye.length,fe=0,ve=0;ve<Se;ve++)fe+=ye[ve].data.length;ie+=fe,ue+=Se,he.length=fe,he.dts=Math.max(he.dts,k),he.pts=Math.max(he.pts,he.dts,0),W=Math.min(he.pts,W),j=Math.max(he.pts,j)}N=R[M-1].dts;var _e=ie+4*ue+8,ge;try{ge=new Uint8Array(_e)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:_e,reason:"fail allocating video mdat "+_e});return}var Pe=new DataView(ge.buffer);Pe.setUint32(0,_e),ge.set(T.default.types.mdat,4);for(var xe=0;xe<M;xe++){for(var Oe=R[xe],Ie=Oe.units,Me=0,G=0,H=Ie.length;G<H;G++){var oe=Ie[G],le=oe.data,Ee=oe.data.byteLength;Pe.setUint32(C,Ee),C+=4,ge.set(le,C),C+=Ee,Me+=4+Ee}if(xe<M-1)B=R[xe+1].dts-Oe.dts;else{var Te=this.config,ae=Oe.dts-R[xe>0?xe-1:xe].dts;if(Te.stretchShortVideoTrack&&this.nextAudioPts!==null){var be=Math.floor(Te.maxBufferHole*p),Le=(E?W+E*p:this.nextAudioPts)-Oe.pts;Le>be?(B=Le-ae,B<0&&(B=ae),O.logger.log("[mp4-remuxer]: It is approximately "+Le/90+" ms to the next segment; using duration "+B/90+" ms for the last video frame.")):B=ae}else B=ae}var Ce=Math.round(Oe.pts-Oe.dts);P.push(new a(Oe.key,B,Me,Ce))}if(P.length&&m&&m<70){var Ve=P[0].flags;Ve.dependsOn=2,Ve.isNonSync=0}console.assert(B!==void 0,"mp4SampleDuration must be computed"),this.nextAvcDts=w=N+B,this.isVideoContiguous=!0;var tt=T.default.moof(f.sequenceNumber++,k,_({},f,{samples:P})),Be="video",rt={data1:tt,data2:ge,startPTS:W/p,endPTS:(j+B)/p,startDTS:k/p,endDTS:w/p,type:Be,hasAudio:!1,hasVideo:!0,nb:P.length,dropped:f.dropped};return f.samples=[],f.dropped=0,console.assert(ge.length,"MDAT length must not be zero"),rt},c.remuxAudio=function(f,o,l,E,p){var R=f.inputTimeScale,P=f.samplerate?f.samplerate:R,M=R/P,F=f.isAAC?x:v,w=F*M,C=this._initPTS,B=!f.isAAC&&this.typeSupported.mpeg,k=[],N=f.samples,W=B?0:8,j=this.nextAudioPts||-1,K=o*R;if(this.isAudioContiguous=l=l||N.length&&j>0&&(E&&Math.abs(K-j)<9e3||Math.abs(t(N[0].pts-C,K)-j)<20*w),N.forEach(function(le){le.pts=t(le.pts-C,K)}),!l||j<0){if(N=N.filter(function(le){return le.pts>=0}),!N.length)return;p===0?j=0:E?j=Math.max(0,K):j=N[0].pts}if(f.isAAC)for(var V=p!==void 0,Y=this.config.maxAudioFramesDrift,Q=0,z=j;Q<N.length;Q++){var re=N[Q],X=re.pts,J=X-z,se=Math.abs(1e3*J/R);if(J<=-Y*w&&V)Q===0&&(O.logger.warn("Audio frame @ "+(X/R).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*J/R)+" ms."),this.nextAudioPts=j=z=X);else if(J>=Y*w&&se<L&&V){var ne=Math.round(J/w);z=X-ne*w,z<0&&(ne--,z+=w),Q===0&&(this.nextAudioPts=j=z),O.logger.warn("[mp4-remuxer]: Injecting "+ne+" audio frame @ "+(z/R).toFixed(3)+"s due to "+Math.round(1e3*J/R)+" ms gap.");for(var pe=0;pe<ne;pe++){var ee=Math.max(z,0),Z=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);Z||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=re.unit.subarray()),N.splice(Q,0,{unit:Z,pts:ee}),z+=w,Q++}}re.pts=z,z+=w}for(var q=null,$=null,ue,ie=0,de=N.length;de--;)ie+=N[de].unit.byteLength;for(var he=0,ye=N.length;he<ye;he++){var Se=N[he],fe=Se.unit,ve=Se.pts;if($!==null){var _e=k[he-1];_e.duration=Math.round((ve-$)/M)}else if(l&&f.isAAC&&(ve=j),q=ve,ie>0){ie+=W;try{ue=new Uint8Array(ie)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ie,reason:"fail allocating audio mdat "+ie});return}if(!B){var ge=new DataView(ue.buffer);ge.setUint32(0,ie),ue.set(T.default.types.mdat,4)}}else return;ue.set(fe,W);var Pe=fe.byteLength;W+=Pe,k.push(new a(!0,F,Pe,0)),$=ve}var xe=k.length;if(!!xe){var Oe=k[k.length-1];this.nextAudioPts=j=$+M*Oe.duration;var Ie=B?new Uint8Array(0):T.default.moof(f.sequenceNumber++,q/M,_({},f,{samples:k}));f.samples=[];var Me=q/R,G=j/R,H="audio",oe={data1:Ie,data2:ue,startPTS:Me,endPTS:G,startDTS:Me,endDTS:G,type:H,hasAudio:!0,hasVideo:!1,nb:xe};return this.isAudioContiguous=!0,console.assert(ue.length,"MDAT length must not be zero"),oe}},c.remuxEmptyAudio=function(f,o,l,E){var p=f.inputTimeScale,R=f.samplerate?f.samplerate:p,P=p/R,M=this.nextAudioPts,F=(M!==null?M:E.startDTS*p)+this._initDTS,w=E.endDTS*p+this._initDTS,C=P*x,B=Math.ceil((w-F)/C),k=y.default.getSilentFrame(f.manifestCodec||f.codec,f.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!k){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],W=0;W<B;W++){var j=F+W*C;N.push({unit:k,pts:j,dts:j})}return f.samples=N,this.remuxAudio(f,o,l,!1)},c.remuxID3=function(f,o){var l=f.samples.length;if(!!l){for(var E=f.inputTimeScale,p=this._initPTS,R=this._initDTS,P=0;P<l;P++){var M=f.samples[P];M.pts=t(M.pts-p,o*E)/E,M.dts=t(M.dts-R,o*E)/E}var F=f.samples;return f.samples=[],{samples:F}}},c.remuxText=function(f,o){var l=f.samples.length;if(!!l){for(var E=f.inputTimeScale,p=this._initPTS,R=0;R<l;R++){var P=f.samples[R];P.pts=t(P.pts-p,o*E)/E}f.samples.sort(function(F,w){return F.pts-w.pts});var M=f.samples;return f.samples=[],{samples:M}}},h}();function t(h,c){var u;if(c===null)return h;for(c<h?u=-8589934592:u=8589934592;Math.abs(h-c)>4294967296;)h+=u;return h}function r(h){for(var c=0;c<h.length;c++)if(h[c].key)return c;return-1}var a=function(c,u,f,o){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=u,this.size=f,this.cts=o,this.flags=new n(c)},n=function(c){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=c?2:1,this.isNonSync=c?0:1}},"./src/remux/passthrough-remuxer.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/polyfills/number.ts"),y=d("./src/utils/mp4-tools.ts"),T=d("./src/loader/fragment.ts"),I=d("./src/utils/logger.ts"),S=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 _=g.prototype;return _.destroy=function(){},_.resetTimeStamp=function(x){this.initPTS=x,this.lastEndDTS=null},_.resetNextTimestamp=function(){this.lastEndDTS=null},_.resetInitSegment=function(x,v,m){this.audioCodec=v,this.videoCodec=m,this.generateInitSegment(x),this.emitInitSegment=!0},_.generateInitSegment=function(x){var v=this.audioCodec,m=this.videoCodec;if(!x||!x.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(y.parseInitSegment)(x);v||(v=A(s.audio,T.ElementaryStreamTypes.AUDIO)),m||(m=A(s.video,T.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:v+","+m,initSegment:x,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:v,initSegment:x,id:"audio"}:s.video?e.video={container:"video/mp4",codec:m,initSegment:x,id:"main"}:I.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},_.remux=function(x,v,m,s,e){var i=this.initPTS,t=this.lastEndDTS,r={audio:void 0,video:void 0,text:s,id3:m,initSegment:void 0};Object(b.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(b.isFiniteNumber)(i)||(this.initPTS=n.initPTS=i=O(h,a,t));var c=Object(y.getDuration)(a,h),u=t,f=c+u;Object(y.offsetStartDTS)(h,a,i),c>0?this.lastEndDTS=f:(I.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var o=!!h.audio,l=!!h.video,E="";o&&(E+="audio"),l&&(E+="video");var p={data1:a,startPTS:u,startDTS:u,endPTS:f,endDTS:f,type:E,hasAudio:o,hasVideo:l,nb:1,dropped:0};return r.audio=p.type==="audio"?p:void 0,r.video=p.type!=="audio"?p:void 0,r.text=s,r.id3=m,r.initSegment=n,r},g}(),O=function(_,L,x){return Object(y.getStartDTS)(_,L)-x};function A(g,_){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"||_===T.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}D.default=S},"./src/task-loop.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return b});var b=function(){function y(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var T=y.prototype;return T.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},T.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},T.onHandlerDestroyed=function(){},T.hasInterval=function(){return!!this._tickInterval},T.hasNextTick=function(){return!!this._tickTimer},T.setInterval=function(S){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,S),!0)},T.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},T.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},T.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},T.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},T.doTick=function(){},y}()},"./src/types/cmcd.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"CMCDVersion",function(){return b}),d.d(D,"CMCDObjectType",function(){return y}),d.d(D,"CMCDStreamingFormat",function(){return T}),d.d(D,"CMCDStreamType",function(){return I});var b=1,y;(function(S){S.MANIFEST="m",S.AUDIO="a",S.VIDEO="v",S.MUXED="av",S.INIT="i",S.CAPTION="c",S.TIMED_TEXT="tt",S.KEY="k",S.OTHER="o"})(y||(y={}));var T;(function(S){S.DASH="d",S.HLS="h",S.SMOOTH="s",S.OTHER="o"})(T||(T={}));var I;(function(S){S.VOD="v",S.LIVE="l"})(I||(I={}))},"./src/types/level.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"HlsSkip",function(){return T}),d.d(D,"getSkipValue",function(){return I}),d.d(D,"HlsUrlParameters",function(){return S}),d.d(D,"Level",function(){return O});function b(A,g){for(var _=0;_<g.length;_++){var L=g[_];L.enumerable=L.enumerable||!1,L.configurable=!0,"value"in L&&(L.writable=!0),Object.defineProperty(A,L.key,L)}}function y(A,g,_){return g&&b(A.prototype,g),_&&b(A,_),A}var T;(function(A){A.No="",A.Yes="YES",A.v2="v2"})(T||(T={}));function I(A,g){var _=A.canSkipUntil,L=A.canSkipDateRanges,x=A.endSN,v=g!==void 0?g-x:0;return _&&v<_?L?T.v2:T.Yes:T.No}var S=function(){function A(_,L,x){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=_,this.part=L,this.skip=x}var g=A.prototype;return g.addDirectives=function(L){var x=new self.URL(L);return this.msn!==void 0&&x.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&x.searchParams.set("_HLS_part",this.part.toString()),this.skip&&x.searchParams.set("_HLS_skip",this.skip),x.toString()},A}(),O=function(){function A(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(_){return _}).join(",").replace(/\.[^.,]+/g,"")}return y(A,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(_){var L=_%this.url.length;this._urlId!==L&&(this.details=void 0,this._urlId=L)}}]),A}()},"./src/types/loader.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"PlaylistContextType",function(){return b}),d.d(D,"PlaylistLevelType",function(){return y});var b;(function(T){T.MANIFEST="manifest",T.LEVEL="level",T.AUDIO_TRACK="audioTrack",T.SUBTITLE_TRACK="subtitleTrack"})(b||(b={}));var y;(function(T){T.MAIN="main",T.AUDIO="audio",T.SUBTITLE="subtitle"})(y||(y={}))},"./src/types/transmuxer.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"ChunkMetadata",function(){return b});var b=function(I,S,O,A,g,_){A===void 0&&(A=0),g===void 0&&(g=-1),_===void 0&&(_=!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=S,this.id=O,this.size=A,this.part=g,this.partial=_};function y(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"AttrList",function(){return T});var b=/^(\d+)x(\d+)$/,y=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,T=function(){function I(O){typeof O=="string"&&(O=I.parseAttrList(O));for(var A in O)O.hasOwnProperty(A)&&(this[A]=O[A])}var S=I.prototype;return S.decimalInteger=function(A){var g=parseInt(this[A],10);return g>Number.MAX_SAFE_INTEGER?1/0:g},S.hexadecimalInteger=function(A){if(this[A]){var g=(this[A]||"0x").slice(2);g=(g.length&1?"0":"")+g;for(var _=new Uint8Array(g.length/2),L=0;L<g.length/2;L++)_[L]=parseInt(g.slice(L*2,L*2+2),16);return _}else return null},S.hexadecimalIntegerAsNumber=function(A){var g=parseInt(this[A],16);return g>Number.MAX_SAFE_INTEGER?1/0:g},S.decimalFloatingPoint=function(A){return parseFloat(this[A])},S.optionalFloat=function(A,g){var _=this[A];return _?parseFloat(_):g},S.enumeratedString=function(A){return this[A]},S.bool=function(A){return this[A]==="YES"},S.decimalResolution=function(A){var g=b.exec(this[A]);if(g!==null)return{width:parseInt(g[1],10),height:parseInt(g[2],10)}},I.parseAttrList=function(A){var g,_={},L='"';for(y.lastIndex=0;(g=y.exec(A))!==null;){var x=g[2];x.indexOf(L)===0&&x.lastIndexOf(L)===x.length-1&&(x=x.slice(1,-1)),_[g[1]]=x}return _},I}()},"./src/utils/binary-search.ts":function(U,D,d){"use strict";d.r(D);var b={search:function(T,I){for(var S=0,O=T.length-1,A=null,g=null;S<=O;){A=(S+O)/2|0,g=T[A];var _=I(g);if(_>0)S=A+1;else if(_<0)O=A-1;else return g}return null}};D.default=b},"./src/utils/buffer-helper.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"BufferHelper",function(){return T});var b=d("./src/utils/logger.ts"),y={length:0,start:function(){return 0},end:function(){return 0}},T=function(){function I(){}return I.isBuffered=function(O,A){try{if(O){for(var g=I.getBuffered(O),_=0;_<g.length;_++)if(A>=g.start(_)&&A<=g.end(_))return!0}}catch{}return!1},I.bufferInfo=function(O,A,g){try{if(O){var _=I.getBuffered(O),L=[],x;for(x=0;x<_.length;x++)L.push({start:_.start(x),end:_.end(x)});return this.bufferedInfo(L,A,g)}}catch{}return{len:0,start:A,end:A,nextStart:void 0}},I.bufferedInfo=function(O,A,g){A=Math.max(0,A),O.sort(function(n,h){var c=n.start-h.start;return c||h.end-n.end});var _=[];if(g)for(var L=0;L<O.length;L++){var x=_.length;if(x){var v=_[x-1].end;O[L].start-v<g?O[L].end>v&&(_[x-1].end=O[L].end):_.push(O[L])}else _.push(O[L])}else _=O;for(var m=0,s,e=A,i=A,t=0;t<_.length;t++){var r=_[t].start,a=_[t].end;if(A+g>=r&&A<a)e=r,i=a,m=i-A;else if(A+g<r){s=r;break}}return{len:m,start:e||0,end:i||0,nextStart:s}},I.getBuffered=function(O){try{return O.buffered}catch(A){return b.logger.log("failed to get media.buffered",A),y}},I}()},"./src/utils/cea-608-parser.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"Row",function(){return i}),d.d(D,"CaptionScreen",function(){return t});var b=d("./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},T=function(f){var o=f;return y.hasOwnProperty(f)&&(o=y[f]),String.fromCharCode(o)},I=15,S=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},A={17:2,18:4,21:6,22:8,23:10,19:13,20:15},g={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_={25:2,26:4,29:6,30:8,31:10,27:13,28:15},L=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],x;(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"})(x||(x={}));var v=function(){function u(){this.time=null,this.verboseLevel=x.ERROR}var f=u.prototype;return f.log=function(l,E){this.verboseLevel>=l&&b.logger.log(this.time+" ["+l+"] "+E)},u}(),m=function(f){for(var o=[],l=0;l<f.length;l++)o.push(f[l].toString(16));return o},s=function(){function u(o,l,E,p,R){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=o||"white",this.underline=l||!1,this.italics=E||!1,this.background=p||"black",this.flash=R||!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(l){for(var E=["foreground","underline","italics","background","flash"],p=0;p<E.length;p++){var R=E[p];l.hasOwnProperty(R)&&(this[R]=l[R])}},f.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},f.equals=function(l){return this.foreground===l.foreground&&this.underline===l.underline&&this.italics===l.italics&&this.background===l.background&&this.flash===l.flash},f.copy=function(l){this.foreground=l.foreground,this.underline=l.underline,this.italics=l.italics,this.background=l.background,this.flash=l.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(o,l,E,p,R,P){this.uchar=void 0,this.penState=void 0,this.uchar=o||" ",this.penState=new s(l,E,p,R,P)}var f=u.prototype;return f.reset=function(){this.uchar=" ",this.penState.reset()},f.setChar=function(l,E){this.uchar=l,this.penState.copy(E)},f.setPenState=function(l){this.penState.copy(l)},f.equals=function(l){return this.uchar===l.uchar&&this.penState.equals(l.penState)},f.copy=function(l){this.uchar=l.uchar,this.penState.copy(l.penState)},f.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},u}(),i=function(){function u(o){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var l=0;l<S;l++)this.chars.push(new e);this.logger=o,this.pos=0,this.currPenState=new s}var f=u.prototype;return f.equals=function(l){for(var E=!0,p=0;p<S;p++)if(!this.chars[p].equals(l.chars[p])){E=!1;break}return E},f.copy=function(l){for(var E=0;E<S;E++)this.chars[E].copy(l.chars[E])},f.isEmpty=function(){for(var l=!0,E=0;E<S;E++)if(!this.chars[E].isEmpty()){l=!1;break}return l},f.setCursor=function(l){this.pos!==l&&(this.pos=l),this.pos<0?(this.logger.log(x.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>S&&(this.logger.log(x.DEBUG,"Too large cursor position "+this.pos),this.pos=S)},f.moveCursor=function(l){var E=this.pos+l;if(l>1)for(var p=this.pos+1;p<E+1;p++)this.chars[p].setPenState(this.currPenState);this.setCursor(E)},f.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},f.insertChar=function(l){l>=144&&this.backSpace();var E=T(l);if(this.pos>=S){this.logger.log(x.ERROR,"Cannot insert "+l.toString(16)+" ("+E+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(E,this.currPenState),this.moveCursor(1)},f.clearFromPos=function(l){var E;for(E=l;E<S;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 l=[],E=!0,p=0;p<S;p++){var R=this.chars[p].uchar;R!==" "&&(E=!1),l.push(R)}return E?"":l.join("")},f.setPenStyles=function(l){this.currPenState.setStyles(l);var E=this.chars[this.pos];E.setPenState(this.currPenState)},u}(),t=function(){function u(o){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var l=0;l<I;l++)this.rows.push(new i(o));this.logger=o,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var f=u.prototype;return f.reset=function(){for(var l=0;l<I;l++)this.rows[l].clear();this.currRow=I-1},f.equals=function(l){for(var E=!0,p=0;p<I;p++)if(!this.rows[p].equals(l.rows[p])){E=!1;break}return E},f.copy=function(l){for(var E=0;E<I;E++)this.rows[E].copy(l.rows[E])},f.isEmpty=function(){for(var l=!0,E=0;E<I;E++)if(!this.rows[E].isEmpty()){l=!1;break}return l},f.backSpace=function(){var l=this.rows[this.currRow];l.backSpace()},f.clearToEndOfRow=function(){var l=this.rows[this.currRow];l.clearToEndOfRow()},f.insertChar=function(l){var E=this.rows[this.currRow];E.insertChar(l)},f.setPen=function(l){var E=this.rows[this.currRow];E.setPenStyles(l)},f.moveCursor=function(l){var E=this.rows[this.currRow];E.moveCursor(l)},f.setCursor=function(l){this.logger.log(x.INFO,"setCursor: "+l);var E=this.rows[this.currRow];E.setCursor(l)},f.setPAC=function(l){this.logger.log(x.INFO,"pacData = "+JSON.stringify(l));var E=l.row-1;if(this.nrRollUpRows&&E<this.nrRollUpRows-1&&(E=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==E){for(var p=0;p<I;p++)this.rows[p].clear();var R=this.currRow+1-this.nrRollUpRows,P=this.lastOutputScreen;if(P){var M=P.rows[R].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[E-this.nrRollUpRows+w+1].copy(P.rows[R+w])}}this.currRow=E;var C=this.rows[this.currRow];if(l.indent!==null){var B=l.indent,k=Math.max(B-1,0);C.setCursor(l.indent),l.color=C.chars[k].penState.foreground}var N={foreground:l.color,underline:l.underline,italics:l.italics,background:"black",flash:!1};this.setPen(N)},f.setBkgData=function(l){this.logger.log(x.INFO,"bkgData = "+JSON.stringify(l)),this.backSpace(),this.setPen(l),this.insertChar(32)},f.setRollUpRows=function(l){this.nrRollUpRows=l},f.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(x.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(x.TEXT,this.getDisplayText());var l=this.currRow+1-this.nrRollUpRows,E=this.rows.splice(l,1)[0];E.clear(),this.rows.splice(this.currRow,0,E),this.logger.log(x.INFO,"Rolling up")},f.getDisplayText=function(l){l=l||!1;for(var E=[],p="",R=-1,P=0;P<I;P++){var M=this.rows[P].getTextString();M&&(R=P+1,l?E.push("Row "+R+": '"+M+"'"):E.push(M.trim()))}return E.length>0&&(l?p="["+E.join(" | ")+"]":p=E.join(`
|
|
19
|
-
`)),p},f.getTextAndFormat=function(){return this.rows},u}(),r=function(){function u(o,l,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=o,this.outputFilter=l,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(l){this.outputFilter=l},f.setPAC=function(l){this.writeScreen.setPAC(l)},f.setBkgData=function(l){this.writeScreen.setBkgData(l)},f.setMode=function(l){l!==this.mode&&(this.mode=l,this.logger.log(x.INFO,"MODE="+l),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=l)},f.insertChars=function(l){for(var E=0;E<l.length;E++)this.writeScreen.insertChar(l[E]);var p=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(x.INFO,p+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(x.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},f.ccRCL=function(){this.logger.log(x.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},f.ccBS=function(){this.logger.log(x.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(x.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},f.ccRU=function(l){this.logger.log(x.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},f.ccFON=function(){this.logger.log(x.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},f.ccRDC=function(){this.logger.log(x.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},f.ccTR=function(){this.logger.log(x.INFO,"TR"),this.setMode("MODE_TEXT")},f.ccRTD=function(){this.logger.log(x.INFO,"RTD"),this.setMode("MODE_TEXT")},f.ccEDM=function(){this.logger.log(x.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},f.ccCR=function(){this.logger.log(x.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},f.ccENM=function(){this.logger.log(x.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},f.ccEOC=function(){if(this.logger.log(x.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var l=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=l,this.writeScreen=this.nonDisplayedMemory,this.logger.log(x.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},f.ccTO=function(l){this.logger.log(x.INFO,"TO("+l+") - Tab Offset"),this.writeScreen.moveCursor(l)},f.ccMIDROW=function(l){var E={flash:!1};if(E.underline=l%2==1,E.italics=l>=46,E.italics)E.foreground="white";else{var p=Math.floor(l/2)-16,R=["white","green","blue","cyan","red","yellow","magenta"];E.foreground=R[p]}this.logger.log(x.INFO,"MIDROW: "+JSON.stringify(E)),this.writeScreen.setPen(E)},f.outputDataUpdate=function(l){l===void 0&&(l=!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),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:E),this.lastOutputScreen.copy(this.displayedMemory))},f.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},u}(),a=function(){function u(o,l,E){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var p=new v;this.channels=[null,new r(o,l,p),new r(o+1,E,p)],this.cmdHistory=c(),this.logger=p}var f=u.prototype;return f.getHandler=function(l){return this.channels[l].getHandler()},f.setHandler=function(l,E){this.channels[l].setHandler(E)},f.addData=function(l,E){var p,R,P,M=!1;this.logger.time=l;for(var F=0;F<E.length;F+=2)if(R=E[F]&127,P=E[F+1]&127,!(R===0&&P===0)){if(this.logger.log(x.DATA,"["+m([E[F],E[F+1]])+"] -> ("+m([R,P])+")"),p=this.parseCmd(R,P),p||(p=this.parseMidrow(R,P)),p||(p=this.parsePAC(R,P)),p||(p=this.parseBackgroundAttributes(R,P)),!p&&(M=this.parseChars(R,P),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(x.WARNING,"No channel found yet. TEXT-MODE?")}!p&&!M&&this.logger.log(x.WARNING,"Couldn't parse cleaned data "+m([R,P])+" orig: "+m([E[F],E[F+1]]))}},f.parseCmd=function(l,E){var p=this.cmdHistory,R=(l===20||l===28||l===21||l===29)&&E>=32&&E<=47,P=(l===23||l===31)&&E>=33&&E<=35;if(!(R||P))return!1;if(h(l,E,p))return n(null,null,p),this.logger.log(x.DEBUG,"Repeated command ("+m([l,E])+") is dropped"),!0;var M=l===20||l===21||l===23?1:2,F=this.channels[M];return l===20||l===21||l===28||l===29?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(l,E,p),this.currentChannel=M,!0},f.parseMidrow=function(l,E){var p=0;if((l===17||l===25)&&E>=32&&E<=47){if(l===17?p=1:p=2,p!==this.currentChannel)return this.logger.log(x.ERROR,"Mismatch channel in midrow parsing"),!1;var R=this.channels[p];return R?(R.ccMIDROW(E),this.logger.log(x.DEBUG,"MIDROW ("+m([l,E])+")"),!0):!1}return!1},f.parsePAC=function(l,E){var p,R=this.cmdHistory,P=(l>=17&&l<=23||l>=25&&l<=31)&&E>=64&&E<=127,M=(l===16||l===24)&&E>=64&&E<=95;if(!(P||M))return!1;if(h(l,E,R))return n(null,null,R),!0;var F=l<=23?1:2;E>=64&&E<=95?p=F===1?O[l]:g[l]:p=F===1?A[l]:_[l];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(p,E)),n(l,E,R),this.currentChannel=F,!0):!1},f.interpretPAC=function(l,E){var p,R={color:null,italics:!1,indent:null,underline:!1,row:l};return E>95?p=E-96:p=E-64,R.underline=(p&1)==1,p<=13?R.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(p/2)]:p<=15?(R.italics=!0,R.color="white"):R.indent=Math.floor((p-16)/2)*4,R},f.parseChars=function(l,E){var p,R=null,P=null;if(l>=25?(p=2,P=l-8):(p=1,P=l),P>=17&&P<=19){var M;P===17?M=E+80:P===18?M=E+112:M=E+144,this.logger.log(x.INFO,"Special char '"+T(M)+"' in channel "+p),R=[M]}else l>=32&&l<=127&&(R=E===0?[l]:[l,E]);if(R){var F=m(R);this.logger.log(x.DEBUG,"Char codes = "+F.join(",")),n(l,E,this.cmdHistory)}return R},f.parseBackgroundAttributes=function(l,E){var p=(l===16||l===24)&&E>=32&&E<=47,R=(l===23||l===31)&&E>=45&&E<=47;if(!(p||R))return!1;var P,M={};l===16||l===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=l<=23?1:2,w=this.channels[F];return w.setBkgData(M),n(l,E,this.cmdHistory),!0},f.reset=function(){for(var l=0;l<Object.keys(this.channels).length;l++){var E=this.channels[l];E&&E.reset()}this.cmdHistory=c()},f.cueSplitAtTime=function(l){for(var E=0;E<this.channels.length;E++){var p=this.channels[E];p&&p.cueSplitAtTime(l)}},u}();function n(u,f,o){o.a=u,o.b=f}function h(u,f,o){return o.a===u&&o.b===f}function c(){return{a:null,b:null}}D.default=a},"./src/utils/codecs.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"isCodecType",function(){return y}),d.d(D,"isCodecSupportedInMp4",function(){return T});var b={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,S){var O=b[S];return!!O&&O[I.slice(0,4)]===!0}function T(I,S){return MediaSource.isTypeSupported((S||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/utils/vttparser.ts"),y=d("./src/utils/webvtt-parser.ts"),T=d("./src/utils/texttrack-utils.ts"),I=/\s/,S={newCue:function(A,g,_,L){for(var x=[],v,m,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===_&&(_+=1e-4),e>=16?e--:e++;var n=Object(b.fixLineBreaks)(i.trim()),h=Object(y.generateCueId)(g,_,n);(!A||!A.cues||!A.cues.getCueById(h))&&(m=new t(g,_,n),m.id=h,m.line=r+1,m.align="left",m.position=10+Math.min(80,Math.floor(e*8/32)*10),x.push(m))}return A&&x.length&&(x.sort(function(c,u){return c.line==="auto"||u.line==="auto"?0:c.line>8&&u.line>8?u.line-c.line:c.line-u.line}),x.forEach(function(c){return Object(T.addCueToTrack)(A,c)})),x}};D.default=S},"./src/utils/discontinuities.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"findFirstFragWithCC",function(){return I}),d.d(D,"shouldAlignOnDiscontinuities",function(){return S}),d.d(D,"findDiscontinuousReferenceFrag",function(){return O}),d.d(D,"adjustSlidingStart",function(){return g}),d.d(D,"alignStream",function(){return _}),d.d(D,"alignPDT",function(){return x}),d.d(D,"alignFragmentByPDTDelta",function(){return v}),d.d(D,"alignMediaPlaylistByPDT",function(){return m});var b=d("./src/polyfills/number.ts"),y=d("./src/utils/logger.ts"),T=d("./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 S(s,e,i){return!!(e.details&&(i.endCC>i.startCC||s&&s.cc<i.startCC))}function O(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 A(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++)A(i[t],s);e.fragmentHint&&A(e.fragmentHint,s),e.alignedSliding=!0}function _(s,e,i){!e||(L(s,i,e),!i.alignedSliding&&e.details&&x(i,e.details),!i.alignedSliding&&e.details&&!i.skippedSegments&&Object(T.adjustSliding)(e.details,i))}function L(s,e,i){if(S(s,i,e)){var t=O(i.details,e);t&&Object(b.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 x(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(b.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 m(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(U,D,d){"use strict";d.r(D);var b=d("./src/utils/ewma.ts"),y=function(){function T(S,O,A){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=A,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new b.default(S),this.fast_=new b.default(O)}var I=T.prototype;return I.update=function(O,A){var g=this.slow_,_=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new b.default(O,g.getEstimate(),g.getTotalWeight())),this.fast_.halfLife!==A&&(this.fast_=new b.default(A,_.getEstimate(),_.getTotalWeight()))},I.sample=function(O,A){O=Math.max(O,this.minDelayMs_);var g=8*A,_=O/1e3,L=g/_;this.fast_.sample(_,L),this.slow_.sample(_,L)},I.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},T}();D.default=y},"./src/utils/ewma.ts":function(U,D,d){"use strict";d.r(D);var b=function(){function y(I,S,O){S===void 0&&(S=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=S,this.totalWeight_=O}var T=y.prototype;return T.sample=function(S,O){var A=Math.pow(this.alpha_,S);this.estimate_=O*(1-A)+A*this.estimate_,this.totalWeight_+=S},T.getTotalWeight=function(){return this.totalWeight_},T.getEstimate=function(){if(this.alpha_){var S=1-Math.pow(this.alpha_,this.totalWeight_);if(S)return this.estimate_/S}return this.estimate_},y}();D.default=b},"./src/utils/fetch-loader.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"fetchSupported",function(){return v});var b=d("./src/polyfills/number.ts"),y=d("./src/loader/load-stats.ts"),T=d("./src/demux/chunk-cache.ts");function I(t,r){t.prototype=Object.create(r.prototype),t.prototype.constructor=t,_(t,r)}function S(t){var r=typeof Map=="function"?new Map:void 0;return S=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 O(n,arguments,L(this).constructor)}return h.prototype=Object.create(n.prototype,{constructor:{value:h,enumerable:!1,writable:!0,configurable:!0}}),_(h,n)},S(t)}function O(t,r,a){return A()?O=Reflect.construct:O=function(h,c,u){var f=[null];f.push.apply(f,c);var o=Function.bind.apply(h,f),l=new o;return u&&_(l,u.prototype),l},O.apply(null,arguments)}function A(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function g(t){return Function.toString.call(t).indexOf("[native code]")!==-1}function _(t,r){return _=Object.setPrototypeOf||function(n,h){return n.__proto__=h,n},_(t,r)}function L(t){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},L(t)}function x(){return x=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},x.apply(this,arguments)}function v(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var m=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,c){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 o=s(n,this.controller.signal),l=c.onProgress,E=n.responseType==="arraybuffer",p=E?"byteLength":"length";this.context=n,this.config=h,this.callbacks=c,this.request=this.fetchSetup(n,o),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){u.abortInternal(),c.onTimeout(f,n,u.response)},h.timeout),self.fetch(this.request).then(function(R){if(u.response=u.loader=R,!R.ok){var P=R.status,M=R.statusText;throw new i(M||"fetch, bad network response",P,R)}return f.loading.first=Math.max(self.performance.now(),f.loading.start),f.total=parseInt(R.headers.get("Content-Length")||"0"),l&&Object(b.isFiniteNumber)(h.highWaterMark)?u.loadProgressively(R,f,n,h.highWaterMark,l):E?R.arrayBuffer():R.text()}).then(function(R){var P=u.response;self.clearTimeout(u.requestTimeout),f.loading.end=Math.max(self.performance.now(),f.loading.first),f.loaded=f.total=R[p];var M={url:P.url,data:R};l&&!Object(b.isFiniteNumber)(h.highWaterMark)&&l(f,n,R,P),c.onSuccess(M,f,n,P)}).catch(function(R){if(self.clearTimeout(u.requestTimeout),!f.aborted){var P=R.code||0;c.onError({code:P,text:R.message},n,R.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,c,u,f){u===void 0&&(u=0);var o=new T.default,l=n.body.getReader(),E=function p(){return l.read().then(function(R){if(R.done)return o.dataLength&&f(h,c,o.flush(),n),Promise.resolve(new ArrayBuffer(0));var P=R.value,M=P.length;return h.loaded+=M,M<u||o.dataLength?(o.push(P),o.dataLength>=u&&f(h,c,o.flush(),n)):f(h,c,P,n),p()}).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(x({},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 c;return c=t.call(this,a)||this,c.code=void 0,c.details=void 0,c.code=n,c.details=h,c}return r}(S(Error));D.default=m},"./src/utils/imsc1-ttml-parser.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"IMSC1_CODEC",function(){return g}),d.d(D,"parseIMSC1",function(){return v});var b=d("./src/utils/mp4-tools.ts"),y=d("./src/utils/vttparser.ts"),T=d("./src/utils/vttcue.ts"),I=d("./src/demux/id3.ts"),S=d("./src/utils/timescale-conversion.ts"),O=d("./src/utils/webvtt-parser.ts");function A(){return A=Object.assign||function(u){for(var f=1;f<arguments.length;f++){var o=arguments[f];for(var l in o)Object.prototype.hasOwnProperty.call(o,l)&&(u[l]=o[l])}return u},A.apply(this,arguments)}var g="stpp.ttml.im1t",_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,L=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,x={left:"start",center:"center",right:"end",start:"start",end:"end"};function v(u,f,o,l,E){var p=Object(b.findBox)(new Uint8Array(u),["mdat"]);if(p.length===0){E(new Error("Could not parse IMSC1 mdat"));return}var R=p[0],P=Object(I.utf8ArrayToStr)(new Uint8Array(u,R.start,R.end-R.start)),M=Object(S.toTimescaleFromScale)(f,1,o);try{l(m(P,M))}catch(F){E(F)}}function m(u,f){var o=new DOMParser,l=o.parseFromString(u,"text/xml"),E=l.getElementsByTagName("tt")[0];if(!E)throw new Error("Invalid ttml");var p={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},R=Object.keys(p).reduce(function(C,B){return C[B]=E.getAttribute("ttp:"+B)||p[B],C},{}),P=E.getAttribute("xml:space")!=="preserve",M=e(s(E,"styling","style")),F=e(s(E,"layout","region")),w=s(E,"body","[begin]");return[].map.call(w,function(C){var B=i(C,P);if(!B||!C.hasAttribute("begin"))return null;var k=n(C.getAttribute("begin"),R),N=n(C.getAttribute("dur"),R),W=n(C.getAttribute("end"),R);if(k===null)throw a(C);if(W===null){if(N===null)throw a(C);W=k+N}var j=new T.default(k-f,W-f,B);j.id=Object(O.generateCueId)(j.startTime,j.endTime,j.text);var K=F[C.getAttribute("region")],V=M[C.getAttribute("style")];j.position=10,j.size=80;var Y=t(K,V),Q=Y.textAlign;if(Q){var z=x[Q];z&&(j.lineAlign=z),j.align=Q}return A(j,Y),j}).filter(function(C){return C!==null})}function s(u,f,o){var l=u.getElementsByTagName(f)[0];return l?[].slice.call(l.querySelectorAll(o)):[]}function e(u){return u.reduce(function(f,o){var l=o.getAttribute("xml:id");return l&&(f[l]=o),f},{})}function i(u,f){return[].slice.call(u.childNodes).reduce(function(o,l,E){var p;return l.nodeName==="br"&&E?o+`
|
|
20
|
-
`:(p=l.childNodes)!==null&&p!==void 0&&p.length?i(l,f):f?o+l.textContent.trim().replace(/\s+/g," "):o+l.textContent},"")}function t(u,f){var o="http://www.w3.org/ns/ttml#styling",l=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"];return l.reduce(function(E,p){var R=r(f,o,p)||r(u,o,p);return R&&(E[p]=R),E},{})}function r(u,f,o){return u.hasAttributeNS(f,o)?u.getAttributeNS(f,o):null}function a(u){return new Error("Could not parse ttml timestamp "+u)}function n(u,f){if(!u)return null;var o=Object(y.parseTimeStamp)(u);return o===null&&(_.test(u)?o=h(u,f):L.test(u)&&(o=c(u,f))),o}function h(u,f){var o=_.exec(u),l=(o[4]|0)+(o[5]|0)/f.subFrameRate;return(o[1]|0)*3600+(o[2]|0)*60+(o[3]|0)+l/f.frameRate}function c(u,f){var o=L.exec(u),l=Number(o[1]),E=o[2];switch(E){case"h":return l*3600;case"m":return l*60;case"ms":return l*1e3;case"f":return l/f.frameRate;case"t":return l/f.tickRate}return l}},"./src/utils/logger.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"enableLogs",function(){return O}),d.d(D,"logger",function(){return A});var b=function(){},y={trace:b,debug:b,log:b,warn:b,info:b,error:b},T=y;function I(g){var _=self.console[g];return _?_.bind(self.console,"["+g+"] >"):b}function S(g){for(var _=arguments.length,L=new Array(_>1?_-1:0),x=1;x<_;x++)L[x-1]=arguments[x];L.forEach(function(v){T[v]=g[v]?g[v].bind(g):I(v)})}function O(g){if(self.console&&g===!0||typeof g=="object"){S(g,"debug","log","info","warn","error");try{T.log()}catch{T=y}}else T=y}var A=T},"./src/utils/mediakeys-helper.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"KeySystems",function(){return b}),d.d(D,"requestMediaKeySystemAccess",function(){return y});var b;(function(T){T.WIDEVINE="com.widevine.alpha",T.PLAYREADY="com.microsoft.playready"})(b||(b={}));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(U,D,d){"use strict";d.r(D),d.d(D,"getMediaSource",function(){return b});function b(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"bin2str",function(){return S}),d.d(D,"readUint16",function(){return O}),d.d(D,"readUint32",function(){return A}),d.d(D,"writeUint32",function(){return g}),d.d(D,"findBox",function(){return _}),d.d(D,"parseSegmentIndex",function(){return L}),d.d(D,"parseInitSegment",function(){return x}),d.d(D,"getStartDTS",function(){return v}),d.d(D,"getDuration",function(){return m}),d.d(D,"computeRawDurationFromSamples",function(){return s}),d.d(D,"offsetStartDTS",function(){return e}),d.d(D,"segmentValidRange",function(){return i}),d.d(D,"appendUint8Array",function(){return t});var b=d("./src/utils/typed-array.ts"),y=d("./src/loader/fragment.ts"),T=Math.pow(2,32)-1,I=[].push;function S(r){return String.fromCharCode.apply(null,r)}function O(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 A(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 _(r,a){var n=[];if(!a.length)return n;var h,c,u;"data"in r?(h=r.data,c=r.start,u=r.end):(h=r,c=0,u=h.byteLength);for(var f=c;f<u;){var o=A(h,f),l=S(h.subarray(f+4,f+8)),E=o>1?f+o:u;if(l===a[0])if(a.length===1)n.push({data:h,start:f+8,end:E});else{var p=_({data:h,start:f+8,end:E},a.slice(1));p.length&&I.apply(n,p)}f=E}return n}function L(r){var a=_(r,["moov"]),n=a[0],h=n?n.end:null,c=_(r,["sidx"]);if(!c||!c[0])return null;var u=[],f=c[0],o=f.data[0],l=o===0?8:16,E=A(f,l);l+=4;var p=0,R=0;o===0?l+=8:l+=16,l+=2;var P=f.end+R,M=O(f,l);l+=2;for(var F=0;F<M;F++){var w=l,C=A(f,w);w+=4;var B=C&2147483647,k=(C&2147483648)>>>31;if(k===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var N=A(f,w);w+=4,u.push({referenceSize:B,subsegmentDuration:N,info:{duration:N/E,start:P,end:P+B-1}}),P+=B,w+=4,l=w}return{earliestPresentationTime:p,timescale:E,version:o,referencesCount:M,references:u,moovEndOffset:h}}function x(r){for(var a=[],n=_(r,["moov","trak"]),h=0;h<n.length;h++){var c=n[h],u=_(c,["tkhd"])[0];if(u){var f=u.data[u.start],o=f===0?12:20,l=A(u,o),E=_(c,["mdia","mdhd"])[0];if(E){f=E.data[E.start],o=f===0?12:20;var p=A(E,o),R=_(c,["mdia","hdlr"])[0];if(R){var P=S(R.data.subarray(R.start+8,R.start+12)),M={soun:y.ElementaryStreamTypes.AUDIO,vide:y.ElementaryStreamTypes.VIDEO}[P];if(M){var F=_(c,["mdia","minf","stbl","stsd"])[0],w=void 0;F&&(w=S(F.data.subarray(F.start+12,F.start+16))),a[l]={timescale:p,type:M},a[M]={timescale:p,id:l,codec:w}}}}}}var C=_(r,["moov","mvex","trex"]);return C.forEach(function(B){var k=A(B,4),N=a[k];N&&(N.default={duration:A(B,12),flags:A(B,20)})}),a}function v(r,a){return _(a,["moof","traf"]).reduce(function(n,h){var c=_(h,["tfdt"])[0],u=c.data[c.start],f=_(h,["tfhd"]).reduce(function(o,l){var E=A(l,4),p=r[E];if(p){var R=A(c,4);u===1&&(R*=Math.pow(2,32),R+=A(c,8));var P=p.timescale||9e4,M=R/P;if(isFinite(M)&&(o===null||M<o))return M}return o},null);return f!==null&&isFinite(f)&&(n===null||f<n)?f:n},null)||0}function m(r,a){for(var n=0,h=0,c=0,u=_(r,["moof","traf"]),f=0;f<u.length;f++){var o=u[f],l=_(o,["tfhd"])[0],E=A(l,4),p=a[E];if(!!p){var R=p.default,P=A(l,0)|(R==null?void 0:R.flags),M=R==null?void 0:R.duration;P&8&&(P&2?M=A(l,12):M=A(l,8));for(var F=p.timescale||9e4,w=_(o,["trun"]),C=0;C<w.length;C++){if(n=s(w[C]),!n&&M){var B=A(w[C],4);n=M*B}p.type===y.ElementaryStreamTypes.VIDEO?h+=n/F:p.type===y.ElementaryStreamTypes.AUDIO&&(c+=n/F)}}}if(h===0&&c===0){var k=L(r);if(k!=null&&k.references)return k.references.reduce(function(N,W){return N+W.info.duration||0},0)}return h||c}function s(r){var a=A(r,0),n=8;a&1&&(n+=4),a&4&&(n+=4);for(var h=0,c=A(r,4),u=0;u<c;u++){if(a&256){var f=A(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,["moof","traf"]).forEach(function(h){_(h,["tfhd"]).forEach(function(c){var u=A(c,4),f=r[u];if(!!f){var o=f.timescale||9e4;_(h,["tfdt"]).forEach(function(l){var E=l.data[l.start],p=A(l,4);if(E===0)g(l,4,p-n*o);else{p*=Math.pow(2,32),p+=A(l,8),p-=n*o,p=Math.max(p,0);var R=Math.floor(p/(T+1)),P=Math.floor(p%(T+1));g(l,4,R),g(l,8,P)}})}})})}function i(r){var a={valid:null,remainder:null},n=_(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(b.sliceUint8)(r,0,h.start-8),a.remainder=Object(b.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(U,D,d){"use strict";d.r(D),d.d(D,"default",function(){return b});var b=function(){function y(I,S){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=S}var T=y.prototype;return T.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},T.newCue=function(S,O,A){(this.startTime===null||this.startTime>S)&&(this.startTime=S),this.endTime=O,this.screen=A,this.timelineController.createCaptionsTrack(this.trackName)},T.reset=function(){this.cueRanges=[],this.startTime=null},y}()},"./src/utils/texttrack-utils.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"sendAddTrackEvent",function(){return y}),d.d(D,"addCueToTrack",function(){return T}),d.d(D,"clearCurrentCues",function(){return I}),d.d(D,"removeCuesInRange",function(){return S}),d.d(D,"getCuesInRange",function(){return A});var b=d("./src/utils/logger.ts");function y(g,_){var L;try{L=new Event("addtrack")}catch{L=document.createEvent("Event"),L.initEvent("addtrack",!1,!1)}L.track=g,_.dispatchEvent(L)}function T(g,_){var L=g.mode;if(L==="disabled"&&(g.mode="hidden"),g.cues&&!g.cues.getCueById(_.id))try{if(g.addCue(_),!g.cues.getCueById(_.id))throw new Error("addCue is failed for: "+_)}catch(v){b.logger.debug("[texttrack-utils]: "+v);var x=new self.TextTrackCue(_.startTime,_.endTime,_.text);x.id=_.id,g.addCue(x)}L==="disabled"&&(g.mode=L)}function I(g){var _=g.mode;if(_==="disabled"&&(g.mode="hidden"),g.cues)for(var L=g.cues.length;L--;)g.removeCue(g.cues[L]);_==="disabled"&&(g.mode=_)}function S(g,_,L){var x=g.mode;if(x==="disabled"&&(g.mode="hidden"),g.cues&&g.cues.length>0)for(var v=A(g.cues,_,L),m=0;m<v.length;m++)g.removeCue(v[m]);x==="disabled"&&(g.mode=x)}function O(g,_){if(_<g[0].startTime)return 0;var L=g.length-1;if(_>g[L].endTime)return-1;for(var x=0,v=L;x<=v;){var m=Math.floor((v+x)/2);if(_<g[m].startTime)v=m-1;else if(_>g[m].startTime&&x<L)x=m+1;else return m}return g[x].startTime-_<_-g[v].startTime?x:v}function A(g,_,L){var x=[],v=O(g,_);if(v>-1)for(var m=v,s=g.length;m<s;m++){var e=g[m];if(e.startTime>=_&&e.endTime<=L)x.push(e);else if(e.startTime>L)return x}return x}},"./src/utils/time-ranges.ts":function(U,D,d){"use strict";d.r(D);var b={toString:function(T){for(var I="",S=T.length,O=0;O<S;O++)I+="["+T.start(O).toFixed(3)+","+T.end(O).toFixed(3)+"]";return I}};D.default=b},"./src/utils/timescale-conversion.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"toTimescaleFromBase",function(){return y}),d.d(D,"toTimescaleFromScale",function(){return T}),d.d(D,"toMsFromMpegTsClock",function(){return I}),d.d(D,"toMpegTsClockFromTimescale",function(){return S});var b=9e4;function y(O,A,g,_){g===void 0&&(g=1),_===void 0&&(_=!1);var L=O*A*g;return _?Math.round(L):L}function T(O,A,g,_){return g===void 0&&(g=1),_===void 0&&(_=!1),y(O,A,1/g,_)}function I(O,A){return A===void 0&&(A=!1),y(O,1e3,1/b,A)}function S(O,A){return A===void 0&&(A=1),y(O,b,1/A)}},"./src/utils/typed-array.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"sliceUint8",function(){return b});function b(y,T,I){return Uint8Array.prototype.slice?y.slice(T,I):new Uint8Array(Array.prototype.slice.call(y,T,I))}},"./src/utils/vttcue.ts":function(U,D,d){"use strict";d.r(D),D.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var b=["","lr","rl"],y=["start","middle","end","left","right"];function T(g,_){if(typeof _!="string"||!Array.isArray(g))return!1;var L=_.toLowerCase();return~g.indexOf(L)?L:!1}function I(g){return T(b,g)}function S(g){return T(y,g)}function O(g){for(var _=arguments.length,L=new Array(_>1?_-1:0),x=1;x<_;x++)L[x-1]=arguments[x];for(var v=1;v<arguments.length;v++){var m=arguments[v];for(var s in m)g[s]=m[s]}return g}function A(g,_,L){var x=this,v={enumerable:!0};x.hasBeenReset=!1;var m="",s=!1,e=g,i=_,t=L,r=null,a="",n=!0,h="auto",c="start",u=50,f="middle",o=50,l="middle";Object.defineProperty(x,"id",O({},v,{get:function(){return m},set:function(p){m=""+p}})),Object.defineProperty(x,"pauseOnExit",O({},v,{get:function(){return s},set:function(p){s=!!p}})),Object.defineProperty(x,"startTime",O({},v,{get:function(){return e},set:function(p){if(typeof p!="number")throw new TypeError("Start time must be set to a number.");e=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"endTime",O({},v,{get:function(){return i},set:function(p){if(typeof p!="number")throw new TypeError("End time must be set to a number.");i=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"text",O({},v,{get:function(){return t},set:function(p){t=""+p,this.hasBeenReset=!0}})),Object.defineProperty(x,"region",O({},v,{get:function(){return r},set:function(p){r=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"vertical",O({},v,{get:function(){return a},set:function(p){var R=I(p);if(R===!1)throw new SyntaxError("An invalid or illegal string was specified.");a=R,this.hasBeenReset=!0}})),Object.defineProperty(x,"snapToLines",O({},v,{get:function(){return n},set:function(p){n=!!p,this.hasBeenReset=!0}})),Object.defineProperty(x,"line",O({},v,{get:function(){return h},set:function(p){if(typeof p!="number"&&p!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");h=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"lineAlign",O({},v,{get:function(){return c},set:function(p){var R=S(p);if(!R)throw new SyntaxError("An invalid or illegal string was specified.");c=R,this.hasBeenReset=!0}})),Object.defineProperty(x,"position",O({},v,{get:function(){return u},set:function(p){if(p<0||p>100)throw new Error("Position must be between 0 and 100.");u=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"positionAlign",O({},v,{get:function(){return f},set:function(p){var R=S(p);if(!R)throw new SyntaxError("An invalid or illegal string was specified.");f=R,this.hasBeenReset=!0}})),Object.defineProperty(x,"size",O({},v,{get:function(){return o},set:function(p){if(p<0||p>100)throw new Error("Size must be between 0 and 100.");o=p,this.hasBeenReset=!0}})),Object.defineProperty(x,"align",O({},v,{get:function(){return l},set:function(p){var R=S(p);if(!R)throw new SyntaxError("An invalid or illegal string was specified.");l=R,this.hasBeenReset=!0}})),x.displayState=void 0}return A.prototype.getCueAsHTML=function(){var g=self.WebVTT;return g.convertCueToDOMTree(self,this.text)},A}()},"./src/utils/vttparser.ts":function(U,D,d){"use strict";d.r(D),d.d(D,"parseTimeStamp",function(){return T}),d.d(D,"fixLineBreaks",function(){return _}),d.d(D,"VTTParser",function(){return L});var b=d("./src/utils/vttcue.ts"),y=function(){function x(){}var v=x.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))},x}();function T(x){function v(s,e,i,t){return(s|0)*3600+(e|0)*60+(i|0)+parseFloat(t||0)}var m=x.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return m?parseFloat(m[2])>59?v(m[2],m[3],0,m[4]):v(m[1],m[2],m[3],m[4]):null}var I=function(){function x(){this.values=Object.create(null)}var v=x.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},x}();function S(x,v,m,s){var e=s?x.split(s):[x];for(var i in e)if(typeof e[i]=="string"){var t=e[i].split(m);if(t.length===2){var r=t[0],a=t[1];v(r,a)}}}var O=new b.default(0,0,""),A=O.align==="middle"?"middle":"center";function g(x,v,m){var s=x;function e(){var r=T(x);if(r===null)throw new Error("Malformed timestamp: "+s);return x=x.replace(/^[^\sa-zA-Z-]+/,""),r}function i(r,a){var n=new I;S(r,function(u,f){var o;switch(u){case"region":for(var l=m.length-1;l>=0;l--)if(m[l].id===f){n.set(u,m[l].region);break}break;case"vertical":n.alt(u,f,["rl","lr"]);break;case"line":o=f.split(","),n.integer(u,o[0]),n.percent(u,o[0])&&n.set("snapToLines",!1),n.alt(u,o[0],["auto"]),o.length===2&&n.alt("lineAlign",o[1],["start",A,"end"]);break;case"position":o=f.split(","),n.percent(u,o[0]),o.length===2&&n.alt("positionAlign",o[1],["start",A,"end","line-left","line-right","auto"]);break;case"size":n.percent(u,f);break;case"align":n.alt(u,f,["start",A,"end","left","right"]);break}},/:/,/\s/),a.region=n.get("region",null),a.vertical=n.get("vertical","");var h=n.get("line","auto");h==="auto"&&O.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",A);var c=n.get("position","auto");c==="auto"&&O.position===50&&(c=a.align==="start"||a.align==="left"?0:a.align==="end"||a.align==="right"?100:50),a.position=c}function t(){x=x.replace(/^\s+/,"")}if(t(),v.startTime=e(),t(),x.substr(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);x=x.substr(3),t(),v.endTime=e(),t(),i(x,v)}function _(x){return x.replace(/<br(?: \/)?>/gi,`
|
|
21
|
-
`)}var
|
|
22
|
-
`;)++
|
|
23
|
-
`&&++
|
|
24
|
-
`),e.cue.text+=
|
|
17
|
+
timeOffset: `+b+`
|
|
18
|
+
initSegmentChange: `+Y);var H=new I.TransmuxConfig(f,a,o,u,h);this.configureTransmuxer(H)}if(this.frag=i,this.part=t,L)L.postMessage({cmd:"demux",data:e,decryptdata:M,chunkMeta:r,state:K},e instanceof ArrayBuffer?[e]:[]);else if(m){var z=m.push(e,M,r,K);Object(I.isPromise)(z)?z.then(function($){v.handleTransmuxComplete($)}):this.handleTransmuxComplete(z)}},y.flush=function(e){var o=this;e.transmuxing.start=self.performance.now();var f=this.transmuxer,a=this.worker;if(a)a.postMessage({cmd:"flush",chunkMeta:e});else if(f){var i=f.flush(e);Object(I.isPromise)(i)?i.then(function(t){o.handleFlushResult(t,e)}):this.handleFlushResult(i,e)}},y.handleFlushResult=function(e,o){var f=this;e.forEach(function(a){f.handleTransmuxComplete(a)}),this.onFlush(o)},y.onWorkerMessage=function(e){var o=e.data,f=this.hls;switch(o.event){case"init":{self.URL.revokeObjectURL(this.worker.objectURL);break}case"transmuxComplete":{this.handleTransmuxComplete(o.data);break}case"flush":{this.onFlush(o.data);break}case"workerLog":S.logger[o.data.logType]&&S.logger[o.data.logType](o.data.message);break;default:{o.data=o.data||{},o.data.frag=this.frag,o.data.id=this.id,f.trigger(o.event,o.data);break}}},y.configureTransmuxer=function(e){var o=this.worker,f=this.transmuxer;o?o.postMessage({cmd:"configure",config:e}):f&&f.configure(e)},y.handleTransmuxComplete=function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)},g}()},"./src/demux/transmuxer-worker.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return O});var R=n("./src/demux/transmuxer.ts"),p=n("./src/events.ts"),T=n("./src/utils/logger.ts"),I=n("./node_modules/eventemitter3/index.js"),S=n.n(I);function O(x){var g=new I.EventEmitter,y=function(o,f){x.postMessage({event:o,data:f})};g.on(p.Events.FRAG_DECRYPTED,y),g.on(p.Events.ERROR,y);var s=function(){var o=function(i){var t=function(c){y("workerLog",{logType:i,message:c})};T.logger[i]=t};for(var f in T.logger)o(f)};x.addEventListener("message",function(e){var o=e.data;switch(o.cmd){case"init":{var f=JSON.parse(o.config);x.transmuxer=new R.default(g,o.typeSupported,f,o.vendor,o.id),Object(T.enableLogs)(f.debug),s(),y("init",null);break}case"configure":{x.transmuxer.configure(o.config);break}case"demux":{var a=x.transmuxer.push(o.data,o.decryptdata,o.chunkMeta,o.state);Object(R.isPromise)(a)?a.then(function(u){_(x,u)}):_(x,a);break}case"flush":{var i=o.chunkMeta,t=x.transmuxer.flush(i);Object(R.isPromise)(t)?t.then(function(u){A(x,u,i)}):A(x,t,i);break}default:break}})}function _(x,g){if(D(g.remuxResult))return!1;var y=[],s=g.remuxResult,e=s.audio,o=s.video;return e&&E(y,e),o&&E(y,o),x.postMessage({event:"transmuxComplete",data:g},y),!0}function E(x,g){g.data1&&x.push(g.data1.buffer),g.data2&&x.push(g.data2.buffer)}function A(x,g,y){var s=g.reduce(function(e,o){return _(x,o)||e},!1);s||x.postMessage({event:"transmuxComplete",data:g[0]}),x.postMessage({event:"flush",data:y})}function D(x){return!x.audio&&!x.video&&!x.text&&!x.id3&&!x.initSegment}},"./src/demux/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return y}),n.d(P,"isPromise",function(){return o}),n.d(P,"TransmuxConfig",function(){return f}),n.d(P,"TransmuxState",function(){return a});var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/crypt/decrypter.ts"),I=n("./src/demux/aacdemuxer.ts"),S=n("./src/demux/mp4demuxer.ts"),O=n("./src/demux/tsdemuxer.ts"),_=n("./src/demux/mp3demuxer.ts"),E=n("./src/remux/mp4-remuxer.ts"),A=n("./src/remux/passthrough-remuxer.ts"),D=n("./src/utils/logger.ts"),x;try{x=self.performance.now.bind(self.performance)}catch{D.logger.debug("Unable to use Performance API on this environment"),x=self.Date.now}var g=[{demux:O.default,remux:E.default},{demux:S.default,remux:A.default},{demux:I.default,remux:E.default},{demux:_.default,remux:E.default}],y=function(){function i(u,c,r,h,d){this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=u,this.typeSupported=c,this.config=r,this.vendor=h,this.id=d}var t=i.prototype;return t.configure=function(c){this.transmuxConfig=c,this.decrypter&&this.decrypter.reset()},t.push=function(c,r,h,d){var l=this,v=h.transmuxing;v.executeStart=x();var m=new Uint8Array(c),L=this.config,b=this.currentTransmuxState,M=this.transmuxConfig;d&&(this.currentTransmuxState=d);var F=d||b,w=F.contiguous,C=F.discontinuity,U=F.trackSwitch,k=F.accurateTimeOffset,j=F.timeOffset,N=F.initSegmentChange,W=M.audioCodec,Y=M.videoCodec,K=M.defaultInitPts,H=M.duration,z=M.initSegmentData;(C||U||N)&&this.resetInitSegment(z,W,Y,H),(C||N)&&this.resetInitialTimestamp(K),w||this.resetContiguity();var $=s(m,r);if($&&$.method==="AES-128"){var X=this.getDecrypter();if(L.enableSoftwareAES){var J=X.softwareDecrypt(m,$.key.buffer,$.iv.buffer);if(!J)return v.executeEnd=x(),e(h);m=new Uint8Array(J)}else return this.decryptionPromise=X.webCryptoDecrypt(m,$.key.buffer,$.iv.buffer).then(function(ae){var se=l.push(ae,null,h);return l.decryptionPromise=null,se}),this.decryptionPromise}this.needsProbing(m,C,U)&&this.configureTransmuxer(m,M);var te=this.transmux(m,$,j,k,h),Q=this.currentTransmuxState;return Q.contiguous=!0,Q.discontinuity=!1,Q.trackSwitch=!1,v.executeEnd=x(),te},t.flush=function(c){var r=this,h=c.transmuxing;h.executeStart=x();var d=this.decrypter,l=this.currentTransmuxState,v=this.decryptionPromise;if(v)return v.then(function(){return r.flush(c)});var m=[],L=l.timeOffset;if(d){var b=d.flush();b&&m.push(this.push(b,null,c))}var M=this.demuxer,F=this.remuxer;if(!M||!F)return this.observer.emit(R.Events.ERROR,R.Events.ERROR,{type:p.ErrorTypes.MEDIA_ERROR,details:p.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),h.executeEnd=x(),[e(c)];var w=M.flush(L);return o(w)?w.then(function(C){return r.flushRemux(m,C,c),m}):(this.flushRemux(m,w,c),m)},t.flushRemux=function(c,r,h){var d=r.audioTrack,l=r.videoTrack,v=r.id3Track,m=r.textTrack,L=this.currentTransmuxState,b=L.accurateTimeOffset,M=L.timeOffset;D.logger.log("[transmuxer.ts]: Flushed fragment "+h.sn+(h.part>-1?" p: "+h.part:"")+" of level "+h.level);var F=this.remuxer.remux(d,l,v,m,M,b,!0,this.id);c.push({remuxResult:F,chunkMeta:h}),h.transmuxing.executeEnd=x()},t.resetInitialTimestamp=function(c){var r=this.demuxer,h=this.remuxer;!r||!h||(r.resetTimeStamp(c),h.resetTimeStamp(c))},t.resetContiguity=function(){var c=this.demuxer,r=this.remuxer;!c||!r||(c.resetContiguity(),r.resetNextTimestamp())},t.resetInitSegment=function(c,r,h,d){var l=this.demuxer,v=this.remuxer;!l||!v||(l.resetInitSegment(c,r,h,d),v.resetInitSegment(c,r,h))},t.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},t.transmux=function(c,r,h,d,l){var v;return r&&r.method==="SAMPLE-AES"?v=this.transmuxSampleAes(c,r,h,d,l):v=this.transmuxUnencrypted(c,h,d,l),v},t.transmuxUnencrypted=function(c,r,h,d){var l=this.demuxer.demux(c,r,!1,!this.config.progressive),v=l.audioTrack,m=l.videoTrack,L=l.id3Track,b=l.textTrack,M=this.remuxer.remux(v,m,L,b,r,h,!1,this.id);return{remuxResult:M,chunkMeta:d}},t.transmuxSampleAes=function(c,r,h,d,l){var v=this;return this.demuxer.demuxSampleAes(c,r,h).then(function(m){var L=v.remuxer.remux(m.audioTrack,m.videoTrack,m.id3Track,m.textTrack,h,d,!1,v.id);return{remuxResult:L,chunkMeta:l}})},t.configureTransmuxer=function(c,r){for(var h=this.config,d=this.observer,l=this.typeSupported,v=this.vendor,m=r.audioCodec,L=r.defaultInitPts,b=r.duration,M=r.initSegmentData,F=r.videoCodec,w,C=0,U=g.length;C<U;C++)if(g[C].demux.probe(c)){w=g[C];break}w||(D.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),w={demux:S.default,remux:A.default});var k=this.demuxer,j=this.remuxer,N=w.remux,W=w.demux;(!j||!(j instanceof N))&&(this.remuxer=new N(d,h,l,v)),(!k||!(k instanceof W))&&(this.demuxer=new W(d,h,l),this.probe=W.probe),this.resetInitSegment(M,m,F,b),this.resetInitialTimestamp(L)},t.needsProbing=function(c,r,h){return!this.demuxer||!this.remuxer||r||h},t.getDecrypter=function(){var c=this.decrypter;return c||(c=this.decrypter=new T.default(this.observer,this.config)),c},i}();function s(i,t){var u=null;return i.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(u=t),u}var e=function(t){return{remuxResult:{},chunkMeta:t}};function o(i){return"then"in i&&i.then instanceof Function}var f=function(t,u,c,r,h){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=u,this.initSegmentData=c,this.duration=r,this.defaultInitPts=h},a=function(t,u,c,r,h,d){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=u,this.accurateTimeOffset=c,this.trackSwitch=r,this.timeOffset=h,this.initSegmentChange=d}},"./src/demux/tsdemuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"discardEPB",function(){return f});var R=n("./src/demux/adts.ts"),p=n("./src/demux/mpegaudio.ts"),T=n("./src/demux/exp-golomb.ts"),I=n("./src/demux/sample-aes.ts"),S=n("./src/events.ts"),O=n("./src/utils/mp4-tools.ts"),_=n("./src/utils/logger.ts"),E=n("./src/errors.ts"),A=n("./src/types/demuxer.ts");function D(){return D=Object.assign?Object.assign.bind():function(a){for(var i=1;i<arguments.length;i++){var t=arguments[i];for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(a[u]=t[u])}return a},D.apply(this,arguments)}var x=function(){function a(t,u,c){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=u,this.typeSupported=c}a.probe=function(u){return u[0]===71&&u[188]===71},a.createTrack=function(u,c){return{container:u==="video"||u==="audio"?"video/mp2t":void 0,type:u,id:O.RemuxerTrackIdConfig[u],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:u==="audio"?c:void 0}};var i=a.prototype;return i.resetInitSegment=function(u,c,r,h){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=a.createTrack("video"),this._audioTrack=a.createTrack("audio",h),this._id3Track=a.createTrack("id3"),this._txtTrack=a.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=c,this.videoCodec=r,this._duration=h},i.resetTimeStamp=function(){},i.resetContiguity=function(){var u=this._audioTrack,c=this._avcTrack,r=this._id3Track;u&&(u.pesData=null),c&&(c.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null},i.demux=function(u,c,r,h){r===void 0&&(r=!1),h===void 0&&(h=!1),r||(this.sampleAes=null);var d,l=this._avcTrack,v=this._audioTrack,m=this._id3Track,L=this._txtTrack,b=l.pid,M=l.pesData,F=v.pid,w=m.pid,C=v.pesData,U=m.pesData,k=null,j=this.pmtParsed,N=this._pmtId,W=u.length;if(this.remainderData&&(u=Object(O.appendUint8Array)(this.remainderData,u),W=u.length,this.remainderData=null),W<188&&!h)return this.remainderData=u,{audioTrack:v,videoTrack:l,id3Track:m,textTrack:L};W-=W%188,W<u.byteLength&&!h&&(this.remainderData=new Uint8Array(u.buffer,W,u.buffer.byteLength-W));for(var Y=0,K=0;K<W;K+=188)if(u[K]===71){var H=!!(u[K+1]&64),z=((u[K+1]&31)<<8)+u[K+2],$=(u[K+3]&48)>>4,X=void 0;if($>1){if(X=K+5+u[K+4],X===K+188)continue}else X=K+4;switch(z){case b:H&&(M&&(d=e(M))&&this.parseAVCPES(l,L,d,!1),M={data:[],size:0}),M&&(M.data.push(u.subarray(X,K+188)),M.size+=K+188-X);break;case F:if(H){if(C&&(d=e(C)))switch(v.segmentCodec){case"aac":this.parseAACPES(v,d);break;case"mp3":this.parseMPEGPES(v,d);break}C={data:[],size:0}}C&&(C.data.push(u.subarray(X,K+188)),C.size+=K+188-X);break;case w:H&&(U&&(d=e(U))&&this.parseID3PES(m,d),U={data:[],size:0}),U&&(U.data.push(u.subarray(X,K+188)),U.size+=K+188-X);break;case 0:H&&(X+=u[X]+1),N=this._pmtId=y(u,X);break;case N:{H&&(X+=u[X]+1);var J=s(u,X,this.typeSupported,r);b=J.avc,b>0&&(l.pid=b),F=J.audio,F>0&&(v.pid=F,v.segmentCodec=J.segmentCodec),w=J.id3,w>0&&(m.pid=w),k!==null&&!j&&(_.logger.log("unknown PID '"+k+"' in TS found"),k=null),j=this.pmtParsed=!0;break}case 17:case 8191:break;default:k=z;break}}else Y++;Y>0&&this.observer.emit(S.Events.ERROR,S.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+Y+" TS packet/s that do not start with 0x47"}),l.pesData=M,v.pesData=C,m.pesData=U;var te={audioTrack:v,videoTrack:l,id3Track:m,textTrack:L};return h&&this.extractRemainingSamples(te),te},i.flush=function(){var u=this.remainderData;this.remainderData=null;var c;return u?c=this.demux(u,-1,!1,!0):c={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(c),this.sampleAes?this.decrypt(c,this.sampleAes):c},i.extractRemainingSamples=function(u){var c=u.audioTrack,r=u.videoTrack,h=u.id3Track,d=u.textTrack,l=r.pesData,v=c.pesData,m=h.pesData,L;if(l&&(L=e(l))?(this.parseAVCPES(r,d,L,!0),r.pesData=null):r.pesData=l,v&&(L=e(v))){switch(c.segmentCodec){case"aac":this.parseAACPES(c,L);break;case"mp3":this.parseMPEGPES(c,L);break}c.pesData=null}else v!=null&&v.size&&_.logger.log("last AAC PES packet truncated,might overlap between fragments"),c.pesData=v;m&&(L=e(m))?(this.parseID3PES(h,L),h.pesData=null):h.pesData=m},i.demuxSampleAes=function(u,c,r){var h=this.demux(u,r,!0,!this.config.progressive),d=this.sampleAes=new I.default(this.observer,this.config,c);return this.decrypt(h,d)},i.decrypt=function(u,c){return new Promise(function(r){var h=u.audioTrack,d=u.videoTrack;h.samples&&h.segmentCodec==="aac"?c.decryptAacSamples(h.samples,0,function(){d.samples?c.decryptAvcSamples(d.samples,0,0,function(){r(u)}):r(u)}):d.samples&&c.decryptAvcSamples(d.samples,0,0,function(){r(u)})})},i.destroy=function(){this._duration=0},i.parseAVCPES=function(u,c,r,h){var d=this,l=this.parseAVCNALu(u,r.data),v=!1,m=this.avcSample,L,b=!1;r.data=null,m&&l.length&&!u.audFound&&(o(m,u),m=this.avcSample=g(!1,r.pts,r.dts,"")),l.forEach(function(M){switch(M.type){case 1:{L=!0,m||(m=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="NDR "),m.frame=!0;var F=M.data;if(b&&F.length>4){var w=new T.default(F).readSliceType();(w===2||w===4||w===7||w===9)&&(m.key=!0)}break}case 5:L=!0,m||(m=d.avcSample=g(!0,r.pts,r.dts,"")),v&&(m.debug+="IDR "),m.key=!0,m.frame=!0;break;case 6:{L=!0,v&&m&&(m.debug+="SEI "),Object(O.parseSEIMessageFromNALu)(f(M.data),r.pts,c.samples);break}case 7:if(L=!0,b=!0,v&&m&&(m.debug+="SPS "),!u.sps){var C=new T.default(M.data),U=C.readSPS();u.width=U.width,u.height=U.height,u.pixelRatio=U.pixelRatio,u.sps=[M.data],u.duration=d._duration;for(var k=M.data.subarray(1,4),j="avc1.",N=0;N<3;N++){var W=k[N].toString(16);W.length<2&&(W="0"+W),j+=W}u.codec=j}break;case 8:L=!0,v&&m&&(m.debug+="PPS "),u.pps||(u.pps=[M.data]);break;case 9:L=!1,u.audFound=!0,m&&o(m,u),m=d.avcSample=g(!1,r.pts,r.dts,v?"AUD ":"");break;case 12:L=!0;break;default:L=!1,m&&(m.debug+="unknown NAL "+M.type+" ");break}if(m&&L){var Y=m.units;Y.push(M)}}),h&&m&&(o(m,u),this.avcSample=null)},i.getLastNalUnit=function(u){var c,r=this.avcSample,h;if((!r||r.units.length===0)&&(r=u[u.length-1]),(c=r)!==null&&c!==void 0&&c.units){var d=r.units;h=d[d.length-1]}return h},i.parseAVCNALu=function(u,c){var r=c.byteLength,h=u.naluState||0,d=h,l=[],v=0,m,L,b,M=-1,F=0;for(h===-1&&(M=0,F=c[0]&31,h=0,v=1);v<r;){if(m=c[v++],!h){h=m?0:1;continue}if(h===1){h=m?0:2;continue}if(!m)h=3;else if(m===1){if(M>=0){var w={data:c.subarray(M,v-h-1),type:F};l.push(w)}else{var C=this.getLastNalUnit(u.samples);if(C&&(d&&v<=4-d&&C.state&&(C.data=C.data.subarray(0,C.data.byteLength-d)),L=v-h-1,L>0)){var U=new Uint8Array(C.data.byteLength+L);U.set(C.data,0),U.set(c.subarray(0,L),C.data.byteLength),C.data=U,C.state=0}}v<r?(b=c[v]&31,M=v,F=b,h=0):h=-1}else h=0}if(M>=0&&h>=0){var k={data:c.subarray(M,r),type:F,state:h};l.push(k)}if(l.length===0){var j=this.getLastNalUnit(u.samples);if(j){var N=new Uint8Array(j.data.byteLength+c.byteLength);N.set(j.data,0),N.set(c,j.data.byteLength),j.data=N}}return u.naluState=h,l},i.parseAACPES=function(u,c){var r=0,h=this.aacOverFlow,d=c.data;if(h){this.aacOverFlow=null;var l=h.missing,v=h.sample.unit.byteLength;if(l===-1){var m=new Uint8Array(v+d.byteLength);m.set(h.sample.unit,0),m.set(d,v),d=m}else{var L=v-l;h.sample.unit.set(d.subarray(0,l),L),u.samples.push(h.sample),r=h.missing}}var b,M;for(b=r,M=d.length;b<M-1&&!R.isHeader(d,b);b++);if(b!==r){var F,w;if(b<M-1?(F="AAC PES did not start with ADTS header,offset:"+b,w=!1):(F="no ADTS header found in AAC PES",w=!0),_.logger.warn("parsing error:"+F),this.observer.emit(S.Events.ERROR,S.Events.ERROR,{type:E.ErrorTypes.MEDIA_ERROR,details:E.ErrorDetails.FRAG_PARSING_ERROR,fatal:w,reason:F}),w)return}R.initTrackConfig(u,this.observer,d,b,this.audioCodec);var C;if(c.pts!==void 0)C=c.pts;else if(h){var U=R.getFrameDuration(u.samplerate);C=h.sample.pts+U}else{_.logger.warn("[tsdemuxer]: AAC PES unknown PTS");return}for(var k=0,j;b<M;)if(j=R.appendFrame(u,d,b,C,k),b+=j.length,j.missing){this.aacOverFlow=j;break}else for(k++;b<M-1&&!R.isHeader(d,b);b++);},i.parseMPEGPES=function(u,c){var r=c.data,h=r.length,d=0,l=0,v=c.pts;if(v===void 0){_.logger.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<h;)if(p.isHeader(r,l)){var m=p.appendFrame(u,r,l,v,d);if(m)l+=m.length,d++;else break}else l++},i.parseID3PES=function(u,c){if(c.pts===void 0){_.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");return}var r=D({},c,{type:this._avcTrack?A.MetadataSchema.emsg:A.MetadataSchema.audioId3});u.samples.push(r)},a}();function g(a,i,t,u){return{key:a,frame:!1,pts:i,dts:t,units:[],debug:u,length:0}}function y(a,i){return(a[i+10]&31)<<8|a[i+11]}function s(a,i,t,u){var c={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},r=(a[i+1]&15)<<8|a[i+2],h=i+3+r-4,d=(a[i+10]&15)<<8|a[i+11];for(i+=12+d;i<h;){var l=(a[i+1]&31)<<8|a[i+2];switch(a[i]){case 207:if(!u){_.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:c.audio===-1&&(c.audio=l);break;case 21:c.id3===-1&&(c.id3=l);break;case 219:if(!u){_.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:c.avc===-1&&(c.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?_.logger.log("MPEG audio found, not supported in this browser"):c.audio===-1&&(c.audio=l,c.segmentCodec="mp3");break;case 36:_.logger.warn("Unsupported HEVC stream type found");break;default:break}i+=((a[i+3]&15)<<8|a[i+4])+5}return c}function e(a){var i=0,t,u,c,r,h,d=a.data;if(!a||a.size===0)return null;for(;d[0].length<19&&d.length>1;){var l=new Uint8Array(d[0].length+d[1].length);l.set(d[0]),l.set(d[1],d[0].length),d[0]=l,d.splice(1,1)}t=d[0];var v=(t[0]<<16)+(t[1]<<8)+t[2];if(v===1){if(u=(t[4]<<8)+t[5],u&&u>a.size-6)return null;var m=t[7];m&192&&(r=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,m&64?(h=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,r-h>60*9e4&&(_.logger.warn(Math.round((r-h)/9e4)+"s delta between PTS and DTS, align them"),r=h)):h=r),c=t[8];var L=c+9;if(a.size<=L)return null;a.size-=L;for(var b=new Uint8Array(a.size),M=0,F=d.length;M<F;M++){t=d[M];var w=t.byteLength;if(L)if(L>w){L-=w;continue}else t=t.subarray(L),w-=L,L=0;b.set(t,i),i+=w}return u&&(u-=c+3),{data:b,pts:r,dts:h,len:u}}return null}function o(a,i){if(a.units.length&&a.frame){if(a.pts===void 0){var t=i.samples,u=t.length;if(u){var c=t[u-1];a.pts=c.pts,a.dts=c.dts}else{i.dropped++;return}}i.samples.push(a)}a.debug.length&&_.logger.log(a.pts+"/"+a.dts+":"+a.debug)}function f(a){for(var i=a.byteLength,t=[],u=1;u<i-2;)a[u]===0&&a[u+1]===0&&a[u+2]===3?(t.push(u+2),u+=2):u++;if(t.length===0)return a;var c=i-t.length,r=new Uint8Array(c),h=0;for(u=0;u<c;h++,u++)h===t[0]&&(h++,t.shift()),r[u]=a[h];return r}P.default=x},"./src/errors.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ErrorTypes",function(){return R}),n.d(P,"ErrorDetails",function(){return p});var R;(function(T){T.NETWORK_ERROR="networkError",T.MEDIA_ERROR="mediaError",T.KEY_SYSTEM_ERROR="keySystemError",T.MUX_ERROR="muxError",T.OTHER_ERROR="otherError"})(R||(R={}));var p;(function(T){T.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",T.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",T.KEY_SYSTEM_NO_SESSION="keySystemNoSession",T.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",T.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",T.MANIFEST_LOAD_ERROR="manifestLoadError",T.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",T.MANIFEST_PARSING_ERROR="manifestParsingError",T.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",T.LEVEL_EMPTY_ERROR="levelEmptyError",T.LEVEL_LOAD_ERROR="levelLoadError",T.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",T.LEVEL_SWITCH_ERROR="levelSwitchError",T.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",T.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",T.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",T.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",T.FRAG_LOAD_ERROR="fragLoadError",T.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",T.FRAG_DECRYPT_ERROR="fragDecryptError",T.FRAG_PARSING_ERROR="fragParsingError",T.REMUX_ALLOC_ERROR="remuxAllocError",T.KEY_LOAD_ERROR="keyLoadError",T.KEY_LOAD_TIMEOUT="keyLoadTimeOut",T.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",T.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",T.BUFFER_APPEND_ERROR="bufferAppendError",T.BUFFER_APPENDING_ERROR="bufferAppendingError",T.BUFFER_STALLED_ERROR="bufferStalledError",T.BUFFER_FULL_ERROR="bufferFullError",T.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",T.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",T.INTERNAL_EXCEPTION="internalException",T.INTERNAL_ABORTED="aborted",T.UNKNOWN="unknown"})(p||(p={}))},"./src/events.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"Events",function(){return R});var R;(function(p){p.MEDIA_ATTACHING="hlsMediaAttaching",p.MEDIA_ATTACHED="hlsMediaAttached",p.MEDIA_DETACHING="hlsMediaDetaching",p.MEDIA_DETACHED="hlsMediaDetached",p.BUFFER_RESET="hlsBufferReset",p.BUFFER_CODECS="hlsBufferCodecs",p.BUFFER_CREATED="hlsBufferCreated",p.BUFFER_APPENDING="hlsBufferAppending",p.BUFFER_APPENDED="hlsBufferAppended",p.BUFFER_EOS="hlsBufferEos",p.BUFFER_FLUSHING="hlsBufferFlushing",p.BUFFER_FLUSHED="hlsBufferFlushed",p.MANIFEST_LOADING="hlsManifestLoading",p.MANIFEST_LOADED="hlsManifestLoaded",p.MANIFEST_PARSED="hlsManifestParsed",p.LEVEL_SWITCHING="hlsLevelSwitching",p.LEVEL_SWITCHED="hlsLevelSwitched",p.LEVEL_LOADING="hlsLevelLoading",p.LEVEL_LOADED="hlsLevelLoaded",p.LEVEL_UPDATED="hlsLevelUpdated",p.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",p.LEVELS_UPDATED="hlsLevelsUpdated",p.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",p.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",p.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",p.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",p.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",p.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",p.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",p.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",p.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",p.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",p.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",p.CUES_PARSED="hlsCuesParsed",p.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",p.INIT_PTS_FOUND="hlsInitPtsFound",p.FRAG_LOADING="hlsFragLoading",p.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",p.FRAG_LOADED="hlsFragLoaded",p.FRAG_DECRYPTED="hlsFragDecrypted",p.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",p.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",p.FRAG_PARSING_METADATA="hlsFragParsingMetadata",p.FRAG_PARSED="hlsFragParsed",p.FRAG_BUFFERED="hlsFragBuffered",p.FRAG_CHANGED="hlsFragChanged",p.FPS_DROP="hlsFpsDrop",p.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",p.ERROR="hlsError",p.DESTROYING="hlsDestroying",p.KEY_LOADING="hlsKeyLoading",p.KEY_LOADED="hlsKeyLoaded",p.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",p.BACK_BUFFER_REACHED="hlsBackBufferReached"})(R||(R={}))},"./src/hls.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return i});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),p=n.n(R),T=n("./src/loader/playlist-loader.ts"),I=n("./src/loader/key-loader.ts"),S=n("./src/controller/id3-track-controller.ts"),O=n("./src/controller/latency-controller.ts"),_=n("./src/controller/level-controller.ts"),E=n("./src/controller/fragment-tracker.ts"),A=n("./src/controller/stream-controller.ts"),D=n("./src/is-supported.ts"),x=n("./src/utils/logger.ts"),g=n("./src/config.ts"),y=n("./node_modules/eventemitter3/index.js"),s=n.n(y),e=n("./src/events.ts"),o=n("./src/errors.ts");function f(t,u){for(var c=0;c<u.length;c++){var r=u[c];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function a(t,u,c){return u&&f(t.prototype,u),c&&f(t,c),Object.defineProperty(t,"prototype",{writable:!1}),t}var i=function(){t.isSupported=function(){return Object(D.isSupported)()};function t(c){c===void 0&&(c={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new y.EventEmitter,this._autoLevelCapping=void 0,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var r=this.config=Object(g.mergeConfig)(t.DefaultConfig,c);this.userConfig=c,Object(x.enableLogs)(r.debug),this._autoLevelCapping=-1,r.progressive&&Object(g.enableStreamingMode)(r);var h=r.abrController,d=r.bufferController,l=r.capLevelController,v=r.fpsController,m=this.abrController=new h(this),L=this.bufferController=new d(this),b=this.capLevelController=new l(this),M=new v(this),F=new T.default(this),w=new I.default(this),C=new S.default(this),U=this.levelController=new _.default(this),k=new E.FragmentTracker(this),j=this.streamController=new A.default(this,k);b.setStreamController(j),M.setStreamController(j);var N=[F,w,U,j];this.networkControllers=N;var W=[m,L,b,M,C,k];this.audioTrackController=this.createController(r.audioTrackController,null,N),this.createController(r.audioStreamController,k,N),this.subtitleTrackController=this.createController(r.subtitleTrackController,null,N),this.createController(r.subtitleStreamController,k,N),this.createController(r.timelineController,null,W),this.emeController=this.createController(r.emeController,null,W),this.cmcdController=this.createController(r.cmcdController,null,W),this.latencyController=this.createController(O.default,null,W),this.coreComponents=W}var u=t.prototype;return u.createController=function(r,h,d){if(r){var l=h?new r(this,h):new r(this);return d&&d.push(l),l}return null},u.on=function(r,h,d){d===void 0&&(d=this),this._emitter.on(r,h,d)},u.once=function(r,h,d){d===void 0&&(d=this),this._emitter.once(r,h,d)},u.removeAllListeners=function(r){this._emitter.removeAllListeners(r)},u.off=function(r,h,d,l){d===void 0&&(d=this),this._emitter.off(r,h,d,l)},u.listeners=function(r){return this._emitter.listeners(r)},u.emit=function(r,h,d){return this._emitter.emit(r,h,d)},u.trigger=function(r,h){if(this.config.debug)return this.emit(r,r,h);try{return this.emit(r,r,h)}catch(d){x.logger.error("An internal error happened while handling event "+r+'. Error message: "'+d.message+'". Here is a stacktrace:',d),this.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:r,error:d})}return!1},u.listenerCount=function(r){return this._emitter.listenerCount(r)},u.destroy=function(){x.logger.log("destroy"),this.trigger(e.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(function(r){return r.destroy()}),this.networkControllers.length=0,this.coreComponents.forEach(function(r){return r.destroy()}),this.coreComponents.length=0},u.attachMedia=function(r){x.logger.log("attachMedia"),this._media=r,this.trigger(e.Events.MEDIA_ATTACHING,{media:r})},u.detachMedia=function(){x.logger.log("detachMedia"),this.trigger(e.Events.MEDIA_DETACHING,void 0),this._media=null},u.loadSource=function(r){this.stopLoad();var h=this.media,d=this.url,l=this.url=R.buildAbsoluteURL(self.location.href,r,{alwaysNormalize:!0});x.logger.log("loadSource:"+l),h&&d&&d!==l&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(h)),this.trigger(e.Events.MANIFEST_LOADING,{url:r})},u.startLoad=function(r){r===void 0&&(r=-1),x.logger.log("startLoad("+r+")"),this.networkControllers.forEach(function(h){h.startLoad(r)})},u.stopLoad=function(){x.logger.log("stopLoad"),this.networkControllers.forEach(function(r){r.stopLoad()})},u.swapAudioCodec=function(){x.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},u.recoverMediaError=function(){x.logger.log("recoverMediaError");var r=this._media;this.detachMedia(),r&&this.attachMedia(r)},u.removeLevel=function(r,h){h===void 0&&(h=0),this.levelController.removeLevel(r,h)},a(t,[{key:"levels",get:function(){var r=this.levelController.levels;return r||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(r){x.logger.log("set currentLevel:"+r),this.loadLevel=r,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(r){x.logger.log("set nextLevel:"+r),this.levelController.manualLevel=r,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(r){x.logger.log("set loadLevel:"+r),this.levelController.manualLevel=r}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(r){this.levelController.nextLoadLevel=r}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(r){x.logger.log("set firstLevel:"+r),this.levelController.firstLevel=r}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(r){x.logger.log("set startLevel:"+r),r!==-1&&(r=Math.max(r,this.minAutoLevel)),this.levelController.startLevel=r}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(r){var h=!!r;h!==this.config.capLevelToPlayerSize&&(h?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=h)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(r){this._autoLevelCapping!==r&&(x.logger.log("set autoLevelCapping:"+r),this._autoLevelCapping=r)}},{key:"bandwidthEstimate",get:function(){var r=this.abrController.bwEstimator;return r?r.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return this.levelController.manualLevel===-1}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var r=this.levels,h=this.config.minAutoBitrate;if(!r)return 0;for(var d=r.length,l=0;l<d;l++)if(r[l].maxBitrate>=h)return l;return 0}},{key:"maxAutoLevel",get:function(){var r=this.levels,h=this.autoLevelCapping,d;return h===-1&&r&&r.length?d=r.length-1:d=h,d}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(r){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,r)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"audioTracks",get:function(){var r=this.audioTrackController;return r?r.audioTracks:[]}},{key:"audioTrack",get:function(){var r=this.audioTrackController;return r?r.audioTrack:-1},set:function(r){var h=this.audioTrackController;h&&(h.audioTrack=r)}},{key:"subtitleTracks",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var r=this.subtitleTrackController;return r?r.subtitleTrack:-1},set:function(r){var h=this.subtitleTrackController;h&&(h.subtitleTrack=r)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var r=this.subtitleTrackController;return r?r.subtitleDisplay:!1},set:function(r){var h=this.subtitleTrackController;h&&(h.subtitleDisplay=r)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(r){this.config.lowLatencyMode=r}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.2.3"}},{key:"Events",get:function(){return e.Events}},{key:"ErrorTypes",get:function(){return o.ErrorTypes}},{key:"ErrorDetails",get:function(){return o.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:g.hlsDefaultConfig},set:function(r){t.defaultConfig=r}}]),t}();i.defaultConfig=void 0},"./src/is-supported.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isSupported",function(){return T}),n.d(P,"changeTypeSupported",function(){return I});var R=n("./src/utils/mediasource-helper.ts");function p(){return self.SourceBuffer||self.WebKitSourceBuffer}function T(){var S=Object(R.getMediaSource)();if(!S)return!1;var O=p(),_=S&&typeof S.isTypeSupported=="function"&&S.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),E=!O||O.prototype&&typeof O.prototype.appendBuffer=="function"&&typeof O.prototype.remove=="function";return!!_&&!!E}function I(){var S,O=p();return typeof(O==null||(S=O.prototype)===null||S===void 0?void 0:S.changeType)=="function"}},"./src/loader/date-range.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"DateRangeAttribute",function(){return _}),n.d(P,"DateRange",function(){return E});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/attr-list.ts"),T=n("./src/utils/logger.ts");function I(){return I=Object.assign?Object.assign.bind():function(A){for(var D=1;D<arguments.length;D++){var x=arguments[D];for(var g in x)Object.prototype.hasOwnProperty.call(x,g)&&(A[g]=x[g])}return A},I.apply(this,arguments)}function S(A,D){for(var x=0;x<D.length;x++){var g=D[x];g.enumerable=g.enumerable||!1,g.configurable=!0,"value"in g&&(g.writable=!0),Object.defineProperty(A,g.key,g)}}function O(A,D,x){return D&&S(A.prototype,D),x&&S(A,x),Object.defineProperty(A,"prototype",{writable:!1}),A}var _;(function(A){A.ID="ID",A.CLASS="CLASS",A.START_DATE="START-DATE",A.DURATION="DURATION",A.END_DATE="END-DATE",A.END_ON_NEXT="END-ON-NEXT",A.PLANNED_DURATION="PLANNED-DURATION",A.SCTE35_OUT="SCTE35-OUT",A.SCTE35_IN="SCTE35-IN"})(_||(_={}));var E=function(){function A(D,x){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,x){var g=x.attr;for(var y in g)if(Object.prototype.hasOwnProperty.call(D,y)&&D[y]!==g[y]){T.logger.warn('DATERANGE tag attribute: "'+y+'" does not match for tags with ID: "'+D.ID+'"'),this._badValueForSameId=y;break}D=I(new p.AttrList({}),g,D)}if(this.attr=D,this._startDate=new Date(D[_.START_DATE]),_.END_DATE in this.attr){var s=new Date(this.attr[_.END_DATE]);Object(R.isFiniteNumber)(s.getTime())&&(this._endDate=s)}}return O(A,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var x=this.duration;return x!==null?new Date(this._startDate.getTime()+x*1e3):null}},{key:"duration",get:function(){if(_.DURATION in this.attr){var x=this.attr.decimalFloatingPoint(_.DURATION);if(Object(R.isFiniteNumber)(x))return x}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return _.PLANNED_DURATION in this.attr?this.attr.decimalFloatingPoint(_.PLANNED_DURATION):null}},{key:"endOnNext",get:function(){return this.attr.bool(_.END_ON_NEXT)}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&Object(R.isFiniteNumber)(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),A}()},"./src/loader/fragment-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return x}),n.d(P,"LoadError",function(){return y});var R=n("./src/polyfills/number.ts"),p=n("./src/errors.ts");function T(s,e){s.prototype=Object.create(e.prototype),s.prototype.constructor=s,E(s,e)}function I(s){var e=typeof Map=="function"?new Map:void 0;return I=function(f){if(f===null||!_(f))return f;if(typeof f!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e!="undefined"){if(e.has(f))return e.get(f);e.set(f,a)}function a(){return S(f,arguments,A(this).constructor)}return a.prototype=Object.create(f.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),E(a,f)},I(s)}function S(s,e,o){return O()?S=Reflect.construct.bind():S=function(a,i,t){var u=[null];u.push.apply(u,i);var c=Function.bind.apply(a,u),r=new c;return t&&E(r,t.prototype),r},S.apply(null,arguments)}function O(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function _(s){return Function.toString.call(s).indexOf("[native code]")!==-1}function E(s,e){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(f,a){return f.__proto__=a,f},E(s,e)}function A(s){return A=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(o){return o.__proto__||Object.getPrototypeOf(o)},A(s)}var D=Math.pow(2,17),x=function(){function s(o){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=o}var e=s.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(f,a){var i=this,t=f.url;if(!t)return Promise.reject(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,networkDetails:null},"Fragment does not have a "+(t?"part list":"url")));this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){i.loader&&i.loader.destroy();var l=i.loader=f.loader=c?new c(u):new r(u),v=g(f),m={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:f.sn==="initSegment"?1/0:D};f.stats=l.stats,l.load(v,m,{onSuccess:function(b,M,F,w){i.resetLoader(f,l),h({frag:f,part:null,payload:b.data,networkDetails:w})},onError:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,response:b,networkDetails:F}))},onAbort:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,networkDetails:F}))},onTimeout:function(b,M,F){i.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,networkDetails:F}))},onProgress:function(b,M,F,w){a&&a({frag:f,part:null,payload:F,networkDetails:w})}})})},e.loadPart=function(f,a,i){var t=this;this.abort();var u=this.config,c=u.fLoader,r=u.loader;return new Promise(function(h,d){t.loader&&t.loader.destroy();var l=t.loader=f.loader=c?new c(u):new r(u),v=g(f,a),m={timeout:u.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:u.fragLoadingMaxRetryTimeout,highWaterMark:D};a.stats=l.stats,l.load(v,m,{onSuccess:function(b,M,F,w){t.resetLoader(f,l),t.updateStatsFromPart(f,a);var C={frag:f,part:a,payload:b.data,networkDetails:w};i(C),h(C)},onError:function(b,M,F){t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:f,part:a,response:b,networkDetails:F}))},onAbort:function(b,M,F){f.stats.aborted=a.stats.aborted,t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:f,part:a,networkDetails:F}))},onTimeout:function(b,M,F){t.resetLoader(f,l),d(new y({type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:f,part:a,networkDetails:F}))}})})},e.updateStatsFromPart=function(f,a){var i=f.stats,t=a.stats,u=t.total;if(i.loaded+=t.loaded,u){var c=Math.round(f.duration/a.duration),r=Math.min(Math.round(i.loaded/u),c),h=c-r,d=h*Math.round(i.loaded/r);i.total=i.loaded+d}else i.total=Math.max(i.loaded,i.total);var l=i.loading,v=t.loading;l.start?l.first+=v.first-v.start:(l.start=v.start,l.first=v.first),l.end=v.end},e.resetLoader=function(f,a){f.loader=null,this.loader===a&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),a.destroy()},s}();function g(s,e){e===void 0&&(e=null);var o=e||s,f={frag:s,part:e,responseType:"arraybuffer",url:o.url,headers:{},rangeStart:0,rangeEnd:0},a=o.byteRangeStartOffset,i=o.byteRangeEndOffset;return Object(R.isFiniteNumber)(a)&&Object(R.isFiniteNumber)(i)&&(f.rangeStart=a,f.rangeEnd=i),f}var y=function(s){T(e,s);function e(o){for(var f,a=arguments.length,i=new Array(a>1?a-1:0),t=1;t<a;t++)i[t-1]=arguments[t];return f=s.call.apply(s,[this].concat(i))||this,f.data=void 0,f.data=o,f}return e}(I(Error))},"./src/loader/fragment.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ElementaryStreamTypes",function(){return x}),n.d(P,"BaseSegment",function(){return g}),n.d(P,"Fragment",function(){return y}),n.d(P,"Part",function(){return s});var R=n("./src/polyfills/number.ts"),p=n("./node_modules/url-toolkit/src/url-toolkit.js"),T=n.n(p),I=n("./src/utils/logger.ts"),S=n("./src/loader/level-key.ts"),O=n("./src/loader/load-stats.ts");function _(e,o){e.prototype=Object.create(o.prototype),e.prototype.constructor=e,E(e,o)}function E(e,o){return E=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,i){return a.__proto__=i,a},E(e,o)}function A(e,o){for(var f=0;f<o.length;f++){var a=o[f];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}function D(e,o,f){return o&&A(e.prototype,o),f&&A(e,f),Object.defineProperty(e,"prototype",{writable:!1}),e}var x;(function(e){e.AUDIO="audio",e.VIDEO="video",e.AUDIOVIDEO="audiovideo"})(x||(x={}));var g=function(){function e(f){var a;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=(a={},a[x.AUDIO]=null,a[x.VIDEO]=null,a[x.AUDIOVIDEO]=null,a),this.baseurl=f}var o=e.prototype;return o.setByteRange=function(a,i){var t=a.split("@",2),u=[];t.length===1?u[0]=i?i.byteRangeEndOffset:0:u[0]=parseInt(t[1]),u[1]=parseInt(t[0])+u[0],this._byteRange=u},D(e,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(p.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(a){this._url=a}}]),e}(),y=function(e){_(o,e);function o(a,i){var t;return t=e.call(this,i)||this,t._decryptdata=null,t.rawProgramDateTime=null,t.programDateTime=null,t.tagList=[],t.duration=0,t.sn=0,t.levelkey=void 0,t.type=void 0,t.loader=null,t.level=-1,t.cc=0,t.startPTS=void 0,t.endPTS=void 0,t.appendedPTS=void 0,t.startDTS=void 0,t.endDTS=void 0,t.start=0,t.deltaPTS=void 0,t.maxStartPTS=void 0,t.minEndPTS=void 0,t.stats=new O.LoadStats,t.urlId=0,t.data=void 0,t.bitrateTest=!1,t.title=null,t.initSegment=null,t.type=a,t}var f=o.prototype;return f.createInitializationVector=function(i){for(var t=new Uint8Array(16),u=12;u<16;u++)t[u]=i>>8*(15-u)&255;return t},f.setDecryptDataFromLevelKey=function(i,t){var u=i;return(i==null?void 0:i.method)==="AES-128"&&i.uri&&!i.iv&&(u=S.LevelKey.fromURI(i.uri),u.method=i.method,u.iv=this.createInitializationVector(t),u.keyFormat="identity"),u},f.setElementaryStreamInfo=function(i,t,u,c,r,h){h===void 0&&(h=!1);var d=this.elementaryStreams,l=d[i];if(!l){d[i]={startPTS:t,endPTS:u,startDTS:c,endDTS:r,partial:h};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,u),l.startDTS=Math.min(l.startDTS,c),l.endDTS=Math.max(l.endDTS,r)},f.clearElementaryStreamInfo=function(){var i=this.elementaryStreams;i[x.AUDIO]=null,i[x.VIDEO]=null,i[x.AUDIOVIDEO]=null},D(o,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var i=this.sn;typeof i!="number"&&(this.levelkey&&this.levelkey.method==="AES-128"&&!this.levelkey.iv&&I.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),i=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,i)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(this.programDateTime===null||!Object(R.isFiniteNumber)(this.programDateTime))return null;var i=Object(R.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+i*1e3}},{key:"encrypted",get:function(){var i;return!!((i=this.decryptdata)!==null&&i!==void 0&&i.keyFormat&&this.decryptdata.uri)}}]),o}(g),s=function(e){_(o,e);function o(f,a,i,t,u){var c;c=e.call(this,i)||this,c.fragOffset=0,c.duration=0,c.gap=!1,c.independent=!1,c.relurl=void 0,c.fragment=void 0,c.index=void 0,c.stats=new O.LoadStats,c.duration=f.decimalFloatingPoint("DURATION"),c.gap=f.bool("GAP"),c.independent=f.bool("INDEPENDENT"),c.relurl=f.enumeratedString("URI"),c.fragment=a,c.index=t;var r=f.enumeratedString("BYTERANGE");return r&&c.setByteRange(r,u),u&&(c.fragOffset=u.fragOffset+u.duration),c}return D(o,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var a=this.elementaryStreams;return!!(a.audio||a.video||a.audiovideo)}}]),o}(g)},"./src/loader/key-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return I});var R=n("./src/events.ts"),p=n("./src/errors.ts"),T=n("./src/utils/logger.ts"),I=function(){function S(_){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=_,this.registerListeners()}var O=S.prototype;return O.startLoad=function(E){},O.stopLoad=function(){this.destroyInternalLoaders()},O.registerListeners=function(){this.hls.on(R.Events.KEY_LOADING,this.onKeyLoading,this)},O.unregisterListeners=function(){this.hls.off(R.Events.KEY_LOADING,this.onKeyLoading)},O.destroyInternalLoaders=function(){for(var E in this.loaders){var A=this.loaders[E];A&&A.destroy()}this.loaders={}},O.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},O.onKeyLoading=function(E,A){var D=A.frag,x=D.type,g=this.loaders[x];if(!D.decryptdata){T.logger.warn("Missing decryption data on fragment in onKeyLoading");return}var y=D.decryptdata.uri;if(y!==this.decrypturl||this.decryptkey===null){var s=this.hls.config;if(g&&(T.logger.warn("abort previous key loader for type:"+x),g.abort()),!y){T.logger.warn("key uri is falsy");return}var e=s.loader,o=D.loader=this.loaders[x]=new e(s);this.decrypturl=y,this.decryptkey=null;var f={url:y,frag:D,responseType:"arraybuffer"},a={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:s.fragLoadingRetryDelay,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:0},i={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};o.load(f,a,i)}else this.decryptkey&&(D.decryptdata.key=this.decryptkey,this.hls.trigger(R.Events.KEY_LOADED,{frag:D}))},O.loadsuccess=function(E,A,D){var x=D.frag;if(!x.decryptdata){T.logger.error("after key load, decryptdata unset");return}this.decryptkey=x.decryptdata.key=new Uint8Array(E.data),x.loader=null,delete this.loaders[x.type],this.hls.trigger(R.Events.KEY_LOADED,{frag:x})},O.loaderror=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:D,response:E})},O.loadtimeout=function(E,A){var D=A.frag,x=D.loader;x&&x.abort(),delete this.loaders[D.type],this.hls.trigger(R.Events.ERROR,{type:p.ErrorTypes.NETWORK_ERROR,details:p.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:D})},S}()},"./src/loader/level-details.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelDetails",function(){return S});var R=n("./src/polyfills/number.ts");function p(O,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(O,A.key,A)}}function T(O,_,E){return _&&p(O.prototype,_),E&&p(O,E),Object.defineProperty(O,"prototype",{writable:!1}),O}var I=10,S=function(){function O(E){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.fragments=[],this.dateRanges={},this.url=E}var _=O.prototype;return _.reloaded=function(A){if(!A){this.advanced=!0,this.updated=!0;return}var D=this.lastPartSn-A.lastPartSn,x=this.lastPartIndex-A.lastPartIndex;this.updated=this.endSN!==A.endSN||!!x||!!D,this.advanced=this.endSN>A.endSN||D>0||D===0&&x>0,this.updated||this.advanced?this.misses=Math.floor(A.misses*.6):this.misses=A.misses+1,this.availabilityDelay=A.availabilityDelay},T(O,[{key:"hasProgramDateTime",get:function(){return this.fragments.length?Object(R.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime):!1}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||I}},{key:"drift",get:function(){var A=this.driftEndTime-this.driftStartTime;if(A>0){var D=this.driftEnd-this.driftStart;return D*1e3/A}return 1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var A;return(A=this.fragments)!==null&&A!==void 0&&A.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var A;return(A=this.partList)!==null&&A!==void 0&&A.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),O}()},"./src/loader/level-key.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LevelKey",function(){return S});var R=n("./node_modules/url-toolkit/src/url-toolkit.js"),p=n.n(R);function T(O,_){for(var E=0;E<_.length;E++){var A=_[E];A.enumerable=A.enumerable||!1,A.configurable=!0,"value"in A&&(A.writable=!0),Object.defineProperty(O,A.key,A)}}function I(O,_,E){return _&&T(O.prototype,_),E&&T(O,E),Object.defineProperty(O,"prototype",{writable:!1}),O}var S=function(){O.fromURL=function(E,A){return new O(E,A)},O.fromURI=function(E){return new O(E)};function O(_,E){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,E?this._uri=Object(R.buildAbsoluteURL)(_,E,{alwaysNormalize:!0}):this._uri=_}return I(O,[{key:"uri",get:function(){return this._uri}}]),O}()},"./src/loader/load-stats.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"LoadStats",function(){return R});var R=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}},"./src/loader/m3u8-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return f});var R=n("./src/polyfills/number.ts"),p=n("./node_modules/url-toolkit/src/url-toolkit.js"),T=n.n(p),I=n("./src/loader/date-range.ts"),S=n("./src/loader/fragment.ts"),O=n("./src/loader/level-details.ts"),_=n("./src/loader/level-key.ts"),E=n("./src/utils/attr-list.ts"),A=n("./src/utils/logger.ts"),D=n("./src/utils/codecs.ts"),x=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,g=/#EXT-X-MEDIA:(.*)/g,y=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),s=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),e=/\.(mp4|m4s|m4v|m4a)$/i;function o(r){var h,d;return e.test((h=(d=p.parseURL(r))===null||d===void 0?void 0:d.path)!=null?h:"")}var f=function(){function r(){}return r.findGroup=function(d,l){for(var v=0;v<d.length;v++){var m=d[v];if(m.id===l)return m}},r.convertAVC1ToAVCOTI=function(d){var l=d.split(".");if(l.length>2){var v=l.shift()+".";return v+=parseInt(l.shift()).toString(16),v+=("000"+parseInt(l.shift()).toString(16)).slice(-4),v}return d},r.resolve=function(d,l){return p.buildAbsoluteURL(l,d,{alwaysNormalize:!0})},r.parseMasterPlaylist=function(d,l){var v=[],m={},L=!1;x.lastIndex=0;for(var b;(b=x.exec(d))!=null;)if(b[1]){var M=new E.AttrList(b[1]),F={attrs:M,bitrate:M.decimalInteger("AVERAGE-BANDWIDTH")||M.decimalInteger("BANDWIDTH"),name:M.NAME,url:r.resolve(b[2],l)},w=M.decimalResolution("RESOLUTION");w&&(F.width=w.width,F.height=w.height),a((M.CODECS||"").split(/[ ,]+/).filter(function(U){return U}),F),F.videoCodec&&F.videoCodec.indexOf("avc1")!==-1&&(F.videoCodec=r.convertAVC1ToAVCOTI(F.videoCodec)),v.push(F)}else if(b[3]){var C=new E.AttrList(b[3]);C["DATA-ID"]&&(L=!0,m[C["DATA-ID"]]=C)}return{levels:v,sessionData:L?m:null}},r.parseMasterPlaylistMedia=function(d,l,v,m){m===void 0&&(m=[]);var L,b=[],M=0;for(g.lastIndex=0;(L=g.exec(d))!==null;){var F=new E.AttrList(L[1]);if(F.TYPE===v){var w={attrs:F,bitrate:0,id:M++,groupId:F["GROUP-ID"],instreamId:F["INSTREAM-ID"],name:F.NAME||F.LANGUAGE||"",type:v,default:F.bool("DEFAULT"),autoselect:F.bool("AUTOSELECT"),forced:F.bool("FORCED"),lang:F.LANGUAGE,url:F.URI?r.resolve(F.URI,l):""};if(m.length){var C=r.findGroup(m,w.groupId)||m[0];i(w,C,"audioCodec"),i(w,C,"textCodec")}b.push(w)}}return b},r.parseLevelPlaylist=function(d,l,v,m,L){var b=new O.LevelDetails(l),M=b.fragments,F=null,w=0,C=0,U=0,k=0,j=null,N=new S.Fragment(m,l),W,Y,K,H=-1,z=!1;for(y.lastIndex=0,b.m3u8=d;(W=y.exec(d))!==null;){z&&(z=!1,N=new S.Fragment(m,l),N.start=U,N.sn=w,N.cc=k,N.level=v,F&&(N.initSegment=F,N.rawProgramDateTime=F.rawProgramDateTime,F.rawProgramDateTime=null));var $=W[1];if($){N.duration=parseFloat($);var X=(" "+W[2]).slice(1);N.title=X||null,N.tagList.push(X?["INF",$,X]:["INF",$])}else if(W[3])Object(R.isFiniteNumber)(N.duration)&&(N.start=U,K&&(N.levelkey=K),N.sn=w,N.level=v,N.cc=k,N.urlId=L,M.push(N),N.relurl=(" "+W[3]).slice(1),u(N,j),j=N,U+=N.duration,w++,C=0,z=!0);else if(W[4]){var J=(" "+W[4]).slice(1);j?N.setByteRange(J,j):N.setByteRange(J)}else if(W[5])N.rawProgramDateTime=(" "+W[5]).slice(1),N.tagList.push(["PROGRAM-DATE-TIME",N.rawProgramDateTime]),H===-1&&(H=M.length);else{if(W=W[0].match(s),!W){A.logger.warn("No matches on slow regex match for level playlist!");continue}for(Y=1;Y<W.length&&typeof W[Y]=="undefined";Y++);var te=(" "+W[Y]).slice(1),Q=(" "+W[Y+1]).slice(1),ae=W[Y+2]?(" "+W[Y+2]).slice(1):"";switch(te){case"PLAYLIST-TYPE":b.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":w=b.startSN=parseInt(Q);break;case"SKIP":{var se=new E.AttrList(Q),re=se.decimalInteger("SKIPPED-SEGMENTS");if(Object(R.isFiniteNumber)(re)){b.skippedSegments=re;for(var ee=re;ee--;)M.unshift(null);w+=re}var Z=se.enumeratedString("RECENTLY-REMOVED-DATERANGES");Z&&(b.recentlyRemovedDateranges=Z.split(" "));break}case"TARGETDURATION":b.targetduration=parseFloat(Q);break;case"VERSION":b.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(Q||ae)&&N.tagList.push(ae?[Q,ae]:[Q]);break;case"DISCONTINUITY":k++,N.tagList.push(["DIS"]);break;case"GAP":N.tagList.push([te]);break;case"BITRATE":N.tagList.push([te,Q]);break;case"DATERANGE":{var q=new E.AttrList(Q),fe=new I.DateRange(q,b.dateRanges[q.ID]);fe.isValid||b.skippedSegments?b.dateRanges[fe.id]=fe:A.logger.warn('Ignoring invalid DATERANGE tag: "'+Q+'"'),N.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DISCONTINUITY-SEQUENCE":k=parseInt(Q);break;case"KEY":{var ge,ie=new E.AttrList(Q),me=ie.enumeratedString("METHOD"),ye=ie.URI,Te=ie.hexadecimalInteger("IV"),oe=ie.enumeratedString("KEYFORMATVERSIONS"),de=ie.enumeratedString("KEYID"),Se=(ge=ie.enumeratedString("KEYFORMAT"))!=null?ge:"identity",Ee=["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"];if(Ee.indexOf(Se)>-1){A.logger.warn("Keyformat "+Se+" is not supported from the manifest");continue}else if(Se!=="identity")continue;me&&(K=_.LevelKey.fromURL(l,ye),ye&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(me)>=0&&(K.method=me,K.keyFormat=Se,de&&(K.keyID=de),oe&&(K.keyFormatVersions=oe),K.iv=Te));break}case"START":{var Ae=new E.AttrList(Q),Oe=Ae.decimalFloatingPoint("TIME-OFFSET");Object(R.isFiniteNumber)(Oe)&&(b.startTimeOffset=Oe);break}case"MAP":{var Me=new E.AttrList(Q);if(N.duration){var De=new S.Fragment(m,l);c(De,Me,v,K),F=De,N.initSegment=F,F.rawProgramDateTime&&!N.rawProgramDateTime&&(N.rawProgramDateTime=F.rawProgramDateTime)}else c(N,Me,v,K),F=N,z=!0;break}case"SERVER-CONTROL":{var xe=new E.AttrList(Q);b.canBlockReload=xe.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=xe.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&xe.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=xe.optionalFloat("PART-HOLD-BACK",0),b.holdBack=xe.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{var G=new E.AttrList(Q);b.partTarget=G.decimalFloatingPoint("PART-TARGET");break}case"PART":{var V=b.partList;V||(V=b.partList=[]);var ue=C>0?V[V.length-1]:void 0,he=C++,pe=new S.Part(new E.AttrList(Q),N,l,he,ue);V.push(pe),N.duration+=pe.duration;break}case"PRELOAD-HINT":{var _e=new E.AttrList(Q);b.preloadHint=_e;break}case"RENDITION-REPORT":{var le=new E.AttrList(Q);b.renditionReports=b.renditionReports||[],b.renditionReports.push(le);break}default:A.logger.warn("line parsed but not handled: "+W);break}}}j&&!j.relurl?(M.pop(),U-=j.duration,b.partList&&(b.fragmentHint=j)):b.partList&&(u(N,j),N.cc=k,b.fragmentHint=N);var Re=M.length,Le=M[0],Ie=M[Re-1];if(U+=b.skippedSegments*b.targetduration,U>0&&Re&&Ie){b.averagetargetduration=U/Re;var je=Ie.sn;b.endSN=je!=="initSegment"?je:0,Le&&(b.startCC=Le.cc,Le.initSegment||b.fragments.every(function(ke){return ke.relurl&&o(ke.relurl)})&&(A.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),N=new S.Fragment(m,l),N.relurl=Ie.relurl,N.level=v,N.sn="initSegment",Le.initSegment=N,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(U+=b.fragmentHint.duration),b.totalduration=U,b.endCC=k,H>0&&t(M,H),b},r}();function a(r,h){["video","audio","text"].forEach(function(d){var l=r.filter(function(m){return Object(D.isCodecType)(m,d)});if(l.length){var v=l.filter(function(m){return m.lastIndexOf("avc1",0)===0||m.lastIndexOf("mp4a",0)===0});h[d+"Codec"]=v.length>0?v[0]:l[0],r=r.filter(function(m){return l.indexOf(m)===-1})}}),h.unknownCodecs=r}function i(r,h,d){var l=h[d];l&&(r[d]=l)}function t(r,h){for(var d=r[h],l=h;l--;){var v=r[l];if(!v)return;v.programDateTime=d.programDateTime-v.duration*1e3,d=v}}function u(r,h){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):h!=null&&h.programDateTime&&(r.programDateTime=h.endProgramDateTime),Object(R.isFiniteNumber)(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function c(r,h,d,l){r.relurl=h.URI,h.BYTERANGE&&r.setByteRange(h.BYTERANGE),r.level=d,r.sn="initSegment",l&&(r.levelkey=l),r.initSegment=null}},"./src/loader/playlist-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/events.ts"),T=n("./src/errors.ts"),I=n("./src/utils/logger.ts"),S=n("./src/utils/mp4-tools.ts"),O=n("./src/loader/m3u8-parser.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/attr-list.ts");function A(g){var y=g.type;switch(y){case _.PlaylistContextType.AUDIO_TRACK:return _.PlaylistLevelType.AUDIO;case _.PlaylistContextType.SUBTITLE_TRACK:return _.PlaylistLevelType.SUBTITLE;default:return _.PlaylistLevelType.MAIN}}function D(g,y){var s=g.url;return(s===void 0||s.indexOf("data:")===0)&&(s=y.url),s}var x=function(){function g(s){this.hls=void 0,this.loaders=Object.create(null),this.hls=s,this.registerListeners()}var y=g.prototype;return y.startLoad=function(e){},y.stopLoad=function(){this.destroyInternalLoaders()},y.registerListeners=function(){var e=this.hls;e.on(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.unregisterListeners=function(){var e=this.hls;e.off(p.Events.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.Events.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},y.createInternalLoader=function(e){var o=this.hls.config,f=o.pLoader,a=o.loader,i=f||a,t=new i(o);return e.loader=t,this.loaders[e.type]=t,t},y.getInternalLoader=function(e){return this.loaders[e.type]},y.resetInternalLoader=function(e){this.loaders[e]&&delete this.loaders[e]},y.destroyInternalLoaders=function(){for(var e in this.loaders){var o=this.loaders[e];o&&o.destroy(),this.resetInternalLoader(e)}},y.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},y.onManifestLoading=function(e,o){var f=o.url;this.load({id:null,groupId:null,level:0,responseType:"text",type:_.PlaylistContextType.MANIFEST,url:f,deliveryDirectives:null})},y.onLevelLoading=function(e,o){var f=o.id,a=o.level,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:null,level:a,responseType:"text",type:_.PlaylistContextType.LEVEL,url:i,deliveryDirectives:t})},y.onAudioTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.AUDIO_TRACK,url:i,deliveryDirectives:t})},y.onSubtitleTrackLoading=function(e,o){var f=o.id,a=o.groupId,i=o.url,t=o.deliveryDirectives;this.load({id:f,groupId:a,level:null,responseType:"text",type:_.PlaylistContextType.SUBTITLE_TRACK,url:i,deliveryDirectives:t})},y.load=function(e){var o,f=this.hls.config,a=this.getInternalLoader(e);if(a){var i=a.context;if(i&&i.url===e.url){I.logger.trace("[playlist-loader]: playlist request ongoing");return}I.logger.log("[playlist-loader]: aborting previous loader for type: "+e.type),a.abort()}var t,u,c,r;switch(e.type){case _.PlaylistContextType.MANIFEST:t=f.manifestLoadingMaxRetry,u=f.manifestLoadingTimeOut,c=f.manifestLoadingRetryDelay,r=f.manifestLoadingMaxRetryTimeout;break;case _.PlaylistContextType.LEVEL:case _.PlaylistContextType.AUDIO_TRACK:case _.PlaylistContextType.SUBTITLE_TRACK:t=0,u=f.levelLoadingTimeOut;break;default:t=f.levelLoadingMaxRetry,u=f.levelLoadingTimeOut,c=f.levelLoadingRetryDelay,r=f.levelLoadingMaxRetryTimeout;break}if(a=this.createInternalLoader(e),(o=e.deliveryDirectives)!==null&&o!==void 0&&o.part){var h;if(e.type===_.PlaylistContextType.LEVEL&&e.level!==null?h=this.hls.levels[e.level].details:e.type===_.PlaylistContextType.AUDIO_TRACK&&e.id!==null?h=this.hls.audioTracks[e.id].details:e.type===_.PlaylistContextType.SUBTITLE_TRACK&&e.id!==null&&(h=this.hls.subtitleTracks[e.id].details),h){var d=h.partTarget,l=h.targetduration;d&&l&&(u=Math.min(Math.max(d*3,l*.8)*1e3,u))}}var v={timeout:u,maxRetry:t,retryDelay:c,maxRetryDelay:r,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};a.load(e,v,m)},y.loadsuccess=function(e,o,f,a){if(a===void 0&&(a=null),f.isSidxRequest){this.handleSidxRequest(e,f),this.handlePlaylistLoaded(e,o,f,a);return}this.resetInternalLoader(f.type);var i=e.data;if(i.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(e,f,"no EXTM3U delimiter",a);return}o.parsing.start=performance.now(),i.indexOf("#EXTINF:")>0||i.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(e,o,f,a):this.handleMasterPlaylist(e,o,f,a)},y.loaderror=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!1,e)},y.loadtimeout=function(e,o,f){f===void 0&&(f=null),this.handleNetworkError(o,f,!0)},y.handleMasterPlaylist=function(e,o,f,a){var i=this.hls,t=e.data,u=D(e,f),c=O.default.parseMasterPlaylist(t,u),r=c.levels,h=c.sessionData;if(!r.length){this.handleManifestParsingError(e,f,"no level found in manifest",a);return}var d=r.map(function(M){return{id:M.attrs.AUDIO,audioCodec:M.audioCodec}}),l=r.map(function(M){return{id:M.attrs.SUBTITLES,textCodec:M.textCodec}}),v=O.default.parseMasterPlaylistMedia(t,u,"AUDIO",d),m=O.default.parseMasterPlaylistMedia(t,u,"SUBTITLES",l),L=O.default.parseMasterPlaylistMedia(t,u,"CLOSED-CAPTIONS");if(v.length){var b=v.some(function(M){return!M.url});!b&&r[0].audioCodec&&!r[0].attrs.AUDIO&&(I.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),v.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new E.AttrList({}),bitrate:0,url:""}))}i.trigger(p.Events.MANIFEST_LOADED,{levels:r,audioTracks:v,subtitles:m,captions:L,url:u,stats:o,networkDetails:a,sessionData:h})},y.handleTrackOrLevelPlaylist=function(e,o,f,a){var i=this.hls,t=f.id,u=f.level,c=f.type,r=D(e,f),h=Object(R.isFiniteNumber)(t)?t:0,d=Object(R.isFiniteNumber)(u)?u:h,l=A(f),v=O.default.parseLevelPlaylist(e.data,r,d,l,h);if(!v.fragments.length){i.trigger(p.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:r,reason:"no fragments found in level",level:typeof f.level=="number"?f.level:void 0});return}if(c===_.PlaylistContextType.MANIFEST){var m={attrs:new E.AttrList({}),bitrate:0,details:v,name:"",url:r};i.trigger(p.Events.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:r,stats:o,networkDetails:a,sessionData:null})}if(o.parsing.end=performance.now(),v.needSidxRanges){var L,b=(L=v.fragments[0].initSegment)===null||L===void 0?void 0:L.url;this.load({url:b,isSidxRequest:!0,type:c,level:u,levelDetails:v,id:t,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null});return}f.levelDetails=v,this.handlePlaylistLoaded(e,o,f,a)},y.handleSidxRequest=function(e,o){var f=new Uint8Array(e.data),a=Object(S.findBox)(f,["sidx"])[0];if(!!a){var i=Object(S.parseSegmentIndex)(a);if(!!i){var t=i.references,u=o.levelDetails;t.forEach(function(c,r){var h=c.info,d=u.fragments[r];if(d.byteRange.length===0&&d.setByteRange(String(1+h.end-h.start)+"@"+String(h.start)),d.initSegment){var l=Object(S.findBox)(f,["moov"])[0],v=l?l.length:null;d.initSegment.setByteRange(String(v)+"@0")}})}}},y.handleManifestParsingError=function(e,o,f,a){this.hls.trigger(p.Events.ERROR,{type:T.ErrorTypes.NETWORK_ERROR,details:T.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:o.type===_.PlaylistContextType.MANIFEST,url:e.url,reason:f,response:e,context:o,networkDetails:a})},y.handleNetworkError=function(e,o,f,a){f===void 0&&(f=!1),I.logger.warn("[playlist-loader]: A network "+(f?"timeout":"error")+" occurred while loading "+e.type+" level: "+e.level+" id: "+e.id+' group-id: "'+e.groupId+'"');var i=T.ErrorDetails.UNKNOWN,t=!1,u=this.getInternalLoader(e);switch(e.type){case _.PlaylistContextType.MANIFEST:i=f?T.ErrorDetails.MANIFEST_LOAD_TIMEOUT:T.ErrorDetails.MANIFEST_LOAD_ERROR,t=!0;break;case _.PlaylistContextType.LEVEL:i=f?T.ErrorDetails.LEVEL_LOAD_TIMEOUT:T.ErrorDetails.LEVEL_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.AUDIO_TRACK:i=f?T.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:T.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,t=!1;break;case _.PlaylistContextType.SUBTITLE_TRACK:i=f?T.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:T.ErrorDetails.SUBTITLE_LOAD_ERROR,t=!1;break}u&&this.resetInternalLoader(e.type);var c={type:T.ErrorTypes.NETWORK_ERROR,details:i,fatal:t,url:e.url,loader:u,context:e,networkDetails:o};a&&(c.response=a),this.hls.trigger(p.Events.ERROR,c)},y.handlePlaylistLoaded=function(e,o,f,a){var i=f.type,t=f.level,u=f.id,c=f.groupId,r=f.loader,h=f.levelDetails,d=f.deliveryDirectives;if(!(h!=null&&h.targetduration)){this.handleManifestParsingError(e,f,"invalid target duration",a);return}if(!!r)switch(h.live&&(r.getCacheAge&&(h.ageHeader=r.getCacheAge()||0),(!r.getCacheAge||isNaN(h.ageHeader))&&(h.ageHeader=0)),i){case _.PlaylistContextType.MANIFEST:case _.PlaylistContextType.LEVEL:this.hls.trigger(p.Events.LEVEL_LOADED,{details:h,level:t||0,id:u||0,stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(p.Events.AUDIO_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break;case _.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(p.Events.SUBTITLE_TRACK_LOADED,{details:h,id:u||0,groupId:c||"",stats:o,networkDetails:a,deliveryDirectives:d});break}},g}();P.default=x},"./src/polyfills/number.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isFiniteNumber",function(){return R}),n.d(P,"MAX_SAFE_INTEGER",function(){return p});var R=Number.isFinite||function(T){return typeof T=="number"&&isFinite(T)},p=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function p(){}return p.getSilentFrame=function(I,S){switch(I){case"mp4a.40.2":if(S===1)return new Uint8Array([0,200,0,128,35,128]);if(S===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(S===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(S===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(S===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(S===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(S===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(S===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(S===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}},p}();P.default=R},"./src/remux/mp4-generator.ts":function(B,P,n){"use strict";n.r(P);var R=Math.pow(2,32)-1,p=function(){function T(){}return T.init=function(){T.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};var S;for(S in T.types)T.types.hasOwnProperty(S)&&(T.types[S]=[S.charCodeAt(0),S.charCodeAt(1),S.charCodeAt(2),S.charCodeAt(3)]);var O=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),_=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);T.HDLR_TYPES={video:O,audio:_};var E=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),A=new Uint8Array([0,0,0,0,0,0,0,0]);T.STTS=T.STSC=T.STCO=A,T.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),T.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),T.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),T.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var D=new Uint8Array([105,115,111,109]),x=new Uint8Array([97,118,99,49]),g=new Uint8Array([0,0,0,1]);T.FTYP=T.box(T.types.ftyp,D,g,D,x),T.DINF=T.box(T.types.dinf,T.box(T.types.dref,E))},T.box=function(S){for(var O=8,_=arguments.length,E=new Array(_>1?_-1:0),A=1;A<_;A++)E[A-1]=arguments[A];for(var D=E.length,x=D;D--;)O+=E[D].byteLength;var g=new Uint8Array(O);for(g[0]=O>>24&255,g[1]=O>>16&255,g[2]=O>>8&255,g[3]=O&255,g.set(S,4),D=0,O=8;D<x;D++)g.set(E[D],O),O+=E[D].byteLength;return g},T.hdlr=function(S){return T.box(T.types.hdlr,T.HDLR_TYPES[S])},T.mdat=function(S){return T.box(T.types.mdat,S)},T.mdhd=function(S,O){O*=S;var _=Math.floor(O/(R+1)),E=Math.floor(O%(R+1));return T.box(T.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,S>>24&255,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,85,196,0,0]))},T.mdia=function(S){return T.box(T.types.mdia,T.mdhd(S.timescale,S.duration),T.hdlr(S.type),T.minf(S))},T.mfhd=function(S){return T.box(T.types.mfhd,new Uint8Array([0,0,0,0,S>>24,S>>16&255,S>>8&255,S&255]))},T.minf=function(S){return S.type==="audio"?T.box(T.types.minf,T.box(T.types.smhd,T.SMHD),T.DINF,T.stbl(S)):T.box(T.types.minf,T.box(T.types.vmhd,T.VMHD),T.DINF,T.stbl(S))},T.moof=function(S,O,_){return T.box(T.types.moof,T.mfhd(S),T.traf(_,O))},T.moov=function(S){for(var O=S.length,_=[];O--;)_[O]=T.trak(S[O]);return T.box.apply(null,[T.types.moov,T.mvhd(S[0].timescale,S[0].duration)].concat(_).concat(T.mvex(S)))},T.mvex=function(S){for(var O=S.length,_=[];O--;)_[O]=T.trex(S[O]);return T.box.apply(null,[T.types.mvex].concat(_))},T.mvhd=function(S,O){O*=S;var _=Math.floor(O/(R+1)),E=Math.floor(O%(R+1)),A=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,S>>24&255,S>>16&255,S>>8&255,S&255,_>>24,_>>16&255,_>>8&255,_&255,E>>24,E>>16&255,E>>8&255,E&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return T.box(T.types.mvhd,A)},T.sdtp=function(S){var O=S.samples||[],_=new Uint8Array(4+O.length),E,A;for(E=0;E<O.length;E++)A=O[E].flags,_[E+4]=A.dependsOn<<4|A.isDependedOn<<2|A.hasRedundancy;return T.box(T.types.sdtp,_)},T.stbl=function(S){return T.box(T.types.stbl,T.stsd(S),T.box(T.types.stts,T.STTS),T.box(T.types.stsc,T.STSC),T.box(T.types.stsz,T.STSZ),T.box(T.types.stco,T.STCO))},T.avc1=function(S){var O=[],_=[],E,A,D;for(E=0;E<S.sps.length;E++)A=S.sps[E],D=A.byteLength,O.push(D>>>8&255),O.push(D&255),O=O.concat(Array.prototype.slice.call(A));for(E=0;E<S.pps.length;E++)A=S.pps[E],D=A.byteLength,_.push(D>>>8&255),_.push(D&255),_=_.concat(Array.prototype.slice.call(A));var x=T.box(T.types.avcC,new Uint8Array([1,O[3],O[4],O[5],255,224|S.sps.length].concat(O).concat([S.pps.length]).concat(_))),g=S.width,y=S.height,s=S.pixelRatio[0],e=S.pixelRatio[1];return T.box(T.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,g>>8&255,g&255,y>>8&255,y&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),x,T.box(T.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),T.box(T.types.pasp,new Uint8Array([s>>24,s>>16&255,s>>8&255,s&255,e>>24,e>>16&255,e>>8&255,e&255])))},T.esds=function(S){var O=S.config.length;return new Uint8Array([0,0,0,0,3,23+O,0,1,0,4,15+O,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([O]).concat(S.config).concat([6,1,2]))},T.mp4a=function(S){var O=S.samplerate;return T.box(T.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]),T.box(T.types.esds,T.esds(S)))},T.mp3=function(S){var O=S.samplerate;return T.box(T.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,S.channelCount,0,16,0,0,0,0,O>>8&255,O&255,0,0]))},T.stsd=function(S){return S.type==="audio"?S.segmentCodec==="mp3"&&S.codec==="mp3"?T.box(T.types.stsd,T.STSD,T.mp3(S)):T.box(T.types.stsd,T.STSD,T.mp4a(S)):T.box(T.types.stsd,T.STSD,T.avc1(S))},T.tkhd=function(S){var O=S.id,_=S.duration*S.timescale,E=S.width,A=S.height,D=Math.floor(_/(R+1)),x=Math.floor(_%(R+1));return T.box(T.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,O>>24&255,O>>16&255,O>>8&255,O&255,0,0,0,0,D>>24,D>>16&255,D>>8&255,D&255,x>>24,x>>16&255,x>>8&255,x&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,E>>8&255,E&255,0,0,A>>8&255,A&255,0,0]))},T.traf=function(S,O){var _=T.sdtp(S),E=S.id,A=Math.floor(O/(R+1)),D=Math.floor(O%(R+1));return T.box(T.types.traf,T.box(T.types.tfhd,new Uint8Array([0,0,0,0,E>>24,E>>16&255,E>>8&255,E&255])),T.box(T.types.tfdt,new Uint8Array([1,0,0,0,A>>24,A>>16&255,A>>8&255,A&255,D>>24,D>>16&255,D>>8&255,D&255])),T.trun(S,_.length+16+20+8+16+8+8),_)},T.trak=function(S){return S.duration=S.duration||4294967295,T.box(T.types.trak,T.tkhd(S),T.mdia(S))},T.trex=function(S){var O=S.id;return T.box(T.types.trex,new Uint8Array([0,0,0,0,O>>24,O>>16&255,O>>8&255,O&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},T.trun=function(S,O){var _=S.samples||[],E=_.length,A=12+16*E,D=new Uint8Array(A),x,g,y,s,e,o;for(O+=8+A,D.set([S.type==="video"?1:0,0,15,1,E>>>24&255,E>>>16&255,E>>>8&255,E&255,O>>>24&255,O>>>16&255,O>>>8&255,O&255],0),x=0;x<E;x++)g=_[x],y=g.duration,s=g.size,e=g.flags,o=g.cts,D.set([y>>>24&255,y>>>16&255,y>>>8&255,y&255,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e.isLeading<<2|e.dependsOn,e.isDependedOn<<6|e.hasRedundancy<<4|e.paddingValue<<1|e.isNonSync,e.degradPrio&240<<8,e.degradPrio&15,o>>>24&255,o>>>16&255,o>>>8&255,o&255],12+16*x);return T.box(T.types.trun,D)},T.initSegment=function(S){T.types||T.init();var O=T.moov(S),_=new Uint8Array(T.FTYP.byteLength+O.byteLength);return _.set(T.FTYP),_.set(O,T.FTYP.byteLength),_},T}();p.types=void 0,p.HDLR_TYPES=void 0,p.STTS=void 0,p.STSC=void 0,p.STCO=void 0,p.STSZ=void 0,p.VMHD=void 0,p.SMHD=void 0,p.STSD=void 0,p.FTYP=void 0,p.DINF=void 0,P.default=p},"./src/remux/mp4-remuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return e}),n.d(P,"normalizePts",function(){return o}),n.d(P,"flushTextTrackMetadataCueSamples",function(){return a}),n.d(P,"flushTextTrackUserdataCueSamples",function(){return i});var R=n("./src/polyfills/number.ts"),p=n("./src/remux/aac-helper.ts"),T=n("./src/remux/mp4-generator.ts"),I=n("./src/events.ts"),S=n("./src/errors.ts"),O=n("./src/utils/logger.ts"),_=n("./src/types/loader.ts"),E=n("./src/utils/timescale-conversion.ts");function A(){return A=Object.assign?Object.assign.bind():function(c){for(var r=1;r<arguments.length;r++){var h=arguments[r];for(var d in h)Object.prototype.hasOwnProperty.call(h,d)&&(c[d]=h[d])}return c},A.apply(this,arguments)}var D=10*1e3,x=1024,g=1152,y=null,s=null,e=function(){function c(h,d,l,v){if(v===void 0&&(v=""),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=h,this.config=d,this.typeSupported=l,this.ISGenerated=!1,y===null){var m=navigator.userAgent||"",L=m.match(/Chrome\/(\d+)/i);y=L?parseInt(L[1]):0}if(s===null){var b=navigator.userAgent.match(/Safari\/(\d+)/i);s=b?parseInt(b[1]):0}}var r=c.prototype;return r.destroy=function(){},r.resetTimeStamp=function(d){O.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=d},r.resetNextTimestamp=function(){O.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},r.resetInitSegment=function(){O.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},r.getVideoStartPts=function(d){var l=!1,v=d.reduce(function(m,L){var b=L.pts-m;return b<-4294967296?(l=!0,o(m,L.pts)):b>0?m:L.pts},d[0].pts);return l&&O.logger.debug("PTS rollover detected"),v},r.remux=function(d,l,v,m,L,b,M,F){var w,C,U,k,j,N,W=L,Y=L,K=d.pid>-1,H=l.pid>-1,z=l.samples.length,$=d.samples.length>0,X=M&&z>0||z>1,J=(!K||$)&&(!H||X)||this.ISGenerated||M;if(J){this.ISGenerated||(U=this.generateIS(d,l,L));var te=this.isVideoContiguous,Q=-1,ae;if(X&&(Q=f(l.samples),!te&&this.config.forceKeyFrameOnDiscontinuity))if(N=!0,Q>0){O.logger.warn("[mp4-remuxer]: Dropped "+Q+" out of "+z+" video samples due to a missing keyframe");var se=this.getVideoStartPts(l.samples);l.samples=l.samples.slice(Q),l.dropped+=Q,Y+=(l.samples[0].pts-se)/l.inputTimeScale,ae=Y}else Q===-1&&(O.logger.warn("[mp4-remuxer]: No keyframe found out of "+z+" video samples"),N=!1);if(this.ISGenerated){if($&&X){var re=this.getVideoStartPts(l.samples),ee=o(d.samples[0].pts,re)-re,Z=ee/l.inputTimeScale;W+=Math.max(0,Z),Y+=Math.max(0,-Z)}if($){if(d.samplerate||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),U=this.generateIS(d,l,L)),C=this.remuxAudio(d,W,this.isAudioContiguous,b,H||X||F===_.PlaylistLevelType.AUDIO?Y:void 0),X){var q=C?C.endPTS-C.startPTS:0;l.inputTimeScale||(O.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),U=this.generateIS(d,l,L)),w=this.remuxVideo(l,Y,te,q)}}else X&&(w=this.remuxVideo(l,Y,te,0));w&&(w.firstKeyFrame=Q,w.independent=Q!==-1,w.firstKeyFramePTS=ae)}}return this.ISGenerated&&(v.samples.length&&(j=a(v,L,this._initPTS,this._initDTS)),m.samples.length&&(k=i(m,L,this._initPTS))),{audio:C,video:w,initSegment:U,independent:N,text:k,id3:j}},r.generateIS=function(d,l,v){var m=d.samples,L=l.samples,b=this.typeSupported,M={},F=!Object(R.isFiniteNumber)(this._initPTS),w="audio/mp4",C,U,k;if(F&&(C=U=1/0),d.config&&m.length){switch(d.timescale=d.samplerate,d.segmentCodec){case"mp3":b.mpeg?(w="audio/mpeg",d.codec=""):b.mp3&&(d.codec="mp3");break}M.audio={id:"audio",container:w,codec:d.codec,initSegment:d.segmentCodec==="mp3"&&b.mpeg?new Uint8Array(0):T.default.initSegment([d]),metadata:{channelCount:d.channelCount}},F&&(k=d.inputTimeScale,C=U=m[0].pts-Math.round(k*v))}if(l.sps&&l.pps&&L.length&&(l.timescale=l.inputTimeScale,M.video={id:"main",container:"video/mp4",codec:l.codec,initSegment:T.default.initSegment([l]),metadata:{width:l.width,height:l.height}},F)){k=l.inputTimeScale;var j=this.getVideoStartPts(L),N=Math.round(k*v);U=Math.min(U,o(L[0].dts,j)-N),C=Math.min(C,j-N)}if(Object.keys(M).length)return this.ISGenerated=!0,F&&(this._initPTS=C,this._initDTS=U),{tracks:M,initPTS:C,timescale:k}},r.remuxVideo=function(d,l,v,m){var L=d.inputTimeScale,b=d.samples,M=[],F=b.length,w=this._initPTS,C=this.nextAvcDts,U=8,k=this.videoSampleDuration,j,N,W=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,K=!1;if(!v||C===null){var H=l*L,z=b[0].pts-o(b[0].dts,b[0].pts);C=H-z}for(var $=0;$<F;$++){var X=b[$];X.pts=o(X.pts-w,C),X.dts=o(X.dts-w,C),X.dts<b[$>0?$-1:$].dts&&(K=!0)}K&&b.sort(function(We,it){var nt=We.dts-it.dts,mt=We.pts-it.pts;return nt||mt}),j=b[0].dts,N=b[b.length-1].dts;var J=N-j,te=J?Math.round(J/(F-1)):k||d.inputTimeScale/30;if(v){var Q=j-C,ae=Q>te,se=Q<-1;if(ae||se){ae?O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms ("+Q+"dts) hole between fragments detected, filling it"):O.logger.warn("AVC: "+Object(E.toMsFromMpegTsClock)(-Q,!0)+" ms ("+Q+"dts) overlapping between fragments detected"),j=C;var re=b[0].pts-Q;b[0].dts=j,b[0].pts=re,O.logger.log("Video: First PTS/DTS adjusted: "+Object(E.toMsFromMpegTsClock)(re,!0)+"/"+Object(E.toMsFromMpegTsClock)(j,!0)+", delta: "+Object(E.toMsFromMpegTsClock)(Q,!0)+" ms")}}j=Math.max(0,j);for(var ee=0,Z=0,q=0;q<F;q++){for(var fe=b[q],ge=fe.units,ie=ge.length,me=0,ye=0;ye<ie;ye++)me+=ge[ye].data.length;Z+=me,ee+=ie,fe.length=me,fe.dts=Math.max(fe.dts,j),W=Math.min(fe.pts,W),Y=Math.max(fe.pts,Y)}N=b[F-1].dts;var Te=Z+4*ee+8,oe;try{oe=new Uint8Array(Te)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:Te,reason:"fail allocating video mdat "+Te});return}var de=new DataView(oe.buffer);de.setUint32(0,Te),oe.set(T.default.types.mdat,4);for(var Se=!1,Ee=Number.POSITIVE_INFINITY,Ae=Number.POSITIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY,Me=Number.NEGATIVE_INFINITY,De=0;De<F;De++){for(var xe=b[De],G=xe.units,V=0,ue=0,he=G.length;ue<he;ue++){var pe=G[ue],_e=pe.data,le=pe.data.byteLength;de.setUint32(U,le),U+=4,oe.set(_e,U),U+=le,V+=4+le}var Re=void 0;if(De<F-1)k=b[De+1].dts-xe.dts,Re=b[De+1].pts-xe.pts;else{var Le=this.config,Ie=De>0?xe.dts-b[De-1].dts:te;if(Re=De>0?xe.pts-b[De-1].pts:te,Le.stretchShortVideoTrack&&this.nextAudioPts!==null){var je=Math.floor(Le.maxBufferHole*L),ke=(m?W+m*L:this.nextAudioPts)-xe.pts;ke>je?(k=ke-Ie,k<0?k=Ie:Se=!0,O.logger.log("[mp4-remuxer]: It is approximately "+ke/90+" ms to the next segment; using duration "+k/90+" ms for the last video frame.")):k=Ie}else k=Ie}var Be=Math.round(xe.pts-xe.dts);Ee=Math.min(Ee,k),Oe=Math.max(Oe,k),Ae=Math.min(Ae,Re),Me=Math.max(Me,Re),M.push(new t(xe.key,k,V,Be))}if(M.length){if(y){if(y<70){var et=M[0].flags;et.dependsOn=2,et.isNonSync=0}}else if(s&&Me-Ae<Oe-Ee&&te/Oe<.025&&M[0].cts===0){O.logger.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var He=j,Ce=0,Ke=M.length;Ce<Ke;Ce++){var Ve=He+M[Ce].duration,Ye=He+M[Ce].cts;if(Ce<Ke-1){var tt=Ve+M[Ce+1].cts;M[Ce].duration=tt-Ye}else M[Ce].duration=Ce?M[Ce-1].duration:te;M[Ce].cts=0,He=Ve}}}console.assert(k!==null,"mp4SampleDuration must be computed"),k=Se||!k?te:k,this.nextAvcDts=C=N+k,this.videoSampleDuration=k,this.isVideoContiguous=!0;var rt=T.default.moof(d.sequenceNumber++,j,A({},d,{samples:M})),vt="video",gt={data1:rt,data2:oe,startPTS:W/L,endPTS:(Y+k)/L,startDTS:j/L,endDTS:C/L,type:vt,hasAudio:!1,hasVideo:!0,nb:M.length,dropped:d.dropped};return d.samples=[],d.dropped=0,console.assert(oe.length,"MDAT length must not be zero"),gt},r.remuxAudio=function(d,l,v,m,L){var b=d.inputTimeScale,M=d.samplerate?d.samplerate:b,F=b/M,w=d.segmentCodec==="aac"?x:g,C=w*F,U=this._initPTS,k=d.segmentCodec==="mp3"&&this.typeSupported.mpeg,j=[],N=L!==void 0,W=d.samples,Y=k?0:8,K=this.nextAudioPts||-1,H=l*b;if(this.isAudioContiguous=v=v||W.length&&K>0&&(m&&Math.abs(H-K)<9e3||Math.abs(o(W[0].pts-U,H)-K)<20*C),W.forEach(function(pe){pe.pts=o(pe.pts-U,H)}),!v||K<0){if(W=W.filter(function(pe){return pe.pts>=0}),!W.length)return;L===0?K=0:m&&!N?K=Math.max(0,H):K=W[0].pts}if(d.segmentCodec==="aac")for(var z=this.config.maxAudioFramesDrift,$=0,X=K;$<W.length;$++){var J=W[$],te=J.pts,Q=te-X,ae=Math.abs(1e3*Q/b);if(Q<=-z*C&&N)$===0&&(O.logger.warn("Audio frame @ "+(te/b).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*Q/b)+" ms."),this.nextAudioPts=K=X=te);else if(Q>=z*C&&ae<D&&N){var se=Math.round(Q/C);X=te-se*C,X<0&&(se--,X+=C),$===0&&(this.nextAudioPts=K=X),O.logger.warn("[mp4-remuxer]: Injecting "+se+" audio frame @ "+(X/b).toFixed(3)+"s due to "+Math.round(1e3*Q/b)+" ms gap.");for(var re=0;re<se;re++){var ee=Math.max(X,0),Z=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);Z||(O.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Z=J.unit.subarray()),W.splice($,0,{unit:Z,pts:ee}),X+=C,$++}}J.pts=X,X+=C}for(var q=null,fe=null,ge,ie=0,me=W.length;me--;)ie+=W[me].unit.byteLength;for(var ye=0,Te=W.length;ye<Te;ye++){var oe=W[ye],de=oe.unit,Se=oe.pts;if(fe!==null){var Ee=j[ye-1];Ee.duration=Math.round((Se-fe)/F)}else if(v&&d.segmentCodec==="aac"&&(Se=K),q=Se,ie>0){ie+=Y;try{ge=new Uint8Array(ie)}catch{this.observer.emit(I.Events.ERROR,I.Events.ERROR,{type:S.ErrorTypes.MUX_ERROR,details:S.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:ie,reason:"fail allocating audio mdat "+ie});return}if(!k){var Ae=new DataView(ge.buffer);Ae.setUint32(0,ie),ge.set(T.default.types.mdat,4)}}else return;ge.set(de,Y);var Oe=de.byteLength;Y+=Oe,j.push(new t(!0,w,Oe,0)),fe=Se}var Me=j.length;if(!!Me){var De=j[j.length-1];this.nextAudioPts=K=fe+F*De.duration;var xe=k?new Uint8Array(0):T.default.moof(d.sequenceNumber++,q/F,A({},d,{samples:j}));d.samples=[];var G=q/b,V=K/b,ue="audio",he={data1:xe,data2:ge,startPTS:G,endPTS:V,startDTS:G,endDTS:V,type:ue,hasAudio:!0,hasVideo:!1,nb:Me};return this.isAudioContiguous=!0,console.assert(ge.length,"MDAT length must not be zero"),he}},r.remuxEmptyAudio=function(d,l,v,m){var L=d.inputTimeScale,b=d.samplerate?d.samplerate:L,M=L/b,F=this.nextAudioPts,w=(F!==null?F:m.startDTS*L)+this._initDTS,C=m.endDTS*L+this._initDTS,U=M*x,k=Math.ceil((C-w)/U),j=p.default.getSilentFrame(d.manifestCodec||d.codec,d.channelCount);if(O.logger.warn("[mp4-remuxer]: remux empty Audio"),!j){O.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}for(var N=[],W=0;W<k;W++){var Y=w+W*U;N.push({unit:j,pts:Y,dts:Y})}return d.samples=N,this.remuxAudio(d,l,v,!1)},c}();function o(c,r){var h;if(r===null)return c;for(r<c?h=-8589934592:h=8589934592;Math.abs(c-r)>4294967296;)c+=h;return c}function f(c){for(var r=0;r<c.length;r++)if(c[r].key)return r;return-1}function a(c,r,h,d){var l=c.samples.length;if(!!l){for(var v=c.inputTimeScale,m=0;m<l;m++){var L=c.samples[m];L.pts=o(L.pts-h,r*v)/v,L.dts=o(L.dts-d,r*v)/v}var b=c.samples;return c.samples=[],{samples:b}}}function i(c,r,h){var d=c.samples.length;if(!!d){for(var l=c.inputTimeScale,v=0;v<d;v++){var m=c.samples[v];m.pts=o(m.pts-h,r*l)/l}c.samples.sort(function(b,M){return b.pts-M.pts});var L=c.samples;return c.samples=[],{samples:L}}}var t=function(r,h,d,l){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=h,this.size=d,this.cts=l,this.flags=new u(r)},u=function(r){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=r?2:1,this.isNonSync=r?0:1}},"./src/remux/passthrough-remuxer.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/polyfills/number.ts"),p=n("./src/remux/mp4-remuxer.ts"),T=n("./src/utils/mp4-tools.ts"),I=n("./src/loader/fragment.ts"),S=n("./src/utils/logger.ts"),O=function(){function E(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndTime=null}var A=E.prototype;return A.destroy=function(){},A.resetTimeStamp=function(x){this.initPTS=x,this.lastEndTime=null},A.resetNextTimestamp=function(){this.lastEndTime=null},A.resetInitSegment=function(x,g,y){this.audioCodec=g,this.videoCodec=y,this.generateInitSegment(x),this.emitInitSegment=!0},A.generateInitSegment=function(x){var g=this.audioCodec,y=this.videoCodec;if(!x||!x.byteLength){this.initTracks=void 0,this.initData=void 0;return}var s=this.initData=Object(T.parseInitSegment)(x);g||(g=_(s.audio,I.ElementaryStreamTypes.AUDIO)),y||(y=_(s.video,I.ElementaryStreamTypes.VIDEO));var e={};s.audio&&s.video?e.audiovideo={container:"video/mp4",codec:g+","+y,initSegment:x,id:"main"}:s.audio?e.audio={container:"audio/mp4",codec:g,initSegment:x,id:"audio"}:s.video?e.video={container:"video/mp4",codec:y,initSegment:x,id:"main"}:S.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=e},A.remux=function(x,g,y,s,e){var o,f=this.initPTS,a=this.lastEndTime,i={audio:void 0,video:void 0,text:s,id3:y,initSegment:void 0};Object(R.isFiniteNumber)(a)||(a=this.lastEndTime=e||0);var t=g.samples;if(!t||!t.length)return i;var u={initPTS:void 0,timescale:1},c=this.initData;if((!c||!c.length)&&(this.generateInitSegment(t),c=this.initData),!c||!c.length)return S.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),i;this.emitInitSegment&&(u.tracks=this.initTracks,this.emitInitSegment=!1);var r=Object(T.getStartDTS)(c,t);Object(R.isFiniteNumber)(f)||(this.initPTS=u.initPTS=f=r-e);var h=Object(T.getDuration)(t,c),d=x?r-f:a,l=d+h;Object(T.offsetStartDTS)(c,t,f),h>0?this.lastEndTime=l:(S.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var v=!!c.audio,m=!!c.video,L="";v&&(L+="audio"),m&&(L+="video");var b={data1:t,startPTS:d,startDTS:d,endPTS:l,endDTS:l,type:L,hasAudio:v,hasVideo:m,nb:1,dropped:0};i.audio=b.type==="audio"?b:void 0,i.video=b.type!=="audio"?b:void 0,i.initSegment=u;var M=(o=this.initPTS)!=null?o:0;return i.id3=Object(p.flushTextTrackMetadataCueSamples)(y,e,M,M),s.samples.length&&(i.text=Object(p.flushTextTrackUserdataCueSamples)(s,e,M)),i},E}();function _(E,A){var D=E==null?void 0:E.codec;return D&&D.length>4?D:D==="hvc1"||D==="hev1"?"hvc1.1.c.L120.90":D==="av01"?"av01.0.04M.08":D==="avc1"||A===I.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}P.default=O},"./src/task-loop.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var T=p.prototype;return T.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},T.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},T.onHandlerDestroyed=function(){},T.hasInterval=function(){return!!this._tickInterval},T.hasNextTick=function(){return!!this._tickTimer},T.setInterval=function(S){return this._tickInterval?!1:(this._tickInterval=self.setInterval(this._boundTick,S),!0)},T.clearInterval=function(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1},T.clearNextTick=function(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1},T.tick=function(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},T.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},T.doTick=function(){},p}()},"./src/types/cmcd.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"CMCDVersion",function(){return R}),n.d(P,"CMCDObjectType",function(){return p}),n.d(P,"CMCDStreamingFormat",function(){return T}),n.d(P,"CMCDStreamType",function(){return I});var R=1,p;(function(S){S.MANIFEST="m",S.AUDIO="a",S.VIDEO="v",S.MUXED="av",S.INIT="i",S.CAPTION="c",S.TIMED_TEXT="tt",S.KEY="k",S.OTHER="o"})(p||(p={}));var T;(function(S){S.DASH="d",S.HLS="h",S.SMOOTH="s",S.OTHER="o"})(T||(T={}));var I;(function(S){S.VOD="v",S.LIVE="l"})(I||(I={}))},"./src/types/demuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"MetadataSchema",function(){return R});var R;(function(p){p.audioId3="org.id3",p.dateRange="com.apple.quicktime.HLS",p.emsg="https://aomedia.org/emsg/ID3"})(R||(R={}))},"./src/types/level.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"HlsSkip",function(){return T}),n.d(P,"getSkipValue",function(){return I}),n.d(P,"HlsUrlParameters",function(){return S}),n.d(P,"Level",function(){return O});function R(_,E){for(var A=0;A<E.length;A++){var D=E[A];D.enumerable=D.enumerable||!1,D.configurable=!0,"value"in D&&(D.writable=!0),Object.defineProperty(_,D.key,D)}}function p(_,E,A){return E&&R(_.prototype,E),A&&R(_,A),Object.defineProperty(_,"prototype",{writable:!1}),_}var T;(function(_){_.No="",_.Yes="YES",_.v2="v2"})(T||(T={}));function I(_,E){var A=_.canSkipUntil,D=_.canSkipDateRanges,x=_.endSN,g=E!==void 0?E-x:0;return A&&g<A?D?T.v2:T.Yes:T.No}var S=function(){function _(A,D,x){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=A,this.part=D,this.skip=x}var E=_.prototype;return E.addDirectives=function(D){var x=new self.URL(D);return this.msn!==void 0&&x.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&x.searchParams.set("_HLS_part",this.part.toString()),this.skip&&x.searchParams.set("_HLS_skip",this.skip),x.toString()},_}(),O=function(){function _(E){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[E.url],this.attrs=E.attrs,this.bitrate=E.bitrate,E.details&&(this.details=E.details),this.id=E.id||0,this.name=E.name,this.width=E.width||0,this.height=E.height||0,this.audioCodec=E.audioCodec,this.videoCodec=E.videoCodec,this.unknownCodecs=E.unknownCodecs,this.codecSet=[E.videoCodec,E.audioCodec].filter(function(A){return A}).join(",").replace(/\.[^.,]+/g,"")}return p(_,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(A){var D=A%this.url.length;this._urlId!==D&&(this.details=void 0,this._urlId=D)}}]),_}()},"./src/types/loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"PlaylistContextType",function(){return R}),n.d(P,"PlaylistLevelType",function(){return p});var R;(function(T){T.MANIFEST="manifest",T.LEVEL="level",T.AUDIO_TRACK="audioTrack",T.SUBTITLE_TRACK="subtitleTrack"})(R||(R={}));var p;(function(T){T.MAIN="main",T.AUDIO="audio",T.SUBTITLE="subtitle"})(p||(p={}))},"./src/types/transmuxer.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"ChunkMetadata",function(){return R});var R=function(I,S,O,_,E,A){_===void 0&&(_=0),E===void 0&&(E=-1),A===void 0&&(A=!1),this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=p(),this.buffering={audio:p(),video:p(),audiovideo:p()},this.level=I,this.sn=S,this.id=O,this.size=_,this.part=E,this.partial=A};function p(){return{start:0,executeStart:0,executeEnd:0,end:0}}},"./src/utils/attr-list.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"AttrList",function(){return T});var R=/^(\d+)x(\d+)$/,p=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,T=function(){function I(O){typeof O=="string"&&(O=I.parseAttrList(O));for(var _ in O)O.hasOwnProperty(_)&&(this[_]=O[_])}var S=I.prototype;return S.decimalInteger=function(_){var E=parseInt(this[_],10);return E>Number.MAX_SAFE_INTEGER?1/0:E},S.hexadecimalInteger=function(_){if(this[_]){var E=(this[_]||"0x").slice(2);E=(E.length&1?"0":"")+E;for(var A=new Uint8Array(E.length/2),D=0;D<E.length/2;D++)A[D]=parseInt(E.slice(D*2,D*2+2),16);return A}else return null},S.hexadecimalIntegerAsNumber=function(_){var E=parseInt(this[_],16);return E>Number.MAX_SAFE_INTEGER?1/0:E},S.decimalFloatingPoint=function(_){return parseFloat(this[_])},S.optionalFloat=function(_,E){var A=this[_];return A?parseFloat(A):E},S.enumeratedString=function(_){return this[_]},S.bool=function(_){return this[_]==="YES"},S.decimalResolution=function(_){var E=R.exec(this[_]);if(E!==null)return{width:parseInt(E[1],10),height:parseInt(E[2],10)}},I.parseAttrList=function(_){var E,A={},D='"';for(p.lastIndex=0;(E=p.exec(_))!==null;){var x=E[2];x.indexOf(D)===0&&x.lastIndexOf(D)===x.length-1&&(x=x.slice(1,-1)),A[E[1]]=x}return A},I}()},"./src/utils/binary-search.ts":function(B,P,n){"use strict";n.r(P);var R={search:function(T,I){for(var S=0,O=T.length-1,_=null,E=null;S<=O;){_=(S+O)/2|0,E=T[_];var A=I(E);if(A>0)S=_+1;else if(A<0)O=_-1;else return E}return null}};P.default=R},"./src/utils/buffer-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"BufferHelper",function(){return T});var R=n("./src/utils/logger.ts"),p={length:0,start:function(){return 0},end:function(){return 0}},T=function(){function I(){}return I.isBuffered=function(O,_){try{if(O){for(var E=I.getBuffered(O),A=0;A<E.length;A++)if(_>=E.start(A)&&_<=E.end(A))return!0}}catch{}return!1},I.bufferInfo=function(O,_,E){try{if(O){var A=I.getBuffered(O),D=[],x;for(x=0;x<A.length;x++)D.push({start:A.start(x),end:A.end(x)});return this.bufferedInfo(D,_,E)}}catch{}return{len:0,start:_,end:_,nextStart:void 0}},I.bufferedInfo=function(O,_,E){_=Math.max(0,_),O.sort(function(t,u){var c=t.start-u.start;return c||u.end-t.end});var A=[];if(E)for(var D=0;D<O.length;D++){var x=A.length;if(x){var g=A[x-1].end;O[D].start-g<E?O[D].end>g&&(A[x-1].end=O[D].end):A.push(O[D])}else A.push(O[D])}else A=O;for(var y=0,s,e=_,o=_,f=0;f<A.length;f++){var a=A[f].start,i=A[f].end;if(_+E>=a&&_<i)e=a,o=i,y=o-_;else if(_+E<a){s=a;break}}return{len:y,start:e||0,end:o||0,nextStart:s}},I.getBuffered=function(O){try{return O.buffered}catch(_){return R.logger.log("failed to get media.buffered",_),p}},I}()},"./src/utils/cea-608-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"Row",function(){return o}),n.d(P,"CaptionScreen",function(){return f});var R=n("./src/utils/logger.ts"),p={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},T=function(h){var d=h;return p.hasOwnProperty(h)&&(d=p[h]),String.fromCharCode(d)},I=15,S=100,O={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_={17:2,18:4,21:6,22:8,23:10,19:13,20:15},E={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},A={25:2,26:4,29:6,30:8,31:10,27:13,28:15},D=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],x;(function(r){r[r.ERROR=0]="ERROR",r[r.TEXT=1]="TEXT",r[r.WARNING=2]="WARNING",r[r.INFO=2]="INFO",r[r.DEBUG=3]="DEBUG",r[r.DATA=3]="DATA"})(x||(x={}));var g=function(){function r(){this.time=null,this.verboseLevel=x.ERROR}var h=r.prototype;return h.log=function(l,v){this.verboseLevel>=l&&R.logger.log(this.time+" ["+l+"] "+v)},r}(),y=function(h){for(var d=[],l=0;l<h.length;l++)d.push(h[l].toString(16));return d},s=function(){function r(d,l,v,m,L){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=d||"white",this.underline=l||!1,this.italics=v||!1,this.background=m||"black",this.flash=L||!1}var h=r.prototype;return h.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},h.setStyles=function(l){for(var v=["foreground","underline","italics","background","flash"],m=0;m<v.length;m++){var L=v[m];l.hasOwnProperty(L)&&(this[L]=l[L])}},h.isDefault=function(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash},h.equals=function(l){return this.foreground===l.foreground&&this.underline===l.underline&&this.italics===l.italics&&this.background===l.background&&this.flash===l.flash},h.copy=function(l){this.foreground=l.foreground,this.underline=l.underline,this.italics=l.italics,this.background=l.background,this.flash=l.flash},h.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},r}(),e=function(){function r(d,l,v,m,L,b){this.uchar=void 0,this.penState=void 0,this.uchar=d||" ",this.penState=new s(l,v,m,L,b)}var h=r.prototype;return h.reset=function(){this.uchar=" ",this.penState.reset()},h.setChar=function(l,v){this.uchar=l,this.penState.copy(v)},h.setPenState=function(l){this.penState.copy(l)},h.equals=function(l){return this.uchar===l.uchar&&this.penState.equals(l.penState)},h.copy=function(l){this.uchar=l.uchar,this.penState.copy(l.penState)},h.isEmpty=function(){return this.uchar===" "&&this.penState.isDefault()},r}(),o=function(){function r(d){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var l=0;l<S;l++)this.chars.push(new e);this.logger=d,this.pos=0,this.currPenState=new s}var h=r.prototype;return h.equals=function(l){for(var v=!0,m=0;m<S;m++)if(!this.chars[m].equals(l.chars[m])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<S;v++)this.chars[v].copy(l.chars[v])},h.isEmpty=function(){for(var l=!0,v=0;v<S;v++)if(!this.chars[v].isEmpty()){l=!1;break}return l},h.setCursor=function(l){this.pos!==l&&(this.pos=l),this.pos<0?(this.logger.log(x.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>S&&(this.logger.log(x.DEBUG,"Too large cursor position "+this.pos),this.pos=S)},h.moveCursor=function(l){var v=this.pos+l;if(l>1)for(var m=this.pos+1;m<v+1;m++)this.chars[m].setPenState(this.currPenState);this.setCursor(v)},h.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},h.insertChar=function(l){l>=144&&this.backSpace();var v=T(l);if(this.pos>=S){this.logger.log(x.ERROR,"Cannot insert "+l.toString(16)+" ("+v+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(v,this.currPenState),this.moveCursor(1)},h.clearFromPos=function(l){var v;for(v=l;v<S;v++)this.chars[v].reset()},h.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},h.clearToEndOfRow=function(){this.clearFromPos(this.pos)},h.getTextString=function(){for(var l=[],v=!0,m=0;m<S;m++){var L=this.chars[m].uchar;L!==" "&&(v=!1),l.push(L)}return v?"":l.join("")},h.setPenStyles=function(l){this.currPenState.setStyles(l);var v=this.chars[this.pos];v.setPenState(this.currPenState)},r}(),f=function(){function r(d){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var l=0;l<I;l++)this.rows.push(new o(d));this.logger=d,this.currRow=I-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var h=r.prototype;return h.reset=function(){for(var l=0;l<I;l++)this.rows[l].clear();this.currRow=I-1},h.equals=function(l){for(var v=!0,m=0;m<I;m++)if(!this.rows[m].equals(l.rows[m])){v=!1;break}return v},h.copy=function(l){for(var v=0;v<I;v++)this.rows[v].copy(l.rows[v])},h.isEmpty=function(){for(var l=!0,v=0;v<I;v++)if(!this.rows[v].isEmpty()){l=!1;break}return l},h.backSpace=function(){var l=this.rows[this.currRow];l.backSpace()},h.clearToEndOfRow=function(){var l=this.rows[this.currRow];l.clearToEndOfRow()},h.insertChar=function(l){var v=this.rows[this.currRow];v.insertChar(l)},h.setPen=function(l){var v=this.rows[this.currRow];v.setPenStyles(l)},h.moveCursor=function(l){var v=this.rows[this.currRow];v.moveCursor(l)},h.setCursor=function(l){this.logger.log(x.INFO,"setCursor: "+l);var v=this.rows[this.currRow];v.setCursor(l)},h.setPAC=function(l){this.logger.log(x.INFO,"pacData = "+JSON.stringify(l));var v=l.row-1;if(this.nrRollUpRows&&v<this.nrRollUpRows-1&&(v=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==v){for(var m=0;m<I;m++)this.rows[m].clear();var L=this.currRow+1-this.nrRollUpRows,b=this.lastOutputScreen;if(b){var M=b.rows[L].cueStartTime,F=this.logger.time;if(M&&F!==null&&M<F)for(var w=0;w<this.nrRollUpRows;w++)this.rows[v-this.nrRollUpRows+w+1].copy(b.rows[L+w])}}this.currRow=v;var C=this.rows[this.currRow];if(l.indent!==null){var U=l.indent,k=Math.max(U-1,0);C.setCursor(l.indent),l.color=C.chars[k].penState.foreground}var j={foreground:l.color,underline:l.underline,italics:l.italics,background:"black",flash:!1};this.setPen(j)},h.setBkgData=function(l){this.logger.log(x.INFO,"bkgData = "+JSON.stringify(l)),this.backSpace(),this.setPen(l),this.insertChar(32)},h.setRollUpRows=function(l){this.nrRollUpRows=l},h.rollUp=function(){if(this.nrRollUpRows===null){this.logger.log(x.DEBUG,"roll_up but nrRollUpRows not set yet");return}this.logger.log(x.TEXT,this.getDisplayText());var l=this.currRow+1-this.nrRollUpRows,v=this.rows.splice(l,1)[0];v.clear(),this.rows.splice(this.currRow,0,v),this.logger.log(x.INFO,"Rolling up")},h.getDisplayText=function(l){l=l||!1;for(var v=[],m="",L=-1,b=0;b<I;b++){var M=this.rows[b].getTextString();M&&(L=b+1,l?v.push("Row "+L+": '"+M+"'"):v.push(M.trim()))}return v.length>0&&(l?m="["+v.join(" | ")+"]":m=v.join(`
|
|
19
|
+
`)),m},h.getTextAndFormat=function(){return this.rows},r}(),a=function(){function r(d,l,v){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=d,this.outputFilter=l,this.mode=null,this.verbose=0,this.displayedMemory=new f(v),this.nonDisplayedMemory=new f(v),this.lastOutputScreen=new f(v),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=v}var h=r.prototype;return h.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[I-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},h.getHandler=function(){return this.outputFilter},h.setHandler=function(l){this.outputFilter=l},h.setPAC=function(l){this.writeScreen.setPAC(l)},h.setBkgData=function(l){this.writeScreen.setBkgData(l)},h.setMode=function(l){l!==this.mode&&(this.mode=l,this.logger.log(x.INFO,"MODE="+l),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=l)},h.insertChars=function(l){for(var v=0;v<l.length;v++)this.writeScreen.insertChar(l[v]);var m=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(x.INFO,m+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(x.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},h.ccRCL=function(){this.logger.log(x.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},h.ccBS=function(){this.logger.log(x.INFO,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},h.ccAOF=function(){},h.ccAON=function(){},h.ccDER=function(){this.logger.log(x.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},h.ccRU=function(l){this.logger.log(x.INFO,"RU("+l+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(l)},h.ccFON=function(){this.logger.log(x.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},h.ccRDC=function(){this.logger.log(x.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},h.ccTR=function(){this.logger.log(x.INFO,"TR"),this.setMode("MODE_TEXT")},h.ccRTD=function(){this.logger.log(x.INFO,"RTD"),this.setMode("MODE_TEXT")},h.ccEDM=function(){this.logger.log(x.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},h.ccCR=function(){this.logger.log(x.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},h.ccENM=function(){this.logger.log(x.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},h.ccEOC=function(){if(this.logger.log(x.INFO,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){var l=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=l,this.writeScreen=this.nonDisplayedMemory,this.logger.log(x.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},h.ccTO=function(l){this.logger.log(x.INFO,"TO("+l+") - Tab Offset"),this.writeScreen.moveCursor(l)},h.ccMIDROW=function(l){var v={flash:!1};if(v.underline=l%2===1,v.italics=l>=46,v.italics)v.foreground="white";else{var m=Math.floor(l/2)-16,L=["white","green","blue","cyan","red","yellow","magenta"];v.foreground=L[m]}this.logger.log(x.INFO,"MIDROW: "+JSON.stringify(v)),this.writeScreen.setPen(v)},h.outputDataUpdate=function(l){l===void 0&&(l=!1);var v=this.logger.time;v!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=v:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,v,this.lastOutputScreen),l&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:v),this.lastOutputScreen.copy(this.displayedMemory))},h.cueSplitAtTime=function(l){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,l,this.displayedMemory),this.cueStartTime=l))},r}(),i=function(){function r(d,l,v){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var m=new g;this.channels=[null,new a(d,l,m),new a(d+1,v,m)],this.cmdHistory=c(),this.logger=m}var h=r.prototype;return h.getHandler=function(l){return this.channels[l].getHandler()},h.setHandler=function(l,v){this.channels[l].setHandler(v)},h.addData=function(l,v){var m,L,b,M=!1;this.logger.time=l;for(var F=0;F<v.length;F+=2)if(L=v[F]&127,b=v[F+1]&127,!(L===0&&b===0)){if(this.logger.log(x.DATA,"["+y([v[F],v[F+1]])+"] -> ("+y([L,b])+")"),m=this.parseCmd(L,b),m||(m=this.parseMidrow(L,b)),m||(m=this.parsePAC(L,b)),m||(m=this.parseBackgroundAttributes(L,b)),!m&&(M=this.parseChars(L,b),M)){var w=this.currentChannel;if(w&&w>0){var C=this.channels[w];C.insertChars(M)}else this.logger.log(x.WARNING,"No channel found yet. TEXT-MODE?")}!m&&!M&&this.logger.log(x.WARNING,"Couldn't parse cleaned data "+y([L,b])+" orig: "+y([v[F],v[F+1]]))}},h.parseCmd=function(l,v){var m=this.cmdHistory,L=(l===20||l===28||l===21||l===29)&&v>=32&&v<=47,b=(l===23||l===31)&&v>=33&&v<=35;if(!(L||b))return!1;if(u(l,v,m))return t(null,null,m),this.logger.log(x.DEBUG,"Repeated command ("+y([l,v])+") is dropped"),!0;var M=l===20||l===21||l===23?1:2,F=this.channels[M];return l===20||l===21||l===28||l===29?v===32?F.ccRCL():v===33?F.ccBS():v===34?F.ccAOF():v===35?F.ccAON():v===36?F.ccDER():v===37?F.ccRU(2):v===38?F.ccRU(3):v===39?F.ccRU(4):v===40?F.ccFON():v===41?F.ccRDC():v===42?F.ccTR():v===43?F.ccRTD():v===44?F.ccEDM():v===45?F.ccCR():v===46?F.ccENM():v===47&&F.ccEOC():F.ccTO(v-32),t(l,v,m),this.currentChannel=M,!0},h.parseMidrow=function(l,v){var m=0;if((l===17||l===25)&&v>=32&&v<=47){if(l===17?m=1:m=2,m!==this.currentChannel)return this.logger.log(x.ERROR,"Mismatch channel in midrow parsing"),!1;var L=this.channels[m];return L?(L.ccMIDROW(v),this.logger.log(x.DEBUG,"MIDROW ("+y([l,v])+")"),!0):!1}return!1},h.parsePAC=function(l,v){var m,L=this.cmdHistory,b=(l>=17&&l<=23||l>=25&&l<=31)&&v>=64&&v<=127,M=(l===16||l===24)&&v>=64&&v<=95;if(!(b||M))return!1;if(u(l,v,L))return t(null,null,L),!0;var F=l<=23?1:2;v>=64&&v<=95?m=F===1?O[l]:E[l]:m=F===1?_[l]:A[l];var w=this.channels[F];return w?(w.setPAC(this.interpretPAC(m,v)),t(l,v,L),this.currentChannel=F,!0):!1},h.interpretPAC=function(l,v){var m,L={color:null,italics:!1,indent:null,underline:!1,row:l};return v>95?m=v-96:m=v-64,L.underline=(m&1)===1,m<=13?L.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(m/2)]:m<=15?(L.italics=!0,L.color="white"):L.indent=Math.floor((m-16)/2)*4,L},h.parseChars=function(l,v){var m,L=null,b=null;if(l>=25?(m=2,b=l-8):(m=1,b=l),b>=17&&b<=19){var M;b===17?M=v+80:b===18?M=v+112:M=v+144,this.logger.log(x.INFO,"Special char '"+T(M)+"' in channel "+m),L=[M]}else l>=32&&l<=127&&(L=v===0?[l]:[l,v]);if(L){var F=y(L);this.logger.log(x.DEBUG,"Char codes = "+F.join(",")),t(l,v,this.cmdHistory)}return L},h.parseBackgroundAttributes=function(l,v){var m=(l===16||l===24)&&v>=32&&v<=47,L=(l===23||l===31)&&v>=45&&v<=47;if(!(m||L))return!1;var b,M={};l===16||l===24?(b=Math.floor((v-32)/2),M.background=D[b],v%2===1&&(M.background=M.background+"_semi")):v===45?M.background="transparent":(M.foreground="black",v===47&&(M.underline=!0));var F=l<=23?1:2,w=this.channels[F];return w.setBkgData(M),t(l,v,this.cmdHistory),!0},h.reset=function(){for(var l=0;l<Object.keys(this.channels).length;l++){var v=this.channels[l];v&&v.reset()}this.cmdHistory=c()},h.cueSplitAtTime=function(l){for(var v=0;v<this.channels.length;v++){var m=this.channels[v];m&&m.cueSplitAtTime(l)}},r}();function t(r,h,d){d.a=r,d.b=h}function u(r,h,d){return d.a===r&&d.b===h}function c(){return{a:null,b:null}}P.default=i},"./src/utils/codecs.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"isCodecType",function(){return p}),n.d(P,"isCodecSupportedInMp4",function(){return T});var R={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function p(I,S){var O=R[S];return!!O&&O[I.slice(0,4)]===!0}function T(I,S){return MediaSource.isTypeSupported((S||"video")+'/mp4;codecs="'+I+'"')}},"./src/utils/cues.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/vttparser.ts"),p=n("./src/utils/webvtt-parser.ts"),T=n("./src/utils/texttrack-utils.ts"),I=/\s/,S={newCue:function(_,E,A,D){for(var x=[],g,y,s,e,o,f=self.VTTCue||self.TextTrackCue,a=0;a<D.rows.length;a++)if(g=D.rows[a],s=!0,e=0,o="",!g.isEmpty()){for(var i=0;i<g.chars.length;i++)I.test(g.chars[i].uchar)&&s?e++:(o+=g.chars[i].uchar,s=!1);g.cueStartTime=E,E===A&&(A+=1e-4),e>=16?e--:e++;var t=Object(R.fixLineBreaks)(o.trim()),u=Object(p.generateCueId)(E,A,t);(!_||!_.cues||!_.cues.getCueById(u))&&(y=new f(E,A,t),y.id=u,y.line=a+1,y.align="left",y.position=10+Math.min(80,Math.floor(e*8/32)*10),x.push(y))}return _&&x.length&&(x.sort(function(c,r){return c.line==="auto"||r.line==="auto"?0:c.line>8&&r.line>8?r.line-c.line:c.line-r.line}),x.forEach(function(c){return Object(T.addCueToTrack)(_,c)})),x}};P.default=S},"./src/utils/discontinuities.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"findFirstFragWithCC",function(){return I}),n.d(P,"shouldAlignOnDiscontinuities",function(){return S}),n.d(P,"findDiscontinuousReferenceFrag",function(){return O}),n.d(P,"adjustSlidingStart",function(){return E}),n.d(P,"alignStream",function(){return A}),n.d(P,"alignPDT",function(){return x}),n.d(P,"alignFragmentByPDTDelta",function(){return g}),n.d(P,"alignMediaPlaylistByPDT",function(){return y});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/logger.ts"),T=n("./src/controller/level-helper.ts");function I(s,e){for(var o=null,f=0,a=s.length;f<a;f++){var i=s[f];if(i&&i.cc===e){o=i;break}}return o}function S(s,e,o){return!!(e.details&&(o.endCC>o.startCC||s&&s.cc<o.startCC))}function O(s,e){var o=s.fragments,f=e.fragments;if(!f.length||!o.length){p.logger.log("No fragments to align");return}var a=I(o,f[0].cc);if(!a||a&&!a.startPTS){p.logger.log("No frag in previous level to align on");return}return a}function _(s,e){if(s){var o=s.start+e;s.start=s.startPTS=o,s.endPTS=o+s.duration}}function E(s,e){for(var o=e.fragments,f=0,a=o.length;f<a;f++)_(o[f],s);e.fragmentHint&&_(e.fragmentHint,s),e.alignedSliding=!0}function A(s,e,o){!e||(D(s,o,e),!o.alignedSliding&&e.details&&x(o,e.details),!o.alignedSliding&&e.details&&!o.skippedSegments&&Object(T.adjustSliding)(e.details,o))}function D(s,e,o){if(S(s,o,e)){var f=O(o.details,e);f&&Object(R.isFiniteNumber)(f.start)&&(p.logger.log("Adjusting PTS using last level due to CC increase within current level "+e.url),E(f.start,e))}}function x(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=s.fragments[0].programDateTime,a=(f-o)/1e3+e.fragments[0].start;a&&Object(R.isFiniteNumber)(a)&&(p.logger.log("Adjusting PTS using programDateTime delta "+(f-o)+"ms, sliding:"+a.toFixed(3)+" "+s.url+" "),E(a,s))}}function g(s,e){var o=s.programDateTime;if(!!o){var f=(o-e)/1e3;s.start=s.startPTS=f,s.endPTS=f+s.duration}}function y(s,e){if(!(!e.fragments.length||!s.hasProgramDateTime||!e.hasProgramDateTime)){var o=e.fragments[0].programDateTime,f=e.fragments[0].start,a=o-f*1e3;s.fragments.forEach(function(i){g(i,a)}),s.fragmentHint&&g(s.fragmentHint,a),s.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/ewma.ts"),p=function(){function T(S,O,_){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=_,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new R.default(S),this.fast_=new R.default(O)}var I=T.prototype;return I.update=function(O,_){var E=this.slow_,A=this.fast_;this.slow_.halfLife!==O&&(this.slow_=new R.default(O,E.getEstimate(),E.getTotalWeight())),this.fast_.halfLife!==_&&(this.fast_=new R.default(_,A.getEstimate(),A.getTotalWeight()))},I.sample=function(O,_){O=Math.max(O,this.minDelayMs_);var E=8*_,A=O/1e3,D=E/A;this.fast_.sample(A,D),this.slow_.sample(A,D)},I.canEstimate=function(){var O=this.fast_;return O&&O.getTotalWeight()>=this.minWeight_},I.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},I.destroy=function(){},T}();P.default=p},"./src/utils/ewma.ts":function(B,P,n){"use strict";n.r(P);var R=function(){function p(I,S,O){S===void 0&&(S=0),O===void 0&&(O=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=I,this.alpha_=I?Math.exp(Math.log(.5)/I):0,this.estimate_=S,this.totalWeight_=O}var T=p.prototype;return T.sample=function(S,O){var _=Math.pow(this.alpha_,S);this.estimate_=O*(1-_)+_*this.estimate_,this.totalWeight_+=S},T.getTotalWeight=function(){return this.totalWeight_},T.getEstimate=function(){if(this.alpha_){var S=1-Math.pow(this.alpha_,this.totalWeight_);if(S)return this.estimate_/S}return this.estimate_},p}();P.default=R},"./src/utils/fetch-loader.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"fetchSupported",function(){return g});var R=n("./src/polyfills/number.ts"),p=n("./src/loader/load-stats.ts"),T=n("./src/demux/chunk-cache.ts");function I(f,a){f.prototype=Object.create(a.prototype),f.prototype.constructor=f,A(f,a)}function S(f){var a=typeof Map=="function"?new Map:void 0;return S=function(t){if(t===null||!E(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof a!="undefined"){if(a.has(t))return a.get(t);a.set(t,u)}function u(){return O(t,arguments,D(this).constructor)}return u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,writable:!0,configurable:!0}}),A(u,t)},S(f)}function O(f,a,i){return _()?O=Reflect.construct.bind():O=function(u,c,r){var h=[null];h.push.apply(h,c);var d=Function.bind.apply(u,h),l=new d;return r&&A(l,r.prototype),l},O.apply(null,arguments)}function _(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function E(f){return Function.toString.call(f).indexOf("[native code]")!==-1}function A(f,a){return A=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,u){return t.__proto__=u,t},A(f,a)}function D(f){return D=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(i){return i.__proto__||Object.getPrototypeOf(i)},D(f)}function x(){return x=Object.assign?Object.assign.bind():function(f){for(var a=1;a<arguments.length;a++){var i=arguments[a];for(var t in i)Object.prototype.hasOwnProperty.call(i,t)&&(f[t]=i[t])}return f},x.apply(this,arguments)}function g(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}var y=function(){function f(i){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=i.fetchSetup||e,this.controller=new self.AbortController,this.stats=new p.LoadStats}var a=f.prototype;return a.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},a.abortInternal=function(){var t=this.response;(!t||!t.ok)&&(this.stats.aborted=!0,this.controller.abort())},a.abort=function(){var t;this.abortInternal(),(t=this.callbacks)!==null&&t!==void 0&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},a.load=function(t,u,c){var r=this,h=this.stats;if(h.loading.start)throw new Error("Loader can only be used once.");h.loading.start=self.performance.now();var d=s(t,this.controller.signal),l=c.onProgress,v=t.responseType==="arraybuffer",m=v?"byteLength":"length";this.context=t,this.config=u,this.callbacks=c,this.request=this.fetchSetup(t,d),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(function(){r.abortInternal(),c.onTimeout(h,t,r.response)},u.timeout),self.fetch(this.request).then(function(L){if(r.response=r.loader=L,!L.ok){var b=L.status,M=L.statusText;throw new o(M||"fetch, bad network response",b,L)}return h.loading.first=Math.max(self.performance.now(),h.loading.start),h.total=parseInt(L.headers.get("Content-Length")||"0"),l&&Object(R.isFiniteNumber)(u.highWaterMark)?r.loadProgressively(L,h,t,u.highWaterMark,l):v?L.arrayBuffer():L.text()}).then(function(L){var b=r.response;self.clearTimeout(r.requestTimeout),h.loading.end=Math.max(self.performance.now(),h.loading.first),h.loaded=h.total=L[m];var M={url:b.url,data:L};l&&!Object(R.isFiniteNumber)(u.highWaterMark)&&l(h,t,L,b),c.onSuccess(M,h,t,b)}).catch(function(L){if(self.clearTimeout(r.requestTimeout),!h.aborted){var b=L&&L.code||0,M=L?L.message:null;c.onError({code:b,text:M},t,L?L.details:null)}})},a.getCacheAge=function(){var t=null;if(this.response){var u=this.response.headers.get("age");t=u?parseFloat(u):null}return t},a.loadProgressively=function(t,u,c,r,h){r===void 0&&(r=0);var d=new T.default,l=t.body.getReader(),v=function m(){return l.read().then(function(L){if(L.done)return d.dataLength&&h(u,c,d.flush(),t),Promise.resolve(new ArrayBuffer(0));var b=L.value,M=b.length;return u.loaded+=M,M<r||d.dataLength?(d.push(b),d.dataLength>=r&&h(u,c,d.flush(),t)):h(u,c,b,t),m()}).catch(function(){return Promise.reject()})};return v()},f}();function s(f,a){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:a,headers:new self.Headers(x({},f.headers))};return f.rangeEnd&&i.headers.set("Range","bytes="+f.rangeStart+"-"+String(f.rangeEnd-1)),i}function e(f,a){return new self.Request(f.url,a)}var o=function(f){I(a,f);function a(i,t,u){var c;return c=f.call(this,i)||this,c.code=void 0,c.details=void 0,c.code=t,c.details=u,c}return a}(S(Error));P.default=y},"./src/utils/imsc1-ttml-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"IMSC1_CODEC",function(){return E}),n.d(P,"parseIMSC1",function(){return g});var R=n("./src/utils/mp4-tools.ts"),p=n("./src/utils/vttparser.ts"),T=n("./src/utils/vttcue.ts"),I=n("./src/demux/id3.ts"),S=n("./src/utils/timescale-conversion.ts"),O=n("./src/utils/webvtt-parser.ts");function _(){return _=Object.assign?Object.assign.bind():function(r){for(var h=1;h<arguments.length;h++){var d=arguments[h];for(var l in d)Object.prototype.hasOwnProperty.call(d,l)&&(r[l]=d[l])}return r},_.apply(this,arguments)}var E="stpp.ttml.im1t",A=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,D=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,x={left:"start",center:"center",right:"end",start:"start",end:"end"};function g(r,h,d,l,v){var m=Object(R.findBox)(new Uint8Array(r),["mdat"]);if(m.length===0){v(new Error("Could not parse IMSC1 mdat"));return}var L=m.map(function(M){return Object(I.utf8ArrayToStr)(M)}),b=Object(S.toTimescaleFromScale)(h,1,d);try{L.forEach(function(M){return l(y(M,b))})}catch(M){v(M)}}function y(r,h){var d=new DOMParser,l=d.parseFromString(r,"text/xml"),v=l.getElementsByTagName("tt")[0];if(!v)throw new Error("Invalid ttml");var m={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},L=Object.keys(m).reduce(function(C,U){return C[U]=v.getAttribute("ttp:"+U)||m[U],C},{}),b=v.getAttribute("xml:space")!=="preserve",M=e(s(v,"styling","style")),F=e(s(v,"layout","region")),w=s(v,"body","[begin]");return[].map.call(w,function(C){var U=o(C,b);if(!U||!C.hasAttribute("begin"))return null;var k=t(C.getAttribute("begin"),L),j=t(C.getAttribute("dur"),L),N=t(C.getAttribute("end"),L);if(k===null)throw i(C);if(N===null){if(j===null)throw i(C);N=k+j}var W=new T.default(k-h,N-h,U);W.id=Object(O.generateCueId)(W.startTime,W.endTime,W.text);var Y=F[C.getAttribute("region")],K=M[C.getAttribute("style")];W.position=10,W.size=80;var H=f(Y,K,M),z=H.textAlign;if(z){var $=x[z];$&&(W.lineAlign=$),W.align=z}return _(W,H),W}).filter(function(C){return C!==null})}function s(r,h,d){var l=r.getElementsByTagName(h)[0];return l?[].slice.call(l.querySelectorAll(d)):[]}function e(r){return r.reduce(function(h,d){var l=d.getAttribute("xml:id");return l&&(h[l]=d),h},{})}function o(r,h){return[].slice.call(r.childNodes).reduce(function(d,l,v){var m;return l.nodeName==="br"&&v?d+`
|
|
20
|
+
`:(m=l.childNodes)!==null&&m!==void 0&&m.length?o(l,h):h?d+l.textContent.trim().replace(/\s+/g," "):d+l.textContent},"")}function f(r,h,d){var l="http://www.w3.org/ns/ttml#styling",v=null,m=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],L=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return L&&d.hasOwnProperty(L)&&(v=d[L]),m.reduce(function(b,M){var F=a(h,l,M)||a(r,l,M)||a(v,l,M);return F&&(b[M]=F),b},{})}function a(r,h,d){return r&&r.hasAttributeNS(h,d)?r.getAttributeNS(h,d):null}function i(r){return new Error("Could not parse ttml timestamp "+r)}function t(r,h){if(!r)return null;var d=Object(p.parseTimeStamp)(r);return d===null&&(A.test(r)?d=u(r,h):D.test(r)&&(d=c(r,h))),d}function u(r,h){var d=A.exec(r),l=(d[4]|0)+(d[5]|0)/h.subFrameRate;return(d[1]|0)*3600+(d[2]|0)*60+(d[3]|0)+l/h.frameRate}function c(r,h){var d=D.exec(r),l=Number(d[1]),v=d[2];switch(v){case"h":return l*3600;case"m":return l*60;case"ms":return l*1e3;case"f":return l/h.frameRate;case"t":return l/h.tickRate}return l}},"./src/utils/logger.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"enableLogs",function(){return O}),n.d(P,"logger",function(){return _});var R=function(){},p={trace:R,debug:R,log:R,warn:R,info:R,error:R},T=p;function I(E){var A=self.console[E];return A?A.bind(self.console,"["+E+"] >"):R}function S(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];D.forEach(function(g){T[g]=E[g]?E[g].bind(E):I(g)})}function O(E){if(self.console&&E===!0||typeof E=="object"){S(E,"debug","log","info","warn","error");try{T.log()}catch{T=p}}else T=p}var _=T},"./src/utils/mediakeys-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"KeySystems",function(){return R}),n.d(P,"requestMediaKeySystemAccess",function(){return p});var R;(function(T){T.WIDEVINE="com.widevine.alpha",T.PLAYREADY="com.microsoft.playready"})(R||(R={}));var p=function(){return typeof self!="undefined"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}()},"./src/utils/mediasource-helper.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"getMediaSource",function(){return R});function R(){return self.MediaSource||self.WebKitMediaSource}},"./src/utils/mp4-tools.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"RemuxerTrackIdConfig",function(){return O}),n.d(P,"bin2str",function(){return _}),n.d(P,"readUint16",function(){return E}),n.d(P,"readUint32",function(){return A}),n.d(P,"readSint32",function(){return D}),n.d(P,"writeUint32",function(){return x}),n.d(P,"findBox",function(){return g}),n.d(P,"parseSegmentIndex",function(){return y}),n.d(P,"parseInitSegment",function(){return s}),n.d(P,"getStartDTS",function(){return e}),n.d(P,"getDuration",function(){return o}),n.d(P,"computeRawDurationFromSamples",function(){return f}),n.d(P,"offsetStartDTS",function(){return a}),n.d(P,"segmentValidRange",function(){return i}),n.d(P,"appendUint8Array",function(){return t}),n.d(P,"parseSamples",function(){return u}),n.d(P,"parseSEIMessageFromNALu",function(){return h}),n.d(P,"parseEmsg",function(){return l});var R=n("./src/utils/typed-array.ts"),p=n("./src/loader/fragment.ts"),T=n("./src/demux/id3.ts"),I=Math.pow(2,32)-1,S=[].push,O={video:1,audio:2,id3:3,text:4};function _(v){return String.fromCharCode.apply(null,v)}function E(v,m){var L=v[m]<<8|v[m+1];return L<0?65536+L:L}function A(v,m){var L=D(v,m);return L<0?4294967296+L:L}function D(v,m){return v[m]<<24|v[m+1]<<16|v[m+2]<<8|v[m+3]}function x(v,m,L){v[m]=L>>24,v[m+1]=L>>16&255,v[m+2]=L>>8&255,v[m+3]=L&255}function g(v,m){var L=[];if(!m.length)return L;for(var b=v.byteLength,M=0;M<b;){var F=A(v,M),w=_(v.subarray(M+4,M+8)),C=F>1?M+F:b;if(w===m[0])if(m.length===1)L.push(v.subarray(M+8,C));else{var U=g(v.subarray(M+8,C),m.slice(1));U.length&&S.apply(L,U)}M=C}return L}function y(v){var m=[],L=v[0],b=8,M=A(v,b);b+=4;var F=0,w=0;L===0?b+=8:b+=16,b+=2;var C=v.length+w,U=E(v,b);b+=2;for(var k=0;k<U;k++){var j=b,N=A(v,j);j+=4;var W=N&2147483647,Y=(N&2147483648)>>>31;if(Y===1)return console.warn("SIDX has hierarchical references (not supported)"),null;var K=A(v,j);j+=4,m.push({referenceSize:W,subsegmentDuration:K,info:{duration:K/M,start:C,end:C+W-1}}),C+=W,j+=4,b=j}return{earliestPresentationTime:F,timescale:M,version:L,referencesCount:U,references:m}}function s(v){for(var m=[],L=g(v,["moov","trak"]),b=0;b<L.length;b++){var M=L[b],F=g(M,["tkhd"])[0];if(F){var w=F[0],C=w===0?12:20,U=A(F,C),k=g(M,["mdia","mdhd"])[0];if(k){w=k[0],C=w===0?12:20;var j=A(k,C),N=g(M,["mdia","hdlr"])[0];if(N){var W=_(N.subarray(8,12)),Y={soun:p.ElementaryStreamTypes.AUDIO,vide:p.ElementaryStreamTypes.VIDEO}[W];if(Y){var K=g(M,["mdia","minf","stbl","stsd"])[0],H=void 0;K&&(H=_(K.subarray(12,16))),m[U]={timescale:j,type:Y},m[Y]={timescale:j,id:U,codec:H}}}}}}var z=g(v,["moov","mvex","trex"]);return z.forEach(function($){var X=A($,4),J=m[X];J&&(J.default={duration:A($,12),flags:A($,20)})}),m}function e(v,m){return g(m,["moof","traf"]).reduce(function(L,b){var M=g(b,["tfdt"])[0],F=M[0],w=g(b,["tfhd"]).reduce(function(C,U){var k=A(U,4),j=v[k];if(j){var N=A(M,4);F===1&&(N*=Math.pow(2,32),N+=A(M,8));var W=j.timescale||9e4,Y=N/W;if(isFinite(Y)&&(C===null||Y<C))return Y}return C},null);return w!==null&&isFinite(w)&&(L===null||w<L)?w:L},null)||0}function o(v,m){for(var L=0,b=0,M=0,F=g(v,["moof","traf"]),w=0;w<F.length;w++){var C=F[w],U=g(C,["tfhd"])[0],k=A(U,4),j=m[k];if(!!j){var N=j.default,W=A(U,0)|(N==null?void 0:N.flags),Y=N==null?void 0:N.duration;W&8&&(W&2?Y=A(U,12):Y=A(U,8));for(var K=j.timescale||9e4,H=g(C,["trun"]),z=0;z<H.length;z++){if(L=f(H[z]),!L&&Y){var $=A(H[z],4);L=Y*$}j.type===p.ElementaryStreamTypes.VIDEO?b+=L/K:j.type===p.ElementaryStreamTypes.AUDIO&&(M+=L/K)}}}if(b===0&&M===0){for(var X=0,J=g(v,["sidx"]),te=0;te<J.length;te++){var Q=y(J[te]);Q!=null&&Q.references&&(X+=Q.references.reduce(function(ae,se){return ae+se.info.duration||0},0))}return X}return b||M}function f(v){var m=A(v,0),L=8;m&1&&(L+=4),m&4&&(L+=4);for(var b=0,M=A(v,4),F=0;F<M;F++){if(m&256){var w=A(v,L);b+=w,L+=4}m&512&&(L+=4),m&1024&&(L+=4),m&2048&&(L+=4)}return b}function a(v,m,L){g(m,["moof","traf"]).forEach(function(b){g(b,["tfhd"]).forEach(function(M){var F=A(M,4),w=v[F];if(!!w){var C=w.timescale||9e4;g(b,["tfdt"]).forEach(function(U){var k=U[0],j=A(U,4);if(k===0)j-=L*C,j=Math.max(j,0),x(U,4,j);else{j*=Math.pow(2,32),j+=A(U,8),j-=L*C,j=Math.max(j,0);var N=Math.floor(j/(I+1)),W=Math.floor(j%(I+1));x(U,4,N),x(U,8,W)}})}})})}function i(v){var m={valid:null,remainder:null},L=g(v,["moof"]);if(L){if(L.length<2)return m.remainder=v,m}else return m;var b=L[L.length-1];return m.valid=Object(R.sliceUint8)(v,0,b.byteOffset-8),m.remainder=Object(R.sliceUint8)(v,b.byteOffset-8),m}function t(v,m){var L=new Uint8Array(v.length+m.length);return L.set(v),L.set(m,v.length),L}function u(v,m){var L=[],b=m.samples,M=m.timescale,F=m.id,w=!1,C=g(b,["moof"]);return C.map(function(U){var k=U.byteOffset-8,j=g(U,["traf"]);j.map(function(N){var W=g(N,["tfdt"]).map(function(Y){var K=Y[0],H=A(Y,4);return K===1&&(H*=Math.pow(2,32),H+=A(Y,8)),H/M})[0];return W!==void 0&&(v=W),g(N,["tfhd"]).map(function(Y){var K=A(Y,4),H=A(Y,0)&16777215,z=(H&1)!==0,$=(H&2)!==0,X=(H&8)!==0,J=0,te=(H&16)!==0,Q=0,ae=(H&32)!==0,se=8;K===F&&(z&&(se+=8),$&&(se+=4),X&&(J=A(Y,se),se+=4),te&&(Q=A(Y,se),se+=4),ae&&(se+=4),m.type==="video"&&(w=c(m.codec)),g(N,["trun"]).map(function(re){var ee=re[0],Z=A(re,0)&16777215,q=(Z&1)!==0,fe=0,ge=(Z&4)!==0,ie=(Z&256)!==0,me=0,ye=(Z&512)!==0,Te=0,oe=(Z&1024)!==0,de=(Z&2048)!==0,Se=0,Ee=A(re,4),Ae=8;q&&(fe=A(re,Ae),Ae+=4),ge&&(Ae+=4);for(var Oe=fe+k,Me=0;Me<Ee;Me++){if(ie?(me=A(re,Ae),Ae+=4):me=J,ye?(Te=A(re,Ae),Ae+=4):Te=Q,oe&&(Ae+=4),de&&(ee===0?Se=A(re,Ae):Se=D(re,Ae),Ae+=4),m.type===p.ElementaryStreamTypes.VIDEO)for(var De=0;De<Te;){var xe=A(b,Oe);Oe+=4;var G=b[Oe]&31;if(r(w,G)){var V=b.subarray(Oe,Oe+xe);h(V,v+Se/M,L)}Oe+=xe,De+=xe+4}v+=me/M}}))})})}),L}function c(v){if(!v)return!1;var m=v.indexOf("."),L=m<0?v:v.substring(0,m);return L==="hvc1"||L==="hev1"||L==="dvh1"||L==="dvhe"}function r(v,m){return v?m===39||m===40:m===6}function h(v,m,L){var b=d(v),M=0;M++;for(var F=0,w=0,C=!1,U=0;M<b.length;){F=0;do{if(M>=b.length)break;U=b[M++],F+=U}while(U===255);w=0;do{if(M>=b.length)break;U=b[M++],w+=U}while(U===255);var k=b.length-M;if(!C&&F===4&&M<b.length){C=!0;var j=b[M++];if(j===181){var N=E(b,M);if(M+=2,N===49){var W=A(b,M);if(M+=4,W===1195456820){var Y=b[M++];if(Y===3){var K=b[M++],H=31&K,z=64&K,$=z?2+H*3:0,X=new Uint8Array($);if(z){X[0]=K;for(var J=1;J<$;J++)X[J]=b[M++]}L.push({type:Y,payloadType:F,pts:m,bytes:X})}}}}}else if(F===5&&w<k){if(C=!0,w>16){for(var te=[],Q=0;Q<16;Q++){var ae=b[M++].toString(16);te.push(ae.length==1?"0"+ae:ae),(Q===3||Q===5||Q===7||Q===9)&&te.push("-")}for(var se=w-16,re=new Uint8Array(se),ee=0;ee<se;ee++)re[ee]=b[M++];L.push({payloadType:F,pts:m,uuid:te.join(""),userData:Object(T.utf8ArrayToStr)(re),userDataBytes:re})}}else if(w<k)M+=w;else if(w>k)break}}function d(v){for(var m=v.byteLength,L=[],b=1;b<m-2;)v[b]===0&&v[b+1]===0&&v[b+2]===3?(L.push(b+2),b+=2):b++;if(L.length===0)return v;var M=m-L.length,F=new Uint8Array(M),w=0;for(b=0;b<M;w++,b++)w===L[0]&&(w++,L.shift()),F[b]=v[w];return F}function l(v){var m=v[0],L="",b="",M=0,F=0,w=0,C=0,U=0,k=0;if(m===0){for(;_(v.subarray(k,k+1))!=="\0";)L+=_(v.subarray(k,k+1)),k+=1;for(L+=_(v.subarray(k,k+1)),k+=1;_(v.subarray(k,k+1))!=="\0";)b+=_(v.subarray(k,k+1)),k+=1;b+=_(v.subarray(k,k+1)),k+=1,M=A(v,12),F=A(v,16),C=A(v,20),U=A(v,24),k=28}else if(m===1){k+=4,M=A(v,k),k+=4;var j=A(v,k);k+=4;var N=A(v,k);for(k+=4,w=Math.pow(2,32)*j+N,Number.isSafeInteger(w)||(w=Number.MAX_SAFE_INTEGER,console.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),C=A(v,k),k+=4,U=A(v,k),k+=4;_(v.subarray(k,k+1))!=="\0";)L+=_(v.subarray(k,k+1)),k+=1;for(L+=_(v.subarray(k,k+1)),k+=1;_(v.subarray(k,k+1))!=="\0";)b+=_(v.subarray(k,k+1)),k+=1;b+=_(v.subarray(k,k+1)),k+=1}var W=v.subarray(k,v.byteLength);return{schemeIdUri:L,value:b,timeScale:M,presentationTime:w,presentationTimeDelta:F,eventDuration:C,id:U,payload:W}}},"./src/utils/output-filter.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"default",function(){return R});var R=function(){function p(I,S){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=I,this.trackName=S}var T=p.prototype;return T.dispatchCue=function(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},T.newCue=function(S,O,_){(this.startTime===null||this.startTime>S)&&(this.startTime=S),this.endTime=O,this.screen=_,this.timelineController.createCaptionsTrack(this.trackName)},T.reset=function(){this.cueRanges=[],this.startTime=null},p}()},"./src/utils/texttrack-utils.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sendAddTrackEvent",function(){return p}),n.d(P,"addCueToTrack",function(){return T}),n.d(P,"clearCurrentCues",function(){return I}),n.d(P,"removeCuesInRange",function(){return S}),n.d(P,"getCuesInRange",function(){return _});var R=n("./src/utils/logger.ts");function p(E,A){var D;try{D=new Event("addtrack")}catch{D=document.createEvent("Event"),D.initEvent("addtrack",!1,!1)}D.track=E,A.dispatchEvent(D)}function T(E,A){var D=E.mode;if(D==="disabled"&&(E.mode="hidden"),E.cues&&!E.cues.getCueById(A.id))try{if(E.addCue(A),!E.cues.getCueById(A.id))throw new Error("addCue is failed for: "+A)}catch(g){R.logger.debug("[texttrack-utils]: "+g);var x=new self.TextTrackCue(A.startTime,A.endTime,A.text);x.id=A.id,E.addCue(x)}D==="disabled"&&(E.mode=D)}function I(E){var A=E.mode;if(A==="disabled"&&(E.mode="hidden"),E.cues)for(var D=E.cues.length;D--;)E.removeCue(E.cues[D]);A==="disabled"&&(E.mode=A)}function S(E,A,D,x){var g=E.mode;if(g==="disabled"&&(E.mode="hidden"),E.cues&&E.cues.length>0)for(var y=_(E.cues,A,D),s=0;s<y.length;s++)(!x||x(y[s]))&&E.removeCue(y[s]);g==="disabled"&&(E.mode=g)}function O(E,A){if(A<E[0].startTime)return 0;var D=E.length-1;if(A>E[D].endTime)return-1;for(var x=0,g=D;x<=g;){var y=Math.floor((g+x)/2);if(A<E[y].startTime)g=y-1;else if(A>E[y].startTime&&x<D)x=y+1;else return y}return E[x].startTime-A<A-E[g].startTime?x:g}function _(E,A,D){var x=[],g=O(E,A);if(g>-1)for(var y=g,s=E.length;y<s;y++){var e=E[y];if(e.startTime>=A&&e.endTime<=D)x.push(e);else if(e.startTime>D)return x}return x}},"./src/utils/time-ranges.ts":function(B,P,n){"use strict";n.r(P);var R={toString:function(T){for(var I="",S=T.length,O=0;O<S;O++)I+="["+T.start(O).toFixed(3)+","+T.end(O).toFixed(3)+"]";return I}};P.default=R},"./src/utils/timescale-conversion.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"toTimescaleFromBase",function(){return p}),n.d(P,"toTimescaleFromScale",function(){return T}),n.d(P,"toMsFromMpegTsClock",function(){return I}),n.d(P,"toMpegTsClockFromTimescale",function(){return S});var R=9e4;function p(O,_,E,A){E===void 0&&(E=1),A===void 0&&(A=!1);var D=O*_*E;return A?Math.round(D):D}function T(O,_,E,A){return E===void 0&&(E=1),A===void 0&&(A=!1),p(O,_,1/E,A)}function I(O,_){return _===void 0&&(_=!1),p(O,1e3,1/R,_)}function S(O,_){return _===void 0&&(_=1),p(O,R,1/_)}},"./src/utils/typed-array.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"sliceUint8",function(){return R});function R(p,T,I){return Uint8Array.prototype.slice?p.slice(T,I):new Uint8Array(Array.prototype.slice.call(p,T,I))}},"./src/utils/vttcue.ts":function(B,P,n){"use strict";n.r(P),P.default=function(){if(typeof self!="undefined"&&self.VTTCue)return self.VTTCue;var R=["","lr","rl"],p=["start","middle","end","left","right"];function T(E,A){if(typeof A!="string"||!Array.isArray(E))return!1;var D=A.toLowerCase();return~E.indexOf(D)?D:!1}function I(E){return T(R,E)}function S(E){return T(p,E)}function O(E){for(var A=arguments.length,D=new Array(A>1?A-1:0),x=1;x<A;x++)D[x-1]=arguments[x];for(var g=1;g<arguments.length;g++){var y=arguments[g];for(var s in y)E[s]=y[s]}return E}function _(E,A,D){var x=this,g={enumerable:!0};x.hasBeenReset=!1;var y="",s=!1,e=E,o=A,f=D,a=null,i="",t=!0,u="auto",c="start",r=50,h="middle",d=50,l="middle";Object.defineProperty(x,"id",O({},g,{get:function(){return y},set:function(m){y=""+m}})),Object.defineProperty(x,"pauseOnExit",O({},g,{get:function(){return s},set:function(m){s=!!m}})),Object.defineProperty(x,"startTime",O({},g,{get:function(){return e},set:function(m){if(typeof m!="number")throw new TypeError("Start time must be set to a number.");e=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"endTime",O({},g,{get:function(){return o},set:function(m){if(typeof m!="number")throw new TypeError("End time must be set to a number.");o=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"text",O({},g,{get:function(){return f},set:function(m){f=""+m,this.hasBeenReset=!0}})),Object.defineProperty(x,"region",O({},g,{get:function(){return a},set:function(m){a=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"vertical",O({},g,{get:function(){return i},set:function(m){var L=I(m);if(L===!1)throw new SyntaxError("An invalid or illegal string was specified.");i=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"snapToLines",O({},g,{get:function(){return t},set:function(m){t=!!m,this.hasBeenReset=!0}})),Object.defineProperty(x,"line",O({},g,{get:function(){return u},set:function(m){if(typeof m!="number"&&m!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");u=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"lineAlign",O({},g,{get:function(){return c},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");c=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"position",O({},g,{get:function(){return r},set:function(m){if(m<0||m>100)throw new Error("Position must be between 0 and 100.");r=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"positionAlign",O({},g,{get:function(){return h},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");h=L,this.hasBeenReset=!0}})),Object.defineProperty(x,"size",O({},g,{get:function(){return d},set:function(m){if(m<0||m>100)throw new Error("Size must be between 0 and 100.");d=m,this.hasBeenReset=!0}})),Object.defineProperty(x,"align",O({},g,{get:function(){return l},set:function(m){var L=S(m);if(!L)throw new SyntaxError("An invalid or illegal string was specified.");l=L,this.hasBeenReset=!0}})),x.displayState=void 0}return _.prototype.getCueAsHTML=function(){var E=self.WebVTT;return E.convertCueToDOMTree(self,this.text)},_}()},"./src/utils/vttparser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"parseTimeStamp",function(){return T}),n.d(P,"fixLineBreaks",function(){return A}),n.d(P,"VTTParser",function(){return D});var R=n("./src/utils/vttcue.ts"),p=function(){function x(){}var g=x.prototype;return g.decode=function(s,e){if(!s)return"";if(typeof s!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(s))},x}();function T(x){function g(s,e,o,f){return(s|0)*3600+(e|0)*60+(o|0)+parseFloat(f||0)}var y=x.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return y?parseFloat(y[2])>59?g(y[2],y[3],0,y[4]):g(y[1],y[2],y[3],y[4]):null}var I=function(){function x(){this.values=Object.create(null)}var g=x.prototype;return g.set=function(s,e){!this.get(s)&&e!==""&&(this.values[s]=e)},g.get=function(s,e,o){return o?this.has(s)?this.values[s]:e[o]:this.has(s)?this.values[s]:e},g.has=function(s){return s in this.values},g.alt=function(s,e,o){for(var f=0;f<o.length;++f)if(e===o[f]){this.set(s,e);break}},g.integer=function(s,e){/^-?\d+$/.test(e)&&this.set(s,parseInt(e,10))},g.percent=function(s,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){var o=parseFloat(e);if(o>=0&&o<=100)return this.set(s,o),!0}return!1},x}();function S(x,g,y,s){var e=s?x.split(s):[x];for(var o in e)if(typeof e[o]=="string"){var f=e[o].split(y);if(f.length===2){var a=f[0],i=f[1];g(a,i)}}}var O=new R.default(0,0,""),_=O.align==="middle"?"middle":"center";function E(x,g,y){var s=x;function e(){var a=T(x);if(a===null)throw new Error("Malformed timestamp: "+s);return x=x.replace(/^[^\sa-zA-Z-]+/,""),a}function o(a,i){var t=new I;S(a,function(r,h){var d;switch(r){case"region":for(var l=y.length-1;l>=0;l--)if(y[l].id===h){t.set(r,y[l].region);break}break;case"vertical":t.alt(r,h,["rl","lr"]);break;case"line":d=h.split(","),t.integer(r,d[0]),t.percent(r,d[0])&&t.set("snapToLines",!1),t.alt(r,d[0],["auto"]),d.length===2&&t.alt("lineAlign",d[1],["start",_,"end"]);break;case"position":d=h.split(","),t.percent(r,d[0]),d.length===2&&t.alt("positionAlign",d[1],["start",_,"end","line-left","line-right","auto"]);break;case"size":t.percent(r,h);break;case"align":t.alt(r,h,["start",_,"end","left","right"]);break}},/:/,/\s/),i.region=t.get("region",null),i.vertical=t.get("vertical","");var u=t.get("line","auto");u==="auto"&&O.line===-1&&(u=-1),i.line=u,i.lineAlign=t.get("lineAlign","start"),i.snapToLines=t.get("snapToLines",!0),i.size=t.get("size",100),i.align=t.get("align",_);var c=t.get("position","auto");c==="auto"&&O.position===50&&(c=i.align==="start"||i.align==="left"?0:i.align==="end"||i.align==="right"?100:50),i.position=c}function f(){x=x.replace(/^\s+/,"")}if(f(),g.startTime=e(),f(),x.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);x=x.slice(3),f(),g.endTime=e(),f(),o(x,g)}function A(x){return x.replace(/<br(?: \/)?>/gi,`
|
|
21
|
+
`)}var D=function(){function x(){this.state="INITIAL",this.buffer="",this.decoder=new p,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var g=x.prototype;return g.parse=function(s){var e=this;s&&(e.buffer+=e.decoder.decode(s,{stream:!0}));function o(){var c=e.buffer,r=0;for(c=A(c);r<c.length&&c[r]!=="\r"&&c[r]!==`
|
|
22
|
+
`;)++r;var h=c.slice(0,r);return c[r]==="\r"&&++r,c[r]===`
|
|
23
|
+
`&&++r,e.buffer=c.slice(r),h}function f(c){S(c,function(r,h){},/:/)}try{var a="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;a=o();var i=a.match(/^()?WEBVTT([ \t].*)?$/);if(!i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}for(var t=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(t?t=!1:a=o(),e.state){case"HEADER":/:/.test(a)?f(a):a||(e.state="ID");continue;case"NOTE":a||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){e.state="NOTE";break}if(!a)continue;if(e.cue=new R.default(0,0,""),e.state="CUE",a.indexOf("-->")===-1){e.cue.id=a;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{E(a,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{var u=a.indexOf("-->")!==-1;if(!a||u&&(t=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
|
|
24
|
+
`),e.cue.text+=a}continue;case"BADCUE":a||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},g.flush=function(){var s=this;try{if((s.cue||s.state==="HEADER")&&(s.buffer+=`
|
|
25
25
|
|
|
26
|
-
`,s.parse()),s.state==="INITIAL"||s.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){s.onparsingerror&&s.onparsingerror(e)}return s.onflush&&s.onflush(),this},x}()},"./src/utils/webvtt-parser.ts":function(
|
|
26
|
+
`,s.parse()),s.state==="INITIAL"||s.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){s.onparsingerror&&s.onparsingerror(e)}return s.onflush&&s.onflush(),this},x}()},"./src/utils/webvtt-parser.ts":function(B,P,n){"use strict";n.r(P),n.d(P,"generateCueId",function(){return D}),n.d(P,"parseWebVTT",function(){return g});var R=n("./src/polyfills/number.ts"),p=n("./src/utils/vttparser.ts"),T=n("./src/demux/id3.ts"),I=n("./src/utils/timescale-conversion.ts"),S=n("./src/remux/mp4-remuxer.ts"),O=/\r\n|\n\r|\n|\r/g,_=function(s,e,o){return o===void 0&&(o=0),s.slice(o,o+e.length)===e},E=function(s){var e=parseInt(s.slice(-3)),o=parseInt(s.slice(-6,-4)),f=parseInt(s.slice(-9,-7)),a=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Object(R.isFiniteNumber)(e)||!Object(R.isFiniteNumber)(o)||!Object(R.isFiniteNumber)(f)||!Object(R.isFiniteNumber)(a))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+s);return e+=1e3*o,e+=60*1e3*f,e+=60*60*1e3*a,e},A=function(s){for(var e=5381,o=s.length;o;)e=e*33^s.charCodeAt(--o);return(e>>>0).toString()};function D(y,s,e){return A(y.toString())+A(s.toString())+A(e)}var x=function(s,e,o){var f=s[e],a=s[f.prevCC];if(!a||!a.new&&f.new){s.ccOffset=s.presentationOffset=f.start,f.new=!1;return}for(;(i=a)!==null&&i!==void 0&&i.new;){var i;s.ccOffset+=f.start-a.start,f.new=!1,f=a,a=s[f.prevCC]}s.presentationOffset=o};function g(y,s,e,o,f,a,i,t){var u=new p.VTTParser,c=Object(T.utf8ArrayToStr)(new Uint8Array(y)).trim().replace(O,`
|
|
27
27
|
`).split(`
|
|
28
|
-
`),
|
|
29
|
-
`)}),h.flush()}},"./src/utils/xhr-loader.ts":function(U,D,d){"use strict";d.r(D);var b=d("./src/utils/logger.ts"),y=d("./src/loader/load-stats.ts"),T=/^age:\s*[\d.]+\s*$/m,I=function(){function S(A){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=A?A.xhrSetup:null,this.stats=new y.LoadStats,this.retryDelay=0}var O=S.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var 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()))},O.abort=function(){var g;this.abortInternal(),(g=this.callbacks)!==null&&g!==void 0&&g.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(g,_,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=_,this.callbacks=L,this.retryDelay=_.retryDelay,this.loadInternal()},O.loadInternal=function(){var g=this.config,_=this.context;if(!!g){var L=this.loader=new self.XMLHttpRequest,x=this.stats;x.loading.first=0,x.loaded=0;var v=this.xhrSetup;try{if(v)try{v(L,_.url)}catch{L.open("GET",_.url,!0),v(L,_.url)}L.readyState||L.open("GET",_.url,!0);var m=this.context.headers;if(m)for(var s in m)L.setRequestHeader(s,m[s])}catch(e){this.callbacks.onError({code:L.status,text:e.message},_,L);return}_.rangeEnd&&L.setRequestHeader("Range","bytes="+_.rangeStart+"-"+(_.rangeEnd-1)),L.onreadystatechange=this.readystatechange.bind(this),L.onprogress=this.loadprogress.bind(this),L.responseType=_.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout),L.send()}},O.readystatechange=function(){var g=this.context,_=this.loader,L=this.stats;if(!(!g||!_)){var x=_.readyState,v=this.config;if(!L.aborted&&x>=2)if(self.clearTimeout(this.requestTimeout),L.loading.first===0&&(L.loading.first=Math.max(self.performance.now(),L.loading.start)),x===4){_.onreadystatechange=null,_.onprogress=null;var m=_.status;if(m>=200&&m<300){L.loading.end=Math.max(self.performance.now(),L.loading.first);var s,e;if(g.responseType==="arraybuffer"?(s=_.response,e=s.byteLength):(s=_.responseText,e=s.length),L.loaded=L.total=e,!this.callbacks)return;var i=this.callbacks.onProgress;if(i&&i(L,g,s,_),!this.callbacks)return;var t={url:_.responseURL,data:s};this.callbacks.onSuccess(t,L,g,_)}else L.retry>=v.maxRetry||m>=400&&m<499?(b.logger.error(m+" while loading "+g.url),this.callbacks.onError({code:m,text:_.statusText},g,_)):(b.logger.warn(m+" 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)}},O.loadtimeout=function(){b.logger.warn("timeout while loading "+this.context.url);var g=this.callbacks;g&&(this.abortInternal(),g.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(g){var _=this.stats;_.loaded=g.loaded,g.lengthComputable&&(_.total=g.total)},O.getCacheAge=function(){var g=null;if(this.loader&&T.test(this.loader.getAllResponseHeaders())){var _=this.loader.getResponseHeader("age");g=_?parseFloat(_):null}return g},S}();D.default=I}}).default})});var Qe=class{addEventListener(){}removeEventListener(){}dispatchEvent(D){return!0}};if(typeof DocumentFragment=="undefined"){class U extends Qe{}globalThis.DocumentFragment=U}var ot=class extends Qe{},jt=class extends Qe{},xr={get(U){},define(U,D,d){},upgrade(U){},whenDefined(U){return Promise.resolve(ot)}},$e,Wt=class{constructor(D,d={}){me(this,$e,void 0);De(this,$e,d==null?void 0:d.detail)}get detail(){return te(this,$e)}initCustomEvent(){}};$e=new WeakMap;function Ar(U,D){return new ot}var Gt={document:{createElement:Ar},DocumentFragment,customElements:xr,CustomEvent:Wt,EventTarget:Qe,HTMLElement:ot,HTMLVideoElement:jt},Ht=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Fe=Ht?Gt:globalThis,Tt=Ht?Gt.document:globalThis.document;var At=st(Vt()),ke=st(ut()),_t=st(ut()),We=st(ut()),Dt={ANY:"any",MUTED:"muted"},_r=Object.values(Dt),Yt=U=>typeof U=="boolean"||typeof U=="string"&&_r.includes(U),Xt=(U,D,d)=>{let b=!1,y=!1,T=Yt(D)?D:!!D,I=()=>{U.addEventListener("playing",()=>{b=!0},{once:!0})};if(I(),U.addEventListener("loadstart",()=>{b=!1,I(),Lt(U,T)},{once:!0}),U.addEventListener("loadedmetadata",()=>{d||(y=!Number.isFinite(U.duration)),Lt(U,T)},{once:!0}),d&&d.once(_t.default.Events.LEVEL_LOADED,(S,O)=>{var A;y=(A=O.details.live)!=null?A:!1}),!T){let S=()=>{!y||((d==null?void 0:d.liveSyncPosition)?U.currentTime=d.liveSyncPosition:Number.isFinite(U.seekable.end(0))&&(U.currentTime=U.seekable.end(0)))};U.addEventListener("play",()=>{d&&U.preload==="metadata"?d.once(_t.default.Events.LEVEL_UPDATED,S):d&&S()},{once:!0})}return S=>{b||(T=Yt(S)?S:!!S,Lt(U,T))}},Lt=(U,D)=>{if(!D)return;let d=U.muted,b=()=>U.muted=d;switch(D){case Dt.ANY:U.play().catch(y=>{U.muted=!0,U.play().catch(b)});break;case Dt.MUTED:U.muted=!0,U.play().catch(b);break;default:U.play().catch(()=>{});break}},Ze=class extends Error{constructor(U,D=Ze.MEDIA_ERR_CUSTOM,d){super(U);var b;this.name="MediaError",this.code=D,this.fatal=d!=null?d:D>=Ze.MEDIA_ERR_NETWORK&&D<=Ze.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(b=Ze.defaultMessages[this.code])!=null?b:"")}},Re=Ze;Re.MEDIA_ERR_ABORTED=1,Re.MEDIA_ERR_NETWORK=2,Re.MEDIA_ERR_DECODE=3,Re.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Re.MEDIA_ERR_ENCRYPTED=5,Re.MEDIA_ERR_CUSTOM=100,Re.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};function Dr(U,D){D.on(We.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(y,{tracks:T})=>{T.forEach(I=>{var S;let O=(S=I.subtitleTrack)!=null?S:I.closedCaptions,A=D.subtitleTracks.findIndex(({lang:g,name:_,type:L})=>g==(O==null?void 0:O.lang)&&_===I.label&&L.toLowerCase()===I.kind);Lr(U,I.kind,I.label,O==null?void 0:O.lang,`${I.kind}${A}`)})});let d=()=>{var y;if(!D.subtitleTracks.length)return;let T=Array.from(U.textTracks).find(S=>S.id&&S.mode==="showing"&&["subtitles","captions"].includes(S.kind)),I=`${(y=D.subtitleTracks[D.subtitleTrack])==null?void 0:y.type.toLowerCase()}${D.subtitleTrack}`;if(T&&(D.subtitleTrack<0||(T==null?void 0:T.id)!==I)){let S=D.subtitleTracks.findIndex(({lang:O,name:A,type:g})=>O==T.language&&A===T.label&&g.toLowerCase()===T.kind);D.subtitleTrack=S}T&&(T==null?void 0:T.id)===I&&T.cues&&Array.from(T.cues).forEach(S=>{T.addCue(S)})};U.textTracks.addEventListener("change",d),D.on(We.default.Events.CUES_PARSED,(y,{track:T,type:I,cues:S})=>{let O=U.textTracks.getTrackById(T);if(!O)return;let A=O.mode==="disabled";A&&(O.mode="hidden"),S.forEach(g=>{var _;((_=O.cues)==null?void 0:_.getCueById(g.id))||O.addCue(g)}),A&&(O.mode="disabled")}),D.on(We.default.Events.DESTROYING,()=>{U.textTracks.removeEventListener("change",d),U.querySelectorAll("track[data-removeondestroy]").forEach(y=>{y.remove()})});let b=()=>{Array.from(U.textTracks).forEach(y=>{var T,I;if(!["subtitles","caption"].includes(y.kind)&&y.label==="thumbnails"){if(!((T=y.cues)==null?void 0:T.length)){let S=U.querySelector('track[label="thumbnails"]'),O=(I=S==null?void 0:S.getAttribute("src"))!=null?I:"";S==null||S.removeAttribute("src"),setTimeout(()=>{S==null||S.setAttribute("src",O)},0)}y.mode!=="hidden"&&(y.mode="hidden")}})};D.once(We.default.Events.MANIFEST_LOADED,b),D.once(We.default.Events.MEDIA_ATTACHED,b)}function Lr(U,D,d,b,y){let T=document.createElement("track");return T.kind=D,T.label=d,b&&(T.srclang=b),y&&(T.id=y),T.track.mode="disabled",T.setAttribute("data-removeondestroy",""),U.append(T),T.track}var zt=(U,D)=>U in D,Qt="mux.com",$t=()=>At.default.utils.now(),ft={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Ge={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Ot={HLS:Ge.M3U8},$r=Object.keys(Ot),Jr=[...Object.values(Ge),"hls","HLS"],Or=U=>{let D=U.indexOf("?");if(D<0)return[U];let d=U.slice(0,D),b=U.slice(D);return[d,b]},Jt=(U,{domain:D=Qt}={})=>{if(!U)return;let[d,b=""]=Or(U);return`https://stream.${D}/${d}.m3u8${b}`},Rr=U=>{let D="";try{D=new URL(U).pathname}catch{console.error("invalid url")}let d=D.lastIndexOf(".");if(d<0)return"";let b=D.slice(d+1).toUpperCase();return zt(b,Ge)?Ge[b]:""},Zt=U=>{let D=U.type;if(D){let b=D.toUpperCase();return zt(b,Ot)?Ot[b]:D}let{src:d}=U;return d?Rr(d):""},br=U=>{if([ft.LIVE,ft.LL_LIVE].includes(U)){let D={backBufferLength:12};return U===ft.LL_LIVE?{...D,maxFragLookUpTolerance:.001}:D}return{}},dt=new WeakMap,qt=U=>{var D;return(D=dt.get(U))==null?void 0:D.error},Rt=(U,D)=>{D&&(D.detachMedia(),D.destroy()),(U==null?void 0:U.mux)&&!U.mux.deleted&&(U.mux.destroy(),U.mux),U&&(U.removeEventListener("error",er),U.removeEventListener("error",bt),dt.delete(U))},Pr=(U,D)=>{var d,b,y;let{debug:T,preferMse:I,streamType:S,startTime:O=-1}=U,A=Zt(U),g=A===Ge.M3U8,_=!A||((d=D==null?void 0:D.canPlayType(A))!=null?d:!0),L=ke.default.isSupported(),x=((y=(b=window==null?void 0:window.navigator)==null?void 0:b.userAgent)!=null?y:"").toLowerCase().indexOf("android")!==-1;if(g&&!(!g||_&&!((I||x)&&L))&&L){let v={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},m=br(S);return new ke.default({debug:T,startPosition:O,...v,...m})}},Ir=({playbackId:U,src:D,customDomain:d})=>{if(U)return!0;if(typeof D!="string")return!1;let b=new URL(D).hostname.toLocaleLowerCase();return b.includes(Qt)||!!d&&b.includes(d.toLocaleLowerCase())},Mr=(U,D,d)=>{let{envKey:b}=U,y=Ir(U);if((b||y)&&D){let{playerInitTime:T,playerSoftwareName:I,playerSoftwareVersion:S,beaconCollectionDomain:O,metadata:A,debug:g}=U,_=L=>typeof L.player_error_code=="string"?!1:typeof U.errorTranslator=="function"?U.errorTranslator(L):L;At.default.monitor(D,{debug:g,beaconCollectionDomain:O,hlsjs:d,Hls:d?ke.default:void 0,automaticErrorTracking:!1,errorTranslator:_,data:{...b?{env_key:b}:{},player_software_name:I,player_software_version:S,player_init_time:T,...A}})}},Cr=(U,D,d)=>{var b,y,T;if(!D){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:I,streamType:S}=U,O=Zt(U),A=O===Ge.M3U8,g=!O||((b=D==null?void 0:D.canPlayType(O))!=null?b:!0),_=ke.default.isSupported(),L=((T=(y=window==null?void 0:window.navigator)==null?void 0:y.userAgent)!=null?T:"").toLowerCase().indexOf("android")!==-1&&S===ft.LL_LIVE,x=!A||g&&!((I||L)&&_),{src:v}=U;if(D&&g&&x){if(typeof v=="string"){let{startTime:m}=U;if(D.setAttribute("src",v),m){let s=({target:e})=>{e.currentTime=m,e.removeEventListener("loadedmetadata",s)};D.addEventListener("loadedmetadata",s)}}else D.removeAttribute("src");D.addEventListener("error",er),D.addEventListener("error",bt)}else if(d&&v){switch(d.on(ke.default.Events.ERROR,(m,s)=>{let e={[ke.default.ErrorTypes.NETWORK_ERROR]:Re.MEDIA_ERR_NETWORK,[ke.default.ErrorTypes.MEDIA_ERROR]:Re.MEDIA_ERR_DECODE},i=new Re("",e[s.type]);i.fatal=s.fatal,i.data=s,D.dispatchEvent(new CustomEvent("error",{detail:i}))}),D.addEventListener("error",bt),Dr(D,d),D.preload){case"none":D.addEventListener("play",()=>d.loadSource(v),{once:!0});break;case"metadata":let m=d.config.maxBufferLength,s=d.config.maxBufferSize;d.config.maxBufferLength=1,d.config.maxBufferSize=1,D.addEventListener("play",()=>{d.config.maxBufferLength=m,d.config.maxBufferSize=s},{once:!0}),d.loadSource(v);break;default:d.loadSource(v)}d.attachMedia(D)}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 er(U){if(!U.isTrusted)return;U.stopImmediatePropagation();let D=U.target;if(!(D==null?void 0:D.error))return;let{message:d,code:b}=D.error,y=new Re(d,b);if(D.src&&(b!==Re.MEDIA_ERR_DECODE||b!==void 0)){let{status:T}=await fetch(D.src);y.data={response:{code:T}}}D.dispatchEvent(new CustomEvent("error",{detail:y}))}function bt(U){var D;if(!(U instanceof CustomEvent)||!(U.detail instanceof Re))return;let d=U.target,b=U.detail;if(!b||!b.fatal)return;let y=dt.get(d);y&&(y.error=b),(D=d.mux)==null||D.emit("error",{player_error_code:b.code,player_error_message:b.message})}var tr=(U,D,d)=>{Rt(D,d),dt.set(D,{});let b=Pr(U,D);return Mr(U,D,b),Cr(U,D,b),b};var Fr=()=>{try{return"0.8.5"}catch{}return"UNKNOWN"},wr=Fr(),rr=()=>wr;var Br=U=>{var D,d,b,y,T,kr,S,Pt,A,we,_,It,x,Mt,m,Ur,e,Nr,t,ir,a,n,h,c,u,f,o,ct,E,Kr,R,nr,M,jr,w,ar,B,Wr,N,sr;return D=class extends U{constructor(){super();me(this,o);me(this,E);me(this,R);me(this,M);me(this,w);me(this,B);me(this,N);ze(this,"castEnabled",!1);me(this,a,{paused:!1});me(this,n,void 0);me(this,h,{});me(this,c,void 0);me(this,u,void 0);me(this,f,void 0);D.instances.add(this),Ae(this,w,ar).call(this)}static get castElement(){return te(D,d)}static get castEnabled(){return te(D,b)}static get castState(){var K;return(K=te(D,A,we))==null?void 0:K.getCastState()}static async exitCast(){let K=!0;try{await te(D,A,we).endCurrentSession(K)}catch(V){console.error(V);return}}get castPlayer(){if(D.castElement===this)return te(this,n)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var V;Ae(V=D,t,ir).call(V,K),De(D,d,this),Object.entries(te(this,h)).forEach(([Y,Q])=>{te(this,n).controller.addEventListener(Y,Q)});try{await te(D,A,we).requestSession()}catch{De(D,d,void 0);return}te(this,a).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(Y){console.error(Y)}}async load(){var re,X;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),V=[...this.querySelectorAll("track")].filter(({kind:J,src:se})=>se&&(J==="subtitles"||J==="captions")),Y=[],Q=0;V.length&&(K.tracks=V.map(J=>{let se=++Q;Y.length===0&&J.track.mode==="showing"&&Y.push(se);let ne=new chrome.cast.media.Track(se,chrome.cast.media.TrackType.TEXT);return ne.trackContentId=J.src,ne.trackContentType="text/vtt",ne.subtype=J.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,ne.name=J.label,ne.language=J.srclang,ne})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let z=new chrome.cast.media.LoadRequest(K);z.currentTime=(re=super.currentTime)!=null?re:0,z.autoplay=!te(this,a).paused,z.activeTrackIds=Y,await((X=te(D,_,It))==null?void 0:X.loadMedia(z)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,V,Y;return(Y=(V=this.getAttribute("cast-src"))!=null?V:(K=this.querySelector("source"))==null?void 0:K.src)!=null?Y:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var V;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((V=this.castPlayer.controller)==null||V.muteOrUnmute());return}super.muted=K}get volume(){var K,V;return this.castPlayer?(V=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?V:1:super.volume}set volume(K){var V;if(this.castPlayer){this.castPlayer.volumeLevel=K,(V=this.castPlayer.controller)==null||V.setVolumeLevel();return}super.volume=K}get duration(){var K,V;return this.castPlayer&&te(this,o,ct)?(V=(K=this.castPlayer)==null?void 0:K.duration)!=null?V:NaN:super.duration}get currentTime(){var K,V;return this.castPlayer&&te(this,o,ct)?(V=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?V:0:super.currentTime}set currentTime(K){var V;if(this.castPlayer){this.castPlayer.currentTime=K,(V=this.castPlayer.controller)==null||V.seek();return}super.currentTime=K}get onentercast(){return te(this,c)}set onentercast(K){te(this,c)&&(this.removeEventListener("entercast",te(this,c)),De(this,c,null)),typeof K=="function"&&(De(this,c,K),this.addEventListener("entercast",K))}get onleavecast(){return te(this,u)}set onleavecast(K){te(this,u)&&(this.removeEventListener("leavecast",te(this,u)),De(this,u,null)),typeof K=="function"&&(De(this,u,K),this.addEventListener("leavecast",K))}get oncastchange(){return te(this,f)}set oncastchange(K){te(this,f)&&(this.removeEventListener("castchange",te(this,f)),De(this,f,null)),typeof K=="function"&&(De(this,f,K),this.addEventListener("castchange",K))}},d=new WeakMap,b=new WeakMap,y=new WeakMap,T=new WeakSet,kr=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},S=new WeakSet,Pt=function(){return typeof cast!="undefined"&&cast.framework},A=new WeakSet,we=function(){if(te(D,S,Pt))return cast.framework.CastContext.getInstance()},_=new WeakSet,It=function(){var K;return(K=te(D,A,we))==null?void 0:K.getCurrentSession()},x=new WeakSet,Mt=function(){var K;return(K=te(D,_,It))==null?void 0:K.getSessionObj().media[0]},m=new WeakSet,Ur=function(K){return new Promise((V,Y)=>{te(D,x,Mt).editTracksInfo(K,V,Y)})},e=new WeakSet,Nr=function(K){return new Promise((V,Y)=>{te(D,x,Mt).getStatus(K,V,Y)})},t=new WeakSet,ir=function(K){return te(D,A,we).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},a=new WeakMap,n=new WeakMap,h=new WeakMap,c=new WeakMap,u=new WeakMap,f=new WeakMap,o=new WeakSet,ct=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},E=new WeakSet,Kr=function(){te(D,d)===this&&(Object.entries(te(this,h)).forEach(([K,V])=>{te(this,n).controller.removeEventListener(K,V)}),De(D,d,void 0),this.muted=te(this,n).isMuted,this.currentTime=te(this,n).savedPlayerState.currentTime,te(this,n).savedPlayerState.isPaused===!1&&this.play())},R=new WeakSet,nr=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:te(D,A,we).getCastState()}))},M=new WeakSet,jr=async function(){var V,Y;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(te(D,A,we).getSessionState()===K&&this.castSrc===((V=te(D,x,Mt))==null?void 0:V.media.contentId)){De(D,d,this),Object.entries(te(this,h)).forEach(([Q,z])=>{te(this,n).controller.addEventListener(Q,z)});try{await Ae(Y=D,e,Nr).call(Y,new chrome.cast.media.GetStatusRequest)}catch(Q){console.error(Q)}te(this,h)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),te(this,h)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},w=new WeakSet,ar=function(){var K;!te(D,S,Pt)||this.castEnabled||(this.castEnabled=!0,Ae(K=D,t,ir).call(K),this.textTracks.addEventListener("change",Ae(this,N,sr).bind(this)),Ae(this,R,nr).call(this),De(this,n,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(te(this,n)),De(this,h,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:V})=>{V===!1&&Ae(this,E,Kr).call(this),this.dispatchEvent(new Event(V?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!te(this,o,ct)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var V,Y;((V=this.castPlayer)==null?void 0:V.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(Y=this.castPlayer)==null?void 0:Y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!te(this,o,ct)||(await Promise.resolve(),Ae(this,B,Wr).call(this))}}))},B=new WeakSet,Wr=function(){Ae(this,N,sr).call(this)},N=new WeakSet,sr=async function(){var pe,ee,Z,q,$,ue;if(!this.castPlayer)return;let V=((ee=(pe=te(this,n).mediaInfo)==null?void 0:pe.tracks)!=null?ee:[]).filter(({type:ie})=>ie===chrome.cast.media.TrackType.TEXT),Y=[...this.textTracks].filter(({kind:ie})=>ie==="subtitles"||ie==="captions"),Q=V.map(({language:ie,name:de,trackId:he})=>{var Se;let{mode:ye}=(Se=Y.find(fe=>fe.language===ie&&fe.label===de))!=null?Se:{};return ye?{mode:ye,trackId:he}:!1}).filter(Boolean),re=Q.filter(({mode:ie})=>ie!=="showing").map(({trackId:ie})=>ie),X=Q.find(({mode:ie})=>ie==="showing"),J=($=(q=(Z=te(D,_,It))==null?void 0:Z.getSessionObj().media[0])==null?void 0:q.activeTrackIds)!=null?$:[],se=J;if(J.length&&(se=se.filter(ie=>!re.includes(ie))),(X==null?void 0:X.trackId)&&(se=[...se,X.trackId]),se=[...new Set(se)],!((ie,de)=>ie.length===de.length&&ie.every(he=>de.includes(he)))(J,se))try{let ie=new chrome.cast.media.EditTracksInfoRequest(se);await Ae(ue=D,m,Ur).call(ue,ie)}catch(ie){console.error(ie)}},me(D,T),me(D,S),me(D,A),me(D,_),me(D,x),me(D,m),me(D,e),me(D,t),ze(D,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),ze(D,"instances",new Set),me(D,d,void 0),me(D,b,!1),ze(D,"initCast",()=>{var K;te(D,T,kr)?te(D,S,Pt)?te(K=D,y).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var V;return te(V=D,y).call(V,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var V;return te(V=D,y).call(V,chrome.cast.isAvailable)})}}),me(D,y,K=>{if(K){De(D,b,!0);let{CAST_STATE_CHANGED:V}=cast.framework.CastContextEventType;te(D,A,we).addEventListener(V,Q=>{D.instances.forEach(z=>{var re;return Ae(re=z,R,nr).call(re,Q)})});let{SESSION_STATE_CHANGED:Y}=cast.framework.CastContextEventType;te(D,A,we).addEventListener(Y,Q=>{D.instances.forEach(z=>{var re;return Ae(re=z,M,jr).call(re,Q)})}),D.instances.forEach(Q=>{var z;return Ae(z=Q,w,ar).call(z)})}}),D};if(globalThis.HTMLVideoElement&&globalThis.customElements){let U=Br(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",U,{extends:"video"}),globalThis.CastableVideoElement=U),U.initCast()}var or=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],lr=Tt.createElement("template");lr.innerHTML=`
|
|
28
|
+
`),r=[],h=Object(I.toMpegTsClockFromTimescale)(s,e),d="00:00.000",l=0,v=0,m,L=!0;u.oncue=function(b){var M=o[f],F=o.ccOffset,w=(l-h)/9e4;M!=null&&M.new&&(v!==void 0?F=o.ccOffset=M.start:x(o,f,w)),w&&(F=w-o.presentationOffset);var C=b.endTime-b.startTime,U=Object(S.normalizePts)((b.startTime+F-v)*9e4,a*9e4)/9e4;b.startTime=Math.max(U,0),b.endTime=Math.max(U+C,0);var k=b.text.trim();b.text=decodeURIComponent(encodeURIComponent(k)),b.id||(b.id=D(b.startTime,b.endTime,k)),b.endTime>0&&r.push(b)},u.onparsingerror=function(b){m=b},u.onflush=function(){if(m){t(m);return}i(r)},c.forEach(function(b){if(L)if(_(b,"X-TIMESTAMP-MAP=")){L=!1,b.slice(16).split(",").forEach(function(M){_(M,"LOCAL:")?d=M.slice(6):_(M,"MPEGTS:")&&(l=parseInt(M.slice(7)))});try{v=E(d)/1e3}catch(M){m=M}return}else b===""&&(L=!1);u.parse(b+`
|
|
29
|
+
`)}),u.flush()}},"./src/utils/xhr-loader.ts":function(B,P,n){"use strict";n.r(P);var R=n("./src/utils/logger.ts"),p=n("./src/loader/load-stats.ts"),T=/^age:\s*[\d.]+\s*$/m,I=function(){function S(_){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=_?_.xhrSetup:null,this.stats=new p.LoadStats,this.retryDelay=0}var O=S.prototype;return O.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},O.abortInternal=function(){var E=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),E&&(E.onreadystatechange=null,E.onprogress=null,E.readyState!==4&&(this.stats.aborted=!0,E.abort()))},O.abort=function(){var E;this.abortInternal(),(E=this.callbacks)!==null&&E!==void 0&&E.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},O.load=function(E,A,D){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=E,this.config=A,this.callbacks=D,this.retryDelay=A.retryDelay,this.loadInternal()},O.loadInternal=function(){var E=this.config,A=this.context;if(!!E){var D=this.loader=new self.XMLHttpRequest,x=this.stats;x.loading.first=0,x.loaded=0;var g=this.xhrSetup;try{if(g)try{g(D,A.url)}catch{D.open("GET",A.url,!0),g(D,A.url)}D.readyState||D.open("GET",A.url,!0);var y=this.context.headers;if(y)for(var s in y)D.setRequestHeader(s,y[s])}catch(e){this.callbacks.onError({code:D.status,text:e.message},A,D);return}A.rangeEnd&&D.setRequestHeader("Range","bytes="+A.rangeStart+"-"+(A.rangeEnd-1)),D.onreadystatechange=this.readystatechange.bind(this),D.onprogress=this.loadprogress.bind(this),D.responseType=A.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),E.timeout),D.send()}},O.readystatechange=function(){var E=this.context,A=this.loader,D=this.stats;if(!(!E||!A)){var x=A.readyState,g=this.config;if(!D.aborted&&x>=2)if(self.clearTimeout(this.requestTimeout),D.loading.first===0&&(D.loading.first=Math.max(self.performance.now(),D.loading.start)),x===4){A.onreadystatechange=null,A.onprogress=null;var y=A.status;if(y>=200&&y<300){D.loading.end=Math.max(self.performance.now(),D.loading.first);var s,e;if(E.responseType==="arraybuffer"?(s=A.response,e=s.byteLength):(s=A.responseText,e=s.length),D.loaded=D.total=e,!this.callbacks)return;var o=this.callbacks.onProgress;if(o&&o(D,E,s,A),!this.callbacks)return;var f={url:A.responseURL,data:s};this.callbacks.onSuccess(f,D,E,A)}else D.retry>=g.maxRetry||y>=400&&y<499?(R.logger.error(y+" while loading "+E.url),this.callbacks.onError({code:y,text:A.statusText},E,A)):(R.logger.warn(y+" while loading "+E.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,g.maxRetryDelay),D.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),g.timeout)}},O.loadtimeout=function(){R.logger.warn("timeout while loading "+this.context.url);var E=this.callbacks;E&&(this.abortInternal(),E.onTimeout(this.stats,this.context,this.loader))},O.loadprogress=function(E){var A=this.stats;A.loaded=E.loaded,E.lengthComputable&&(A.total=E.total)},O.getCacheAge=function(){var E=null;if(this.loader&&T.test(this.loader.getAllResponseHeaders())){var A=this.loader.getResponseHeader("age");E=A?parseFloat(A):null}return E},S}();P.default=I}}).default})});var Xe=class{addEventListener(){}removeEventListener(){}dispatchEvent(P){return!0}};if(typeof DocumentFragment=="undefined"){class B extends Xe{}globalThis.DocumentFragment=B}var st=class extends Xe{},bt=class extends Xe{},wr={get(B){},define(B,P,n){},upgrade(B){},whenDefined(B){return Promise.resolve(st)}},ot,Rt=class{constructor(P,n={}){ve(this,ot,void 0);Pe(this,ot,n==null?void 0:n.detail)}get detail(){return ne(this,ot)}initCustomEvent(){}};ot=new WeakMap;function Ur(B,P){return new st}var $t={document:{createElement:Ur},DocumentFragment,customElements:wr,CustomEvent:Rt,EventTarget:Xe,HTMLElement:st,HTMLVideoElement:bt},Jt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",we=Jt?$t:globalThis,Pt=Jt?$t.document:globalThis.document;var jt=yt(Zt(),1),Ge=yt(Tt(),1),wt=yt(Tt(),1),Qe=yt(Tt(),1),$e=(B,P,n,R)=>{B.addEventListener(P,n,R),B.addEventListener("teardown",()=>{B.removeEventListener(P,n)},{once:!0})},nr=(B,P)=>B in P;function kr(B,P,n){P&&n>P&&(n=P);for(let R=0;R<B.length;R++)if(B.start(R)<=n&&B.end(R)>=n)return!0;return!1}var Ut={ANY:"any",MUTED:"muted"},Br=Object.values(Ut),qt=B=>typeof B=="boolean"||typeof B=="string"&&Br.includes(B),ar=(B,P,n)=>{let R=!1,p=!1,T=qt(P)?P:!!P,I=()=>{R||$e(B,"playing",()=>{R=!0},{once:!0})};if(I(),$e(B,"loadstart",()=>{R=!1,I(),Ct(B,T)},{once:!0}),$e(B,"loadstart",()=>{n||(p=!Number.isFinite(B.duration)),Ct(B,T)},{once:!0}),n&&n.once(wt.default.Events.LEVEL_LOADED,(S,O)=>{var _;p=(_=O.details.live)!=null?_:!1}),!T){let S=()=>{!p||(n!=null&&n.liveSyncPosition?B.currentTime=n.liveSyncPosition:Number.isFinite(B.seekable.end(0))&&(B.currentTime=B.seekable.end(0)))};n&&$e(B,"play",()=>{B.preload==="metadata"?n.once(wt.default.Events.LEVEL_UPDATED,S):S()},{once:!0})}return S=>{R||(T=qt(S)?S:!!S,Ct(B,T))}},Ct=(B,P)=>{if(!P)return;let n=B.muted,R=()=>B.muted=n;switch(P){case Ut.ANY:B.play().catch(p=>{B.muted=!0,B.play().catch(R)});break;case Ut.MUTED:B.muted=!0,B.play().catch(R);break;default:B.play().catch(()=>{});break}},ut=class extends Error{constructor(B,P=ut.MEDIA_ERR_CUSTOM,n){var R;super(B),this.name="MediaError",this.code=P,this.fatal=n!=null?n:P>=ut.MEDIA_ERR_NETWORK&&P<=ut.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(R=ut.defaultMessages[this.code])!=null?R:"")}},Fe=ut;Fe.MEDIA_ERR_ABORTED=1,Fe.MEDIA_ERR_NETWORK=2,Fe.MEDIA_ERR_DECODE=3,Fe.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Fe.MEDIA_ERR_ENCRYPTED=5,Fe.MEDIA_ERR_CUSTOM=100,Fe.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};function Nr(B,P){P.on(Qe.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(p,{tracks:T})=>{T.forEach(I=>{var S;let O=(S=I.subtitleTrack)!=null?S:I.closedCaptions,_=P.subtitleTracks.findIndex(({lang:E,name:A,type:D})=>E==(O==null?void 0:O.lang)&&A===I.label&&D.toLowerCase()===I.kind);jr(B,I.kind,I.label,O==null?void 0:O.lang,`${I.kind}${_}`)})});let n=()=>{var p;if(!P.subtitleTracks.length)return;let T=Array.from(B.textTracks).find(S=>S.id&&S.mode==="showing"&&["subtitles","captions"].includes(S.kind)),I=`${(p=P.subtitleTracks[P.subtitleTrack])==null?void 0:p.type.toLowerCase()}${P.subtitleTrack}`;if(T&&(P.subtitleTrack<0||(T==null?void 0:T.id)!==I)){let S=P.subtitleTracks.findIndex(({lang:O,name:_,type:E})=>O==T.language&&_===T.label&&E.toLowerCase()===T.kind);P.subtitleTrack=S}T&&(T==null?void 0:T.id)===I&&T.cues&&Array.from(T.cues).forEach(S=>{T.addCue(S)})};B.textTracks.addEventListener("change",n),P.on(Qe.default.Events.CUES_PARSED,(p,{track:T,type:I,cues:S})=>{let O=B.textTracks.getTrackById(T);if(!O)return;let _=O.mode==="disabled";_&&(O.mode="hidden"),S.forEach(E=>{var A;(A=O.cues)!=null&&A.getCueById(E.id)||O.addCue(E)}),_&&(O.mode="disabled")}),P.once(Qe.default.Events.DESTROYING,()=>{B.textTracks.removeEventListener("change",n),B.querySelectorAll("track[data-removeondestroy]").forEach(p=>{p.remove()})});let R=()=>{Array.from(B.textTracks).forEach(p=>{var T,I;if(!["subtitles","caption"].includes(p.kind)&&p.label==="thumbnails"){if(!((T=p.cues)!=null&&T.length)){let S=B.querySelector('track[label="thumbnails"]'),O=(I=S==null?void 0:S.getAttribute("src"))!=null?I:"";S==null||S.removeAttribute("src"),setTimeout(()=>{S==null||S.setAttribute("src",O)},0)}p.mode!=="hidden"&&(p.mode="hidden")}})};P.once(Qe.default.Events.MANIFEST_LOADED,R),P.once(Qe.default.Events.MEDIA_ATTACHED,R)}function jr(B,P,n,R,p){let T=document.createElement("track");return T.kind=P,T.label=n,R&&(T.srclang=R),p&&(T.id=p),T.track.mode="disabled",T.setAttribute("data-removeondestroy",""),B.append(T),T.track}var er,tr,Kr=(tr=(er=globalThis==null?void 0:globalThis.navigator)==null?void 0:er.userAgent)!=null?tr:"",Wr=Kr.toLowerCase().indexOf("android")!==-1,sr="mux.com",rr,ir,kt=(ir=(rr=Ge.default).isSupported)==null?void 0:ir.call(rr),or=Wr,lr=()=>jt.default.utils.now(),Ft={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},Je={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},Bt={HLS:Je.M3U8},si=Object.keys(Bt),oi=[...Object.values(Je),"hls","HLS"],Gr=B=>{let P=B.indexOf("?");if(P<0)return[B];let n=B.slice(0,P),R=B.slice(P);return[n,R]},ur=(B,{domain:P=sr}={})=>{if(!B)return;let[n,R=""]=Gr(B);return`https://stream.${P}/${n}.m3u8${R}`},Hr=B=>{let P="";try{P=new URL(B).pathname}catch{console.error("invalid url")}let n=P.lastIndexOf(".");if(n<0)return"";let R=P.slice(n+1).toUpperCase();return nr(R,Je)?Je[R]:""},fr=B=>{let P=B.type;if(P){let R=P.toUpperCase();return nr(R,Bt)?Bt[R]:P}let{src:n}=B;return n?Hr(n):""},Vr=B=>{if([Ft.LIVE,Ft.LL_LIVE].includes(B)){let P={backBufferLength:12};return B===Ft.LL_LIVE?{...P,maxFragLookUpTolerance:.001}:P}return{}},Ze=new WeakMap,dr=B=>{var P;return(P=Ze.get(B))==null?void 0:P.error},Kt=(B,P)=>{P&&(P.detachMedia(),P.destroy()),(B==null?void 0:B.mux)&&!B.mux.deleted&&(B.mux.destroy(),delete B.mux),B&&(B.removeAttribute("src"),B.load(),B.removeEventListener("error",hr),B.removeEventListener("error",Nt),B.removeEventListener("durationchange",cr),Ze.delete(B),B.dispatchEvent(new Event("teardown")))},Yr=(B,P)=>{var n;let{debug:R,preferMse:p,streamType:T,startTime:I=-1}=B,S=fr(B),O=S===Je.M3U8,_=!S||((n=P==null?void 0:P.canPlayType(S))!=null?n:!0);if(O&&!(!O||_&&!((p||or)&&kt))&&kt){let E={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},A=Vr(T);return new Ge.default({debug:R,startPosition:I,...E,...A})}},zr=({playbackId:B,src:P,customDomain:n})=>{if(B)return!0;if(typeof P!="string")return!1;let R=new URL(P).hostname.toLocaleLowerCase();return R.includes(sr)||!!n&&R.includes(n.toLocaleLowerCase())},Xr=(B,P,n)=>{let{envKey:R}=B,p=zr(B);if((R||p)&&P){let{playerInitTime:T,playerSoftwareName:I,playerSoftwareVersion:S,beaconCollectionDomain:O,metadata:_,debug:E}=B,A=D=>typeof D.player_error_code=="string"?!1:typeof B.errorTranslator=="function"?B.errorTranslator(D):D;jt.default.monitor(P,{debug:E,beaconCollectionDomain:O,hlsjs:n,Hls:n?Ge.default:void 0,automaticErrorTracking:!1,errorTranslator:A,data:{...R?{env_key:R}:{},player_software_name:I,player_software:I,player_software_version:S,player_init_time:T,..._}})}},Qr=(B,P,n)=>{var R,p;if(!P){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:T,streamType:I}=B,S=fr(B),O=S===Je.M3U8,_=!S||((R=P==null?void 0:P.canPlayType(S))!=null?R:!0),E=!O||_&&!((T||or)&&kt),{src:A}=B;if(P&&_&&E)typeof A=="string"?(P.setAttribute("src",A),B.startTime&&(((p=Ze.get(P))!=null?p:{}).startTime=B.startTime,P.addEventListener("durationchange",cr,{once:!0}))):P.removeAttribute("src"),P.addEventListener("error",hr),P.addEventListener("error",Nt);else if(n&&A){switch(n.on(Ge.default.Events.ERROR,(D,x)=>{let g={[Ge.default.ErrorTypes.NETWORK_ERROR]:Fe.MEDIA_ERR_NETWORK,[Ge.default.ErrorTypes.MEDIA_ERROR]:Fe.MEDIA_ERR_DECODE},y=new Fe("",g[x.type]);y.fatal=x.fatal,y.data=x,P.dispatchEvent(new CustomEvent("error",{detail:y}))}),P.addEventListener("error",Nt),Nr(P,n),P.preload){case"none":$e(P,"play",()=>n.loadSource(A),{once:!0});break;case"metadata":let D=n.config.maxBufferLength,x=n.config.maxBufferSize;n.config.maxBufferLength=1,n.config.maxBufferSize=1,$e(P,"play",()=>{n.config.maxBufferLength=D,n.config.maxBufferSize=x},{once:!0}),n.loadSource(A);break;default:n.loadSource(A)}n.attachMedia(P)}else console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function cr(B){var P;let n=B.target,R=(P=Ze.get(n))==null?void 0:P.startTime;if(!!R&&kr(n.seekable,n.duration,R)){let p=n.preload==="auto";p&&(n.preload="none"),n.currentTime=R,p&&(n.preload="auto")}}async function hr(B){if(!B.isTrusted)return;B.stopImmediatePropagation();let P=B.target;if(!(P!=null&&P.error))return;let{message:n,code:R}=P.error,p=new Fe(n,R);if(P.src&&(R!==Fe.MEDIA_ERR_DECODE||R!==void 0)){let{status:T}=await fetch(P.src);p.data={response:{code:T}}}P.dispatchEvent(new CustomEvent("error",{detail:p}))}function Nt(B){var P,n;if(!(B instanceof CustomEvent)||!(B.detail instanceof Fe))return;let R=B.target,p=B.detail;!p||!p.fatal||(((P=Ze.get(R))!=null?P:{}).error=p,(n=R.mux)==null||n.emit("error",{player_error_code:p.code,player_error_message:p.message}))}var vr=(B,P,n)=>{Kt(P,n),Ze.set(P,{});let R=Yr(B,P);return Xr(B,P,R),Qr(B,P,R),R};var $r=()=>{try{return"0.8.6"}catch{}return"UNKNOWN"},Jr=$r(),gr=()=>Jr;var Zr=B=>{var P,n,R,p,T,mr,S,St,_,Ue,A,xt,x,At,y,pr,e,yr,f,Wt,i,t,u,c,r,h,d,ft,v,Er,L,Gt,M,Tr,w,Ht,U,Sr,j,Vt;return P=class extends B{constructor(){super();ve(this,d);ve(this,v);ve(this,L);ve(this,M);ve(this,w);ve(this,U);ve(this,j);at(this,"castEnabled",!1);ve(this,i,{paused:!1});ve(this,t,void 0);ve(this,u,{});ve(this,c,void 0);ve(this,r,void 0);ve(this,h,void 0);P.instances.add(this),be(this,w,Ht).call(this)}static get castElement(){return ne(P,n)}static get castEnabled(){return ne(P,R)}static get castState(){var K;return(K=ne(P,_,Ue))==null?void 0:K.getCastState()}static async exitCast(){try{await ne(P,_,Ue).endCurrentSession(!0)}catch(H){console.error(H);return}}get castPlayer(){if(P.castElement===this)return ne(this,t)}attributeChangedCallback(K){if(!!this.castPlayer)switch(K){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(K={}){var H;be(H=P,f,Wt).call(H,K),Pe(P,n,this),Object.entries(ne(this,u)).forEach(([z,$])=>{ne(this,t).controller.addEventListener(z,$)});try{await ne(P,_,Ue).requestSession()}catch{Pe(P,n,void 0);return}ne(this,i).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(z){console.error(z)}}async load(){var J,te;if(!this.castPlayer)return super.load();let K=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),H=[...this.querySelectorAll("track")].filter(({kind:Q,src:ae})=>ae&&(Q==="subtitles"||Q==="captions")),z=[],$=0;H.length&&(K.tracks=H.map(Q=>{let ae=++$;z.length===0&&Q.track.mode==="showing"&&z.push(ae);let se=new chrome.cast.media.Track(ae,chrome.cast.media.TrackType.TEXT);return se.trackContentId=Q.src,se.trackContentType="text/vtt",se.subtype=Q.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,se.name=Q.label,se.language=Q.srclang,se})),this.castStreamType==="live"?K.streamType=chrome.cast.media.StreamType.LIVE:K.streamType=chrome.cast.media.StreamType.BUFFERED,K.metadata=new chrome.cast.media.GenericMediaMetadata,K.metadata.title=this.title,K.metadata.images=[{url:this.poster}];let X=new chrome.cast.media.LoadRequest(K);X.currentTime=(J=super.currentTime)!=null?J:0,X.autoplay=!ne(this,i).paused,X.activeTrackIds=z,await((te=ne(P,A,xt))==null?void 0:te.loadMedia(X)),this.dispatchEvent(new Event("volumechange"))}play(){var K;if(this.castPlayer){this.castPlayer.isPaused&&((K=this.castPlayer.controller)==null||K.playOrPause());return}return super.play()}pause(){var K;if(this.castPlayer){this.castPlayer.isPaused||(K=this.castPlayer.controller)==null||K.playOrPause();return}super.pause()}get castSrc(){var K,H,z;return(z=(H=this.getAttribute("cast-src"))!=null?H:(K=this.querySelector("source"))==null?void 0:K.src)!=null?z:this.currentSrc}set castSrc(K){this.castSrc!=K&&this.setAttribute("cast-src",`${K}`)}get castContentType(){var K;return(K=this.getAttribute("cast-content-type"))!=null?K:void 0}set castContentType(K){this.setAttribute("cast-content-type",`${K}`)}get castStreamType(){var K;return(K=this.getAttribute("cast-stream-type"))!=null?K:void 0}set castStreamType(K){this.setAttribute("cast-stream-type",`${K}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var K;return this.castPlayer?(K=this.castPlayer)==null?void 0:K.isMuted:super.muted}set muted(K){var H;if(this.castPlayer){(K&&!this.castPlayer.isMuted||!K&&this.castPlayer.isMuted)&&((H=this.castPlayer.controller)==null||H.muteOrUnmute());return}super.muted=K}get volume(){var K,H;return this.castPlayer?(H=(K=this.castPlayer)==null?void 0:K.volumeLevel)!=null?H:1:super.volume}set volume(K){var H;if(this.castPlayer){this.castPlayer.volumeLevel=K,(H=this.castPlayer.controller)==null||H.setVolumeLevel();return}super.volume=K}get duration(){var K,H;return this.castPlayer&&ne(this,d,ft)?(H=(K=this.castPlayer)==null?void 0:K.duration)!=null?H:NaN:super.duration}get currentTime(){var K,H;return this.castPlayer&&ne(this,d,ft)?(H=(K=this.castPlayer)==null?void 0:K.currentTime)!=null?H:0:super.currentTime}set currentTime(K){var H;if(this.castPlayer){this.castPlayer.currentTime=K,(H=this.castPlayer.controller)==null||H.seek();return}super.currentTime=K}get onentercast(){return ne(this,c)}set onentercast(K){ne(this,c)&&(this.removeEventListener("entercast",ne(this,c)),Pe(this,c,null)),typeof K=="function"&&(Pe(this,c,K),this.addEventListener("entercast",K))}get onleavecast(){return ne(this,r)}set onleavecast(K){ne(this,r)&&(this.removeEventListener("leavecast",ne(this,r)),Pe(this,r,null)),typeof K=="function"&&(Pe(this,r,K),this.addEventListener("leavecast",K))}get oncastchange(){return ne(this,h)}set oncastchange(K){ne(this,h)&&(this.removeEventListener("castchange",ne(this,h)),Pe(this,h,null)),typeof K=="function"&&(Pe(this,h,K),this.addEventListener("castchange",K))}},n=new WeakMap,R=new WeakMap,p=new WeakMap,T=new WeakSet,mr=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},S=new WeakSet,St=function(){return typeof cast!="undefined"&&cast.framework},_=new WeakSet,Ue=function(){if(ne(P,S,St))return cast.framework.CastContext.getInstance()},A=new WeakSet,xt=function(){var K;return(K=ne(P,_,Ue))==null?void 0:K.getCurrentSession()},x=new WeakSet,At=function(){var K;return(K=ne(P,A,xt))==null?void 0:K.getSessionObj().media[0]},y=new WeakSet,pr=function(K){return new Promise((H,z)=>{ne(P,x,At).editTracksInfo(K,H,z)})},e=new WeakSet,yr=function(K){return new Promise((H,z)=>{ne(P,x,At).getStatus(K,H,z)})},f=new WeakSet,Wt=function(K){return ne(P,_,Ue).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...K})},i=new WeakMap,t=new WeakMap,u=new WeakMap,c=new WeakMap,r=new WeakMap,h=new WeakMap,d=new WeakSet,ft=function(){var K;return(K=this.castPlayer)==null?void 0:K.isMediaLoaded},v=new WeakSet,Er=function(){ne(P,n)===this&&(Object.entries(ne(this,u)).forEach(([K,H])=>{ne(this,t).controller.removeEventListener(K,H)}),Pe(P,n,void 0),this.muted=ne(this,t).isMuted,this.currentTime=ne(this,t).savedPlayerState.currentTime,ne(this,t).savedPlayerState.isPaused===!1&&this.play())},L=new WeakSet,Gt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:ne(P,_,Ue).getCastState()}))},M=new WeakSet,Tr=async function(){var H,z;let{SESSION_RESUMED:K}=cast.framework.SessionState;if(ne(P,_,Ue).getSessionState()===K&&this.castSrc===((H=ne(P,x,At))==null?void 0:H.media.contentId)){Pe(P,n,this),Object.entries(ne(this,u)).forEach(([$,X])=>{ne(this,t).controller.addEventListener($,X)});try{await be(z=P,e,yr).call(z,new chrome.cast.media.GetStatusRequest)}catch($){console.error($)}ne(this,u)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),ne(this,u)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},w=new WeakSet,Ht=function(){var K;!ne(P,S,St)||this.castEnabled||(this.castEnabled=!0,be(K=P,f,Wt).call(K),this.textTracks.addEventListener("change",be(this,j,Vt).bind(this)),be(this,L,Gt).call(this),Pe(this,t,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(ne(this,t)),Pe(this,u,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:H})=>{H===!1&&be(this,v,Er).call(this),this.dispatchEvent(new Event(H?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!ne(this,d,ft)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var H,z;((H=this.castPlayer)==null?void 0:H.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(z=this.castPlayer)==null?void 0:z.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!ne(this,d,ft)||(await Promise.resolve(),be(this,U,Sr).call(this))}}))},U=new WeakSet,Sr=function(){be(this,j,Vt).call(this)},j=new WeakSet,Vt=async function(){var re,ee,Z,q,fe,ge;if(!this.castPlayer)return;let H=((ee=(re=ne(this,t).mediaInfo)==null?void 0:re.tracks)!=null?ee:[]).filter(({type:ie})=>ie===chrome.cast.media.TrackType.TEXT),z=[...this.textTracks].filter(({kind:ie})=>ie==="subtitles"||ie==="captions"),$=H.map(({language:ie,name:me,trackId:ye})=>{var oe;let{mode:Te}=(oe=z.find(de=>de.language===ie&&de.label===me))!=null?oe:{};return Te?{mode:Te,trackId:ye}:!1}).filter(Boolean),J=$.filter(({mode:ie})=>ie!=="showing").map(({trackId:ie})=>ie),te=$.find(({mode:ie})=>ie==="showing"),Q=(fe=(q=(Z=ne(P,A,xt))==null?void 0:Z.getSessionObj().media[0])==null?void 0:q.activeTrackIds)!=null?fe:[],ae=Q;if(Q.length&&(ae=ae.filter(ie=>!J.includes(ie))),te!=null&&te.trackId&&(ae=[...ae,te.trackId]),ae=[...new Set(ae)],!((ie,me)=>ie.length===me.length&&ie.every(ye=>me.includes(ye)))(Q,ae))try{let ie=new chrome.cast.media.EditTracksInfoRequest(ae);await be(ge=P,y,pr).call(ge,ie)}catch(ie){console.error(ie)}},ve(P,T),ve(P,S),ve(P,_),ve(P,A),ve(P,x),ve(P,y),ve(P,e),ve(P,f),at(P,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),at(P,"instances",new Set),ve(P,n,void 0),ve(P,R,!1),at(P,"initCast",()=>{var K;ne(P,T,mr)?ne(P,S,St)?ne(K=P,p).call(K,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,p).call(H,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var H;return ne(H=P,p).call(H,chrome.cast.isAvailable)})}}),ve(P,p,K=>{if(K){Pe(P,R,!0);let{CAST_STATE_CHANGED:H}=cast.framework.CastContextEventType;ne(P,_,Ue).addEventListener(H,$=>{P.instances.forEach(X=>{var J;return be(J=X,L,Gt).call(J,$)})});let{SESSION_STATE_CHANGED:z}=cast.framework.CastContextEventType;ne(P,_,Ue).addEventListener(z,$=>{P.instances.forEach(X=>{var J;return be(J=X,M,Tr).call(J,$)})}),P.instances.forEach($=>{var X;return be(X=$,w,Ht).call(X)})}}),P};if(globalThis.HTMLVideoElement&&globalThis.customElements){let B=Zr(HTMLVideoElement);globalThis.customElements.get("castable-video")||(globalThis.customElements.define("castable-video",B,{extends:"video"}),globalThis.CastableVideoElement=B),B.initCast()}var xr=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Ar=Pt.createElement("template");Ar.innerHTML=`
|
|
30
30
|
<style>
|
|
31
31
|
:host {
|
|
32
32
|
display: inline-block;
|
|
@@ -44,5 +44,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
44
44
|
</style>
|
|
45
45
|
<video is="castable-video" part="video" crossorigin></video>
|
|
46
46
|
<slot></slot>
|
|
47
|
-
`;var qe,
|
|
47
|
+
`;var dt,qe,Dt,ct,Yt,Ne=class extends we.HTMLElement{constructor(){super();ve(this,qe);ve(this,ct);ve(this,dt,void 0);this.attachShadow({mode:"open"}),this.isConnected&&be(this,qe,Dt).call(this)}static get observedAttributes(){let n=[],R=T=>T.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(T=>{let I=!1;try{typeof this.prototype[T]=="function"&&(I=!0)}catch{}!I&&T!==T.toUpperCase()&&n.push(T.toLowerCase(),R(T))});let p=Object.getPrototypeOf(this).observedAttributes;return p&&(n=n.concat(p)),n}attributeChangedCallback(n,R,p){be(this,qe,Dt).call(this),be(this,ct,Yt).call(this,n,R,p)}connectedCallback(){be(this,qe,Dt).call(this)}};dt=new WeakMap,qe=new WeakSet,Dt=function(){if(ne(this,dt))return;Pe(this,dt,!0),this.shadowRoot.append(Ar.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),xr.forEach(R=>{this.nativeEl.addEventListener(R,p=>{this.dispatchEvent(new CustomEvent(p.type,{detail:p.detail}))})});let n=this.shadowRoot.querySelector("slot");n.addEventListener("slotchange",()=>{n.assignedElements().forEach(R=>{!["track","source"].includes(R.localName)||this.nativeEl.append(R)})}),Array.prototype.forEach.call(this.attributes,R=>{be(this,ct,Yt).call(this,R.name,null,R.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},ct=new WeakSet,Yt=function(n,R,p){let T=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),I=ei(T,n),S=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;I&&!S?typeof this[I]=="boolean"?p===null?this[I]=!1:this[I]=!0:this[I]=p:p===null?this.nativeEl.removeAttribute(n):["id","class"].indexOf(n)===-1&&this.nativeEl.setAttribute(n,p)};var Dr=[],_r=Pt.createElement("video",{is:"castable-video"}),qr=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let B=Object.getPrototypeOf(_r);B&&B!==we.HTMLElement.prototype;B=Object.getPrototypeOf(B))Object.getOwnPropertyNames(B).forEach(P=>{qr.indexOf(P)===-1&&Dr.push(P)});Dr.forEach(B=>{if(B in Ne.prototype)return;if(typeof _r[B]=="function")Ne.prototype[B]=function(){return this.nativeEl[B].apply(this.nativeEl,arguments)};else{let n={get(){return this.nativeEl[B]}};B!==B.toUpperCase()&&(n.set=function(R){this.nativeEl[B]=R}),Object.defineProperty(Ne.prototype,B,n)}});function ei(B,P){let n=null;return B.forEach(R=>{R.toLowerCase()==P.toLowerCase()&&(n=R)}),n}we.customElements.get("custom-video")||(we.customElements.define("custom-video",Ne),we.CustomVideoElement=Ne);var zt=Ne;var ce={ENV_KEY:"env-key",DEBUG:"debug",PLAYBACK_ID:"playback-id",METADATA_URL:"metadata-url",PREFER_MSE:"prefer-mse",PLAYER_SOFTWARE_VERSION:"player-software-version",PLAYER_SOFTWARE_NAME:"player-software-name",METADATA_VIDEO_ID:"metadata-video-id",METADATA_VIDEO_TITLE:"metadata-video-title",METADATA_VIEWER_USER_ID:"metadata-viewer-user-id",BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",TYPE:"type",STREAM_TYPE:"stream-type",START_TIME:"start-time"},ti=Object.values(ce),ri=gr(),ii="mux-video",ht=class extends zt{constructor(){super();this.__metadata={};this.__playerInitTime=lr()}static get observedAttributes(){var n;return[...ti,...(n=zt.observedAttributes)!=null?n:[]]}get playerInitTime(){return this.__playerInitTime}get playerSoftwareName(){var n;return(n=this.__playerSoftwareName)!=null?n:ii}set playerSoftwareName(n){this.__playerSoftwareName=n}get playerSoftwareVersion(){var n;return(n=this.__playerSoftwareVersion)!=null?n:ri}set playerSoftwareVersion(n){this.__playerSoftwareVersion=n}get hls(){return console.warn("<mux-video>.hls is deprecated, please use ._hls instead"),this._hls}get _hls(){return this.__hls}get mux(){return this.nativeEl.mux}get error(){var n;return(n=dr(this.nativeEl))!=null?n:null}get errorTranslator(){return this.__errorTranslator}set errorTranslator(n){this.__errorTranslator=n}get src(){return this.getAttribute("src")}set src(n){n!==this.src&&(n==null?this.removeAttribute("src"):this.setAttribute("src",n))}get type(){var n;return(n=this.getAttribute(ce.TYPE))!=null?n:void 0}set type(n){n!==this.type&&(n?this.setAttribute(ce.TYPE,n):this.removeAttribute(ce.TYPE))}get autoplay(){let n=this.getAttribute("autoplay");return n===null?!1:n===""?!0:n}set autoplay(n){let R=this.autoplay;n!==R&&(n?this.setAttribute("autoplay",typeof n=="string"?n:""):this.removeAttribute("autoplay"))}get debug(){return this.getAttribute(ce.DEBUG)!=null}set debug(n){n!==this.debug&&(n?this.setAttribute(ce.DEBUG,""):this.removeAttribute(ce.DEBUG))}get startTime(){let n=this.getAttribute(ce.START_TIME);if(n==null)return;let R=+n;return Number.isNaN(R)?void 0:R}set startTime(n){n!==this.startTime&&(n==null?this.removeAttribute(ce.START_TIME):this.setAttribute(ce.START_TIME,`${n}`))}get playbackId(){var n;return(n=this.getAttribute(ce.PLAYBACK_ID))!=null?n:void 0}set playbackId(n){n!==this.playbackId&&(n?this.setAttribute(ce.PLAYBACK_ID,n):this.removeAttribute(ce.PLAYBACK_ID))}get customDomain(){var n;return(n=this.getAttribute(ce.CUSTOM_DOMAIN))!=null?n:void 0}set customDomain(n){n!==this.customDomain&&(n?this.setAttribute(ce.CUSTOM_DOMAIN,n):this.removeAttribute(ce.CUSTOM_DOMAIN))}get envKey(){var n;return(n=this.getAttribute(ce.ENV_KEY))!=null?n:void 0}set envKey(n){n!==this.envKey&&(n?this.setAttribute(ce.ENV_KEY,n):this.removeAttribute(ce.ENV_KEY))}get beaconCollectionDomain(){var n;return(n=this.getAttribute(ce.BEACON_COLLECTION_DOMAIN))!=null?n:void 0}set beaconCollectionDomain(n){n!==this.beaconCollectionDomain&&(n?this.setAttribute(ce.BEACON_COLLECTION_DOMAIN,n):this.removeAttribute(ce.BEACON_COLLECTION_DOMAIN))}get streamType(){var n;return(n=this.getAttribute(ce.STREAM_TYPE))!=null?n:void 0}set streamType(n){n!==this.streamType&&(n?this.setAttribute(ce.STREAM_TYPE,n):this.removeAttribute(ce.STREAM_TYPE))}get preferMse(){return this.getAttribute(ce.PREFER_MSE)!=null}set preferMse(n){n?this.setAttribute(ce.PREFER_MSE,""):this.removeAttribute(ce.PREFER_MSE)}get metadata(){let n=this.getAttribute(ce.METADATA_VIDEO_ID),R=this.getAttribute(ce.METADATA_VIDEO_TITLE),p=this.getAttribute(ce.METADATA_VIEWER_USER_ID);return{...this.__metadata,...n!=null?{video_id:n}:{},...R!=null?{video_title:R}:{},...p!=null?{viewer_user_id:p}:{}}}set metadata(n){this.__metadata=n!=null?n:{},this.mux&&this.mux.emit("hb",this.__metadata)}load(){let n=vr(this,this.nativeEl,this.__hls);this.__hls=n;let R=ar(this.nativeEl,this.autoplay,n);this.__updateAutoplay=R}unload(){Kt(this.nativeEl,this.__hls),this.__hls=void 0,this.__updateAutoplay=void 0}attributeChangedCallback(n,R,p){var T;switch(super.attributeChangedCallback(n,R,p),n){case ce.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=p!=null?p:void 0;break;case ce.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=p!=null?p:void 0;break;case"src":let I=!!R,S=!!p;!I&&S?this.load():I&&!S?this.unload():I&&S&&(this.unload(),this.load());break;case"autoplay":if(p===R)break;(T=this.__updateAutoplay)==null||T.call(this,this.autoplay);break;case ce.PLAYBACK_ID:this.src=ur(p!=null?p:void 0,{domain:this.customDomain});break;case ce.DEBUG:let O=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=O);break;case ce.METADATA_URL:p&&fetch(p).then(_=>_.json()).then(_=>this.metadata=_).catch(_=>console.error(`Unable to load or parse metadata JSON from metadata-url ${p}!`));break;default:break}}disconnectedCallback(){this.unload()}};we.customElements.get("mux-video")||(we.customElements.define("mux-video",ht),we.MuxVideoElement=ht);var Ai=ht;})();
|
|
48
48
|
//# sourceMappingURL=mux-video.js.map
|