@namiml/web-sdk 3.4.4-dev.202607010221 → 3.4.4-dev.202607011943
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/nami-web.cjs +20 -20
- package/dist/nami-web.mjs +20 -20
- package/dist/nami-web.umd.js +33 -33
- package/package.json +2 -2
package/dist/nami-web.mjs
CHANGED
|
@@ -459,7 +459,7 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
459
459
|
`),e,e,e,function(e){return zh[e]||zh.CheckCircleOutlined}(e))}},{key:"render",value:function(){return this.renderSvgIcon(this.shouldRenderCurrentIcon()?this.component.name:this.previousSymbolName)}}])}();gt([qt({type:Object})],DS.prototype,"component",void 0),gt([qt({type:Boolean})],DS.prototype,"inFocusedState",void 0),gt([qt({type:Number})],DS.prototype,"scaleFactor",void 0),DS=gt([Tt("nami-symbol")],DS);var xS=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.inFocusedState,n=e.hidden,a=e.fontSize,r=e.alignment,o=e.strikethrough,s=e.spacing;return U(`\n :host {\n line-height: ${MS(a,t)}px;\n display: ${n?"none":"grid"};\n overflow-wrap: anywhere;\n width: fit-content;\n ${Mu(e,i)}\n ${TS(e,i)}\n font-size: ${(null!=a?a:ES)*t}px;\n text-align: ${r||"center"};\n ${Fu("string"!=typeof o&&o)}\n ${Wu(e.fontName)}\n ${Ou(e,t,i)}\n ${SS(e)}\n ${Tu(e)}\n ${function({alignment:e,horizontalAlignment:t}){return cu("justify-content",t&&du[t]?du[t]:e&&du[e]?du[e]:"center")}(e)}\n }\n :host > :not(:first-child) {\n margin-top: ${s||0}px;\n }\n .anticon {\n text-rendering: optimizelegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: inherit;\n display: inline-block;\n font-style: normal;\n line-height: 0;\n text-align: center;\n text-transform: none;\n vertical-align: -.125em;\n }\n .anticon svg {\n display: inline-block;\n line-height: 1;\n }\n\n :host .bullet-text-wrapper {\n line-height: ${MS(a,t)}px;\n display: inline;\n overflow-wrap: anywhere;\n width: fit-content;\n ${Mu(e,i)}\n ${TS(e,i)}\n font-size: ${(null!=a?a:ES)*t}px;\n text-align: ${r||"center"};\n ${Fu("string"!=typeof o&&o)}\n ${Wu(e.fontName)}\n }\n ${SS(e,":host .bullet-text-wrapper")}\n :host .bullet-text-wrapper p {\n margin: 0;\n line-height: ${MS(a,t)}px;\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.fontColor,i=e.fontSize,n=e.activeFontColor,a=e.bulletComponent,r=e.texts,o=e.spacing,s=a?re({fontColor:t,fontSize:i,activeFontColor:n,spacing:o},a):null;if(!Array.isArray(r))return B(pS||(pS=kS``));var u=r.map(e=>e?B(gS||(gS=kS`<nami-text-list-item-wrapper .component=${0} .scaleFactor=${0}>
|
|
460
460
|
${0}
|
|
461
461
|
<div class="bullet-text-wrapper" .innerHTML="${0}"></div>
|
|
462
|
-
</nami-text-list-item-wrapper>`),this.component,this.scaleFactor,s&&B(yS||(yS=kS`<nami-symbol .component=${0} .scaleFactor=${0}></nami-symbol>`),s,this.scaleFactor),jd(e)):null);return B(bS||(bS=kS`${0}`),u)}}])}();gt([qt({type:Object})],xS.prototype,"component",void 0),gt([qt({type:Boolean})],xS.prototype,"inFocusedState",void 0),gt([qt({type:Number})],xS.prototype,"scaleFactor",void 0),xS=gt([Tt("nami-text-list")],xS);(()=>{var e,t=!0;try{new RegExp("","u"),new RegExp("😀","u"),new RegExp("\\p{P}","u")}catch(e){t=!1}if(!t){var i=null===(e=jd.Lexer)||void 0===e?void 0:e.rules,n=null==i?void 0:i.inline;n&&Object.values(n).forEach(e=>{e&&Object.keys(e).forEach(t=>{e[t]=(e=>{if(!(e instanceof RegExp))return e;if(!/\\p\{/.test(e.source))return e;var t="!\"#$%&'()*+,\\-./:;<=>?@[\\\\]^_`{|}~",i=e.source.replace(/\\p\{P\}\\p\{S\}/g,t).replace(/\\p\{P\}/g,t).replace(/\\p\{S\}/g,t),n=e.flags.replace(/u/g,"");return new RegExp(i,n)})(e[t])})})}})();var CS=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t.handleFocusIn=()=>t.setFocusState(!0),t.handleFocusOut=e=>{var i,n,a=null!==(i=e.relatedTarget)&&void 0!==i?i:null;if(!a)return t.setFocusState(!1);a===t||null!==(n=t.shadowRoot)&&void 0!==n&&n.contains(a)||t.setFocusState(!1)},t.handleFocusChanged=e=>{var i=e.detail;t.setFocusState(!0===(null==i?void 0:i.inFocusedState))},t.addEventListener("focusin",t.handleFocusIn),t.addEventListener("focusout",t.handleFocusOut),t.addEventListener("focus-changed",t.handleFocusChanged),t}return ue(e,lu),ne(e,[{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("focusin",this.handleFocusIn),this.removeEventListener("focusout",this.handleFocusOut),this.removeEventListener("focus-changed",this.handleFocusChanged)}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.minSDKVersion,n=e.backgroundBlur,a="vertical"===e.direction,r=a?"width":"height",o=a?"margin-top":"margin-left",s=e.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):U(Mu(e,!1));return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${s};\n ${Nu(e.position)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus),\n :host(.nami-focus-within){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > * {\n ${Au(i,r)}\n }\n :host > *:not(:first-child) {\n ${o}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}},{key:"setFocusState",value:function(e){this.inFocusedState!==e&&(this.inFocusedState=e,this.classList.toggle("nami-focus-within",e),this.toggleAttribute("data-nami-focused",e))}}])}();function IS(e,t){return e===t||e!=e&&t!=t}function LS(e,t){for(var i=e.length;i--;)if(IS(e[i][0],t))return i;return-1}gt([qt({type:Object})],CS.prototype,"component",void 0),gt([qt({type:Boolean})],CS.prototype,"inFocusedState",void 0),gt([qt({type:Number})],CS.prototype,"scaleFactor",void 0),gt([qt({type:Object})],CS.prototype,"minSDKVersion",void 0),CS=gt([Tt("nami-container")],CS);var _S=Array.prototype.splice;function RS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function FS(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}RS.prototype.clear=function(){this.__data__=[],this.size=0},RS.prototype.delete=function(e){var t=this.__data__,i=LS(t,e);return!(i<0)&&(i==t.length-1?t.pop():_S.call(t,i,1),--this.size,!0)},RS.prototype.get=function(e){var t=this.__data__,i=LS(t,e);return i<0?void 0:t[i][1]},RS.prototype.has=function(e){return LS(this.__data__,e)>-1},RS.prototype.set=function(e,t){var i=this.__data__,n=LS(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function WS(e){if(!FS(e))return!1;var t=An(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var OS,$S=yn["__core-js_shared__"],NS=(OS=/[^.]+$/.exec($S&&$S.keys&&$S.keys.IE_PROTO||""))?"Symbol(src)_1."+OS:"";var jS=Function.prototype.toString;function BS(e){if(null!=e){try{return jS.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var zS=/^\[object .+?Constructor\]$/,US=Function.prototype,HS=Object.prototype,GS=US.toString,VS=HS.hasOwnProperty,KS=RegExp("^"+GS.call(VS).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function XS(e){return!(!FS(e)||(t=e,NS&&NS in t))&&(WS(e)?KS:zS).test(BS(e));var t}function YS(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return XS(i)?i:void 0}var qS=YS(yn,"Map"),JS=YS(Object,"create");var QS=Object.prototype.hasOwnProperty;var ZS=Object.prototype.hasOwnProperty;function eE(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function tE(e,t){var i,n,a=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?a["string"==typeof t?"string":"hash"]:a.map}function iE(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}eE.prototype.clear=function(){this.__data__=JS?JS(null):{},this.size=0},eE.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},eE.prototype.get=function(e){var t=this.__data__;if(JS){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return QS.call(t,e)?t[e]:void 0},eE.prototype.has=function(e){var t=this.__data__;return JS?void 0!==t[e]:ZS.call(t,e)},eE.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=JS&&void 0===t?"__lodash_hash_undefined__":t,this},iE.prototype.clear=function(){this.size=0,this.__data__={hash:new eE,map:new(qS||RS),string:new eE}},iE.prototype.delete=function(e){var t=tE(this,e).delete(e);return this.size-=t?1:0,t},iE.prototype.get=function(e){return tE(this,e).get(e)},iE.prototype.has=function(e){return tE(this,e).has(e)},iE.prototype.set=function(e,t){var i=tE(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function nE(e){var t=this.__data__=new RS(e);this.size=t.size}nE.prototype.clear=function(){this.__data__=new RS,this.size=0},nE.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},nE.prototype.get=function(e){return this.__data__.get(e)},nE.prototype.has=function(e){return this.__data__.has(e)},nE.prototype.set=function(e,t){var i=this.__data__;if(i instanceof RS){var n=i.__data__;if(!qS||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new iE(n)}return i.set(e,t),this.size=i.size,this};function aE(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new iE;++t<i;)this.add(e[t])}function rE(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}aE.prototype.add=aE.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},aE.prototype.has=function(e){return this.__data__.has(e)};function oE(e,t,i,n,a,r){var o=1&i,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var h=-1,c=!0,m=2&i?new aE:void 0;for(r.set(e,t),r.set(t,e);++h<s;){var f=e[h],v=t[h];if(n)var p=o?n(v,f,h,t,e,r):n(f,v,h,e,t,r);if(void 0!==p){if(p)continue;c=!1;break}if(m){if(!rE(t,function(e,t){if(o=t,!m.has(o)&&(f===e||a(f,e,i,n,r)))return m.push(t);var o})){c=!1;break}}else if(f!==v&&!a(f,v,i,n,r)){c=!1;break}}return r.delete(e),r.delete(t),c}var sE=yn.Uint8Array;function uE(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function lE(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var dE=bn?bn.prototype:void 0,hE=dE?dE.valueOf:void 0;var cE=Object.prototype.propertyIsEnumerable,mE=Object.getOwnPropertySymbols,fE=mE?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,a=0,r=[];++i<n;){var o=e[i];t(o,i,e)&&(r[a++]=o)}return r}(mE(e),function(t){return cE.call(e,t)}))}:function(){return[]};function vE(e){return Dn(e)&&"[object Arguments]"==An(e)}var pE=Object.prototype,gE=pE.hasOwnProperty,yE=pE.propertyIsEnumerable,bE=vE(function(){return arguments}())?vE:function(e){return Dn(e)&&gE.call(e,"callee")&&!yE.call(e,"callee")};var wE="object"==typeof exports&&exports&&!exports.nodeType&&exports,kE=wE&&"object"==typeof module&&module&&!module.nodeType&&module,SE=kE&&kE.exports===wE?yn.Buffer:void 0,EE=(SE?SE.isBuffer:void 0)||function(){return!1},ME=/^(?:0|[1-9]\d*)$/;function TE(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&ME.test(e))&&e>-1&&e%1==0&&e<t}function PE(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var AE={};AE["[object Float32Array]"]=AE["[object Float64Array]"]=AE["[object Int8Array]"]=AE["[object Int16Array]"]=AE["[object Int32Array]"]=AE["[object Uint8Array]"]=AE["[object Uint8ClampedArray]"]=AE["[object Uint16Array]"]=AE["[object Uint32Array]"]=!0,AE["[object Arguments]"]=AE["[object Array]"]=AE["[object ArrayBuffer]"]=AE["[object Boolean]"]=AE["[object DataView]"]=AE["[object Date]"]=AE["[object Error]"]=AE["[object Function]"]=AE["[object Map]"]=AE["[object Number]"]=AE["[object Object]"]=AE["[object RegExp]"]=AE["[object Set]"]=AE["[object String]"]=AE["[object WeakMap]"]=!1;var DE,xE="object"==typeof exports&&exports&&!exports.nodeType&&exports,CE=xE&&"object"==typeof module&&module&&!module.nodeType&&module,IE=CE&&CE.exports===xE&&pn.process,LE=function(){try{var e=CE&&CE.require&&CE.require("util").types;return e||IE&&IE.binding&&IE.binding("util")}catch(e){}}(),_E=LE&&LE.isTypedArray,RE=_E?(DE=_E,function(e){return DE(e)}):function(e){return Dn(e)&&PE(e.length)&&!!AE[An(e)]},FE=Object.prototype.hasOwnProperty;function WE(e,t){var i=wn(e),n=!i&&bE(e),a=!i&&!n&&EE(e),r=!i&&!n&&!a&&RE(e),o=i||n||a||r,s=o?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],u=s.length;for(var l in e)!FE.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||TE(l,u))||s.push(l);return s}var OE=Object.prototype;var $E=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),NE=Object.prototype.hasOwnProperty;function jE(e){if(i=(t=e)&&t.constructor,t!==("function"==typeof i&&i.prototype||OE))return $E(e);var t,i,n=[];for(var a in Object(e))NE.call(e,a)&&"constructor"!=a&&n.push(a);return n}function BE(e){return null!=(t=e)&&PE(t.length)&&!WS(t)?WE(e):jE(e);var t}function zE(e){return function(e,t,i){var n=t(e);return wn(e)?n:function(e,t){for(var i=-1,n=t.length,a=e.length;++i<n;)e[a+i]=t[i];return e}(n,i(e))}(e,BE,fE)}var UE=Object.prototype.hasOwnProperty;var HE=YS(yn,"DataView"),GE=YS(yn,"Promise"),VE=YS(yn,"Set"),KE=YS(yn,"WeakMap"),XE="[object Map]",YE="[object Promise]",qE="[object Set]",JE="[object WeakMap]",QE="[object DataView]",ZE=BS(HE),eM=BS(qS),tM=BS(GE),iM=BS(VE),nM=BS(KE),aM=An;(HE&&aM(new HE(new ArrayBuffer(1)))!=QE||qS&&aM(new qS)!=XE||GE&&aM(GE.resolve())!=YE||VE&&aM(new VE)!=qE||KE&&aM(new KE)!=JE)&&(aM=function(e){var t=An(e),i="[object Object]"==t?e.constructor:void 0,n=i?BS(i):"";if(n)switch(n){case ZE:return QE;case eM:return XE;case tM:return YE;case iM:return qE;case nM:return JE}return t});var rM="[object Arguments]",oM="[object Array]",sM="[object Object]",uM=Object.prototype.hasOwnProperty;function lM(e,t,i,n,a,r){var o=wn(e),s=wn(t),u=o?oM:aM(e),l=s?oM:aM(t),d=(u=u==rM?sM:u)==sM,h=(l=l==rM?sM:l)==sM,c=u==l;if(c&&EE(e)){if(!EE(t))return!1;o=!0,d=!1}if(c&&!d)return r||(r=new nE),o||RE(e)?oE(e,t,i,n,a,r):function(e,t,i,n,a,r,o){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new sE(e),new sE(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return IS(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=uE;case"[object Set]":var u=1&n;if(s||(s=lE),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;n|=2,o.set(e,t);var d=oE(s(e),s(t),n,a,r,o);return o.delete(e),d;case"[object Symbol]":if(hE)return hE.call(e)==hE.call(t)}return!1}(e,t,u,i,n,a,r);if(!(1&i)){var m=d&&uM.call(e,"__wrapped__"),f=h&&uM.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new nE),a(v,p,i,n,r)}}return!!c&&(r||(r=new nE),function(e,t,i,n,a,r){var o=1&i,s=zE(e),u=s.length;if(u!=zE(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:UE.call(t,d)))return!1}var h=r.get(e),c=r.get(t);if(h&&c)return h==t&&c==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(n)var g=o?n(p,v,d,t,e,r):n(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,i,n,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,i,n,a,r))}function dM(e,t,i,n,a){return e===t||(null==e||null==t||!Dn(e)&&!Dn(t)?e!=e&&t!=t:lM(e,t,i,n,dM,a))}function hM(e,t){return dM(e,t)}var cM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component.backgroundBlur,t="vertical"===this.component.direction,i=t?"width":"height",n=t?"margin-top":"margin-left",a=this.component.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${this.component.fillImage});\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n height: 100%;\n width: 100%;\n `):U(Mu(this.component,!1));return U(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${a};\n ${e?`backdrop-filter: blur(${e}px);`:""}\n ${Nu(this.component.position)}\n ${Tu(this.component)}\n ${Ou(this.component,this.scaleFactor,!1)}\n transition: transform .5s ease-in;\n }\n :host > *:not(:first-child) {\n ${n}: ${this.component.spacing?this.component.spacing*this.scaleFactor:0}px;\n }\n :host(:focus){\n ${Mu(this.component,!0)}\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n :host > * {\n ${i}: 100%;\n }\n :host(.fade-in){\n opacity: 1;\n animation: fadeIn 0.5s ease-in\n }\n @keyframes fadeIn {\n 0% { opacity: 0; }\n 100% { opacity: 1; }\n }\n `)}},{key:"updated",value:function(){var e=this.contextProvider.state.currentGroupId;hM(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout(()=>this.classList.add("fade-in"),100),this.currentGroupId=e)}},{key:"render",value:function(){var e,t,i=this.contextProvider.state,n=i.mediaList,a=i.currentGroupId,r=i.selectedPaywall,o=i.formFactor,s=xa(this.contextProvider.productDetails,null!==(e=null==r?void 0:r.sku_menus)&&void 0!==e?e:[],(null===(t=this.component)||void 0===t?void 0:t.subsetGroup)||a);return Wa(this.contextProvider,s,this.component,n).map(([e,t])=>(this.inFocusedState="television"==o?e:this.inFocusedState,t.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))))}}])}();gt([qt({type:Object})],cM.prototype,"component",void 0),gt([qt({type:Boolean})],cM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],cM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],cM.prototype,"minSDKVersion",void 0),cM=gt([Tt("nami-product-container")],cM);var mM,fM,vM=e=>e,pM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t=this.component,i=t.imageCropping,n=t.alignment,a=t.height,r=t.width,o=t.rightMargin,s=t.spacing,u=t.hidden,l=t.blur,d="fit"===i,h=this.contextConsumer.state.formFactor,c=wu(null!=a?a:"100%",this.scaleFactor),m=wu(null!==(e="fitContent"==r?a:r)&&void 0!==e?e:"100%",this.scaleFactor),f="string"==typeof a&&a.includes("%")||void 0===a,v="phone"===h&&f?"max-height":"height";return U(`\n :host {\n display: ${"television"===h?"flex":"inline-block"};\n ${u?"display:none;":""}\n position: relative;\n ${v}: ${c};\n width: ${m};\n }\n :host img {\n transition: all 0.3s;\n /* Don't ride the host's text baseline: a strut taller than a small image\n (dots, inline logos) pushes it below the host box. Keep the inline line\n box itself, though — percent-height hosts on phone size from it. */\n vertical-align: top;\n object-fit: ${d?"contain":"cover"};\n object-position: ${n} center;\n ${v}: ${c};\n width: ${m};\n margin-right: ${o||s||0}px;\n ${l?`filter: blur(${l}px);`:""}\n flex-shrink: ${"number"==typeof r?0:1};\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.url,n=t.alt,a=t.title,r=t.focusedBorderColor,o=t.focusedFillColor,s=t.fillColor;return i?(!r&&Ka(s,o)||(this.tabIndex=0),this.ariaLabel=null!==(e=null!=n?n:a)&&void 0!==e?e:"",B(mM||(mM=vM`<img src="${0}" alt="${0}" />`),i,this.ariaLabel)):(this.tabIndex=-1,this.ariaLabel=null,B(fM||(fM=vM``)))}}])}();gt([qt({type:Object})],pM.prototype,"component",void 0),gt([qt({type:Boolean})],pM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],pM.prototype,"scaleFactor",void 0),pM=gt([Tt("nami-image")],pM);var gM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).fullscreen=!1,t.inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),!!document.querySelector("nami-paywall.nami-half-sheet-mode, nami-paywall.nami-modal-mode")||(document.body.style.background=this.component.fillColor||"transparent")}},{key:"styles",value:function(){var e;if(!this.contextConsumer||!this.component)return U("");var t=this.component,i=this.scaleFactor,n=this.contextConsumer.state.formFactor,a=t.backgroundBlur,r="vertical"===t.direction?"margin-top":"margin-left";return U(`\n :host {\n max-height: ${"television"===n?"100vh":""};\n display: ${t.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Pu(t)}\n position: var(--nami-bg-position, fixed);\n width: 100%;\n bottom: 0px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${null!==(e=t.zIndex)&&void 0!==e?e:1};\n top: 0px;\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${Mu(t,!1)}\n transition: all 0.3s;\n ${xu(t,i)}\n }\n :host(:focus){\n ${Mu(t,!0)}\n }\n :host > *:not(:first-child) {\n ${r}: ${t.spacing?t.spacing*i:0}px;\n }\n `)}},{key:"updated",value:function(){}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();gt([qt({type:Object})],gM.prototype,"component",void 0),gt([qt({type:Boolean})],gM.prototype,"fullscreen",void 0),gt([qt({type:Boolean})],gM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],gM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],gM.prototype,"minSDKVersion",void 0),gM=gt([Tt("nami-background-container")],gM);var yM,bM=e=>e,wM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).zIndex=2,t.inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t,i=this.contextConsumer,n=this.component,a=this.zIndex,r=this.scaleFactor;if(!i)return j(yM||(yM=bM``));var o=i.state.formFactor,s=n.backgroundBlur,u="phone"!==o?"width: 100%;":"",l=null!==(e=n.width)&&void 0!==e?e:n.fixedWidth,d=null!==(t=n.height)&&void 0!==t?t:n.fixedHeight,h="phone"===o?`max-width:100%;\n ${void 0!==l?`width: ${wu(l,r)};`:""}\n ${void 0!==d?`height: ${wu(d,r)};`:""}`:Lu(n,r),c="vertical"===n.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${n.hidden?"none":"flex"};\n position: relative;\n flex: 1;\n min-height: 0;\n ${Tu(n)}\n ${h}\n ${u}\n ${function(e){var t,i,n=e.verticalAlignment,a=e.horizontalAlignment,r=e.direction,o=n?du[n]:void 0,s=a?du[a]:void 0;return"vertical"===r?(t=null!=s?s:"center",i=null!=o?o:"start"):(t=null!=o?o:"center",i=null!=s?s:"start"),`${cu("align-items",t)}${cu("justify-content",i)}`}(n)}\n ${s?`backdrop-filter: blur(${s}px);`:""}\n z-index: ${a};\n transition: all 0.3s;\n overflow-y: ${"television"===o?"hidden":"scroll"};\n overflow-x: hidden;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n ${xu(n,r)}\n /* The footer is position:absolute over this container; inset the\n scroll end by its measured height (--nami-footer-height, set by\n the paywall screen) so bottom content is not hidden behind it. */\n padding-bottom: calc(${bu(r,n.bottomPadding)}px + var(--nami-footer-height, 0px));\n ${Mu(n,!1)}\n }\n :host::-webkit-scrollbar {\n display: none;\n }\n :host(:focus){\n ${Mu(n,!0)}\n }\n :host > * {\n width: 100%;\n }\n :host > *:not(:first-child) {\n ${c}: ${n.spacing?n.spacing*r:0}px;\n }\n `)}},{key:"firstUpdated",value:function(){var e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}},{key:"render",value:function(){var e;return(null===(e=this.component.components)||void 0===e?void 0:e.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))||[]}}])}();gt([qt({type:Object})],wM.prototype,"component",void 0),gt([qt({type:Number})],wM.prototype,"zIndex",void 0),gt([qt({type:Boolean})],wM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],wM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],wM.prototype,"minSDKVersion",void 0),wM=gt([Tt("nami-content-container")],wM);var kM,SM=e=>e,EM=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleClick=e=>{e.preventDefault(),gs({contextProvider:t.contextProvider,onTap:t.component.onTap})},t.addEventListener("click",t._handleClick),t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t,i=ju("active",this.component.components[0]),n=ju("inactive",this.component.components[0]);return U(`\n :host {\n box-sizing: border-box;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n position: relative;\n ${Tu(this.component)}\n ${Mu(this.component,!1)}\n ${Ou(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n }\n :host(:focus){\n ${Mu(this.component,!0)}\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n .toggle{\n ${e=this.component,t=this.scaleFactor,`\n position: absolute;\n top: ${bu(t,e.topPadding)}px;\n bottom: ${bu(t,e.bottomPadding)}px;\n width: calc(50% - ${bu(t,e.leftPadding)/2}px) !important;\n `}\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Bu(n,this.scaleFactor,!1)}\n }\n\n :host(:focus) .toggle{\n ${Bu(i,this.scaleFactor,!0)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n left: ${this.component.leftPadding?Number(this.component.leftPadding)*this.scaleFactor:0}px;\n ${Mu(i,!0)}\n ${zu(i,this.scaleFactor)}\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n right: ${this.component.rightPadding?Number(this.component.rightPadding)*this.scaleFactor:0}px;\n ${Mu(i,!0)}\n ${zu(i,this.scaleFactor)}\n `)}},{key:"render",value:function(){this.role="tablist";var e=this.component.components.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return B(kM||(kM=SM`${0}<div class="toggle"></div>`),e)}}])}();gt([qt({type:Object})],EM.prototype,"component",void 0),gt([qt({type:Boolean})],EM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],EM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],EM.prototype,"minSDKVersion",void 0),EM=gt([Tt("nami-segment-picker")],EM);var MM,TM=e=>e,PM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{t._updateFormState(),t.requestUpdate("component")},t._handleHover=()=>{t.inFocusedState=!0},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this._isActive=!!this.component.checked,this.classList.toggle("active",this._isActive),this.component.formId&&this._updateFormState(),this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("mouseover",this._handleHover),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_getParentPicker",value:function(){var e=this.getRootNode();return e instanceof ShadowRoot?e.host:null}},{key:"_getParentFormId",value:function(){var e;return null===(e=this._getParentPicker())||void 0===e?void 0:e.component.formId}},{key:"_updateFormState",value:function(){if(this.contextProvider)if(this.component.formId){var e=this._getParentFormId();e&&this.contextProvider.setFormState(e,this.component.formId)}else this.component.id&&this.contextProvider.setCurrentGroupData(this.component.id,this.component.text||"")}},{key:"updated",value:function(e){var t;if(e.has("component")&&this.contextProvider){var i=null!==(t=e.get("component"))&&void 0!==t?t:this.component;if(i.formId){var n=this._getParentFormId();n&&this.contextProvider.state.formStates[n]&&(this._isActive=this.contextProvider.state.formStates[n]===i.formId)}else this._isActive=hM(i.id,this.contextProvider.state.currentGroupId);if(this.classList.toggle("active",this._isActive),this._isActive){var a=this.getRootNode();if(a instanceof ShadowRoot)a.querySelectorAll("nami-segment-picker-item").forEach(e=>{e!==this&&e.requestUpdate("component",e)})}}}},{key:"styles",value:function(){var e,t,i=ju("active",this.component),n=ju("inactive",this.component);return U(`\n :host {\n box-sizing: border-box;\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Bu(re({},n,this.component),this.scaleFactor,this.inFocusedState)}\n ${Ru(null!==(e=this.component.inactiveDropShadow)&&void 0!==e?e:this.component.dropShadow)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${zu(re({},i,this.component),this.scaleFactor)}\n ${Ru(null!==(t=this.component.activeDropShadow)&&void 0!==t?t:this.component.dropShadow)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.role="tab",this.ariaSelected=`${this._isActive}`,this.ariaLabel=this.component.text||"",B(MM||(MM=TM`<input type="radio"
|
|
462
|
+
</nami-text-list-item-wrapper>`),this.component,this.scaleFactor,s&&B(yS||(yS=kS`<nami-symbol .component=${0} .scaleFactor=${0}></nami-symbol>`),s,this.scaleFactor),jd(e)):null);return B(bS||(bS=kS`${0}`),u)}}])}();gt([qt({type:Object})],xS.prototype,"component",void 0),gt([qt({type:Boolean})],xS.prototype,"inFocusedState",void 0),gt([qt({type:Number})],xS.prototype,"scaleFactor",void 0),xS=gt([Tt("nami-text-list")],xS);(()=>{var e,t=!0;try{new RegExp("","u"),new RegExp("😀","u"),new RegExp("\\p{P}","u")}catch(e){t=!1}if(!t){var i=null===(e=jd.Lexer)||void 0===e?void 0:e.rules,n=null==i?void 0:i.inline;n&&Object.values(n).forEach(e=>{e&&Object.keys(e).forEach(t=>{e[t]=(e=>{if(!(e instanceof RegExp))return e;if(!/\\p\{/.test(e.source))return e;var t="!\"#$%&'()*+,\\-./:;<=>?@[\\\\]^_`{|}~",i=e.source.replace(/\\p\{P\}\\p\{S\}/g,t).replace(/\\p\{P\}/g,t).replace(/\\p\{S\}/g,t),n=e.flags.replace(/u/g,"");return new RegExp(i,n)})(e[t])})})}})();var CS=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t.handleFocusIn=()=>t.setFocusState(!0),t.handleFocusOut=e=>{var i,n,a=null!==(i=e.relatedTarget)&&void 0!==i?i:null;if(!a)return t.setFocusState(!1);a===t||null!==(n=t.shadowRoot)&&void 0!==n&&n.contains(a)||t.setFocusState(!1)},t.handleFocusChanged=e=>{var i=e.detail;t.setFocusState(!0===(null==i?void 0:i.inFocusedState))},t.addEventListener("focusin",t.handleFocusIn),t.addEventListener("focusout",t.handleFocusOut),t.addEventListener("focus-changed",t.handleFocusChanged),t}return ue(e,lu),ne(e,[{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("focusin",this.handleFocusIn),this.removeEventListener("focusout",this.handleFocusOut),this.removeEventListener("focus-changed",this.handleFocusChanged)}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.minSDKVersion,n=e.backgroundBlur,a="vertical"===e.direction,r=a?"width":"height",o=a?"margin-top":"margin-left",s=e.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):U(Mu(e,!1)),u=Boolean(e.fillColor||e.fillImage),l=e.roundBorders,d=Array.isArray(l)&&l.length>0&&l.length<4,h=u&&d?"overflow: hidden;":"";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${s};\n ${h}\n ${Nu(e.position)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus),\n :host(.nami-focus-within){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > * {\n ${Au(i,r)}\n }\n :host > *:not(:first-child) {\n ${o}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}},{key:"setFocusState",value:function(e){this.inFocusedState!==e&&(this.inFocusedState=e,this.classList.toggle("nami-focus-within",e),this.toggleAttribute("data-nami-focused",e))}}])}();function IS(e,t){return e===t||e!=e&&t!=t}function LS(e,t){for(var i=e.length;i--;)if(IS(e[i][0],t))return i;return-1}gt([qt({type:Object})],CS.prototype,"component",void 0),gt([qt({type:Boolean})],CS.prototype,"inFocusedState",void 0),gt([qt({type:Number})],CS.prototype,"scaleFactor",void 0),gt([qt({type:Object})],CS.prototype,"minSDKVersion",void 0),CS=gt([Tt("nami-container")],CS);var _S=Array.prototype.splice;function RS(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function FS(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}RS.prototype.clear=function(){this.__data__=[],this.size=0},RS.prototype.delete=function(e){var t=this.__data__,i=LS(t,e);return!(i<0)&&(i==t.length-1?t.pop():_S.call(t,i,1),--this.size,!0)},RS.prototype.get=function(e){var t=this.__data__,i=LS(t,e);return i<0?void 0:t[i][1]},RS.prototype.has=function(e){return LS(this.__data__,e)>-1},RS.prototype.set=function(e,t){var i=this.__data__,n=LS(i,e);return n<0?(++this.size,i.push([e,t])):i[n][1]=t,this};function WS(e){if(!FS(e))return!1;var t=An(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var OS,$S=yn["__core-js_shared__"],NS=(OS=/[^.]+$/.exec($S&&$S.keys&&$S.keys.IE_PROTO||""))?"Symbol(src)_1."+OS:"";var jS=Function.prototype.toString;function BS(e){if(null!=e){try{return jS.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var zS=/^\[object .+?Constructor\]$/,US=Function.prototype,HS=Object.prototype,GS=US.toString,VS=HS.hasOwnProperty,KS=RegExp("^"+GS.call(VS).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function XS(e){return!(!FS(e)||(t=e,NS&&NS in t))&&(WS(e)?KS:zS).test(BS(e));var t}function YS(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return XS(i)?i:void 0}var qS=YS(yn,"Map"),JS=YS(Object,"create");var QS=Object.prototype.hasOwnProperty;var ZS=Object.prototype.hasOwnProperty;function eE(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}function tE(e,t){var i,n,a=e.__data__;return("string"==(n=typeof(i=t))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==i:null===i)?a["string"==typeof t?"string":"hash"]:a.map}function iE(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}eE.prototype.clear=function(){this.__data__=JS?JS(null):{},this.size=0},eE.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},eE.prototype.get=function(e){var t=this.__data__;if(JS){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return QS.call(t,e)?t[e]:void 0},eE.prototype.has=function(e){var t=this.__data__;return JS?void 0!==t[e]:ZS.call(t,e)},eE.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=JS&&void 0===t?"__lodash_hash_undefined__":t,this},iE.prototype.clear=function(){this.size=0,this.__data__={hash:new eE,map:new(qS||RS),string:new eE}},iE.prototype.delete=function(e){var t=tE(this,e).delete(e);return this.size-=t?1:0,t},iE.prototype.get=function(e){return tE(this,e).get(e)},iE.prototype.has=function(e){return tE(this,e).has(e)},iE.prototype.set=function(e,t){var i=tE(this,e),n=i.size;return i.set(e,t),this.size+=i.size==n?0:1,this};function nE(e){var t=this.__data__=new RS(e);this.size=t.size}nE.prototype.clear=function(){this.__data__=new RS,this.size=0},nE.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},nE.prototype.get=function(e){return this.__data__.get(e)},nE.prototype.has=function(e){return this.__data__.has(e)},nE.prototype.set=function(e,t){var i=this.__data__;if(i instanceof RS){var n=i.__data__;if(!qS||n.length<199)return n.push([e,t]),this.size=++i.size,this;i=this.__data__=new iE(n)}return i.set(e,t),this.size=i.size,this};function aE(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new iE;++t<i;)this.add(e[t])}function rE(e,t){for(var i=-1,n=null==e?0:e.length;++i<n;)if(t(e[i],i,e))return!0;return!1}aE.prototype.add=aE.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},aE.prototype.has=function(e){return this.__data__.has(e)};function oE(e,t,i,n,a,r){var o=1&i,s=e.length,u=t.length;if(s!=u&&!(o&&u>s))return!1;var l=r.get(e),d=r.get(t);if(l&&d)return l==t&&d==e;var h=-1,c=!0,m=2&i?new aE:void 0;for(r.set(e,t),r.set(t,e);++h<s;){var f=e[h],v=t[h];if(n)var p=o?n(v,f,h,t,e,r):n(f,v,h,e,t,r);if(void 0!==p){if(p)continue;c=!1;break}if(m){if(!rE(t,function(e,t){if(o=t,!m.has(o)&&(f===e||a(f,e,i,n,r)))return m.push(t);var o})){c=!1;break}}else if(f!==v&&!a(f,v,i,n,r)){c=!1;break}}return r.delete(e),r.delete(t),c}var sE=yn.Uint8Array;function uE(e){var t=-1,i=Array(e.size);return e.forEach(function(e,n){i[++t]=[n,e]}),i}function lE(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var dE=bn?bn.prototype:void 0,hE=dE?dE.valueOf:void 0;var cE=Object.prototype.propertyIsEnumerable,mE=Object.getOwnPropertySymbols,fE=mE?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,n=null==e?0:e.length,a=0,r=[];++i<n;){var o=e[i];t(o,i,e)&&(r[a++]=o)}return r}(mE(e),function(t){return cE.call(e,t)}))}:function(){return[]};function vE(e){return Dn(e)&&"[object Arguments]"==An(e)}var pE=Object.prototype,gE=pE.hasOwnProperty,yE=pE.propertyIsEnumerable,bE=vE(function(){return arguments}())?vE:function(e){return Dn(e)&&gE.call(e,"callee")&&!yE.call(e,"callee")};var wE="object"==typeof exports&&exports&&!exports.nodeType&&exports,kE=wE&&"object"==typeof module&&module&&!module.nodeType&&module,SE=kE&&kE.exports===wE?yn.Buffer:void 0,EE=(SE?SE.isBuffer:void 0)||function(){return!1},ME=/^(?:0|[1-9]\d*)$/;function TE(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&ME.test(e))&&e>-1&&e%1==0&&e<t}function PE(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}var AE={};AE["[object Float32Array]"]=AE["[object Float64Array]"]=AE["[object Int8Array]"]=AE["[object Int16Array]"]=AE["[object Int32Array]"]=AE["[object Uint8Array]"]=AE["[object Uint8ClampedArray]"]=AE["[object Uint16Array]"]=AE["[object Uint32Array]"]=!0,AE["[object Arguments]"]=AE["[object Array]"]=AE["[object ArrayBuffer]"]=AE["[object Boolean]"]=AE["[object DataView]"]=AE["[object Date]"]=AE["[object Error]"]=AE["[object Function]"]=AE["[object Map]"]=AE["[object Number]"]=AE["[object Object]"]=AE["[object RegExp]"]=AE["[object Set]"]=AE["[object String]"]=AE["[object WeakMap]"]=!1;var DE,xE="object"==typeof exports&&exports&&!exports.nodeType&&exports,CE=xE&&"object"==typeof module&&module&&!module.nodeType&&module,IE=CE&&CE.exports===xE&&pn.process,LE=function(){try{var e=CE&&CE.require&&CE.require("util").types;return e||IE&&IE.binding&&IE.binding("util")}catch(e){}}(),_E=LE&&LE.isTypedArray,RE=_E?(DE=_E,function(e){return DE(e)}):function(e){return Dn(e)&&PE(e.length)&&!!AE[An(e)]},FE=Object.prototype.hasOwnProperty;function WE(e,t){var i=wn(e),n=!i&&bE(e),a=!i&&!n&&EE(e),r=!i&&!n&&!a&&RE(e),o=i||n||a||r,s=o?function(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n}(e.length,String):[],u=s.length;for(var l in e)!FE.call(e,l)||o&&("length"==l||a&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||TE(l,u))||s.push(l);return s}var OE=Object.prototype;var $E=function(e,t){return function(i){return e(t(i))}}(Object.keys,Object),NE=Object.prototype.hasOwnProperty;function jE(e){if(i=(t=e)&&t.constructor,t!==("function"==typeof i&&i.prototype||OE))return $E(e);var t,i,n=[];for(var a in Object(e))NE.call(e,a)&&"constructor"!=a&&n.push(a);return n}function BE(e){return null!=(t=e)&&PE(t.length)&&!WS(t)?WE(e):jE(e);var t}function zE(e){return function(e,t,i){var n=t(e);return wn(e)?n:function(e,t){for(var i=-1,n=t.length,a=e.length;++i<n;)e[a+i]=t[i];return e}(n,i(e))}(e,BE,fE)}var UE=Object.prototype.hasOwnProperty;var HE=YS(yn,"DataView"),GE=YS(yn,"Promise"),VE=YS(yn,"Set"),KE=YS(yn,"WeakMap"),XE="[object Map]",YE="[object Promise]",qE="[object Set]",JE="[object WeakMap]",QE="[object DataView]",ZE=BS(HE),eM=BS(qS),tM=BS(GE),iM=BS(VE),nM=BS(KE),aM=An;(HE&&aM(new HE(new ArrayBuffer(1)))!=QE||qS&&aM(new qS)!=XE||GE&&aM(GE.resolve())!=YE||VE&&aM(new VE)!=qE||KE&&aM(new KE)!=JE)&&(aM=function(e){var t=An(e),i="[object Object]"==t?e.constructor:void 0,n=i?BS(i):"";if(n)switch(n){case ZE:return QE;case eM:return XE;case tM:return YE;case iM:return qE;case nM:return JE}return t});var rM="[object Arguments]",oM="[object Array]",sM="[object Object]",uM=Object.prototype.hasOwnProperty;function lM(e,t,i,n,a,r){var o=wn(e),s=wn(t),u=o?oM:aM(e),l=s?oM:aM(t),d=(u=u==rM?sM:u)==sM,h=(l=l==rM?sM:l)==sM,c=u==l;if(c&&EE(e)){if(!EE(t))return!1;o=!0,d=!1}if(c&&!d)return r||(r=new nE),o||RE(e)?oE(e,t,i,n,a,r):function(e,t,i,n,a,r,o){switch(i){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!r(new sE(e),new sE(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return IS(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=uE;case"[object Set]":var u=1&n;if(s||(s=lE),e.size!=t.size&&!u)return!1;var l=o.get(e);if(l)return l==t;n|=2,o.set(e,t);var d=oE(s(e),s(t),n,a,r,o);return o.delete(e),d;case"[object Symbol]":if(hE)return hE.call(e)==hE.call(t)}return!1}(e,t,u,i,n,a,r);if(!(1&i)){var m=d&&uM.call(e,"__wrapped__"),f=h&&uM.call(t,"__wrapped__");if(m||f){var v=m?e.value():e,p=f?t.value():t;return r||(r=new nE),a(v,p,i,n,r)}}return!!c&&(r||(r=new nE),function(e,t,i,n,a,r){var o=1&i,s=zE(e),u=s.length;if(u!=zE(t).length&&!o)return!1;for(var l=u;l--;){var d=s[l];if(!(o?d in t:UE.call(t,d)))return!1}var h=r.get(e),c=r.get(t);if(h&&c)return h==t&&c==e;var m=!0;r.set(e,t),r.set(t,e);for(var f=o;++l<u;){var v=e[d=s[l]],p=t[d];if(n)var g=o?n(p,v,d,t,e,r):n(v,p,d,e,t,r);if(!(void 0===g?v===p||a(v,p,i,n,r):g)){m=!1;break}f||(f="constructor"==d)}if(m&&!f){var y=e.constructor,b=t.constructor;y==b||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof b&&b instanceof b||(m=!1)}return r.delete(e),r.delete(t),m}(e,t,i,n,a,r))}function dM(e,t,i,n,a){return e===t||(null==e||null==t||!Dn(e)&&!Dn(t)?e!=e&&t!=t:lM(e,t,i,n,dM,a))}function hM(e,t){return dM(e,t)}var cM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component.backgroundBlur,t="vertical"===this.component.direction,i=t?"width":"height",n=t?"margin-top":"margin-left",a=this.component.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${this.component.fillImage});\n background-size: cover;\n background-position: center;\n background-repeat: no-repeat;\n height: 100%;\n width: 100%;\n `):U(Mu(this.component,!1));return U(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${a};\n ${e?`backdrop-filter: blur(${e}px);`:""}\n ${Nu(this.component.position)}\n ${Tu(this.component)}\n ${Ou(this.component,this.scaleFactor,!1)}\n transition: transform .5s ease-in;\n }\n :host > *:not(:first-child) {\n ${n}: ${this.component.spacing?this.component.spacing*this.scaleFactor:0}px;\n }\n :host(:focus){\n ${Mu(this.component,!0)}\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n :host > * {\n ${i}: 100%;\n }\n :host(.fade-in){\n opacity: 1;\n animation: fadeIn 0.5s ease-in\n }\n @keyframes fadeIn {\n 0% { opacity: 0; }\n 100% { opacity: 1; }\n }\n `)}},{key:"updated",value:function(){var e=this.contextProvider.state.currentGroupId;hM(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout(()=>this.classList.add("fade-in"),100),this.currentGroupId=e)}},{key:"render",value:function(){var e,t,i=this.contextProvider.state,n=i.mediaList,a=i.currentGroupId,r=i.selectedPaywall,o=i.formFactor,s=xa(this.contextProvider.productDetails,null!==(e=null==r?void 0:r.sku_menus)&&void 0!==e?e:[],(null===(t=this.component)||void 0===t?void 0:t.subsetGroup)||a);return Wa(this.contextProvider,s,this.component,n).map(([e,t])=>(this.inFocusedState="television"==o?e:this.inFocusedState,t.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))))}}])}();gt([qt({type:Object})],cM.prototype,"component",void 0),gt([qt({type:Boolean})],cM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],cM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],cM.prototype,"minSDKVersion",void 0),cM=gt([Tt("nami-product-container")],cM);var mM,fM,vM=e=>e;function pM(e){if("number"==typeof e)return 0!==e;if("string"==typeof e){var t=parseFloat(e);return!isNaN(t)&&0!==t}return!1}var gM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t=this.component,i=t.imageCropping,n=t.alignment,a=t.height,r=t.width,o=t.rightMargin,s=t.spacing,u=t.hidden,l=t.blur,d="fit"===i,h=this.contextConsumer.state.formFactor,c=wu(null!=a?a:"100%",this.scaleFactor),m=wu(null!==(e="fitContent"==r?a:r)&&void 0!==e?e:"100%",this.scaleFactor),f="string"==typeof a&&a.includes("%")||void 0===a,v="phone"===h&&f?"max-height":"height",p=pM(this.component.moveX)||pM(this.component.moveY);return U(`\n :host {\n display: ${"television"===h?"flex":"inline-block"};\n ${u?"display:none;":""}\n position: relative;\n ${p?Cu(this.component):""}\n ${v}: ${c};\n width: ${m};\n }\n :host img {\n transition: all 0.3s;\n /* Don't ride the host's text baseline: a strut taller than a small image\n (dots, inline logos) pushes it below the host box. Keep the inline line\n box itself, though — percent-height hosts on phone size from it. */\n vertical-align: top;\n object-fit: ${d?"contain":"cover"};\n object-position: ${n} center;\n ${v}: ${c};\n width: ${m};\n margin-right: ${o||s||0}px;\n ${l?`filter: blur(${l}px);`:""}\n flex-shrink: ${"number"==typeof r?0:1};\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.url,n=t.alt,a=t.title,r=t.focusedBorderColor,o=t.focusedFillColor,s=t.fillColor;return i?(!r&&Ka(s,o)||(this.tabIndex=0),this.ariaLabel=null!==(e=null!=n?n:a)&&void 0!==e?e:"",B(mM||(mM=vM`<img src="${0}" alt="${0}" />`),i,this.ariaLabel)):(this.tabIndex=-1,this.ariaLabel=null,B(fM||(fM=vM``)))}}])}();gt([qt({type:Object})],gM.prototype,"component",void 0),gt([qt({type:Boolean})],gM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],gM.prototype,"scaleFactor",void 0),gM=gt([Tt("nami-image")],gM);var yM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).fullscreen=!1,t.inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),!!document.querySelector("nami-paywall.nami-half-sheet-mode, nami-paywall.nami-modal-mode")||(document.body.style.background=this.component.fillColor||"transparent")}},{key:"styles",value:function(){var e;if(!this.contextConsumer||!this.component)return U("");var t=this.component,i=this.scaleFactor,n=this.contextConsumer.state.formFactor,a=t.backgroundBlur,r="vertical"===t.direction?"margin-top":"margin-left";return U(`\n :host {\n max-height: ${"television"===n?"100vh":""};\n display: ${t.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Pu(t)}\n position: var(--nami-bg-position, fixed);\n width: 100%;\n bottom: 0px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${null!==(e=t.zIndex)&&void 0!==e?e:1};\n top: 0px;\n ${a?`backdrop-filter: blur(${a}px);`:""}\n ${Mu(t,!1)}\n transition: all 0.3s;\n ${xu(t,i)}\n }\n :host(:focus){\n ${Mu(t,!0)}\n }\n :host > *:not(:first-child) {\n ${r}: ${t.spacing?t.spacing*i:0}px;\n }\n `)}},{key:"updated",value:function(){}},{key:"render",value:function(){var e;return(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();gt([qt({type:Object})],yM.prototype,"component",void 0),gt([qt({type:Boolean})],yM.prototype,"fullscreen",void 0),gt([qt({type:Boolean})],yM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],yM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],yM.prototype,"minSDKVersion",void 0),yM=gt([Tt("nami-background-container")],yM);var bM,wM=e=>e,kM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).zIndex=2,t.inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t,i=this.contextConsumer,n=this.component,a=this.zIndex,r=this.scaleFactor;if(!i)return j(bM||(bM=wM``));var o=i.state.formFactor,s=n.backgroundBlur,u="phone"!==o?"width: 100%;":"",l=null!==(e=n.width)&&void 0!==e?e:n.fixedWidth,d=null!==(t=n.height)&&void 0!==t?t:n.fixedHeight,h="phone"===o?`max-width:100%;\n ${void 0!==l?`width: ${wu(l,r)};`:""}\n ${void 0!==d?`height: ${wu(d,r)};`:""}`:Lu(n,r),c="vertical"===n.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${n.hidden?"none":"flex"};\n position: relative;\n flex: 1;\n min-height: 0;\n ${Tu(n)}\n ${h}\n ${u}\n ${function(e){var t,i,n=e.verticalAlignment,a=e.horizontalAlignment,r=e.direction,o=n?du[n]:void 0,s=a?du[a]:void 0;return"vertical"===r?(t=null!=s?s:"center",i=null!=o?o:"start"):(t=null!=o?o:"center",i=null!=s?s:"start"),`${cu("align-items",t)}${cu("justify-content",i)}`}(n)}\n ${s?`backdrop-filter: blur(${s}px);`:""}\n z-index: ${a};\n transition: all 0.3s;\n overflow-y: ${"television"===o?"hidden":"scroll"};\n overflow-x: hidden;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n -ms-overflow-style: none; /* IE and Edge */\n scrollbar-width: none; /* Firefox */\n ${xu(n,r)}\n /* The footer is position:absolute over this container; inset the\n scroll end by its measured height (--nami-footer-height, set by\n the paywall screen) so bottom content is not hidden behind it. */\n padding-bottom: calc(${bu(r,n.bottomPadding)}px + var(--nami-footer-height, 0px));\n ${Mu(n,!1)}\n }\n :host::-webkit-scrollbar {\n display: none;\n }\n :host(:focus){\n ${Mu(n,!0)}\n }\n :host > * {\n width: 100%;\n }\n :host > *:not(:first-child) {\n ${c}: ${n.spacing?n.spacing*r:0}px;\n }\n `)}},{key:"firstUpdated",value:function(){var e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}},{key:"render",value:function(){var e;return(null===(e=this.component.components)||void 0===e?void 0:e.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))||[]}}])}();gt([qt({type:Object})],kM.prototype,"component",void 0),gt([qt({type:Number})],kM.prototype,"zIndex",void 0),gt([qt({type:Boolean})],kM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],kM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],kM.prototype,"minSDKVersion",void 0),kM=gt([Tt("nami-content-container")],kM);var SM,EM=e=>e,MM=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleClick=e=>{e.preventDefault(),gs({contextProvider:t.contextProvider,onTap:t.component.onTap})},t.addEventListener("click",t._handleClick),t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t,i=ju("active",this.component.components[0]),n=ju("inactive",this.component.components[0]);return U(`\n :host {\n box-sizing: border-box;\n -webkit-tap-highlight-color: transparent;\n cursor: pointer;\n display: flex;\n flex: 0 0 auto;\n position: relative;\n ${Tu(this.component)}\n ${Mu(this.component,!1)}\n ${Ou(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n }\n :host(:focus){\n ${Mu(this.component,!0)}\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n .toggle{\n ${e=this.component,t=this.scaleFactor,`\n position: absolute;\n top: ${bu(t,e.topPadding)}px;\n bottom: ${bu(t,e.bottomPadding)}px;\n width: calc(50% - ${bu(t,e.leftPadding)/2}px) !important;\n `}\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Bu(n,this.scaleFactor,!1)}\n }\n\n :host(:focus) .toggle{\n ${Bu(i,this.scaleFactor,!0)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n left: ${this.component.leftPadding?Number(this.component.leftPadding)*this.scaleFactor:0}px;\n ${Mu(i,!0)}\n ${zu(i,this.scaleFactor)}\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n right: ${this.component.rightPadding?Number(this.component.rightPadding)*this.scaleFactor:0}px;\n ${Mu(i,!0)}\n ${zu(i,this.scaleFactor)}\n `)}},{key:"render",value:function(){this.role="tablist";var e=this.component.components.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return B(SM||(SM=EM`${0}<div class="toggle"></div>`),e)}}])}();gt([qt({type:Object})],MM.prototype,"component",void 0),gt([qt({type:Boolean})],MM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],MM.prototype,"scaleFactor",void 0),gt([qt({type:Object})],MM.prototype,"minSDKVersion",void 0),MM=gt([Tt("nami-segment-picker")],MM);var TM,PM=e=>e,AM=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{t._updateFormState(),t.requestUpdate("component")},t._handleHover=()=>{t.inFocusedState=!0},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this._isActive=!!this.component.checked,this.classList.toggle("active",this._isActive),this.component.formId&&this._updateFormState(),this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("mouseover",this._handleHover),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_getParentPicker",value:function(){var e=this.getRootNode();return e instanceof ShadowRoot?e.host:null}},{key:"_getParentFormId",value:function(){var e;return null===(e=this._getParentPicker())||void 0===e?void 0:e.component.formId}},{key:"_updateFormState",value:function(){if(this.contextProvider)if(this.component.formId){var e=this._getParentFormId();e&&this.contextProvider.setFormState(e,this.component.formId)}else this.component.id&&this.contextProvider.setCurrentGroupData(this.component.id,this.component.text||"")}},{key:"updated",value:function(e){var t;if(e.has("component")&&this.contextProvider){var i=null!==(t=e.get("component"))&&void 0!==t?t:this.component;if(i.formId){var n=this._getParentFormId();n&&this.contextProvider.state.formStates[n]&&(this._isActive=this.contextProvider.state.formStates[n]===i.formId)}else this._isActive=hM(i.id,this.contextProvider.state.currentGroupId);if(this.classList.toggle("active",this._isActive),this._isActive){var a=this.getRootNode();if(a instanceof ShadowRoot)a.querySelectorAll("nami-segment-picker-item").forEach(e=>{e!==this&&e.requestUpdate("component",e)})}}}},{key:"styles",value:function(){var e,t,i=ju("active",this.component),n=ju("inactive",this.component);return U(`\n :host {\n box-sizing: border-box;\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Bu(re({},n,this.component),this.scaleFactor,this.inFocusedState)}\n ${Ru(null!==(e=this.component.inactiveDropShadow)&&void 0!==e?e:this.component.dropShadow)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${zu(re({},i,this.component),this.scaleFactor)}\n ${Ru(null!==(t=this.component.activeDropShadow)&&void 0!==t?t:this.component.dropShadow)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.role="tab",this.ariaSelected=`${this._isActive}`,this.ariaLabel=this.component.text||"",B(TM||(TM=PM`<input type="radio"
|
|
463
463
|
autocomplete="off"
|
|
464
464
|
id="${0}"
|
|
465
465
|
name="${0}"
|
|
@@ -467,7 +467,7 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
467
467
|
checked="${0}"
|
|
468
468
|
|
|
469
469
|
/>
|
|
470
|
-
<label for="${0}">${0}</label>`),this.component.text,this.component.text,this.component.text,this._isActive,this.component.text,this.component.text)}}])}();gt([qt({type:Object})],PM.prototype,"component",void 0),gt([qt({type:Boolean})],PM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],PM.prototype,"scaleFactor",void 0),gt([Jt()],PM.prototype,"_isActive",void 0),PM=gt([Tt("nami-segment-picker-item")],PM);var AM=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},DM=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=xM},xM=Number.MAX_SAFE_INTEGER||9007199254740991,CM=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),IM=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),LM=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),_M="manifest",RM="level",FM="audioTrack",WM="subtitleTrack",OM="main",$M="audio",NM="subtitle",jM=function(){return ne(function e(t,i=0,n=0){Q(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=i,this.totalWeight_=n},[{key:"sample",value:function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}])}(),BM=function(){return ne(function e(t,i,n,a=100){Q(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new jM(t),this.fast_=new jM(i),this.defaultTTFB_=a,this.ttfb_=new jM(t)},[{key:"update",value:function(e,t){var i=this.slow_,n=this.fast_,a=this.ttfb_;i.halfLife!==e&&(this.slow_=new jM(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new jM(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new jM(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}])}();function zM(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function UM(){return UM=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},UM.apply(null,arguments)}function HM(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function GM(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?HM(Object(i),!0).forEach(function(t){zM(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):HM(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var VM=ne(function e(t,i){Q(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var n=`[${t}]:`;this.trace=KM,this.debug=i.debug.bind(null,n),this.log=i.log.bind(null,n),this.warn=i.warn.bind(null,n),this.info=i.info.bind(null,n),this.error=i.error.bind(null,n)}),KM=function(){},XM={trace:KM,debug:KM,log:KM,warn:KM,info:KM,error:KM};function YM(){return UM({},XM)}function qM(e,t,i){return t[e]?t[e].bind(t):function(e,t){var i=self.console[e];return i?i.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):KM}(e,i)}var JM=YM();var QM=JM;function ZM(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function eT(e,t){var i=Object.keys(e),n=Object.keys(t),a=i.length,r=n.length;return!a||!r||a===r&&!i.some(e=>-1===n.indexOf(e))}function tT(e,t=!1){if("undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,r,o,s=e.length,u="",l=0;l<s;){if(0===(a=e[l++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:r=e[l++],u+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[l++],o=e[l++],u+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return u}function iT(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);n.length<2&&(n="0"+n),t+=n}return t}function nT(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function aT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var rT,oT={exports:{}};var sT,uT,lT,dT,hT,cT=rT?oT.exports:(rT=1,sT=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,uT=/^(?=([^\/?#]*))\1([^]*)$/,lT=/(?:\/|^)\.(?=\/)/g,dT=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,oT.exports=hT={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=hT.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=hT.normalizePath(n.path),hT.buildURLFromParts(n)}var a=hT.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=hT.normalizePath(a.path),hT.buildURLFromParts(a)):t;var r=hT.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){var o=uT.exec(r.path);r.netLoc=o[1],r.path=o[2]}r.netLoc&&!r.path&&(r.path="/");var s={scheme:r.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(s.netLoc=r.netLoc,"/"!==a.path[0]))if(a.path){var u=r.path,l=u.substring(0,u.lastIndexOf("/")+1)+a.path;s.path=hT.normalizePath(l)}else s.path=r.path,a.params||(s.params=r.params,a.query||(s.query=r.query));return null===s.path&&(s.path=i.alwaysNormalize?hT.normalizePath(a.path):a.path),hT.buildURLFromParts(s)},parseURL:function(e){var t=sT.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(lT,"");e.length!==(e=e.replace(dT,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}),mT=ne(function e(){Q(this,e),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}}),fT="audio",vT="video",pT="audiovideo",gT=function(){return ne(function e(t){Q(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(e,t){var i=kT(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")},[{key:"setByteRange",value:function(e,t){var i,n=e.split("@",2);i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){return null===this._streams&&(this._streams={[fT]:null,[vT]:null,[pT]:null}),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new mT),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=cT.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[fT]=null,e[vT]=null,e[pT]=null}}])}();function yT(e){return"initSegment"!==e.sn}var bT=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i]))._decryptdata=null,n._programDateTime=null,n._ref=null,n._bitrate=void 0,n.rawProgramDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.playlistOffset=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.urlId=0,n.type=t,n}return ue(e,gT),ne(e,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],i=this.byteRange[1];if(AM(t)&&AM(i))return i-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e,t=this.levelkeys;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){var i=Object.keys(t);if(1===i.length){var n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=AM(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,i=Object.keys(this.levelkeys),n=i.length;if(n>1||1===n&&null!=(t=this.levelkeys[i[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){AM(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return yT(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){var t=this.levelkeys;if(t){var i,n=t[e];!n||null!=(i=this._decryptdata)&&i.keyId||(this._decryptdata=n.getDecryptData(this.sn,t))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,i,n,a,r=!1){var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,i),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:r}}}])}(),wT=function(){function e(t,i,n,a,r){var o;Q(this,e),(o=J(this,e,[n])).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=i,o.index=a;var s=t.enumeratedString("BYTERANGE");return s&&o.setByteRange(s,r),r&&(o.fragOffset=r.fragOffset+r.duration),o}return ue(e,gT),ne(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}();function kT(e,t){var i=Object.getPrototypeOf(e);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n||kT(i,t)}}var ST=Math.pow(2,32)-1,ET=[].push,MT={video:1,audio:2,id3:3,text:4};function TT(e){return String.fromCharCode.apply(null,e)}function PT(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function AT(e,t){var i=xT(e,t);return i<0?4294967296+i:i}function DT(e,t){var i=AT(e,t);return i*=Math.pow(2,32),i+=AT(e,t+4)}function xT(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function CT(e,t){var i=[];if(!t.length)return i;for(var n=e.byteLength,a=0;a<n;){var r=AT(e,a),o=r>1?a+r:n;if(TT(e.subarray(a+4,a+8))===t[0])if(1===t.length)i.push(e.subarray(a+8,o));else{var s=CT(e.subarray(a+8,o),t.slice(1));s.length&&ET.apply(i,s)}a=o}return i}function IT(e){var t=[],i=e[0],n=8,a=AT(e,n);n+=4;var r=0,o=0;0===i?(r=AT(e,n),o=AT(e,n+4),n+=8):(r=DT(e,n),o=DT(e,n+8),n+=16),n+=2;var s=e.length+o,u=PT(e,n);n+=2;for(var l=0;l<u;l++){var d=n,h=AT(e,d);d+=4;var c=2147483647&h;if(1===(2147483648&h)>>>31)return QM.warn("SIDX has hierarchical references (not supported)"),null;var m=AT(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:m,info:{duration:m/a,start:s,end:s+c-1}}),s+=c,n=d+=4}return{earliestPresentationTime:r,timescale:a,version:i,referencesCount:u,references:t}}function LT(e){for(var t=[],i=CT(e,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],r=CT(a,["tkhd"])[0];if(r){var o=r[0],s=AT(r,0===o?12:20),u=CT(a,["mdia","mdhd"])[0];if(u){var l=AT(u,0===(o=u[0])?12:20),d=CT(a,["mdia","hdlr"])[0];if(d){var h=TT(d.subarray(8,12)),c={soun:fT,vide:vT}[h],m=_T(CT(a,["mdia","minf","stbl","stsd"])[0]);c?(t[s]={timescale:l,type:c,stsd:m},t[c]=GM({timescale:l,id:s},m)):t[s]={timescale:l,type:h,stsd:m}}}}}return CT(e,["moov","mvex","trex"]).forEach(e=>{var i=AT(e,4),n=t[i];n&&(n.default={duration:AT(e,12),flags:AT(e,20)})}),t}function _T(e){var t,i=e.subarray(8),n=i.subarray(86),a=TT(i.subarray(4,8)),r=a,o="enca"===a||"encv"===a;if(o){var s=CT(i,[a])[0];CT(s.subarray("enca"===a?28:78),["sinf"]).forEach(e=>{var t=CT(e,["schm"])[0];if(t){var i=TT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=CT(e,["frma"])[0];n&&(r=TT(n))}}})}var u=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var l=CT(n,["avcC"])[0];l&&l.length>3&&(r+="."+WT(l[1])+WT(l[2])+WT(l[3]),t=RT("avc1"===u?"dva1":"dvav",n));break;case"mp4a":var d=CT(i,[a])[0],h=CT(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(3!==h[c++])break;c=FT(h,c),c+=2;var m=h[c++];if(128&m&&(c+=2),64&m&&(c+=h[c++]),4!==h[c++])break;c=FT(h,c);var f=h[c++];if(64!==f)break;if(r+="."+WT(f),c+=12,5!==h[c++])break;c=FT(h,c);var v=h[c++],p=(248&v)>>3;31===p&&(p+=1+((7&v)<<3)+((224&h[c])>>5)),r+="."+p}break;case"hvc1":case"hev1":var g=CT(n,["hvcC"])[0];if(g&&g.length>12){var y=g[1],b=["","A","B","C"][y>>6],w=31&y,k=AT(g,2),S=(32&y)>>5?"H":"L",E=g[12],M=g.subarray(6,12);r+="."+b+w,r+="."+function(e){for(var t=0,i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(k).toString(16).toUpperCase(),r+="."+S+E;for(var T="",P=M.length;P--;){var A=M[P];if(A||T)T="."+A.toString(16).toUpperCase()+T}r+=T}t=RT("hev1"==u?"dvhe":"dvh1",n);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=RT(r,n)||r;break;case"vp09":var D=CT(n,["vpcC"])[0];if(D&&D.length>6){var x=D[4],C=D[5],I=D[6]>>4&15;r+="."+OT(x)+"."+OT(C)+"."+OT(I)}break;case"av01":var L=CT(n,["av1C"])[0];if(L&&L.length>2){var _=L[1]>>>5,R=31&L[1],F=L[2]>>>7?"H":"M",W=(64&L[2])>>6,O=(32&L[2])>>5,$=2===_&&W?O?12:10:W?10:8,N=(16&L[2])>>4,j=(8&L[2])>>3,B=(4&L[2])>>2,z=3&L[2];r+="."+_+"."+OT(R)+F+"."+OT($)+"."+N+"."+j+B+z+"."+OT(1)+"."+OT(1)+"."+OT(1)+".0",t=RT("dav1",n)}}return{codec:r,encrypted:o,supplemental:t}}function RT(e,t){var i=CT(t,["dvvC"]),n=i.length?i[0]:CT(t,["dvcC"])[0];if(n){var a=n[2]>>1&127,r=n[2]<<5&32|n[3]>>3&31;return e+"."+OT(a)+"."+OT(r)}}function FT(e,t){for(var i=t+5;128&e[t++]&&t<i;);return t}function WT(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function OT(e){return(e<10?"0":"")+e}function $T(e,t){CT(e,["moov","trak"]).forEach(e=>{var i=CT(e,["mdia","minf","stbl","stsd"])[0];if(i){var n=i.subarray(8),a=CT(n,["enca"]),r=a.length>0;r||(a=CT(n,["encv"])),a.forEach(e=>{CT(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var i=NT(e);i&&t(i,r)})})}})}function NT(e){var t=CT(e,["schm"])[0];if(t){var i=TT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=CT(e,["schi","tenc"])[0];if(n)return n}}}function jT(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function BT(e,t){var i=[],n=t.samples,a=t.timescale,r=t.id,o=!1;return CT(n,["moof"]).map(s=>{var u=s.byteOffset-8;CT(s,["traf"]).map(s=>{var l=CT(s,["tfdt"]).map(e=>{var t=e[0],i=AT(e,4);return 1===t&&(i*=Math.pow(2,32),i+=AT(e,8)),i/a})[0];return void 0!==l&&(e=l),CT(s,["tfhd"]).map(l=>{var d=AT(l,4),h=16777215&AT(l,0),c=0,m=!!(16&h),f=0,v=!!(32&h),p=8;d===r&&(!!(1&h)&&(p+=8),!!(2&h)&&(p+=4),!!(8&h)&&(c=AT(l,p),p+=4),m&&(f=AT(l,p),p+=4),v&&(p+=4),"video"===t.type&&(o=zT(t.codec)),CT(s,["trun"]).map(r=>{var s=r[0],l=16777215&AT(r,0),d=!!(1&l),h=0,m=!!(4&l),v=!!(256&l),p=0,g=!!(512&l),y=0,b=!!(1024&l),w=!!(2048&l),k=0,S=AT(r,4),E=8;d&&(h=AT(r,E),E+=4),m&&(E+=4);for(var M=h+u,T=0;T<S;T++){if(v?(p=AT(r,E),E+=4):p=c,g?(y=AT(r,E),E+=4):y=f,b&&(E+=4),w&&(k=0===s?AT(r,E):xT(r,E),E+=4),t.type===vT)for(var P=0;P<y;){var A=AT(n,M);if(UT(o,n[M+=4]))HT(n.subarray(M,M+A),o?2:1,e+k/a,i);M+=A,P+=A+4}e+=p/a}}))})})}),i}function zT(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function UT(e,t){if(e){var i=t>>1&63;return 39===i||40===i}return 6===(31&t)}function HT(e,t,i,n){var a=GT(e),r=0;r+=t;for(var o=0,s=0,u=0;r<a.length;){o=0;do{if(r>=a.length)break;o+=u=a[r++]}while(255===u);s=0;do{if(r>=a.length)break;s+=u=a[r++]}while(255===u);var l=a.length-r,d=r;if(s<l)r+=s;else if(s>l){QM.error(`Malformed SEI payload. ${s} is too small, only ${l} bytes left to parse.`);break}if(4===o){if(181===a[d++]){var h=PT(a,d);if(d+=2,49===h){var c=AT(a,d);if(d+=4,1195456820===c){var m=a[d++];if(3===m){var f=a[d++],v=64&f,p=v?2+3*(31&f):0,g=new Uint8Array(p);if(v){g[0]=f;for(var y=1;y<p;y++)g[y]=a[d++]}n.push({type:m,payloadType:o,pts:i,bytes:g})}}}}}else if(5===o&&s>16){for(var b=[],w=0;w<16;w++){var k=a[d++].toString(16);b.push(1==k.length?"0"+k:k),3!==w&&5!==w&&7!==w&&9!==w||b.push("-")}for(var S=s-16,E=new Uint8Array(S),M=0;M<S;M++)E[M]=a[d++];n.push({payloadType:o,pts:i,uuid:b.join(""),userData:tT(E),userDataBytes:E})}}}function GT(e){for(var t=e.byteLength,i=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;var a=t-i.length,r=new Uint8Array(a),o=0;for(n=0;n<a;o++,n++)o===i[0]&&(o++,i.shift()),r[n]=e[o];return r}function VT(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var r=new Uint8Array(4);return i.byteLength>0&&new DataView(r.buffer).setUint32(0,i.byteLength,!1),function(e,...t){for(var i=t.length,n=8,a=i;a--;)n+=t[a].byteLength;var r=new Uint8Array(n);for(r[0]=n>>24&255,r[1]=n>>16&255,r[2]=n>>8&255,r[3]=255&n,r.set(e,4),a=0,n=8;a<i;a++)r.set(t[a],n),n+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,r,i)}function KT(e){var t=e.getUint32(0),i=e.byteOffset,n=e.byteLength;if(n<t)return{offset:i,size:n};if(1886614376!==e.getUint32(4))return{offset:i,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};var r=e.buffer,o=iT(new Uint8Array(r,i+12,16)),s=null,u=0;if(0===a)u=28;else{var l=e.getUint32(28);if(!l||n<32+16*l)return{offset:i,size:t};s=[];for(var d=0;d<l;d++)s.push(new Uint8Array(r,i+32+16*d,16));u=32+16*l}if(!u)return{offset:i,size:t};var h=e.getUint32(u);return t-32<h?{offset:i,size:t}:{version:a,systemId:o,kids:s,data:new Uint8Array(r,i+u+4,h),offset:i,size:t}}var XT=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),YT={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function qT(e,t){var i=YT[t];return!!i&&!!i[e.slice(0,4)]}function JT(e,t,i=!0){return!e.split(",").some(e=>!QT(e,t,i))}function QT(e,t,i=!0){var n,a=ZM(i);return null!=(n=null==a?void 0:a.isTypeSupported(ZT(e,t)))&&n}function ZT(e,t){return`${t}/mp4;codecs=${e}`}function eP(e){if(e){var t=e.substring(0,4);return YT.video[t]}return 2}function tP(e){var t=XT();return e.split(",").reduce((e,i)=>{var n=t&&zT(i)?9:YT.video[i];return n?(2*n+e)/(e?3:2):(YT.audio[i]+e)/(e?2:1)},0)}var iP={};var nP=/flac|opus|mp4a\.40\.34/i;function aP(e,t=!0){return e.replace(nP,e=>function(e,t=!0){if(iP[e])return iP[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<i.length;n++){var a;if(QT(i[n],"audio",t))return iP[e]=i[n],i[n];if("mp3"===i[n]&&null!=(a=ZM(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function rP(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(oP(e,"audio")||oP(e,"video")))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function oP(e,t){return qT(e,t)&&QT(e,t)}function sP(e){if(e.startsWith("av01.")){for(var t=e.split("."),i=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=i[n-4];return t.join(".")}return e}function uP(e){var t=ZM(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function lP(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var dP={supported:!1,smooth:!1,powerEfficient:!1},hP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function cP(e,t){return{supported:!1,configurations:t,decodingInfoResults:[dP],error:e}}function mP(e,t,i,n={}){var a=e.videoCodec;if(!a&&!e.audioCodec||!i)return Promise.resolve(hP);for(var r=[],o=function(e){var t,i=null==(t=e.videoCodec)?void 0:t.split(","),n=vP(e),a=e.width||640,r=e.height||480,o=e.frameRate||30,s=e.videoRange.toLowerCase();return i?i.map(e=>{var t={contentType:ZT(sP(e),"video"),width:a,height:r,bitrate:n,framerate:o};return"sdr"!==s&&(t.transferFunction=s),t}):[]}(e),s=o.length,u=function(e,t,i){var n,a=null==(n=e.audioCodec)?void 0:n.split(","),r=vP(e);if(a&&e.audioGroups)return e.audioGroups.reduce((e,n)=>{var o,s=n?null==(o=t.groups[n])?void 0:o.tracks:null;return s?s.reduce((e,t)=>{if(t.groupId===n){var o=parseFloat(t.channels||"");a.forEach(t=>{var n={contentType:ZT(t,"audio"),bitrate:i?fP(t,r):r};o&&(n.channels=""+o),e.push(n)})}return e},e):e},[]);return[]}(e,t,s>0),l=u.length,d=s||1*l||1;d--;){var h={type:"media-source"};if(s&&(h.video=o[d%s]),l){h.audio=u[d%l];var c=h.audio.bitrate;h.video&&c&&(h.video.bitrate-=c)}r.push(h)}if(a){var m=navigator.userAgent;if(a.split(",").some(e=>zT(e))&&XT())return Promise.resolve(cP(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${m})`),r))}return Promise.all(r.map(e=>{var t=function(e){var t="",i=e.audio,n=e.video;if(n){t+=`${lP(n.contentType)}_r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction||"sd"}_${Math.ceil(n.bitrate/1e5)}`}if(i){t+=`${n?"_":""}${lP(i.contentType)}_c${i.channels}`}return t}(e);return n[t]||(n[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:r,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:r,decodingInfoResults:[],error:e}))}function fP(e,t){if(t<=1)return 1;var i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}function vP(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var pP=["NONE","TYPE-0","TYPE-1",null];var gP=["SDR","PQ","HLG"];var yP="",bP="YES",wP="v2";function kP(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,n=e.age;return t&&n<t/2?i?wP:bP:yP}var SP=function(){return ne(function e(t,i,n){Q(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n},[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}])}(),EP=function(){return ne(function e(t){if(Q(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in t){var i;this.supplemental=t.supplemental;var n=null==(i=t.supplemental)?void 0:i.videoCodec;n&&n!==t.videoCodec&&(this.codecSet+=`,${n.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)},[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return MP(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return MP(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var i=this._audioGroups;i||(i=this._audioGroups=[]),-1===i.indexOf(t)&&i.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===n.indexOf(t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}])}();function MP(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function TP(e,t){var i=!1,n=[];if(e&&(i="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||gP.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(n=["SDR"])}return{preferHDR:i,allowedVideoRanges:n}}var PP=(e,t)=>JSON.stringify(e,(e=>{var t=new WeakSet;return(i,n)=>{if(e&&(n=e(i,n)),"object"==typeof n&&null!==n){if(t.has(n))return;t.add(n)}return n}})(t));function AP(e,t){QM.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function DP(e){return e.reduce((e,t)=>{var i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);var n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function xP(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function CP(e,t,i){if("attrs"in e){var n=t.indexOf(e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(IP(e,t[a],i))return a}return-1}function IP(e,t,i){var n=e.groupId,a=e.name,r=e.lang,o=e.assocLang,s=e.default,u=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===r||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(r,t.lang))&&(void 0===r||t.assocLang===o)&&(void 0===s||t.default===s)&&(void 0===u||t.forced===u)&&(!("characteristics"in e)||function(e,t=""){var i=e.split(","),n=t.split(",");return i.length===n.length&&!i.some(e=>-1===n.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function LP(e,t){var i=e.audioCodec,n=e.channels;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function _P(e,t,i){for(var n=t;n>-1;n--)if(i(e[n]))return n;for(var a=t+1;a<e.length;a++)if(i(e[a]))return a;return-1}function RP(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}var FP=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["abr",t.logger])).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.rebufferNotice=-1,i.supportedCache={},i.bwEstimator=void 0,i._abandonRulesCheck=e=>{var t,n=i,a=n.fragCurrent,r=n.partCurrent,o=n.hls,s=o.autoLevelEnabled,u=o.media;if(a&&u){var l=performance.now(),d=r?r.stats:a.stats,h=r?r.duration:a.duration,c=l-d.loading.start,m=o.minAutoLevel,f=a.level,v=i._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=m)return i.clearTimer(),void(i._nextAutoLevel=-1);if(s){var p=v>-1&&v!==f,g=!!e||p;if(g||!u.paused&&u.playbackRate&&u.readyState){var y=o.mainForwardBufferInfo;if(g||null!==y){var b=i.bwEstimator.getEstimateTTFB(),w=Math.abs(u.playbackRate);if(!(c<=Math.max(b,h/(2*w)*1e3))){var k=y?y.len/w:0,S=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&S>-1,M=i.getBwEstimate(),T=o.levels,P=T[f],A=Math.max(d.loaded,Math.round(h*(a.bitrate||P.averageBitrate)/8)),D=E?c-S:c;D<1&&E&&(D=Math.min(c,8*d.loaded/M));var x=E?1e3*d.loaded/D:0,C=b/1e3,I=x?(A-d.loaded)/x:8*A/M+C;if(!(I<=k)){var L,_=x?8*x:M,R=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),F=i.hls.config.abrBandWidthUpFactor,W=Number.POSITIVE_INFINITY;for(L=f-1;L>m;L--){var O=T[L].maxBitrate,$=!T[L].details||R;if((W=i.getTimeToLoadFrag(C,_,h*O,$))<Math.min(k,h+C))break}if(!(W>=I||W>10*h)){E?i.bwEstimator.sample(c-Math.min(b,S),d.loaded):i.bwEstimator.sampleTTFB(c);var N=T[L].maxBitrate;i.getBwEstimate()*F>N&&i.resetEstimator(N);var j=i.findBestLevel(N,m,L,0,k,1,1);j>-1&&(L=j),i.warn(`Fragment ${a.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${a.duration.toFixed(3)}\n Time to underbuffer: ${k.toFixed(3)} s\n Estimated load time for current fragment: ${I.toFixed(3)} s\n Estimated load time for down switch fragment: ${W.toFixed(3)} s\n TTFB estimate: ${0|S} ms\n Current BW estimate: ${AM(M)?0|M:"Unknown"} bps\n New BW estimate: ${0|i.getBwEstimate()} bps\n Switching to level ${L} @ ${0|N} bps`),o.nextLoadLevel=o.nextAutoLevel=L,i.clearTimer();var B=()=>{if(i.clearTimer(),i.fragCurrent===a&&i.hls.loadLevel===L&&L>0){var e=i.getStarvationDelay();if(i.warn(`Aborting inflight request ${L>0?"and switching down":""}\n Fragment duration: ${a.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),a.abortRequests(),i.fragCurrent=i.partCurrent=null,L>m){var t=i.findBestLevel(i.hls.levels[m].bitrate,m,L,0,e,1,1);-1===t&&(t=m),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};p||I>2*W?B():i.timer=self.setInterval(B,1e3*W),o.trigger(LM.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:r,stats:d})}}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return ue(e,VM),ne(e,[{key:"resetEstimator",value:function(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new BM(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.FRAG_LOADING,this.onFragLoading,this),e.on(LM.FRAG_LOADED,this.onFragLoaded,this),e.on(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.on(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(LM.LEVEL_LOADED,this.onLevelLoaded,this),e.on(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(LM.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.FRAG_LOADING,this.onFragLoading,this),e.off(LM.FRAG_LOADED,this.onFragLoaded,this),e.off(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.off(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(LM.LEVEL_LOADED,this.onLevelLoaded,this),e.off(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(LM.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(LM.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var i=t.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case IM.BUFFER_ADD_CODEC_ERROR:case IM.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case IM.FRAG_LOAD_TIMEOUT:var i=t.frag,n=this.fragCurrent,a=this.partCurrent;if(i&&n&&i.sn===n.sn&&i.level===n.level){var r=performance.now(),o=a?a.stats:i.stats,s=r-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(l,u),o.loaded)}else this.bwEstimator.sampleTTFB(s)}}}},{key:"getTimeToLoadFrag",value:function(e,t,i,n){return e+i/t+(n?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var i=this.hls.config,n=t.stats.loading,a=n.end-n.first;AM(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,{frag:t,part:i}){var n=i?i.stats:t.stats;if(t.type===OM&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+n.loaded,s=(r.loaded?r.loaded.duration:0)+a;r.loaded={bytes:o,duration:s},r.realBitrate=Math.round(8*o/s)}if(t.bitrateTest){var u={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(LM.FRAG_BUFFERED,u),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:i.stats;if(!a.aborted&&!this.ignoreFragment(i)){var r=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==OM||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,r=this.findBestLevel(n,i,t,0,a,1,1);if(r>-1)return r;var o=this.hls.firstLevel,s=Math.min(Math.max(o,i),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${s}`),s}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,r=i.minAutoLevel,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),u=this.getStarvationDelay(),l=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(s,r,n,u,0,l,d);if(h>=0)return this.rebufferNotice=-1,h}var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var m=this.bitrateTestDelay;if(m)c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),l=d=1}var f=this.findBestLevel(s,r,n,u,c,l,d);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;var v=i.levels[r],p=i.loadLevelObj;return p&&(null==v?void 0:v.bitrate)<p.bitrate?r:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,i,n,a,r,o){var s,u=this,l=n+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,m=this.partCurrent,f=this.hls,v=f.levels,p=f.allAudioTracks,g=f.loadLevel,y=f.config;if(1===v.length)return 0;var b,w=v[h],k=!(null==(s=this.hls.latestLevelDetails)||!s.live),S=-1===g||-1===d,E="SDR",M=(null==w?void 0:w.frameRate)||0,T=y.audioPreference,P=y.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=DP(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var x=this.codecTiers||(this.codecTiers=function(e,t,i,n){return e.slice(i,n+1).reduce((e,i,n)=>{if(!i.codecSet)return e;var a=i.audioGroups,r=e[i.codecSet];r||(e[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);var o=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,o),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.minIndex=Math.min(r.minIndex,n),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,a&&a.forEach(e=>{if(e){var i=t.groups[e];i&&(r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+i.channels[e]}))}}),e},{})}(v,A,t,i)),C=function(e,t,i,n,a){for(var r=Object.keys(e),o=null==n?void 0:n.channels,s=null==n?void 0:n.audioCodec,u=null==a?void 0:a.videoCodec,l=o&&2===parseInt(o),d=!1,h=!1,c=1/0,m=1/0,f=1/0,v=1/0,p=0,g=[],y=TP(t,a),b=y.preferHDR,w=y.allowedVideoRanges,k=function(){var t=e[r[S]];d||(d=t.channels[2]>0),c=Math.min(c,t.minHeight),m=Math.min(m,t.minFramerate),f=Math.min(f,t.minBitrate),w.filter(e=>t.videoRanges[e]>0).length>0&&(h=!0)},S=r.length;S--;)k();c=AM(c)?c:0,m=AM(m)?m:0;var E=Math.max(1080,c),M=Math.max(30,m);f=AM(f)?f:i,i=Math.max(f,i),h||(t=void 0);var T=r.length>1;return{codecSet:r.reduce((t,n)=>{var a=e[n];if(n===t)return t;if(g=h?w.filter(e=>a.videoRanges[e]>0):[],T){if(a.minBitrate>i)return AP(n,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return AP(n,"no renditions with default or auto-select sound found"),t;if(s&&n.indexOf(s.substring(0,4))%5!=0)return AP(n,`audio codec preference "${s}" not found`),t;if(o&&!l){if(!a.channels[o])return AP(n,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||l)&&d&&0===a.channels[2])return AP(n,"no renditions with stereo sound found"),t;if(a.minHeight>E)return AP(n,`min resolution of ${a.minHeight} > maximum of ${E}`),t;if(a.minFramerate>M)return AP(n,`min framerate of ${a.minFramerate} > maximum of ${M}`),t;if(!g.some(e=>a.videoRanges[e]>0))return AP(n,`no variants with VIDEO-RANGE of ${PP(g)} found`),t;if(u&&n.indexOf(u.substring(0,4))%5!=0)return AP(n,`video codec preference "${u}" not found`),t;if(a.maxScore<p)return AP(n,`max score of ${a.maxScore} < selected max of ${p}`),t}return t&&(tP(n)>=tP(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,p=a.maxScore,n)},void 0),videoRanges:g,preferHDR:b,minFramerate:m,minBitrate:f,minIndex:v}}(x,E,e,T,P),I=C.codecSet,L=C.videoRanges,_=C.minFramerate,R=C.minBitrate,F=C.minIndex,W=C.preferHDR;D=F,b=I,E=W?L[L.length-1]:L[0],M=_,e=Math.max(e,R),this.log(`picked start tier ${PP(C)}`)}else b=null==w?void 0:w.codecSet,E=null==w?void 0:w.videoRange;for(var O,$,N=m?m.duration:c?c.duration:0,j=this.bwEstimator.getEstimateTTFB()/1e3,B=[],z=function(){var t=v[U],s=U>h;if(!t)return 0;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var c=navigator.mediaCapabilities;"function"==typeof(null==c?void 0:c.decodingInfo)&&function(e,t,i,n,a,r){var o=e.videoCodec,s=e.audioCodec?e.audioGroups:null,u=null==r?void 0:r.audioCodec,l=null==r?void 0:r.channels,d=l?parseInt(l):u?1/0:2,h=null;if(null!=s&&s.length)try{h=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((e,i)=>{if(i){var n=t.groups[i];if(!n)throw new Error(`Audio track group ${i} not found`);Object.keys(n.channels).forEach(t=>{e[t]=(e[t]||0)+n.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some(e=>zT(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(a,8e6))||!!h&&AM(d)&&Object.keys(h).some(e=>parseInt(e)>d)}(t,A,E,M,e,T)?(t.supportedPromise=mP(t,A,c,u.supportedCache),t.supportedPromise.then(e=>{if(u.hls){t.supportedResult=e;var i=u.hls.levels,n=i.indexOf(t);e.error?u.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${n} ${PP(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&u.log(`MediaCapabilities decodingInfo for level ${n} not smooth or powerEfficient: ${PP(e)}`):(u.warn(`Unsupported MediaCapabilities decodingInfo result for level ${n} ${PP(e)}`),n>-1&&i.length>1&&(u.log(`Removing unsupported level ${n}`),u.hls.removeLevel(n),-1===u.hls.loadLevel&&(u.hls.nextLoadLevel=0)))}}).catch(e=>{u.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=hP}if((b&&t.codecSet!==b||E&&t.videoRange!==E||s&&M>t.frameRate||!s&&M>0&&M<t.frameRate||null!=(O=t.supportedResult)&&null!=(O=O.decodingInfoResults)&&O.some(e=>!1===e.smooth))&&(!S||U!==D))return B.push(U),0;var f,p=t.details,w=(m?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;f=s?o*e:r*e;var P=N&&n>=2*N&&0===a?t.averageBitrate:t.maxBitrate,x=u.getTimeToLoadFrag(j,f,P*w,void 0===p);if(f>=P&&(U===d||0===t.loadError&&0===t.fragmentError)&&(x<=j||!AM(x)||k&&!u.bitrateTestDelay||x<l)){var C=u.forcedAutoLevel;return U===g||-1!==C&&C===g||(B.length&&u.trace(`Skipped level(s) ${B.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${v[B[0]].codecs}" ${v[B[0]].videoRange}; not compatible with "${b}" ${E}`),u.info(`switch candidate:${h}->${U} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-P)} ttfb:${j.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${x.toFixed(1)} firstSelection:${S} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),S&&(u.firstSelection=U),{v:U}}},U=i;U>=t;U--)if(0!==($=z())&&$)return $.v;return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,i=t.maxAutoLevel,n=t.minAutoLevel;return Math.min(Math.max(e,n),i)}}])}(),WP=function(e,t){for(var i=0,n=e.length-1,a=null,r=null;i<=n;){var o=t(r=e[a=(i+n)/2|0]);if(o>0)i=a+1;else{if(!(o<0))return r;n=a-1}}return null};function OP(e,t,i=0,n=0,a=.005){var r=null;if(e){r=t[1+e.sn-t[0].sn]||null;var o=e.endDTS-i;o>0&&o<15e-7&&(i+=15e-7),r&&e.level!==r.level&&r.end<=e.end&&(r=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===$P(i,n,r)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=n}return!1}(r,e,Math.min(a,n))))return r;var s=WP(t,$P.bind(null,i,n));return!s||s===e&&r?r:s}function $P(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;var n=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=e?1:i.start-n>e&&i.start?-1:0}function NP(e,t,i){var n=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>e}function jP(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){var n,a=e.fragments,r=e.fragmentHint;return r&&(a=a.concat(r)),WP(a,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=i?1:e.start>i?-1:0)),n||null}return null}function BP(e){switch(e.details){case IM.FRAG_LOAD_TIMEOUT:case IM.KEY_LOAD_TIMEOUT:case IM.LEVEL_LOAD_TIMEOUT:case IM.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function zP(e){return e.details.startsWith("key")}function UP(e){return zP(e)&&!!e.frag&&!e.frag.decryptdata}function HP(e,t){var i=BP(t);return e.default[(i?"timeout":"error")+"Retry"]}function GP(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function VP(e){return GM(GM({},e),{errorRetry:null,timeoutRetry:null})}function KP(e,t,i,n){if(!e)return!1;var a=null==n?void 0:n.code,r=t<e.maxNumRetry&&(function(e){return XP(e)||!!e&&(e<400||e>499)}(a)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,n,r):r}function XP(e){return 0===e&&!1===navigator.onLine}var YP=0,qP=2,JP=3,QP=5,ZP=0,eA=1,tA=2,iA=4,nA=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["error-controller",t.logger])).hls=void 0,i.playlistError=0,i.hls=t,i.registerListeners(),i}return ue(e,VM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.ERROR,this.onError,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.ERROR,this.onError,this),e.off(LM.ERROR,this.onErrorOut,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===OM?e.level:this.getVariantIndex()}},{key:"getVariantIndex",value:function(){var e,t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}},{key:"variantHasKey",value:function(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;var n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(e=>n.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}},{key:"onManifestLoading",value:function(){this.playlistError=0}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case IM.FRAG_LOAD_ERROR:case IM.FRAG_LOAD_TIMEOUT:case IM.KEY_LOAD_ERROR:case IM.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case IM.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=aA());case IM.FRAG_GAP:case IM.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=qP);case IM.LEVEL_EMPTY_ERROR:case IM.LEVEL_PARSING_ERROR:var r,o=t.parent===OM?t.level:n.loadLevel;return void(t.details===IM.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case IM.LEVEL_LOAD_ERROR:case IM.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case IM.AUDIO_TRACK_LOAD_ERROR:case IM.AUDIO_TRACK_LOAD_TIMEOUT:case IM.SUBTITLE_LOAD_ERROR:case IM.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var s=n.loadLevelObj;if(s&&(a.type===FM&&s.hasAudioGroup(a.groupId)||a.type===WM&&s.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=qP,void(t.errorAction.flags=eA)}return;case IM.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:qP,flags:tA});case IM.KEY_SYSTEM_SESSION_UPDATE_FAILED:case IM.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case IM.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:qP,flags:iA});case IM.BUFFER_ADD_CODEC_ERROR:case IM.REMUX_ALLOC_ERROR:case IM.BUFFER_APPEND_ERROR:var u;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(u=t.level)?u:n.loadLevel);return;case IM.INTERNAL_EXCEPTION:case IM.BUFFER_APPENDING_ERROR:case IM.BUFFER_FULL_ERROR:case IM.LEVEL_SWITCH_ERROR:case IM.BUFFER_STALLED_ERROR:case IM.BUFFER_SEEK_OVER_HOLE:case IM.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=aA())}t.type===CM.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=aA())}}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var i=HP(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(KP(i,n,BP(e),e.response))return{action:QP,flags:ZP,retryConfig:i,retryCount:n};var a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],a=t.config,r=a.fragLoadPolicy,o=a.keyLoadPolicy,s=HP(zP(e)?o:r,e),u=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(n&&(e.details!==IM.FRAG_GAP&&n.fragmentError++,!UP(e)&&KP(s,u,BP(e),e.response)))return{action:QP,flags:ZP,retryConfig:s,retryCount:u};var l=this.getLevelSwitchAction(e,i);return s&&(l.retryConfig=s,l.retryCount=u),l}},{key:"getLevelSwitchAction",value:function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var n=this.hls.levels[t];if(n){var a,r,o=e.details;n.loadError++,o===IM.BUFFER_APPEND_ERROR&&n.fragmentError++;var s=-1,u=i.levels,l=i.loadLevel,d=i.minAutoLevel,h=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var c,m,f,v=null==(a=e.frag)?void 0:a.type,p=(v===$M&&o===IM.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(o===IM.BUFFER_ADD_CODEC_ERROR||o===IM.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:e})=>n.audioCodec!==e),g="video"===e.sourceBufferName&&(o===IM.BUFFER_ADD_CODEC_ERROR||o===IM.BUFFER_APPEND_ERROR)&&u.some(({codecSet:e,audioCodec:t})=>n.codecSet!==e&&n.audioCodec===t),y=null!=(r=e.context)?r:{},b=y.type,w=y.groupId,k=function(){var t=(S+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var i=u[t];if(o===IM.FRAG_GAP&&v===OM&&e.frag){var a=u[t].details;if(a){var r=OP(e.frag,a.fragments,e.frag.start);if(null!=r&&r.gap)return 0}}else{if(b===FM&&i.hasAudioGroup(w)||b===WM&&i.hasSubtitleGroup(w))return 0;if(v===$M&&null!=(c=n.audioGroups)&&c.some(e=>i.hasAudioGroup(e))||v===NM&&null!=(m=n.subtitleGroups)&&m.some(e=>i.hasSubtitleGroup(e))||p&&n.audioCodec===i.audioCodec||g&&n.codecSet===i.codecSet||!p&&n.codecSet!==i.codecSet)return 0}return s=t,1}},S=u.length;S--&&(0===(f=k())||1!==f););if(s>-1&&i.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:qP,flags:ZP,nextAutoLevel:s}}return{action:qP,flags:eA}}},{key:"onErrorOut",value:function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case YP:break;case qP:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===IM.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,i=e.errorAction;if(i){var n=i.flags,a=i.nextAutoLevel;switch(n){case ZP:this.switchLevel(e,a);break;case tA:var r=this.getVariantLevelIndex(e.frag),o=t.levels[r],s=null==o?void 0:o.attrs["HDCP-LEVEL"];if(i.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=pP[pP.indexOf(s)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}case iA:var u=e.decryptdata;if(u){for(var l=this.hls.levels,d=l.length,h=d;h--;){var c,m;if(this.variantHasKey(l[h],u))this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${null==(c=l[h].audioGroups)?void 0:c.join(",")}" (${null==(m=e.frag)?void 0:m.type} fragment) ${iT(u.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}var f=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(f&&f.type!==OM){var v=f.decryptdata;v&&!u.matches(v)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===IM.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var i=lP(e.mimeType),n=this.hls.levels,a=n.length;a--;)n[a][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${a} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(a))}}])}();function aA(e){var t={action:YP,flags:ZP};return e&&(t.resolved=!0),t}var rA="NOT_LOADED",oA="APPENDING",sA="PARTIAL",uA="OK",lA=function(){return ne(function e(t){Q(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()},[{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.BUFFER_APPENDED,this.onBufferAppended,this),e.on(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.on(LM.FRAG_LOADED,this.onFragLoaded,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.BUFFER_APPENDED,this.onBufferAppended,this),e.off(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.off(LM.FRAG_LOADED,this.onFragLoaded,this))}},{key:"destroy",value:function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var i=this.activePartLists[t];if(i)for(var n=i.length;n--;){var a=i[n];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,i){for(var n=this.fragments,a=Object.keys(n),r=a.length;r--;){var o=n[a[r]];if((null==o?void 0:o.body.type)===t&&(!i||o.buffered)){var s=o.body;if(s.start<=e&&e<=s.end)return s}}return null}},{key:"detectEvictedFragments",value:function(e,t,i,n,a){this.timeRanges&&(this.timeRanges[e]=t);var r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(n=>{var o=this.fragments[n];if(o&&!(r>=o.body.sn))if(o.buffered||o.loaded&&!a){var s=o.range[e];s&&(0!==s.time.length?s.time.some(e=>{var i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(o.body),i}):this.removeFragment(o.body))}else o.body.type===i&&this.removeFragment(o.body)})}},{key:"detectPartialFragments",value:function(e){var t=this.timeRanges;if(t&&"initSegment"!==e.frag.sn){var i=e.frag,n=hA(i),a=this.fragments[n];if(!(!a||a.buffered&&i.gap)){var r=!i.relurl;Object.keys(t).forEach(n=>{var o=i.elementaryStreams[n];if(o){var s=t[n],u=r||!0===o.partial;a.range[n]=this.getBufferedTimes(i,e.part,u,s)}}),a.loaded=null,Object.keys(a.range).length?(this.bufferedEnd(a,i),dA(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}}}},{key:"bufferedEnd",value:function(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}},{key:"removeParts",value:function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=cA(i,t=>t.fragment.sn>=e))}},{key:"fragBuffered",value:function(e,t){var i=hA(e),n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}},{key:"getBufferedTimes",value:function(e,t,i,n){for(var a={time:[],partial:i},r=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||r,l=0;l<n.length;l++){var d=n.start(l)-this.bufferPadding,h=n.end(l)+this.bufferPadding;if(u>=d&&s<=h){a.time.push({startPTS:Math.max(r,n.start(l)),endPTS:Math.min(o,n.end(l))});break}if(r<h&&o>d){var c=Math.max(r,n.start(l)),m=Math.min(o,n.end(l));m>c&&(a.partial=!0,a.time.push({startPTS:c,endPTS:m}))}else if(o<=d)break}return a}},{key:"getPartialFragment",value:function(e){var t,i,n,a=null,r=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(u=>{var l=s[u];l&&dA(l)&&(i=l.body.start-o,n=l.body.end+o,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=l.body,r=t)))}),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||dA(t))}},{key:"getState",value:function(e){var t=hA(e),i=this.fragments[t];return i?i.buffered?dA(i)?sA:uA:oA:rA}},{key:"isTimeBuffered",value:function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var i=t.frag,n=t.part?null:t,a=hA(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var i=t.frag,n=t.part,a=t.timeRanges,r=t.type;if("initSegment"!==i.sn){var o=i.type;if(n){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(n)}this.timeRanges=a;var u=a[r];this.detectEvictedFragments(r,u,o,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=hA(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,i=Object.keys(t);if(!e)return i.length>0;for(var n=i.length;n--;){var a=t[i[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{var o=this.fragments[r];if(o){var s=o.body;s.type!==i||n&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}})}},{key:"removeFragment",value:function(e){var t=hA(e);e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var n=e.sn;this.activePartLists[e.type]=cA(i,e=>e.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}])}();function dA(e){var t,i,n;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(n=e.range.audiovideo)&&n.partial)}function hA(e){return`${e.type}_${e.level}_${e.sn}`}function cA(e,t){return e.filter(e=>{var i=t(e);return i||e.clearElementaryStreamInfo(),i})}var mA=0,fA=1,vA=function(){return ne(function e(t,i,n){Q(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=i,this.aesMode=n},[{key:"decrypt",value:function(e,t){switch(this.aesMode){case mA:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case fA:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}])}();var pA=function(){return ne(function e(){Q(this,e),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()},[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),i=new Uint32Array(4),n=0;n<4;n++)i[n]=t.getUint32(4*n);return i}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],r=i[2],o=i[3],s=this.invSubMix,u=s[0],l=s[1],d=s[2],h=s[3],c=new Uint32Array(256),m=0,f=0,v=0;for(v=0;v<256;v++)c[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=f^f<<1^f<<2^f<<3^f<<4;p=p>>>8^255&p^99,e[m]=p,t[p]=m;var g=c[m],y=c[g],b=c[y],w=257*c[p]^16843008*p;n[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,r[m]=w<<8|w>>>24,o[m]=w,w=16843009*b^65537*y^257*g^16843008*m,u[p]=w<<24|w>>>8,l[p]=w<<16|w>>>16,d[p]=w<<8|w>>>24,h[p]=w,m?(m=g^c[c[c[b^g]]],f^=c[c[f]]):m=f=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,n=0;n<t.length&&i;)i=t[n]===this.key[n],n++;if(!i){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var r,o,s,u,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,m=this.rcon,f=this.invSubMix,v=f[0],p=f[1],g=f[2],y=f[3];for(r=0;r<l;r++)r<a?s=d[r]=t[r]:(u=s,r%a===0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=m[r/a|0]<<24):a>6&&r%a===4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[r]=s=(d[r-a]^u)>>>0);for(o=0;o<l;o++)r=l-o,u=3&o?d[r]:d[r-4],h[o]=o<4||r<=4?u:v[c[u>>>24]]^p[c[u>>>16&255]]^g[c[u>>>8&255]]^y[c[255&u]],h[o]=h[o]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,i){for(var n,a,r,o,s,u,l,d,h,c,m,f,v,p,g=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,k=w[0],S=w[1],E=w[2],M=w[3],T=this.uint8ArrayToUint32Array_(i),P=T[0],A=T[1],D=T[2],x=T[3],C=new Int32Array(e),I=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(h=L(C[t]),c=L(C[t+1]),m=L(C[t+2]),f=L(C[t+3]),s=h^y[0],u=f^y[1],l=m^y[2],d=c^y[3],v=4,p=1;p<g;p++)n=k[s>>>24]^S[u>>16&255]^E[l>>8&255]^M[255&d]^y[v],a=k[u>>>24]^S[l>>16&255]^E[d>>8&255]^M[255&s]^y[v+1],r=k[l>>>24]^S[d>>16&255]^E[s>>8&255]^M[255&u]^y[v+2],o=k[d>>>24]^S[s>>16&255]^E[u>>8&255]^M[255&l]^y[v+3],s=n,u=a,l=r,d=o,v+=4;n=b[s>>>24]<<24^b[u>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^y[v],a=b[u>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&s]^y[v+1],r=b[l>>>24]<<24^b[d>>16&255]<<16^b[s>>8&255]<<8^b[255&u]^y[v+2],o=b[d>>>24]<<24^b[s>>16&255]<<16^b[u>>8&255]<<8^b[255&l]^y[v+3],I[t]=L(n^P),I[t+1]=L(o^A),I[t+2]=L(r^D),I[t+3]=L(a^x),P=h,A=c,D=m,x=f,t+=4}return I.buffer}}])}(),gA=function(){return ne(function e(t,i,n){Q(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=i,this.aesMode=n},[{key:"expandKey",value:function(){var e=function(e){switch(e){case mA:return"AES-CBC";case fA:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}])}();var yA=function(){return ne(function e(t,{removePKCS7Padding:i=!0}={}){if(Q(this,e),this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle},[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i,n,a,r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(n=(i=r).byteLength,(a=n&&new DataView(i.buffer).getUint8(n-1))?i.slice(0,n-a):i):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,i,n){return this.useSoftware?new Promise((a,r)=>{var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,n);var s=this.flush();s?a(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}},{key:"softwareDecrypt",value:function(e,t,i,n){var a=this.currentIV,r=this.currentResult,o=this.remainderData;if(n!==mA||16!==t.byteLength)return QM.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=jT(o,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;a&&(i=a);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new pA),u.expandKey(t);var l=r;return this.currentResult=u.decrypt(s.buffer,0,i),this.currentIV=s.slice(-16).buffer,l||null}},{key:"webCryptoDecrypt",value:function(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new gA(this.subtle,t,n)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new vA(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(QM.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i,n)))}},{key:"onWebCryptoError",value:function(e,t,i,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);var r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(QM.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}])}(),bA=Math.pow(2,17),wA=function(){return ne(function e(t){Q(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t},[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var i=e.url;if(!i)return Promise.reject(new EA({type:CM.NETWORK_ERROR,details:IM.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void s(SA(e));e.gap=!1}var u=this.loader=a?new a(n):new r(n),l=kA(e);e.loader=u;var d=VP(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:bA};e.stats=u.stats;var c={onSuccess:(t,i,n,a)=>{this.resetLoader(e,u);var r=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),o({frag:e,part:null,payload:r,networkDetails:a})},onError:(t,n,a,r)=>{this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:GM({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,i,n)=>{this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:(t,i,n)=>{this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:n,stats:t}))}};t&&(c.onProgress=(i,n,a,r)=>t({frag:e,part:null,payload:a,networkDetails:r})),u.load(l,h,c)})}},{key:"loadPart",value:function(e,t,i){this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)s(SA(e,t));else{var u=this.loader=a?new a(n):new r(n),l=kA(e,t);e.loader=u;var d=VP(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:bA};t.stats=u.stats,u.load(l,h,{onSuccess:(n,a,r,s)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:n.data,networkDetails:s};i(l),o(l)},onError:(i,n,a,r)=>{this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:GM({url:l.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:r}))},onAbort:(i,n,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,n,a)=>{this.resetLoader(e,u),s(new EA({type:CM.NETWORK_ERROR,details:IM.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:a,stats:i}))}})}})}},{key:"updateStatsFromPart",value:function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),o=Math.min(Math.round(i.loaded/a),r),s=(r-o)*Math.round(i.loaded/o);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);var u=i.loading,l=n.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}])}();function kA(e,t=null){var i,n=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},r=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if(AM(r)&&AM(o)){var s,u=r,l=o;if("initSegment"===e.sn&&("AES-128"===(i=null==(s=e.decryptdata)?void 0:s.method)||"AES-256"===i)){var d=o-r;d%16&&(l=o+(16-d%16)),0!==r&&(a.resetIV=!0,u=r-16)}a.rangeStart=u,a.rangeEnd=l}return a}function SA(e,t){var i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),n={type:CM.MEDIA_ERROR,details:IM.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new EA(n)}var EA=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t.error.message])).data=void 0,i.data=t,i}return ue(e,ye(Error)),ne(e)}(),MA=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[t,i]))._boundTick=void 0,n._tickTimer=null,n._tickInterval=null,n._tickCallCount=0,n._boundTick=n.tick.bind(n),n}return ue(e,VM),ne(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}])}(),TA=ne(function e(t,i,n,a=0,r=-1,o=!1){Q(this,e),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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=a,this.part=r,this.partial=o});var PA={length:0,start:()=>0,end:()=>0},AA=function(){function e(){Q(this,e)}return ne(e,null,[{key:"isBuffered",value:function(t,i){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(i>=n.start(a)&&i<=n.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var i=e.getBuffered(t);return e.timeRangesToArray(i)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}},{key:"bufferInfo",value:function(t,i,n){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,i,n)}return{len:0,start:i,end:i,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);var n=-1,a=[];if(i)for(var r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(n=r);var o=a.length;if(o){var s=a[o-1].end;e[r].start-s<i?e[r].end>s&&(a[o-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;for(var u,l=0,d=t,h=t,c=0;c<a.length;c++){var m=a[c].start,f=a[c].end;if(-1===n&&t>=m&&t<=f&&(n=c),t+i>=m&&t<f)d=m,l=(h=f)-t;else if(t+i<m){u=m;break}}return{len:l,start:d||0,end:h||0,nextStart:u,buffered:e,bufferedIndex:n}}},{key:"getBuffered",value:function(e){try{return e.buffered||PA}catch(e){return QM.log("failed to get media.buffered",e),PA}}}])}(),DA=/\{\$([a-zA-Z0-9-_]+)\}/g;function xA(e){return DA.test(e)}function CA(e,t){if(null!==e.variableList||e.hasVariableRefs){var i=e.variableList;return t.replace(DA,t=>{var n=t.substring(2,t.length-1),a=null==i?void 0:i[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),t):a})}return t}function IA(e,t,i){var n,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var o=new self.URL(i).searchParams;if(!o.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else n=t.NAME,a=t.VALUE;n in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=a||""}function LA(e,t,i){var n=t.IMPORT;if(i&&n in i){var a=e.variableList;a||(e.variableList=a={}),a[n]=i[n]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}var _A=/^(\d+)x(\d+)$/,RA=/(.+?)=(".*?"|.*?)(?:,|$)/g,FA=function(){return ne(function e(t,i){Q(this,e),"string"==typeof t&&(t=e.parseAttrList(t,i)),UM(this,t)},[{key:"clientAttrs",get:function(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var i=this[e];return i?parseFloat(i):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=_A.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var i,n={};for(RA.lastIndex=0;null!==(i=RA.exec(e));){var a=i[1].trim(),r=i[2],o=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1,s=!1;if(o)r=r.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":s=!0}if(t&&(o||s))r=CA(t,r);else if(!s&&!o)switch(a){case"CLOSED-CAPTIONS":if("NONE"===r)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":QM.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=r}return n}}])}();function WA(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function OA(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var $A=function(){return ne(function e(t,i,n=0){var a;if(Q(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(a=null==i?void 0:i.tagOrder)?a:n,i){var r=i.attr;for(var o in r)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==r[o]){QM.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=o;break}t=UM(new FA({}),r,t)}if(this.attr=t,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var s=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);AM(s.getTime())&&(this._endDate=s)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(QM.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(AM(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&AM(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),NA=function(){return ne(function e(t){Q(this,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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,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.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasKey",value:function(e){return this.encryptedFragments.some(t=>{var i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&AM(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function jA(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function BA(e,t){return!e&&!t||!(!e||!t)&&jA(e,t)}function zA(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function UA(e){switch(e){case"AES-128":case"AES-256":return mA;case"AES-256-CTR":return fA;default:throw new Error(`invalid full segment method ${e}`)}}function HA(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function GA(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function VA(e){var t=function(e,t,i){var n=e[t];e[t]=e[i],e[i]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function KA(e){var t,i,n=e.split(":"),a=null;if("data"===n[0]&&2===n.length){var r=n[1].split(";"),o=r[r.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(r.splice(-1,1),a=HA(u)):(t=GA(u).subarray(0,16),(i=new Uint8Array(16)).set(t,16-t.length),a=i)}}return a}var XA="undefined"!=typeof self?self:void 0,YA={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},qA="org.w3.clearkey",JA="com.apple.streamingkeydelivery",QA="com.microsoft.playready",ZA="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function eD(e){switch(e){case JA:return YA.FAIRPLAY;case QA:return YA.PLAYREADY;case ZA:return YA.WIDEVINE;case qA:return YA.CLEARKEY}}function tD(e){switch(e){case YA.FAIRPLAY:return JA;case YA.PLAYREADY:return QA;case YA.WIDEVINE:return ZA;case YA.CLEARKEY:return qA}}function iD(e){var t=e.drmSystems,i=e.widevineLicenseUrl,n=t?[YA.FAIRPLAY,YA.WIDEVINE,YA.PLAYREADY,YA.CLEARKEY].filter(e=>!!t[e]):[];return!n[YA.WIDEVINE]&&i&&n.push(YA.WIDEVINE),n}var nD,aD=null!=XA&&null!=(nD=XA.navigator)&&nD.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function rD(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),n=i.substring(i.indexOf("<"),i.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var r=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(r){var o=HA(r).subarray(0,16);return VA(o),o}}return null}var oD={},sD=function(){function e(t,i,n,a=[1],r=null,o){Q(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!zA(t),null!=o&&o.startsWith("0x")&&(this.keyId=new Uint8Array(nT(o)))}return ne(e,[{key:"matches",value:function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&jA(e.keyFormatVersions,this.keyFormatVersions)&&BA(e.iv,this.iv)&&BA(e.keyId,this.keyId)}},{key:"isSupported",value:function(){if(this.method){if(zA(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case JA:case ZA:case QA:case qA:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t,i){if(!this.encrypted||!this.uri)return null;if(zA(this.method)){var n=this.iv;return n||("number"!=typeof t&&(QM.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),n=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){var a=oD[this.uri];if(a&&!jA(this.keyId,a)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}var r,o=KA(this.uri);if(o)switch(this.keyFormat){case ZA:if(this.pssh=o,!this.keyId){var s=function(e){var t=[];if(e instanceof ArrayBuffer)for(var i=e.byteLength,n=0;n+32<i;){var a=KT(new DataView(e,n));t.push(a),n+=a.size}return t}(o.buffer);if(s.length){var u,l=s[0];this.keyId=null!=(u=l.kids)&&u.length?l.kids[0]:null}}this.keyId||(this.keyId=uD(i));break;case QA:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=VT(d,0,o),this.keyId=rD(o);break;default:var h=o.subarray(0,16);if(16!==h.length){var c=new Uint8Array(16);c.set(h,16-h.length),h=c}this.keyId=h}this.keyId&&16===this.keyId.byteLength||(r=function(e){var t=null==e?void 0:e[ZA];if(t)return t.keyId;return null}(i),r||(r=uD(i))||(r=oD[this.uri]),r&&(this.keyId=r,e.setKeyIdForUri(this.uri,r)));return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){oD={}}},{key:"setKeyIdForUri",value:function(e,t){oD[e]=t}},{key:"addKeyIdForUri",value:function(e){var t=Object.keys(oD).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),oD[e]=i,i}}])}();function uD(e){var t=null==e?void 0:e[QA];if(t){var i=KA(t.uri);if(i)return rD(i)}return null}var lD=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,dD=/#EXT-X-MEDIA:(.*)/g,hD=/^#EXT(?:INF|-X-TARGETDURATION):/m,cD=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),mD=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),fD=function(){function e(){Q(this,e)}return ne(e,null,[{key:"findGroup",value:function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return cT.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return hD.test(e)}},{key:"parseMasterPlaylist",value:function(t,i){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:xA(t)},r=[];if(lD.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(n=lD.exec(t));)if(n[1]){var o,s=new FA(n[1],a),u=CA(a,n[2]),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:e.resolve(u,i)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),bD(s.CODECS,l);var h=s["SUPPLEMENTAL-CODECS"];h&&(l.supplemental={},bD(h,l.supplemental)),null!=(o=l.unknownCodecs)&&o.length||r.push(l),a.levels.push(l)}else if(n[3]){var c=n[3],m=n[4];switch(c){case"SESSION-DATA":var f=new FA(m,a),v=f["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=f);break;case"SESSION-KEY":var p=gD(m,i,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):QM.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break;case"DEFINE":IA(a,new FA(m,a),i);break;case"CONTENT-STEERING":var g=new FA(m,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],i),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=yD(m)}}var y=r.length>0&&r.length<a.levels.length;return a.levels=y?r:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,i,n){var a,r={},o=n.levels,s={AUDIO:o.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:o.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},u=0;for(dD.lastIndex=0;null!==(a=dD.exec(t));){var l=new FA(a[1],n),d=l.TYPE;if(d){var h=s[d],c=r[d]||[];r[d]=c;var m=l.LANGUAGE,f=l["ASSOC-LANGUAGE"],v=l.CHANNELS,p=l.CHARACTERISTICS,g=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||m||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:m,url:l.URI?e.resolve(l.URI,i):""};if(f&&(y.assocLang=f),v&&(y.channels=v),p&&(y.characteristics=p),g&&(y.instreamId=g),null!=h&&h.length){var b=e.findGroup(h,y.groupId)||h[0];wD(y,b,"audioCodec"),wD(y,b,"textCodec")}c.push(y)}}return r}},{key:"parseLevelPlaylist",value:function(e,t,i,n,a,r){var o,s,u,l,d,h={url:t},c=new NA(t),m=c.fragments,f=[],v=null,p=0,g=0,y=0,b=0,w=0,k=null,S=new bT(n,h),E=-1,M=!1,T=null;if(cD.lastIndex=0,c.m3u8=e,c.hasVariableRefs=xA(e),"#EXTM3U"!==(null==(o=cD.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(s=cD.exec(e));){M&&(M=!1,(S=new bT(n,h)).playlistOffset=y,S.setStart(y),S.sn=p,S.cc=b,w&&(S.bitrate=w),S.level=i,v&&(S.initSegment=v,v.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),T&&(S.setByteRange(T),T=null)));var P=s[1];if(P){S.duration=parseFloat(P);var A=(" "+s[2]).slice(1);S.title=A||null,S.tagList.push(A?["INF",P,A]:["INF",P])}else if(s[3]){if(AM(S.duration)){S.playlistOffset=y,S.setStart(y),l&&ED(S,l,c),S.sn=p,S.level=i,S.cc=b,m.push(S);var D=(" "+s[3]).slice(1);S.relurl=CA(c,D),kD(S,k,f),k=S,y+=S.duration,p++,g=0,M=!0}}else{if(!(s=s[0].match(mD))){QM.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var x=(" "+s[u]).slice(1),C=(" "+s[u+1]).slice(1),I=s[u+2]?(" "+s[u+2]).slice(1):null;switch(x){case"BYTERANGE":k?S.setByteRange(C,k):S.setByteRange(C);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=C,S.tagList.push(["PROGRAM-DATE-TIME",C]),-1===E&&(E=m.length);break;case"PLAYLIST-TYPE":c.type&&MD(c,x,s),c.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?MD(c,x,s):m.length>0&&TD(c,x,s),p=c.startSN=parseInt(C);break;case"SKIP":c.skippedSegments&&MD(c,x,s);var L=new FA(C,c),_=L.decimalInteger("SKIPPED-SEGMENTS");if(AM(_)){c.skippedSegments+=_;for(var R=_;R--;)m.push(null);p+=_}var F=L.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==c.targetduration&&MD(c,x,s),c.targetduration=Math.max(parseInt(C),1);break;case"VERSION":null!==c.version&&MD(c,x,s),c.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||MD(c,x,s),c.live=!1;break;case"#":(C||I)&&S.tagList.push(I?[C,I]:[C]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([x]);break;case"BITRATE":S.tagList.push([x,C]),w=1e3*parseInt(C),AM(w)?S.bitrate=w:w=0;break;case"DATERANGE":var W=new FA(C,c),O=new $A(W,c.dateRanges[W.ID],c.dateRangeTagCount);c.dateRangeTagCount++,O.isValid||c.skippedSegments?c.dateRanges[O.id]=O:QM.warn(`Ignoring invalid DATERANGE tag: "${C}"`),S.tagList.push(["EXT-X-DATERANGE",C]);break;case"DEFINE":var $=new FA(C,c);"IMPORT"in $?LA(c,$,r):IA(c,$,t);break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?MD(c,x,s):m.length>0&&TD(c,x,s),c.startCC=b=parseInt(C);break;case"KEY":var N=gD(C,t,c);if(N.isSupported()){if("NONE"===N.method){l=void 0;break}l||(l={});var j=l[N.keyFormat];null!=j&&j.matches(N)||(j&&(l=UM({},l)),l[N.keyFormat]=N)}else QM.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${C}"`);break;case"START":c.startTimeOffset=yD(C);break;case"MAP":var B=new FA(C,c);if(S.duration){var z=new bT(n,h);SD(z,B,i,l),v=z,S.initSegment=v,v.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime)}else{var U=S.byteRangeEndOffset;if(U){var H=S.byteRangeStartOffset;T=`${U-H}@${H}`}else T=null;SD(S,B,i,l),v=S,M=!0}v.cc=b;break;case"SERVER-CONTROL":d&&MD(c,x,s),d=new FA(C),c.canBlockReload=d.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=d.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&d.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=d.optionalFloat("PART-HOLD-BACK",0),c.holdBack=d.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&MD(c,x,s);var G=new FA(C);c.partTarget=G.decimalFloatingPoint("PART-TARGET");break;case"PART":var V=c.partList;V||(V=c.partList=[]);var K=g>0?V[V.length-1]:void 0,X=g++,Y=new FA(C,c),q=new wT(Y,S,h,X,K);V.push(q),S.duration+=q.duration;break;case"PRELOAD-HINT":var J=new FA(C,c);c.preloadHint=J;break;case"RENDITION-REPORT":var Q=new FA(C,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(Q);break;default:QM.warn(`line parsed but not handled: ${s}`)}}}k&&!k.relurl?(m.pop(),y-=k.duration,c.partList&&(c.fragmentHint=k)):c.partList&&(kD(S,k,f),S.cc=b,c.fragmentHint=S,l&&ED(S,l,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var Z=m.length,ee=m[0],te=m[Z-1];if((y+=c.skippedSegments*c.targetduration)>0&&Z&&te){c.averagetargetduration=y/Z;var ie=te.sn;c.endSN="initSegment"!==ie?ie:0,c.live||(te.endList=!0),E>0&&(!function(e,t){for(var i=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=i.programDateTime-1e3*a.duration,i=a}}(m,E),ee&&f.unshift(ee))}return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,f.length&&c.dateRangeTagCount&&ee&&vD(f,c),c.endCC=b,c}}])}();function vD(e,t){var i=e.length;if(!i){if(!t.hasProgramDateTime)return;var n=t.fragments[t.fragments.length-1];e.push(n),i++}for(var a=e[i-1],r=t.live?1/0:t.totalduration,o=Object.keys(t.dateRanges),s=o.length;s--;){var u=t.dateRanges[o[s]],l=u.startDate.getTime();u.tagAnchor=a.ref;for(var d=i;d--;){var h;if((null==(h=e[d])?void 0:h.sn)<t.startSN)break;var c=pD(t,l,e,d,r);if(-1!==c){u.tagAnchor=t.fragments[c].ref;break}}}}function pD(e,t,i,n,a){var r=i[n];if(r){var o,s=r.programDateTime;if(t>=s||0===n)if(t<=s+1e3*(((null==(o=i[n+1])?void 0:o.start)||a)-r.start)){var u=i[n].sn-e.startSN;if(u<0)return-1;var l=e.fragments;if(l.length>i.length)for(var d=(i[n+1]||l[l.length-1]).sn-e.startSN;d>u;d--){var h=l[d].programDateTime;if(t>=h&&t<h+1e3*l[d].duration)return d}return u}}return-1}function gD(e,t,i){var n,a,r=new FA(e,i),o=null!=(n=r.METHOD)?n:"",s=r.URI,u=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,d=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!u&&QM.error(`Invalid IV: ${r.IV}`);var h=s?fD.resolve(s,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new sD(o,h,d,c,u,r.KEYID)}function yD(e){var t=new FA(e).decimalFloatingPoint("TIME-OFFSET");return AM(t)?t:null}function bD(e,t){var i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{var n=i.filter(t=>qT(t,e));n.length&&(t[`${e}Codec`]=n.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===n.indexOf(e)))}),t.unknownCodecs=i}function wD(e,t,i){var n=t[i];n&&(e[i]=n)}function kD(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function SD(e,t,i,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function ED(e,t,i){e.levelkeys=t;var n=i.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||n.push(e)}function MD(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function TD(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function PD(e,t){var i=t.startPTS;if(AM(i)){var n,a=0;t.sn>e.sn?(a=i-e.start,n=e):(a=e.start-i,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function AD(e,t,i,n,a,r,o){n-i<=0&&(o.warn("Fragment should have a positive duration",t),n=i+t.duration,r=a+t.duration);var s=i,u=n,l=t.startPTS,d=t.endPTS;if(AM(l)){var h=Math.abs(l-i);e&&h>e.totalduration?o.warn(`media timestamps and playlist times differ by ${h}s for level ${t.level} ${e.url}`):AM(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,s=Math.max(i,l),i=Math.min(i,l),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(n,d),n=Math.max(n,d),r=void 0!==t.endDTS?Math.max(r,t.endDTS):r}var c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(n-t.start),t.startPTS=i,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=u,t.endDTS=r;var m,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,m=v;m>0;m--)PD(p[m],p[m-1]);for(m=v;m<p.length-1;m++)PD(p[m],p[m+1]);return e.fragmentHint&&PD(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function DD(e,t,i){if(e!==t){for(var n,a=null,r=e.fragments,o=r.length-1;o>=0;o--){var s=r[o].initSegment;if(s){a=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){for(var n=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a;l<=r;l++){var d=u[o+l],h=s[l];if(n&&!h&&d&&(h=t.fragments[l]=d),d&&h){i(d,h,l,s);var c=d.relurl,m=h.relurl;if(c&&OD(c,m))return void(t.playlistParsingError=xD(`media sequence mismatch ${h.sn}:`,e,t,d,h));if(d.cc!==h.cc)return void(t.playlistParsingError=xD(`discontinuity sequence mismatch (${d.cc}!=${h.cc})`,e,t,d,h))}}}(e,t,(e,i,r,o)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){for(var s=e.cc-i.cc,u=r;u<o.length;u++)o[u].cc+=s;t.endCC=o[o.length-1].cc}AM(e.startPTS)&&AM(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(n=i),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,l=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&l.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){var n=t.dateRanges,a=t.recentlyRemovedDateranges,r=UM({},e);a&&a.forEach(e=>{delete r[e]});var o=Object.keys(r).length;if(!o)return n;return Object.keys(n).forEach(e=>{var t=r[e],a=new $A(n[e].attr,t);a.isValid?(r[e]=a,t||(a.tagOrder+=o)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${PP(n[e].attr)}"`)}),r}(e.dateRanges,t,i));var h=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var c=1;c<l.length;c++)null===l[c].programDateTime&&kD(l[c],l[c-1],h);vD(h,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var m,f=_D(e,t.startSN-1);t.startCC=null!=(m=null==f?void 0:f.cc)?m:u[0].cc}!function(e,t,i){if(e&&t)for(var n=0,a=0,r=e.length;a<=r;a++){var o=e[a],s=t[a+n];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?i(o,s):n--}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?AD(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,i):CD(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var p=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=p),t.driftEndTime=v,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function xD(e,t,i,n,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${i.startSN}\n${i.m3u8}`)}function CD(e,t,i=!0){var n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,r=n>=0,o=0;if(r&&n<a.length)o=a[n].start;else if(r&&t.startSN===e.endSN+1)o=e.fragmentEnd;else if(r&&i)o=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;o=e.fragmentStart}ID(t,o)}function ID(e,t){if(t){for(var i=e.fragments,n=e.skippedSegments;n<i.length;n++)i[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function LD(e,t=1/0){var i=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*i>t){var a=1e3*n[n.length-1].duration;a<i&&(i=a)}}else i/=2;return Math.round(i)}function _D(e,t,i){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&i&&i.sn===t?i:null)}function RD(e,t,i){return e?FD(e.partList,t,i):null}function FD(e,t,i){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===i&&a.fragment.sn===t)return a}return null}function WD(e){e.forEach((e,t)=>{var i;null==(i=e.details)||i.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function OD(e,t){return!(e===t||!t)&&$D(e)!==$D(t)}function $D(e){return e.replace(/\?[^?]*$/,"")}function ND(e,t){for(var i=0,n=e.length;i<n;i++){var a;if((null==(a=e[i])?void 0:a.cc)===t)return e[i]}return null}function jD(e,t){var i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function BD(e,t){for(var i=t.fragments,n=0,a=i.length;n<a;n++)jD(i[n],e);t.fragmentHint&&jD(t.fragmentHint,e),t.alignedSliding=!0}function zD(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),n=ND(t.fragments,i),a=ND(e.fragments,i);if(n&&a)QM.log(`Aligning playlist at start of dicontinuity sequence ${i}`),BD(n.start-a.start,e)}}function UD(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,n=t.fragments;if(i.length&&n.length){var a,r,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=ND(n,o),r=ND(i,o)),a&&r||(r=ND(i,(a=n[Math.floor(n.length/2)]).cc)||i[Math.floor(i.length/2)]);var s=a.programDateTime,u=r.programDateTime;if(s&&u)BD((u-s)/1e3-(r.start-a.start),e)}}}function HD(e,t,i){GD(e,t,i),e.addEventListener(t,i)}function GD(e,t,i){e.removeEventListener(t,i)}var VD=function(e){for(var t="",i=e.length,n=0;n<i;n++)t+=`[${e.start(n).toFixed(3)}-${e.end(n).toFixed(3)}]`;return t},KD="STOPPED",XD="IDLE",YD="KEY_LOADING",qD="FRAG_LOADING",JD="FRAG_LOADING_WAITING_RETRY",QD="WAITING_TRACK",ZD="PARSING",ex="PARSED",tx="ENDED",ix="ERROR",nx="WAITING_INIT_PTS",ax="WAITING_LEVEL",rx=function(){function e(t,i,n,a,r){var o;return Q(this,e),(o=J(this,e,[a,t.logger])).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=KD,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=()=>{var e=o,t=e.config,i=e.fragCurrent,n=e.media,a=e.mediaBuffer,r=e.state,s=n?n.currentTime:0,u=AA.bufferInfo(a||n,s,t.maxBufferHole),l=!u.len;if(o.log(`Media seeking to ${AM(s)?s.toFixed(3):s}, state: ${r}, ${l?"out of":"in"} buffer`),o.state===tx)o.resetLoadingState();else if(i){var d=t.maxFragLookUpTolerance,h=i.start-d,c=i.start+i.duration+d;if(l||c<u.start||h>u.end){var m=s>c;(s<h||m)&&(m&&i.loader&&(o.log(`Cancelling fragment load for seek (sn: ${i.sn})`),i.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(n&&(o.fragmentTracker.removeFragmentsInRange(s,1/0,o.playlistType,!0),s>o.lastCurrentTime&&(o.lastCurrentTime=s),!o.loadingParts)){var f=Math.max(u.end,s),v=o.shouldLoadParts(o.getLevelDetails(),f);v&&(o.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${f.toFixed(2)}`),o.loadingParts=v)}o.hls.hasEnoughToStart||(o.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),o.nextLoadPosition=s,l&&(o.startPosition=s)),l&&o.state===XD&&o.tickImmediate()},o.onMediaEnded=()=>{o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0},o.playlistType=r,o.hls=t,o.fragmentLoader=new wA(t.config),o.keyLoader=n,o.fragmentTracker=i,o.config=t.config,o.decrypter=new yA(t.config),o}return ue(e,MA),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(LM.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==KD){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=KD}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=AA.bufferedInfo(a,e.start,0));var r=e.nextStart;if(r&&r>n&&r<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var o=t.partList;if(null!=o&&o.length){var s=o[o.length-1];return AA.isBuffered(this.media,s.start+s.duration/2)}var u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}},{key:"getLevelDetails",value:function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var i=this.media=this.mediaBuffer=t.media;HD(i,"seeking",this.onMediaSeeking),HD(i,"ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===KD&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(null!==n){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),GD(n,"seeking",this.onMediaSeeking),GD(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),pe(e,"onHandlerDestroying",this)([]),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=KD,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,pe(e,"onHandlerDestroyed",this)([])}},{key:"loadFragment",value:function(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}},{key:"_loadFragForPlayback",value:function(e,t,i){this._doFragLoad(e,t,i,e=>{var t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(e){var t=this.state,i=e.frag;this.fragContextChanged(i)?(t===qD||!this.fragCurrent&&t===ZD)&&(this.fragmentTracker.removeFragment(i),this.state=XD):("payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(LM.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}}).catch(t=>{this.state!==KD&&this.state!==ix&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}},{key:"clearTrackerIfNeeded",value:function(e){var t,i=this.fragmentTracker;if(i.getState(e)===oA){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),r=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1===(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===sA&&i.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t,i=null){if(e-t){var n={startOffset:e,endOffset:t,type:i};this.hls.trigger(LM.BUFFER_FLUSHING,n)}}},{key:"_loadInitSegment",value:function(e,t){this._doFragLoad(e,t).then(e=>{var t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{var t=this.hls,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&zA(a.method)){var r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,UA(a.method)).catch(e=>{throw t.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(n=>{var a=self.performance.now();return t.trigger(LM.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:r,tdecrypt:a}}),e.payload=n,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==KD&&this.state!==ix&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==KD&&(this.state=XD),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"unhandledEncryptionError",value:function(e,t){var i,n,a=e.tracks;if(a&&!t.encrypted&&(null!=(i=a.audio)&&i.encrypted||null!=(n=a.video)&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(LM.ERROR,{type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?VD(AA.getBuffered(i)):"(detached)"})`),yT(e)){var n;if(e.type!==NM){var a=e.elementaryStreams;if(!Object.keys(a).some(e=>!!a[e]))return void(this.state=XD)}var r=null==(n=this.levels)?void 0:n[e.level];null!=r&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=XD}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var i=e.frag,n=e.part,a=e.partsLoaded,r=!a||0===a.length||a.some(e=>!e),o=new TA(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!r);t.flush(o)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t,i=null,n){var a;this.fragCurrent=e;var r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=YD,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(LM.KEY_LOADED,e),this.state===YD&&(this.state=XD),e}),this.hls.trigger(LM.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var s,u=this.fragPrevious;if(yT(e)&&(!u||e.sn!==u.sn)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} loading sn ${null==u?void 0:u.sn}->${e.sn}`),this.loadingParts=l)}if(i=Math.max(e.start,i||0),this.loadingParts&&yT(e)){var d=r.partList;if(d&&n){i>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);var h=this.getNextPart(d,e,i);if(h>-1){var c,m=d[h];return e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${h}/${d.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=qD,c=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,m,t,n)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,m,t,n).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(LM.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}if(yT(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=r.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),AM(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=qD;var f,v=this.config.progressive&&e.type!==NM;return f=v&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,n)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,v?n:void 0),o]).then(([e])=>(!v&&n&&n(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(LM.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}},{key:"doFragPartsLoad",value:function(e,t,i,n){return new Promise((a,r)=>{var o,s=[],u=null==(o=i.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,n).then(n=>{s[t.index]=n;var r=n.part;this.hls.trigger(LM.FRAG_LOADED,n);var o=RD(i.details,e.sn,t.index+1)||FD(u,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)}).catch(r)};l(t)})}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;t.frag&&t.details===IM.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===CM.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(LM.ERROR,t)}else this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===ZD){var i=t.frag,n=t.part,a=t.level,r=self.performance.now();i.stats.parsing.end=r,n&&(n.stats.parsing.end=r);var o=this.getLevelDetails(),s=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=s),this.updateLevelTiming(i,n,a,e.partial)}else this.fragCurrent||this.state===KD||this.state===ix||(this.state=XD)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,n,a=e.partList[0];if(a.fragment.type===NM)return!1;if(t>=a.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,i=this.fragCurrent,n=e.level,a=e.sn,r=e.part;if(null==t||!t[n])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;var o=t[n],s=o.details,u=r>-1?RD(s,a,r):null,l=u?u.fragment:_D(s,a,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:u,level:o}):null}},{key:"bufferFragmentData",value:function(e,t,i,n,a){if(this.state===ZD){var r=e.data1,o=e.data2,s=r;if(o&&(s=jT(r,o)),s.length){var u=this.initPTS[t.cc],l=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:i,chunkMeta:n,offset:l,parent:t.type,data:s};if(this.hls.trigger(LM.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(AA.isBuffered(t,t.currentTime)){var i=t.currentTime,n=AA.bufferInfo(t,i,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,n.end-r),i+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var i,n=this.getLoadPosition();if(!AM(n))return null;var a=this.lastCurrentTime>n||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,i,n){var a=AA.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var r=this.fragmentTracker.getBufferedFrag(t,i);if(r&&(a.nextStart<=r.end||r.gap)){var o=Math.max(Math.min(a.nextStart,r.end)-t,n);return AA.bufferInfo(e,t,o)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)}},{key:"exceedsMaxBuffer",value:function(e,t,i){var n=e.nextStart;if(n&&i.start>n){var a=e.buffered;if(a){for(var r=e.len,o=e.bufferedIndex,s=a.length-1;s>o;s--)a[s].start<i.start&&(r+=a[s].end-a[s].start);return r>=t}}return!1}},{key:"reduceMaxBufferLength",value:function(e,t){var i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),a=Math.max(e-3*t,i.maxMaxBufferLength/2,n);return a>=n&&(i.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}},{key:"getAppendedFrag",value:function(e,t=OM){var i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var i=t.fragments,n=i.length;if(!n)return null;var a=this.config,r=t.fragmentStart,o=a.lowLatencyMode&&!!t.partList,s=null;if(t.live){var u=a.initialLiveManifestSize;if(n<u)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),s=this.getInitialLiveFragment(t);var d,h,c=this.config.startPosition,m=this.hls.startPosition,f=this.hls.liveSyncPosition,v=(null==(l=s)?void 0:l.start)||0;-1!==m&&m>=r?(d=m,h=m===c?"config":"next load start"):null!==f?(d=f,h="live edge"):(d=e,h="buffer pos"),d<v&&(d=v,h="live frag start"),d<r&&(d=r,h="playlist start"),this.startPosition==d&&this.nextLoadPosition==d||(this.log(`Setting startPosition to ${d.toFixed(3)} ${-1===m?"":`(from ${c}) `}based on ${h}. live edge: ${f} live frag start: ${v.toFixed(3)} playlist start: ${r.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=d)}}else e<=r&&(s=i[0]);if(!s){var p=this.loadingParts?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,p,t)}var g=this.filterReplacedPrimary(s,t);if(!g&&s){var y=s.sn-t.startSN;g=this.filterReplacedPrimary(i[y+1]||null,t)}return this.mapToInitFragWhenRequired(g)}},{key:"isLoopLoading",value:function(e,t){if(this.nextLoadPosition<=t)return!1;var i=this.fragmentTracker.getState(e);return i===uA||i===sA&&!!e.gap}},{key:"getNextFragmentLoopLoading",value:function(e,t,i,n,a){var r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t))&&!r.gap&&i.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(null!==o&&i.len+o.len>=a){var s=r.sn;return this.loopSn!==s&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${s}`),this.loopSn=s),null}}return this.loopSn=void 0,r}},{key:"primaryPrefetch",get:function(){var e;if(ox(this.config)&&(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if(ox(this.config)&&e.type!==NM){var i=this.hls.interstitialsManager,n=null==i?void 0:i.bufferingItem;if(n){var a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||0===n.start)return null}else{if(e.end<=n.start&&!1===(null==t?void 0:t.live))return null;if(e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}}var r=null==i?void 0:i.playerQueue;if(r)for(var o=r.length;o--;){var s=r[o].interstitial;if(s.appendInPlace&&e.start>=s.startTime&&e.end<=s.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,i){for(var n=-1,a=!1,r=!0,o=0,s=e.length;o<s;o++){var u=e[o];if(r=r&&!u.independent,n>-1&&i<u.start)break;var l=u.loaded;l?n=-1:(a||(u.independent||r)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),n=o),a=l}return n}},{key:"loadedEndOfParts",value:function(e,t){for(var i,n=e.length;n--;){if(!(i=e[n]).loaded)return!1;if(t>i.start)return!0}return!1}},{key:"getInitialLiveFragment",value:function(e){var t=e.fragments,i=this.fragPrevious,n=null;if(i){if(e.hasProgramDateTime&&(n=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!AM(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var n=0;n<e.length;++n){var a=e[n];if(NP(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),n&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!n){var a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){var r=t[a-e.startSN];i.cc===r.cc&&(n=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=jP(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,i){var n,a,r=this.config,o=this.fragPrevious,s=i.fragments,u=i.endSN,l=i.fragmentHint,d=r.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&l);(c&&!this.bitrateTest&&h[h.length-1].fragment.sn===l.sn&&(s=s.concat(l),u=l.sn),e<t)?n=OP(o,s,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):n=s[s.length-1];if(n){var m=n.sn-i.startSN,f=this.fragmentTracker.getState(n);if((f===uA||f===sA&&n.gap)&&(o=n),o&&n.sn===o.sn&&(!c||h[0].fragment.sn>n.sn||!i.live))if(n.level===o.level){var v=s[m+1];n=n.sn<u&&this.fragmentTracker.getState(v)!==uA?v:null}}return n}},{key:"alignPlaylists",value:function(e,t,i){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,r=!t,o=e.alignedSliding&&AM(a);if(r||!o&&!a){!function(e,t){e&&(zD(t,e),t.alignedSliding||UD(t,e),t.alignedSliding||t.skippedSegments||CD(e,t,!1))}(i,e);var s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),s}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var i=this.startPosition;i<t&&(i=-1);var n=this.timelineOffset;if(-1===i){var a=null!==this.startTimeOffset,r=a?this.startTimeOffset:e.startTimeOffset;null!==r&&AM(r)?(i=t+r,r<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${r} found in ${a?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}},{key:"getLoadPosition",value:function(){var e,t=this.media,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&yT(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===JD)||(this.state=XD)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var i;if(t.chunkMeta&&!t.frag){var n=this.getCurrentContext(t.chunkMeta);n&&(t.frag=n.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var r;this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`)}else{var o=t.details===IM.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(a,!0);var s=t.errorAction;if(s){var u=s.action,l=s.flags,d=s.retryCount,h=void 0===d?0:d,c=s.retryConfig,m=!!c,f=m&&u===QP,v=m&&!s.resolved&&l===eA,p=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&v&&yT(a)&&!a.endList&&p&&!UP(t))this.resetFragmentErrors(e),this.treatAsGap(a),s.resolved=!0;else if((f||v)&&h<c.maxNumRetry){var g,y=XP(null==(g=t.response)?void 0:g.code),b=GP(c,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=JD,s.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${c.maxNumRetry} in ${b}ms`)}else if(c){if(this.resetFragmentErrors(e),!(h<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);o||u===JP||(s.resolved=!0)}else this.state=u===qP?ax:ix;this.tickImmediate()}else this.state=ix}}},{key:"checkRetryDate",value:function(){var e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!XP(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=XD)}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===ZD||this.state===ex){var t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var r=!a;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}},{key:"resetFragmentErrors",value:function(e){e===$M&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==KD&&(this.state=XD)}},{key:"afterBufferFlushed",value:function(e,t,i){if(e){var n=AA.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===tx&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==KD&&(this.state=XD)}},{key:"resetStartWhenNotLoaded",value:function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,i,n){var a=i.details;if(a){if(!Object.keys(e.elementaryStreams).reduce((t,r)=>{var o=e.elementaryStreams[r];if(o){var s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${s})`),t||!1;var u=n?0:AD(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,this);return this.hls.trigger(LM.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1)){var r,o=null===(null==(r=this.transmuxer)?void 0:r.error);if((0===i.fragmentError||o&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),o){var s=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(s.message),this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=ex,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(LM.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===OM?"level":"track"}},{key:"fragInfo",value:function(e,t=!0,i){var n,a;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(n=t&&!i?e.startPTS:(i||e).start)?n:NaN).toFixed(3)}-${(null!=(a=t&&!i?e.endPTS:(i||e).end)?a:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}}])}();function ox(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var sx=function(){return ne(function e(){Q(this,e),this.chunks=[],this.dataLength=0},[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var i=new Uint8Array(t),n=0,a=0;a<e.length;a++){var r=e[a];i.set(r,n),n+=r.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}])}();var ux,lx={exports:{}};var dx=(ux||(ux=1,function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function r(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,r||e,o),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),s.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,r=n.length,o=new Array(r);a<r;a++)o[a]=n[a].fn;return o},s.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,a,r,o){var s=i?i+e:e;if(!this._events[s])return!1;var u,l,d=this._events[s],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,a),!0;case 5:return d.fn.call(d.context,t,n,a,r),!0;case 6:return d.fn.call(d.context,t,n,a,r,o),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,m=d.length;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,n);break;case 4:d[l].fn.call(d[l].context,t,n,a);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},s.prototype.on=function(e,t,i){return r(this,e,t,i,!1)},s.prototype.once=function(e,t,i){return r(this,e,t,i,!0)},s.prototype.removeListener=function(e,t,n,a){var r=i?i+e:e;if(!this._events[r])return this;if(!t)return o(this,r),this;var s=this._events[r];if(s.fn)s.fn!==t||a&&!s.once||n&&s.context!==n||o(this,r);else{for(var u=0,l=[],d=s.length;u<d;u++)(s[u].fn!==t||a&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[r]=1===l.length?l[0]:l:o(this,r)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=i,s.EventEmitter=s,e.exports=s}(lx)),lx.exports),hx=aT(dx),cx="1.6.16",mx={};function fx(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function vx(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function px(e,t){var i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3]}function gx(e,t){for(var i=t,n=0;vx(e,t);){n+=10,n+=px(e,t+6),fx(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(i,i+n)}function yx(e,t){return 255===e[t]&&240==(246&e[t+1])}function bx(e,t){return 1&e[t+1]?7:9}function wx(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function kx(e,t){return t+1<e.length&&yx(e,t)}function Sx(e,t){if(kx(e,t)){var i=bx(e,t);if(t+i>=e.length)return!1;var n=wx(e,t);if(n<=i)return!1;var a=t+n;return a===e.length||kx(e,a)}return!1}function Ex(e,t,i,n,a){if(!e.samplerate){var r=function(e,t,i,n){var a=t[i+2],r=a>>2&15;if(!(r>12)){var o=1+(a>>6&3),s=t[i+3]>>6&3|(1&a)<<2,u="mp4a.40."+o,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r],d=r;5!==o&&29!==o||(d-=3);var h=[o<<3|(14&d)>>1,(1&d)<<7|s<<3];return QM.log(`manifest codec:${n}, parsed codec:${u}, channels:${s}, rate:${l} (ADTS object type:${o} sampling index:${r})`),{config:h,samplerate:l,channelCount:s,codec:u,parsedCodec:u,manifestCodec:n}}var c=new Error(`invalid ADTS sampling index:${r}`);e.emit(LM.ERROR,LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,i,n,a);if(!r)return;UM(e,r)}}function Mx(e){return 9216e4/e}function Tx(e,t,i,n,a){var r,o=n+a*Mx(e.samplerate),s=function(e,t){var i=bx(e,t);if(t+i<=e.length){var n=wx(e,t)-i;if(n>0)return{headerLength:i,frameLength:n}}}(t,i);if(s){var u=s.frameLength,l=s.headerLength,d=l+u,h=Math.max(0,i+d-t.length);h?(r=new Uint8Array(d-l)).set(t.subarray(i+l,t.length),0):r=t.subarray(i+l,i+d);var c={unit:r,pts:o};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var m=t.length-i;return(r=new Uint8Array(m)).set(t.subarray(i,t.length),0),{sample:{unit:r,pts:o},length:m,missing:-1}}function Px(e,t){return vx(e,t)&&px(e,t+6)+10<=e.length-t}function Ax(e,t=0,i=1/0){return function(e,t,i,n){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),r=1;"BYTES_PER_ELEMENT"in n&&(r=n.BYTES_PER_ELEMENT);var o=(h=e,h&&h.buffer instanceof ArrayBuffer&&void 0!==h.byteLength&&void 0!==h.byteOffset?e.byteOffset:0),s=(o+e.byteLength)/r,u=(o+t)/r,l=Math.floor(Math.max(0,Math.min(u,s))),d=Math.floor(Math.min(l+Math.max(i,0),s));var h;return new n(a,l,d-l)}(e,t,i,Uint8Array)}function Dx(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var i=e.data.subarray(1).indexOf(0);if(-1!==i){var n=tT(Ax(e.data,1,i)),a=e.data[2+i],r=e.data.subarray(3+i).indexOf(0);if(-1!==r){var o,s=tT(Ax(e.data,3+i,r));return o="--\x3e"===n?tT(Ax(e.data,4+i+r)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+r)),t.mimeType=n,t.pictureType=a,t.description=s,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function xx(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=tT(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=tT(e.data.subarray(t),!0);t+=i.length+1;var n=tT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=tT(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?Dx(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=tT(e.data.subarray(t),!0);t+=i.length+1;var n=tT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=tT(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function Cx(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=px(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function Ix(e){for(var t=0,i=[];vx(e,t);){var n=px(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+n;t+10<a;){var r=Cx(e.subarray(t)),o=xx(r);o&&i.push(o),t+=r.size+10}fx(e,t)&&(t+=10)}return i}function Lx(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function _x(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),i=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}}function Rx(e){for(var t=Ix(e),i=0;i<t.length;i++){var n=t[i];if(Lx(n))return _x(n)}}var Fx=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function Wx(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var Ox=function(){return ne(function e(){Q(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null},[{key:"resetInitSegment",value:function(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,i){}},{key:"demux",value:function(e,t){this.cachedData&&(e=jT(this.cachedData,e),this.cachedData=null);var i,n=gx(e,0),a=n?n.length:0,r=this._audioTrack,o=this._id3Track,s=n?Rx(n):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&AM(s))&&(this.basePTS=$x(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Fx.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var l=this.appendFrame(r,e,a);l?(this.frameIndex++,this.lastPTS=l.sample.pts,i=a+=l.length):a=u}else Px(e,a)?(n=gx(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Fx.audioId3,duration:Number.POSITIVE_INFINITY}),i=a+=n.length):a++;if(a===u&&i!==u){var d=e.slice(i);this.cachedData?this.cachedData=jT(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:Wx(),id3Track:o,textTrack:Wx()}}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Wx(),id3Track:this._id3Track,textTrack:Wx()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}])}(),$x=(e,t,i)=>AM(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),Nx=null,jx=[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],Bx=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],zx=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ux=[0,1,1,4];function Hx(e,t,i,n,a){if(!(i+24>t.length)){var r=Gx(t,i);if(r&&i+r.frameLength<=t.length){var o=n+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(i,i+r.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=r.channelCount,e.samplerate=r.sampleRate,e.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function Gx(e,t){var i=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==r){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*jx[14*(3===i?3-n:3===n?3:4)+a-1],l=Bx[3*(3===i?0:2===i?1:2)+r],d=3===s?1:2,h=zx[i][n],c=Ux[n],m=8*h*c,f=Math.floor(h*u/l+o)*c;if(null===Nx){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nx=v?parseInt(v[1]):0}return!!Nx&&Nx<=87&&2===n&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:f,samplesPerFrame:m}}}function Vx(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Kx(e,t){return t+1<e.length&&Vx(e,t)}function Xx(e,t){if(t+1<e.length&&Vx(e,t)){var i=Gx(e,t),n=4;null!=i&&i.frameLength&&(n=i.frameLength);var a=t+n;return a===e.length||Kx(e,a)}return!1}var Yx=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e)).observer=void 0,n.config=void 0,n.observer=t,n.config=i,n}return ue(e,Ox),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&yx(e,t)&&wx(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){Ex(e,this.observer,t,i,e.manifestCodec);var n=Tx(e,t,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var i=gx(e,0),n=(null==i?void 0:i.length)||0;if(Xx(e,n))return!1;for(var a=e.length;n<a;n++)if(Sx(e,n))return t.log("ADTS sync word found !"),!0;return!1}}])}(),qx=(e,t)=>{var i=0,n=5;t+=n;for(var a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);n>0;){o[0]=e[t];var s=Math.min(n,8),u=8-s;r[0]=4278190080>>>24+u<<u,a[0]=(o[0]&r[0])>>u,i=i?i<<s|a[0]:a[0],t+=1,n-=s}return i},Jx=function(){function e(t){var i;return Q(this,e),(i=J(this,e)).observer=void 0,i.observer=t,i}return ue(e,Ox),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,i){var n=Qx(e,t,i,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=gx(e,0);if(!t)return!1;var i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==Rx(t)&&qx(e,i)<16}}])}();function Qx(e,t,i,n,a){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var r=t[i+4]>>6;if(r>=3)return-1;var o=[48e3,44100,32e3][r],s=63&t[i+4],u=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*s+r];if(i+u>t.length)return-1;var l=t[i+6]>>5,d=0;2===l?d+=2:(1&l&&1!==l&&(d+=2),4&l&&(d+=2));var h=(t[i+6]<<8|t[i+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][l]+h,m=t[i+5]>>3,f=7&t[i+5],v=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|h<<2|s>>4,s<<4&224]),p=n+a*(1536/o*9e4),g=t.subarray(i,i+u);return e.config=v,e.channelCount=c,e.samplerate=o,e.samples.push({unit:g,pts:p}),u}var Zx=function(){function e(){return Q(this,e),J(this,e,arguments)}return ue(e,Ox),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return Vx(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){if(null!==this.basePTS)return Hx(e,t,i,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=gx(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==Rx(t)&&qx(e,i)<=16)return!1;for(var n=e.length;i<n;i++)if(Xx(e,i))return QM.log("MPEG Audio sync word found !"),!0;return!1}}])}(),eC=/\/emsg[-/]ID3/i,tC=function(){return ne(function e(t,i){Q(this,e),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=i},[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,i,n){var a=this.videoTrack=Wx("video",1),r=this.audioTrack=Wx("audio",1),o=this.txtTrack=Wx("text",1);if(this.id3Track=Wx("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var s=LT(e);if(s.video){var u=s.video,l=u.id,d=u.timescale,h=u.codec,c=u.supplemental;a.id=l,a.timescale=o.timescale=d,a.codec=h,a.supplemental=c}if(s.audio){var m=s.audio,f=m.id,v=m.timescale,p=m.codec;r.id=f,r.timescale=v,r.codec=p}o.id=MT.text,a.sampleDuration=0,a.duration=r.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var i=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=jT(this.remainderData,e));var r=function(e){var t={valid:null,remainder:null},i=CT(e,["moof"]);if(i.length<2)return t.remainder=e,t;var n=i[i.length-1];return t.valid=e.slice(0,n.byteOffset-8),t.remainder=e.slice(n.byteOffset-8),t}(i);this.remainderData=r.remainder,n.samples=r.valid||new Uint8Array}else n.samples=i;var o=this.extractID3Track(n,t);return a.samples=BT(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return i.samples=BT(e,t),{videoTrack:t,audioTrack:Wx(),id3Track:n,textTrack:Wx()}}},{key:"extractID3Track",value:function(e,t){var i=this.id3Track;if(e.samples.length){var n=CT(e.samples,["emsg"]);n&&n.forEach(e=>{var n=function(e){var t=e[0],i="",n="",a=0,r=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==TT(e.subarray(l,l+1));)i+=TT(e.subarray(l,l+1)),l+=1;for(i+=TT(e.subarray(l,l+1)),l+=1;"\0"!==TT(e.subarray(l,l+1));)n+=TT(e.subarray(l,l+1)),l+=1;n+=TT(e.subarray(l,l+1)),l+=1,a=AT(e,12),r=AT(e,16),s=AT(e,20),u=AT(e,24),l=28}else if(1===t){a=AT(e,l+=4);var d=AT(e,l+=4),h=AT(e,l+=4);for(l+=4,DM(o=2**32*d+h)||(o=Number.MAX_SAFE_INTEGER,QM.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=AT(e,l),u=AT(e,l+=4),l+=4;"\0"!==TT(e.subarray(l,l+1));)i+=TT(e.subarray(l,l+1)),l+=1;for(i+=TT(e.subarray(l,l+1)),l+=1;"\0"!==TT(e.subarray(l,l+1));)n+=TT(e.subarray(l,l+1)),l+=1;n+=TT(e.subarray(l,l+1)),l+=1}return{schemeIdUri:i,value:n,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(eC.test(n.schemeIdUri)){var a=iC(n,t),r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);var o=n.payload;i.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:Fx.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var s=iC(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:s,pts:s,type:Fx.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,i=0;i<t;){var n=AT(e,i);if(n>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=n>1?i+n:t}return!1}(e)}}])}();function iC(e,t){return AM(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var nC=function(){return ne(function e(t,i,n){Q(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new yA(i,{removePKCS7Padding:!1})},[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,mA)}},{key:"decryptAacSample",value:function(e,t,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then(a=>{var r=new Uint8Array(a);n.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}}},{key:"decryptAacSamples",value:function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var i=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,i,n,a){var r=GT(a.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(o=>{a.data=this.getAvcDecryptedUnit(r,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}},{key:"decryptAvcSamples",value:function(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void n();for(var a=e[t].units;!(i>=a.length);i++){var r=a[i];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,i,n,r),this.decrypter.isSync())))return}}}}])}(),aC=function(){return ne(function e(){Q(this,e),this.VideoSample=null},[{key:"createVideoSample",value:function(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,i,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;i=a[a.length-1]}return i}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,n=i.length;if(!n)return void t.dropped++;var a=i[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,i){var n,a,r=t.byteLength,o=e.naluState||0,s=o,u=[],l=0,d=-1,h=0;for(-1===o&&(d=0,h=this.getNALuType(t,0),o=0,l=1);l<r;)if(n=t[l++],o)if(1!==o)if(n)if(1===n){if(a=l-o-1,d>=0){var c={data:t.subarray(d,a),type:h};u.push(c)}else{var m=this.getLastNalUnit(e.samples);m&&(s&&l<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),a>0&&(m.data=jT(m.data,t.subarray(0,a)),m.state=0))}l<r?(d=l,h=this.getNALuType(t,l),o=0):o=-1}else o=0;else o=3;else o=n?0:2;else o=n?0:1;if(d>=0&&o>=0){var f={data:t.subarray(d,r),type:h,state:o};u.push(f)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=jT(v.data,t))}return e.naluState=o,u}}])}(),rC=function(){return ne(function e(t){Q(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0},[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&QM.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}])}(),oC=function(){function e(){return Q(this,e),J(this,e,arguments)}return ue(e,aC),ne(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 1:var l=!1;a=!0;var d,h=n.data;if(s&&h.length>4){var c=this.readSliceType(h);2!==c&&4!==c&&7!==c&&9!==c||(l=!0)}if(l)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=l;break;case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,HT(n.data,1,i.pts,t.samples);break;case 7:var m,f;a=!0,s=!0;var v=n.data,p=this.readSPS(v);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(m=e.pixelRatio)?void 0:m[0])!==p.pixelRatio[0]||(null==(f=e.pixelRatio)?void 0:f[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),y="avc1.",b=0;b<3;b++){var w=g[b].toString(16);w.length<2&&(w="0"+w),y+=w}e.codec=y}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new rC(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var i=8,n=8,a=0;a<e;a++)0!==n&&(n=(i+t.readEG()+256)%256),i=0===n?i:n}},{key:"readSPS",value:function(e){var t,i,n,a=new rC(e),r=0,o=0,s=0,u=0,l=a.readUByte.bind(a),d=a.readBits.bind(a),h=a.readUEG.bind(a),c=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),v=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);l();var g=l();if(d(5),m(3),l(),v(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var y=h();if(3===y&&m(1),v(),v(),m(1),c())for(i=3!==y?8:12,n=0;n<i;n++)c()&&p(n<6?16:64,a)}v();var b=h();if(0===b)h();else if(1===b)for(m(1),f(),f(),t=h(),n=0;n<t;n++)f();v(),m(1);var w=h(),k=h(),S=d(1);0===S&&m(1),m(1),c()&&(r=h(),o=h(),s=h(),u=h());var E=[1,1];if(c()&&c())switch(l()){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=[l()<<8|l(),l()<<8|l()]}return{width:Math.ceil(16*(w+1)-2*r-2*o),height:(2-S)*(k+1)*16-(S?2:4)*(s+u),pixelRatio:E}}}])}(),sC=function(){function e(...t){var i;return Q(this,e),(i=J(this,e,[...t])).initVPS=null,i}return ue(e,aC),ne(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var l;if(a=!0,s)null!=(l=o)&&l.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,HT(n.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=UM(e.params,this.readVPS(n.data)),this.initVPS=n.data),e.vps=[n.data];break;case 33:if(a=!0,s=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],n.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=this.readSPS(n.data);for(var h in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),d.params)e.params[h]=d.params[h]}this.pushParameterSet(e.sps,n.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0;break;case 34:if(a=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var c=this.readPPS(n.data);for(var m in c)e.params[m]=c[m]}this.pushParameterSet(e.pps,n.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),i=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}},{key:"pushAccessUnit",value:function(t,i){pe(e,"pushAccessUnit",this)([t,i]),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new rC(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new rC(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var n=t.readBits(2),a=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),s=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),m=t.readUByte(),f=t.readUByte(),v=t.readUByte(),p=t.readUByte(),g=[],y=[],b=0;b<i;b++)g.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(var w=i;w<8;w++)t.readBits(2);for(var k=0;k<i;k++)g[k]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[k]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var E=t.readUEG(),M=t.readUEG(),T=t.readBoolean(),P=0,A=0,D=0,x=0;T&&(P+=t.readUEG(),A+=t.readUEG(),D+=t.readUEG(),x+=t.readUEG());for(var C=t.readUEG(),I=t.readUEG(),L=t.readUEG(),_=t.readBoolean()?0:i;_<=i;_++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var R=0;R<4;R++)for(var F=0;F<(3===R?2:6);F++){if(t.readBoolean()){var W=Math.min(64,1<<4+(R<<1));R>1&&t.readEG();for(var O=0;O<W;O++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var $=t.readUEG(),N=0,j=0;j<$;j++){var B=!1;if(0!==j&&(B=t.readBoolean()),B){j===$&&t.readUEG(),t.readBoolean(),t.readUEG();for(var z=0,U=0;U<=N;U++){var H=t.readBoolean(),G=!1;H||(G=t.readBoolean()),(H||G)&&z++}N=z}else{var V=t.readUEG(),K=t.readUEG();N=V+K;for(var X=0;X<V;X++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var q=t.readUEG(),J=0;J<q;J++){for(var Q=0;Q<L+4;Q++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ie=!0,ne=1,ae=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){var re=t.readUByte();re>0&&re<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][re-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][re-1]):255===re&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean())if(ne=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),se=t.readBoolean(),ue=!1;(oe||se)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var le=0;le<=i;le++){var de=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var he=de?1:t.readUEG()+1;if(oe)for(var ce=0;ce<he;ce++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(se)for(var me=0;me<he;me++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var fe=E,ve=M;if(T){var pe=1,ge=1;1===S?pe=ge=2:2==S&&(pe=2),fe=E-pe*A-pe*P,ve=M-ge*x-ge*D}for(var ye=n?["A","B","C"][n]:"",be=o<<24|s<<16|u<<8|l,we=0,ke=0;ke<32;ke++)we=(we|(be>>ke&1)<<31-ke)>>>0;var Se=we.toString(16);return 1===r&&"2"===Se&&(Se="6"),{codecString:`hvc1.${ye}${r}.${Se}.${a?"H":"L"}${p}.B0`,params:{general_tier_flag:a,general_profile_idc:r,general_profile_space:n,general_profile_compatibility_flags:[o,s,u,l],general_constraint_indicator_flags:[d,h,c,m,f,v],general_level_idc:p,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:Z,chroma_format_idc:S,frame_rate:{fixed:ie,fps:ae/ne}},width:fe,height:ve,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new rC(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),n=t.readBoolean(),a=1;return n&&i?a=0:n?a=3:i&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}])}(),uC=188,lC=function(){function e(t,i,n,a){Q(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,i,n=!1,a=!1){var r;n||(this.sampleAes=null);var o=this._videoTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=o.pid,h=o.pesData,c=s.pid,m=u.pid,f=s.pesData,v=u.pesData,p=null,g=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=jT(this.remainderData,t)).length,this.remainderData=null),b<uC&&!a)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var w=Math.max(0,e.syncOffset(t));(b-=(b-w)%uC)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,b,t.buffer.byteLength-b));for(var k=0,S=w;S<b;S+=uC)if(71===t[S]){var E=!!(64&t[S+1]),M=dC(t,S),T=void 0;if((48&t[S+3])>>4>1){if((T=S+5+t[S+4])===S+uC)continue}else T=S+4;switch(M){case d:E&&(h&&(r=vC(h,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,l,r,!1)),h={data:[],size:0}),h&&(h.data.push(t.subarray(T,S+uC)),h.size+=S+uC-T);break;case c:if(E){if(f&&(r=vC(f,this.logger)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(T,S+uC)),f.size+=S+uC-T);break;case m:E&&(v&&(r=vC(v,this.logger))&&this.parseID3PES(u,r),v={data:[],size:0}),v&&(v.data.push(t.subarray(T,S+uC)),v.size+=S+uC-T);break;case 0:E&&(T+=t[T]+1),y=this._pmtId=hC(t,T);break;case y:E&&(T+=t[T]+1);var P=cC(t,T,this.typeSupported,n,this.observer,this.logger);(d=P.videoPid)>0&&(o.pid=d,o.segmentCodec=P.segmentVideoCodec),(c=P.audioPid)>0&&(s.pid=c,s.segmentCodec=P.segmentAudioCodec),(m=P.id3Pid)>0&&(u.pid=m),null===p||g||(this.logger.warn(`MPEG-TS PMT found at ${S} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,S=w-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=M}}else k++;k>0&&mC(this.observer,new Error(`Found ${k} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=h,s.pesData=f,u.pesData=v;var A={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return a&&this.extractRemainingSamples(A),A}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,i=e.audioTrack,n=e.videoTrack,a=e.id3Track,r=e.textTrack,o=n.pesData,s=i.pesData,u=a.pesData;if(o&&(t=vC(o,this.logger))?(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(n,r,t,!0),n.pesData=null)):n.pesData=o,s&&(t=vC(s,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=s&&s.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=s;u&&(t=vC(u,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u}},{key:"demuxSampleAes",value:function(e,t,i){var n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new nC(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"readyVideoParser",value:function(e){null===this.videoParser&&("avc"===e?this.videoParser=new oC:"hevc"===e&&(this.videoParser=new sC))}},{key:"decrypt",value:function(e,t){return new Promise(i=>{var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var i,n,a,r=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u)s=jT(o.sample.unit,s);else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),r=o.missing}}for(i=r,n=s.length;i<n-1&&!kx(s,i);i++);if(i!==r){var h,c=i<n-1;if(h=c?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",mC(this.observer,new Error(h),c,this.logger),!c)return}if(Ex(e,this.observer,s,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=Mx(e.samplerate);a=o.sample.pts+m}for(var f,v=0;i<n;){if(i+=(f=Tx(e,s,i,a,v)).length,f.missing){this.aacOverFlow=f;break}for(v++;i<n-1&&!kx(s,i);i++);}}},{key:"parseMPEGPES",value:function(e,t){var i=t.data,n=i.length,a=0,r=0,o=t.pts;if(void 0!==o)for(;r<n;)if(Kx(i,r)){var s=Hx(e,i,r,o,a);if(!s)break;r+=s.length,a++}else r++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var i=t.data,n=t.pts;if(void 0!==n)for(var a,r=i.length,o=0,s=0;s<r&&(a=Qx(e,i,s,n,o++))>0;)s+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var i=UM({},t,{type:this._videoTrack?Fx.emsg:Fx.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,i){var n=e.syncOffset(t);return n>0&&i.warn(`MPEG2-TS detected but first sync word found @ offset ${n}`),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,i=Math.min(940,t-uC)+1,n=0;n<i;){for(var a=!1,r=-1,o=0,s=n;s<t;s+=uC){if(71!==e[s]||t-s!==uC&&71!==e[s+uC]){if(o)return-1;break}if(o++,-1===r&&0!==(r=s)&&(i=Math.min(r+18612,e.length-uC)+1),a||(a=0===dC(e,s)),a&&o>1&&(0===r&&o>2||s+uC>i))return r}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:MT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}])}();function dC(e,t){return((31&e[t+1])<<8)+e[t+2]}function hC(e,t){return(31&e[t+10])<<8|e[t+11]}function cC(e,t,i,n,a,r){var o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var u=dC(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){fC("ADTS AAC",r);break}case 15:-1===o.audioPid&&(o.audioPid=u);break;case 21:-1===o.id3Pid&&(o.id3Pid=u);break;case 219:if(!n){fC("H.264",r);break}case 27:-1===o.videoPid&&(o.videoPid=u);break;case 3:case 4:i.mpeg||i.mp3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="mp3"):r.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){fC("AC-3",r);break}case 129:i.ac3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===o.audioPid&&l>0)for(var d=t+5,h=l;h>2;){if(106===e[d])!0!==i.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=u,o.segmentAudioCodec="ac3");var c=e[d+1]+2;d+=c,h-=c}break;case 194:case 135:return mC(a,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:-1===o.videoPid&&(o.videoPid=u,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}t+=l+5}return o}function mC(e,t,i,n){n.warn(`parsing error: ${t.message}`),e.emit(LM.ERROR,LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function fC(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function vC(e,t){var i,n,a,r,o,s=0,u=e.data;if(!e||0===e.size)return null;for(;u[0].length<19&&u.length>1;)u[0]=jT(u[0],u[1]),u.splice(1,1);if(1===((i=u[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>e.size-6)return null;var l=i[7];192&l&&(r=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&l?r-(o=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o):o=r);var d=(a=i[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,m=u.length;c<m;c++){var f=(i=u[c]).byteLength;if(d){if(d>f){d-=f;continue}i=i.subarray(d),f-=d,d=0}h.set(i,s),s+=f}return n&&(n-=a+3),{data:h,pts:r,dts:o,len:n}}return null}var pC=function(){return ne(function e(){Q(this,e)},null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}])}(),gC=Math.pow(2,32)-1,yC=function(){function e(){Q(this,e)}return ne(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),n=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]);e.HDLR_TYPES={video:i,audio:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=r,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,u,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e,...t){for(var i=8,n=t.length,a=n;n--;)i+=t[n].byteLength;var r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),n=0,i=8;n<a;n++)r.set(t[n],i),i+=t[n].byteLength;return r}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,i){i*=t;var n=Math.floor(i/(gC+1)),a=Math.floor(i%(gC+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,i,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,i))}},{key:"moov",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(n).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex,...n])}},{key:"mvhd",value:function(t,i){i*=t;var n=Math.floor(i/(gC+1)),a=Math.floor(i%(gC+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,r)}},{key:"sdtp",value:function(t){var i,n,a=t.samples||[],r=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)n=a[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,r)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var i,n,a,r=[],o=[];for(i=0;i<t.sps.length;i++)a=(n=t.sps[i]).byteLength,r.push(a>>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(n));for(i=0;i<t.pps.length;i++)a=(n=t.pps[i]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var i=t.segmentCodec;if("audio"===t.type){if("aac"===i)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===i&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===i&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${i}/${t.codec})`)}},{key:"tkhd",value:function(t){var i=t.id,n=(t.duration||0)*(t.timescale||0),a=t.width||0,r=t.height||0,o=Math.floor(n/(gC+1)),s=Math.floor(n%(gC+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,r>>8&255,255&r,0,0]))}},{key:"traf",value:function(t,i){var n=e.sdtp(t),a=t.id,r=Math.floor(i/(gC+1)),o=Math.floor(i%(gC+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,i){var n,a,r,o,s,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),n=0;n<d;n++)r=(a=l[n]).duration,o=a.size,s=a.flags,u=a.cts,c.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var i=e.moov(t);return jT(e.FTYP,i)}},{key:"hvc1",value:function(t){for(var i=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),n.length]),r=a.length,o=0;o<n.length;o+=1){r+=3;for(var s=0;s<n[o].length;s+=1)r+=2+n[o][s].length}var u=new Uint8Array(r);u.set(a,0),r=a.length;for(var l=n.length-1,d=0;d<n.length;d+=1){u.set(new Uint8Array([32+d|(d===l?128:0),0,n[d].length]),r),r+=3;for(var h=0;h<n[d].length;h+=1)u.set(new Uint8Array([n[d][h].length>>8,255&n[d][h].length]),r),r+=2,u.set(n[d][h],r),r+=n[d][h].length}var c=e.box(e.types.hvcC,u),m=t.width,f=t.height,v=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,m>>8&255,255&m,f>>8&255,255&f,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]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,255&v,p>>24,p>>16&255,p>>8&255,255&p])))}}])}();yC.types=void 0,yC.HDLR_TYPES=void 0,yC.STTS=void 0,yC.STSC=void 0,yC.STCO=void 0,yC.STSZ=void 0,yC.VMHD=void 0,yC.SMHD=void 0,yC.STSD=void 0,yC.FTYP=void 0,yC.DINF=void 0;function bC(e,t,i=1,n=!1){var a=e*t*i;return n?Math.round(a):a}function wC(e,t=!1){return bC(e,1e3,1/9e4,t)}function kC(e){var t=e.baseTime,i=e.timescale;return`${t/i} (${t}/${i}) trackId: ${e.trackId}`}var SC=null,EC=null;function MC(e,t,i,n){return{duration:t,size:i,cts:n,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var TC=function(){function e(t,i,n,a){var r;if(Q(this,e),(r=J(this,e,["mp4-remuxer",a])).observer=void 0,r.config=void 0,r.typeSupported=void 0,r.ISGenerated=!1,r._initPTS=null,r._initDTS=null,r.nextVideoTs=null,r.nextAudioTs=null,r.videoSampleDuration=null,r.isAudioContiguous=!1,r.isVideoContiguous=!1,r.videoTrackConfig=void 0,r.observer=t,r.config=i,r.typeSupported=n,r.ISGenerated=!1,null===SC){var o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);SC=o?parseInt(o[1]):0}if(null===EC){var s=navigator.userAgent.match(/Safari\/(\d+)/i);EC=s?parseInt(s[1]):0}return r}return ue(e,VM),ne(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?kC(t):t} > ${e?kC(e):e}`),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,i=e[0].pts,n=e.reduce((e,n)=>{var a=n.pts,r=a-e;return r<-4294967296&&(t=!0,r=(a=PC(a,i))-e),r>0?e:a},i);return t&&this.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,i,n,a,r,o,s){var u,l,d,h,c,m,f=a,v=a,p=e.pid>-1,g=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!g||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,E,M,T=this.videoTrackConfig;(T&&(t.width!==T.width||t.height!==T.height||(null==(k=t.pixelRatio)?void 0:k[0])!==(null==(S=T.pixelRatio)?void 0:S[0])||(null==(E=t.pixelRatio)?void 0:E[1])!==(null==(M=T.pixelRatio)?void 0:M[1]))||!T&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,r));var P,A=this.isVideoContiguous,D=-1;if(w&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,D>0){this.warn(`Dropped ${D} out of ${y} video samples due to a missing keyframe`);var x=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,P=v+=(t.samples[0].pts-x)/t.inputTimeScale}else-1===D&&(this.warn(`No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){var C=this.getVideoStartPts(t.samples),I=(PC(e.samples[0].pts,C)-C)/t.inputTimeScale;f+=Math.max(0,I),v+=Math.max(0,-I)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,g||w||s===$M?v:void 0),w){var L=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,r)),u=this.remuxVideo(t,v,A,L)}}else w&&(u=this.remuxVideo(t,v,A,0));u&&(u.firstKeyFrame=D,u.independent=-1!==D,u.firstKeyFramePTS=P)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=AC(i,a,this._initPTS,this._initDTS)),n.samples.length&&(h=DC(n,a,this._initPTS))),{audio:l,video:u,initSegment:d,independent:m,text:h,id3:c}}},{key:"computeInitPts",value:function(e,t,i,n){var a=Math.round(i*t),r=PC(e,a);if(r<a+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-r)/t} ${n}`);r<a+t;)r+=8589934592;return r-a}},{key:"generateIS",value:function(e,t,i,n){var a,r,o,s=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||n,m="audio/mp4",f=-1;if(c&&(a=r=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(m="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):yC.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(f=e.id,o=e.inputTimeScale,h&&o===h.timescale?c=!1:a=r=this.computeInitPts(s[0].pts,o,i,"audio"))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:yC.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(f=t.id,o=t.inputTimeScale,h&&o===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=PC(u[0].dts,v),g=this.computeInitPts(p,o,i,"video"),y=this.computeInitPts(v,o,i,"video");r=Math.min(r,g),a=Math.min(a,y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(h&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${a/o} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/o} (${a}/${o}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:o,trackId:f},this._initDTS={baseTime:r,timescale:o,trackId:f}):a=o=void 0,{tracks:d,initPTS:a,timescale:o,trackId:f}}},{key:"remuxVideo",value:function(e,t,i,n){var a,r,o=e.inputTimeScale,s=e.samples,u=[],l=s.length,d=this._initPTS,h=d.baseTime*o/d.timescale,c=this.nextVideoTs,m=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){var y=h+t*o,b=s[0].pts-PC(s[0].dts,s[0].pts);SC&&null!==c&&Math.abs(y-b-(c+h))<15e3?i=!0:c=y-b-h}for(var w=c+h,k=0;k<l;k++){var S=s[k];S.pts=PC(S.pts,w),S.dts=PC(S.dts,w),S.dts<s[k>0?k-1:k].dts&&(g=!0)}g&&s.sort(function(e,t){var i=e.dts-t.dts,n=e.pts-t.pts;return i||n}),a=s[0].dts;var E=(r=s[s.length-1].dts)-a,M=E?Math.round(E/(l-1)):f||e.inputTimeScale/30;if(i){var T=a-w,P=T>M,A=T<-1;if((P||A)&&(P?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${wC(T,!0)} ms (${T}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${wC(-T,!0)} ms (${T}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!A||w>=s[0].pts||SC)){a=w;var D=s[0].pts-T;if(P)s[0].dts=a,s[0].pts=D;else for(var x=!0,C=0;C<s.length&&!(s[C].dts>D&&x);C++){var I=s[C].pts;if(s[C].dts-=T,s[C].pts-=T,C<s.length-1){var L=s[C+1].pts;x=L<=s[C].pts==L<=I}}this.log(`Video: Initial PTS/DTS adjusted: ${wC(D,!0)}/${wC(a,!0)}, delta: ${wC(T,!0)} ms`)}}for(var _=0,R=0,F=a=Math.max(0,a),W=0;W<l;W++){for(var O=s[W],$=O.units,N=$.length,j=0,B=0;B<N;B++)j+=$[B].data.length;R+=j,_+=N,O.length=j,O.dts<F?(O.dts=F,F+=M/4|0||1):F=O.dts,v=Math.min(O.pts,v),p=Math.max(O.pts,p)}r=s[l-1].dts;var z,U=R+4*_+8;try{z=new Uint8Array(U)}catch(e){return void this.observer.emit(LM.ERROR,LM.ERROR,{type:CM.MUX_ERROR,details:IM.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:`fail allocating video mdat ${U}`})}var H=new DataView(z.buffer);H.setUint32(0,U),z.set(yC.types.mdat,4);for(var G=!1,V=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,q=0;q<l;q++){for(var J=s[q],Q=J.units,Z=0,ee=0,te=Q.length;ee<te;ee++){var ie=Q[ee],ne=ie.data,ae=ie.data.byteLength;H.setUint32(m,ae),m+=4,z.set(ne,m),m+=ae,Z+=4+ae}var re=void 0;if(q<l-1)f=s[q+1].dts-J.dts,re=s[q+1].pts-J.pts;else{var oe=this.config,se=q>0?J.dts-s[q-1].dts:M;if(re=q>0?J.pts-s[q-1].pts:M,oe.stretchShortVideoTrack&&null!==this.nextAudioTs){var ue=Math.floor(oe.maxBufferHole*o),le=(n?v+n*o:this.nextAudioTs+h)-J.pts;le>ue?((f=le-se)<0?f=se:G=!0,this.log(`It is approximately ${le/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=se}else f=se}var de=Math.round(J.pts-J.dts);V=Math.min(V,f),X=Math.max(X,f),K=Math.min(K,re),Y=Math.max(Y,re),u.push(MC(J.key,f,Z,de))}if(u.length)if(SC){if(SC<70){var he=u[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(EC&&Y-K<X-V&&M/X<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=a,me=0,fe=u.length;me<fe;me++){var ve=ce+u[me].duration,pe=ce+u[me].cts;if(me<fe-1){var ge=ve+u[me+1].cts;u[me].duration=ge-pe}else u[me].duration=me?u[me-1].duration:M;u[me].cts=0,ce=ve}}var ye=r+(f=G||!f?M:f);this.nextVideoTs=c=ye-h,this.videoSampleDuration=f,this.isVideoContiguous=!0;var be={data1:yC.moof(e.sequenceNumber++,a,UM(e,{samples:u})),data2:z,startPTS:(v-h)/o,endPTS:(p+f-h)/o,startDTS:(a-h)/o,endDTS:c/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,i,n,a){var r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),u=s*o,l=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],c=void 0!==a,m=e.samples,f=d?0:8,v=this.nextAudioTs||-1,p=l.baseTime*r/l.timescale,g=p+t*r;if(this.isAudioContiguous=i=i||m.length&&v>0&&(n&&Math.abs(g-(v+p))<9e3||Math.abs(PC(m[0].pts,g)-(v+p))<20*u),m.forEach(function(e){e.pts=PC(e.pts,g)}),!i||v<0){var y=m.length;if(m=m.filter(e=>e.pts>=0),y!==m.length&&this.warn(`Removed ${m.length-y} of ${y} samples (initPTS ${p} / ${r})`),!m.length)return;v=0===a?0:n&&!c?Math.max(0,g-p):m[0].pts-p}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,w=0,k=v+p;w<m.length;w++){var S=m[w],E=S.pts,M=E-k,T=Math.abs(1e3*M/r);if(M<=-b*u&&c)0===w&&(this.warn(`Audio frame @ ${(E/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*M/r)} ms.`),this.nextAudioTs=v=E-p,k=E);else if(M>=b*u&&T<1e4&&c){var P=Math.round(M/u);for(k=E-P*u;k<0&&P&&u;)P--,k+=u;0===w&&(this.nextAudioTs=v=k-p),this.warn(`Injecting ${P} audio frames @ ${((k-p)/r).toFixed(3)}s due to ${Math.round(1e3*M/r)} ms gap.`);for(var A=0;A<P;A++){var D=pC.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);D||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),D=S.unit.subarray()),m.splice(w,0,{unit:D,pts:k}),k+=u,w++}}S.pts=k,k+=u}for(var x,C=null,I=null,L=0,_=m.length;_--;)L+=m[_].unit.byteLength;for(var R=0,F=m.length;R<F;R++){var W=m[R],O=W.unit,$=W.pts;if(null!==I){h[R-1].duration=Math.round(($-I)/o)}else{if(i&&"aac"===e.segmentCodec&&($=v+p),C=$,!(L>0))return;L+=f;try{x=new Uint8Array(L)}catch(e){return void this.observer.emit(LM.ERROR,LM.ERROR,{type:CM.MUX_ERROR,details:IM.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating audio mdat ${L}`})}d||(new DataView(x.buffer).setUint32(0,L),x.set(yC.types.mdat,4))}x.set(O,f);var N=O.byteLength;f+=N,h.push(MC(!0,s,N,0)),I=$}var j=h.length;if(j){var B=h[h.length-1];v=I-p,this.nextAudioTs=v+o*B.duration;var z=d?new Uint8Array(0):yC.moof(e.sequenceNumber++,C/o,UM({},e,{samples:h}));e.samples=[];var U=(C-p)/r,H=this.nextAudioTs/r,G={data1:z,data2:x,startPTS:U,endPTS:H,startDTS:U,endDTS:H,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,G}}}])}();function PC(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function AC(e,t,i,n){var a=e.samples.length;if(a){for(var r=e.inputTimeScale,o=0;o<a;o++){var s=e.samples[o];s.pts=PC(s.pts-i.baseTime*r/i.timescale,t*r)/r,s.dts=PC(s.dts-n.baseTime*r/n.timescale,t*r)/r}var u=e.samples;return e.samples=[],{samples:u}}}function DC(e,t,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,r=0;r<n;r++){var o=e.samples[r];o.pts=PC(o.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);var s=e.samples;return e.samples=[],{samples:s}}}var xC,CC=function(){function e(t,i,n,a){var r;return Q(this,e),(r=J(this,e,["passthrough-remuxer",a])).emitInitSegment=!1,r.audioCodec=void 0,r.videoCodec=void 0,r.initData=void 0,r.initPTS=null,r.initTracks=void 0,r.lastEndTime=null,r.isVideoContiguous=!1,r}return ue(e,VM),ne(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}},{key:"resetNextTimestamp",value:function(){this.isVideoContiguous=!1,this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e,t){var i=this.audioCodec,n=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=LT(e),r=a.audio,o=a.video;if(t)!function(e,t){if(e&&t){var i=t.keyId;i&&t.isCommonEncryption&&$T(e,(e,t)=>{var n=e.subarray(8,24);n.some(e=>0!==e)||(QM.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${iT(n)} -> ${iT(i)}`),e.set(i,8))})}}(e,t);else{var s=r||o;null!=s&&s.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${s.codec}")!`)}r&&(i=LC(r,fT,this)),o&&(n=LC(o,vT,this));var u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}},{key:"remux",value:function(e,t,i,n,a,r){var o,s,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};AM(l)||(l=this.lastEndTime=a||0);var h=t.samples;if(!h.length)return d;var c={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(h),m=this.initData),null==(s=m)||!s.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var f=function(e,t,i){for(var n={},a=CT(e,["moof","traf"]),r=0;r<a.length;r++){var o=a[r],s=CT(o,["tfhd"])[0],u=AT(s,4),l=t[u];if(l){n[u]||(n[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});var d=n[u],h=CT(o,["tfdt"])[0];if(h){var c=h[0],m=AT(h,4);1===c&&(m===ST?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(m*=ST+1,m+=AT(h,8))),AM(m)&&(!AM(d.start)||m<d.start)&&(d.start=m)}var f=l.default,v=AT(s,0)|(null==f?void 0:f.flags),p=(null==f?void 0:f.duration)||0;8&v&&(p=AT(s,2&v?12:8));for(var g=CT(o,["trun"]),y=d.start||0,b=0,w=p,k=0;k<g.length;k++){var S=g[k],E=AT(S,4),M=d.sampleCount;d.sampleCount+=E;var T=1&S[3],P=4&S[3],A=1&S[2],D=2&S[2],x=4&S[2],C=8&S[2],I=8,L=E;for(T&&(I+=4),P&&E&&(1&S[I+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=M),I+=4,A?(w=AT(S,I),I+=4):w=p,D&&(I+=4),C&&(I+=4),y+=w,b+=w,L--);L--;)A?(w=AT(S,I),I+=4):w=p,D&&(I+=4),x&&(1&S[I+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(L+1),d.keyFrameStart=y),I+=4),C&&(I+=4),y+=w,b+=w;!b&&p&&(b+=p*E)}d.duration+=b}}if(!Object.keys(n).some(e=>n[e].duration)){for(var _=1/0,R=0,F=CT(e,["sidx"]),W=0;W<F.length;W++){var O=IT(F[W]);if(null!=O&&O.references){_=Math.min(_,O.earliestPresentationTime/O.timescale);var $=O.references.reduce((e,t)=>e+t.info.duration||0,0);R=Math.max(R,$+O.earliestPresentationTime/O.timescale)}}R&&AM(R)&&Object.keys(n).forEach(e=>{n[e].duration||(n[e].duration=R*n[e].timescale-n[e].start)})}return n}(h,m,this),v=m.audio?f[m.audio.id]:null,p=m.video?f[m.video.id]:null,g=IC(p,1/0),y=IC(v,1/0),b=IC(p,0,!0),w=IC(v,0,!0),k=a,S=0,E=v&&(!p||!u&&y<g||u&&u.trackId===m.audio.id),M=E?v:p;if(M){var T=M.timescale,P=M.start-a*T,A=E?m.audio.id:m.video.id;k=M.start/T,S=E?w-y:b-g,!r&&u||!function(e,t,i,n){if(null===e)return!0;var a=Math.max(n,1),r=t-e.baseTime/e.timescale;return Math.abs(r-i)>a}(u,k,a,S)&&T===u.timescale||(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${a} ${P/T} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${a} offset: ${k-a} (${P}/${T}) trackId: ${A}`),u=null,c.initPTS=P,c.timescale=T,c.trackId=A)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${a}`);u?(c.initPTS=u.baseTime,c.timescale=u.timescale,c.trackId=u.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=k,c.timescale=1,c.trackId=-1),this.initPTS=u={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});var D=k-u.baseTime/u.timescale,x=D+S;S>0?this.lastEndTime=x:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var C=!!m.audio,I=!!m.video,L="";C&&(L+="audio"),I&&(L+="video");var _={data1:h,startPTS:D,startDTS:D,endPTS:x,endDTS:x,type:L,hasAudio:C,hasVideo:I,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};d.audio=C&&!I?_:void 0,d.video=I?_:void 0;var R=null==p?void 0:p.sampleCount;if(R){var F=p.keyFrameIndex,W=-1!==F;_.nb=R,_.dropped=0===F||this.isVideoContiguous?0:W?F:R,_.independent=W,_.firstKeyFrame=F,W&&p.keyFrameStart&&(_.firstKeyFramePTS=(p.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(d.independent=W),this.isVideoContiguous||(this.isVideoContiguous=W),_.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${F}/${R} dropped: ${_.dropped} start: ${_.firstKeyFramePTS||"NA"}`)}return d.initSegment=c,d.id3=AC(i,a,u,u),n.samples.length&&(d.text=DC(n,a,u)),d}}])}();function IC(e,t,i=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function LC(e,t,i){var n=e.codec;if(n&&n.length>4)return n;if(t===fT){if("ec-3"===n||"ac-3"===n||"alac"===n)return n;if("fLaC"===n||"Opus"===n){return aP(n,!1)}return i.warn(`Unhandled audio codec "${n}" in mp4 MAP`),n||"mp4a"}return i.warn(`Unhandled video codec "${n}" in mp4 MAP`),n||"avc1"}try{xC=self.performance.now.bind(self.performance)}catch(e){xC=Date.now}var _C=[{demux:tC,remux:CC},{demux:lC,remux:TC},{demux:Yx,remux:TC},{demux:Zx,remux:TC}];_C.splice(2,0,{demux:Jx,remux:TC});var RC=function(){return ne(function e(t,i,n,a,r,o){Q(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=t,this.typeSupported=i,this.config=n,this.id=r,this.logger=o},[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,i,n){var a=i.transmuxing;a.executeStart=xC();var r=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;n&&(this.currentTransmuxState=n);var u=n||o,l=u.contiguous,d=u.discontinuity,h=u.trackSwitch,c=u.accurateTimeOffset,m=u.timeOffset,f=u.initSegmentChange,v=s.audioCodec,p=s.videoCodec,g=s.defaultInitPts,y=s.duration,b=s.initSegmentData,w=function(e,t){var i=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t);return i}(r,t);if(w&&zA(w.method)){var k=this.getDecrypter(),S=UA(w.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(r,w.key.buffer,w.iv.buffer,S).then(e=>{var t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;var E=k.softwareDecrypt(r,w.key.buffer,w.iv.buffer,S);if(i.part>-1){var M=k.flush();E=M?M.buffer:M}if(!E)return a.executeEnd=xC(),FC(i);r=new Uint8Array(E)}var T=this.needsProbing(d,h);if(T){var P=this.configureTransmuxer(r);if(P)return this.logger.warn(`[transmuxer] ${P.message}`),this.observer.emit(LM.ERROR,LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_PARSING_ERROR,fatal:!1,error:P,reason:P.message}),a.executeEnd=xC(),FC(i)}(d||h||f||T)&&this.resetInitSegment(b,v,p,y,t),(d||f||T)&&this.resetInitialTimestamp(g),l||this.resetContiguity();var A=this.transmux(r,w,m,c,i);this.asyncResult=WC(A);var D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,a.executeEnd=xC(),A}},{key:"flush",value:function(e){var t=e.transmuxing;t.executeStart=xC();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));var r=[],o=n.timeOffset;if(i){var s=i.flush();s&&r.push(this.push(s.buffer,null,e))}var u=this.demuxer,l=this.remuxer;if(!u||!l){t.executeEnd=xC();var d=[FC(e)];return this.asyncResult?Promise.resolve(d):d}var h=u.flush(o);return WC(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,h,e),this.asyncResult?Promise.resolve(r):r)}},{key:"flushRemux",value:function(e,t,i){var n=t.audioTrack,a=t.videoTrack,r=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===OM?"level":"track"} ${i.level}`);var d=this.remuxer.remux(n,a,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=xC()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,i,n,a){var r=this.demuxer,o=this.remuxer;r&&o&&(r.resetInitSegment(e,t,i,n),o.resetInitSegment(e,t,i,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,i,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,n,a):this.transmuxUnencrypted(e,i,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,i,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),r=a.audioTrack,o=a.videoTrack,s=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(r,o,s,u,t,i,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:a}))}},{key:"configureTransmuxer",value:function(e){for(var t,i=this.config,n=this.observer,a=this.typeSupported,r=0,o=_C.length;r<o;r++){var s;if(null!=(s=_C[r].demux)&&s.probe(e,this.logger)){t=_C[r];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,l=this.remuxer,d=t.remux,h=t.demux;l&&l instanceof d||(this.remuxer=new d(n,i,a,this.logger)),u&&u instanceof h||(this.demuxer=new h(n,i,a,this.logger),this.probe=h.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new yA(this.config)),e}}])}();var FC=e=>({remuxResult:{},chunkMeta:e});function WC(e){return"then"in e&&e.then instanceof Function}var OC=ne(function e(t,i,n,a,r){Q(this,e),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=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=r||null}),$C=ne(function e(t,i,n,a,r,o){Q(this,e),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=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=r,this.initSegmentChange=o}),NC=0,jC=function(){return ne(function e(t,i,n,a){Q(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=NC++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{var t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":var n,a=null==(n=this.workerContext)?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(this.hls){var t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var r=t.config;this.hls=t,this.id=i,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===LM.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new hx,this.observer.on(LM.FRAG_DECRYPTED,o),this.observer.on(LM.ERROR,o);var s=uP(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var u=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(u.log(`loading Web Worker ${r.workerPath} for "${i}"`),this.workerContext=function(e){var t=mx[e];if(t)return t.clientCount++,t;var i=new self.URL(e,self.location.href).href,n={worker:new self.Worker(i),scriptURL:i,clientCount:1};return mx[e]=n,n}(r.workerPath)):(u.log(`injecting Web Worker for "${i}"`),this.workerContext=function(){var e=mx[cx];if(e)return e.clientCount++,e;var t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(t),n={worker:new self.Worker(i),objectURL:i,clientCount:1};return mx[cx]=n,n}());var l=this.workerContext.worker;l.addEventListener("message",this.onWorkerMessage),l.addEventListener("error",this.onWorkerError),l.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:s,id:i,config:PP(r)})}catch(e){u.warn(`Error setting up "${i}" Web Worker, fallback to inline`,e),this.terminateWorker(),this.error=null,this.transmuxer=new RC(this.observer,s,r,"",i,t.logger)}return}}this.transmuxer=new RC(this.observer,s,r,"",i,t.logger)},[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=NC++;var t=this.hls.config,i=uP(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:PP(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=mx[e||cx];if(t&&1===t.clientCount--){var i=t.worker,n=t.objectURL;delete mx[e||cx],n&&self.URL.revokeObjectURL(n),i.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,i,n,a,r,o,s,u,l){var d,h;u.transmuxing.start=self.performance.now();var c=this.instanceNo,m=this.transmuxer,f=r?r.start:a.start,v=a.decryptdata,p=this.frag,g=!(p&&a.cc===p.cc),y=!(p&&u.level===p.level),b=p?u.sn-p.sn:-1,w=this.part?u.part-this.part.index:-1,k=0===b&&u.id>1&&u.id===(null==p?void 0:p.stats.chunkCount),S=!y&&(1===b||0===b&&(1===w||k&&w<=0)),E=self.performance.now();(y||b||0===a.stats.parsing.start)&&(a.stats.parsing.start=E),!r||!w&&S||(r.stats.parsing.start=E);var M=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),T=new $C(g,S,s,y,f,M);if(!S||g||M){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===OM?"level":"track"}: ${u.level} id: ${u.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${s}\n timeOffset: ${f}\n initSegmentChange: ${M}`);var P=new OC(i,n,t,o,l);this.configureTransmuxer(P)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:T},e instanceof ArrayBuffer?[e]:[]);else if(m){var A=m.push(e,v,u,T);WC(A)?A.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(A)}}},{key:"flush",value:function(e){e.transmuxing.start=self.performance.now();var t=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);WC(n)?n.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}},{key:"handleFlushResult",value:function(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}])}(),BC=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"audio-stream-controller",$M])).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return ue(e,rx),ne(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([]),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.on(LM.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(LM.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(LM.BUFFER_RESET,this.onBufferReset,this),t.on(LM.BUFFER_CREATED,this.onBufferCreated,this),t.on(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(LM.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(LM.FRAG_LOADING,this.onFragLoading,this),t.on(LM.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var t=this.hls;t&&(pe(e,"unregisterListeners",this)([]),t.off(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.off(LM.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(LM.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(LM.BUFFER_RESET,this.onBufferReset,this),t.off(LM.BUFFER_CREATED,this.onBufferCreated,this),t.off(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(LM.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(LM.FRAG_LOADING,this.onFragLoading,this),t.off(LM.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){if(i===OM){var o=t.cc,s=this.fragCurrent;if(this.initPTS[o]={baseTime:n,timescale:a,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${n/a} (${n}/${a}) trackId: ${r}`),this.mainAnchor=t,this.state===nx){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,null==u?void 0:u.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==o?(s.abortRequests(),this.syncWithAnchor(t,s)):this.state===XD&&this.tick()}}},{key:"getLoadPosition",value:function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:pe(e,"getLoadPosition",this)([])}},{key:"syncWithAnchor",value:function(e,t){var i,n=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(!t||(null==n?void 0:n.cc)!==t.cc){var a=(n||e).cc,r=jP(this.getLevelDetails(),a,this.getLoadPosition());r&&(this.log(`Syncing with main frag at ${r.start} cc ${r.cc}`),this.startFragRequested=!1,this.nextLoadPosition=r.start,this.resetLoadingState(),this.state===XD&&this.doTickIdle())}}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=KD);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=XD):this.state=QD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case XD:this.doTickIdle();break;case QD:var t=this.levels,i=this.trackId,n=null==t?void 0:t[i],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=nx}break;case JD:this.checkRetryDate();break;case nx:var r=this.waitingData;if(r){var o=r.frag,s=r.part,u=r.cache,l=r.complete,d=this.mainAnchor;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.state=qD;var h={frag:o,part:s,payload:u.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(h),l&&pe(e,"_handleFragmentLoadComplete",this)([h])}else d&&d.cc!==r.frag.cc&&this.syncWithAnchor(d,r.frag)}else this.state=XD}this.onTickEnd()}},{key:"resetLoadingState",value:function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),pe(e,"resetLoadingState",this)([])}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,i=this.levels,n=this.media,a=this.trackId,r=t.config;if(this.buffering&&(n||this.primaryPrefetch||!this.startFragRequested&&r.startFragPrefetch)&&null!=i&&i[a]){var o=i[a],s=o.details;if(!s||this.waitForLive(o)||this.waitForCdnTuneIn(s))return this.state=QD,void(this.startFragRequested=!1);var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,fT,$M));var l=this.getFwdBufferInfo(u,$M);if(null!==l){if(!this.switchingTrack&&this._streamEnded(l,s))return t.trigger(LM.BUFFER_EOS,{type:"audio"}),void(this.state=tx);var d=l.len,h=t.maxBufferLength,c=s.fragments,m=c[0].start,f=this.getLoadPosition(),v=this.flushing?f:l.end;if(this.switchingTrack&&n){var p=f;s.PTSKnown&&p<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=m+.05)}if(!(d>=h&&!this.switchingTrack&&v<c[c.length-1].start)){var g=this.getNextFragment(v,s);if(g&&this.isLoopLoading(g,v)&&(g=this.getNextFragmentLoopLoading(g,s,l,OM,h)),g){if(!this.exceedsMaxBuffer(l,h,g)){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&yT(g)&&!g.endList&&(!s.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===uA&&(this.mainFragLoading=y=null),y&&yT(y))){if(g.start>y.end){var b=this.fragmentTracker.getFragAtPos(v,OM);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,o,v)}}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(t,i){this.bufferFlushed=this.flushing=!1,pe(e,"onMediaDetaching",this)([t,i])}},{key:"onAudioTracksUpdated",value:function(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new EP(e))}},{key:"onAudioTrackSwitching",value:function(e,t){var i=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==KD&&(this.setInterval(100),this.state=XD,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(LM.AUDIO_TRACK_LOADED,i))}},{key:"onAudioTrackLoaded",value:function(e,t){var i,n=this.levels,a=t.details,r=t.id,o=t.groupId,s=t.track;if(n){var u=this.mainDetails;if(!u||a.endCC>u.endCC||u.expired)return this.cachedTrackLoadedData=t,void(this.state!==KD&&(this.state=QD));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${s.name}" of "${o}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);var l=n[r],d=0;if(a.live||null!=(i=l.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var h;if(l.details)d=this.alignPlaylists(a,l.details,null==(h=this.levelLastLoaded)?void 0:h.details);a.alignedSliding||(zD(a,u),a.alignedSliding||UD(a,u),d=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(LM.AUDIO_TRACK_UPDATED,{details:a,id:r,groupId:t.groupId}),this.state!==QD||this.waitForCdnTuneIn(a)||(this.state=XD),this.tick()}else this.warn(`Audio tracks reset while loading track ${r} "${s.name}" of "${o}"`)}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.config,o=this.trackId,s=this.levels;if(s){var u=s[o];if(u){var l=u.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var d=r.defaultAudioCodec||u.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new jC(this.hls,$M,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[i.cc],m=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){var f=n?n.index:-1,v=-1!==f,p=new TA(i.level,i.sn,i.stats.chunkCount,a.byteLength,f,v);h.push(a,m,d,"",i,n,l.totalduration,!1,p,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track ${o}`),(this.waitingData=this.waitingData||{frag:i,part:n,cache:new sx,complete:!1}).cache.push(new Uint8Array(a)),this.state!==KD&&(this.state=nx)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"_handleFragmentLoadComplete",value:function(t){this.waitingData?this.waitingData.complete=!0:pe(e,"_handleFragmentLoadComplete",this)([t])}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===OM&&yT(t.frag)&&(this.mainFragLoading=t,this.state===XD&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part;if(i.type===$M)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(yT(i)){this.fragPrevious=i;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(LM.AUDIO_TRACK_SWITCHED,GM({},a)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}else this.audioOnly||i.type!==OM||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(t,i){var n;if(i.fatal)this.state=ix;else switch(i.details){case IM.FRAG_GAP:case IM.FRAG_PARSING_ERROR:case IM.FRAG_DECRYPT_ERROR:case IM.FRAG_LOAD_ERROR:case IM.FRAG_LOAD_TIMEOUT:case IM.KEY_LOAD_ERROR:case IM.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError($M,i);break;case IM.AUDIO_TRACK_LOAD_ERROR:case IM.AUDIO_TRACK_LOAD_TIMEOUT:case IM.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==QD||(null==(n=i.context)?void 0:n.type)!==FM||(this.state=XD);break;case IM.BUFFER_ADD_CODEC_ERROR:case IM.BUFFER_APPEND_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)||this.resetLoadingState();break;case IM.BUFFER_FULL_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]));break;case IM.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}}},{key:"onBufferFlushing",value:function(e,{type:t}){t!==vT&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==vT){this.flushing=!1,this.bufferFlushed=!0,this.state===tx&&(this.state=XD);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,$M),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,i="audio",n=this.hls,a=e.remuxResult,r=e.chunkMeta,o=this.getCurrentContext(r);if(o){var s=o.frag,u=o.part,l=o.level,d=l.details,h=a.audio,c=a.text,m=a.id3,f=a.initSegment;if(!this.fragContextChanged(s)&&d){if(this.state=ZD,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){var v=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,f.tracks,v,r),n.trigger(LM.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:f.tracks})}if(h){var p=h.startPTS,g=h.endPTS,y=h.startDTS,b=h.endDTS;u&&(u.elementaryStreams[fT]={startPTS:p,endPTS:g,startDTS:y,endDTS:b}),s.setElementaryStreamInfo(fT,p,g,y,b),this.bufferFragmentData(h,s,u,r)}if(null!=m&&null!=(t=m.samples)&&t.length){var w=UM({id:i,frag:s,details:d},m);n.trigger(LM.FRAG_PARSING_METADATA,w)}if(c){var k=UM({id:i,frag:s,details:d},c);n.trigger(LM.FRAG_PARSING_USERDATA,k)}}else this.fragmentTracker.removeFragment(s)}else this.resetWhenMissingContext(r)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===ZD&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=$M;var r=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${r}/${a.codec}]`),r&&1===r.split(",").length&&(a.levelCodec=r),this.hls.trigger(LM.BUFFER_CODECS,t);var o=a.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:o};this.hls.trigger(LM.BUFFER_APPENDING,s)}this.tickImmediate()}}},{key:"loadFragment",value:function(t,i,n){var a,r=this.fragmentTracker.getState(t);if(this.switchingTrack||r===rA||r===sA)if(yT(t))if(null!=(a=i.details)&&a.live&&!this.initPTS[t.cc]){this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=nx;var o=this.mainDetails;o&&o.fragmentStart!==i.details.fragmentStart&&UD(i.details,o)}else pe(e,"loadFragment",this)([t,i,n]);else this._loadInitSegment(t,i);else this.clearTrackerIfNeeded(t)}},{key:"flushAudioIfNeeded",value:function(t){if(this.media&&this.bufferedTrack){var i=this.bufferedTrack;IP({name:i.name,lang:i.lang,assocLang:i.assocLang,characteristics:i.characteristics,audioCodec:i.audioCodec,channels:i.channels},t,LP)||(RP(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]),this.bufferedTrack=null):this.bufferedTrack=t)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(LM.AUDIO_TRACK_SWITCHED,GM({},e))}}])}(),zC=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i,t.logger])).hls=void 0,n.canLoad=!1,n.timer=-1,n.hls=t,n}return ue(e,VM),ne(e,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,i){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,r=0;r<n.length;r++){var o=n[r],s=void 0;try{s=new self.URL(o.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=o.URI||""}if(s===e){a=r;break}s===e.substring(0,s.length)&&(a=r)}if(-1!==a){var u=n[a],l=parseInt(u["LAST-MSN"])||t.lastPartSn,d=parseInt(u["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=i&&kP(i);return new SP(l,d>=0?d:void 0,c)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}},{key:"playlistLoaded",value:function(e,t,i){var n=t.details,a=t.stats,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;n.advancedDateTime=Date.now()-o;var s=this.hls.config.timelineOffset;if(s!==n.appliedTimelineOffset){var u=Math.max(s||0,0);n.appliedTimelineOffset=u,n.fragments.forEach(e=>{e.setStart(e.playlistOffset+u)})}if(n.live||null!=i&&i.live){var l="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){DD(i,n,this);var d=n.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var c,m=t.networkDetails;return void h.trigger(LM.ERROR,{type:CM.NETWORK_ERROR,details:IM.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(c=n.fragments[0])?void 0:c.type,networkDetails:m,stats:a})}n.playlistParsingError=null}}-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,v=this.hls.mainForwardBufferInfo,p=v?v.end-v.len:0,g=LD(n,1e3*(n.edge-p));if(n.requestScheduled+g<r?n.requestScheduled=r:n.requestScheduled+=g,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;var y=void 0,b=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var w=this.hls.config.lowLatencyMode,k=n.lastPartSn,S=n.endSN,E=n.lastPartIndex,M=k===S;-1!==E?M?(y=S+1,b=w?0:E):(y=k,b=w?E+1:n.maxPartIndex):y=S+1;var T=n.age,P=T+n.ageHeader,A=Math.min(P-n.partTarget,1.5*n.targetduration);if(A>0){if(P>3*n.targetduration)this.log(`Playlist last advanced ${T.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,b=void 0;else if(null!=i&&i.tuneInGoal&&P-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${A} with playlist age: ${n.age}`),A=0;else{var D=Math.floor(A/n.targetduration);if(y+=D,void 0!==b)b+=Math.round(A%n.targetduration/n.partTarget);this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${T.toFixed(2)}s goal: ${A} skip sn ${D} to part ${b}`)}n.tuneInGoal=A}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b),w||!M)return n.requestScheduled=r,void this.loadingPlaylist(l,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b));f&&void 0!==y&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(g-2*o,g/2)),this.scheduleLoading(l,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,i){var n=i||e.details;if(n){var a=self.performance.now(),r=n.requestScheduled;if(a>=r)this.loadingPlaylist(e,t);else{var o=r-a;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,i,n){var a=kP(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=yP),new SP(i,n,a)}},{key:"checkRetry",value:function(e){var t=e.details,i=BP(e),n=e.errorAction,a=n||{},r=a.action,o=a.retryCount,s=void 0===o?0:o,u=a.retryConfig,l=!!n&&!!u&&(r===QP||!n.resolved&&r===qP);if(l){var d;if(s>=u.maxNumRetry)return!1;if(i&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var h=GP(u,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,n.resolved=!0}return l}}])}();function UC(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!HC(e[i].attrs,t[i].attrs))return!1;return!0}function HC(e,t,i){var n=e["STABLE-RENDITION-ID"];return n&&!i?n===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function GC(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var VC=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t,"audio-track-controller"])).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}return ue(e,zC),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.on(LM.LEVEL_LOADING,this.onLevelLoading,this),e.on(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(LM.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.off(LM.LEVEL_LOADING,this.onLevelLoading,this),e.off(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(LM.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(LM.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,pe(e,"destroy",this)([])}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Audio track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.audioPreference;if(!a&&o){var s=CP(o,r,LP);if(s>-1)a=r[s];else{var u=CP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(LM.AUDIO_TRACKS_UPDATED,d);var h=this.trackId;if(-1!==l&&-1===h)this.setAudioTrack(l);else if(r.length&&-1===h){var c,m=new Error(`No audio track selected for current audio group-ID(s): ${null==(c=this.groupIds)?void 0:c.join(",")} track count: ${r.length}`);this.warn(m.message),this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==FM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var n=this.currentTrack;if(n&&IP(e,n,LP))return n;var a=CP(e,this.tracksInGroup,LP);if(a>-1){var r=this.tracksInGroup[a];return this.setAudioTrack(a),r}if(n){var o=t.loadLevel;-1===o&&(o=t.firstAutoLevel);var s=function(e,t,i,n,a){var r=t[n],o=t.reduce((e,t,i)=>{var n=t.uri;return(e[n]||(e[n]=[])).push(i),e},{})[r.uri];o.length>1&&(n=Math.max.apply(Math,o));var s=r.videoRange,u=r.frameRate,l=r.codecSet.substring(0,4),d=_P(t,n,t=>{if(t.videoRange!==s||t.frameRate!==u||t.codecSet.substring(0,4)!==l)return!1;var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return CP(e,r,a)>-1});return d>-1?d:_P(t,n,t=>{var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return CP(e,r,a)>-1})}(e,t.levels,i,o,LP);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){var u=CP(e,i);if(u>-1)return i[u]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn(`Invalid audio track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e],a=n.details&&!n.details.live;if(!(e===this.trackId&&n===i&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(LM.AUDIO_TRACK_SWITCHING,GM({},n)),a))){var r=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(r)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||IP(e,n,LP)))return i}if(e){for(var a=e.name,r=e.lang,o=e.assocLang,s=e.characteristics,u=e.audioCodec,l=e.channels,d=0;d<t.length;d++){if(IP({name:a,lang:r,assocLang:o,characteristics:s,audioCodec:u,channels:l},t[d],LP))return d}for(var h=0;h<t.length;h++){var c=t[h];if(HC(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var m=0;m<t.length;m++){var f=t[m];if(HC(e.attrs,f.attrs,["LANGUAGE"]))return m}}return-1}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]);var i=this.currentTrack;this.shouldLoadPlaylist(i)&&RP(i.url,this.hls)&&this.scheduleLoading(i,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading audio-track ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(LM.AUDIO_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}}])}(),KC=function(){return ne(function e(t){Q(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t},[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,i){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||i||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){return new Promise(t=>{var i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}},{key:"prependBlocker",value:function(e){return new Promise(t=>{if(this.queues){var i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t,i=null==(t=e[0])?void 0:t.label;"async-blocker"!==i&&"async-blocker-prepend"!==i||(e[0].execute(),e.splice(0,1))})}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var i=t[0];try{i.execute()}catch(t){var n;if(i.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}},{key:"list",value:function(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}},{key:"listSbInfo",value:function(e){var t,i=null==(t=this.tracks)?void 0:t[e],n=null==i?void 0:i.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}])}(),XC=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,YC="HlsJsTrackRemovedError",qC=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t])).name=YC,i}return ue(e,ye(Error)),ne(e)}(),JC=function(){function e(t,i){var n,a;return Q(this,e),(n=J(this,e,["buffer-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.details=null,n._objectUrl=null,n.operationQueue=null,n.bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.lastMpegAudioChunk=null,n.blockedAudioAppend=null,n.lastVideoAppendEnd=0,n.appendSource=void 0,n.transferData=void 0,n.overrides=void 0,n.appendErrors={audio:0,video:0,audiovideo:0},n.tracks={},n.sourceBuffers=[[null,null],[null,null]],n._onEndStreaming=e=>{var t;n.hls&&"open"===(null==(t=n.mediaSource)?void 0:t.readyState)&&n.hls.pauseBuffering()},n._onStartStreaming=e=>{n.hls&&n.hls.resumeBuffering()},n._onMediaSourceOpen=e=>{var t=n,i=t.media,a=t.mediaSource;e&&n.log("Media source opened"),i&&a&&(a.removeEventListener("sourceopen",n._onMediaSourceOpen),i.removeEventListener("emptied",n._onMediaEmptied),n.updateDuration(),n.hls.trigger(LM.MEDIA_ATTACHED,{media:i,mediaSource:a}),null!==n.mediaSource&&n.checkPendingTracks())},n._onMediaSourceClose=()=>{n.log("Media source closed")},n._onMediaSourceEnded=()=>{n.log("Media source ended")},n._onMediaEmptied=()=>{var e=n,t=e.mediaSrc,i=e._objectUrl;t!==i&&n.error(`Media element src was set while attaching MediaSource (${i} > ${t})`)},n.hls=t,n.fragmentTracker=i,n.appendSource=(a=ZM(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),n.initTracks(),n.registerListeners(),n}return ue(e,VM),ne(e,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.on(LM.BUFFER_RESET,this.onBufferReset,this),e.on(LM.BUFFER_APPENDING,this.onBufferAppending,this),e.on(LM.BUFFER_CODECS,this.onBufferCodecs,this),e.on(LM.BUFFER_EOS,this.onBufferEos,this),e.on(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(LM.FRAG_PARSED,this.onFragParsed,this),e.on(LM.FRAG_CHANGED,this.onFragChanged,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.off(LM.BUFFER_RESET,this.onBufferReset,this),e.off(LM.BUFFER_APPENDING,this.onBufferAppending,this),e.off(LM.BUFFER_CODECS,this.onBufferCodecs,this),e.off(LM.BUFFER_EOS,this.onBufferEos,this),e.off(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(LM.FRAG_PARSED,this.onFragParsed,this),e.off(LM.FRAG_CHANGED,this.onFragChanged,this),e.off(LM.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this.media,t=this.mediaSource;if(!e)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}var r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?UM(i,r.tracks):this.sourceBuffers.forEach(e=>{var t=e[0];t&&(i[t]=UM({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var i,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;this.transferData=this.overrides=void 0;var n=ZM(this.appendSource);if(n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var r=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(r),a)this._objectUrl=i.src,this.attachTransferred();else{var o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{i.removeAttribute("src");var s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&r instanceof s,QC(i),function(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,o),i.load()}catch(e){i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,i;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(i=e.constructor)?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this.media,t=this.transferData;if(t&&e){var i=this.tracks,n=t.tracks,a=n?Object.keys(n):null,r=a?a.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&a&&r){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${PP(i,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${PP(n,(e,t)=>"initSegment"===e?void 0:t)}}`),!eT(n,i)){t.mediaSource=null,t.tracks=void 0;var s=e.currentTime,u=this.details,l=Math.max(s,(null==u?void 0:u.fragments[0].start)||0);return l-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${l}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${l} currentTime: ${s}`),this.onMediaDetaching(LM.MEDIA_DETACHING,{}),this.onMediaAttaching(LM.MEDIA_ATTACHING,t),void(e.currentTime=l))}this.transferData=void 0,a.forEach(e=>{var t=e,i=n[t];if(i){var a=i.buffer;if(a){var r=this.fragmentTracker,o=i.id;if(r.hasFragments(o)||r.hasParts(o)){var s=AA.getBuffered(a);r.detectEvictedFragments(t,s,o,null,!0)}var u=ZC(t),l=[t,a];this.sourceBuffers[u]=l,a.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,i)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,r=this._objectUrl;if(a){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var s=a.sourceBuffers,u=s.length;u--;)o&&s[u].abort(),a.removeSourceBuffer(s[u]);o&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(n.removeAttribute("src"),this.appendSource&&QC(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(LM.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[ZC(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new KC(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var i,n=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);var r="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&a.some(e=>!n[e]);r||o?this.warn(`Unsupported transition between "${Object.keys(n)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a,r=t[e],o=r.id,s=r.codec,u=r.levelCodec,l=r.container,d=r.metadata,h=r.supplemental,c=n[e],m=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=m&&m.buffer?m:c,v=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),p=null==f?void 0:f.levelCodec;c||(c=n[e]={buffer:void 0,listeners:[],codec:s,supplemental:h,container:l,levelCodec:u,metadata:d,id:o});var g=rP(v,p),y=null==g?void 0:g.replace(XC,"$1"),b=rP(s,u),w=null==(a=b)?void 0:a.replace(XC,"$1");b&&g&&y!==w&&("audio"===e.slice(0,5)&&(b=aP(b,this.appendSource)),this.log(`switching codec ${v} to ${b}`),b!==(c.pendingCodec||c.codec)&&(c.pendingCodec=b),c.container=l,this.appendChangeType(e,l,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(i=t.audio)?void 0:i.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}},{key:"sourceBufferTracks",get:function(){return Object.keys(this.tracks).reduce((e,t)=>{var i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}},{key:"appendChangeType",value:function(e,t,i){var n=`${t};codecs=${i}`,a={label:`change-type=${n}`,execute:()=>{var a=this.tracks[e];if(a){var r=a.buffer;null!=r&&r.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),r.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,OM))?void 0:t.gap))){var a={label:"block-audio",execute:()=>{var e,t=this.tracks.video;(this.lastVideoAppendEnd>n||null!=t&&t.buffer&&AA.isBuffered(t.buffer,n)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(n,OM))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var i=this.tracks,n=t.data,a=t.type,r=t.parent,o=t.frag,s=t.part,u=t.chunkMeta,l=t.offset,d=u.buffering[a],h=o.sn,c=o.cc,m=self.performance.now();d.start=m;var f=o.stats.buffering,v=s?s.stats.buffering:null;0===f.start&&(f.start=m),v&&0===v.start&&(v.start=m);var p=i.audio,g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var y=i.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==h){var w=s||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===r||this.blockedAudioAppend||y.ending||y.ended){if("video"===a){var S=w.end;if(k){var E=k.frag.start;(S>E||S<this.lastVideoAppendEnd||AA.isBuffered(b,E))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var M=w.start+.05*w.duration,T=b.buffered,P=this.currentOp("video");T.length||P?!P&&!AA.isBuffered(b,M)&&this.lastVideoAppendEnd<M&&this.blockAudio(w):this.blockAudio(w)}}var A=(s||o).start,D={label:`append-${a}`,execute:()=>{var e;d.executeStart=self.performance.now();var t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(g?this.updateTimestampOffset(t,A,.1,a,h,c):void 0!==l&&AM(l)&&this.updateTimestampOffset(t,l,1e-6,a,h,c)),this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t={};this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=AA.getBuffered(i))}),this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(LM.BUFFER_APPENDED,{type:a,frag:o,part:s,chunkMeta:u,parent:o.type,timeRanges:t})},onError:e=>{var t,i={type:CM.MEDIA_ERROR,parent:o.type,details:IM.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:s,chunkMeta:u,error:e,err:e,fatal:!1},n=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=IM.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!n)i.errorAction=aA(!0);else if(e.name===YC&&0===this.sourceBufferCount)i.errorAction=aA(!0);else{var r=++this.appendErrors[a];this.warn(`Failed ${r}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer (${n||"no media error"})`),(r>=this.hls.config.appendErrorMaxRetry||n)&&(i.fatal=!0)}this.hls.trigger(LM.ERROR,i)}};this.log(`queuing "${a}" append sn: ${h}${s?" p: "+s.index:""} of ${o.type===OM?"level":"track"} ${o.level} cc: ${c}`),this.append(D,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(LM.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.type,n=t.startOffset,a=t.endOffset;i?this.append(this.getFlushOp(i,n,a),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,n,a),e)})}},{key:"onFragParsed",value:function(e,t){var i=t.frag,n=t.part,a=[],r=n?n.elementaryStreams:i.elementaryStreams;r[pT]?a.push("audiovideo"):(r[fT]&&a.push("audio"),r[vT]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(()=>{var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;this.hls.trigger(LM.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})},a).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){var t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}},{key:"onBufferEos",value:function(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){var i=this.tracks[e];t.type&&t.type!==e||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();var e=this.mediaSource;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(LM.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(LM.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}},{key:"tracksEnded",value:function(){this.sourceBuffers.forEach(([e])=>{if(null!==e){var t=this.tracks[e];t&&(t.ending=!1)}})}},{key:"onLevelUpdated",value:function(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}},{key:"updateDuration",value:function(){this.blockUntilOpen(()=>{var e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}},{key:"onError",value:function(e,t){if(t.details===IM.BUFFER_APPEND_ERROR&&t.frag){var i,n=null==(i=t.errorAction)?void 0:i.nextAutoLevel;AM(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.sourceBufferCount){var n=e.config,a=i.currentTime,r=t.levelTargetDuration,o=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(AM(o)&&o>=0){var s=Math.max(o,r),u=Math.floor(a/r)*r-s;this.flushBackBuffer(a,r,u)}var l=n.frontBufferFlushThreshold;if(AM(l)&&l>0){var d=Math.max(n.maxBufferLength,l),h=Math.max(d,r),c=Math.floor(a/r)*r+h;this.flushFrontBuffer(a,r,c)}}}},{key:"flushBackBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){var n=AA.getBuffered(t);if(n.length>0&&i>n.start(0)){var a;this.hls.trigger(LM.BACK_BUFFER_REACHED,{bufferEnd:i});var r=this.tracks[e];if(null!=(a=this.details)&&a.live)this.hls.trigger(LM.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=r&&r.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(LM.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}},{key:"flushFrontBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([t,n])=>{if(n){var a=AA.getBuffered(n),r=a.length;if(r<2)return;var o=a.start(r-1),s=a.end(r-1);if(i>o||e>=o&&e<=s)return;this.hls.trigger(LM.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:t})}})}},{key:"getDurationAndRange",value:function(){var e,t=this.details,i=this.mediaSource;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var r=null==(e=this.overrides)?void 0:e.duration;if(r)return AM(r)?{duration:r}:null;var o=this.media.duration;return n>(AM(i.duration)?i.duration:0)&&n>o||!AM(o)?{duration:n}:null}},{key:"updateMediaSource",value:function({duration:e,start:t,end:i}){var n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==e&&(AM(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,i=this.tracks;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${PP(i)}`),this.tracksReady){var n,a=null==(n=this.transferData)?void 0:n.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){if(this.sourceBufferCount){var e={};this.sourceBuffers.forEach(([t,i])=>{if(t){var n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(LM.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{var t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,r=e[a];if(this.isPending(r)){var o=this.getTrackCodec(r,a),s=`${r.container};codecs=${o}`;r.codec=o,this.log(`creating sourceBuffer(${s})${this.currentOp(a)?" Queued":""} ${PP(r)}`);try{var u=i.addSourceBuffer(s),l=ZC(a),d=[a,u];t[l]=d,r.buffer=u}catch(e){var h;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s,parent:r.id})}this.trackSourceBuffer(a,r)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var i=e.supplemental,n=e.codec;i&&("video"===t||"audiovideo"===t)&&JT(i,"video")&&(n=function(e,t){var i=[];if(e)for(var n=e.split(","),a=0;a<n.length;a++)qT(n[a],"video")||i.push(n[a]);return t&&i.push(t),i.join(",")}(n,i));var a=rP(n,e.levelCodec);return a?"audio"===t.slice(0,5)?aP(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{var i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(LM.BUFFER_FLUSHED,{type:e})})}}},{key:"mediaSrc",get:function(){var e,t,i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var i,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"updateTimestampOffset",value:function(e,t,i,n,a,r){var o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${r})`),e.timestampOffset=t)}},{key:"removeExecutor",value:function(e,t,i){var n=this.media,a=this.mediaSource,r=this.tracks[e],o=null==r?void 0:r.buffer;if(!n||!a||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);var s=AM(n.duration)?n.duration:1/0,u=AM(a.duration)?a.duration:1/0,l=Math.max(0,t),d=Math.min(i,s,u);d>l&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${l},${d}] from the ${e} SourceBuffer`),o.remove(l,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var i=this.tracks[t],n=null==i?void 0:i.buffer;if(!n)throw new qC(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}},{key:"isQueued",value:function(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,n=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}},{key:"stepOperationQueue",value:function(e){e.forEach(e=>{var t,i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}},{key:"append",value:function(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}},{key:"addBufferListener",value:function(e,t,i){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var r=i.bind(this,e);n.listeners.push({event:t,listener:r}),a.addEventListener(t,r)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}}}])}();function QC(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function ZC(e){return"audio"===e?1:0}var eI=function(){function e(t){Q(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return ne(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.on(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(LM.BUFFER_CODECS,this.onBufferCodecs,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(LM.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.off(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(LM.BUFFER_CODECS,this.onBufferCodecs,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&AM(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var i=this.hls.levels;if(!i.length)return-1;var n=i.filter((e,i)=>this.isLevelAllowed(e)&&i<=t);return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,i){if(null==e||!e.length)return-1;for(var n=(e,t)=>!t||(e.width!==t.width||e.height!==t.height),a=e.length-1,r=Math.max(t,i),o=0;o<e.length;o+=1){var s=e[o];if((s.width>=r||s.height>=r)&&n(s,e[o+1])){a=o;break}}return a}}])}(),tI={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},iI={HLS:"h"},nI=ne(function e(t,i){Q(this,e),Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=i});function aI(e,t,i,n){return new Error(`failed to ${e} "${a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"==typeof a?JSON.stringify(a):String(a)}" as ${i}`,{cause:n});var a}function rI(e,t,i){return aI("serialize",e,t,i)}var oI=ne(function e(t){Q(this,e),this.description=t}),sI="Bare Item";function uI(e){if(!1===ArrayBuffer.isView(e))throw rI(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function lI(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw rI(e,"Integer");return e.toString()}function dI(e,t){if(e<0)return-dI(-e,t);var i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){var n=Math.floor(e*i);return(n%2==0?n:n+1)/i}return Math.round(e*i)/i}function hI(e){var t=dI(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw rI(e,"Decimal");var i=t.toString();return i.includes(".")?i:`${i}.0`}var cI=/[\x00-\x1f\x7f]+/;function mI(e){var t,i=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw rI(i,"Token");return i}function fI(e){switch(typeof e){case"number":if(!AM(e))throw rI(e,sI);return Number.isInteger(e)?lI(e):hI(e);case"string":return function(e){if(cI.test(e))throw rI(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return mI(e);case"boolean":return function(e){if("boolean"!=typeof e)throw rI(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${lI(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return uI(e);if(e instanceof oI)return mI(e);default:throw rI(e,sI)}}function vI(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw rI(e,"Key");return e}function pI(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${vI(e)}`:`;${vI(e)}=${fI(t)}`).join("")}function gI(e){return e instanceof nI?`${fI(e.value)}${pI(e.params)}`:fI(e)}function yI(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw rI(e,"Dict");var i=e instanceof Map?e.entries():Object.entries(e),n=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof nI==!1&&(t=new nI(t));var i,n=vI(e);return!0===t.value?n+=pI(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map(gI).join(" ")})${pI(i.params)}`:n+=gI(t)),n}).join(`,${n}`)}function bI(e,t){return yI(e,t)}var wI="CMCD-Object",kI="CMCD-Request",SI="CMCD-Session",EI="CMCD-Status",MI={br:wI,ab:wI,d:wI,ot:wI,tb:wI,tpb:wI,lb:wI,tab:wI,lab:wI,url:wI,pb:kI,bl:kI,tbl:kI,dl:kI,ltc:kI,mtp:kI,nor:kI,nrr:kI,rc:kI,sn:kI,sta:kI,su:kI,ttfb:kI,ttfbb:kI,ttlb:kI,cmsdd:kI,cmsds:kI,smrt:kI,df:kI,cs:kI,ts:kI,cid:SI,pr:SI,sf:SI,sid:SI,st:SI,v:SI,msd:SI,bs:EI,bsd:EI,cdn:EI,rtp:EI,bg:EI,pt:EI,ec:EI,e:EI},TI=kI;function PI(e,t){var i={};if(!e)return i;var n,a=Object.keys(e),r=t?(n=t,Object.keys(n).reduce((e,t)=>{var i;return null===(i=n[t])||void 0===i||i.forEach(i=>e[i]=t),e},{})):{};return a.reduce((t,i)=>{var n,a=MI[i]||r[i]||TI;return(null!==(n=t[a])&&void 0!==n?n:t[a]={})[i]=e[i],t},i)}var AI="event";var DI=e=>Math.round(e),xI=(e,t)=>Array.isArray(e)?e.map(e=>xI(e,t)):e instanceof nI&&"string"==typeof e.value?new nI(xI(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){var i=new URL(e),n=new URL(t);if(i.origin!==n.origin)return e;for(var a=i.pathname.split("/").slice(1),r=n.pathname.split("/").slice(1,-1);a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),CI=e=>100*DI(e/100),II={br:DI,d:DI,bl:CI,dl:CI,mtp:CI,nor:(e,t)=>{var i=e;return t.version>=2&&(e instanceof nI&&"string"==typeof e.value?i=new nI([e]):"string"==typeof e&&(i=[e])),xI(i,t)},rtp:CI,tb:DI},LI="request",_I="response",RI=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],FI=["e"],WI=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function OI(e){return WI.test(e)}var $I=["d","dl","nor","ot","rtp","su"];var NI=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];var jI=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function BI(e){return jI.includes(e)||OI(e)}var zI={[_I]:function(e){return RI.includes(e)||$I.includes(e)||NI.includes(e)||OI(e)},[AI]:function(e){return RI.includes(e)||FI.includes(e)||OI(e)},[LI]:function(e){return RI.includes(e)||$I.includes(e)||OI(e)}};function UI(e,t={}){var i={};if(null==e||"object"!=typeof e)return i;var n=t.version||e.v||1,a=t.reportingMode||LI,r=1===n?BI:zI[a],o=Object.keys(e).filter(r),s=t.filter;"function"==typeof s&&(o=o.filter(s));var u=a===_I||a===AI;u&&!o.includes("ts")&&o.push("ts"),n>1&&!o.includes("v")&&o.push("v");var l=UM({},II,t.formatters),d={version:n,reportingMode:a,baseUrl:t.baseUrl};return o.sort().forEach(t=>{var a=e[t],r=l[t];if("function"==typeof r&&(a=r(a,d)),"v"===t){if(1===n)return;a=n}"pr"==t&&1===a||(u&&"ts"===t&&!AM(a)&&(a=Date.now()),function(e){return"number"==typeof e?AM(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof a&&(a=new oI(a)),i[t]=a))}),i}function HI(e,t,i){return UM(e,function(e,t={}){var i={};if(!e)return i;var n=PI(UI(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(n).reduce((e,[t,i])=>{var n=bI(i,{whitespace:!1});return n&&(e[t]=n),e},i)}(t,i))}function GI(e,t={}){if(!e)return"";var i=function(e,t={}){return e?bI(UI(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(i)}var VI=/CMCD=[^&#]+/;function KI(e,t,i){var n=function(e,t={}){return e?`CMCD=${GI(e,t)}`:""}(t,i);if(!n)return e;if(VI.test(e))return e.replace(VI,n);var a=e.includes("?")?"&":"?";return`${e}${a}${n}`}var XI=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:tI.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,i=e.part,n=this.hls.levels[t.level],a=this.getObjectType(t),r={d:1e3*(i||t).duration,ot:a};a!==tI.VIDEO&&a!==tI.AUDIO&&a!=tI.MUXED||(r.br=n.bitrate/1e3,r.tb=this.getTopBandwidth(a)/1e3,r.bl=this.getBufferLength(a));var o=i?this.getNextPart(i):this.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(r.nor=o.url),this.apply(e,r)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())},[{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHED,this.onMediaDetached,this),e.on(LM.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHED,this.onMediaDetached,this),e.off(LM.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var i,n;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:iI.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e,t={}){UM(t,this.createData());var i=t.ot===tI.INIT||t.ot===tI.VIDEO||t.ot===tI.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n=this.includeKeys;n&&(t=Object.keys(t).reduce((e,i)=>(n.includes(i)&&(e[i]=t[i]),e),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),HI(e.headers,t,a)):e.url=KI(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var n=e.sn-i.startSN;return i.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(t=t.details)?void 0:t.partList;if(a)for(var r=n.sn,o=a.length-1;o>=0;o--){var s=a[o];if(s.index===i&&s.fragment.sn===r)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?tI.TIMED_TEXT:"initSegment"===e.sn?tI.INIT:"audio"===t?tI.AUDIO:"main"===t?this.hls.audioTracks.length?tI.VIDEO:tI.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,i=0,n=this.hls;if(e===tI.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,i=e===tI.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*AA.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){return ne(function e(t){Q(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){return ne(function e(t){Q(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}}])}(),YI=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["content-steering",t.logger])).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}return ue(e,VM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.off(LM.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var i=t.errorAction;if((null==i?void 0:i.action)===qP&&i.flags===eA){var n=this.levels,a=this._pathwayPriority,r=this.pathwayId;if(t.context){var o=t.context,s=o.groupId,u=o.pathwayId,l=o.type;s&&n?r=this.getPathwayForGroupId(s,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!a&&n&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),i.resolved=this.pathwayId!==r),t.details!==IM.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${n?n.length:n} priorities: ${PP(a)} penalized: ${PP(this.penalizedPathways)}`):i.resolved=!0}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(e=>{n-i[e]>3e5&&delete i[e]});for(var a=0;a<e.length;a++){var r=e[a];if(!(r in i)){if(r===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,WD(t),this.hls.trigger(LM.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,i){for(var n=this.getLevelsForPathway(i).concat(this.levels||[]),a=0;a<n.length;a++)if(t===FM&&n[a].hasAudioGroup(e)||t===WM&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return i}},{key:"clonePathways",value:function(e){var t=this.levels;if(t){var i={},n={};e.forEach(e=>{var a=e.ID,r=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!t.some(e=>e.pathwayId===a)){var s=this.getLevelsForPathway(r).map(e=>{var t=new FA(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=JI(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new EP({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",`${e.audioGroups[d]}_clone_${a}`);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",`${e.subtitleGroups[h]}_clone_${a}`);return l});t.push(...s),qI(this.audioTracks,i,o,a),qI(this.subtitleTracks,n,o,a)}})}}},{key:"loadSteeringManifest",value:function(e){var t,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var r={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,i,n,a)=>{this.log(`Loaded steering manifest: "${t}"`);var r=e.data;if(1===(null==r?void 0:r.VERSION)){this.updated=performance.now(),this.timeToLoad=r.TTL;var o=r["RELOAD-URI"],s=r["PATHWAY-CLONES"],u=r["PATHWAY-PRIORITY"];if(o)try{this.uri=new self.URL(o,t).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||n.url),s&&this.clonePathways(s);var l={steeringManifest:r,url:t.toString()};this.hls.trigger(LM.STEERING_MANIFEST_LOADED,l),u&&this.updatePathwayPriority(u)}else this.log(`Steering VERSION ${r.VERSION} not supported!`)},onError:(e,t,i,n)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);var a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{var r=this.loader;if("function"==typeof(null==r?void 0:r.getResponseHeader)){var o=r.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,u,l)}},{key:"scheduleRefresh",value:function(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t,i=null==(t=this.hls)?void 0:t.media;!i||i.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}])}();function qI(e,t,i,n){e&&Object.keys(t).forEach(a=>{var r=e.filter(e=>e.groupId===a).map(e=>{var r=UM({},e);return r.details=void 0,r.attrs=new FA(r.attrs),r.url=r.attrs.URI=JI(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=n,r});e.push(...r)})}function JI(e,t,i,n){var a,r=n.HOST,o=n.PARAMS,s=n[i];t&&(a=null==s?void 0:s[t])&&(e=a);var u=new self.URL(e);return r&&!a&&(u.host=r),o&&Object.keys(o).sort().forEach(e=>{e&&u.searchParams.set(e,o[e])}),u.href}var QI=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["eme",t.logger])).hls=void 0,i.config=void 0,i.media=null,i.mediaResolved=void 0,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.mediaKeys=null,i.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],i.bannedKeyIds={},i.onMediaEncrypted=e=>{var t=e.initDataType,n=e.initData,a=`"${e.type}" event: init data type: "${t}"`;if(i.debug(a),null!==n){if(!i.keyFormatPromise){var r=Object.keys(i.keySystemAccessPromises);r.length||(r=iD(i.config));var o=r.map(tD).filter(e=>!!e);i.keyFormatPromise=i.getKeyFormatPromise(o)}i.keyFormatPromise.then(r=>{var o=eD(r);if("sinf"===t&&o===YA.FAIRPLAY){var s;try{var u=TT(new Uint8Array(n)),l=NT(HA(JSON.parse(u).sinf));if(!l)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(l.subarray(8,24))}catch(e){return void i.warn(`${a} Failed to parse sinf: ${e}`)}for(var d,h=iT(s),c=i,m=c.keyIdToKeySessionPromise,f=c.mediaKeySessions,v=m[h],p=function(){var e=f[g],a=e.decryptdata;if(!a.keyId)return 0;var r=iT(a.keyId);return jA(s,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(h)?(v=m[r])?(a.pssh||(delete m[r],a.pssh=new Uint8Array(n),a.keyId=s,(v=m[h]=v.then(()=>i.generateRequestWithPreferredKeySession(e,t,n,"encrypted-event-key-match"))).catch(e=>i.handleError(e))),1):0:void 0},g=0;g<f.length&&(0===(d=p())||1!==d);g++);v||i.handleError(new Error(`Key ID ${h} not encountered in playlist. Key-system sessions ${f.length}.`))}else i.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${o}`)}).catch(e=>i.handleError(e))}},i.onWaitingForKey=e=>{i.log(`"${e.type}" event`)},i.hls=t,i.config=t.config,i.registerListeners(),i}return ue(e,VM),ne(e,[{key:"destroy",value:function(){this.onDestroying(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(LM.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(LM.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(LM.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){this.hls.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(LM.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(LM.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(LM.DESTROYING,this.onDestroying,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=null==i?void 0:i[e];return a?a.licenseUrl:e===YA.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}},{key:"attemptKeySystemAccess",value:function(e){var t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,n=t.map(e=>e.audioCodec).filter(i),a=t.map(e=>e.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,i)=>{var r=e=>{var o=e.shift();this.getMediaKeysPromise(o,n,a).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?r(e):i(t instanceof tL?t:new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};r(e)})}},{key:"requestMediaKeySystemAccess",value:function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof i){var n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===aD&&"http:"===self.location.protocol&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,i){var n,a=function(e,t,i,n){var a;switch(e){case YA.FAIRPLAY:a=["cenc","sinf"];break;case YA.WIDEVINE:case YA.PLAYREADY:a=["cenc"];break;case YA.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}))}]}(a,t,i,n)}(e,t,i,this.config.drmSystemOptions||{}),r=this.keySystemAccessPromises[e],o=null==(n=r)?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${PP(a)}`),o=this.requestMediaKeySystemAccess(e,a);var s=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),o.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);var i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);var n=s.mediaKeys=t.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),s.hasMediaKeys=!0,i.then(i=>i?this.setMediaKeysServerCertificate(t,e,i):t)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return o.then(()=>r.mediaKeys)}},{key:"createMediaKeySessionContext",value:function({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${iT(e.keyId||[])} keyUri: ${e.uri}`);var n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=ZI(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"updateKeySession",value:function(e,t){var i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${iT(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),i.update(t)}},{key:"getSelectedKeySystemFormats",value:function(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>tD(e)).filter(e=>!!e)}},{key:"getKeySystemAccess",value:function(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}},{key:"selectKeySystem",value:function(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var n=tD(e);n?t(n):i(new Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=iD(this.config),i=e.map(eD).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}},{key:"getKeyStatus",value:function(e){for(var t=this.mediaKeySessions,i=0;i<t.length;i++){var n=eL(e,t[i]);if(n)return n}}},{key:"loadKey",value:function(e){var t=e.keyInfo.decryptdata,i=ZI(t),n=this.bannedKeyIds[i];if(n||"internal-error"===this.getKeyStatus(t)){var a=iL(n||"internal-error",t);return this.handleError(a,e.frag),Promise.reject(a)}var r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);var o=this.keyIdToKeySessionPromise[i];if(!o){var s=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(i,n).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:n,decryptdata:t}))))).then(e=>{var i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=s,s}return o.catch(i=>{if(i instanceof tL){var n=GM({},i.data);"internal-error"===this.getKeyStatus(t)&&(n.decryptdata=t);var a=new tL(n,i.message);this.handleError(a,e.frag)}}),o}},{key:"throwIfDestroyed",value:function(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e,t){if(this.hls)if(e instanceof tL){t&&(e.data.frag=t);var i=e.data.decryptdata;this.error(`${e.message}${i?` (${iT(i.keyId||[])})`:""}`),this.hls.trigger(LM.ERROR,e.data)}else this.error(e.message),this.hls.trigger(LM.ERROR,{type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}},{key:"getKeySystemForKeyPromise",value:function(e){var t=ZI(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=eD(e.keyFormat),a=n?[n]:iD(this.config);return this.attemptKeySystemAccess(a)}return i}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=iD(this.config)),0===e.length)throw new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${PP({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();var i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);var n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,i)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return i(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,i,n){var a,r=null==(a=this.config.drmSystems)||null==(a=a[e.keySystem])?void 0:a.generateRequest;if(r)try{var o=r.call(this.hls,t,i,e);if(!o)throw new Error("Invalid response from configured generateRequest filter");t=o.initDataType,i=o.initData?o.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);var s=ZI(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${s} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);var l=new hx,d=e._onmessage=t=>{var i=e.mediaKeysSession;if(i){var n=t.messageType,a=t.message;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${a.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(e,a).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===n?e.keySystem===YA.FAIRPLAY&&this.updateKeySession(e,GA("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${n}"`)}else l.emit("error",new Error("invalid state"))},h=(e,t)=>{var i;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=iL(e,t.decryptdata):"expired"===e?i=new Error(`key expired (keyId: ${s})`):"released"===e?i=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${s})`),i&&(l.eventNames().length?l.emit("error",i):this.handleError(i))},c=e._onkeystatuseschange=t=>{if(e.mediaKeysSession){var i=this.getKeyStatuses(e);if(Object.keys(i).some(e=>"status-pending"!==i[e])){if("expired"===i[s])return this.log(`Expired key ${PP(i)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);var n=i[s];if(n)h(n,e);else{var a;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[s]||(a[s]=self.setTimeout(()=>{if(e.mediaKeysSession&&this.mediaKeys){var t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${s} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${s} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(n="internal-error",e)}},1e3)),this.log(`No status for keyId ${s} (${PP(i)}).`)}}}else l.emit("error",new Error("invalid state"))};HD(e.mediaKeysSession,"message",d),HD(e.mediaKeysSession,"keystatuseschange",c);var m=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${s} URI: ${u}`)}).catch(t=>{throw new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>m).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}},{key:"getKeyStatuses",value:function(e){var t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if("string"==typeof n&&"object"==typeof i){var a=n;n=i,i=a}var r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===YA.PLAYREADY&&16===r.length){var o=iT(r);t[o]=i,VA(r)}var s=iT(r);"internal-error"===i&&(this.bannedKeyIds[s]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=i}),t}},{key:"fetchServerCertificate",value:function(e){var t=this.config,i=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,r)=>{var o={responseType:"arraybuffer",url:n},s=t.certLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{a(e.data)},onError:(t,i,a,s)=>{r(new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:GM({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${n}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{r(new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(e,t,i)=>{r(new Error("aborted"))}};i.load(o,u,l)})):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(e=>{a(new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}},{key:"renewLicense",value:function(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(i,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var r,o=0,s=a.length;o<s;o++){var u,l,d=null==(u=(r=a[o]).querySelector("name"))?void 0:u.textContent,h=null==(l=r.querySelector("value"))?void 0:l.textContent;d&&h&&e.setRequestHeader(d,h)}var c=n.querySelector("Challenge"),m=null==c?void 0:c.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return GA(atob(m))}},{key:"setupLicenseXHR",value:function(e,t,i,n){var a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(r=>{if(!i.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{var r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;var s=o.response;this.log(`License received ${s instanceof ArrayBuffer?s.byteLength:s}`);var u=this.config.licenseResponseCallback;if(u)try{s=u.call(this.hls,o,r,e)}catch(e){this.error(e)}n(s)}else{var l=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new tL({type:CM.KEY_SYSTEM_ERROR,details:IM.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{var h=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==YA.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(a)})}},{key:"onDestroying",value:function(){this.unregisterListeners(),this._clear()}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,HD(i,"encrypted",this.onMediaEncrypted),HD(i,"waitingforkey",this.onWaitingForKey);var n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(GD(e,"encrypted",this.onMediaEncrypted),GD(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}},{key:"_clear",value:function(){var t;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};var i=this.mediaResolved;if(i&&i(),this.mediaKeys||this.mediaKeySessions.length){var n=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,sD.clearKeyUriToKeyIdMap();var r=a.length;e.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}}},{key:"onManifestLoading",value:function(){this._clear()}},{key:"onManifestLoaded",value:function(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){var i=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=e.mediaKeysSession,i=e.licenseXhr,n=e.decryptdata;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${iT((null==n?void 0:n.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var r=e.keyStatusTimeouts;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));var o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(this.config.drmSystemOptions)?new Promise((e,i)=>{self.setTimeout(()=>i(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}])}();function ZI(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return iT(e.keyId)}function eL(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}QI.CDMCleanupPromise=void 0;var tL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i])).data=void 0,t.error||(t.error=new Error(i)),n.data=t,t.err=t.error,n}return ue(e,ye(Error)),ne(e)}();function iL(e,t){var i="output-restricted"===e,n=i?IM.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:IM.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new tL({type:CM.KEY_SYSTEM_ERROR,details:n,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}var nL=function(){return ne(function e(t){Q(this,e),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=t,this.registerListeners()},[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*r/a,u=this.hls;if(u.trigger(LM.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),s>0&&r>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(LM.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}])}();function aL(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function rL(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){QM.debug(`[texttrack-utils]: ${i}`);try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){QM.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function oL(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===i&&(e.mode=i)}function sL(e,t,i,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var r=function(e,t,i){var n=[],a=function(e,t){if(t<=e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;var n,a=0,r=i;for(;a<=r;)if(t<e[n=Math.floor((r+a)/2)].startTime)r=n-1;else{if(!(t>e[n].startTime&&a<i))return n;a=n+1}return e[a].startTime-t<t-e[r].startTime?a:r}(e,t);if(a>-1)for(var r=a,o=e.length;r<o;r++){var s=e[r];if(s.startTime>=t&&s.endTime<=i)n.push(s);else if(s.startTime>i)return n}return n}(e.cues,t,i),o=0;o<r.length;o++)n&&!n(r[o])||e.removeCue(r[o]);"disabled"===a&&(e.mode=a)}function uL(e){for(var t=[],i=0;i<e.length;i++){var n=e[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[i])}return t}var lL=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t,"subtitle-track-controller"])).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=()=>i.pollTrackChange(0),i.onTextTracksChanged=()=>{if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=uL(i.media.textTracks),n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}var a=i.findTrackForTextTrack(e);i.subtitleTrack!==a&&i.setSubtitleTrack(a)}},i.registerListeners(),i}return ue(e,zC),ne(e,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,pe(e,"destroy",this)([])}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.on(LM.LEVEL_LOADING,this.onLevelLoading,this),e.on(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(LM.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(LM.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),e.off(LM.LEVEL_LOADING,this.onLevelLoading,this),e.off(LM.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(LM.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(LM.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.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))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var i=this.media;if(i){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n)uL(i.textTracks).forEach(e=>{oL(e)})}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var s=CP(o,r);if(s>-1)a=r[s];else{var u=CP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(LM.SUBTITLE_TRACKS_UPDATED,d),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!i||a.default)&&(i||e)&&(!e||IP(a,e)))return n}if(e){for(var r=0;r<t.length;r++){var o=t[r];if(HC(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(var s=0;s<t.length;s++){var u=t[s];if(HC(e.attrs,u.attrs,["LANGUAGE"]))return s}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,i=0;i<t.length;i++){if(GC(t[i],e))return i}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==WM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var i=this.currentTrack;if(i&&IP(e,i))return i;var n=CP(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(i)return null;var r=CP(e,t);if(r>-1)return t[r]}}return null}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading subtitle ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(LM.SUBTITLE_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,i=uL(e.textTracks),n=this.currentTrack;if(n&&((t=i.filter(e=>GC(n,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(i).forEach(e=>{"disabled"!==e.mode&&e!==t&&(e.mode="disabled")}),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!AM(e))this.warn(`Invalid subtitle track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),n){var a=!!n.details&&!n.details.live;if(e!==this.trackId||n!==i||!a){this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));var r=n.id,o=n.groupId,s=void 0===o?"":o,u=n.name,l=n.type,d=n.url;this.hls.trigger(LM.SUBTITLE_TRACK_SWITCH,{id:r,groupId:s,name:u,type:l,url:d});var h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}}else this.hls.trigger(LM.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}])}();function dL(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var hL=.025,cL=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function mL(e,t,i){return`${e.identifier}-${i+1}-${dL(t)}`}var fL=function(){return ne(function e(t,i){Q(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=i,this.dateRange=t,this.setDateRange(t)},[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return vL(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-vL(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=AM(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return vL(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<hL))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?cL.Range:cL.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}])}();function vL(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<hL)?t.start:t.start+t.duration}function pL(e,t,i){var n=new self.URL(e,i);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function gL(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function yL(e){var t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}var bL=function(){return ne(function e(t,i,n,a){Q(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(LM.PLAYOUT_LIMIT_REACHED,{})};var r=this.hls=new t(i);this.interstitial=n,this.assetItem=a;var o=()=>{this.hasDetails=!0};r.once(LM.LEVEL_LOADED,o),r.once(LM.AUDIO_TRACK_LOADED,o),r.once(LM.SUBTITLE_TRACK_LOADED,o),r.on(LM.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(LM.BUFFER_APPENDED,()=>{var e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(LM.BUFFERED_TO_END,void 0))}))})},[{key:"appendInPlace",get:function(){return this.interstitial.appendInPlace}},{key:"loadSource",value:function(){var e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{var t=this.assetItem.uri;try{t=pL(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}},{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;var i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,a=AA.bufferInfo(e,n,0);return this.getAssetTime(a.end)>=i-.02}},{key:"reachedPlayout",value:function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=AA.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;if(!e)return 0;var t=this.interstitial.playoutLimit;if(t){var i=t-this.startOffset;if(i>0&&i<e)return i}return e}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}},{key:"detachMedia",value:function(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.hls)||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.hls)||e.pauseBuffering()}},{key:"transferMedia",value:function(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}},{key:"resetDetails",value:function(){var e=this.hls;if(e&&this.hasDetails){e.stopLoad();var t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}},{key:"on",value:function(e,t,i){var n;null==(n=this.hls)||n.on(e,t)}},{key:"once",value:function(e,t,i){var n;null==(n=this.hls)||n.once(e,t)}},{key:"off",value:function(e,t,i){var n;null==(n=this.hls)||n.off(e,t)}},{key:"toString",value:function(){var e;return`HlsAssetPlayer: ${yL(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}])}(),wL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["interstitials-sched",i])).onScheduleUpdate=void 0,n.eventMap={},n.events=null,n.items=null,n.durations={primary:0,playout:0,integrated:0},n.onScheduleUpdate=t,n}return ue(e,VM),ne(e,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(a=n[i])&&a.event;){var a;i--}return i}},{key:"findItemIndexAtTime",value:function(e,t){var i=this.items;if(i)for(var n=0;n<i.length;n++){var a=i[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var i=this.items;if(i)for(var n=e;n<=t&&i[n];n++){var a=i[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var i=t.length;i--;){var n;if((null==(n=t[i].event)?void 0:n.identifier)===e)return i}return-1}},{key:"findAssetIndex",value:function(e,t){var i=e.assetList,n=i.length;if(n>1)for(var a=0;a<n;a++){var r=i[a];if(!r.error){var o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||a===n-1))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){var i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var i=e.main.details,n=i.dateRanges,a=this.events,r=this.parseDateRanges(n,{url:i.url},t),o=Object.keys(n),s=a?a.filter(e=>!o.includes(e.identifier)):[];r.length&&r.sort((e,t)=>{var i=e.cue.pre,n=e.cue.post,a=t.cue.pre,r=t.cue.post;if(i&&!a)return-1;if(a&&!i)return 1;if(n&&!r)return 1;if(r&&!n)return-1;if(!(i||a||n||r)){var o=e.startTime,s=t.startTime;if(o!==s)return o-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=r,s.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,s)}},{key:"updateSchedule",value:function(e,t=[],i=!1){var n=this.events||[];if(n.length||t.length||this.length<2){var a=this.items,r=this.parseSchedule(n,e),o=i||t.length||(null==a?void 0:a.length)!==r.length||r.some((e,t)=>Math.abs(e.playout.start-a[t].playout.start)>.005||Math.abs(e.playout.end-a[t].playout.end)>.005);o&&(this.items=r,this.onScheduleUpdate(t,a))}}},{key:"parseDateRanges",value:function(e,t,i){for(var n=[],a=Object.keys(e),r=0;r<a.length;r++){var o=a[r],s=e[o];if(s.isInterstitial){var u=this.eventMap[o];u?u.setDateRange(s):(u=new fL(s,t),this.eventMap[o]=u,!1===i&&(u.appendInPlace=i)),n.push(u)}}return n}},{key:"parseSchedule",value:function(e,t){var i=[],n=t.main.details,a=n.live?1/0:n.edge,r=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);var o=0,s=0;if(e.forEach((t,n)=>{var u=t.cue.pre,l=t.cue.post,d=e[n-1]||null,h=t.appendInPlace,c=l?a:t.startOffset,m=t.duration,f=t.timelineOccupancy===cL.Range?m:0,v=t.resumptionOffset,p=(null==d?void 0:d.startTime)===c,g=c+t.cumulativeDuration,y=h?g+m:c+v;if(u||!l&&c<=0){var b=s;s+=f,t.timelineStart=g;var w=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:w,end:r},integrated:{start:b,end:s}})}else{if(!(c<=a))return;if(!p){var k=c-o;if(k>.033){var S=o,E=s;s+=k;var M=r;r+=k;var T={previousEvent:e[n-1]||null,nextEvent:t,start:S,end:S+k,playout:{start:M,end:r},integrated:{start:E,end:s}};i.push(T)}else k>0&&d&&(d.cumulativeDuration+=k,i[i.length-1].end=c)}l&&(y=g),t.timelineStart=g;var P=s;s+=f;var A=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:A,end:r},integrated:{start:P,end:s}})}var D=t.resumeTime;o=l||D>a?a:D}),o<a){var u,l=o,d=s,h=a-o;s+=h;var c=r;r+=h,i.push({previousEvent:(null==(u=i[i.length-1])?void 0:u.event)||null,nextEvent:null,start:o,end:l+h,playout:{start:c,end:r},integrated:{start:d,end:s}})}this.setDurations(a,r,s)}else{i.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return i}},{key:"setDurations",value:function(e,t,i){this.durations={primary:e,playout:t,integrated:i}}},{key:"resolveOffsets",value:function(e,t){var i=t.main.details,n=i.live?1/0:i.edge,a=0,r=-1;e.forEach((o,s)=>{var u=o.cue.pre,l=o.cue.post,d=u?0:l?n:o.startTime;(this.updateAssetDurations(o),r===d?o.cumulativeDuration=a:(a=0,r=d),!l&&o.snapOptions.in&&(o.resumeAnchor=OP(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&s+1<e.length&&(e[s+1].startTime-e[s].resumeTime<.033&&(e[s+1].appendInPlace=!1,e[s+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`)));var h=AM(o.resumeOffset)?o.resumeOffset:o.duration;a+=h})}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>hL?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(n=>{var a=t[n].details,r=a.edge;if(i>=r)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${r}`),!1;var o=OP(null,a.fragments,i);if(!o)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;var s="audio"===n?.175:0;return!(Math.abs(o.start-i)<hL+s||Math.abs(o.end-i)<hL+s)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${o.start}-${o.end} sn: ${o.sn} cc: ${o.cc})`),!0)})}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){for(var t=e.timelineStart,i=0,n=!1,a=!1,r=0;r<e.assetList.length;r++){var o=e.assetList[r],s=t+i;o.startOffset=i,o.timelineStart=s,n||(n=null===o.duration),a||(a=!!o.error),i+=o.error?0:o.duration||0}e.duration=n&&!a?Math.max(i,e.duration):i}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}])}();function kL(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var SL=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.hls=t},[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var i,n=e.assetListUrl;try{i=pL(n,this.hls.sessionId,e.baseUrl)}catch(t){var a=this.assignAssetListError(e,IM.ASSET_LIST_LOAD_ERROR,t,n);return void this.hls.trigger(LM.ERROR,a)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);var r=this.hls.config,o=new(0,r.loader)(r),s={responseType:"json",url:i.href},u=r.interstitialAssetListLoadPolicy.default,l={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,i,n,a)=>{var r=t.data,o=null==r?void 0:r.ASSETS;if(Array.isArray(o))e.assetListResponse=r,this.hls.trigger(LM.ASSET_LIST_LOADED,{event:e,assetListResponse:r,networkDetails:a});else{var s=this.assignAssetListError(e,IM.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,i,a);this.hls.trigger(LM.ERROR,s)}},onError:(t,i,n,a)=>{var r=this.assignAssetListError(e,IM.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,n);this.hls.trigger(LM.ERROR,r)},onTimeout:(t,i,n)=>{var a=this.assignAssetListError(e,IM.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,n);this.hls.trigger(LM.ERROR,a)}};return o.load(s,l,d),this.hls.trigger(LM.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,i,n,a,r){return e.error=i,{type:CM.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:r,stats:a}}}])}();function EL(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function ML(e,t){return`[${e}] Advancing timeline position to ${t}`}var TL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["interstitials",t.logger])).HlsPlayerClass=void 0,n.hls=void 0,n.assetListLoader=void 0,n.mediaSelection=null,n.altSelection=null,n.media=null,n.detachedData=null,n.requiredTracks=null,n.manager=null,n.playerQueue=[],n.bufferedPos=-1,n.timelinePos=-1,n.schedule=void 0,n.playingItem=null,n.bufferingItem=null,n.waitingItem=null,n.endedItem=null,n.playingAsset=null,n.endedAsset=null,n.bufferingAsset=null,n.shouldPlay=!1,n.onPlay=()=>{n.shouldPlay=!0},n.onPause=()=>{n.shouldPlay=!1},n.onSeeking=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&n.schedule){var t=e-n.timelinePos;if(!(Math.abs(t)<1/7056e5)){var i=t<=-.01;-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),n.timelinePos=e,n.bufferedPos=e;var a=n.playingItem;if(a){if(i)n.schedule.resetErrorsInRange(e,e-t)&&n.updateSchedule(!0);if(n.checkBuffer(),i&&e<a.start||e>=a.end){var r,o=n.findItemIndex(a),s=n.schedule.findItemIndexAtTime(e);if(-1===s&&(s=o+(i?-1:1),n.log(`seeked ${i?"back ":""}to position not covered by schedule ${e} (resolving from ${o} to ${s})`)),!n.isInterstitial(a)&&null!=(r=n.media)&&r.paused&&(n.shouldPlay=!1),!i&&s>o){var u=n.schedule.findJumpRestrictedIndex(o+1,s);if(u>o)return void n.setSchedulePosition(u)}n.setSchedulePosition(s)}else{var l=n.playingAsset;if(l){var d,h=l.timelineStart,c=l.duration||0;if(i&&e<h||e>=h+c)null!=(d=a.event)&&d.appendInPlace&&(n.clearAssetPlayers(a.event,a),n.flushFrontBuffer(e)),n.setScheduleToAssetAtTime(e,l)}else if(n.playingLastItem&&n.isInterstitial(a)){var m=a.event.assetList[0];m&&(n.endedItem=n.playingItem,n.playingItem=null,n.setScheduleToAssetAtTime(e,m))}}}else n.checkBuffer()}}},n.onTimeupdate=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&(-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),e>n.timelinePos)){n.timelinePos=e,e>n.bufferedPos&&n.checkBuffer();var t=n.playingItem;if(t&&!n.playingLastItem){if(e>=t.end){n.timelinePos=t.end;var i=n.findItemIndex(t);n.setSchedulePosition(i+1)}var a=n.playingAsset;if(a)e>=a.timelineStart+(a.duration||0)&&n.setScheduleToAssetAtTime(e,a)}}},n.onScheduleUpdate=(e,t)=>{var i=n.schedule;if(i){var a=n.playingItem,r=i.events||[],o=i.items||[],s=i.durations,u=e.map(e=>e.identifier),l=!(!r.length&&!u.length);(l||t)&&n.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${o.map(e=>kL(e))} pos: ${n.timelinePos}`),u.length&&n.log(`Removed events ${u}`);var d=null,h=null;a&&(d=n.updateItem(a,n.timelinePos),n.itemsMatch(a,d)?n.playingItem=d:n.waitingItem=n.endedItem=null),n.waitingItem=n.updateItem(n.waitingItem),n.endedItem=n.updateItem(n.endedItem);var c=n.bufferingItem;if(c&&(h=n.updateItem(c,n.bufferedPos),n.itemsMatch(c,h)?n.bufferingItem=h:c.event&&(n.bufferingItem=n.playingItem,n.clearInterstitial(c.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{n.clearAssetPlayer(e.identifier,null)})}),n.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(a){Math.abs(i)>hL&&n.warn(`${a} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(n.hls.trigger(LM.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:o.slice(0),durations:s,removedIds:u}),n.isInterstitial(a)&&u.includes(a.event.identifier))return n.warn(`Interstitial "${a.event.identifier}" removed while playing`),void n.primaryFallback(a.event);a&&n.trimInPlace(d,a),c&&h!==d&&n.trimInPlace(h,c),n.checkBuffer()}}},n.hls=t,n.HlsPlayerClass=i,n.assetListLoader=new SL(t),n.schedule=new wL(n.onScheduleUpdate,t.logger),n.registerListeners(),n}return ue(e,VM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(LM.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(LM.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(LM.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(LM.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(LM.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(LM.BUFFER_APPENDED,this.onBufferAppended,this),e.on(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(LM.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(LM.MEDIA_ENDED,this.onMediaEnded,this),e.on(LM.ERROR,this.onError,this),e.on(LM.DESTROYING,this.onDestroying,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(LM.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(LM.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(LM.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(LM.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(LM.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(LM.BUFFER_CODECS,this.onBufferCodecs,this),e.off(LM.BUFFER_APPENDED,this.onBufferAppended,this),e.off(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(LM.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(LM.MEDIA_ENDED,this.onMediaEnded,this),e.off(LM.ERROR,this.onError,this),e.off(LM.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){GD(e,"play",this.onPlay),GD(e,"pause",this.onPause),GD(e,"seeking",this.onSeeking),GD(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;HD(i,"seeking",this.onSeeking),HD(i,"timeupdate",this.onTimeupdate),HD(i,"play",this.onPlay),HD(i,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(i);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.log(`Removing schedule state for detachedData and ${a}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.hls)return null;if(this.manager)return this.manager;var e=this,t=()=>e.bufferingItem||e.waitingItem,i=t=>t?e.getAssetPlayer(t.identifier):t,n=(t,n,r,o,s)=>{if(t){var u=t[n].start,l=t.event;if(l){if("playout"===n||l.timelineOccupancy!==cL.Point){var d=i(r);(null==d?void 0:d.interstitial)===l&&(u+=d.assetItem.startOffset+d[s])}}else u+=("bufferedPos"===o?a():e[o])-t.start;return u}return 0},a=()=>{var t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var i,n;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(n=e.schedule)?void 0:n.durations[t])||0},o=(t,a)=>{var r,o,s=e.effectivePlayingItem;if((null==s||null==(r=s.event)||!r.restrictions.skip)&&e.schedule){e.log(`seek to ${t} "${a}"`);var u=e.effectivePlayingItem,l=e.schedule.findItemIndexAtTime(t,a),d=null==(o=e.schedule.items)?void 0:o[l],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,m=null==c?void 0:c.appendInPlace,f=u&&e.itemsMatch(u,d);if(u&&(m||f)){var v=i(e.playingAsset),p=(null==v?void 0:v.media)||e.primaryMedia;if(p){var g="primary"===a?p.currentTime:n(u,a,e.playingAsset,"timelinePos","currentTime"),y=t-g,b=(m?g:p.currentTime)+y;if(b>=0&&(!v||m||b<=v.duration))return void(p.currentTime=b)}}if(d){var w=t;if("primary"!==a){var k=t-d[a].start;w=d.start+k}var S=!e.isInterstitial(d);if(e.isInterstitial(u)&&!u.event.appendInPlace||!S&&!d.event.appendInPlace){if(u){var E=e.findItemIndex(u);if(l>E){var M=e.schedule.findJumpRestrictedIndex(E+1,l);if(M>E)return void e.setSchedulePosition(M)}var T=0;if(S)e.timelinePos=w,e.checkBuffer();else for(var P=d.event.assetList,A=t-(d[a]||d).start,D=P.length;D--;){var x=P[D];if(x.duration&&A>=x.startOffset&&A<x.startOffset+x.duration){T=D;break}}e.setSchedulePosition(l,T)}}else{var C=e.media||(m?null==h?void 0:h.media:null);C&&(C.currentTime=w)}}}},s=()=>{var i=e.effectivePlayingItem;if(e.isInterstitial(i))return i;var n=t();return e.isInterstitial(n)?n:null},u={get bufferedEnd(){var i,a=t(),r=e.bufferingItem;return r&&r===a&&(n(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(i=e.bufferingAsset)?void 0:i.startOffset))||0},get currentTime(){var t=s(),i=e.effectivePlayingItem;return i&&i===t?n(i,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(t){var i=s(),n=e.effectivePlayingItem;n&&n===i&&o(t+n.playout.start,"playout")},get duration(){var e=s();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,i=null==(t=s())?void 0:t.event.assetList;return i?i.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t,i=null==(t=s())?void 0:t.event;return i&&e.effectivePlayingAsset?i.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return s()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return s()?u:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var i=t();return e.findItemIndex(i)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){o(e,"primary")},get duration(){return r("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){o(e,"integrated")},get duration(){return r("integrated")},get seekableStart(){var t;return((t,i)=>{var n;if(0!==t&&"primary"!==i&&null!=(n=e.schedule)&&n.length){var a,r=e.schedule.findItemIndexAtTime(t),o=null==(a=e.schedule.items)?void 0:a[r];if(o)return t+(o[i].start-o.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{var t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;o(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&i)&&this.findItemIndex(t)===i.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(n=this.primaryMedia);var a=null==(t=n)?void 0:t.currentTime;if(void 0!==a&&AM(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n)return void(this.detachedData={media:n});var a=e.transferMedia();this.log(`transfer MediaSource from ${e} ${PP(a)}`),this.detachedData=a}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var i,n;if(e.media!==t){var a,r=null,o=this.hls,s=e!==o,u=s&&e.interstitial.appendInPlace,l=null==(i=this.detachedData)?void 0:i.mediaSource;if(o.media)u&&(r=o.transferMedia(),this.detachedData=r),a="Primary";else if(l){var d=this.getBufferingPlayer();d?(r=d.transferMedia(),a=`${d}`):a="detached MediaSource"}else a="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${PP(r)}`);else if(!this.detachedData||o.media===t){var h=this.playerQueue;h.length>1&&h.forEach(e=>{if(s&&e.interstitial.appendInPlace!==u){var t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}var c=r&&"mediaSource"in r&&"closed"!==(null==(n=r.mediaSource)?void 0:n.readyState),m=c&&r?r:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${s?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`);var f=this.schedule;if(m===r&&f){var v=s&&e.assetId===f.assetIdAtEnd;m.overrides={duration:f.duration,endOfStream:!s||v,cueRemoval:!s}}e.attachMedia(m)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=null==e?void 0:e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var i=this.timelinePos,n=this.effectivePlayingItem;if(-1===i){var a=this.hls.startPosition;if(this.timelinePos=a,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(ML("checkStart (preroll)",a));var r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(a>=0||!this.primaryLive){this.log(ML("checkStart",a));var o=this.timelinePos=a>0?a:0,s=e.findItemIndexAtTime(o);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(ML("checkStart (playing item)",n.start));var u=e.findItemIndex(n);this.setSchedulePosition(u)}}}},{key:"advanceAssetBuffering",value:function(e,t){var i=e.event,n=i.findAssetIndex(t),a=gL(i,n);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var r,o=null==(r=this.schedule.items)?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}else this.bufferedToEvent(e,a)}},{key:"advanceAfterAssetEnded",value:function(e,t,i){var n=gL(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){var a=this.schedule.items;if(a){var r=t+1;if(r>=a.length)return void this.setSchedulePosition(-1);var o=e.resumeTime;this.timelinePos<o&&(this.log(ML("advanceAfterAssetEnded",o)),this.timelinePos=o,e.appendInPlace&&this.advanceInPlace(o),this.checkBuffer(this.bufferedPos<o)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){var s=e.assetList[n];s&&this.advanceInPlace(s.timelineStart)}this.setSchedulePosition(t,n)}}},{key:"setScheduleToAssetAtTime",value:function(e,t){var i=this.schedule;if(i){var n=t.parentIdentifier,a=i.getEvent(n);if(a){var r=i.findEventIndex(n),o=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,r,o-1)}}}},{key:"setSchedulePosition",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;if(n&&!this.playbackDisabled){var a=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a?kL(a):a}) pos: ${this.timelinePos}`);var r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){var s=r.event,u=this.playingAsset,l=null==u?void 0:u.identifier,d=l?this.getAssetPlayer(l):null;if(d&&l&&(!this.eventItemsMatch(r,a)||void 0!==t&&l!==s.assetList[t].identifier)){var h,c=s.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${c+1}/${s.assetList.length} ${yL(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(LM.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:c,event:s,schedule:n.slice(0),scheduleIndex:e,player:d}),r!==this.playingItem)return void(this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),c));this.retreiveMediaSource(l,a),!d.media||null!=(h=this.detachedData)&&h.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(r,a)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${kL(r)}`),s.hasPlayed=!0,this.hls.trigger(LM.INTERSTITIAL_ENDED,{event:s,schedule:n.slice(0),scheduleIndex:e}),s.cue.once)){var m;this.updateSchedule();var f=null==(m=this.schedule)?void 0:m.items;if(a&&f){var v=this.findItemIndex(a);this.advanceSchedule(v,f,t,r,o)}return}}this.advanceSchedule(e,n,t,r,o)}}},{key:"advanceSchedule",value:function(e,t,i,n,a){var r=this.schedule;if(r){var o=t[e]||null,s=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(t=>{var i=t.interstitial,n=r.findEventIndex(i.identifier);(n<e||n>e+1)&&this.clearInterstitial(i,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);var l=o.event;if(void 0===i){var d=gL(l,(i=r.findAssetIndex(l,this.timelinePos))-1);if(l.isAssetPastPlayoutLimit(d)||l.appendInPlace&&this.timelinePos===o.end)return void this.advanceAfterAssetEnded(l,e,i);i=d}var h=this.waitingItem;this.assetsBuffered(o,s)||this.setBufferingItem(o);var c=this.preloadAssets(l,i);if(this.eventItemsMatch(o,h||n)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${kL(o)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(LM.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${l}`);if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!s)return void this.log(`Waiting for attachMedia to start Interstitial ${l}`);this.waitingItem=this.endedItem=null,this.playingItem=o;var m=l.assetList[i];if(!m)return void this.advanceAfterAssetEnded(l,e,i||0);if(c||(c=this.getAssetPlayer(m.identifier)),null===c||c.destroyed){var f=l.assetList.length;this.warn(`asset ${i+1}/${f} player destroyed ${l}`),(c=this.createAssetPlayer(l,m,i)).loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(c,i,t,e,s),this.shouldPlay&&EL(c.media)}else o?(this.resumePrimary(o,e,n),this.shouldPlay&&EL(this.hls.media)):a&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,i){var n,a;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${kL(e)}`),null==(n=this.detachedData)||!n.mediaSource){var r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(ML("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(i){var o=null==(a=this.schedule)?void 0:a.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${kL(e)}`),this.hls.trigger(LM.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var i=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:AA.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(ML("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var i,n=this.hls;!n.loadingEnabled||!n.media||Math.abs(((null==(i=n.mainForwardBufferInfo)?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}},{key:"onManifestLoading",value:function(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(LM.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(LM.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level&&this.schedule){var i=this.hls.levels[t.level];if(i.details){var n=GM(GM({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}}},{key:"onAudioTrackUpdated",value:function(e,t){var i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=GM(GM({},n),{},{audio:i});this.mediaSelection=a}else this.altSelection=GM(GM({},this.altSelection),{},{audio:i})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=GM(GM({},n),{},{subtitles:i});this.mediaSelection=a}else this.altSelection=GM(GM({},this.altSelection),{},{subtitles:i})}},{key:"onAudioTrackSwitching",value:function(e,t){var i=xP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i=xP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}},{key:"onBufferCodecs",value:function(e,t){var i=t.tracks;i&&(this.requiredTracks=i)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){var n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){if(this.schedule){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var i=0;i<t.length;i++){var n=t[i];if(n.cue.post){var a,r=this.schedule.findEventIndex(n.identifier),o=null==(a=this.schedule.items)?void 0:a[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;return e&&n&&n[this.findItemIndex(e,t)]||null}},{key:"trimInPlace",value:function(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});var i=e.end+.25,n=AA.bufferInfo(this.primaryMedia,i,0);if(n.end>i||(n.nextStart||0)>i){this.log(`trim buffered interstitial ${kL(e)} (was ${kL(t)})`);this.attachPrimary(i,null,!0),this.flushFrontBuffer(i)}}}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}},{key:"findItemIndex",value:function(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(e=!1){var t,i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}},{key:"checkBuffer",value:function(e){var t,i=null==(t=this.schedule)?void 0:t.items;if(i){var n=AA.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}}},{key:"updateBufferedPos",value:function(e,t,i){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e)&&n)if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var r=this.playingItem,o=this.findItemIndex(r),s=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var u,l=this.findItemIndex(a),d=Math.min(l+1,t.length-1),h=t[d];if((-1===s&&a&&e>=a.end||null!=(u=h.event)&&u.appendInPlace&&e+.01>=h.start)&&(s=d),this.isInterstitial(a)){var c=a.event;if(d-o>1&&!1===c.appendInPlace)return;if(0===c.assetList.length&&c.assetListLoader)return}if(this.bufferedPos=e,s>l&&s>o)this.bufferedToItem(h);else{var m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&h.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&r&&!this.itemsMatch(r,a)&&(s===o?this.bufferedToItem(r):s===o+1&&this.bufferedToItem(t[s]))}}},{key:"assetsBuffered",value:function(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{var i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){var n=i.items,a=i.events;if(!n||!a)return t;var r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));var s=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${kL(e)}`+(t?` (${s.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){var u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,t)=>{var i=this.getAssetPlayer(e.identifier);i&&(t===u&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(LM.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}},{key:"bufferedToItem",value:function(e,t=0){var i=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}},{key:"bufferedToEvent",value:function(e,t){var i=e.event,n=0===i.assetList.length&&!i.assetListLoader,a=i.cue.once;if(n||!a){var r=this.preloadAssets(i,t);if(null!=r&&r.interstitial.appendInPlace){var o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}},{key:"preloadAssets",value:function(e,t){var i=e.assetUrl,n=e.assetList.length,a=0===n&&!e.assetListLoader,r=e.cue.once;if(a){var o,s=e.timelineStart;if(e.appendInPlace){var u,l=this.playingItem;this.isInterstitial(l)||(null==l||null==(u=l.nextEvent)?void 0:u.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}var d=0;if(!this.playingItem&&this.primaryLive&&-1===(d=this.hls.startPosition)&&(d=this.hls.liveSyncPosition||0),d&&!e.cue.pre&&!e.cue.post){var h=d-s;h>0&&(o=Math.round(1e3*h)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${o?` live-start: ${d} start-offset: ${o}`:""}`),i)return this.createAsset(e,0,0,s,e.duration,i);var c=this.assetListLoader.loadAssetList(e,o);c&&(e.assetListLoader=c)}else if(!r&&n){for(var m=t;m<n;m++){var f=e.assetList[m],v=this.getAssetPlayerQueueIndex(f.identifier);-1!==v&&!this.playerQueue[v].destroyed||f.error||this.createAssetPlayer(e,f,m)}var p=e.assetList[t];if(p){var g=this.getAssetPlayer(p.identifier);return g&&g.loadSource(),g}}return null}},{key:"flushFrontBuffer",value:function(e){var t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(LM.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var i=0;i<e.length;i++)if(e[i].media===t)return e[i];return null}},{key:"createAsset",value:function(e,t,i,n,a,r){var o={parentIdentifier:e.identifier,identifier:mL(e,r,t),duration:a,startOffset:i,timelineStart:n,uri:r};return this.createAssetPlayer(e,o,t)}},{key:"createAssetPlayer",value:function(e,t,i){var n=this.hls,a=n.userConfig,r=a.videoPreference,o=n.loadLevelObj||n.levels[n.currentLevel];(r||o)&&(r=UM({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));var s=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var h=t.duration;h&&d<h&&(l=d)}}var c=t.identifier,m=GM(GM({},a),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:s||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));var f=m.cmcd;null!=f&&f.sessionId&&f.contentId&&(m.cmcd=UM({},f,{contentId:dL(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);var v=new bL(this.HlsPlayerClass,m,e,t);this.playerQueue.push(v),e.assetList[i]=t;var p=!0,g=n=>{if(n.live){var a,r=new Error(`Interstitials MUST be VOD assets ${e}`),o={fatal:!0,type:CM.OTHER_ERROR,details:IM.INTERSTITIAL_ASSET_ITEM_ERROR,error:r},s=(null==(a=this.schedule)?void 0:a.findEventIndex(e.identifier))||-1;this.handleAssetItemError(o,e,s,i,r.message)}else{var u=n.edge-n.fragmentStart,l=t.duration;(p||null===l||u>l)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${l} > ${u}`),t.duration=u,this.updateSchedule())}};v.on(LM.LEVEL_UPDATED,(e,{details:t})=>g(t)),v.on(LM.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),v.on(LM.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());var y=(e,t)=>{var i=this.getAssetPlayer(c);if(i&&t.tracks){i.off(LM.BUFFER_CODECS,y),i.tracks=t.tracks;var n=this.primaryMedia;this.bufferingAsset===i.assetItem&&n&&!i.media&&this.bufferAssetPlayer(i,n)}};v.on(LM.BUFFER_CODECS,y);v.on(LM.BUFFERED_TO_END,()=>{var i,n=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${n}`),n&&this.schedule){var a=this.schedule.findEventIndex(e.identifier),r=null==(i=this.schedule.items)?void 0:i[a];this.isInterstitial(r)&&this.advanceAssetBuffering(r,t)}});var b=t=>()=>{if(this.getAssetPlayer(c)&&this.schedule){this.shouldPlay=!0;var i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)}};return v.once(LM.MEDIA_ENDED,b(i)),v.once(LM.PLAYOUT_LIMIT_REACHED,b(1/0)),v.on(LM.ERROR,(t,n)=>{if(this.schedule){var a=this.getAssetPlayer(c);if(n.details===IM.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${n.error} ${e}`)}}),v.on(LM.DESTROYING,()=>{if(this.getAssetPlayer(c)&&this.schedule){var t=new Error(`Asset player destroyed unexpectedly ${c}`),n={fatal:!0,type:CM.OTHER_ERROR,details:IM.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,t.message)}}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${yL(t)}`),this.hls.trigger(LM.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:v}),v}},{key:"clearInterstitial",value:function(e,t){this.clearAssetPlayers(e,t),e.reset()}},{key:"clearAssetPlayers",value:function(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}},{key:"resetAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);var i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}},{key:"clearAssetPlayer",value:function(e,t){var i=this.getAssetPlayerQueueIndex(e);if(-1!==i){var n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t?kL(t):t}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,i,n,a){var r=e.interstitial,o=e.assetItem,s=e.assetId,u=r.assetList.length,l=this.playingAsset;this.endedAsset=null,this.playingAsset=o,l&&l.identifier===s||(l&&(this.clearAssetPlayer(l.identifier,i[n]),delete l.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${yL(o)}`),this.hls.trigger(LM.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var i,n;if(this.schedule){var a=e.interstitial,r=e.assetItem,o=this.schedule.findEventIndex(a.identifier),s=null==(i=this.schedule.items)?void 0:i[o];if(s){e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=r;var u=this.getBufferingPlayer();if(u!==e){var l=a.appendInPlace;if(!l||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(l&&r!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!eT(d,e.tracks)){var h=new Error(`Asset ${yL(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),c={fatal:!0,type:CM.OTHER_ERROR,details:IM.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=a.findAssetIndex(r);return void this.handleAssetItemError(c,a,o,m,h.message)}}this.transferMediaTo(e,t)}}}}}},{key:"handleInPlaceStall",value:function(e){var t=this.schedule,i=this.primaryMedia;if(t&&i){var n=i.currentTime,a=t.findAssetIndex(e,n),r=e.assetList[a];if(r){var o=this.getAssetPlayer(r.identifier);if(o){var s=o.currentTime||n-r.timelineStart,u=o.duration-s;if(this.warn(`Stalled at ${s} of ${s+u} in ${o} ${e} (media.currentTime: ${n})`),s&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){var l=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,l,a)}}}}}},{key:"advanceInPlace",value:function(e){var t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}},{key:"handleAssetItemError",value:function(e,t,i,n,a){if(e.details!==IM.BUFFER_STALLED_ERROR){var r=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r?yL(r):r} ${e.error}`),this.schedule){var o=(null==r?void 0:r.identifier)||"",s=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[s]||null,l=this.schedule.items,d=UM({},e,{fatal:!1,errorAction:aA(!0),asset:r,assetListIndex:n,event:t,schedule:l,scheduleIndex:i,player:u});if(this.hls.trigger(LM.INTERSTITIAL_ASSET_ERROR,d),e.fatal){var h=this.playingAsset,c=this.bufferingAsset,m=new Error(a);if(r&&(this.clearAssetPlayer(o,null),r.error=m),t.assetList.some(e=>!e.error))for(var f=n;f<t.assetList.length;f++)this.resetAssetPlayer(t.assetList[f].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,n):c&&c.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,i=this.effectivePlayingItem,n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${kL(i)} error: ${e.error}`),-1===n&&(n=this.hls.startPosition);var a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===n)return void this.checkStart();if(this.schedule){var r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}}},{key:"onAssetListLoaded",value:function(e,t){var i,n,a=t.event,r=a.identifier,o=t.assetListResponse.ASSETS;if(null!=(i=this.schedule)&&i.hasEvent(r)){var s=a.timelineStart,u=a.duration,l=0;o.forEach((e,t)=>{var i=parseFloat(e.DURATION);this.createAsset(a,t,l,s+l,i,e.URI),l+=i}),a.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${a}`);var d=this.waitingItem,h=(null==d?void 0:d.event.identifier)===r;this.updateSchedule();var c=null==(n=this.bufferingItem)?void 0:n.event;if(h){var m,f=this.schedule.findEventIndex(r),v=null==(m=this.schedule.items)?void 0:m[f];if(v){if(!this.playingItem&&this.timelinePos>v.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==f)return a.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(v)}this.setSchedulePosition(f)}else if((null==c?void 0:c.identifier)===r){var p=a.assetList[0];if(p){var g=this.getAssetPlayer(p.identifier);if(c.appendInPlace){var y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}}},{key:"onError",value:function(e,t){if(this.schedule)switch(t.details){case IM.ASSET_LIST_PARSING_ERROR:case IM.ASSET_LIST_LOAD_ERROR:case IM.ASSET_LIST_LOAD_TIMEOUT:var i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break;case IM.BUFFER_STALLED_ERROR:var n=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&n.event.appendInPlace)return void this.handleInPlaceStall(n.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}])}(),PL=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"subtitle-stream-controller",NM])).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return ue(e,rx),ne(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([]),this.mainDetails=null}},{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.on(LM.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(LM.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(LM.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(LM.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(LM.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){pe(e,"unregisterListeners",this)([]);var t=this.hls;t.off(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.off(LM.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(LM.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(LM.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(LM.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(LM.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=XD,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.mainDetails=null}},{key:"onMediaDetaching",value:function(t,i){this.tracksBuffered=[],pe(e,"onMediaDetaching",this)([t,i])}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var i=t.frag,n=t.success;if(this.fragContextChanged(i)||(yT(i)&&(this.fragPrevious=i),this.state=XD),n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var r,o=i.start,s=0;s<a.length;s++)if(o>=a[s].start&&o<=a[s].end){r=a[s];break}var u=i.start+i.duration;r?r.end=u:(r={start:o,end:u},a.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.startOffset,n=t.endOffset;if(0===i&&n!==Number.POSITIVE_INFINITY){var a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(e=>{for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}}),this.fragmentTracker.removeFragmentsInRange(i,a,NM)}}},{key:"onError",value:function(e,t){var i=t.frag;(null==i?void 0:i.type)===NM&&(t.details===IM.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==KD&&(this.state=XD))}},{key:"onSubtitleTracksUpdated",value:function(e,{subtitleTracks:t}){this.levels&&UC(this.levels,t)?this.levels=t.map(e=>new EP(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{var t=new EP(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,NM),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i;if(this.currentTrackId=t.id,null!=(i=this.levels)&&i.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==KD&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i,n=this.currentTrackId,a=this.levels,r=t.details,o=t.id;if(a){var s=a[o];if(!(o>=a.length)&&s){this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(r.live||null!=(i=s.details)&&i.live){if(r.deltaUpdateFailed)return;var l=this.mainDetails;if(!l)return void(this.startFragRequested=!1);var d,h=l.fragments[0];if(s.details)0===(u=this.alignPlaylists(r,s.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&h&&ID(r,u=h.start);else r.hasProgramDateTime&&l.hasProgramDateTime?(UD(r,l),u=r.fragmentStart):h&&ID(r,u=h.start);l&&!this.startFragRequested&&this.setStartPosition(l,u)}if(s.details=r,this.levelLastLoaded=s,o===n)if(this.hls.trigger(LM.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===XD)OP(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}else this.warn(`Subtitle tracks were reset while loading level ${o}`)}},{key:"_handleFragmentLoadComplete",value:function(e){var t=e.frag,i=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&zA(n.method)){var r=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,UA(n.method)).catch(e=>{throw a.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(e=>{var i=performance.now();a.trigger(LM.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:r,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=XD})}}},{key:"doTick",value:function(){if(this.media){if(this.state===XD){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;if(this.waitForLive(i))return;var n=this.config,a=this.getLoadPosition(),r=AA.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),o=r.end,s=r.len,u=i.details;if(s>this.hls.maxBufferLength+u.levelTargetDuration)return;var l=u.fragments,d=l.length,h=u.edge,c=null,m=this.fragPrevious;if(o<h){var f=n.maxFragLookUpTolerance,v=o>h-f?0:f;!(c=OP(m,l,Math.max(l[0].start,o),v))&&m&&m.start<l[0].start&&(c=l[0])}else c=l[d-1];if(!(c=this.filterReplacedPrimary(c,i.details)))return;var p=l[c.sn-u.startSN-1];if(p&&p.cc===c.cc&&this.fragmentTracker.getState(p)===rA&&(c=p),this.fragmentTracker.getState(c)===rA){var g=this.mapToInitFragWhenRequired(c);g&&this.loadFragment(g,i,o)}}}else this.state=XD}},{key:"loadFragment",value:function(t,i,n){yT(t)?pe(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i)}},{key:"mediaBufferTimeRanges",get:function(){return new AL(this.tracksBuffered[this.currentTrackId]||[])}}])}(),AL=ne(function e(t){Q(this,e),this.buffered=void 0;var i=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:e=>i("end",e,t.length),start:e=>i("start",e,t.length)}}),DL={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},xL=e=>String.fromCharCode(DL[e]||e),CL=15,IL=100,LL={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},_L={17:2,18:4,21:6,22:8,23:10,19:13,20:15},RL={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},FL={25:2,26:4,29:6,30:8,31:10,27:13,28:15},WL=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],OL=function(){return ne(function e(){Q(this,e),this.time=null,this.verboseLevel=0},[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;QM.log(`${this.time} [${e}] ${i}`)}}}])}(),$L=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t},NL=function(){return ne(function e(){Q(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}])}(),jL=function(){return ne(function e(){Q(this,e),this.uchar=" ",this.penState=new NL},[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}])}(),BL=function(){return ne(function e(t){Q(this,e),this.chars=[],this.pos=0,this.currPenState=new NL,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<IL;i++)this.chars.push(new jL);this.logger=t},[{key:"equals",value:function(e){for(var t=0;t<IL;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<IL;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<IL;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>IL&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=IL)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=xL(e);this.pos>=IL?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<IL;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,i=0;i<IL;i++){var n=this.chars[i].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}])}(),zL=function(){return ne(function e(t){Q(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<CL;i++)this.rows.push(new BL(t));this.logger=t},[{key:"reset",value:function(){for(var e=0;e<CL;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,i=0;i<CL;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<CL;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<CL;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,()=>"pacData = "+PP(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<CL;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,o=this.logger.time;if(null!==r&&null!==o&&r<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[n+s])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,d=Math.max(l-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,()=>"bkgData = "+PP(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){this.logger.log(1,()=>this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<CL;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}},{key:"getTextAndFormat",value:function(){return this.rows}}])}(),UL=function(){return ne(function e(t,i,n){Q(this,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=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new zL(n),this.nonDisplayedMemory=new zL(n),this.lastOutputScreen=new zL(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n},[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+PP(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}])}(),HL=function(){return ne(function e(t,i,n){Q(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new OL;this.channels=[null,new UL(t,i,a),new UL(t+1,n,a)]},[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var i=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],r=!1,o=null;if(0===n&&0===a)return 0;i.logger.log(3,()=>"["+$L([t[e],t[e+1]])+"] -> ("+$L([n,a])+")");var s=i.cmdHistory;if(n>=16&&n<=31){if(function(e,t,i){return i.a===e&&i.b===t}(n,a,s))return GL(null,null,s),i.logger.log(3,()=>"Repeated command ("+$L([n,a])+") is dropped"),0;GL(n,a,i.cmdHistory),(r=i.parseCmd(n,a))||(r=i.parseMidrow(n,a)),r||(r=i.parsePAC(n,a)),r||(r=i.parseBackgroundAttributes(n,a))}else GL(null,null,s);if(!r&&(o=i.parseChars(n,a))){var u=i.currentChannel;if(u&&u>0)i.channels[u].insertChars(o);else i.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||i.logger.log(2,()=>"Couldn't parse cleaned data "+$L([n,a])+" orig: "+$L([t[e],t[e+1]]))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=i,!0}},{key:"parseMidrow",value:function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+$L([e,t])+")"),!0)}return!1}},{key:"parsePAC",value:function(e,t){var i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;i=t>=64&&t<=95?1===n?LL[e]:RL[e]:1===n?_L[e]:FL[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=!(1&~i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}},{key:"parseChars",value:function(e,t){var i,n,a=null,r=null;(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19)?(n=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+xL(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,()=>"Char codes = "+$L(a).join(",")),a}},{key:"parseBackgroundAttributes",value:function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(i=Math.floor((t-32)/2),n.background=WL[i],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}GL(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}}}])}();function GL(e,t,i){i.a=e,i.b=t}var VL=function(){if(null!=XA&&XA.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var i=t.toLowerCase();return!!~e.indexOf(i)&&i}function n(e){return i(t,e)}function a(e,...t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var a in n)e[a]=n[a]}return e}function r(t,r,o){var s=this,u={enumerable:!0};s.hasBeenReset=!1;var l="",d=!1,h=t,c=r,m=o,f=null,v="",p=!0,g="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},u,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return v},set:function(t){var n=function(t){return i(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");v=n,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return w},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}(),KL=function(){return ne(function e(){Q(this,e)},[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}])}();function XL(e){function t(e,t,i,n){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(n||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var YL=function(){return ne(function e(){Q(this,e),this.values=Object.create(null)},[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}])}();function qL(e,t,i,n){var a=n?e.split(n):[e];for(var r in a)if("string"==typeof a[r]){var o=a[r].split(i);if(2===o.length)t(o[0],o[1])}}var JL=new VL(0,0,""),QL="middle"===JL.align?"middle":"center";function ZL(e,t,i){var n=e;function a(){var t=XL(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function r(){e=e.replace(/^\s+/,"")}if(r(),t.startTime=a(),r(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){var n=new YL;qL(e,function(e,t){var a;switch(e){case"region":for(var r=i.length-1;r>=0;r--)if(i[r].id===t){n.set(e,i[r].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",QL,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",QL,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",QL,"end","left","right"])}},/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===JL.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",QL);var r=n.get("position","auto");"auto"===r&&50===JL.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function e_(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var t_=function(){return ne(function e(){Q(this,e),this.state="INITIAL",this.buffer="",this.decoder=new KL,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0},[{key:"parse",value:function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=e_(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var n=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),n}function n(e){qL(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var r=(a=i()).match(/^()?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new VL(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{ZL(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}])}(),i_=/\r\n|\n\r|\n|\r/g,n_=function(e,t,i=0){return e.slice(i,i+t.length)===t};function a_(e,t,i){return dL(e.toString())+dL(t.toString())+dL(i)}function r_(e,t,i,n,a,r,o){var s,u=new t_,l=tT(new Uint8Array(e)).trim().replace(i_,"\n").split("\n"),d=[],h=t?function(e,t=1){return bC(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",m=0,f=0,v=!0;u.oncue=function(e){var r=i[n],o=i.ccOffset,u=(m-h)/9e4;if(null!=r&&r.new&&(void 0!==f?o=i.ccOffset=r.start:function(e,t,i){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=i}(i,n,u)),u){if(!t)return void(s=new Error("Missing initPTS for VTT MPEGTS"));o=u-i.presentationOffset}var l=e.endTime-e.startTime,c=PC(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+l,0);var v=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(v)),e.id||(e.id=a_(e.startTime,e.endTime,v)),e.endTime>0&&d.push(e)},u.onparsingerror=function(e){s=e},u.onflush=function(){s?o(s):r(d)},l.forEach(e=>{if(v){if(n_(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{n_(e,"LOCAL:")?c=e.slice(6):n_(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(AM(t)&&AM(i)&&AM(n)&&AM(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*n,t+36e5*a}(c)/1e3}catch(e){s=e}return}""===e&&(v=!1)}u.parse(e+"\n")}),u.flush()}var o_="stpp.ttml.im1t",s_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,u_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,l_={left:"start",center:"center",right:"end",start:"start",end:"end"};function d_(e,t,i,n){var a=CT(new Uint8Array(e),["mdat"]);if(0!==a.length){var r=a.map(e=>tT(e)),o=function(e,t,i=1,n=!1){return bC(e,t,1/i,n)}(t.baseTime,1,t.timescale);try{r.forEach(e=>i(function(e,t){var i=(new DOMParser).parseFromString(e,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce((e,t)=>(e[t]=n.getAttribute(`ttp:${t}`)||a[t],e),{}),o="preserve"!==n.getAttribute("xml:space"),s=c_(h_(n,"styling","style")),u=c_(h_(n,"layout","region")),l=h_(n,"body","[begin]");return[].map.call(l,e=>{var i=m_(e,o);if(!i||!e.hasAttribute("begin"))return null;var n=p_(e.getAttribute("begin"),r),a=p_(e.getAttribute("dur"),r),l=p_(e.getAttribute("end"),r);if(null===n)throw v_(e);if(null===l){if(null===a)throw v_(e);l=n+a}var d=new VL(n-t,l-t,i);d.id=a_(d.startTime,d.endTime,d.text);var h=function(e,t,i){var n="http://www.w3.org/ns/ttml#styling",a=null,r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(a=i[o]);return r.reduce((i,r)=>{var o=f_(t,n,r)||f_(e,n,r)||f_(a,n,r);return o&&(i[r]=o),i},{})}(u[e.getAttribute("region")],s[e.getAttribute("style")],s),c=h.textAlign;if(c){var m=l_[c];m&&(d.lineAlign=m),d.align=c}return UM(d,h),d}).filter(e=>null!==e)}(e,o)))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function h_(e,t,i){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function c_(e){return e.reduce((e,t)=>{var i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function m_(e,t){return[].slice.call(e.childNodes).reduce((e,i,n)=>{var a;return"br"===i.nodeName&&n?e+"\n":null!=(a=i.childNodes)&&a.length?m_(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function f_(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function v_(e){return new Error(`Could not parse ttml timestamp ${e}`)}function p_(e,t){if(!e)return null;var i=XL(e);return null===i&&(s_.test(e)?i=function(e,t){var i=s_.exec(e),n=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/t.frameRate}(e,t):u_.test(e)&&(i=function(e,t){var i=u_.exec(e),n=Number(i[1]);switch(i[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),i}var g_=function(){return ne(function e(t,i){Q(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=i},[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}])}(),y_=function(){return ne(function e(t){Q(this,e),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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},t.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),t.on(LM.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(LM.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(LM.FRAG_LOADING,this.onFragLoading,this),t.on(LM.FRAG_LOADED,this.onFragLoaded,this),t.on(LM.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(LM.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(LM.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(LM.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(LM.BUFFER_FLUSHING,this.onBufferFlushing,this)},[{key:"destroy",value:function(){var e=this.hls;e.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(LM.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(LM.FRAG_LOADING,this.onFragLoading,this),e.off(LM.FRAG_LOADED,this.onFragLoaded,this),e.off(LM.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(LM.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(LM.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(LM.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new g_(this,"textTrack1"),t=new g_(this,"textTrack2"),i=new g_(this,"textTrack3"),n=new g_(this,"textTrack4");this.cea608Parser1=new HL(1,e,t),this.cea608Parser2=new HL(3,i,n)}},{key:"addCues",value:function(e,t,i,n,a){for(var r=!1,o=a.length;o--;){var s=a[o],u=k_(s[0],s[1],t,i);if(u>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),r=!0,u/(i-t)>.5))return}if(r||a.push([t,i]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,t,i,n)}else{var d=this.Cues.newCue(null,t,i,n);this.hls.trigger(LM.CUES_PARSED,{type:"captions",cues:d,track:e})}}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){var o=this.unparsedVttFrags;i===OM&&(this.initPTS[t.cc]={baseTime:n,timescale:a,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(LM.FRAG_LOADED,e):this.hls.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}},{key:"getExistingTrack",value:function(e,t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var a=i.textTracks[n];if(w_(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,o=a.languageCode,s=this.getExistingTrack(r,o);if(s)i[e]=s,oL(i[e]),aL(i[e],n);else{var u=this.createTextTrack("captions",r,o);u&&(u[e]=!0,i[e]=u)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(LM.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}}},{key:"createTextTrack",value:function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;Object.keys(n).forEach(e=>{oL(n[e]),delete n[e]}),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)oL(t[i])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var i=t.subtitleTracks||[],n=i.some(e=>e.textCodec===o_);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(UC(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a=this.media,r=a?uL(a.textTracks):null;if(this.tracks.forEach((e,t)=>{var i;if(r){for(var n=null,a=0;a<r.length;a++)if(r[a]&&w_(r[a],e)){n=r[a],r[a]=null;break}n&&(i=n)}if(i)oL(i);else{var o=b_(e);(i=this.createTextTrack(o,e.name,e.lang))&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=r&&r.length){var o=r.filter(e=>null!==e).map(e=>e.label);o.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${o.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){var s=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(LM.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}}}},{key:"onManifestLoaded",value:function(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i=`textTrack${t[1]}`,n=this.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}})}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===OM){var i,n,a=this.cea608Parser1,r=this.cea608Parser2,o=this.lastSn,s=t.frag,u=s.cc,l=s.sn,d=null!=(i=null==(n=t.part)?void 0:n.index)?i:-1;a&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}},{key:"onFragLoaded",value:function(e,t){var i=t.frag,n=t.payload;if(i.type===NM)if(n.byteLength){var a=i.decryptdata,r="stats"in t;if(null==a||!a.encrypted||r){var o=this.tracks[i.level],s=this.vttCCs;s[i.cc]||(s[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===o_?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var i=this.hls;d_(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}},{key:"_parseVTTs",value:function(e){var t,i=e.frag,n=e.payload,a=this.initPTS,r=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var s=this.hls;r_(null!=(t=i.initSegment)&&t.data?jT(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,e=>{this._appendCues(e,i.level),s.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},t=>{var a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(i,n),s.logger.log(`Failed to parse VTT cue: ${t}`),a&&o>i.cc||s.trigger(LM.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})})}else r.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var i=this.tracks[e.level];i.textCodec||d_(t,this.initPTS[e.cc],()=>{i.textCodec=o_,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}},{key:"_appendCues",value:function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach(e=>rL(n,e))}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(LM.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===NM&&this.onFragLoaded(LM.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,n=t.samples;if(i.type!==OM||"NONE"!==this.closedCaptionsForLevel(i))for(var a=0;a<n.length;a++){var r=n[a].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();var o=this.extractCea608Data(r);this.cea608Parser1.addData(n[a].pts,o[0]),this.cea608Parser2.addData(n[a].pts,o[1])}}}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){var r=this.media;if(r&&!(r.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach(e=>sL(o[e],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==n){var s=this.textTracks;Object.keys(s).forEach(e=>sL(s[e],t,n))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],o=127&e[n++],s=127&e[n++];if(0!==o||0!==s)if(!!(4&r)){var u=3&r;0!==u&&1!==u||(t[u].push(o),t[u].push(s))}}return t}}])}();function b_(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function w_(e,t){return!!e&&e.kind===b_(t)&&GC(t,e)}function k_(e,t,i,n){return Math.min(t,n)-Math.max(e,i)}var S_=/\s/,E_={newCue(e,t,i,n){for(var a,r,o,s,u,l=[],d=self.VTTCue||self.TextTrackCue,h=0;h<n.rows.length;h++)if(o=!0,s=0,u="",!(a=n.rows[h]).isEmpty()){for(var c,m=0;m<a.chars.length;m++)S_.test(a.chars[m].uchar)&&o?s++:(u+=a.chars[m].uchar,o=!1);a.cueStartTime=t,t===i&&(i+=1e-4),s>=16?s--:s++;var f=e_(u.trim()),v=a_(t,i,f);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((r=new d(t,i,f)).id=v,r.line=h+1,r.align="left",r.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(r))}return e&&l.length&&(l.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),l.forEach(t=>rL(e,t))),l}};var M_=/(\d+)-(\d+)\/(\d+)/,T_=function(){return ne(function e(t){Q(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||P_,this.controller=new self.AbortController,this.stats=new mT},[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,i){var n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(UM({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),r="arraybuffer"===e.responseType,o=r?"byteLength":"length",s=t.loadPolicy,u=s.maxTimeToFirstByteMs,l=s.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=u&&AM(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(WC(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var a;this.response=this.loader=i;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},l-(o-n.loading.start)),!i.ok){var s=i.status,u=i.statusText;throw new A_(u||"fetch, bad network response",s,i)}n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var i=function(e){var t=M_.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(AM(i))return i}var n=e.get("Content-Length");if(n)return parseInt(n)}(i.headers)||n.total;var d=null==(a=this.callbacks)?void 0:a.onProgress;return d&&AM(t.highWaterMark)?this.loadProgressively(i,n,e,t.highWaterMark,d):r?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var a,r,s=this.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=i[o];u&&(n.loaded=n.total=u);var l={url:s.url,data:i,code:s.status},d=null==(a=this.callbacks)?void 0:a.onProgress;d&&!AM(t.highWaterMark)&&d(n,e,i,s),null==(r=this.callbacks)||r.onSuccess(l,n,e,s)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),!n.aborted){var a=t&&t.code||0,r=t?t.message:null;null==(i=this.callbacks)||i.onError({code:a,text:r},e,t?t.details:null,n)}})}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,i,n=0,a){var r=new sx,o=e.body.getReader(),s=()=>o.read().then(o=>{if(o.done)return r.dataLength&&a(t,i,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l<n||r.dataLength?(r.push(u),r.dataLength>=n&&a(t,i,r.flush().buffer,e)):a(t,i,u.buffer,e),s()}).catch(()=>Promise.reject());return s()}}])}();function P_(e,t){return new self.Request(e.url,t)}var A_=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t])).code=void 0,a.details=void 0,a.code=i,a.details=n,a}return ue(e,ye(Error)),ne(e)}(),D_=/^age:\s*[\d.]+\s*$/im,x_=function(){return ne(function e(t){Q(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new mT,this.retryDelay=0},[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,i){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=t,this.callbacks=i,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.config,t=this.context;if(e&&t){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===i&&!this.stats.aborted)return a(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),a(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:i.status,text:e.message},t,i,n)}):this.openAndSendXhr(i,t,e)}}},{key:"openAndSendXhr",value:function(e,t,i){e.readyState||e.open("GET",t.url,!0);var n=t.headers,a=i.loadPolicy,r=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(n)for(var s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&AM(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){var s=null!=o?o:t.response;if(null!=s){var u,l;i.loading.end=Math.max(self.performance.now(),i.loading.first);var d="arraybuffer"===t.responseType?s.byteLength:s.length;i.loaded=i.total=d,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);var h=null==(u=this.callbacks)?void 0:u.onProgress;h&&h(i,e,s,t);var c={url:t.responseURL,data:s,code:r};return void(null==(l=this.callbacks)||l.onSuccess(c,i,e,t))}}var m,f=a.loadPolicy.errorRetry;if(KP(f,i.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(f);else QM.error(`${r} while loading ${e.url}`),null==(m=this.callbacks)||m.onError({code:r,text:t.statusText},e,t,i)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(KP(e,this.stats.retry,!0))this.retry(e);else{var t;QM.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,i=this.stats;this.retryDelay=GP(e,i.retry),i.retry++,QM.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&D_.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}])}(),C_=GM(GM({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:x_,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:FP,bufferController:JC,capLevelController:eI,errorController:nA,fpsController:nL,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:aD,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:E_,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:PL,subtitleTrackController:lL,timelineController:y_,audioStreamController:BC,audioTrackController:VC,emeController:QI,cmcdController:XI,contentSteeringController:YI,interstitialsController:TL});function I_(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(I_):Object.keys(e).reduce((t,i)=>(t[i]=I_(e[i]),t),{}):e}function L_(e,t){var i=e.loader;i!==T_&&i!==x_?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=T_,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var __=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["gap-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.media=null,n.mediaSource=void 0,n.nudgeRetry=0,n.stallReported=!1,n.stalled=null,n.moved=!1,n.seeking=!1,n.buffered={},n.lastCurrentTime=0,n.ended=0,n.waiting=0,n.onMediaPlaying=()=>{n.ended=0,n.waiting=0},n.onMediaWaiting=()=>{var e;null!=(e=n.media)&&e.seeking||(n.waiting=self.performance.now(),n.tick())},n.onMediaEnded=()=>{var e;n.hls&&(n.ended=(null==(e=n.media)?void 0:e.currentTime)||1,n.hls.trigger(LM.MEDIA_ENDED,{stalled:!1}))},n.hls=t,n.fragmentTracker=i,n.registerListeners(),n}return ue(e,MA),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){pe(e,"destroy",this)([]),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var i=this.media=t.media;HD(i,"playing",this.onMediaPlaying),HD(i,"waiting",this.onMediaWaiting),HD(i,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var i=this.media;i&&(GD(i,"playing",this.onMediaPlaying),GD(i,"waiting",this.onMediaWaiting),GD(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var i,n,a=null==(i=this.hls)?void 0:i.config;if(a){var r=this.media;if(r){var o=r.seeking,s=this.seeking&&!o,u=!this.seeking&&o,l=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!l&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||s)s&&this.stallResolved(e);else{if(l)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(LM.MEDIA_ENDED,{stalled:!1})));if(AA.getBuffered(r).length){var d=AA.bufferInfo(r,e,0),h=d.nextStart||0,c=this.fragmentTracker;if(o&&c&&this.hls){var m=R_(this.hls.inFlightFragments,e),f=d.len>2,v=!h||m||h-e>2&&!c.getPartialFragment(e);if(f||v)return;this.moved=!1}var p=null==(n=this.hls)?void 0:n.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(d.len>0)&&!h)return;var g=Math.max(h,d.start||0)-e,y=!(null==p||!p.live)?2*p.targetduration:2,b=W_(e,c);if(g>0&&(g<=y||b))return void(r.paused||this._trySkipBufferHole(b))}var w=a.detectStallWithCurrentTimeMs,k=self.performance.now(),S=this.waiting,E=this.stalled;if(null===E){if(!(S>0&&k-S<w))return void(this.stalled=k);E=this.stalled=S}var M=k-E;if(!o&&(M>=w||S)&&this.hls){var T;if("ended"===(null==(T=this.mediaSource)?void 0:T.readyState)&&(null==p||!p.live)&&Math.abs(e-((null==p?void 0:p.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(LM.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var P=AA.bufferInfo(r,e,a.maxBufferHole);this._tryFixBufferStall(P,M,e)}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(LM.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var i,n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&n&&n.length>1&&e>n.end(0)){var a=AA.bufferedInfo(AA.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var r=AA.timeRangesToArray(n),o=AA.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){var s=AA.bufferedInfo(r,e,0).bufferedIndex,u=r[o].end,l=r[o+1].start;if((-1===s||s>o)&&l-u<1&&e-u<2){var d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${l} buffered index: ${s}`);this.warn(d.message),this.media.currentTime+=1e-6;var h=W_(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var c=AA.bufferInfo(this.media,e,0);this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:c.len,bufferInfo:c})}}}}}},{key:"_tryFixBufferStall",value:function(e,t,i){var n,a,r=this.fragmentTracker,o=this.media,s=null==(n=this.hls)?void 0:n.config;if(o&&r&&s){var u=null==(a=this.hls)?void 0:a.latestLevelDetails,l=W_(i,r);if(l||null!=u&&u.live&&i<u.fragmentStart)if(this._trySkipBufferHole(l)||!this.media)return;var d=e.buffered,h=this.adjacentTraversal(e,i);(d&&d.length>1&&e.len>s.maxBufferHole||e.nextStart&&(e.nextStart-i<s.maxBufferHole||h))&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"adjacentTraversal",value:function(e,t){var i=this.fragmentTracker,n=e.nextStart;if(i&&n){var a=i.getFragAtPos(t,OM),r=i.getFragAtPos(n,OM);if(a&&r)return r.sn-a.sn<2}return!1}},{key:"_reportStall",value:function(e){var t=this.hls,i=this.media,n=this.stallReported,a=this.stalled;if(!n&&null!==a&&i&&t){this.stallReported=!0;var r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${PP(e)})`);this.warn(r.message),t.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,i=this.fragmentTracker,n=this.media,a=null==(t=this.hls)?void 0:t.config;if(!n||!i||!a)return 0;var r=n.currentTime,o=AA.bufferInfo(n,r,0),s=r<o.start?o.start:o.nextStart;if(s&&this.hls){var u=o.len<=a.maxBufferHole,l=o.len>0&&o.len<1&&n.readyState<3,d=s-r;if(d>0&&(u||l)){if(d>a.maxBufferHole){var h=!1;if(0===r){var c=i.getAppendedFrag(0,OM);c&&s<c.end&&(h=!0)}if(!h&&e){var m;if(null==(m=this.hls.loadLevelObj)||!m.details)return 0;if(R_(this.hls.inFlightFragments,s))return 0;for(var f=!1,v=e.end;v<s;){var p=W_(v,i);if(!p){f=!0;break}v+=p.duration}if(f)return 0}}var g=Math.max(s+.05,r+.1);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${g}`),this.moved=!0,n.currentTime=g,null==e||!e.gap){var y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${g}`),b={type:CM.MEDIA_ERROR,details:IM.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(LM.ERROR,b)}return g}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,i=this.media,n=this.nudgeRetry,a=null==t?void 0:t.config;if(!i||!a)return 0;var r=i.currentTime;if(this.nudgeRetry++,n<a.nudgeMaxRetry){var o=r+(n+1)*a.nudgeOffset,s=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(s.message),i.currentTime=o,t.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1,buffer:e.len,bufferInfo:e})}else{var u=new Error(`Playhead still not moving while enough data buffered @${r} after ${a.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}])}();function R_(e,t){var i=F_(e.main);if(i&&i.start<=t)return i;var n=F_(e.audio);return n&&n.start<=t?n:null}function F_(e){if(!e)return null;switch(e.state){case XD:case KD:case tx:case ix:return null}return e.frag}function W_(e,t){return t.getAppendedFrag(e,OM)||t.getPartialFragment(e)}function O_(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function $_(e,t,i,n,a){var r=new e(t,i,"");try{r.value=n,a&&(r.type=a)}catch(o){r=new e(t,i,PP(a?GM({type:a},n):n))}return r}var N_=(()=>{var e=O_();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),j_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(LM.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()},[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(LM.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(LM.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(LM.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"onMediaAttaching",value:function(e,t){var i;this.media=t.media,!1===(null==(i=t.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&oL(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return aL(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media&&this.hls){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=O_();if(o)for(var s=0;s<r.length;s++){var u=r[s].type;if((u!==Fx.emsg||n)&&a){var l=Ix(r[s].data),d=r[s].pts,h=d+r[s].duration;h>N_&&(h=N_),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var m=l[c];if(!Lx(m)){this.updateId3CueEnds(d,u);var f=$_(o,d,h,m,u);f&&this.id3Track.addCue(f)}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var i,n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(var a=n.length;a--;){var r=n[a];r.type===t&&r.startTime<e&&r.endTime===N_&&(r.endTime=e)}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,type:n}){var a=this.id3Track,r=this.hls;if(r){var o=r.config,s=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(s||u))sL(a,t,i,"audio"===n?e=>e.type===Fx.audioId3&&u:"video"===n?e=>e.type===Fx.emsg&&s:e=>e.type===Fx.audioId3&&u||e.type===Fx.emsg&&s)}}},{key:"onLevelUpdated",value:function(e,{details:t}){this.updateDateRangeCues(t,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var i=this;if(this.hls&&this.media){var n=this.hls.config,a=n.assetPlayerId,r=n.timelineOffset,o=n.enableDateRangeMetadataCues,s=n.interstitialsController;if(o){var u=O_();if(a&&r&&!s){var l=e.fragmentStart,d=e.fragmentEnd,h=this.assetCue;h?(h.startTime=l,h.endTime=d):u&&(h=this.assetCue=$_(u,l,d,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(h.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(h),h.addEventListener("enter",this.onEventCueEnter))}if(e.hasProgramDateTime){var c,m=this.id3Track,f=e.dateRanges,v=Object.keys(f),p=this.dateRangeCuesAppended;if(m&&t)if(null!=(c=m.cues)&&c.length)for(var g,y=Object.keys(p).filter(e=>!v.includes(e)),b=function(){var e=y[w],t=null==(g=p[e])?void 0:g.cues;delete p[e],t&&Object.keys(t).forEach(e=>{var n=t[e];if(n){n.removeEventListener("enter",i.onEventCueEnter);try{m.removeCue(n)}catch(e){}}})},w=y.length;w--;)b();else p=this.dateRangeCuesAppended={};var k=e.fragments[e.fragments.length-1];if(0!==v.length&&AM(null==k?void 0:k.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var S=function(){var e=v[E],t=f[e],n=t.startTime,a=p[e],r=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,l=N_,d=t.duration;if(t.endDate&&null!==d)l=n+d,o=!0;else if(t.endOnNext&&!o){var h=v.reduce((e,i)=>{if(i!==t.id){var n=f[i];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e},null);h&&(l=h.startTime,o=!0)}for(var c=Object.keys(t.attr),m=0;m<c.length;m++){var g=c[m];if(WA(g)){var y=r[g];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-n)>.01&&(y.startTime=n,y.endTime=l):y.endTime=l;else if(u){var b=t.attr[g];OA(g)&&(b=nT(b));var w=$_(u,n,l,{key:g,data:b},Fx.dateRange);w&&(w.id=e,i.id3Track.addCue(w),r[g]=w,s&&("X-ASSET-LIST"!==g&&"X-ASSET-URL"!==g||w.addEventListener("enter",i.onEventCueEnter)))}}}p[e]={cues:r,dateRange:t,durationKnown:o}},E=0;E<v.length;E++)S()}}}}}}])}(),B_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var i=this.computeLatency();if(null!==i){this._latency=i;var n=this.config,a=n.lowLatencyMode,r=n.maxLiveSyncPlaybackRate;if(a&&1!==r&&t.live){var o=this.targetLatency;if(null!==o){var s=i-o;if(s<Math.min(this.maxLatency,o+t.targetduration)&&s>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,r)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,l));this.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()},[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,i=e.partHoldBack,n=e.targetduration,a=this.config,r=a.liveSyncDuration,o=a.liveSyncDurationCount,s=a.lowLatencyMode,u=this.hls.userConfig,l=s&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:o*n);var d=n;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var i=this.levelDetails;if(null===i)return null;var n=i.edge,a=e-t-this.edgeStalled,r=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,a),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(LM.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(LM.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(LM.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(LM.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var i;t.details===IM.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var i,n;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(n=this.targetLatency)?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}])}(),z_=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[t,"level-controller"]))._levels=[],n._firstLevel=-1,n._maxAutoLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=i,n._registerListeners(),n}return ue(e,zC),ne(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(LM.LEVEL_LOADED,this.onLevelLoaded,this),e.on(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.on(LM.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(LM.LEVEL_LOADED,this.onLevelLoaded,this),e.off(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(LM.FRAG_BUFFERED,this.onFragBuffered,this),e.off(LM.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),pe(e,"destroy",this)([])}},{key:"stopLoad",value:function(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),pe(e,"stopLoad",this)([])}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var i=this.hls.config.preferManagedMediaSource,n=[],a={},r={},o=!1,s=!1,u=!1;t.levels.forEach(e=>{var t=e.attrs,l=e.audioCodec,d=e.videoCodec;l&&(e.audioCodec=l=aP(l,i)||void 0),d&&(d=e.videoCodec=function(e){for(var t=e.split(","),i=0;i<t.length;i++){var n=t[i].split(".");n.length>2&&"avc1"===n[0]&&(t[i]=`avc1.${parseInt(n[1]).toString(16)}${("000"+parseInt(n[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));var h=e.width,c=e.height,m=e.unknownCodecs,f=(null==m?void 0:m.length)||0;if(o||(o=!(!h||!c)),s||(s=!!d),u||(u=!!l),f||l&&!this.isAudioSupported(l)||d&&!this.isVideoSupported(d))this.log(`Some or all CODECS not supported "${t.CODECS}"`);else{var v=t.CODECS,p=t["FRAME-RATE"],g=t["HDCP-LEVEL"],y=t["PATHWAY-ID"],b=t.RESOLUTION,w=t["VIDEO-RANGE"],k=`${`${y||"."}-`}${e.bitrate}-${b}-${p}-${v}-${w}-${g}`;if(a[k])if(a[k].uri===e.url||e.attrs["PATHWAY-ID"])a[k].addGroupId("audio",t.AUDIO),a[k].addGroupId("text",t.SUBTITLES);else{var S=r[k]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var E=this.createLevel(e);a[k]=E,n.push(E)}else{var M=this.createLevel(e);a[k]=M,r[k]=1,n.push(M)}}}),this.filterAndSortMediaOptions(n,t,o,s,u)}},{key:"createLevel",value:function(e){var t=new EP(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=cP(n,[])}return t}},{key:"isAudioSupported",value:function(e){return JT(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return JT(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,i,n,a){var r,o=[],s=[],u=e,l=(null==(r=t.stats)?void 0:r.parsing)||{};if((i||n)&&a&&(u=u.filter(({videoCodec:e,videoRange:t,width:i,height:n})=>{return(!!e||!(!i||!n))&&(!!(a=t)&&gP.indexOf(a)>-1);var a})),0===u.length)return Promise.resolve().then(()=>{if(this.hls){var e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${PP(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);var n=new Error(e);this.hls.trigger(LM.ERROR,{type:CM.MEDIA_ERROR,details:IM.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:n,reason:i})}}),void(l.end=performance.now());t.audioTracks&&U_(o=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&U_(s=t.subtitles);var d=u.slice(0);u.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return gP.indexOf(e.videoRange)-gP.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var n=eP(e.videoCodec),a=eP(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var r=tP(e.codecSet),o=tP(t.codecSet);if(r!==o)return o-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var m=0;m<u.length;m++)if(u[m]===h){var f;this._firstLevel=m;var v=h.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${v}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);g>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var y=a&&!n,b=this.hls.config,w=!(!b.audioStreamController||!b.audioTrackController),k={levels:u,audioTracks:o,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:w&&!y&&o.some(e=>!!e.url)};l.end=performance.now(),this.hls.trigger(LM.MANIFEST_PARSED,k)}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,r=this.currentLevel,o=r?r.attrs["PATHWAY-ID"]:void 0,s=t[e],u=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,a!==e||!r||o!==u){this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${u?" with Pathway "+u:""} from level ${a}${o?" with Pathway "+o:""}`);var l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(LM.LEVEL_SWITCHING,l);var d=s.details;if(!d||d.live){var h=this.switchParams(s.uri,null==r?void 0:r.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===RM&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,{frag:t}){if(void 0!==t&&t.type===OM){var i=t.elementaryStreams;if(!Object.keys(i).some(e=>!!i[e]))return;var n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var i,n,a=t.level,r=t.details,o=t.levelInfo;if(!o)return this.warn(`Invalid level index ${a}`),void(null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0));if(o===this.currentLevel||t.withoutMultiVariant){0===o.fragmentError&&(o.loadError=0);var s=o.details;s===t.details&&s.advanced&&(s=void 0),this.playlistLoaded(a,t,s)}else null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=this.getUrlWithDirectives(t.uri,i),a=this.currentLevelIndex,r=t.attrs["PATHWAY-ID"],o=t.details,s=null==o?void 0:o.age;this.log(`Loading level index ${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${r?" Pathway "+r:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${n}`),this.hls.trigger(LM.LEVEL_LOADING,{url:n,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t;if(1!==this._levels.length){var i=this._levels.filter((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));WD(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(LM.LEVELS_UPDATED,{levels:i})}}},{key:"onLevelsUpdated",value:function(e,{levels:t}){this._levels=t}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(LM.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}])}();function U_(e){var t={};e.forEach(e=>{var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function H_(){return self.SourceBuffer||self.WebKitSourceBuffer}function G_(){if(!ZM())return!1;var e=H_();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var V_=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"stream-controller",OM])).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=()=>{a.tick()},a.onMediaSeeked=()=>{var e=a.media,t=e?e.currentTime:null;if(null!==t&&AM(t)&&(a.log(`Media seeked to ${t.toFixed(3)}`),a.getBufferedFrag(t))){var i=a.getFwdBufferInfoAtPos(e,t,OM,0);null!==i&&0!==i.len?a.tick():a.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`)}},a.registerListeners(),a}return ue(e,rx),ne(e,[{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(LM.MANIFEST_PARSED,this.onManifestParsed,this),t.on(LM.LEVEL_LOADING,this.onLevelLoading,this),t.on(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.on(LM.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(LM.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(LM.BUFFER_CREATED,this.onBufferCreated,this),t.on(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(LM.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){pe(e,"unregisterListeners",this)([]);var t=this.hls;t.off(LM.MANIFEST_PARSED,this.onManifestParsed,this),t.off(LM.LEVEL_LOADED,this.onLevelLoaded,this),t.off(LM.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(LM.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(LM.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(LM.BUFFER_CREATED,this.onBufferCreated,this),t.off(LM.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(LM.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(LM.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([])}},{key:"startLoad",value:function(e,t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=XD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=KD}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,pe(e,"stopLoad",this)([])}},{key:"doTick",value:function(){switch(this.state){case ax:var e=this.levels,t=this.level,i=null==e?void 0:e[t],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=XD;break}if(this.hls.nextLoadLevel!==this.level){this.state=XD;break}break;case JD:this.checkRetryDate()}this.state===XD&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var t;pe(e,"onTickEnd",this)([]),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,n=this.media;if(null!==t&&(n||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=i&&i[a]){var r=i[a],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(LM.BUFFER_EOS,u),void(this.state=tx)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;var l=r.details;if(!l||this.state===ax||this.waitForLive(r))return this.level=a,this.state=ax,void(this.startFragRequested=!1);var d=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&m&&yT(m)&&this.fragmentTracker.getState(m)!==uA){var f,v=(null!=(f=this.backtrackFragment)?f:m).sn-l.startSN,p=l.fragments[v-1];p&&m.cc===p.cc&&(m=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,c)){if(!m.gap){var g=this.audioOnly&&!this.altAudio?fT:vT,y=(g===vT?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,OM)}m=this.getNextFragmentLoopLoading(m,l,o,OM,h)}m&&(this.exceedsMaxBuffer(o,h,m)||(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,r,c)))}}}}}}},{key:"loadFragment",value:function(t,i,n){var a=this.fragmentTracker.getState(t);a===rA||a===sA?yT(t)?this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,i)):pe(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i):this.clearTrackerIfNeeded(t)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,OM)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){var t;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),0!==this.altAudio)&&(((null==(t=this.getLevelDetails())?void 0:t.fragmentStart)||0)>this.lastCurrentTime&&pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]))}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var r=this.getMainFwdBufferInfo();if(!r||r.len<2*a.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else i=0;var u=this.getBufferedFrag(t.currentTime+i);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case YD:case qD:case JD:case ZD:case ex:this.state=XD}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(t,i){pe(e,"flushMainBuffer",this)([t,i,2===this.altAudio?"video":null])}},{key:"onMediaAttached",value:function(t,i){pe(e,"onMediaAttached",this)([t,i]);var n=i.media;HD(n,"playing",this.onMediaPlaying),HD(n,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(t,i){var n=this.media;n&&(GD(n,"playing",this.onMediaPlaying),GD(n,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,pe(e,"onMediaDetaching",this)([t,i]),!!i.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.log("Trigger BUFFER_RESET"),this.hls.trigger(LM.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){for(var i,n,a=!1,r=!1,o=0;o<t.levels.length;o++){var s=t.levels[o].audioCodec;s&&(a=a||-1!==s.indexOf("mp4a.40.2"),r=r||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&r&&!("function"==typeof(null==(n=H_())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===XD){var i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=ax)}}},{key:"onLevelLoaded",value:function(e,t){var i,n=this.levels,a=this.startFragRequested,r=t.level,o=t.details,s=o.totalduration;if(n){this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);var u=t.levelInfo,l=this.fragCurrent;!l||this.state!==qD&&this.state!==JD||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(o.live||null!=(i=u.details)&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(u.details=o,this.levelLastLoaded=u,a||this.setStartPosition(o,d),this.hls.trigger(LM.LEVEL_UPDATED,{details:o,level:r}),this.state===ax){if(this.waitForCdnTuneIn(o))return;this.state=XD}a&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}else this.warn(`Levels were reset while loading level ${r}`)}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,a=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==n&&i.duration>n&&(a<n||!s)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!s&&i.readyState<4||a<o-u)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${n.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l,d=AA.bufferInfo(i,n,0);if(null==(l=d.buffered)||!l.length)return void(i.currentTime=n);if(d.start<=a)return void(i.currentTime=n);var h=AA.bufferedInfo(d.buffered,a,0).nextStart;h&&(i.currentTime=h)}else i.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.levels;if(r){var o=r[i.level];if(o){var s=o.details;if(!s)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);var u=o.videoCodec,l=s.PTSKnown||!s.live,d=null==(t=i.initSegment)?void 0:t.data,h=this._getAudioCodec(o),c=this.transmuxer=this.transmuxer||new jC(this.hls,OM,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=n?n.index:-1,f=-1!==m,v=new TA(i.level,i.sn,i.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[i.cc];c.push(a,d,h,u,i,n,s.totalduration,l,v,p)}else this.warn(`Level ${i.level} not found on progress`)}else this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"onAudioTrackSwitching",value:function(e,t){var i=this.hls,n=0!==this.altAudio;if(RP(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(LM.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(LM.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(LM.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(LM.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var i=RP(t.url,this.hls);if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var i,n,a=t.tracks,r=!1;for(var o in a){var s=a[o];if("main"===s.id){if(n=o,i=s,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else r=!0}r&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=i.type===OM;if(a){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===ex&&(this.state=XD));var r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),yT(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}var o=this.media;o&&(!this._hasEnoughToStart&&AA.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var i;if(t.fatal)this.state=ix;else switch(t.details){case IM.FRAG_GAP:case IM.FRAG_PARSING_ERROR:case IM.FRAG_DECRYPT_ERROR:case IM.FRAG_LOAD_ERROR:case IM.FRAG_LOAD_TIMEOUT:case IM.KEY_LOAD_ERROR:case IM.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(OM,t);break;case IM.LEVEL_LOAD_ERROR:case IM.LEVEL_LOAD_TIMEOUT:case IM.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==ax||(null==(i=t.context)?void 0:i.type)!==RM||(this.state=XD);break;case IM.BUFFER_ADD_CODEC_ERROR:case IM.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case IM.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t))!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case IM.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=XD,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==fT||!this.altAudio){var i=(t===vT?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,OM),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);var n=this.timelineOffset;n&&i&&(i+=n);var a=this.getLevelDetails(),r=AA.getBuffered(e),o=r.length?r.start(0):0,s=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||s>0&&(s<u||this.loadingParts&&s<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${s} to match buffer start`),i+=s,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{var i=this.hls,n=null==e?void 0:e.frag;if(n&&!this.fragContextChanged(n)){t.fragmentError=0,this.state=XD,this.startFragRequested=!1,this.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(LM.FRAG_LOADED,e),n.bitrateTest=!1}}).catch(t=>{this.state!==KD&&this.state!==ix&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"_handleTransmuxComplete",value:function(e){var t=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,r=this.getCurrentContext(a);if(r){var o=r.frag,s=r.part,u=r.level,l=n.video,d=n.text,h=n.id3,c=n.initSegment,m=u.details,f=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=ZD,c){var v=c.tracks;if(v){var p=o.initSegment||o;if(this.unhandledEncryptionError(c,o))return;this._bufferInitSegment(u,v,p,a),i.trigger(LM.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:t,tracks:v})}var g=c.initPTS,y=c.timescale,b=this.initPTS[o.cc];if(AM(g)&&(!b||b.baseTime!==g||b.timescale!==y)){var w=c.trackId;this.initPTS[o.cc]={baseTime:g,timescale:y,trackId:w},i.trigger(LM.INIT_PTS_FOUND,{frag:o,id:t,initPTS:g,timescale:y,trackId:w})}}if(l&&m){f&&"audiovideo"===l.type&&this.logMuxedErr(o);var k=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,E=!k||o.cc>k.cc;if(!1!==n.independent){var M=l.startPTS,T=l.endPTS,P=l.startDTS,A=l.endDTS;if(s)s.elementaryStreams[l.type]={startPTS:M,endPTS:T,startDTS:P,endDTS:A};else if(l.firstKeyFrame&&l.independent&&1===a.id&&!E&&(this.couldBacktrack=!0),l.dropped&&l.independent){var D=this.getMainFwdBufferInfo(),x=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=l.firstKeyFramePTS?l.firstKeyFramePTS:M;if(!S&&x<C-this.config.maxBufferHole&&!E)return void this.backtrack(o);E&&(o.gap=!0),o.setElementaryStreamInfo(l.type,o.start,T,o.start,A,!0)}else S&&M-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(l.type,M,T,P,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(l,o,s,a,S||E)}else{if(!S&&!E)return void this.backtrack(o);o.gap=!0}}if(f){var I=f.startPTS,L=f.endPTS,_=f.startDTS,R=f.endDTS;s&&(s.elementaryStreams[fT]={startPTS:I,endPTS:L,startDTS:_,endDTS:R}),o.setElementaryStreamInfo(fT,I,L,_,R),this.bufferFragmentData(f,o,s,a)}if(m&&null!=h&&h.samples.length){var F={id:t,frag:o,details:m,samples:h.samples};i.trigger(LM.FRAG_PARSING_METADATA,F)}if(m&&d){var W={id:t,frag:o,details:m,samples:d.samples};i.trigger(LM.FRAG_PARSING_USERDATA,W)}}}else this.resetWhenMissingContext(a)}},{key:"logMuxedErr",value:function(e){this.warn(`${yT(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===ZD){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));var a=t.audio,r=t.video,o=t.audiovideo;if(a){var s=e.audioCodec,u=rP(a.codec,s);"mp4a"===u&&(u="mp4a.40.5");var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log(`Android: force audio codec to ${u}`)),s&&s!==u&&this.log(`Swapping manifest audio codec "${s}" for "${u}"`),a.levelCodec=u,a.id=OM,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${u||""}/${s||""}/${a.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=OM;var h=r.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e"}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${h}]${r.codec!==h?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(LM.BUFFER_CODECS,t),!this.hls)return;c.forEach(e=>{var a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(LM.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,OM)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=XD}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if(AA.isBuffered(e,i)?t=this.getAppendedFrag(i):AA.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(LM.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(LM.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return AM(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(AM(t)){var i=this.getLevelDetails(),n=this.currentFrag||(i?OP(null,i.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var r=a+1e3*(t-n.start);return new Date(r)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(),K_=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["key-loader",i])).config=void 0,n.keyIdToKeyInfo={},n.emeController=null,n.config=t,n}return ue(e,VM),ne(e,[{key:"abort",value:function(e){for(var t in this.keyIdToKeyInfo){var i=this.keyIdToKeyInfo[t].loader;if(i){var n;if(e&&e!==(null==(n=i.context)?void 0:n.frag.type))return;i.abort()}}}},{key:"detach",value:function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}},{key:"createKeyLoadError",value:function(e,t=IM.KEY_LOAD_ERROR,i,n,a){return new EA({type:CM.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}},{key:"loadClear",value:function(e,t,i){var n=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(var a,r=function(){var a=t[o];if(e.cc<=a.cc&&(!yT(e)||!yT(a)||e.sn<a.sn)||!i&&o==s-1)return{v:n.emeController.selectKeySystemFormat(a).then(e=>{if(n.emeController){a.setKeyFormat(e);var t=eD(e);return t?n.emeController.getKeySystemAccess([t]):void 0}})}},o=0,s=t.length;o<s;o++)if(a=r())return a.v;if(this.config.requireKeySystemAccessOnStart){var u=iD(this.config);if(u.length)return this.emeController.getKeySystemAccess(u)}}return null}},{key:"load",value:function(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,IM.KEY_LOAD_ERROR,r))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,IM.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));var s=X_(a),u=this.keyIdToKeyInfo[s];if(null!=(i=u)&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&null!=(n=u)&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(t=>{var i=t.keyInfo;return a.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[s]?"Rel":"L"}oading${a.keyId?" keyId: "+iT(a.keyId):""} URI: ${a.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,IM.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}},{key:"loadKeyEME",value:function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&null!=(n=t.initSegment)&&n.data){var a=function(e){var t=[];return $T(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(a.length){var r=a[0];r.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${iT(r)}`),sD.setKeyIdForUri(e.decryptdata.uri,r)):(r=sD.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${iT(r)}`)),e.decryptdata.keyId=r}}if(!e.decryptdata.keyId&&!yT(t))return Promise.resolve(i);var o=this.emeController.loadKey(i);return(e.keyLoadPromise=o.then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i})}return Promise.resolve(i)}},{key:"loadKeyHTTP",value:function(e,t){var i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,r)=>{var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=i.keyLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{var o=i.frag,s=i.keyInfo,u=X_(s.decryptdata);if(!o.decryptdata||s!==this.keyIdToKeyInfo[u])return r(this.createKeyLoadError(o,IM.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,i,n,a)=>{this.resetLoader(i),r(this.createKeyLoadError(t,IM.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),n,GM({url:o.url,data:void 0},e)))},onTimeout:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,IM.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,IM.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,l)})}},{key:"resetLoader",value:function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null);var r=X_(i.decryptdata)||n;delete this.keyIdToKeyInfo[r],a&&a.destroy()}}])}();function X_(e){if(e.keyFormat!==JA){var t=e.keyId;if(t)return iT(t)}return e.uri}function Y_(e){switch(e.type){case FM:return $M;case WM:return NM;default:return OM}}function q_(e,t){var i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}var J_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()},[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.on(LM.LEVEL_LOADING,this.onLevelLoading,this),e.on(LM.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(LM.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(LM.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(LM.MANIFEST_LOADING,this.onManifestLoading,this),e.off(LM.LEVEL_LOADING,this.onLevelLoading,this),e.off(LM.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(LM.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(LM.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:_M,url:i,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var i=t.id,n=t.level,a=t.pathwayId,r=t.url,o=t.deliveryDirectives,s=t.levelInfo;this.load({id:i,level:n,pathwayId:a,responseType:"text",type:RM,url:r,deliveryDirectives:o,levelOrTrack:s})}},{key:"onAudioTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:FM,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onSubtitleTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:WM,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onLevelsUpdated",value:function(e,t){var i=this.loaders[RM];if(i){var n=i.context;n&&!t.levels.some(e=>e===n.levelOrTrack)&&(i.abort(),delete this.loaders[RM])}}},{key:"load",value:function(e){var t,i,n,a=this.hls.config,r=this.getInternalLoader(e);if(r){var o=this.hls.logger,s=r.context;if(s&&s.levelOrTrack===e.levelOrTrack&&(s.url===e.url||s.deliveryDirectives&&!e.deliveryDirectives))return void(s.url===e.url?o.log(`[playlist-loader]: ignore ${e.url} ongoing request`):o.log(`[playlist-loader]: ignore ${e.url} in favor of ${s.url}`));o.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if((i=e.type===_M?a.manifestLoadPolicy.default:UM({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),AM(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===RM&&null!==e.level?n=this.hls.levels[e.level].details:e.type===FM&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===WM&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,l=n.targetduration;if(u&&l){var d=1e3*Math.max(3*u,.8*l);i=UM({},i,{maxTimeToFirstByteMs:Math.min(d,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,i.maxTimeToFirstByteMs)})}}var h=i.errorRetry||i.timeoutRetry||{},c={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},m={onSuccess:(e,t,i,n)=>{var a=this.getInternalLoader(i);this.resetInternalLoader(i.type);var r=e.data;t.parsing.start=performance.now(),fD.isMediaPlaylist(r)||i.type!==_M?this.handleTrackOrLevelPlaylist(e,t,i,n||null,a):this.handleMasterPlaylist(e,t,i,n)},onError:(e,t,i,n)=>{this.handleNetworkError(t,i,!1,e,n)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,c,m)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,i=t.autoStartLoad,n=t.startPosition,a=e.forceStartLoad;(i||a)&&(this.hls.logger.log(`${i?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}}},{key:"handleMasterPlaylist",value:function(e,t,i,n){var a=this.hls,r=e.data,o=q_(e,i),s=fD.parseMasterPlaylist(r,o);if(s.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,i,s.playlistParsingError,n,t);var u=s.contentSteering,l=s.levels,d=s.sessionData,h=s.sessionKeys,c=s.startTimeOffset,m=s.variableList;this.variableList=m,l.forEach(e=>{var t=e.unknownCodecs;if(t)for(var i=this.hls.config.preferManagedMediaSource,n=e.audioCodec,a=e.videoCodec,r=t.length;r--;){var o=t[r];JT(o,"audio",i)?(e.audioCodec=n=n?`${n},${o}`:o,YT.audio[n.substring(0,4)]=2,t.splice(r,1)):JT(o,"video",i)&&(e.videoCodec=a=a?`${a},${o}`:o,YT.video[a.substring(0,4)]=2,t.splice(r,1))}});var f=fD.parseMasterPlaylistMedia(r,o,s),v=f.AUDIO,p=void 0===v?[]:v,g=f.SUBTITLES,y=f["CLOSED-CAPTIONS"];p.length&&(p.some(e=>!e.url)||!l[0].audioCodec||l[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new FA({}),bitrate:0,url:""})));a.trigger(LM.MANIFEST_LOADED,{levels:l,audioTracks:p,subtitles:g,captions:y,contentSteering:u,url:o,stats:t,networkDetails:n,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:m})}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,i,n,a){var r=this.hls,o=i.id,s=i.level,u=i.type,l=q_(e,i),d=AM(s)?s:AM(o)?o:0,h=Y_(i),c=fD.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===_M){var m={attrs:new FA({}),bitrate:0,details:c,name:"",url:l};c.requestScheduled=t.loading.start+LD(c,0),r.trigger(LM.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:l,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,n,a)}},{key:"handleManifestParsingError",value:function(e,t,i,n,a){this.hls.trigger(LM.ERROR,{type:CM.NETWORK_ERROR,details:IM.MANIFEST_PARSING_ERROR,fatal:t.type===_M,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t,i=!1,n,a){var r=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===RM?r+=`: ${e.level} id: ${e.id}`:e.type!==FM&&e.type!==WM||(r+=` id: ${e.id} group-id: "${e.groupId}"`);var o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);var s=IM.UNKNOWN,u=!1,l=this.getInternalLoader(e);switch(e.type){case _M:s=i?IM.MANIFEST_LOAD_TIMEOUT:IM.MANIFEST_LOAD_ERROR,u=!0;break;case RM:s=i?IM.LEVEL_LOAD_TIMEOUT:IM.LEVEL_LOAD_ERROR,u=!1;break;case FM:s=i?IM.AUDIO_TRACK_LOAD_TIMEOUT:IM.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case WM:s=i?IM.SUBTITLE_TRACK_LOAD_TIMEOUT:IM.SUBTITLE_LOAD_ERROR,u=!1}l&&this.resetInternalLoader(e.type);var d={type:CM.NETWORK_ERROR,details:s,fatal:u,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(n){var h=(null==t?void 0:t.url)||e.url;d.response=GM({url:h,data:void 0},n)}this.hls.trigger(LM.ERROR,d)}},{key:"handlePlaylistLoaded",value:function(e,t,i,n,a,r){var o=this.hls,s=n.type,u=n.level,l=n.levelOrTrack,d=n.id,h=n.groupId,c=n.deliveryDirectives,m=q_(t,n),f=Y_(n),v="number"==typeof n.level&&f===OM?u:void 0,p=e.playlistParsingError;if(p){if(this.hls.logger.warn(`${p} ${e.url}`),!o.config.ignorePlaylistParsingErrors)return void o.trigger(LM.ERROR,{type:CM.NETWORK_ERROR,details:IM.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case _M:case RM:if(v)if(l){if(l!==o.levels[v]){var g=o.levels.indexOf(l);g>-1&&(v=g)}}else v=0;o.trigger(LM.LEVEL_LOADED,{details:e,levelInfo:l||o.levels[0],level:v||0,id:d||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:s===_M});break;case FM:o.trigger(LM.AUDIO_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c});break;case WM:o.trigger(LM.SUBTITLE_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(LM.ERROR,{type:CM.NETWORK_ERROR,details:IM.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i})}}}])}(),Q_=function(){function e(t={}){Q(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new hx,this._autoLevelCapping=-1,this._maxHdcpLevel=null,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,i){var n=YM();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(t=>{n[t]=qM(t,e,i)});try{n.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return YM()}a.forEach(t=>{JM[t]=qM(t,e)})}else UM(JM,n);return n}(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=function(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=I_(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{var r=`${"level"===e?"playlist":e}LoadPolicy`,o=void 0===t[r],s=[];a.forEach(i=>{var a=`${e}Loading${i}`,u=t[a];if(void 0!==u&&o){s.push(a);var l=n[r].default;switch(t[r]={default:l},i){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}}),s.length&&i.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${r}": ${PP(t[r])}`)}),GM(GM({},n),t)}(e.DefaultConfig,t,i);this.userConfig=t,n.progressive&&L_(n,i);var a=n.abrController,r=n.bufferController,o=n.capLevelController,s=n.errorController,u=n.fpsController,l=new s(this),d=this.abrController=new a(this),h=new lA(this),c=n.interstitialsController,m=c?this.interstitialsController=new c(this,e):null,f=this.bufferController=new r(this,h),v=this.capLevelController=new o(this),p=new u(this),g=new J_(this),y=n.contentSteeringController,b=y?new y(this):null,w=this.levelController=new z_(this,b),k=new j_(this),S=new K_(this.config,this.logger),E=this.streamController=new V_(this,h,S),M=this.gapController=new __(this,h);v.setStreamController(E),p.setStreamController(E);var T=[g,w,E];m&&T.splice(1,0,m),b&&T.splice(1,0,b),this.networkControllers=T;var P=[d,f,M,v,p,k,h];this.audioTrackController=this.createController(n.audioTrackController,T);var A=n.audioStreamController;A&&T.push(this.audioStreamController=new A(this,h,S)),this.subtitleTrackController=this.createController(n.subtitleTrackController,T);var D=n.subtitleStreamController;D&&T.push(this.subtititleStreamController=new D(this,h,S)),this.createController(n.timelineController,P),S.emeController=this.emeController=this.createController(n.emeController,P),this.cmcdController=this.createController(n.cmcdController,P),this.latencyController=this.createController(B_,P),this.coreComponents=P,T.push(l);var x=l.onErrorOut;"function"==typeof x&&this.on(LM.ERROR,x,l),this.on(LM.MANIFEST_LOADED,g.onManifestLoaded,g)}return ne(e,[{key:"createController",value:function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null}},{key:"on",value:function(e,t,i=this){this._emitter.on(e,t,i)}},{key:"once",value:function(e,t,i=this){this._emitter.once(e,t,i)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t,i=this,n){this._emitter.off(e,t,i,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,i){return this._emitter.emit(e,t,i)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var i=e===LM.ERROR;this.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(LM.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(LM.ERROR,{type:CM.OTHER_ERROR,details:IM.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var i="media"in e,n=i?e.media:e,a=i?e:{media:n};this._media=n,this.trigger(LM.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(LM.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(LM.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,i=this._url,n=this._url=cT.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(LM.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(var i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}},{key:"inFlightFragments",get:function(){var e={[OM]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[$M]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[NM]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(a){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var i=(new Date).getTime(),n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)});return n}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return pP.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,n)for(var a=e;a--;){var r=t[a].attrs["HDCP-LEVEL"];if(r&&r<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e,t=this.allAudioTracks){return mP(e,DP(t),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return cx}},{key:"isMSESupported",value:function(){return G_()}},{key:"isSupported",value:function(){return function(){if(!G_())return!1;var e=ZM();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(ZT(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(ZT(t,"audio"))))}()}},{key:"getMediaSource",value:function(){return ZM()}},{key:"Events",get:function(){return LM}},{key:"MetadataSchema",get:function(){return Fx}},{key:"ErrorTypes",get:function(){return CM}},{key:"ErrorDetails",get:function(){return IM}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:C_},set:function(t){e.defaultConfig=t}}])}();Q_.defaultConfig=void 0;var Z_,eR=e=>e,tR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.bgVideo=!1,t}return ue(e,lu),ne(e,[{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),ps.instance&&(ps.instance.removeVideoEvents(),ps.instance=null)}},{key:"styles",value:function(){var e,t,i=this.component,n=i.url,a=i.imageCropping,r=i.alignment,o=i.rightMargin,s=i.spacing,u="fit"===a,l=null!==(e=null===(t=this.getRootNode().host)||void 0===t?void 0:t.tagName.toLowerCase())&&void 0!==e?e:"";this.bgVideo=l.includes("background");var d=u?"":U(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return U(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${n});\n background-size: ${u?"contain":"cover"};\n background-position: ${r||""} center;\n background-repeat: no-repeat;\n ${Lu(this.component,this.scaleFactor)};\n margin-right: ${o||s||0}px;\n ${Ou(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n ${d}\n }\n :host(:focus) {\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n #nami-video {\n ${Lu(this.component,this.scaleFactor)};\n object-fit: ${u?"contain":"cover"};\n }\n `)}},{key:"loadMediaSrc",value:function(e){var t=this.component.url;if(t&&!t.includes(r)&&e.src!==t)if(!t.includes("m3u8")||e.canPlayType("application/vnd.apple.mpegurl"))e.src=t;else if(Q_.isSupported()){var i=new Q_;i.loadSource(t),i.attachMedia(e)}}},{key:"updated",value:function(){var e,t;Object.keys(this.component).forEach(e=>{this.component[e]=ja(this.contextProvider,this.component[e])});var i=this.component,n=i.id,a=i.title,r=i.autoplayVideo,o=i.mute,s=i.loopVideo,u=i.controlsType,l=i.fallbackImage,d=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("nami-video");d&&(d.autoplay=null!=r&&r,d.loop=null!=s&&s,d.muted=null!=o&&o,d.controls="none"!==u,d.poster=null!=l?l:"",d.playsInline=null!=r?r:this.bgVideo,this.loadMediaSrc(d),null===(t=ps.instance)||void 0===t||t.removeVideoEvents(),ps.instance=new ps(this.contextProvider,d,a,n))}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor,r=t.screenreaderText,o=t.title;return this.ariaLabel=null!==(e=null!=r?r:o)&&void 0!==e?e:"",!i&&Ka(a,n)||(this.tabIndex=0),B(Z_||(Z_=eR`<video id="nami-video" preload="auto"></video>`))}}])}();gt([qt({type:Object})],tR.prototype,"component",void 0),gt([qt({type:Boolean})],tR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],tR.prototype,"scaleFactor",void 0),tR=gt([Tt("nami-video")],tR);var iR,nR=e=>e,aR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.height=0,t.scaleFactor=1,t.isCollapsed=!0,t._handleClick=()=>{var e,i;t.isCollapsed=!t.isCollapsed,t.contextProvider.setOpenHeaderIds(t.component.id||"",t.component.sku),t.height=(null===(e=t.shadowRoot)||void 0===e||null===(e=e.getElementById("collapse"))||void 0===e?void 0:e.scrollHeight)||0,null===(i=t.shadowRoot)||void 0===i||null===(i=i.getElementById("collapse"))||void 0===i||i.classList.toggle("hidden")},t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component,t=this.height,i=this.scaleFactor,n=e.backgroundBlur,a="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${Mu(e,!1)};\n ${Tu(this.component)}\n ${Ou(e,i,!1)}\n cursor: pointer;\n }\n :host > *:not(:first-child) {\n ${a}: ${e.spacing?e.spacing*i:0}px;\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,i,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n padding: 0;\n margin: 0;\n }\n #collapse {\n ${Lu(e,i)}\n max-height: ${t}px;\n opacity: 1;\n transition: all linear 0.5s;\n overflow: hidden;\n }\n #collapse-btn{\n background: transparent;\n border: none;\n width: 100%;\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.components,i=e.collapseHeader,n=e.focusedBorderColor,a=e.focusedFillColor,r=e.fillColor;!n&&Ka(r,a)||(this.tabIndex=0);var o=t.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return B(iR||(iR=nR`
|
|
470
|
+
<label for="${0}">${0}</label>`),this.component.text,this.component.text,this.component.text,this._isActive,this.component.text,this.component.text)}}])}();gt([qt({type:Object})],AM.prototype,"component",void 0),gt([qt({type:Boolean})],AM.prototype,"inFocusedState",void 0),gt([qt({type:Number})],AM.prototype,"scaleFactor",void 0),gt([Jt()],AM.prototype,"_isActive",void 0),AM=gt([Tt("nami-segment-picker-item")],AM);var DM=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},xM=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=CM},CM=Number.MAX_SAFE_INTEGER||9007199254740991,IM=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),LM=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),_M=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),RM="manifest",FM="level",WM="audioTrack",OM="subtitleTrack",$M="main",NM="audio",jM="subtitle",BM=function(){return ne(function e(t,i=0,n=0){Q(this,e),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=i,this.totalWeight_=n},[{key:"sample",value:function(e,t){var i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}},{key:"getTotalWeight",value:function(){return this.totalWeight_}},{key:"getEstimate",value:function(){if(this.alpha_){var e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}])}(),zM=function(){return ne(function e(t,i,n,a=100){Q(this,e),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new BM(t),this.fast_=new BM(i),this.defaultTTFB_=a,this.ttfb_=new BM(t)},[{key:"update",value:function(e,t){var i=this.slow_,n=this.fast_,a=this.ttfb_;i.halfLife!==e&&(this.slow_=new BM(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new BM(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new BM(e,a.getEstimate(),a.getTotalWeight()))}},{key:"sample",value:function(e,t){var i=(e=Math.max(e,this.minDelayMs_))/1e3,n=8*t/i;this.fast_.sample(i,n),this.slow_.sample(i,n)}},{key:"sampleTTFB",value:function(e){var t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}},{key:"canEstimate",value:function(){return this.fast_.getTotalWeight()>=this.minWeight_}},{key:"getEstimate",value:function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}},{key:"getEstimateTTFB",value:function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}},{key:"defaultEstimate",get:function(){return this.defaultEstimate_}},{key:"destroy",value:function(){}}])}();function UM(e,t,i){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function HM(){return HM=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)({}).hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},HM.apply(null,arguments)}function GM(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function VM(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?GM(Object(i),!0).forEach(function(t){UM(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):GM(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}var KM=ne(function e(t,i){Q(this,e),this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var n=`[${t}]:`;this.trace=XM,this.debug=i.debug.bind(null,n),this.log=i.log.bind(null,n),this.warn=i.warn.bind(null,n),this.info=i.info.bind(null,n),this.error=i.error.bind(null,n)}),XM=function(){},YM={trace:XM,debug:XM,log:XM,warn:XM,info:XM,error:XM};function qM(){return HM({},YM)}function JM(e,t,i){return t[e]?t[e].bind(t):function(e,t){var i=self.console[e];return i?i.bind(self.console,`${t?"["+t+"] ":""}[${e}] >`):XM}(e,i)}var QM=qM();var ZM=QM;function eT(e=!0){if("undefined"!=typeof self)return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function tT(e,t){var i=Object.keys(e),n=Object.keys(t),a=i.length,r=n.length;return!a||!r||a===r&&!i.some(e=>-1===n.indexOf(e))}function iT(e,t=!1){if("undefined"!=typeof TextDecoder){var i=new TextDecoder("utf-8").decode(e);if(t){var n=i.indexOf("\0");return-1!==n?i.substring(0,n):i}return i.replace(/\0/g,"")}for(var a,r,o,s=e.length,u="",l=0;l<s;){if(0===(a=e[l++])&&t)return u;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:r=e[l++],u+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[l++],o=e[l++],u+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return u}function nT(e){for(var t="",i=0;i<e.length;i++){var n=e[i].toString(16);n.length<2&&(n="0"+n),t+=n}return t}function aT(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function rT(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var oT,sT={exports:{}};var uT,lT,dT,hT,cT,mT=oT?sT.exports:(oT=1,uT=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,lT=/^(?=([^\/?#]*))\1([^]*)$/,dT=/(?:\/|^)\.(?=\/)/g,hT=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,sT.exports=cT={buildAbsoluteURL:function(e,t,i){if(i=i||{},e=e.trim(),!(t=t.trim())){if(!i.alwaysNormalize)return e;var n=cT.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");return n.path=cT.normalizePath(n.path),cT.buildURLFromParts(n)}var a=cT.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=cT.normalizePath(a.path),cT.buildURLFromParts(a)):t;var r=cT.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){var o=lT.exec(r.path);r.netLoc=o[1],r.path=o[2]}r.netLoc&&!r.path&&(r.path="/");var s={scheme:r.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(s.netLoc=r.netLoc,"/"!==a.path[0]))if(a.path){var u=r.path,l=u.substring(0,u.lastIndexOf("/")+1)+a.path;s.path=cT.normalizePath(l)}else s.path=r.path,a.params||(s.params=r.params,a.query||(s.query=r.query));return null===s.path&&(s.path=i.alwaysNormalize?cT.normalizePath(a.path):a.path),cT.buildURLFromParts(s)},parseURL:function(e){var t=uT.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(dT,"");e.length!==(e=e.replace(hT,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}}),fT=ne(function e(){Q(this,e),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}}),vT="audio",pT="video",gT="audiovideo",yT=function(){return ne(function e(t){Q(this,e),this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(e,t){var i=ST(e,t);i&&(i.enumerable=!0,Object.defineProperty(e,t,i))}(this,"stats")},[{key:"setByteRange",value:function(e,t){var i,n=e.split("@",2);i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}},{key:"baseurl",get:function(){return this.base.url}},{key:"byteRange",get:function(){return null===this._byteRange?[]:this._byteRange}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"elementaryStreams",get:function(){return null===this._streams&&(this._streams={[vT]:null,[pT]:null,[gT]:null}),this._streams},set:function(e){this._streams=e}},{key:"hasStats",get:function(){return null!==this._stats}},{key:"hasStreams",get:function(){return null!==this._streams}},{key:"stats",get:function(){return null===this._stats&&(this._stats=new fT),this._stats},set:function(e){this._stats=e}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=mT.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(e){this._url=e}},{key:"clearElementaryStreamInfo",value:function(){var e=this.elementaryStreams;e[vT]=null,e[pT]=null,e[gT]=null}}])}();function bT(e){return"initSegment"!==e.sn}var wT=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i]))._decryptdata=null,n._programDateTime=null,n._ref=null,n._bitrate=void 0,n.rawProgramDateTime=null,n.tagList=[],n.duration=0,n.sn=0,n.levelkeys=void 0,n.type=void 0,n.loader=null,n.keyLoader=null,n.level=-1,n.cc=0,n.startPTS=void 0,n.endPTS=void 0,n.startDTS=void 0,n.endDTS=void 0,n.start=0,n.playlistOffset=0,n.deltaPTS=void 0,n.maxStartPTS=void 0,n.minEndPTS=void 0,n.data=void 0,n.bitrateTest=!1,n.title=null,n.initSegment=null,n.endList=void 0,n.gap=void 0,n.urlId=0,n.type=t,n}return ue(e,yT),ne(e,[{key:"byteLength",get:function(){if(this.hasStats){var e=this.stats.total;if(e)return e}if(this.byteRange.length){var t=this.byteRange[0],i=this.byteRange[1];if(DM(t)&&DM(i))return i-t}return null}},{key:"bitrate",get:function(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null},set:function(e){this._bitrate=e}},{key:"decryptdata",get:function(){var e,t=this.levelkeys;if(!t||t.NONE)return null;if(t.identity)this._decryptdata||(this._decryptdata=t.identity.getDecryptData(this.sn));else if(null==(e=this._decryptdata)||!e.keyId){var i=Object.keys(t);if(1===i.length){var n=this._decryptdata=t[i[0]]||null;n&&(this._decryptdata=n.getDecryptData(this.sn,t))}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;var e=DM(this.duration)?this.duration:0;return this.programDateTime+1e3*e}},{key:"encrypted",get:function(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var t,i=Object.keys(this.levelkeys),n=i.length;if(n>1||1===n&&null!=(t=this.levelkeys[i[0]])&&t.encrypted)return!0}return!1}},{key:"programDateTime",get:function(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime},set:function(e){DM(e)?this._programDateTime=e:this._programDateTime=this.rawProgramDateTime=null}},{key:"ref",get:function(){return bT(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}},{key:"addStart",value:function(e){this.setStart(this.start+e)}},{key:"setStart",value:function(e){this.start=e,this._ref&&(this._ref.start=e)}},{key:"setDuration",value:function(e){this.duration=e,this._ref&&(this._ref.duration=e)}},{key:"setKeyFormat",value:function(e){var t=this.levelkeys;if(t){var i,n=t[e];!n||null!=(i=this._decryptdata)&&i.keyId||(this._decryptdata=n.getDecryptData(this.sn,t))}}},{key:"abortRequests",value:function(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}},{key:"setElementaryStreamInfo",value:function(e,t,i,n,a,r=!1){var o=this.elementaryStreams,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,i),s.startDTS=Math.min(s.startDTS,n),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:r}}}])}(),kT=function(){function e(t,i,n,a,r){var o;Q(this,e),(o=J(this,e,[n])).fragOffset=0,o.duration=0,o.gap=!1,o.independent=!1,o.relurl=void 0,o.fragment=void 0,o.index=void 0,o.duration=t.decimalFloatingPoint("DURATION"),o.gap=t.bool("GAP"),o.independent=t.bool("INDEPENDENT"),o.relurl=t.enumeratedString("URI"),o.fragment=i,o.index=a;var s=t.enumeratedString("BYTERANGE");return s&&o.setByteRange(s,r),r&&(o.fragOffset=r.fragOffset+r.duration),o}return ue(e,yT),ne(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var e=this.elementaryStreams;return!!(e.audio||e.video||e.audiovideo)}}])}();function ST(e,t){var i=Object.getPrototypeOf(e);if(i){var n=Object.getOwnPropertyDescriptor(i,t);return n||ST(i,t)}}var ET=Math.pow(2,32)-1,MT=[].push,TT={video:1,audio:2,id3:3,text:4};function PT(e){return String.fromCharCode.apply(null,e)}function AT(e,t){var i=e[t]<<8|e[t+1];return i<0?65536+i:i}function DT(e,t){var i=CT(e,t);return i<0?4294967296+i:i}function xT(e,t){var i=DT(e,t);return i*=Math.pow(2,32),i+=DT(e,t+4)}function CT(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function IT(e,t){var i=[];if(!t.length)return i;for(var n=e.byteLength,a=0;a<n;){var r=DT(e,a),o=r>1?a+r:n;if(PT(e.subarray(a+4,a+8))===t[0])if(1===t.length)i.push(e.subarray(a+8,o));else{var s=IT(e.subarray(a+8,o),t.slice(1));s.length&&MT.apply(i,s)}a=o}return i}function LT(e){var t=[],i=e[0],n=8,a=DT(e,n);n+=4;var r=0,o=0;0===i?(r=DT(e,n),o=DT(e,n+4),n+=8):(r=xT(e,n),o=xT(e,n+8),n+=16),n+=2;var s=e.length+o,u=AT(e,n);n+=2;for(var l=0;l<u;l++){var d=n,h=DT(e,d);d+=4;var c=2147483647&h;if(1===(2147483648&h)>>>31)return ZM.warn("SIDX has hierarchical references (not supported)"),null;var m=DT(e,d);d+=4,t.push({referenceSize:c,subsegmentDuration:m,info:{duration:m/a,start:s,end:s+c-1}}),s+=c,n=d+=4}return{earliestPresentationTime:r,timescale:a,version:i,referencesCount:u,references:t}}function _T(e){for(var t=[],i=IT(e,["moov","trak"]),n=0;n<i.length;n++){var a=i[n],r=IT(a,["tkhd"])[0];if(r){var o=r[0],s=DT(r,0===o?12:20),u=IT(a,["mdia","mdhd"])[0];if(u){var l=DT(u,0===(o=u[0])?12:20),d=IT(a,["mdia","hdlr"])[0];if(d){var h=PT(d.subarray(8,12)),c={soun:vT,vide:pT}[h],m=RT(IT(a,["mdia","minf","stbl","stsd"])[0]);c?(t[s]={timescale:l,type:c,stsd:m},t[c]=VM({timescale:l,id:s},m)):t[s]={timescale:l,type:h,stsd:m}}}}}return IT(e,["moov","mvex","trex"]).forEach(e=>{var i=DT(e,4),n=t[i];n&&(n.default={duration:DT(e,12),flags:DT(e,20)})}),t}function RT(e){var t,i=e.subarray(8),n=i.subarray(86),a=PT(i.subarray(4,8)),r=a,o="enca"===a||"encv"===a;if(o){var s=IT(i,[a])[0];IT(s.subarray("enca"===a?28:78),["sinf"]).forEach(e=>{var t=IT(e,["schm"])[0];if(t){var i=PT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=IT(e,["frma"])[0];n&&(r=PT(n))}}})}var u=r;switch(r){case"avc1":case"avc2":case"avc3":case"avc4":var l=IT(n,["avcC"])[0];l&&l.length>3&&(r+="."+OT(l[1])+OT(l[2])+OT(l[3]),t=FT("avc1"===u?"dva1":"dvav",n));break;case"mp4a":var d=IT(i,[a])[0],h=IT(d.subarray(28),["esds"])[0];if(h&&h.length>7){var c=4;if(3!==h[c++])break;c=WT(h,c),c+=2;var m=h[c++];if(128&m&&(c+=2),64&m&&(c+=h[c++]),4!==h[c++])break;c=WT(h,c);var f=h[c++];if(64!==f)break;if(r+="."+OT(f),c+=12,5!==h[c++])break;c=WT(h,c);var v=h[c++],p=(248&v)>>3;31===p&&(p+=1+((7&v)<<3)+((224&h[c])>>5)),r+="."+p}break;case"hvc1":case"hev1":var g=IT(n,["hvcC"])[0];if(g&&g.length>12){var y=g[1],b=["","A","B","C"][y>>6],w=31&y,k=DT(g,2),S=(32&y)>>5?"H":"L",E=g[12],M=g.subarray(6,12);r+="."+b+w,r+="."+function(e){for(var t=0,i=0;i<32;i++)t|=(e>>i&1)<<31-i;return t>>>0}(k).toString(16).toUpperCase(),r+="."+S+E;for(var T="",P=M.length;P--;){var A=M[P];if(A||T)T="."+A.toString(16).toUpperCase()+T}r+=T}t=FT("hev1"==u?"dvhe":"dvh1",n);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":r=FT(r,n)||r;break;case"vp09":var D=IT(n,["vpcC"])[0];if(D&&D.length>6){var x=D[4],C=D[5],I=D[6]>>4&15;r+="."+$T(x)+"."+$T(C)+"."+$T(I)}break;case"av01":var L=IT(n,["av1C"])[0];if(L&&L.length>2){var _=L[1]>>>5,R=31&L[1],F=L[2]>>>7?"H":"M",W=(64&L[2])>>6,O=(32&L[2])>>5,$=2===_&&W?O?12:10:W?10:8,N=(16&L[2])>>4,j=(8&L[2])>>3,B=(4&L[2])>>2,z=3&L[2];r+="."+_+"."+$T(R)+F+"."+$T($)+"."+N+"."+j+B+z+"."+$T(1)+"."+$T(1)+"."+$T(1)+".0",t=FT("dav1",n)}}return{codec:r,encrypted:o,supplemental:t}}function FT(e,t){var i=IT(t,["dvvC"]),n=i.length?i[0]:IT(t,["dvcC"])[0];if(n){var a=n[2]>>1&127,r=n[2]<<5&32|n[3]>>3&31;return e+"."+$T(a)+"."+$T(r)}}function WT(e,t){for(var i=t+5;128&e[t++]&&t<i;);return t}function OT(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function $T(e){return(e<10?"0":"")+e}function NT(e,t){IT(e,["moov","trak"]).forEach(e=>{var i=IT(e,["mdia","minf","stbl","stsd"])[0];if(i){var n=i.subarray(8),a=IT(n,["enca"]),r=a.length>0;r||(a=IT(n,["encv"])),a.forEach(e=>{IT(r?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var i=jT(e);i&&t(i,r)})})}})}function jT(e){var t=IT(e,["schm"])[0];if(t){var i=PT(t.subarray(4,8));if("cbcs"===i||"cenc"===i){var n=IT(e,["schi","tenc"])[0];if(n)return n}}}function BT(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function zT(e,t){var i=[],n=t.samples,a=t.timescale,r=t.id,o=!1;return IT(n,["moof"]).map(s=>{var u=s.byteOffset-8;IT(s,["traf"]).map(s=>{var l=IT(s,["tfdt"]).map(e=>{var t=e[0],i=DT(e,4);return 1===t&&(i*=Math.pow(2,32),i+=DT(e,8)),i/a})[0];return void 0!==l&&(e=l),IT(s,["tfhd"]).map(l=>{var d=DT(l,4),h=16777215&DT(l,0),c=0,m=!!(16&h),f=0,v=!!(32&h),p=8;d===r&&(!!(1&h)&&(p+=8),!!(2&h)&&(p+=4),!!(8&h)&&(c=DT(l,p),p+=4),m&&(f=DT(l,p),p+=4),v&&(p+=4),"video"===t.type&&(o=UT(t.codec)),IT(s,["trun"]).map(r=>{var s=r[0],l=16777215&DT(r,0),d=!!(1&l),h=0,m=!!(4&l),v=!!(256&l),p=0,g=!!(512&l),y=0,b=!!(1024&l),w=!!(2048&l),k=0,S=DT(r,4),E=8;d&&(h=DT(r,E),E+=4),m&&(E+=4);for(var M=h+u,T=0;T<S;T++){if(v?(p=DT(r,E),E+=4):p=c,g?(y=DT(r,E),E+=4):y=f,b&&(E+=4),w&&(k=0===s?DT(r,E):CT(r,E),E+=4),t.type===pT)for(var P=0;P<y;){var A=DT(n,M);if(HT(o,n[M+=4]))GT(n.subarray(M,M+A),o?2:1,e+k/a,i);M+=A,P+=A+4}e+=p/a}}))})})}),i}function UT(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}function HT(e,t){if(e){var i=t>>1&63;return 39===i||40===i}return 6===(31&t)}function GT(e,t,i,n){var a=VT(e),r=0;r+=t;for(var o=0,s=0,u=0;r<a.length;){o=0;do{if(r>=a.length)break;o+=u=a[r++]}while(255===u);s=0;do{if(r>=a.length)break;s+=u=a[r++]}while(255===u);var l=a.length-r,d=r;if(s<l)r+=s;else if(s>l){ZM.error(`Malformed SEI payload. ${s} is too small, only ${l} bytes left to parse.`);break}if(4===o){if(181===a[d++]){var h=AT(a,d);if(d+=2,49===h){var c=DT(a,d);if(d+=4,1195456820===c){var m=a[d++];if(3===m){var f=a[d++],v=64&f,p=v?2+3*(31&f):0,g=new Uint8Array(p);if(v){g[0]=f;for(var y=1;y<p;y++)g[y]=a[d++]}n.push({type:m,payloadType:o,pts:i,bytes:g})}}}}}else if(5===o&&s>16){for(var b=[],w=0;w<16;w++){var k=a[d++].toString(16);b.push(1==k.length?"0"+k:k),3!==w&&5!==w&&7!==w&&9!==w||b.push("-")}for(var S=s-16,E=new Uint8Array(S),M=0;M<S;M++)E[M]=a[d++];n.push({payloadType:o,pts:i,uuid:b.join(""),userData:iT(E),userDataBytes:E})}}}function VT(e){for(var t=e.byteLength,i=[],n=1;n<t-2;)0===e[n]&&0===e[n+1]&&3===e[n+2]?(i.push(n+2),n+=2):n++;if(0===i.length)return e;var a=t-i.length,r=new Uint8Array(a),o=0;for(n=0;n<a;o++,n++)o===i[0]&&(o++,i.shift()),r[n]=e[o];return r}function KT(e,t,i){if(16!==e.byteLength)throw new RangeError("Invalid system id");var n,a;n=new Uint8Array,a=new Uint8Array;var r=new Uint8Array(4);return i.byteLength>0&&new DataView(r.buffer).setUint32(0,i.byteLength,!1),function(e,...t){for(var i=t.length,n=8,a=i;a--;)n+=t[a].byteLength;var r=new Uint8Array(n);for(r[0]=n>>24&255,r[1]=n>>16&255,r[2]=n>>8&255,r[3]=255&n,r.set(e,4),a=0,n=8;a<i;a++)r.set(t[a],n),n+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,a,n,r,i)}function XT(e){var t=e.getUint32(0),i=e.byteOffset,n=e.byteLength;if(n<t)return{offset:i,size:n};if(1886614376!==e.getUint32(4))return{offset:i,size:t};var a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:i,size:t};var r=e.buffer,o=nT(new Uint8Array(r,i+12,16)),s=null,u=0;if(0===a)u=28;else{var l=e.getUint32(28);if(!l||n<32+16*l)return{offset:i,size:t};s=[];for(var d=0;d<l;d++)s.push(new Uint8Array(r,i+32+16*d,16));u=32+16*l}if(!u)return{offset:i,size:t};var h=e.getUint32(u);return t-32<h?{offset:i,size:t}:{version:a,systemId:o,kids:s,data:new Uint8Array(r,i+u+4,h),offset:i,size:t}}var YT=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),qT={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function JT(e,t){var i=qT[t];return!!i&&!!i[e.slice(0,4)]}function QT(e,t,i=!0){return!e.split(",").some(e=>!ZT(e,t,i))}function ZT(e,t,i=!0){var n,a=eT(i);return null!=(n=null==a?void 0:a.isTypeSupported(eP(e,t)))&&n}function eP(e,t){return`${t}/mp4;codecs=${e}`}function tP(e){if(e){var t=e.substring(0,4);return qT.video[t]}return 2}function iP(e){var t=YT();return e.split(",").reduce((e,i)=>{var n=t&&UT(i)?9:qT.video[i];return n?(2*n+e)/(e?3:2):(qT.audio[i]+e)/(e?2:1)},0)}var nP={};var aP=/flac|opus|mp4a\.40\.34/i;function rP(e,t=!0){return e.replace(aP,e=>function(e,t=!0){if(nP[e])return nP[e];for(var i={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[e],n=0;n<i.length;n++){var a;if(ZT(i[n],"audio",t))return nP[e]=i[n],i[n];if("mp3"===i[n]&&null!=(a=eT(t))&&a.isTypeSupported("audio/mpeg"))return""}return e}(e.toLowerCase(),t))}function oP(e,t){if(e&&(e.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(e))&&(sP(e,"audio")||sP(e,"video")))return e;if(t){var i=t.split(",");if(i.length>1){if(e)for(var n=i.length;n--;)if(i[n].substring(0,4)===e.substring(0,4))return i[n];return i[0]}}return t||e}function sP(e,t){return JT(e,t)&&ZT(e,t)}function uP(e){if(e.startsWith("av01.")){for(var t=e.split("."),i=["0","111","01","01","01","0"],n=t.length;n>4&&n<10;n++)t[n]=i[n-4];return t.join(".")}return e}function lP(e){var t=eT(e)||{isTypeSupported:()=>!1};return{mpeg:t.isTypeSupported("audio/mpeg"),mp3:t.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:t.isTypeSupported('audio/mp4; codecs="ac-3"')}}function dP(e){return e.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}var hP={supported:!1,smooth:!1,powerEfficient:!1},cP={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function mP(e,t){return{supported:!1,configurations:t,decodingInfoResults:[hP],error:e}}function fP(e,t,i,n={}){var a=e.videoCodec;if(!a&&!e.audioCodec||!i)return Promise.resolve(cP);for(var r=[],o=function(e){var t,i=null==(t=e.videoCodec)?void 0:t.split(","),n=pP(e),a=e.width||640,r=e.height||480,o=e.frameRate||30,s=e.videoRange.toLowerCase();return i?i.map(e=>{var t={contentType:eP(uP(e),"video"),width:a,height:r,bitrate:n,framerate:o};return"sdr"!==s&&(t.transferFunction=s),t}):[]}(e),s=o.length,u=function(e,t,i){var n,a=null==(n=e.audioCodec)?void 0:n.split(","),r=pP(e);if(a&&e.audioGroups)return e.audioGroups.reduce((e,n)=>{var o,s=n?null==(o=t.groups[n])?void 0:o.tracks:null;return s?s.reduce((e,t)=>{if(t.groupId===n){var o=parseFloat(t.channels||"");a.forEach(t=>{var n={contentType:eP(t,"audio"),bitrate:i?vP(t,r):r};o&&(n.channels=""+o),e.push(n)})}return e},e):e},[]);return[]}(e,t,s>0),l=u.length,d=s||1*l||1;d--;){var h={type:"media-source"};if(s&&(h.video=o[d%s]),l){h.audio=u[d%l];var c=h.audio.bitrate;h.video&&c&&(h.video.bitrate-=c)}r.push(h)}if(a){var m=navigator.userAgent;if(a.split(",").some(e=>UT(e))&&YT())return Promise.resolve(mP(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${m})`),r))}return Promise.all(r.map(e=>{var t=function(e){var t="",i=e.audio,n=e.video;if(n){t+=`${dP(n.contentType)}_r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction||"sd"}_${Math.ceil(n.bitrate/1e5)}`}if(i){t+=`${n?"_":""}${dP(i.contentType)}_c${i.channels}`}return t}(e);return n[t]||(n[t]=i.decodingInfo(e))})).then(e=>({supported:!e.some(e=>!e.supported),configurations:r,decodingInfoResults:e})).catch(e=>({supported:!1,configurations:r,decodingInfoResults:[],error:e}))}function vP(e,t){if(t<=1)return 1;var i=128e3;return"ec-3"===e?i=768e3:"ac-3"===e&&(i=64e4),Math.min(t/2,i)}function pP(e){return 1e3*Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)/1e3)||1}var gP=["NONE","TYPE-0","TYPE-1",null];var yP=["SDR","PQ","HLG"];var bP="",wP="YES",kP="v2";function SP(e){var t=e.canSkipUntil,i=e.canSkipDateRanges,n=e.age;return t&&n<t/2?i?kP:wP:bP}var EP=function(){return ne(function e(t,i,n){Q(this,e),this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n},[{key:"addDirectives",value:function(e){var t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}])}(),MP=function(){return ne(function e(t){if(Q(this,e),this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>!!e).map(e=>e.substring(0,4)).join(","),"supplemental"in t){var i;this.supplemental=t.supplemental;var n=null==(i=t.supplemental)?void 0:i.videoCodec;n&&n!==t.videoCodec&&(this.codecSet+=`,${n.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)},[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"hasAudioGroup",value:function(e){return TP(this._audioGroups,e)}},{key:"hasSubtitleGroup",value:function(e){return TP(this._subtitleGroups,e)}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"addGroupId",value:function(e,t){if(t)if("audio"===e){var i=this._audioGroups;i||(i=this._audioGroups=[]),-1===i.indexOf(t)&&i.push(t)}else if("text"===e){var n=this._subtitleGroups;n||(n=this._subtitleGroups=[]),-1===n.indexOf(t)&&n.push(t)}}},{key:"urlId",get:function(){return 0},set:function(e){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var e;return null==(e=this.audioGroups)?void 0:e[0]}},{key:"textGroupId",get:function(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}},{key:"addFallback",value:function(){}}])}();function TP(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function PP(e,t){var i=!1,n=[];if(e&&(i="SDR"!==e,n=[e]),t){var a="SDR"!==(n=t.allowedVideoRanges||yP.slice(0)).join("")&&!t.videoCodec;(i=void 0!==t.preferHDR?t.preferHDR:a&&function(){if("function"==typeof matchMedia){var e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}())||(n=["SDR"])}return{preferHDR:i,allowedVideoRanges:n}}var AP=(e,t)=>JSON.stringify(e,(e=>{var t=new WeakSet;return(i,n)=>{if(e&&(n=e(i,n)),"object"==typeof n&&null!==n){if(t.has(n))return;t.add(n)}return n}})(t));function DP(e,t){ZM.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function xP(e){return e.reduce((e,t)=>{var i=e.groups[t.groupId];i||(i=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),i.tracks.push(t);var n=t.channels||"2";return i.channels[n]=(i.channels[n]||0)+1,i.hasDefault=i.hasDefault||t.default,i.hasAutoSelect=i.hasAutoSelect||t.autoselect,i.hasDefault&&(e.hasDefaultAudio=!0),i.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function CP(e){return e?{lang:e.lang,assocLang:e.assocLang,characteristics:e.characteristics,channels:e.channels,audioCodec:e.audioCodec}:e}function IP(e,t,i){if("attrs"in e){var n=t.indexOf(e);if(-1!==n)return n}for(var a=0;a<t.length;a++){if(LP(e,t[a],i))return a}return-1}function LP(e,t,i){var n=e.groupId,a=e.name,r=e.lang,o=e.assocLang,s=e.default,u=e.forced;return(void 0===n||t.groupId===n)&&(void 0===a||t.name===a)&&(void 0===r||function(e,t="--"){if(e.length===t.length)return e===t;return e.startsWith(t)||t.startsWith(e)}(r,t.lang))&&(void 0===r||t.assocLang===o)&&(void 0===s||t.default===s)&&(void 0===u||t.forced===u)&&(!("characteristics"in e)||function(e,t=""){var i=e.split(","),n=t.split(",");return i.length===n.length&&!i.some(e=>-1===n.indexOf(e))}(e.characteristics||"",t.characteristics))&&(void 0===i||i(e,t))}function _P(e,t){var i=e.audioCodec,n=e.channels;return!(void 0!==i&&(t.audioCodec||"").substring(0,4)!==i.substring(0,4)||void 0!==n&&n!==(t.channels||"2"))}function RP(e,t,i){for(var n=t;n>-1;n--)if(i(e[n]))return n;for(var a=t+1;a<e.length;a++)if(i(e[a]))return a;return-1}function FP(e,t){var i;return!!e&&e!==(null==(i=t.loadLevelObj)?void 0:i.uri)}var WP=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["abr",t.logger])).hls=void 0,i.lastLevelLoadSec=0,i.lastLoadedFragLevel=-1,i.firstSelection=-1,i._nextAutoLevel=-1,i.nextAutoLevelKey="",i.audioTracksByGroup=null,i.codecTiers=null,i.timer=-1,i.fragCurrent=null,i.partCurrent=null,i.bitrateTestDelay=0,i.rebufferNotice=-1,i.supportedCache={},i.bwEstimator=void 0,i._abandonRulesCheck=e=>{var t,n=i,a=n.fragCurrent,r=n.partCurrent,o=n.hls,s=o.autoLevelEnabled,u=o.media;if(a&&u){var l=performance.now(),d=r?r.stats:a.stats,h=r?r.duration:a.duration,c=l-d.loading.start,m=o.minAutoLevel,f=a.level,v=i._nextAutoLevel;if(d.aborted||d.loaded&&d.loaded===d.total||f<=m)return i.clearTimer(),void(i._nextAutoLevel=-1);if(s){var p=v>-1&&v!==f,g=!!e||p;if(g||!u.paused&&u.playbackRate&&u.readyState){var y=o.mainForwardBufferInfo;if(g||null!==y){var b=i.bwEstimator.getEstimateTTFB(),w=Math.abs(u.playbackRate);if(!(c<=Math.max(b,h/(2*w)*1e3))){var k=y?y.len/w:0,S=d.loading.first?d.loading.first-d.loading.start:-1,E=d.loaded&&S>-1,M=i.getBwEstimate(),T=o.levels,P=T[f],A=Math.max(d.loaded,Math.round(h*(a.bitrate||P.averageBitrate)/8)),D=E?c-S:c;D<1&&E&&(D=Math.min(c,8*d.loaded/M));var x=E?1e3*d.loaded/D:0,C=b/1e3,I=x?(A-d.loaded)/x:8*A/M+C;if(!(I<=k)){var L,_=x?8*x:M,R=!0===(null==(t=(null==e?void 0:e.details)||i.hls.latestLevelDetails)?void 0:t.live),F=i.hls.config.abrBandWidthUpFactor,W=Number.POSITIVE_INFINITY;for(L=f-1;L>m;L--){var O=T[L].maxBitrate,$=!T[L].details||R;if((W=i.getTimeToLoadFrag(C,_,h*O,$))<Math.min(k,h+C))break}if(!(W>=I||W>10*h)){E?i.bwEstimator.sample(c-Math.min(b,S),d.loaded):i.bwEstimator.sampleTTFB(c);var N=T[L].maxBitrate;i.getBwEstimate()*F>N&&i.resetEstimator(N);var j=i.findBestLevel(N,m,L,0,k,1,1);j>-1&&(L=j),i.warn(`Fragment ${a.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${a.duration.toFixed(3)}\n Time to underbuffer: ${k.toFixed(3)} s\n Estimated load time for current fragment: ${I.toFixed(3)} s\n Estimated load time for down switch fragment: ${W.toFixed(3)} s\n TTFB estimate: ${0|S} ms\n Current BW estimate: ${DM(M)?0|M:"Unknown"} bps\n New BW estimate: ${0|i.getBwEstimate()} bps\n Switching to level ${L} @ ${0|N} bps`),o.nextLoadLevel=o.nextAutoLevel=L,i.clearTimer();var B=()=>{if(i.clearTimer(),i.fragCurrent===a&&i.hls.loadLevel===L&&L>0){var e=i.getStarvationDelay();if(i.warn(`Aborting inflight request ${L>0?"and switching down":""}\n Fragment duration: ${a.duration.toFixed(3)} s\n Time to underbuffer: ${e.toFixed(3)} s`),a.abortRequests(),i.fragCurrent=i.partCurrent=null,L>m){var t=i.findBestLevel(i.hls.levels[m].bitrate,m,L,0,e,1,1);-1===t&&(t=m),i.hls.nextLoadLevel=i.hls.nextAutoLevel=t,i.resetEstimator(i.hls.levels[t].bitrate)}}};p||I>2*W?B():i.timer=self.setInterval(B,1e3*W),o.trigger(_M.FRAG_LOAD_EMERGENCY_ABORTED,{frag:a,part:r,stats:d})}}}}}}}},i.hls=t,i.bwEstimator=i.initEstimator(),i.registerListeners(),i}return ue(e,KM),ne(e,[{key:"resetEstimator",value:function(e){e&&(this.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}},{key:"initEstimator",value:function(){var e=this.hls.config;return new zM(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}},{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.FRAG_LOADING,this.onFragLoading,this),e.on(_M.FRAG_LOADED,this.onFragLoaded,this),e.on(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.FRAG_LOADING,this.onFragLoading,this),e.off(_M.FRAG_LOADED,this.onFragLoaded,this),e.off(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_M.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(_M.ERROR,this.onError,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}},{key:"onManifestLoading",value:function(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}},{key:"onLevelsUpdated",value:function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}},{key:"onMaxAutoLevelUpdated",value:function(){this.firstSelection=-1,this.nextAutoLevelKey=""}},{key:"onFragLoading",value:function(e,t){var i=t.frag;if(!this.ignoreFragment(i)){var n;if(!i.bitrateTest)this.fragCurrent=i,this.partCurrent=null!=(n=t.part)?n:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}},{key:"onLevelSwitching",value:function(e,t){this.clearTimer()}},{key:"onError",value:function(e,t){if(!t.fatal)switch(t.details){case LM.BUFFER_ADD_CODEC_ERROR:case LM.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case LM.FRAG_LOAD_TIMEOUT:var i=t.frag,n=this.fragCurrent,a=this.partCurrent;if(i&&n&&i.sn===n.sn&&i.level===n.level){var r=performance.now(),o=a?a.stats:i.stats,s=r-o.loading.start,u=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&u>-1){var l=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(s-Math.min(l,u),o.loaded)}else this.bwEstimator.sampleTTFB(s)}}}},{key:"getTimeToLoadFrag",value:function(e,t,i,n){return e+i/t+(n?e+this.lastLevelLoadSec:0)}},{key:"onLevelLoaded",value:function(e,t){var i=this.hls.config,n=t.stats.loading,a=n.end-n.first;DM(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(t.levelInfo)}},{key:"onFragLoaded",value:function(e,{frag:t,part:i}){var n=i?i.stats:t.stats;if(t.type===$M&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:t.duration,r=this.hls.levels[t.level],o=(r.loaded?r.loaded.bytes:0)+n.loaded,s=(r.loaded?r.loaded.duration:0)+a;r.loaded={bytes:o,duration:s},r.realBitrate=Math.round(8*o/s)}if(t.bitrateTest){var u={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(_M.FRAG_BUFFERED,u),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=null!=n&&n.stats.loaded?n.stats:i.stats;if(!a.aborted&&!this.ignoreFragment(i)){var r=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(r,a.loaded),a.bwEstimate=this.getBwEstimate(),i.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}}},{key:"ignoreFragment",value:function(e){return e.type!==$M||"initSegment"===e.sn}},{key:"clearTimer",value:function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}},{key:"firstAutoLevel",get:function(){var e=this.hls,t=e.maxAutoLevel,i=e.minAutoLevel,n=this.getBwEstimate(),a=this.hls.config.maxStarvationDelay,r=this.findBestLevel(n,i,t,0,a,1,1);if(r>-1)return r;var o=this.hls.firstLevel,s=Math.min(Math.max(o,i),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${o} clamped to ${s}`),s}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),i=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&i&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;var n=t&&i?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){var a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n},set:function(e){var t=this.deriveNextAutoLevel(e);this._nextAutoLevel!==t&&(this.nextAutoLevelKey="",this._nextAutoLevel=t)}},{key:"getAutoLevelKey",value:function(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}},{key:"getNextABRAutoLevel",value:function(){var e=this.fragCurrent,t=this.partCurrent,i=this.hls;if(i.levels.length<=1)return i.loadLevel;var n=i.maxAutoLevel,a=i.config,r=i.minAutoLevel,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),u=this.getStarvationDelay(),l=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;if(u){var h=this.findBestLevel(s,r,n,u,0,l,d);if(h>=0)return this.rebufferNotice=-1,h}var c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!u){var m=this.bitrateTestDelay;if(m)c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-m,this.info(`bitrate test took ${Math.round(1e3*m)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),l=d=1}var f=this.findBestLevel(s,r,n,u,c,l,d);if(this.rebufferNotice!==f&&(this.rebufferNotice=f,this.info(`${u?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`)),f>-1)return f;var v=i.levels[r],p=i.loadLevelObj;return p&&(null==v?void 0:v.bitrate)<p.bitrate?r:i.loadLevel}},{key:"getStarvationDelay",value:function(){var e=this.hls,t=e.media;if(!t)return 1/0;var i=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,n=e.mainForwardBufferInfo;return(n?n.len:0)/i}},{key:"getBwEstimate",value:function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}},{key:"findBestLevel",value:function(e,t,i,n,a,r,o){var s,u=this,l=n+a,d=this.lastLoadedFragLevel,h=-1===d?this.hls.firstLevel:d,c=this.fragCurrent,m=this.partCurrent,f=this.hls,v=f.levels,p=f.allAudioTracks,g=f.loadLevel,y=f.config;if(1===v.length)return 0;var b,w=v[h],k=!(null==(s=this.hls.latestLevelDetails)||!s.live),S=-1===g||-1===d,E="SDR",M=(null==w?void 0:w.frameRate)||0,T=y.audioPreference,P=y.videoPreference,A=this.audioTracksByGroup||(this.audioTracksByGroup=xP(p)),D=-1;if(S){if(-1!==this.firstSelection)return this.firstSelection;var x=this.codecTiers||(this.codecTiers=function(e,t,i,n){return e.slice(i,n+1).reduce((e,i,n)=>{if(!i.codecSet)return e;var a=i.audioGroups,r=e[i.codecSet];r||(e[i.codecSet]=r={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:n,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),r.minBitrate=Math.min(r.minBitrate,i.bitrate);var o=Math.min(i.height,i.width);return r.minHeight=Math.min(r.minHeight,o),r.minFramerate=Math.min(r.minFramerate,i.frameRate),r.minIndex=Math.min(r.minIndex,n),r.maxScore=Math.max(r.maxScore,i.score),r.fragmentError+=i.fragmentError,r.videoRanges[i.videoRange]=(r.videoRanges[i.videoRange]||0)+1,a&&a.forEach(e=>{if(e){var i=t.groups[e];i&&(r.hasDefaultAudio=r.hasDefaultAudio||t.hasDefaultAudio?i.hasDefault:i.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(i.channels).forEach(e=>{r.channels[e]=(r.channels[e]||0)+i.channels[e]}))}}),e},{})}(v,A,t,i)),C=function(e,t,i,n,a){for(var r=Object.keys(e),o=null==n?void 0:n.channels,s=null==n?void 0:n.audioCodec,u=null==a?void 0:a.videoCodec,l=o&&2===parseInt(o),d=!1,h=!1,c=1/0,m=1/0,f=1/0,v=1/0,p=0,g=[],y=PP(t,a),b=y.preferHDR,w=y.allowedVideoRanges,k=function(){var t=e[r[S]];d||(d=t.channels[2]>0),c=Math.min(c,t.minHeight),m=Math.min(m,t.minFramerate),f=Math.min(f,t.minBitrate),w.filter(e=>t.videoRanges[e]>0).length>0&&(h=!0)},S=r.length;S--;)k();c=DM(c)?c:0,m=DM(m)?m:0;var E=Math.max(1080,c),M=Math.max(30,m);f=DM(f)?f:i,i=Math.max(f,i),h||(t=void 0);var T=r.length>1;return{codecSet:r.reduce((t,n)=>{var a=e[n];if(n===t)return t;if(g=h?w.filter(e=>a.videoRanges[e]>0):[],T){if(a.minBitrate>i)return DP(n,`min bitrate of ${a.minBitrate} > current estimate of ${i}`),t;if(!a.hasDefaultAudio)return DP(n,"no renditions with default or auto-select sound found"),t;if(s&&n.indexOf(s.substring(0,4))%5!=0)return DP(n,`audio codec preference "${s}" not found`),t;if(o&&!l){if(!a.channels[o])return DP(n,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||l)&&d&&0===a.channels[2])return DP(n,"no renditions with stereo sound found"),t;if(a.minHeight>E)return DP(n,`min resolution of ${a.minHeight} > maximum of ${E}`),t;if(a.minFramerate>M)return DP(n,`min framerate of ${a.minFramerate} > maximum of ${M}`),t;if(!g.some(e=>a.videoRanges[e]>0))return DP(n,`no variants with VIDEO-RANGE of ${AP(g)} found`),t;if(u&&n.indexOf(u.substring(0,4))%5!=0)return DP(n,`video codec preference "${u}" not found`),t;if(a.maxScore<p)return DP(n,`max score of ${a.maxScore} < selected max of ${p}`),t}return t&&(iP(n)>=iP(t)||a.fragmentError>e[t].fragmentError)?t:(v=a.minIndex,p=a.maxScore,n)},void 0),videoRanges:g,preferHDR:b,minFramerate:m,minBitrate:f,minIndex:v}}(x,E,e,T,P),I=C.codecSet,L=C.videoRanges,_=C.minFramerate,R=C.minBitrate,F=C.minIndex,W=C.preferHDR;D=F,b=I,E=W?L[L.length-1]:L[0],M=_,e=Math.max(e,R),this.log(`picked start tier ${AP(C)}`)}else b=null==w?void 0:w.codecSet,E=null==w?void 0:w.videoRange;for(var O,$,N=m?m.duration:c?c.duration:0,j=this.bwEstimator.getEstimateTTFB()/1e3,B=[],z=function(){var t=v[U],s=U>h;if(!t)return 0;if(y.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){var c=navigator.mediaCapabilities;"function"==typeof(null==c?void 0:c.decodingInfo)&&function(e,t,i,n,a,r){var o=e.videoCodec,s=e.audioCodec?e.audioGroups:null,u=null==r?void 0:r.audioCodec,l=null==r?void 0:r.channels,d=l?parseInt(l):u?1/0:2,h=null;if(null!=s&&s.length)try{h=1===s.length&&s[0]?t.groups[s[0]].channels:s.reduce((e,i)=>{if(i){var n=t.groups[i];if(!n)throw new Error(`Audio track group ${i} not found`);Object.keys(n.channels).forEach(t=>{e[t]=(e[t]||0)+n.channels[t]})}return e},{2:0})}catch(e){return!0}return void 0!==o&&(o.split(",").some(e=>UT(e))||e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(n,30)||"SDR"!==e.videoRange&&e.videoRange!==i||e.bitrate>Math.max(a,8e6))||!!h&&DM(d)&&Object.keys(h).some(e=>parseInt(e)>d)}(t,A,E,M,e,T)?(t.supportedPromise=fP(t,A,c,u.supportedCache),t.supportedPromise.then(e=>{if(u.hls){t.supportedResult=e;var i=u.hls.levels,n=i.indexOf(t);e.error?u.warn(`MediaCapabilities decodingInfo error: "${e.error}" for level ${n} ${AP(e)}`):e.supported?e.decodingInfoResults.some(e=>!1===e.smooth||!1===e.powerEfficient)&&u.log(`MediaCapabilities decodingInfo for level ${n} not smooth or powerEfficient: ${AP(e)}`):(u.warn(`Unsupported MediaCapabilities decodingInfo result for level ${n} ${AP(e)}`),n>-1&&i.length>1&&(u.log(`Removing unsupported level ${n}`),u.hls.removeLevel(n),-1===u.hls.loadLevel&&(u.hls.nextLoadLevel=0)))}}).catch(e=>{u.warn(`Error handling MediaCapabilities decodingInfo: ${e}`)})):t.supportedResult=cP}if((b&&t.codecSet!==b||E&&t.videoRange!==E||s&&M>t.frameRate||!s&&M>0&&M<t.frameRate||null!=(O=t.supportedResult)&&null!=(O=O.decodingInfoResults)&&O.some(e=>!1===e.smooth))&&(!S||U!==D))return B.push(U),0;var f,p=t.details,w=(m?null==p?void 0:p.partTarget:null==p?void 0:p.averagetargetduration)||N;f=s?o*e:r*e;var P=N&&n>=2*N&&0===a?t.averageBitrate:t.maxBitrate,x=u.getTimeToLoadFrag(j,f,P*w,void 0===p);if(f>=P&&(U===d||0===t.loadError&&0===t.fragmentError)&&(x<=j||!DM(x)||k&&!u.bitrateTestDelay||x<l)){var C=u.forcedAutoLevel;return U===g||-1!==C&&C===g||(B.length&&u.trace(`Skipped level(s) ${B.join(",")} of ${i} max with CODECS and VIDEO-RANGE:"${v[B[0]].codecs}" ${v[B[0]].videoRange}; not compatible with "${b}" ${E}`),u.info(`switch candidate:${h}->${U} adjustedbw(${Math.round(f)})-bitrate=${Math.round(f-P)} ttfb:${j.toFixed(1)} avgDuration:${w.toFixed(1)} maxFetchDuration:${l.toFixed(1)} fetchDuration:${x.toFixed(1)} firstSelection:${S} codecSet:${t.codecSet} videoRange:${t.videoRange} hls.loadLevel:${g}`)),S&&(u.firstSelection=U),{v:U}}},U=i;U>=t;U--)if(0!==($=z())&&$)return $.v;return-1}},{key:"deriveNextAutoLevel",value:function(e){var t=this.hls,i=t.maxAutoLevel,n=t.minAutoLevel;return Math.min(Math.max(e,n),i)}}])}(),OP=function(e,t){for(var i=0,n=e.length-1,a=null,r=null;i<=n;){var o=t(r=e[a=(i+n)/2|0]);if(o>0)i=a+1;else{if(!(o<0))return r;n=a-1}}return null};function $P(e,t,i=0,n=0,a=.005){var r=null;if(e){r=t[1+e.sn-t[0].sn]||null;var o=e.endDTS-i;o>0&&o<15e-7&&(i+=15e-7),r&&e.level!==r.level&&r.end<=e.end&&(r=t[2+e.sn-t[0].sn]||null)}else 0===i&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===NP(i,n,r)||function(e,t,i){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){var n=t.tagList.reduce((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e),i);return e.start<=n}return!1}(r,e,Math.min(a,n))))return r;var s=OP(t,NP.bind(null,i,n));return!s||s===e&&r?r:s}function NP(e=0,t=0,i){if(i.start<=e&&i.start+i.duration>e)return 0;var n=Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return i.start+i.duration-n<=e?1:i.start-n>e&&i.start?-1:0}function jP(e,t,i){var n=1e3*Math.min(t,i.duration+(i.deltaPTS?i.deltaPTS:0));return(i.endProgramDateTime||0)-n>e}function BP(e,t,i){if(e&&e.startCC<=t&&e.endCC>=t){var n,a=e.fragments,r=e.fragmentHint;return r&&(a=a.concat(r)),OP(a,e=>e.cc<t?1:e.cc>t?-1:(n=e,e.end<=i?1:e.start>i?-1:0)),n||null}return null}function zP(e){switch(e.details){case LM.FRAG_LOAD_TIMEOUT:case LM.KEY_LOAD_TIMEOUT:case LM.LEVEL_LOAD_TIMEOUT:case LM.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function UP(e){return e.details.startsWith("key")}function HP(e){return UP(e)&&!!e.frag&&!e.frag.decryptdata}function GP(e,t){var i=zP(t);return e.default[(i?"timeout":"error")+"Retry"]}function VP(e,t){var i="linear"===e.backoff?1:Math.pow(2,t);return Math.min(i*e.retryDelayMs,e.maxRetryDelayMs)}function KP(e){return VM(VM({},e),{errorRetry:null,timeoutRetry:null})}function XP(e,t,i,n){if(!e)return!1;var a=null==n?void 0:n.code,r=t<e.maxNumRetry&&(function(e){return YP(e)||!!e&&(e<400||e>499)}(a)||!!i);return e.shouldRetry?e.shouldRetry(e,t,i,n,r):r}function YP(e){return 0===e&&!1===navigator.onLine}var qP=0,JP=2,QP=3,ZP=5,eA=0,tA=1,iA=2,nA=4,aA=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["error-controller",t.logger])).hls=void 0,i.playlistError=0,i.hls=t,i.registerListeners(),i}return ue(e,KM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.ERROR,this.onError,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.LEVEL_UPDATED,this.onLevelUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.ERROR,this.onError,this),e.off(_M.ERROR,this.onErrorOut,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.LEVEL_UPDATED,this.onLevelUpdated,this))}},{key:"destroy",value:function(){this.unregisterListeners(),this.hls=null}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.playlistError=0}},{key:"getVariantLevelIndex",value:function(e){return(null==e?void 0:e.type)===$M?e.level:this.getVariantIndex()}},{key:"getVariantIndex",value:function(){var e,t=this.hls,i=t.currentLevel;return null!=(e=t.loadLevelObj)&&e.details||-1===i?t.loadLevel:i}},{key:"variantHasKey",value:function(e,t){if(e){var i;if(null!=(i=e.details)&&i.hasKey(t))return!0;var n=e.audioGroups;if(n)return this.hls.allAudioTracks.filter(e=>n.indexOf(e.groupId)>=0).some(e=>{var i;return null==(i=e.details)?void 0:i.hasKey(t)})}return!1}},{key:"onManifestLoading",value:function(){this.playlistError=0}},{key:"onLevelUpdated",value:function(){this.playlistError=0}},{key:"onError",value:function(e,t){var i;if(!t.fatal){var n=this.hls,a=t.context;switch(t.details){case LM.FRAG_LOAD_ERROR:case LM.FRAG_LOAD_TIMEOUT:case LM.KEY_LOAD_ERROR:case LM.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case LM.FRAG_PARSING_ERROR:if(null!=(i=t.frag)&&i.gap)return void(t.errorAction=rA());case LM.FRAG_GAP:case LM.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=JP);case LM.LEVEL_EMPTY_ERROR:case LM.LEVEL_PARSING_ERROR:var r,o=t.parent===$M?t.level:n.loadLevel;return void(t.details===LM.LEVEL_EMPTY_ERROR&&null!=(r=t.context)&&null!=(r=r.levelDetails)&&r.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,o)));case LM.LEVEL_LOAD_ERROR:case LM.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level)));case LM.AUDIO_TRACK_LOAD_ERROR:case LM.AUDIO_TRACK_LOAD_TIMEOUT:case LM.SUBTITLE_LOAD_ERROR:case LM.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var s=n.loadLevelObj;if(s&&(a.type===WM&&s.hasAudioGroup(a.groupId)||a.type===OM&&s.hasSubtitleGroup(a.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=JP,void(t.errorAction.flags=tA)}return;case LM.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(t.errorAction={action:JP,flags:iA});case LM.KEY_SYSTEM_SESSION_UPDATE_FAILED:case LM.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case LM.KEY_SYSTEM_NO_SESSION:return void(t.errorAction={action:JP,flags:nA});case LM.BUFFER_ADD_CODEC_ERROR:case LM.REMUX_ALLOC_ERROR:case LM.BUFFER_APPEND_ERROR:var u;if(!t.errorAction)t.errorAction=this.getLevelSwitchAction(t,null!=(u=t.level)?u:n.loadLevel);return;case LM.INTERNAL_EXCEPTION:case LM.BUFFER_APPENDING_ERROR:case LM.BUFFER_FULL_ERROR:case LM.LEVEL_SWITCH_ERROR:case LM.BUFFER_STALLED_ERROR:case LM.BUFFER_SEEK_OVER_HOLE:case LM.BUFFER_NUDGE_ON_STALL:return void(t.errorAction=rA())}t.type===IM.KEY_SYSTEM_ERROR&&(t.levelRetry=!1,t.errorAction=rA())}}},{key:"getPlaylistRetryOrSwitchAction",value:function(e,t){var i=GP(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++;if(XP(i,n,zP(e),e.response))return{action:ZP,flags:eA,retryConfig:i,retryCount:n};var a=this.getLevelSwitchAction(e,t);return i&&(a.retryConfig=i,a.retryCount=n),a}},{key:"getFragRetryOrSwitchAction",value:function(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],a=t.config,r=a.fragLoadPolicy,o=a.keyLoadPolicy,s=GP(UP(e)?o:r,e),u=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(n&&(e.details!==LM.FRAG_GAP&&n.fragmentError++,!HP(e)&&XP(s,u,zP(e),e.response)))return{action:ZP,flags:eA,retryConfig:s,retryCount:u};var l=this.getLevelSwitchAction(e,i);return s&&(l.retryConfig=s,l.retryCount=u),l}},{key:"getLevelSwitchAction",value:function(e,t){var i=this.hls;null==t&&(t=i.loadLevel);var n=this.hls.levels[t];if(n){var a,r,o=e.details;n.loadError++,o===LM.BUFFER_APPEND_ERROR&&n.fragmentError++;var s=-1,u=i.levels,l=i.loadLevel,d=i.minAutoLevel,h=i.maxAutoLevel;i.autoLevelEnabled||i.config.preserveManualLevelOnError||(i.loadLevel=-1);for(var c,m,f,v=null==(a=e.frag)?void 0:a.type,p=(v===NM&&o===LM.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(o===LM.BUFFER_ADD_CODEC_ERROR||o===LM.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:e})=>n.audioCodec!==e),g="video"===e.sourceBufferName&&(o===LM.BUFFER_ADD_CODEC_ERROR||o===LM.BUFFER_APPEND_ERROR)&&u.some(({codecSet:e,audioCodec:t})=>n.codecSet!==e&&n.audioCodec===t),y=null!=(r=e.context)?r:{},b=y.type,w=y.groupId,k=function(){var t=(S+l)%u.length;if(t!==l&&t>=d&&t<=h&&0===u[t].loadError){var i=u[t];if(o===LM.FRAG_GAP&&v===$M&&e.frag){var a=u[t].details;if(a){var r=$P(e.frag,a.fragments,e.frag.start);if(null!=r&&r.gap)return 0}}else{if(b===WM&&i.hasAudioGroup(w)||b===OM&&i.hasSubtitleGroup(w))return 0;if(v===NM&&null!=(c=n.audioGroups)&&c.some(e=>i.hasAudioGroup(e))||v===jM&&null!=(m=n.subtitleGroups)&&m.some(e=>i.hasSubtitleGroup(e))||p&&n.audioCodec===i.audioCodec||g&&n.codecSet===i.codecSet||!p&&n.codecSet!==i.codecSet)return 0}return s=t,1}},S=u.length;S--&&(0===(f=k())||1!==f););if(s>-1&&i.loadLevel!==s)return e.levelRetry=!0,this.playlistError=0,{action:JP,flags:eA,nextAutoLevel:s}}return{action:JP,flags:tA}}},{key:"onErrorOut",value:function(e,t){var i;switch(null==(i=t.errorAction)?void 0:i.action){case qP:break;case JP:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===LM.FRAG_GAP?/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):t.fatal=!0}t.fatal&&this.hls.stopLoad()}},{key:"sendAlternateToPenaltyBox",value:function(e){var t=this.hls,i=e.errorAction;if(i){var n=i.flags,a=i.nextAutoLevel;switch(n){case eA:this.switchLevel(e,a);break;case iA:var r=this.getVariantLevelIndex(e.frag),o=t.levels[r],s=null==o?void 0:o.attrs["HDCP-LEVEL"];if(i.hdcpLevel=s,"NONE"===s)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(s){t.maxHdcpLevel=gP[gP.indexOf(s)-1],i.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}case nA:var u=e.decryptdata;if(u){for(var l=this.hls.levels,d=l.length,h=d;h--;){var c,m;if(this.variantHasKey(l[h],u))this.log(`Banned key found in level ${h} (${l[h].bitrate}bps) or audio group "${null==(c=l[h].audioGroups)?void 0:c.join(",")}" (${null==(m=e.frag)?void 0:m.type} fragment) ${nT(u.keyId||[])}`),l[h].fragmentError++,l[h].loadError++,this.log(`Removing level ${h} with key error (${e.error})`),this.hls.removeLevel(h)}var f=e.frag;if(this.hls.levels.length<d)i.resolved=!0;else if(f&&f.type!==$M){var v=f.decryptdata;v&&!u.matches(v)&&(i.resolved=!0)}}}i.resolved||this.switchLevel(e,a)}}},{key:"switchLevel",value:function(e,t){if(void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,e.details===LM.BUFFER_ADD_CODEC_ERROR&&e.mimeType&&"audiovideo"!==e.sourceBufferName))for(var i=dP(e.mimeType),n=this.hls.levels,a=n.length;a--;)n[a][`${e.sourceBufferName}Codec`]===i&&(this.log(`Removing level ${a} for ${e.details} ("${i}" not supported)`),this.hls.removeLevel(a))}}])}();function rA(e){var t={action:qP,flags:eA};return e&&(t.resolved=!0),t}var oA="NOT_LOADED",sA="APPENDING",uA="PARTIAL",lA="OK",dA=function(){return ne(function e(t){Q(this,e),this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()},[{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_M.FRAG_LOADED,this.onFragLoaded,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_M.FRAG_LOADED,this.onFragLoaded,this))}},{key:"destroy",value:function(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}},{key:"getAppendedFrag",value:function(e,t){var i=this.activePartLists[t];if(i)for(var n=i.length;n--;){var a=i[n];if(!a)break;if(a.start<=e&&e<=a.end&&a.loaded)return a}return this.getBufferedFrag(e,t)}},{key:"getBufferedFrag",value:function(e,t){return this.getFragAtPos(e,t,!0)}},{key:"getFragAtPos",value:function(e,t,i){for(var n=this.fragments,a=Object.keys(n),r=a.length;r--;){var o=n[a[r]];if((null==o?void 0:o.body.type)===t&&(!i||o.buffered)){var s=o.body;if(s.start<=e&&e<=s.end)return s}}return null}},{key:"detectEvictedFragments",value:function(e,t,i,n,a){this.timeRanges&&(this.timeRanges[e]=t);var r=(null==n?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(n=>{var o=this.fragments[n];if(o&&!(r>=o.body.sn))if(o.buffered||o.loaded&&!a){var s=o.range[e];s&&(0!==s.time.length?s.time.some(e=>{var i=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return i&&this.removeFragment(o.body),i}):this.removeFragment(o.body))}else o.body.type===i&&this.removeFragment(o.body)})}},{key:"detectPartialFragments",value:function(e){var t=this.timeRanges;if(t&&"initSegment"!==e.frag.sn){var i=e.frag,n=cA(i),a=this.fragments[n];if(!(!a||a.buffered&&i.gap)){var r=!i.relurl;Object.keys(t).forEach(n=>{var o=i.elementaryStreams[n];if(o){var s=t[n],u=r||!0===o.partial;a.range[n]=this.getBufferedTimes(i,e.part,u,s)}}),a.loaded=null,Object.keys(a.range).length?(this.bufferedEnd(a,i),hA(a)||this.removeParts(i.sn-1,i.type)):this.removeFragment(a.body)}}}},{key:"bufferedEnd",value:function(e,t){e.buffered=!0,(e.body.endList=t.endList||e.body.endList)&&(this.endListFragments[e.body.type]=e)}},{key:"removeParts",value:function(e,t){var i=this.activePartLists[t];i&&(this.activePartLists[t]=mA(i,t=>t.fragment.sn>=e))}},{key:"fragBuffered",value:function(e,t){var i=cA(e),n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,this.bufferedEnd(n,e))}},{key:"getBufferedTimes",value:function(e,t,i,n){for(var a={time:[],partial:i},r=e.start,o=e.end,s=e.minEndPTS||o,u=e.maxStartPTS||r,l=0;l<n.length;l++){var d=n.start(l)-this.bufferPadding,h=n.end(l)+this.bufferPadding;if(u>=d&&s<=h){a.time.push({startPTS:Math.max(r,n.start(l)),endPTS:Math.min(o,n.end(l))});break}if(r<h&&o>d){var c=Math.max(r,n.start(l)),m=Math.min(o,n.end(l));m>c&&(a.partial=!0,a.time.push({startPTS:c,endPTS:m}))}else if(o<=d)break}return a}},{key:"getPartialFragment",value:function(e){var t,i,n,a=null,r=0,o=this.bufferPadding,s=this.fragments;return Object.keys(s).forEach(u=>{var l=s[u];l&&hA(l)&&(i=l.body.start-o,n=l.body.end+o,e>=i&&e<=n&&(t=Math.min(e-i,n-e),r<=t&&(a=l.body,r=t)))}),a}},{key:"isEndListAppended",value:function(e){var t=this.endListFragments[e];return void 0!==t&&(t.buffered||hA(t))}},{key:"getState",value:function(e){var t=cA(e),i=this.fragments[t];return i?i.buffered?hA(i)?uA:lA:sA:oA}},{key:"isTimeBuffered",value:function(e,t,i){for(var n,a,r=0;r<i.length;r++){if(n=i.start(r)-this.bufferPadding,a=i.end(r)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}},{key:"onManifestLoading",value:function(){this.removeAllFragments()}},{key:"onFragLoaded",value:function(e,t){if("initSegment"!==t.frag.sn&&!t.frag.bitrateTest){var i=t.frag,n=t.part?null:t,a=cA(i);this.fragments[a]={body:i,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}}},{key:"onBufferAppended",value:function(e,t){var i=t.frag,n=t.part,a=t.timeRanges,r=t.type;if("initSegment"!==i.sn){var o=i.type;if(n){var s=this.activePartLists[o];s||(this.activePartLists[o]=s=[]),s.push(n)}this.timeRanges=a;var u=a[r];this.detectEvictedFragments(r,u,o,n)}}},{key:"onFragBuffered",value:function(e,t){this.detectPartialFragments(t)}},{key:"hasFragment",value:function(e){var t=cA(e);return!!this.fragments[t]}},{key:"hasFragments",value:function(e){var t=this.fragments,i=Object.keys(t);if(!e)return i.length>0;for(var n=i.length;n--;){var a=t[i[n]];if((null==a?void 0:a.body.type)===e)return!0}return!1}},{key:"hasParts",value:function(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}},{key:"removeFragmentsInRange",value:function(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(r=>{var o=this.fragments[r];if(o){var s=o.body;s.type!==i||n&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}})}},{key:"removeFragment",value:function(e){var t=cA(e);e.clearElementaryStreamInfo();var i=this.activePartLists[e.type];if(i){var n=e.sn;this.activePartLists[e.type]=mA(i,e=>e.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}},{key:"removeAllFragments",value:function(){var e;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;var t=null==(e=this.hls)||null==(e=e.latestLevelDetails)?void 0:e.partList;t&&t.forEach(e=>e.clearElementaryStreamInfo())}}])}();function hA(e){var t,i,n;return e.buffered&&!!(e.body.gap||null!=(t=e.range.video)&&t.partial||null!=(i=e.range.audio)&&i.partial||null!=(n=e.range.audiovideo)&&n.partial)}function cA(e){return`${e.type}_${e.level}_${e.sn}`}function mA(e,t){return e.filter(e=>{var i=t(e);return i||e.clearElementaryStreamInfo(),i})}var fA=0,vA=1,pA=function(){return ne(function e(t,i,n){Q(this,e),this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=i,this.aesMode=n},[{key:"decrypt",value:function(e,t){switch(this.aesMode){case fA:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case vA:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}])}();var gA=function(){return ne(function e(){Q(this,e),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()},[{key:"uint8ArrayToUint32Array_",value:function(e){for(var t=new DataView(e),i=new Uint32Array(4),n=0;n<4;n++)i[n]=t.getUint32(4*n);return i}},{key:"initTable",value:function(){var e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],r=i[2],o=i[3],s=this.invSubMix,u=s[0],l=s[1],d=s[2],h=s[3],c=new Uint32Array(256),m=0,f=0,v=0;for(v=0;v<256;v++)c[v]=v<128?v<<1:v<<1^283;for(v=0;v<256;v++){var p=f^f<<1^f<<2^f<<3^f<<4;p=p>>>8^255&p^99,e[m]=p,t[p]=m;var g=c[m],y=c[g],b=c[y],w=257*c[p]^16843008*p;n[m]=w<<24|w>>>8,a[m]=w<<16|w>>>16,r[m]=w<<8|w>>>24,o[m]=w,w=16843009*b^65537*y^257*g^16843008*m,u[p]=w<<24|w>>>8,l[p]=w<<16|w>>>16,d[p]=w<<8|w>>>24,h[p]=w,m?(m=g^c[c[c[b^g]]],f^=c[c[f]]):m=f=1}}},{key:"expandKey",value:function(e){for(var t=this.uint8ArrayToUint32Array_(e),i=!0,n=0;n<t.length&&i;)i=t[n]===this.key[n],n++;if(!i){this.key=t;var a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);var r,o,s,u,l=this.ksRows=4*(a+6+1),d=this.keySchedule=new Uint32Array(l),h=this.invKeySchedule=new Uint32Array(l),c=this.sBox,m=this.rcon,f=this.invSubMix,v=f[0],p=f[1],g=f[2],y=f[3];for(r=0;r<l;r++)r<a?s=d[r]=t[r]:(u=s,r%a===0?(u=c[(u=u<<8|u>>>24)>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u],u^=m[r/a|0]<<24):a>6&&r%a===4&&(u=c[u>>>24]<<24|c[u>>>16&255]<<16|c[u>>>8&255]<<8|c[255&u]),d[r]=s=(d[r-a]^u)>>>0);for(o=0;o<l;o++)r=l-o,u=3&o?d[r]:d[r-4],h[o]=o<4||r<=4?u:v[c[u>>>24]]^p[c[u>>>16&255]]^g[c[u>>>8&255]]^y[c[255&u]],h[o]=h[o]>>>0}}},{key:"networkToHostOrderSwap",value:function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}},{key:"decrypt",value:function(e,t,i){for(var n,a,r,o,s,u,l,d,h,c,m,f,v,p,g=this.keySize+6,y=this.invKeySchedule,b=this.invSBox,w=this.invSubMix,k=w[0],S=w[1],E=w[2],M=w[3],T=this.uint8ArrayToUint32Array_(i),P=T[0],A=T[1],D=T[2],x=T[3],C=new Int32Array(e),I=new Int32Array(C.length),L=this.networkToHostOrderSwap;t<C.length;){for(h=L(C[t]),c=L(C[t+1]),m=L(C[t+2]),f=L(C[t+3]),s=h^y[0],u=f^y[1],l=m^y[2],d=c^y[3],v=4,p=1;p<g;p++)n=k[s>>>24]^S[u>>16&255]^E[l>>8&255]^M[255&d]^y[v],a=k[u>>>24]^S[l>>16&255]^E[d>>8&255]^M[255&s]^y[v+1],r=k[l>>>24]^S[d>>16&255]^E[s>>8&255]^M[255&u]^y[v+2],o=k[d>>>24]^S[s>>16&255]^E[u>>8&255]^M[255&l]^y[v+3],s=n,u=a,l=r,d=o,v+=4;n=b[s>>>24]<<24^b[u>>16&255]<<16^b[l>>8&255]<<8^b[255&d]^y[v],a=b[u>>>24]<<24^b[l>>16&255]<<16^b[d>>8&255]<<8^b[255&s]^y[v+1],r=b[l>>>24]<<24^b[d>>16&255]<<16^b[s>>8&255]<<8^b[255&u]^y[v+2],o=b[d>>>24]<<24^b[s>>16&255]<<16^b[u>>8&255]<<8^b[255&l]^y[v+3],I[t]=L(n^P),I[t+1]=L(o^A),I[t+2]=L(r^D),I[t+3]=L(a^x),P=h,A=c,D=m,x=f,t+=4}return I.buffer}}])}(),yA=function(){return ne(function e(t,i,n){Q(this,e),this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=i,this.aesMode=n},[{key:"expandKey",value:function(){var e=function(e){switch(e){case fA:return"AES-CBC";case vA:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${e}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])}}])}();var bA=function(){return ne(function e(t,{removePKCS7Padding:i=!0}={}){if(Q(this,e),this.logEnabled=!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.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=i,i)try{var n=self.crypto;n&&(this.subtle=n.subtle||n.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle},[{key:"destroy",value:function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}},{key:"isSync",value:function(){return this.useSoftware}},{key:"flush",value:function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var i,n,a,r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(n=(i=r).byteLength,(a=n&&new DataView(i.buffer).getUint8(n-1))?i.slice(0,n-a):i):r}},{key:"reset",value:function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}},{key:"decrypt",value:function(e,t,i,n){return this.useSoftware?new Promise((a,r)=>{var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.softwareDecrypt(o,t,i,n);var s=this.flush();s?a(s.buffer):r(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i,n)}},{key:"softwareDecrypt",value:function(e,t,i,n){var a=this.currentIV,r=this.currentResult,o=this.remainderData;if(n!==fA||16!==t.byteLength)return ZM.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),o&&(e=BT(o,e),this.remainderData=null);var s=this.getValidChunk(e);if(!s.length)return null;a&&(i=a);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new gA),u.expandKey(t);var l=r;return this.currentResult=u.decrypt(s.buffer,0,i),this.currentIV=s.slice(-16).buffer,l||null}},{key:"webCryptoDecrypt",value:function(e,t,i,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,i,n));this.key=t,this.fastAesKey=new yA(this.subtle,t,n)}return this.fastAesKey.expandKey().then(t=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new pA(this.subtle,new Uint8Array(i),n).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(ZM.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i,n)))}},{key:"onWebCryptoError",value:function(e,t,i,n){var a=this.enableSoftwareAES;if(a){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i,n);var r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(a?" and softwareDecrypt":"")+": failed to decrypt data")}},{key:"getValidChunk",value:function(e){var t=e,i=e.length-e.length%16;return i!==e.length&&(t=e.slice(0,i),this.remainderData=e.slice(i)),t}},{key:"logOnce",value:function(e){this.logEnabled&&(ZM.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}])}(),wA=Math.pow(2,17),kA=function(){return ne(function e(t){Q(this,e),this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t},[{key:"destroy",value:function(){this.loader&&(this.loader.destroy(),this.loader=null)}},{key:"abort",value:function(){this.loader&&this.loader.abort()}},{key:"load",value:function(e,t){var i=e.url;if(!i)return Promise.reject(new MA({type:IM.NETWORK_ERROR,details:LM.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(i?"part list":"url")),networkDetails:null}));this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void s(EA(e));e.gap=!1}var u=this.loader=a?new a(n):new r(n),l=SA(e);e.loader=u;var d=KP(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:wA};e.stats=u.stats;var c={onSuccess:(t,i,n,a)=>{this.resetLoader(e,u);var r=t.data;n.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),o({frag:e,part:null,payload:r,networkDetails:a})},onError:(t,n,a,r)=>{this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:VM({url:i,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,i,n)=>{this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:n,stats:t}))},onTimeout:(t,i,n)=>{this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:n,stats:t}))}};t&&(c.onProgress=(i,n,a,r)=>t({frag:e,part:null,payload:a,networkDetails:r})),u.load(l,h,c)})}},{key:"loadPart",value:function(e,t,i){this.abort();var n=this.config,a=n.fLoader,r=n.loader;return new Promise((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)s(EA(e,t));else{var u=this.loader=a?new a(n):new r(n),l=SA(e,t);e.loader=u;var d=KP(n.fragLoadPolicy.default),h={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:wA};t.stats=u.stats,u.load(l,h,{onSuccess:(n,a,r,s)=>{this.resetLoader(e,u),this.updateStatsFromPart(e,t);var l={frag:e,part:t,payload:n.data,networkDetails:s};i(l),o(l)},onError:(i,n,a,r)=>{this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:VM({url:l.url,data:void 0},i),error:new Error(`HTTP Error ${i.code} ${i.text}`),networkDetails:a,stats:r}))},onAbort:(i,n,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:i}))},onTimeout:(i,n,a)=>{this.resetLoader(e,u),s(new MA({type:IM.NETWORK_ERROR,details:LM.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:a,stats:i}))}})}})}},{key:"updateStatsFromPart",value:function(e,t){var i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){var r=Math.round(e.duration/t.duration),o=Math.min(Math.round(i.loaded/a),r),s=(r-o)*Math.round(i.loaded/o);i.total=i.loaded+s}else i.total=Math.max(i.loaded,i.total);var u=i.loading,l=n.loading;u.start?u.first+=l.first-l.start:(u.start=l.start,u.first=l.first),u.end=l.end}},{key:"resetLoader",value:function(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}])}();function SA(e,t=null){var i,n=t||e,a={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},r=n.byteRangeStartOffset,o=n.byteRangeEndOffset;if(DM(r)&&DM(o)){var s,u=r,l=o;if("initSegment"===e.sn&&("AES-128"===(i=null==(s=e.decryptdata)?void 0:s.method)||"AES-256"===i)){var d=o-r;d%16&&(l=o+(16-d%16)),0!==r&&(a.resetIV=!0,u=r-16)}a.rangeStart=u,a.rangeEnd=l}return a}function EA(e,t){var i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),n={type:IM.MEDIA_ERROR,details:LM.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(n.part=t),(t||e).stats.aborted=!0,new MA(n)}var MA=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t.error.message])).data=void 0,i.data=t,i}return ue(e,ye(Error)),ne(e)}(),TA=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[t,i]))._boundTick=void 0,n._tickTimer=null,n._tickInterval=null,n._tickCallCount=0,n._boundTick=n.tick.bind(n),n}return ue(e,KM),ne(e,[{key:"destroy",value:function(){this.onHandlerDestroying(),this.onHandlerDestroyed()}},{key:"onHandlerDestroying",value:function(){this.clearNextTick(),this.clearInterval()}},{key:"onHandlerDestroyed",value:function(){}},{key:"hasInterval",value:function(){return!!this._tickInterval}},{key:"hasNextTick",value:function(){return!!this._tickTimer}},{key:"setInterval",value:function(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}},{key:"clearInterval",value:function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}},{key:"clearNextTick",value:function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}},{key:"tick",value:function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}},{key:"tickImmediate",value:function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}},{key:"doTick",value:function(){}}])}(),PA=ne(function e(t,i,n,a=0,r=-1,o=!1){Q(this,e),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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=a,this.part=r,this.partial=o});var AA={length:0,start:()=>0,end:()=>0},DA=function(){function e(){Q(this,e)}return ne(e,null,[{key:"isBuffered",value:function(t,i){if(t)for(var n=e.getBuffered(t),a=n.length;a--;)if(i>=n.start(a)&&i<=n.end(a))return!0;return!1}},{key:"bufferedRanges",value:function(t){if(t){var i=e.getBuffered(t);return e.timeRangesToArray(i)}return[]}},{key:"timeRangesToArray",value:function(e){for(var t=[],i=0;i<e.length;i++)t.push({start:e.start(i),end:e.end(i)});return t}},{key:"bufferInfo",value:function(t,i,n){if(t){var a=e.bufferedRanges(t);if(a.length)return e.bufferedInfo(a,i,n)}return{len:0,start:i,end:i,bufferedIndex:-1}}},{key:"bufferedInfo",value:function(e,t,i){t=Math.max(0,t),e.length>1&&e.sort((e,t)=>e.start-t.start||t.end-e.end);var n=-1,a=[];if(i)for(var r=0;r<e.length;r++){t>=e[r].start&&t<=e[r].end&&(n=r);var o=a.length;if(o){var s=a[o-1].end;e[r].start-s<i?e[r].end>s&&(a[o-1].end=e[r].end):a.push(e[r])}else a.push(e[r])}else a=e;for(var u,l=0,d=t,h=t,c=0;c<a.length;c++){var m=a[c].start,f=a[c].end;if(-1===n&&t>=m&&t<=f&&(n=c),t+i>=m&&t<f)d=m,l=(h=f)-t;else if(t+i<m){u=m;break}}return{len:l,start:d||0,end:h||0,nextStart:u,buffered:e,bufferedIndex:n}}},{key:"getBuffered",value:function(e){try{return e.buffered||AA}catch(e){return ZM.log("failed to get media.buffered",e),AA}}}])}(),xA=/\{\$([a-zA-Z0-9-_]+)\}/g;function CA(e){return xA.test(e)}function IA(e,t){if(null!==e.variableList||e.hasVariableRefs){var i=e.variableList;return t.replace(xA,t=>{var n=t.substring(2,t.length-1),a=null==i?void 0:i[n];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),t):a})}return t}function LA(e,t,i){var n,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){n=t.QUERYPARAM;try{var o=new self.URL(i).searchParams;if(!o.has(n))throw new Error(`"${n}" does not match any query parameter in URI: "${i}"`);a=o.get(n)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else n=t.NAME,a=t.VALUE;n in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):r[n]=a||""}function _A(e,t,i){var n=t.IMPORT;if(i&&n in i){var a=e.variableList;a||(e.variableList=a={}),a[n]=i[n]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${n}"`))}var RA=/^(\d+)x(\d+)$/,FA=/(.+?)=(".*?"|.*?)(?:,|$)/g,WA=function(){return ne(function e(t,i){Q(this,e),"string"==typeof t&&(t=e.parseAttrList(t,i)),HM(this,t)},[{key:"clientAttrs",get:function(){return Object.keys(this).filter(e=>"X-"===e.substring(0,2))}},{key:"decimalInteger",value:function(e){var t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"hexadecimalInteger",value:function(e){if(this[e]){var t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;for(var i=new Uint8Array(t.length/2),n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(2*n,2*n+2),16);return i}return null}},{key:"hexadecimalIntegerAsNumber",value:function(e){var t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}},{key:"decimalFloatingPoint",value:function(e){return parseFloat(this[e])}},{key:"optionalFloat",value:function(e,t){var i=this[e];return i?parseFloat(i):t}},{key:"enumeratedString",value:function(e){return this[e]}},{key:"enumeratedStringList",value:function(e,t){var i=this[e];return(i?i.split(/[ ,]+/):[]).reduce((e,t)=>(e[t.toLowerCase()]=!0,e),t)}},{key:"bool",value:function(e){return"YES"===this[e]}},{key:"decimalResolution",value:function(e){var t=RA.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}}],[{key:"parseAttrList",value:function(e,t){var i,n={};for(FA.lastIndex=0;null!==(i=FA.exec(e));){var a=i[1].trim(),r=i[2],o=0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1,s=!1;if(o)r=r.slice(1,-1);else switch(a){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":s=!0}if(t&&(o||s))r=IA(t,r);else if(!s&&!o)switch(a){case"CLOSED-CAPTIONS":if("NONE"===r)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":ZM.warn(`${e}: attribute ${a} is missing quotes`)}n[a]=r}return n}}])}();function OA(e){return"ID"!==e&&"CLASS"!==e&&"CUE"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function $A(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e||"SCTE35-CMD"===e}var NA=function(){return ne(function e(t,i,n=0){var a;if(Q(this,e),this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==i?void 0:i.tagAnchor)||null,this.tagOrder=null!=(a=null==i?void 0:i.tagOrder)?a:n,i){var r=i.attr;for(var o in r)if(Object.prototype.hasOwnProperty.call(t,o)&&t[o]!==r[o]){ZM.warn(`DATERANGE tag attribute: "${o}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=o;break}t=HM(new WA({}),r,t)}if(this.attr=t,i?(this._startDate=i._startDate,this._cue=i._cue,this._endDate=i._endDate,this._dateAtEnd=i._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var s=(null==i?void 0:i.endDate)||new Date(this.attr["END-DATE"]);DM(s.getTime())&&(this._endDate=s)}},[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"cue",get:function(){var e=this._cue;return void 0===e?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):e}},{key:"startTime",get:function(){var e=this.tagAnchor;return null===e||null===e.programDateTime?(ZM.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${e}`),NaN):e.start+(this.startDate.getTime()-e.programDateTime)/1e3}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){var e=this._endDate||this._dateAtEnd;if(e)return e;var t=this.duration;return null!==t?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(DM(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isInterstitial",get:function(){return"com.apple.hls.interstitial"===this.class}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&DM(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}])}(),jA=function(){return ne(function e(t){Q(this,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.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,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.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t},[{key:"reloaded",value:function(e){if(!e)return this.advanced=!0,void(this.updated=!0);var t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&i>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1}},{key:"hasKey",value:function(e){return this.encryptedFragments.some(t=>{var i=t.decryptdata;return i||(t.setKeyFormat(e.keyFormat),i=t.decryptdata),!!i&&e.matches(i)})}},{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&DM(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}},{key:"fragmentStart",get:function(){return this.fragments.length?this.fragments[0].start:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}},{key:"maxPartIndex",get:function(){var e=this.partList;if(e){var t=this.lastPartIndex;if(-1!==t){for(var i=e.length;i--;)if(e[i].index>t)return e[i].index;return t}}return 0}},{key:"lastPartSn",get:function(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}},{key:"expired",get:function(){if(this.live&&this.age&&this.misses<3){var e=this.partEnd-this.fragmentStart;return this.age>Math.max(e,this.totalduration)+this.levelTargetDuration}return!1}}])}();function BA(e,t){return e.length===t.length&&!e.some((e,i)=>e!==t[i])}function zA(e,t){return!e&&!t||!(!e||!t)&&BA(e,t)}function UA(e){return"AES-128"===e||"AES-256"===e||"AES-256-CTR"===e}function HA(e){switch(e){case"AES-128":case"AES-256":return fA;case"AES-256-CTR":return vA;default:throw new Error(`invalid full segment method ${e}`)}}function GA(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function VA(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}function KA(e){var t=function(e,t,i){var n=e[t];e[t]=e[i],e[i]=n};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function XA(e){var t,i,n=e.split(":"),a=null;if("data"===n[0]&&2===n.length){var r=n[1].split(";"),o=r[r.length-1].split(",");if(2===o.length){var s="base64"===o[0],u=o[1];s?(r.splice(-1,1),a=GA(u)):(t=VA(u).subarray(0,16),(i=new Uint8Array(16)).set(t,16-t.length),a=i)}}return a}var YA="undefined"!=typeof self?self:void 0,qA={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},JA="org.w3.clearkey",QA="com.apple.streamingkeydelivery",ZA="com.microsoft.playready",eD="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function tD(e){switch(e){case QA:return qA.FAIRPLAY;case ZA:return qA.PLAYREADY;case eD:return qA.WIDEVINE;case JA:return qA.CLEARKEY}}function iD(e){switch(e){case qA.FAIRPLAY:return QA;case qA.PLAYREADY:return ZA;case qA.WIDEVINE:return eD;case qA.CLEARKEY:return JA}}function nD(e){var t=e.drmSystems,i=e.widevineLicenseUrl,n=t?[qA.FAIRPLAY,qA.WIDEVINE,qA.PLAYREADY,qA.CLEARKEY].filter(e=>!!t[e]):[];return!n[qA.WIDEVINE]&&i&&n.push(qA.WIDEVINE),n}var aD,rD=null!=YA&&null!=(aD=YA.navigator)&&aD.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function oD(e){var t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=String.fromCharCode.apply(null,Array.from(t)),n=i.substring(i.indexOf("<"),i.length),a=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];if(a){var r=a.childNodes[0]?a.childNodes[0].nodeValue:a.getAttribute("VALUE");if(r){var o=GA(r).subarray(0,16);return KA(o),o}}return null}var sD={},uD=function(){function e(t,i,n,a=[1],r=null,o){Q(this,e),this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=i,this.keyFormat=n,this.keyFormatVersions=a,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!UA(t),null!=o&&o.startsWith("0x")&&(this.keyId=new Uint8Array(aT(o)))}return ne(e,[{key:"matches",value:function(e){return e.uri===this.uri&&e.method===this.method&&e.encrypted===this.encrypted&&e.keyFormat===this.keyFormat&&BA(e.keyFormatVersions,this.keyFormatVersions)&&zA(e.iv,this.iv)&&zA(e.keyId,this.keyId)}},{key:"isSupported",value:function(){if(this.method){if(UA(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case QA:case eD:case ZA:case JA:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}},{key:"getDecryptData",value:function(t,i){if(!this.encrypted||!this.uri)return null;if(UA(this.method)){var n=this.iv;return n||("number"!=typeof t&&(ZM.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),n=function(e){for(var t=new Uint8Array(16),i=12;i<16;i++)t[i]=e>>8*(15-i)&255;return t}(t)),new e(this.method,this.uri,"identity",this.keyFormatVersions,n)}if(this.keyId){var a=sD[this.uri];if(a&&!BA(this.keyId,a)&&e.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}var r,o=XA(this.uri);if(o)switch(this.keyFormat){case eD:if(this.pssh=o,!this.keyId){var s=function(e){var t=[];if(e instanceof ArrayBuffer)for(var i=e.byteLength,n=0;n+32<i;){var a=XT(new DataView(e,n));t.push(a),n+=a.size}return t}(o.buffer);if(s.length){var u,l=s[0];this.keyId=null!=(u=l.kids)&&u.length?l.kids[0]:null}}this.keyId||(this.keyId=lD(i));break;case ZA:var d=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=KT(d,0,o),this.keyId=oD(o);break;default:var h=o.subarray(0,16);if(16!==h.length){var c=new Uint8Array(16);c.set(h,16-h.length),h=c}this.keyId=h}this.keyId&&16===this.keyId.byteLength||(r=function(e){var t=null==e?void 0:e[eD];if(t)return t.keyId;return null}(i),r||(r=lD(i))||(r=sD[this.uri]),r&&(this.keyId=r,e.setKeyIdForUri(this.uri,r)));return this}}],[{key:"clearKeyUriToKeyIdMap",value:function(){sD={}}},{key:"setKeyIdForUri",value:function(e,t){sD[e]=t}},{key:"addKeyIdForUri",value:function(e){var t=Object.keys(sD).length%Number.MAX_SAFE_INTEGER,i=new Uint8Array(16);return new DataView(i.buffer,12,4).setUint32(0,t),sD[e]=i,i}}])}();function lD(e){var t=null==e?void 0:e[ZA];if(t){var i=XA(t.uri);if(i)return oD(i)}return null}var dD=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,hD=/#EXT-X-MEDIA:(.*)/g,cD=/^#EXT(?:INF|-X-TARGETDURATION):/m,mD=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),fD=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|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|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),vD=function(){function e(){Q(this,e)}return ne(e,null,[{key:"findGroup",value:function(e,t){for(var i=0;i<e.length;i++){var n=e[i];if(n.id===t)return n}}},{key:"resolve",value:function(e,t){return mT.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}},{key:"isMediaPlaylist",value:function(e){return cD.test(e)}},{key:"parseMasterPlaylist",value:function(t,i){var n,a={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:CA(t)},r=[];if(dD.lastIndex=0,!t.startsWith("#EXTM3U"))return a.playlistParsingError=new Error("no EXTM3U delimiter"),a;for(;null!=(n=dD.exec(t));)if(n[1]){var o,s=new WA(n[1],a),u=IA(a,n[2]),l={attrs:s,bitrate:s.decimalInteger("BANDWIDTH")||s.decimalInteger("AVERAGE-BANDWIDTH"),name:s.NAME,url:e.resolve(u,i)},d=s.decimalResolution("RESOLUTION");d&&(l.width=d.width,l.height=d.height),wD(s.CODECS,l);var h=s["SUPPLEMENTAL-CODECS"];h&&(l.supplemental={},wD(h,l.supplemental)),null!=(o=l.unknownCodecs)&&o.length||r.push(l),a.levels.push(l)}else if(n[3]){var c=n[3],m=n[4];switch(c){case"SESSION-DATA":var f=new WA(m,a),v=f["DATA-ID"];v&&(null===a.sessionData&&(a.sessionData={}),a.sessionData[v]=f);break;case"SESSION-KEY":var p=yD(m,i,a);p.encrypted&&p.isSupported()?(null===a.sessionKeys&&(a.sessionKeys=[]),a.sessionKeys.push(p)):ZM.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break;case"DEFINE":LA(a,new WA(m,a),i);break;case"CONTENT-STEERING":var g=new WA(m,a);a.contentSteering={uri:e.resolve(g["SERVER-URI"],i),pathwayId:g["PATHWAY-ID"]||"."};break;case"START":a.startTimeOffset=bD(m)}}var y=r.length>0&&r.length<a.levels.length;return a.levels=y?r:a.levels,0===a.levels.length&&(a.playlistParsingError=new Error("no levels found in manifest")),a}},{key:"parseMasterPlaylistMedia",value:function(t,i,n){var a,r={},o=n.levels,s={AUDIO:o.map(e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:o.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]},u=0;for(hD.lastIndex=0;null!==(a=hD.exec(t));){var l=new WA(a[1],n),d=l.TYPE;if(d){var h=s[d],c=r[d]||[];r[d]=c;var m=l.LANGUAGE,f=l["ASSOC-LANGUAGE"],v=l.CHANNELS,p=l.CHARACTERISTICS,g=l["INSTREAM-ID"],y={attrs:l,bitrate:0,id:u++,groupId:l["GROUP-ID"]||"",name:l.NAME||m||"",type:d,default:l.bool("DEFAULT"),autoselect:l.bool("AUTOSELECT"),forced:l.bool("FORCED"),lang:m,url:l.URI?e.resolve(l.URI,i):""};if(f&&(y.assocLang=f),v&&(y.channels=v),p&&(y.characteristics=p),g&&(y.instreamId=g),null!=h&&h.length){var b=e.findGroup(h,y.groupId)||h[0];kD(y,b,"audioCodec"),kD(y,b,"textCodec")}c.push(y)}}return r}},{key:"parseLevelPlaylist",value:function(e,t,i,n,a,r){var o,s,u,l,d,h={url:t},c=new jA(t),m=c.fragments,f=[],v=null,p=0,g=0,y=0,b=0,w=0,k=null,S=new wT(n,h),E=-1,M=!1,T=null;if(mD.lastIndex=0,c.m3u8=e,c.hasVariableRefs=CA(e),"#EXTM3U"!==(null==(o=mD.exec(e))?void 0:o[0]))return c.playlistParsingError=new Error("Missing format identifier #EXTM3U"),c;for(;null!==(s=mD.exec(e));){M&&(M=!1,(S=new wT(n,h)).playlistOffset=y,S.setStart(y),S.sn=p,S.cc=b,w&&(S.bitrate=w),S.level=i,v&&(S.initSegment=v,v.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime,v.rawProgramDateTime=null),T&&(S.setByteRange(T),T=null)));var P=s[1];if(P){S.duration=parseFloat(P);var A=(" "+s[2]).slice(1);S.title=A||null,S.tagList.push(A?["INF",P,A]:["INF",P])}else if(s[3]){if(DM(S.duration)){S.playlistOffset=y,S.setStart(y),l&&MD(S,l,c),S.sn=p,S.level=i,S.cc=b,m.push(S);var D=(" "+s[3]).slice(1);S.relurl=IA(c,D),SD(S,k,f),k=S,y+=S.duration,p++,g=0,M=!0}}else{if(!(s=s[0].match(fD))){ZM.warn("No matches on slow regex match for level playlist!");continue}for(u=1;u<s.length&&void 0===s[u];u++);var x=(" "+s[u]).slice(1),C=(" "+s[u+1]).slice(1),I=s[u+2]?(" "+s[u+2]).slice(1):null;switch(x){case"BYTERANGE":k?S.setByteRange(C,k):S.setByteRange(C);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=C,S.tagList.push(["PROGRAM-DATE-TIME",C]),-1===E&&(E=m.length);break;case"PLAYLIST-TYPE":c.type&&TD(c,x,s),c.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":0!==c.startSN?TD(c,x,s):m.length>0&&PD(c,x,s),p=c.startSN=parseInt(C);break;case"SKIP":c.skippedSegments&&TD(c,x,s);var L=new WA(C,c),_=L.decimalInteger("SKIPPED-SEGMENTS");if(DM(_)){c.skippedSegments+=_;for(var R=_;R--;)m.push(null);p+=_}var F=L.enumeratedString("RECENTLY-REMOVED-DATERANGES");F&&(c.recentlyRemovedDateranges=(c.recentlyRemovedDateranges||[]).concat(F.split("\t")));break;case"TARGETDURATION":0!==c.targetduration&&TD(c,x,s),c.targetduration=Math.max(parseInt(C),1);break;case"VERSION":null!==c.version&&TD(c,x,s),c.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":c.live||TD(c,x,s),c.live=!1;break;case"#":(C||I)&&S.tagList.push(I?[C,I]:[C]);break;case"DISCONTINUITY":b++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([x]);break;case"BITRATE":S.tagList.push([x,C]),w=1e3*parseInt(C),DM(w)?S.bitrate=w:w=0;break;case"DATERANGE":var W=new WA(C,c),O=new NA(W,c.dateRanges[W.ID],c.dateRangeTagCount);c.dateRangeTagCount++,O.isValid||c.skippedSegments?c.dateRanges[O.id]=O:ZM.warn(`Ignoring invalid DATERANGE tag: "${C}"`),S.tagList.push(["EXT-X-DATERANGE",C]);break;case"DEFINE":var $=new WA(C,c);"IMPORT"in $?_A(c,$,r):LA(c,$,t);break;case"DISCONTINUITY-SEQUENCE":0!==c.startCC?TD(c,x,s):m.length>0&&PD(c,x,s),c.startCC=b=parseInt(C);break;case"KEY":var N=yD(C,t,c);if(N.isSupported()){if("NONE"===N.method){l=void 0;break}l||(l={});var j=l[N.keyFormat];null!=j&&j.matches(N)||(j&&(l=HM({},l)),l[N.keyFormat]=N)}else ZM.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${C}"`);break;case"START":c.startTimeOffset=bD(C);break;case"MAP":var B=new WA(C,c);if(S.duration){var z=new wT(n,h);ED(z,B,i,l),v=z,S.initSegment=v,v.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=v.rawProgramDateTime)}else{var U=S.byteRangeEndOffset;if(U){var H=S.byteRangeStartOffset;T=`${U-H}@${H}`}else T=null;ED(S,B,i,l),v=S,M=!0}v.cc=b;break;case"SERVER-CONTROL":d&&TD(c,x,s),d=new WA(C),c.canBlockReload=d.bool("CAN-BLOCK-RELOAD"),c.canSkipUntil=d.optionalFloat("CAN-SKIP-UNTIL",0),c.canSkipDateRanges=c.canSkipUntil>0&&d.bool("CAN-SKIP-DATERANGES"),c.partHoldBack=d.optionalFloat("PART-HOLD-BACK",0),c.holdBack=d.optionalFloat("HOLD-BACK",0);break;case"PART-INF":c.partTarget&&TD(c,x,s);var G=new WA(C);c.partTarget=G.decimalFloatingPoint("PART-TARGET");break;case"PART":var V=c.partList;V||(V=c.partList=[]);var K=g>0?V[V.length-1]:void 0,X=g++,Y=new WA(C,c),q=new kT(Y,S,h,X,K);V.push(q),S.duration+=q.duration;break;case"PRELOAD-HINT":var J=new WA(C,c);c.preloadHint=J;break;case"RENDITION-REPORT":var Q=new WA(C,c);c.renditionReports=c.renditionReports||[],c.renditionReports.push(Q);break;default:ZM.warn(`line parsed but not handled: ${s}`)}}}k&&!k.relurl?(m.pop(),y-=k.duration,c.partList&&(c.fragmentHint=k)):c.partList&&(SD(S,k,f),S.cc=b,c.fragmentHint=S,l&&MD(S,l,c)),c.targetduration||(c.playlistParsingError=new Error("Missing Target Duration"));var Z=m.length,ee=m[0],te=m[Z-1];if((y+=c.skippedSegments*c.targetduration)>0&&Z&&te){c.averagetargetduration=y/Z;var ie=te.sn;c.endSN="initSegment"!==ie?ie:0,c.live||(te.endList=!0),E>0&&(!function(e,t){for(var i=e[t],n=t;n--;){var a=e[n];if(!a)return;a.programDateTime=i.programDateTime-1e3*a.duration,i=a}}(m,E),ee&&f.unshift(ee))}return c.fragmentHint&&(y+=c.fragmentHint.duration),c.totalduration=y,f.length&&c.dateRangeTagCount&&ee&&pD(f,c),c.endCC=b,c}}])}();function pD(e,t){var i=e.length;if(!i){if(!t.hasProgramDateTime)return;var n=t.fragments[t.fragments.length-1];e.push(n),i++}for(var a=e[i-1],r=t.live?1/0:t.totalduration,o=Object.keys(t.dateRanges),s=o.length;s--;){var u=t.dateRanges[o[s]],l=u.startDate.getTime();u.tagAnchor=a.ref;for(var d=i;d--;){var h;if((null==(h=e[d])?void 0:h.sn)<t.startSN)break;var c=gD(t,l,e,d,r);if(-1!==c){u.tagAnchor=t.fragments[c].ref;break}}}}function gD(e,t,i,n,a){var r=i[n];if(r){var o,s=r.programDateTime;if(t>=s||0===n)if(t<=s+1e3*(((null==(o=i[n+1])?void 0:o.start)||a)-r.start)){var u=i[n].sn-e.startSN;if(u<0)return-1;var l=e.fragments;if(l.length>i.length)for(var d=(i[n+1]||l[l.length-1]).sn-e.startSN;d>u;d--){var h=l[d].programDateTime;if(t>=h&&t<h+1e3*l[d].duration)return d}return u}}return-1}function yD(e,t,i){var n,a,r=new WA(e,i),o=null!=(n=r.METHOD)?n:"",s=r.URI,u=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,d=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!u&&ZM.error(`Invalid IV: ${r.IV}`);var h=s?vD.resolve(s,t):"",c=(l||"1").split("/").map(Number).filter(Number.isFinite);return new uD(o,h,d,c,u,r.KEYID)}function bD(e){var t=new WA(e).decimalFloatingPoint("TIME-OFFSET");return DM(t)?t:null}function wD(e,t){var i=(e||"").split(/[ ,]+/).filter(e=>e);["video","audio","text"].forEach(e=>{var n=i.filter(t=>JT(t,e));n.length&&(t[`${e}Codec`]=n.map(e=>e.split("/")[0]).join(","),i=i.filter(e=>-1===n.indexOf(e)))}),t.unknownCodecs=i}function kD(e,t,i){var n=t[i];n&&(e[i]=n)}function SD(e,t,i){e.rawProgramDateTime?i.push(e):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime)}function ED(e,t,i,n){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=i,e.sn="initSegment",n&&(e.levelkeys=n),e.initSegment=null}function MD(e,t,i){e.levelkeys=t;var n=i.encryptedFragments;n.length&&n[n.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||n.push(e)}function TD(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must not appear more than once (${i[0]})`)}function PD(e,t,i){e.playlistParsingError=new Error(`#EXT-X-${t} must appear before the first Media Segment (${i[0]})`)}function AD(e,t){var i=t.startPTS;if(DM(i)){var n,a=0;t.sn>e.sn?(a=i-e.start,n=e):(a=e.start-i,n=t),n.duration!==a&&n.setDuration(a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.setStart(e.start+(e.minEndPTS-e.start)):t.setStart(e.start+e.duration)}else t.setStart(Math.max(e.start-t.duration,0))}function DD(e,t,i,n,a,r,o){n-i<=0&&(o.warn("Fragment should have a positive duration",t),n=i+t.duration,r=a+t.duration);var s=i,u=n,l=t.startPTS,d=t.endPTS;if(DM(l)){var h=Math.abs(l-i);e&&h>e.totalduration?o.warn(`media timestamps and playlist times differ by ${h}s for level ${t.level} ${e.url}`):DM(t.deltaPTS)?t.deltaPTS=Math.max(h,t.deltaPTS):t.deltaPTS=h,s=Math.max(i,l),i=Math.min(i,l),a=void 0!==t.startDTS?Math.min(a,t.startDTS):a,u=Math.min(n,d),n=Math.max(n,d),r=void 0!==t.endDTS?Math.max(r,t.endDTS):r}var c=i-t.start;0!==t.start&&t.setStart(i),t.setDuration(n-t.start),t.startPTS=i,t.maxStartPTS=s,t.startDTS=a,t.endPTS=n,t.minEndPTS=u,t.endDTS=r;var m,f=t.sn;if(!e||f<e.startSN||f>e.endSN)return 0;var v=f-e.startSN,p=e.fragments;for(p[v]=t,m=v;m>0;m--)AD(p[m],p[m-1]);for(m=v;m<p.length-1;m++)AD(p[m],p[m+1]);return e.fragmentHint&&AD(p[p.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,c}function xD(e,t,i){if(e!==t){for(var n,a=null,r=e.fragments,o=r.length-1;o>=0;o--){var s=r[o].initSegment;if(s){a=s;break}}e.fragmentHint&&delete e.fragmentHint.endPTS,function(e,t,i){for(var n=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(n?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,s=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=a;l<=r;l++){var d=u[o+l],h=s[l];if(n&&!h&&d&&(h=t.fragments[l]=d),d&&h){i(d,h,l,s);var c=d.relurl,m=h.relurl;if(c&&$D(c,m))return void(t.playlistParsingError=CD(`media sequence mismatch ${h.sn}:`,e,t,d,h));if(d.cc!==h.cc)return void(t.playlistParsingError=CD(`discontinuity sequence mismatch (${d.cc}!=${h.cc})`,e,t,d,h))}}}(e,t,(e,i,r,o)=>{if((!t.startCC||t.skippedSegments)&&i.cc!==e.cc){for(var s=e.cc-i.cc,u=r;u<o.length;u++)o[u].cc+=s;t.endCC=o[o.length-1].cc}DM(e.startPTS)&&DM(e.endPTS)&&(i.setStart(i.startPTS=e.startPTS),i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.setDuration(e.endPTS-e.startPTS),i.duration&&(n=i),t.PTSKnown=t.alignedSliding=!0),e.hasStreams&&(i.elementaryStreams=e.elementaryStreams),i.loader=e.loader,e.hasStats&&(i.stats=e.stats),e.initSegment&&(i.initSegment=e.initSegment,a=e.initSegment)});var u=t.fragments,l=t.fragmentHint?u.concat(t.fragmentHint):u;if(a&&l.forEach(e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=a)?void 0:t.relurl)||(e.initSegment=a)}),t.skippedSegments){if(t.deltaUpdateFailed=u.some(e=>!e),t.deltaUpdateFailed){i.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=t.skippedSegments;d--;)u.shift();t.startSN=u[0].sn}else{t.canSkipDateRanges&&(t.dateRanges=function(e,t,i){var n=t.dateRanges,a=t.recentlyRemovedDateranges,r=HM({},e);a&&a.forEach(e=>{delete r[e]});var o=Object.keys(r).length;if(!o)return n;return Object.keys(n).forEach(e=>{var t=r[e],a=new NA(n[e].attr,t);a.isValid?(r[e]=a,t||(a.tagOrder+=o)):i.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${AP(n[e].attr)}"`)}),r}(e.dateRanges,t,i));var h=e.fragments.filter(e=>e.rawProgramDateTime);if(e.hasProgramDateTime&&!t.hasProgramDateTime)for(var c=1;c<l.length;c++)null===l[c].programDateTime&&SD(l[c],l[c-1],h);pD(h,t)}t.endCC=u[u.length-1].cc}if(!t.startCC){var m,f=RD(e,t.startSN-1);t.startCC=null!=(m=null==f?void 0:f.cc)?m:u[0].cc}!function(e,t,i){if(e&&t)for(var n=0,a=0,r=e.length;a<=r;a++){var o=e[a],s=t[a+n];o&&s&&o.index===s.index&&o.fragment.sn===s.fragment.sn?i(o,s):n--}}(e.partList,t.partList,(e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?DD(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS,i):ID(e,t),u.length&&(t.totalduration=t.edge-u[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;var v=t.advancedDateTime;if(t.advanced&&v){var p=t.edge;t.driftStart||(t.driftStartTime=v,t.driftStart=p),t.driftEndTime=v,t.driftEnd=p}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime;-1===t.requestScheduled&&(t.requestScheduled=e.requestScheduled)}}function CD(e,t,i,n,a){return new Error(`${e} ${a.url}\nPlaylist starting @${t.startSN}\n${t.m3u8}\n\nPlaylist starting @${i.startSN}\n${i.m3u8}`)}function ID(e,t,i=!0){var n=t.startSN+t.skippedSegments-e.startSN,a=e.fragments,r=n>=0,o=0;if(r&&n<a.length)o=a[n].start;else if(r&&t.startSN===e.endSN+1)o=e.fragmentEnd;else if(r&&i)o=e.fragmentStart+n*t.levelTargetDuration;else{if(t.skippedSegments||0!==t.fragmentStart)return;o=e.fragmentStart}LD(t,o)}function LD(e,t){if(t){for(var i=e.fragments,n=e.skippedSegments;n<i.length;n++)i[n].addStart(t);e.fragmentHint&&e.fragmentHint.addStart(t)}}function _D(e,t=1/0){var i=1e3*e.targetduration;if(e.updated){var n=e.fragments;if(n.length&&4*i>t){var a=1e3*n[n.length-1].duration;a<i&&(i=a)}}else i/=2;return Math.round(i)}function RD(e,t,i){if(!e)return null;var n=e.fragments[t-e.startSN];return n||((n=e.fragmentHint)&&n.sn===t?n:t<e.startSN&&i&&i.sn===t?i:null)}function FD(e,t,i){return e?WD(e.partList,t,i):null}function WD(e,t,i){if(e)for(var n=e.length;n--;){var a=e[n];if(a.index===i&&a.fragment.sn===t)return a}return null}function OD(e){e.forEach((e,t)=>{var i;null==(i=e.details)||i.fragments.forEach(e=>{e.level=t,e.initSegment&&(e.initSegment.level=t)})})}function $D(e,t){return!(e===t||!t)&&ND(e)!==ND(t)}function ND(e){return e.replace(/\?[^?]*$/,"")}function jD(e,t){for(var i=0,n=e.length;i<n;i++){var a;if((null==(a=e[i])?void 0:a.cc)===t)return e[i]}return null}function BD(e,t){var i=e.start+t;e.startPTS=i,e.setStart(i),e.endPTS=i+e.duration}function zD(e,t){for(var i=t.fragments,n=0,a=i.length;n<a;n++)BD(i[n],e);t.fragmentHint&&BD(t.fragmentHint,e),t.alignedSliding=!0}function UD(e,t){if(function(e,t){return!!(e&&t.startCC<e.endCC&&t.endCC>e.startCC)}(t,e)){var i=Math.min(t.endCC,e.endCC),n=jD(t.fragments,i),a=jD(e.fragments,i);if(n&&a)ZM.log(`Aligning playlist at start of dicontinuity sequence ${i}`),zD(n.start-a.start,e)}}function HD(e,t){if(e.hasProgramDateTime&&t.hasProgramDateTime){var i=e.fragments,n=t.fragments;if(i.length&&n.length){var a,r,o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=jD(n,o),r=jD(i,o)),a&&r||(r=jD(i,(a=n[Math.floor(n.length/2)]).cc)||i[Math.floor(i.length/2)]);var s=a.programDateTime,u=r.programDateTime;if(s&&u)zD((u-s)/1e3-(r.start-a.start),e)}}}function GD(e,t,i){VD(e,t,i),e.addEventListener(t,i)}function VD(e,t,i){e.removeEventListener(t,i)}var KD=function(e){for(var t="",i=e.length,n=0;n<i;n++)t+=`[${e.start(n).toFixed(3)}-${e.end(n).toFixed(3)}]`;return t},XD="STOPPED",YD="IDLE",qD="KEY_LOADING",JD="FRAG_LOADING",QD="FRAG_LOADING_WAITING_RETRY",ZD="WAITING_TRACK",ex="PARSING",tx="PARSED",ix="ENDED",nx="ERROR",ax="WAITING_INIT_PTS",rx="WAITING_LEVEL",ox=function(){function e(t,i,n,a,r){var o;return Q(this,e),(o=J(this,e,[a,t.logger])).hls=void 0,o.fragPrevious=null,o.fragCurrent=null,o.fragmentTracker=void 0,o.transmuxer=null,o._state=XD,o.playlistType=void 0,o.media=null,o.mediaBuffer=null,o.config=void 0,o.bitrateTest=!1,o.lastCurrentTime=0,o.nextLoadPosition=0,o.startPosition=0,o.startTimeOffset=null,o.retryDate=0,o.levels=null,o.fragmentLoader=void 0,o.keyLoader=void 0,o.levelLastLoaded=null,o.startFragRequested=!1,o.decrypter=void 0,o.initPTS=[],o.buffering=!0,o.loadingParts=!1,o.loopSn=void 0,o.onMediaSeeking=()=>{var e=o,t=e.config,i=e.fragCurrent,n=e.media,a=e.mediaBuffer,r=e.state,s=n?n.currentTime:0,u=DA.bufferInfo(a||n,s,t.maxBufferHole),l=!u.len;if(o.log(`Media seeking to ${DM(s)?s.toFixed(3):s}, state: ${r}, ${l?"out of":"in"} buffer`),o.state===ix)o.resetLoadingState();else if(i){var d=t.maxFragLookUpTolerance,h=i.start-d,c=i.start+i.duration+d;if(l||c<u.start||h>u.end){var m=s>c;(s<h||m)&&(m&&i.loader&&(o.log(`Cancelling fragment load for seek (sn: ${i.sn})`),i.abortRequests(),o.resetLoadingState()),o.fragPrevious=null)}}if(n&&(o.fragmentTracker.removeFragmentsInRange(s,1/0,o.playlistType,!0),s>o.lastCurrentTime&&(o.lastCurrentTime=s),!o.loadingParts)){var f=Math.max(u.end,s),v=o.shouldLoadParts(o.getLevelDetails(),f);v&&(o.log(`LL-Part loading ON after seeking to ${s.toFixed(2)} with buffer @${f.toFixed(2)}`),o.loadingParts=v)}o.hls.hasEnoughToStart||(o.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${s} for seek without enough to start`),o.nextLoadPosition=s,l&&(o.startPosition=s)),l&&o.state===YD&&o.tickImmediate()},o.onMediaEnded=()=>{o.log("setting startPosition to 0 because media ended"),o.startPosition=o.lastCurrentTime=0},o.playlistType=r,o.hls=t,o.fragmentLoader=new kA(t.config),o.keyLoader=n,o.fragmentTracker=i,o.config=t.config,o.decrypter=new bA(t.config),o}return ue(e,TA),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_M.ERROR,this.onError,this)}},{key:"doTick",value:function(){this.onTickEnd()}},{key:"onTickEnd",value:function(){}},{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){if(this.state!==XD){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);var e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=XD}}},{key:"startPositionValue",get:function(){var e=this.nextLoadPosition,t=this.startPosition;return-1===t&&e?e:t}},{key:"bufferingEnabled",get:function(){return this.buffering}},{key:"pauseBuffering",value:function(){this.buffering=!1}},{key:"resumeBuffering",value:function(){this.buffering=!0}},{key:"inFlightFrag",get:function(){return{frag:this.fragCurrent,state:this.state}}},{key:"_streamEnded",value:function(e,t){if(t.live||!this.media)return!1;var i=e.end||0,n=this.config.timelineOffset||0;if(i<=n)return!1;var a=e.buffered;this.config.maxBufferHole&&a&&a.length>1&&(e=DA.bufferedInfo(a,e.start,0));var r=e.nextStart;if(r&&r>n&&r<t.edge)return!1;if(this.media.currentTime<e.start)return!1;var o=t.partList;if(null!=o&&o.length){var s=o[o.length-1];return DA.isBuffered(this.media,s.start+s.duration/2)}var u=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(u)}},{key:"getLevelDetails",value:function(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}},{key:"timelineOffset",get:function(){var e,t=this.config.timelineOffset;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}},{key:"onMediaAttached",value:function(e,t){var i=this.media=this.mediaBuffer=t.media;GD(i,"seeking",this.onMediaSeeking),GD(i,"ended",this.onMediaEnded);var n=this.config;this.levels&&n.autoStartLoad&&this.state===XD&&this.startLoad(n.startPosition)}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(null!==n){if(n.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),VD(n,"seeking",this.onMediaSeeking),VD(n,"ended",this.onMediaEnded),this.keyLoader&&!i&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,i)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}},{key:"onManifestLoading",value:function(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}},{key:"onError",value:function(e,t){}},{key:"onManifestLoaded",value:function(e,t){this.startTimeOffset=t.startTimeOffset}},{key:"onHandlerDestroying",value:function(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),pe(e,"onHandlerDestroying",this)([]),this.hls=this.onMediaSeeking=this.onMediaEnded=null}},{key:"onHandlerDestroyed",value:function(){this.state=XD,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,pe(e,"onHandlerDestroyed",this)([])}},{key:"loadFragment",value:function(e,t,i){this.startFragRequested=!0,this._loadFragForPlayback(e,t,i)}},{key:"_loadFragForPlayback",value:function(e,t,i){this._doFragLoad(e,t,i,e=>{var t=e.frag;if(this.fragContextChanged(t))return this.warn(`${t.type} sn: ${t.sn}${e.part?" part: "+e.part.index:""} of ${this.fragInfo(t,!1,e.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(t);t.stats.chunkCount++,this._handleFragmentLoadProgress(e)}).then(e=>{if(e){var t=this.state,i=e.frag;this.fragContextChanged(i)?(t===JD||!this.fragCurrent&&t===ex)&&(this.fragmentTracker.removeFragment(i),this.state=YD):("payload"in e&&(this.log(`Loaded ${i.type} sn: ${i.sn} of ${this.playlistLabel()} ${i.level}`),this.hls.trigger(_M.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e))}}).catch(t=>{this.state!==XD&&this.state!==nx&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))})}},{key:"clearTrackerIfNeeded",value:function(e){var t,i=this.fragmentTracker;if(i.getState(e)===sA){var n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),r=Math.max(e.duration,a?a.len:this.config.maxBufferLength),o=this.backtrackFragment;(1===(o?e.sn-o.sn:0)||this.reduceMaxBufferLength(r,e.duration))&&i.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===uA&&i.removeFragment(e))}},{key:"checkLiveUpdate",value:function(e){if(e.updated&&!e.live){var t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}},{key:"waitForLive",value:function(e){var t=e.details;return(null==t?void 0:t.live)&&"EVENT"!==t.type&&(this.levelLastLoaded!==e||t.expired)}},{key:"flushMainBuffer",value:function(e,t,i=null){if(e-t){var n={startOffset:e,endOffset:t,type:i};this.hls.trigger(_M.BUFFER_FLUSHING,n)}}},{key:"_loadInitSegment",value:function(e,t){this._doFragLoad(e,t).then(e=>{var t=null==e?void 0:e.frag;if(!t||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return e}).then(e=>{var t=this.hls,i=e.frag,n=e.payload,a=i.decryptdata;if(n&&n.byteLength>0&&null!=a&&a.key&&a.iv&&UA(a.method)){var r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer,HA(a.method)).catch(e=>{throw t.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(n=>{var a=self.performance.now();return t.trigger(_M.FRAG_DECRYPTED,{frag:i,payload:n,stats:{tstart:r,tdecrypt:a}}),e.payload=n,this.completeInitSegmentLoad(e)})}return this.completeInitSegmentLoad(e)}).catch(t=>{this.state!==XD&&this.state!==nx&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"completeInitSegmentLoad",value:function(e){if(!this.levels)throw new Error("init load aborted, missing levels");var t=e.frag.stats;this.state!==XD&&(this.state=YD),e.frag.data=new Uint8Array(e.payload),t.parsing.start=t.buffering.start=self.performance.now(),t.parsing.end=t.buffering.end=self.performance.now(),this.tick()}},{key:"unhandledEncryptionError",value:function(e,t){var i,n,a=e.tracks;if(a&&!t.encrypted&&(null!=(i=a.audio)&&i.encrypted||null!=(n=a.video)&&n.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){var r=this.media,o=new Error(`Encrypted track with no key in ${this.fragInfo(t)} (media ${r?"attached mediaKeys: "+r.mediaKeys:"detached"})`);return this.warn(o.message),!r||r.mediaKeys?!1:(this.hls.trigger(_M.ERROR,{type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_NO_KEYS,fatal:!1,error:o,frag:t}),this.resetTransmuxer(),!0)}return!1}},{key:"fragContextChanged",value:function(e){var t=this.fragCurrent;return!e||!t||e.sn!==t.sn||e.level!==t.level}},{key:"fragBufferedComplete",value:function(e,t){var i=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)} > buffer:${i?KD(DA.getBuffered(i)):"(detached)"})`),bT(e)){var n;if(e.type!==jM){var a=e.elementaryStreams;if(!Object.keys(a).some(e=>!!a[e]))return void(this.state=YD)}var r=null==(n=this.levels)?void 0:n[e.level];null!=r&&r.fragmentError&&(this.log(`Resetting level fragment error count of ${r.fragmentError} on frag buffered`),r.fragmentError=0)}this.state=YD}},{key:"_handleFragmentLoadComplete",value:function(e){var t=this.transmuxer;if(t){var i=e.frag,n=e.part,a=e.partsLoaded,r=!a||0===a.length||a.some(e=>!e),o=new PA(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!r);t.flush(o)}}},{key:"_handleFragmentLoadProgress",value:function(e){}},{key:"_doFragLoad",value:function(e,t,i=null,n){var a;this.fragCurrent=e;var r=t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);var o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key)e.encrypted||(o=this.keyLoader.loadClear(e,r.encryptedFragments,this.startFragRequested))&&this.log("[eme] blocking frag load until media-keys acquired");else if(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${this.playlistLabel()} ${e.level}`),this.state=qD,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(_M.KEY_LOADED,e),this.state===qD&&(this.state=YD),e}),this.hls.trigger(_M.KEY_LOADING,{frag:e}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);var s,u=this.fragPrevious;if(bT(e)&&(!u||e.sn!==u.sn)){var l=this.shouldLoadParts(t.details,e.end);l!==this.loadingParts&&(this.log(`LL-Part loading ${l?"ON":"OFF"} loading sn ${null==u?void 0:u.sn}->${e.sn}`),this.loadingParts=l)}if(i=Math.max(e.start,i||0),this.loadingParts&&bT(e)){var d=r.partList;if(d&&n){i>r.fragmentEnd&&r.fragmentHint&&(e=r.fragmentHint);var h=this.getNextPart(d,e,i);if(h>-1){var c,m=d[h];return e=this.fragCurrent=m.fragment,this.log(`Loading ${e.type} sn: ${e.sn} part: ${m.index} (${h}/${d.length-1}) of ${this.fragInfo(e,!1,m)}) cc: ${e.cc} [${r.startSN}-${r.endSN}], target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=m.start+m.duration,this.state=JD,c=o?o.then(i=>!i||this.fragContextChanged(i.frag)?null:this.doFragPartsLoad(e,m,t,n)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,m,t,n).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(_M.FRAG_LOADING,{frag:e,part:m,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(d,i))return Promise.resolve(null)}}if(bT(e)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${i.toFixed(2)} Check buffer at sn: ${e.sn} loaded parts: ${null==(s=r.partList)?void 0:s.filter(e=>e.loaded).map(e=>`[${e.start}-${e.end}]`)}`),this.loadingParts=!1;else if(!e.url)return Promise.resolve(null);this.log(`Loading ${e.type} sn: ${e.sn} of ${this.fragInfo(e,!1)}) cc: ${e.cc} ${"["+r.startSN+"-"+r.endSN+"]"}, target: ${parseFloat(i.toFixed(3))}`),DM(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=JD;var f,v=this.config.progressive&&e.type!==jM;return f=v&&o?o.then(t=>!t||this.fragContextChanged(t.frag)?null:this.fragmentLoader.load(e,n)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,v?n:void 0),o]).then(([e])=>(!v&&n&&n(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(_M.FRAG_LOADING,{frag:e,targetBufferTime:i}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):f}},{key:"doFragPartsLoad",value:function(e,t,i,n){return new Promise((a,r)=>{var o,s=[],u=null==(o=i.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,n).then(n=>{s[t.index]=n;var r=n.part;this.hls.trigger(_M.FRAG_LOADED,n);var o=FD(i.details,e.sn,t.index+1)||WD(u,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)}).catch(r)};l(t)})}},{key:"handleFragLoadError",value:function(e){if("data"in e){var t=e.data;t.frag&&t.details===LM.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):t.frag&&t.type===IM.KEY_SYSTEM_ERROR?(t.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(t.frag)):this.hls.trigger(_M.ERROR,t)}else this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}},{key:"_handleTransmuxerFlush",value:function(e){var t=this.getCurrentContext(e);if(t&&this.state===ex){var i=t.frag,n=t.part,a=t.level,r=self.performance.now();i.stats.parsing.end=r,n&&(n.stats.parsing.end=r);var o=this.getLevelDetails(),s=o&&i.sn>o.endSN||this.shouldLoadParts(o,i.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} after parsing segment ending @${i.end.toFixed(2)}`),this.loadingParts=s),this.updateLevelTiming(i,n,a,e.partial)}else this.fragCurrent||this.state===XD||this.state===nx||(this.state=YD)}},{key:"shouldLoadParts",value:function(e,t){if(this.config.lowLatencyMode){if(!e)return this.loadingParts;if(e.partList){var i,n,a=e.partList[0];if(a.fragment.type===jM)return!1;if(t>=a.end+((null==(i=e.fragmentHint)?void 0:i.duration)||0))if((this.hls.hasEnoughToStart?(null==(n=this.media)?void 0:n.currentTime)||this.lastCurrentTime:this.getLoadPosition())>a.start-a.fragment.duration)return!0}}return!1}},{key:"getCurrentContext",value:function(e){var t=this.levels,i=this.fragCurrent,n=e.level,a=e.sn,r=e.part;if(null==t||!t[n])return this.warn(`Levels object was unset while buffering fragment ${a} of ${this.playlistLabel()} ${n}. The current chunk will not be buffered.`),null;var o=t[n],s=o.details,u=r>-1?FD(s,a,r):null,l=u?u.fragment:RD(s,a,i);return l?(i&&i!==l&&(l.stats=i.stats),{frag:l,part:u,level:o}):null}},{key:"bufferFragmentData",value:function(e,t,i,n,a){if(this.state===ex){var r=e.data1,o=e.data2,s=r;if(o&&(s=BT(r,o)),s.length){var u=this.initPTS[t.cc],l=u?-u.baseTime/u.timescale:void 0,d={type:e.type,frag:t,part:i,chunkMeta:n,offset:l,parent:t.type,data:s};if(this.hls.trigger(_M.BUFFER_APPENDING,d),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}}}},{key:"flushBufferGap",value:function(e){var t=this.media;if(t)if(DA.isBuffered(t,t.currentTime)){var i=t.currentTime,n=DA.bufferInfo(t,i,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,n.end-r),i+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}else this.flushMainBuffer(0,e.start)}},{key:"getFwdBufferInfo",value:function(e,t){var i,n=this.getLoadPosition();if(!DM(n))return null;var a=this.lastCurrentTime>n||null!=(i=this.media)&&i.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(e,n,t,a)}},{key:"getFwdBufferInfoAtPos",value:function(e,t,i,n){var a=DA.bufferInfo(e,t,n);if(0===a.len&&void 0!==a.nextStart){var r=this.fragmentTracker.getBufferedFrag(t,i);if(r&&(a.nextStart<=r.end||r.gap)){var o=Math.max(Math.min(a.nextStart,r.end)-t,n);return DA.bufferInfo(e,t,o)}}return a}},{key:"getMaxBufferLength",value:function(e){var t,i=this.config;return t=e?Math.max(8*i.maxBufferSize/e,i.maxBufferLength):i.maxBufferLength,Math.min(t,i.maxMaxBufferLength)}},{key:"exceedsMaxBuffer",value:function(e,t,i){var n=e.nextStart;if(n&&i.start>n){var a=e.buffered;if(a){for(var r=e.len,o=e.bufferedIndex,s=a.length-1;s>o;s--)a[s].start<i.start&&(r+=a[s].end-a[s].start);return r>=t}}return!1}},{key:"reduceMaxBufferLength",value:function(e,t){var i=this.config,n=Math.max(Math.min(e-t,i.maxBufferLength),t),a=Math.max(e-3*t,i.maxMaxBufferLength/2,n);return a>=n&&(i.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}},{key:"getAppendedFrag",value:function(e,t=$M){var i=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(e,t):null;return i&&"fragment"in i?i.fragment:i}},{key:"getNextFragment",value:function(e,t){var i=t.fragments,n=i.length;if(!n)return null;var a=this.config,r=t.fragmentStart,o=a.lowLatencyMode&&!!t.partList,s=null;if(t.live){var u=a.initialLiveManifestSize;if(n<u)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${u})`),null;if(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r){var l;o&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),s=this.getInitialLiveFragment(t);var d,h,c=this.config.startPosition,m=this.hls.startPosition,f=this.hls.liveSyncPosition,v=(null==(l=s)?void 0:l.start)||0;-1!==m&&m>=r?(d=m,h=m===c?"config":"next load start"):null!==f?(d=f,h="live edge"):(d=e,h="buffer pos"),d<v&&(d=v,h="live frag start"),d<r&&(d=r,h="playlist start"),this.startPosition==d&&this.nextLoadPosition==d||(this.log(`Setting startPosition to ${d.toFixed(3)} ${-1===m?"":`(from ${c}) `}based on ${h}. live edge: ${f} live frag start: ${v.toFixed(3)} playlist start: ${r.toFixed(3)} buffer pos: ${e}`),this.startPosition=this.nextLoadPosition=d)}}else e<=r&&(s=i[0]);if(!s){var p=this.loadingParts?t.partEnd:t.fragmentEnd;s=this.getFragmentAtPosition(e,p,t)}var g=this.filterReplacedPrimary(s,t);if(!g&&s){var y=s.sn-t.startSN;g=this.filterReplacedPrimary(i[y+1]||null,t)}return this.mapToInitFragWhenRequired(g)}},{key:"isLoopLoading",value:function(e,t){if(this.nextLoadPosition<=t)return!1;var i=this.fragmentTracker.getState(e);return i===lA||i===uA&&!!e.gap}},{key:"getNextFragmentLoopLoading",value:function(e,t,i,n,a){var r=null;if(e.gap&&(r=this.getNextFragment(this.nextLoadPosition,t))&&!r.gap&&i.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n,0);if(null!==o&&i.len+o.len>=a){var s=r.sn;return this.loopSn!==s&&(this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${s}`),this.loopSn=s),null}}return this.loopSn=void 0,r}},{key:"primaryPrefetch",get:function(){var e;if(sx(this.config)&&(null==(e=this.hls.interstitialsManager)||null==(e=e.playingItem)?void 0:e.event))return!0;return!1}},{key:"filterReplacedPrimary",value:function(e,t){if(!e)return e;if(sx(this.config)&&e.type!==jM){var i=this.hls.interstitialsManager,n=null==i?void 0:i.bufferingItem;if(n){var a=n.event;if(a){if(a.appendInPlace||Math.abs(e.start-n.start)>1||0===n.start)return null}else{if(e.end<=n.start&&!1===(null==t?void 0:t.live))return null;if(e.start>n.end&&n.nextEvent&&(n.nextEvent.appendInPlace||e.start-n.end>1))return null}}var r=null==i?void 0:i.playerQueue;if(r)for(var o=r.length;o--;){var s=r[o].interstitial;if(s.appendInPlace&&e.start>=s.startTime&&e.end<=s.resumeTime)return null}}return e}},{key:"mapToInitFragWhenRequired",value:function(e){return null==e||!e.initSegment||e.initSegment.data||this.bitrateTest?e:e.initSegment}},{key:"getNextPart",value:function(e,t,i){for(var n=-1,a=!1,r=!0,o=0,s=e.length;o<s;o++){var u=e[o];if(r=r&&!u.independent,n>-1&&i<u.start)break;var l=u.loaded;l?n=-1:(a||(u.independent||r)&&u.fragment===t)&&(u.fragment!==t&&this.warn(`Need buffer at ${i} but next unloaded part starts at ${u.start}`),n=o),a=l}return n}},{key:"loadedEndOfParts",value:function(e,t){for(var i,n=e.length;n--;){if(!(i=e[n]).loaded)return!1;if(t>i.start)return!0}return!1}},{key:"getInitialLiveFragment",value:function(e){var t=e.fragments,i=this.fragPrevious,n=null;if(i){if(e.hasProgramDateTime&&(n=function(e,t,i){if(null===t||!Array.isArray(e)||!e.length||!DM(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;for(var n=0;n<e.length;++n){var a=e[n];if(jP(t,i,a))return a}return null}(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance),n&&this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`)),!n){var a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){var r=t[a-e.startSN];i.cc===r.cc&&(n=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=BP(e,i.cc,i.end))&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`)}}else{var o=this.hls.liveSyncPosition;null!==o&&(n=this.getFragmentAtPosition(o,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}},{key:"getFragmentAtPosition",value:function(e,t,i){var n,a,r=this.config,o=this.fragPrevious,s=i.fragments,u=i.endSN,l=i.fragmentHint,d=r.maxFragLookUpTolerance,h=i.partList,c=!!(this.loadingParts&&null!=h&&h.length&&l);(c&&!this.bitrateTest&&h[h.length-1].fragment.sn===l.sn&&(s=s.concat(l),u=l.sn),e<t)?n=$P(o,s,e,e<this.lastCurrentTime||e>t-d||null!=(a=this.media)&&a.paused||!this.startFragRequested?0:d):n=s[s.length-1];if(n){var m=n.sn-i.startSN,f=this.fragmentTracker.getState(n);if((f===lA||f===uA&&n.gap)&&(o=n),o&&n.sn===o.sn&&(!c||h[0].fragment.sn>n.sn||!i.live))if(n.level===o.level){var v=s[m+1];n=n.sn<u&&this.fragmentTracker.getState(v)!==lA?v:null}}return n}},{key:"alignPlaylists",value:function(e,t,i){var n=e.fragments.length;if(!n)return this.warn("No fragments in live playlist"),0;var a=e.fragmentStart,r=!t,o=e.alignedSliding&&DM(a);if(r||!o&&!a){!function(e,t){e&&(UD(t,e),t.alignedSliding||HD(t,e),t.alignedSliding||t.skippedSegments||ID(e,t,!1))}(i,e);var s=e.fragmentStart;return this.log(`Live playlist sliding: ${s.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} fragments: ${n}`),s}return a}},{key:"waitForCdnTuneIn",value:function(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}},{key:"setStartPosition",value:function(e,t){var i=this.startPosition;i<t&&(i=-1);var n=this.timelineOffset;if(-1===i){var a=null!==this.startTimeOffset,r=a?this.startTimeOffset:e.startTimeOffset;null!==r&&DM(r)?(i=t+r,r<0&&(i+=e.edge),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Setting startPosition to ${i} for start time offset ${r} found in ${a?"multivariant":"media"} playlist`),this.startPosition=i):e.live?(i=this.hls.liveSyncPosition||t,this.log(`Setting startPosition to -1 to start at live edge ${i}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=i=0),this.lastCurrentTime=i+n}this.nextLoadPosition=i+n}},{key:"getLoadPosition",value:function(){var e,t=this.media,i=0;return null!=(e=this.hls)&&e.hasEnoughToStart&&t?i=t.currentTime:this.nextLoadPosition>=0&&(i=this.nextLoadPosition),i}},{key:"handleFragLoadAborted",value:function(e,t){this.transmuxer&&e.type===this.playlistType&&bT(e)&&e.stats.aborted&&(this.log(`Fragment ${e.sn}${t?" part "+t.index:""} of ${this.playlistLabel()} ${e.level} was aborted`),this.resetFragmentLoading(e))}},{key:"resetFragmentLoading",value:function(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===QD)||(this.state=YD)}},{key:"onFragmentOrKeyLoadError",value:function(e,t){var i;if(t.chunkMeta&&!t.frag){var n=this.getCurrentContext(t.chunkMeta);n&&(t.frag=n.frag)}var a=t.frag;if(a&&a.type===e&&this.levels)if(this.fragContextChanged(a)){var r;this.warn(`Frag load error must match current frag to retry ${a.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`)}else{var o=t.details===LM.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(a,!0);var s=t.errorAction;if(s){var u=s.action,l=s.flags,d=s.retryCount,h=void 0===d?0:d,c=s.retryConfig,m=!!c,f=m&&u===ZP,v=m&&!s.resolved&&l===tA,p=null==(i=this.hls.latestLevelDetails)?void 0:i.live;if(!f&&v&&bT(a)&&!a.endList&&p&&!HP(t))this.resetFragmentErrors(e),this.treatAsGap(a),s.resolved=!0;else if((f||v)&&h<c.maxNumRetry){var g,y=YP(null==(g=t.response)?void 0:g.code),b=VP(c,h);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+b,this.state=QD,s.resolved=!0,y)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(t.reason="offline");this.warn(`Fragment ${a.sn} of ${e} ${a.level} errored with ${t.details}, retrying loading ${h+1}/${c.maxNumRetry} in ${b}ms`)}else if(c){if(this.resetFragmentErrors(e),!(h<c.maxNumRetry))return void this.warn(`${t.details} reached or exceeded max retry (${h})`);o||u===QP||(s.resolved=!0)}else this.state=u===JP?rx:nx;this.tickImmediate()}else this.state=nx}}},{key:"checkRetryDate",value:function(){var e=self.performance.now(),t=this.retryDate,i=t===1/0;(!t||e>=t||i&&!YP(0))&&(i&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=YD)}},{key:"reduceLengthAndFlushBuffer",value:function(e){if(this.state===ex||this.state===tx){var t=e.frag,i=e.parent,n=this.getFwdBufferInfo(this.mediaBuffer,i),a=n&&n.len>.5;a&&this.reduceMaxBufferLength(n.len,(null==t?void 0:t.duration)||10);var r=!a;return r&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${i} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}},{key:"resetFragmentErrors",value:function(e){e===NM&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==XD&&(this.state=YD)}},{key:"afterBufferFlushed",value:function(e,t,i){if(e){var n=DA.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===ix&&this.resetLoadingState()}}},{key:"resetLoadingState",value:function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==XD&&(this.state=YD)}},{key:"resetStartWhenNotLoaded",value:function(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;var e=this.levelLastLoaded,t=e?e.details:null;null!=t&&t.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(t,t.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}},{key:"resetWhenMissingContext",value:function(e){this.log(`Loading context changed while buffering sn ${e.sn} of ${this.playlistLabel()} ${-1===e.level?"<removed>":e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}},{key:"removeUnbufferedFrags",value:function(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}},{key:"updateLevelTiming",value:function(e,t,i,n){var a=i.details;if(a){if(!Object.keys(e.elementaryStreams).reduce((t,r)=>{var o=e.elementaryStreams[r];if(o){var s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${r} duration reliably (${s})`),t||!1;var u=n?0:DD(a,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS,this);return this.hls.trigger(_M.LEVEL_PTS_UPDATED,{details:a,level:i,drift:u,type:r,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1)){var r,o=null===(null==(r=this.transmuxer)?void 0:r.error);if((0===i.fragmentError||o&&(i.fragmentError<2||e.endList))&&this.treatAsGap(e,i),o){var s=new Error(`Found no media in fragment ${e.sn} of ${this.playlistLabel()} ${e.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(s.message),this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_PARSING_ERROR,fatal:!1,error:s,frag:e,reason:`Found no media in msn ${e.sn} of ${this.playlistLabel()} "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=tx,this.log(`Parsed ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.fragInfo(e,!1,t)})`),this.hls.trigger(_M.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}},{key:"playlistLabel",value:function(){return this.playlistType===$M?"level":"track"}},{key:"fragInfo",value:function(e,t=!0,i){var n,a;return`${this.playlistLabel()} ${e.level} (${i?"part":"frag"}:[${(null!=(n=t&&!i?e.startPTS:(i||e).start)?n:NaN).toFixed(3)}-${(null!=(a=t&&!i?e.endPTS:(i||e).end)?a:NaN).toFixed(3)}]${i&&"main"===e.type?"INDEPENDENT="+(i.independent?"YES":"NO"):""}`}},{key:"treatAsGap",value:function(e,t){t&&t.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)}},{key:"resetTransmuxer",value:function(){var e;null==(e=this.transmuxer)||e.reset()}},{key:"recoverWorkerError",value:function(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}},{key:"state",get:function(){return this._state},set:function(e){var t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}}])}();function sx(e){return!!e.interstitialsController&&!1!==e.enableInterstitialPlayback}var ux=function(){return ne(function e(){Q(this,e),this.chunks=[],this.dataLength=0},[{key:"push",value:function(e){this.chunks.push(e),this.dataLength+=e.length}},{key:"flush",value:function(){var e,t=this.chunks,i=this.dataLength;return t.length?(e=1===t.length?t[0]:function(e,t){for(var i=new Uint8Array(t),n=0,a=0;a<e.length;a++){var r=e[a];i.set(r,n),n+=r.length}return i}(t,i),this.reset(),e):new Uint8Array(0)}},{key:"reset",value:function(){this.chunks.length=0,this.dataLength=0}}])}();var lx,dx={exports:{}};var hx=(lx||(lx=1,function(e){var t=Object.prototype.hasOwnProperty,i="~";function n(){}function a(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function r(e,t,n,r,o){if("function"!=typeof n)throw new TypeError("The listener must be a function");var s=new a(n,r||e,o),u=i?i+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],s]:e._events[u].push(s):(e._events[u]=s,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function s(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),s.prototype.eventNames=function(){var e,n,a=[];if(0===this._eventsCount)return a;for(n in e=this._events)t.call(e,n)&&a.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=i?i+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var a=0,r=n.length,o=new Array(r);a<r;a++)o[a]=n[a].fn;return o},s.prototype.listenerCount=function(e){var t=i?i+e:e,n=this._events[t];return n?n.fn?1:n.length:0},s.prototype.emit=function(e,t,n,a,r,o){var s=i?i+e:e;if(!this._events[s])return!1;var u,l,d=this._events[s],h=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),h){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,n),!0;case 4:return d.fn.call(d.context,t,n,a),!0;case 5:return d.fn.call(d.context,t,n,a,r),!0;case 6:return d.fn.call(d.context,t,n,a,r,o),!0}for(l=1,u=new Array(h-1);l<h;l++)u[l-1]=arguments[l];d.fn.apply(d.context,u)}else{var c,m=d.length;for(l=0;l<m;l++)switch(d[l].once&&this.removeListener(e,d[l].fn,void 0,!0),h){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,t);break;case 3:d[l].fn.call(d[l].context,t,n);break;case 4:d[l].fn.call(d[l].context,t,n,a);break;default:if(!u)for(c=1,u=new Array(h-1);c<h;c++)u[c-1]=arguments[c];d[l].fn.apply(d[l].context,u)}}return!0},s.prototype.on=function(e,t,i){return r(this,e,t,i,!1)},s.prototype.once=function(e,t,i){return r(this,e,t,i,!0)},s.prototype.removeListener=function(e,t,n,a){var r=i?i+e:e;if(!this._events[r])return this;if(!t)return o(this,r),this;var s=this._events[r];if(s.fn)s.fn!==t||a&&!s.once||n&&s.context!==n||o(this,r);else{for(var u=0,l=[],d=s.length;u<d;u++)(s[u].fn!==t||a&&!s[u].once||n&&s[u].context!==n)&&l.push(s[u]);l.length?this._events[r]=1===l.length?l[0]:l:o(this,r)}return this},s.prototype.removeAllListeners=function(e){var t;return e?(t=i?i+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=i,s.EventEmitter=s,e.exports=s}(dx)),dx.exports),cx=rT(hx),mx="1.6.16",fx={};function vx(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function px(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function gx(e,t){var i=0;return i=(127&e[t])<<21,i|=(127&e[t+1])<<14,i|=(127&e[t+2])<<7,i|=127&e[t+3]}function yx(e,t){for(var i=t,n=0;px(e,t);){n+=10,n+=gx(e,t+6),vx(e,t+10)&&(n+=10),t+=n}if(n>0)return e.subarray(i,i+n)}function bx(e,t){return 255===e[t]&&240==(246&e[t+1])}function wx(e,t){return 1&e[t+1]?7:9}function kx(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Sx(e,t){return t+1<e.length&&bx(e,t)}function Ex(e,t){if(Sx(e,t)){var i=wx(e,t);if(t+i>=e.length)return!1;var n=kx(e,t);if(n<=i)return!1;var a=t+n;return a===e.length||Sx(e,a)}return!1}function Mx(e,t,i,n,a){if(!e.samplerate){var r=function(e,t,i,n){var a=t[i+2],r=a>>2&15;if(!(r>12)){var o=1+(a>>6&3),s=t[i+3]>>6&3|(1&a)<<2,u="mp4a.40."+o,l=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][r],d=r;5!==o&&29!==o||(d-=3);var h=[o<<3|(14&d)>>1,(1&d)<<7|s<<3];return ZM.log(`manifest codec:${n}, parsed codec:${u}, channels:${s}, rate:${l} (ADTS object type:${o} sampling index:${r})`),{config:h,samplerate:l,channelCount:s,codec:u,parsedCodec:u,manifestCodec:n}}var c=new Error(`invalid ADTS sampling index:${r}`);e.emit(_M.ERROR,_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(t,i,n,a);if(!r)return;HM(e,r)}}function Tx(e){return 9216e4/e}function Px(e,t,i,n,a){var r,o=n+a*Tx(e.samplerate),s=function(e,t){var i=wx(e,t);if(t+i<=e.length){var n=kx(e,t)-i;if(n>0)return{headerLength:i,frameLength:n}}}(t,i);if(s){var u=s.frameLength,l=s.headerLength,d=l+u,h=Math.max(0,i+d-t.length);h?(r=new Uint8Array(d-l)).set(t.subarray(i+l,t.length),0):r=t.subarray(i+l,i+d);var c={unit:r,pts:o};return h||e.samples.push(c),{sample:c,length:d,missing:h}}var m=t.length-i;return(r=new Uint8Array(m)).set(t.subarray(i,t.length),0),{sample:{unit:r,pts:o},length:m,missing:-1}}function Ax(e,t){return px(e,t)&&gx(e,t+6)+10<=e.length-t}function Dx(e,t=0,i=1/0){return function(e,t,i,n){var a=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),r=1;"BYTES_PER_ELEMENT"in n&&(r=n.BYTES_PER_ELEMENT);var o=(h=e,h&&h.buffer instanceof ArrayBuffer&&void 0!==h.byteLength&&void 0!==h.byteOffset?e.byteOffset:0),s=(o+e.byteLength)/r,u=(o+t)/r,l=Math.floor(Math.max(0,Math.min(u,s))),d=Math.floor(Math.min(l+Math.max(i,0),s));var h;return new n(a,l,d-l)}(e,t,i,Uint8Array)}function xx(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var i=e.data.subarray(1).indexOf(0);if(-1!==i){var n=iT(Dx(e.data,1,i)),a=e.data[2+i],r=e.data.subarray(3+i).indexOf(0);if(-1!==r){var o,s=iT(Dx(e.data,3+i,r));return o="--\x3e"===n?iT(Dx(e.data,4+i+r)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+i+r)),t.mimeType=n,t.pictureType=a,t.description=s,t.data=o,t}}}else console.log("Ignore frame with unrecognized character encoding")}function Cx(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=iT(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:i.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,i=iT(e.data.subarray(t),!0);t+=i.length+1;var n=iT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=iT(e.data);return{key:e.type,info:"",data:a}}(e):"APIC"===e.type?xx(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,i=iT(e.data.subarray(t),!0);t+=i.length+1;var n=iT(e.data.subarray(t));return{key:e.type,info:i,data:n}}var a=iT(e.data.subarray(1));return{key:e.type,info:"",data:a}}}(e)}function Ix(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),i=gx(e,4);return{type:t,size:i,data:e.subarray(10,10+i)}}function Lx(e){for(var t=0,i=[];px(e,t);){var n=gx(e,t+6);e[t+5]>>6&1&&(t+=10);for(var a=(t+=10)+n;t+10<a;){var r=Ix(e.subarray(t)),o=Cx(r);o&&i.push(o),t+=r.size+10}vx(e,t)&&(t+=10)}return i}function _x(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function Rx(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),i=1&t[3],n=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return n/=45,i&&(n+=47721858.84),Math.round(n)}}function Fx(e){for(var t=Lx(e),i=0;i<t.length;i++){var n=t[i];if(_x(n))return Rx(n)}}var Wx=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function Ox(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var $x=function(){return ne(function e(){Q(this,e),this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null},[{key:"resetInitSegment",value:function(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}},{key:"resetTimeStamp",value:function(e){this.initPTS=e,this.resetContiguity()}},{key:"resetContiguity",value:function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}},{key:"canParse",value:function(e,t){return!1}},{key:"appendFrame",value:function(e,t,i){}},{key:"demux",value:function(e,t){this.cachedData&&(e=BT(this.cachedData,e),this.cachedData=null);var i,n=yx(e,0),a=n?n.length:0,r=this._audioTrack,o=this._id3Track,s=n?Fx(n):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&DM(s))&&(this.basePTS=Nx(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),n&&n.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Wx.audioId3,duration:Number.POSITIVE_INFINITY});a<u;){if(this.canParse(e,a)){var l=this.appendFrame(r,e,a);l?(this.frameIndex++,this.lastPTS=l.sample.pts,i=a+=l.length):a=u}else Ax(e,a)?(n=yx(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:n,type:Wx.audioId3,duration:Number.POSITIVE_INFINITY}),i=a+=n.length):a++;if(a===u&&i!==u){var d=e.slice(i);this.cachedData?this.cachedData=BT(this.cachedData,d):this.cachedData=d}}return{audioTrack:r,videoTrack:Ox(),id3Track:o,textTrack:Ox()}}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}},{key:"flush",value:function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Ox(),id3Track:this._id3Track,textTrack:Ox()}}},{key:"destroy",value:function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}])}(),Nx=(e,t,i)=>DM(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0),jx=null,Bx=[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],zx=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ux=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Hx=[0,1,1,4];function Gx(e,t,i,n,a){if(!(i+24>t.length)){var r=Vx(t,i);if(r&&i+r.frameLength<=t.length){var o=n+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(i,i+r.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=r.channelCount,e.samplerate=r.sampleRate,e.samples.push(s),{sample:s,length:r.frameLength,missing:0}}}}function Vx(e,t){var i=e[t+1]>>3&3,n=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==i&&0!==a&&15!==a&&3!==r){var o=e[t+2]>>1&1,s=e[t+3]>>6,u=1e3*Bx[14*(3===i?3-n:3===n?3:4)+a-1],l=zx[3*(3===i?0:2===i?1:2)+r],d=3===s?1:2,h=Ux[i][n],c=Hx[n],m=8*h*c,f=Math.floor(h*u/l+o)*c;if(null===jx){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);jx=v?parseInt(v[1]):0}return!!jx&&jx<=87&&2===n&&u>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:d,frameLength:f,samplesPerFrame:m}}}function Kx(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Xx(e,t){return t+1<e.length&&Kx(e,t)}function Yx(e,t){if(t+1<e.length&&Kx(e,t)){var i=Vx(e,t),n=4;null!=i&&i.frameLength&&(n=i.frameLength);var a=t+n;return a===e.length||Xx(e,a)}return!1}var qx=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e)).observer=void 0,n.config=void 0,n.observer=t,n.config=i,n}return ue(e,$x),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&bx(e,t)&&kx(e,t)<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){Mx(e,this.observer,t,i,e.manifestCodec);var n=Px(e,t,i,this.basePTS,this.frameIndex);if(n&&0===n.missing)return n}}],[{key:"probe",value:function(e,t){if(!e)return!1;var i=yx(e,0),n=(null==i?void 0:i.length)||0;if(Yx(e,n))return!1;for(var a=e.length;n<a;n++)if(Ex(e,n))return t.log("ADTS sync word found !"),!0;return!1}}])}(),Jx=(e,t)=>{var i=0,n=5;t+=n;for(var a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);n>0;){o[0]=e[t];var s=Math.min(n,8),u=8-s;r[0]=4278190080>>>24+u<<u,a[0]=(o[0]&r[0])>>u,i=i?i<<s|a[0]:a[0],t+=1,n-=s}return i},Qx=function(){function e(t){var i;return Q(this,e),(i=J(this,e)).observer=void 0,i.observer=t,i}return ue(e,$x),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return t+64<e.length}},{key:"appendFrame",value:function(e,t,i){var n=Zx(e,t,i,this.basePTS,this.frameIndex);if(-1!==n)return{sample:e.samples[e.samples.length-1],length:n,missing:0}}}],[{key:"probe",value:function(e){if(!e)return!1;var t=yx(e,0);if(!t)return!1;var i=t.length;return 11===e[i]&&119===e[i+1]&&void 0!==Fx(t)&&Jx(e,i)<16}}])}();function Zx(e,t,i,n,a){if(i+8>t.length)return-1;if(11!==t[i]||119!==t[i+1])return-1;var r=t[i+4]>>6;if(r>=3)return-1;var o=[48e3,44100,32e3][r],s=63&t[i+4],u=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*s+r];if(i+u>t.length)return-1;var l=t[i+6]>>5,d=0;2===l?d+=2:(1&l&&1!==l&&(d+=2),4&l&&(d+=2));var h=(t[i+6]<<8|t[i+7])>>12-d&1,c=[2,1,2,3,3,4,4,5][l]+h,m=t[i+5]>>3,f=7&t[i+5],v=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|h<<2|s>>4,s<<4&224]),p=n+a*(1536/o*9e4),g=t.subarray(i,i+u);return e.config=v,e.channelCount=c,e.samplerate=o,e.samples.push({unit:g,pts:p}),u}var eC=function(){function e(){return Q(this,e),J(this,e,arguments)}return ue(e,$x),ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){pe(e,"resetInitSegment",this)([t,i,n,a]),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:i,duration:a,inputTimeScale:9e4,dropped:0}}},{key:"canParse",value:function(e,t){return function(e,t){return Kx(e,t)&&4<=e.length-t}(e,t)}},{key:"appendFrame",value:function(e,t,i){if(null!==this.basePTS)return Gx(e,t,i,this.basePTS,this.frameIndex)}}],[{key:"probe",value:function(e){if(!e)return!1;var t=yx(e,0),i=(null==t?void 0:t.length)||0;if(t&&11===e[i]&&119===e[i+1]&&void 0!==Fx(t)&&Jx(e,i)<=16)return!1;for(var n=e.length;i<n;i++)if(Yx(e,i))return ZM.log("MPEG Audio sync word found !"),!0;return!1}}])}(),tC=/\/emsg[-/]ID3/i,iC=function(){return ne(function e(t,i){Q(this,e),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=i},[{key:"resetTimeStamp",value:function(){}},{key:"resetInitSegment",value:function(e,t,i,n){var a=this.videoTrack=Ox("video",1),r=this.audioTrack=Ox("audio",1),o=this.txtTrack=Ox("text",1);if(this.id3Track=Ox("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var s=_T(e);if(s.video){var u=s.video,l=u.id,d=u.timescale,h=u.codec,c=u.supplemental;a.id=l,a.timescale=o.timescale=d,a.codec=h,a.supplemental=c}if(s.audio){var m=s.audio,f=m.id,v=m.timescale,p=m.codec;r.id=f,r.timescale=v,r.codec=p}o.id=TT.text,a.sampleDuration=0,a.duration=r.duration=n}}},{key:"resetContiguity",value:function(){this.remainderData=null}},{key:"demux",value:function(e,t){this.timeOffset=t;var i=e,n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=BT(this.remainderData,e));var r=function(e){var t={valid:null,remainder:null},i=IT(e,["moof"]);if(i.length<2)return t.remainder=e,t;var n=i[i.length-1];return t.valid=e.slice(0,n.byteOffset-8),t.remainder=e.slice(n.byteOffset-8),t}(i);this.remainderData=r.remainder,n.samples=r.valid||new Uint8Array}else n.samples=i;var o=this.extractID3Track(n,t);return a.samples=zT(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}},{key:"flush",value:function(){var e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var n=this.extractID3Track(t,this.timeOffset);return i.samples=zT(e,t),{videoTrack:t,audioTrack:Ox(),id3Track:n,textTrack:Ox()}}},{key:"extractID3Track",value:function(e,t){var i=this.id3Track;if(e.samples.length){var n=IT(e.samples,["emsg"]);n&&n.forEach(e=>{var n=function(e){var t=e[0],i="",n="",a=0,r=0,o=0,s=0,u=0,l=0;if(0===t){for(;"\0"!==PT(e.subarray(l,l+1));)i+=PT(e.subarray(l,l+1)),l+=1;for(i+=PT(e.subarray(l,l+1)),l+=1;"\0"!==PT(e.subarray(l,l+1));)n+=PT(e.subarray(l,l+1)),l+=1;n+=PT(e.subarray(l,l+1)),l+=1,a=DT(e,12),r=DT(e,16),s=DT(e,20),u=DT(e,24),l=28}else if(1===t){a=DT(e,l+=4);var d=DT(e,l+=4),h=DT(e,l+=4);for(l+=4,xM(o=2**32*d+h)||(o=Number.MAX_SAFE_INTEGER,ZM.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=DT(e,l),u=DT(e,l+=4),l+=4;"\0"!==PT(e.subarray(l,l+1));)i+=PT(e.subarray(l,l+1)),l+=1;for(i+=PT(e.subarray(l,l+1)),l+=1;"\0"!==PT(e.subarray(l,l+1));)n+=PT(e.subarray(l,l+1)),l+=1;n+=PT(e.subarray(l,l+1)),l+=1}return{schemeIdUri:i,value:n,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:u,payload:e.subarray(l,e.byteLength)}}(e);if(tC.test(n.schemeIdUri)){var a=nC(n,t),r=4294967295===n.eventDuration?Number.POSITIVE_INFINITY:n.eventDuration/n.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);var o=n.payload;i.samples.push({data:o,len:o.byteLength,dts:a,pts:a,type:Wx.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&n.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var s=nC(n,t);i.samples.push({data:n.payload,len:n.payload.byteLength,dts:s,pts:s,type:Wx.misbklv,duration:Number.POSITIVE_INFINITY})}})}return i}},{key:"demuxSampleAes",value:function(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}},{key:"destroy",value:function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}}],[{key:"probe",value:function(e){return function(e){for(var t=e.byteLength,i=0;i<t;){var n=DT(e,i);if(n>8&&109===e[i+4]&&111===e[i+5]&&111===e[i+6]&&102===e[i+7])return!0;i=n>1?i+n:t}return!1}(e)}}])}();function nC(e,t){return DM(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var aC=function(){return ne(function e(t,i,n){Q(this,e),this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new bA(i,{removePKCS7Padding:!1})},[{key:"decryptBuffer",value:function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,fA)}},{key:"decryptAacSample",value:function(e,t,i){var n=e[t].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then(a=>{var r=new Uint8Array(a);n.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)}).catch(i)}}},{key:"decryptAacSamples",value:function(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}},{key:"getAvcEncryptedData",value:function(e){for(var t=16*Math.floor((e.length-48)/160)+16,i=new Int8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}},{key:"getAvcDecryptedUnit",value:function(e,t){for(var i=new Uint8Array(t),n=0,a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}},{key:"decryptAvcSample",value:function(e,t,i,n,a){var r=VT(a.data),o=this.getAvcEncryptedData(r);this.decryptBuffer(o.buffer).then(o=>{a.data=this.getAvcDecryptedUnit(r,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)}).catch(n)}},{key:"decryptAvcSamples",value:function(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void n();for(var a=e[t].units;!(i>=a.length);i++){var r=a[i];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,i,n,r),this.decrypter.isSync())))return}}}}])}(),rC=function(){return ne(function e(){Q(this,e),this.VideoSample=null},[{key:"createVideoSample",value:function(e,t,i){return{key:e,frame:!1,pts:t,dts:i,units:[],length:0}}},{key:"getLastNalUnit",value:function(e){var t,i,n=this.VideoSample;if(n&&0!==n.units.length||(n=e[e.length-1]),null!=(t=n)&&t.units){var a=n.units;i=a[a.length-1]}return i}},{key:"pushAccessUnit",value:function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,n=i.length;if(!n)return void t.dropped++;var a=i[n-1];e.pts=a.pts,e.dts=a.dts}t.samples.push(e)}}},{key:"parseNALu",value:function(e,t,i){var n,a,r=t.byteLength,o=e.naluState||0,s=o,u=[],l=0,d=-1,h=0;for(-1===o&&(d=0,h=this.getNALuType(t,0),o=0,l=1);l<r;)if(n=t[l++],o)if(1!==o)if(n)if(1===n){if(a=l-o-1,d>=0){var c={data:t.subarray(d,a),type:h};u.push(c)}else{var m=this.getLastNalUnit(e.samples);m&&(s&&l<=4-s&&m.state&&(m.data=m.data.subarray(0,m.data.byteLength-s)),a>0&&(m.data=BT(m.data,t.subarray(0,a)),m.state=0))}l<r?(d=l,h=this.getNALuType(t,l),o=0):o=-1}else o=0;else o=3;else o=n?0:2;else o=n?0:1;if(d>=0&&o>=0){var f={data:t.subarray(d,r),type:h,state:o};u.push(f)}if(0===u.length){var v=this.getLastNalUnit(e.samples);v&&(v.data=BT(v.data,t))}return e.naluState=o,u}}])}(),oC=function(){return ne(function e(t){Q(this,e),this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0},[{key:"loadWord",value:function(){var e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}},{key:"skipBits",value:function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}},{key:"readBits",value:function(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(e>32&&ZM.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?i<<t|this.readBits(t):i}},{key:"skipLZ",value:function(){var e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"skipEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var e=this.skipLZ();return this.readBits(e+1)-1}},{key:"readEG",value:function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}},{key:"readBoolean",value:function(){return 1===this.readBits(1)}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"readUShort",value:function(){return this.readBits(16)}},{key:"readUInt",value:function(){return this.readBits(32)}}])}(),sC=function(){function e(){return Q(this,e),J(this,e,arguments)}return ue(e,rC),ne(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 1:var l=!1;a=!0;var d,h=n.data;if(s&&h.length>4){var c=this.readSliceType(h);2!==c&&4!==c&&7!==c&&9!==c||(l=!0)}if(l)null!=(d=o)&&d.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.frame=!0,o.key=l;break;case 5:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 6:a=!0,GT(n.data,1,i.pts,t.samples);break;case 7:var m,f;a=!0,s=!0;var v=n.data,p=this.readSPS(v);if(!e.sps||e.width!==p.width||e.height!==p.height||(null==(m=e.pixelRatio)?void 0:m[0])!==p.pixelRatio[0]||(null==(f=e.pixelRatio)?void 0:f[1])!==p.pixelRatio[1]){e.width=p.width,e.height=p.height,e.pixelRatio=p.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),y="avc1.",b=0;b<3;b++){var w=g[b].toString(16);w.length<2&&(w="0"+w),y+=w}e.codec=y}break;case 8:a=!0,e.pps=[n.data];break;case 9:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;case 12:a=!0;break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"getNALuType",value:function(e,t){return 31&e[t]}},{key:"readSliceType",value:function(e){var t=new oC(e);return t.readUByte(),t.readUEG(),t.readUEG()}},{key:"skipScalingList",value:function(e,t){for(var i=8,n=8,a=0;a<e;a++)0!==n&&(n=(i+t.readEG()+256)%256),i=0===n?i:n}},{key:"readSPS",value:function(e){var t,i,n,a=new oC(e),r=0,o=0,s=0,u=0,l=a.readUByte.bind(a),d=a.readBits.bind(a),h=a.readUEG.bind(a),c=a.readBoolean.bind(a),m=a.skipBits.bind(a),f=a.skipEG.bind(a),v=a.skipUEG.bind(a),p=this.skipScalingList.bind(this);l();var g=l();if(d(5),m(3),l(),v(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){var y=h();if(3===y&&m(1),v(),v(),m(1),c())for(i=3!==y?8:12,n=0;n<i;n++)c()&&p(n<6?16:64,a)}v();var b=h();if(0===b)h();else if(1===b)for(m(1),f(),f(),t=h(),n=0;n<t;n++)f();v(),m(1);var w=h(),k=h(),S=d(1);0===S&&m(1),m(1),c()&&(r=h(),o=h(),s=h(),u=h());var E=[1,1];if(c()&&c())switch(l()){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=[l()<<8|l(),l()<<8|l()]}return{width:Math.ceil(16*(w+1)-2*r-2*o),height:(2-S)*(k+1)*16-(S?2:4)*(s+u),pixelRatio:E}}}])}(),uC=function(){function e(...t){var i;return Q(this,e),(i=J(this,e,[...t])).initVPS=null,i}return ue(e,rC),ne(e,[{key:"parsePES",value:function(e,t,i,n){var a,r=this.parseNALu(e,i.data,n),o=this.VideoSample,s=!1;i.data=null,o&&r.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),r.forEach(n=>{var r,u;switch(n.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts)),o.frame=!0,a=!0;break;case 16:case 17:case 18:case 21:var l;if(a=!0,s)null!=(l=o)&&l.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null);o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 19:case 20:a=!0,null!=(r=o)&&r.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0,o.frame=!0;break;case 39:a=!0,GT(n.data,2,i.pts,t.samples);break;case 32:a=!0,e.vps||("object"!=typeof e.params&&(e.params={}),e.params=HM(e.params,this.readVPS(n.data)),this.initVPS=n.data),e.vps=[n.data];break;case 33:if(a=!0,s=!0,void 0===e.vps||e.vps[0]===this.initVPS||void 0===e.sps||this.matchSPS(e.sps[0],n.data)||(this.initVPS=e.vps[0],e.sps=e.pps=void 0),!e.sps){var d=this.readSPS(n.data);for(var h in e.width=d.width,e.height=d.height,e.pixelRatio=d.pixelRatio,e.codec=d.codecString,e.sps=[],"object"!=typeof e.params&&(e.params={}),d.params)e.params[h]=d.params[h]}this.pushParameterSet(e.sps,n.data,e.vps),o||(o=this.VideoSample=this.createVideoSample(!0,i.pts,i.dts)),o.key=!0;break;case 34:if(a=!0,"object"==typeof e.params){if(!e.pps){e.pps=[];var c=this.readPPS(n.data);for(var m in c)e.params[m]=c[m]}this.pushParameterSet(e.pps,n.data,e.vps)}break;case 35:a=!0,e.audFound=!0,null!=(u=o)&&u.frame&&(this.pushAccessUnit(o,e),o=null),o||(o=this.VideoSample=this.createVideoSample(!1,i.pts,i.dts));break;default:a=!1}o&&a&&o.units.push(n)}),n&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}},{key:"pushParameterSet",value:function(e,t,i){(i&&i[0]===this.initVPS||!i&&!e.length)&&e.push(t)}},{key:"getNALuType",value:function(e,t){return(126&e[t])>>>1}},{key:"ebsp2rbsp",value:function(e){for(var t=new Uint8Array(e.byteLength),i=0,n=0;n<e.byteLength;n++)n>=2&&3===e[n]&&0===e[n-1]&&0===e[n-2]||(t[i]=e[n],i++);return new Uint8Array(t.buffer,0,i)}},{key:"pushAccessUnit",value:function(t,i){pe(e,"pushAccessUnit",this)([t,i]),this.initVPS&&(this.initVPS=null)}},{key:"readVPS",value:function(e){var t=new oC(e);return t.readUByte(),t.readUByte(),t.readBits(4),t.skipBits(2),t.readBits(6),{numTemporalLayers:t.readBits(3)+1,temporalIdNested:t.readBoolean()}}},{key:"readSPS",value:function(e){var t=new oC(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.readBits(4);var i=t.readBits(3);t.readBoolean();for(var n=t.readBits(2),a=t.readBoolean(),r=t.readBits(5),o=t.readUByte(),s=t.readUByte(),u=t.readUByte(),l=t.readUByte(),d=t.readUByte(),h=t.readUByte(),c=t.readUByte(),m=t.readUByte(),f=t.readUByte(),v=t.readUByte(),p=t.readUByte(),g=[],y=[],b=0;b<i;b++)g.push(t.readBoolean()),y.push(t.readBoolean());if(i>0)for(var w=i;w<8;w++)t.readBits(2);for(var k=0;k<i;k++)g[k]&&(t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte(),t.readUByte()),y[k]&&t.readUByte();t.readUEG();var S=t.readUEG();3==S&&t.skipBits(1);var E=t.readUEG(),M=t.readUEG(),T=t.readBoolean(),P=0,A=0,D=0,x=0;T&&(P+=t.readUEG(),A+=t.readUEG(),D+=t.readUEG(),x+=t.readUEG());for(var C=t.readUEG(),I=t.readUEG(),L=t.readUEG(),_=t.readBoolean()?0:i;_<=i;_++)t.skipUEG(),t.skipUEG(),t.skipUEG();if((t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG(),t.readBoolean())&&t.readBoolean())for(var R=0;R<4;R++)for(var F=0;F<(3===R?2:6);F++){if(t.readBoolean()){var W=Math.min(64,1<<4+(R<<1));R>1&&t.readEG();for(var O=0;O<W;O++)t.readEG()}else t.readUEG()}t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.skipUEG(),t.skipUEG(),t.readBoolean());for(var $=t.readUEG(),N=0,j=0;j<$;j++){var B=!1;if(0!==j&&(B=t.readBoolean()),B){j===$&&t.readUEG(),t.readBoolean(),t.readUEG();for(var z=0,U=0;U<=N;U++){var H=t.readBoolean(),G=!1;H||(G=t.readBoolean()),(H||G)&&z++}N=z}else{var V=t.readUEG(),K=t.readUEG();N=V+K;for(var X=0;X<V;X++)t.readUEG(),t.readBoolean();for(var Y=0;Y<K;Y++)t.readUEG(),t.readBoolean()}}if(t.readBoolean())for(var q=t.readUEG(),J=0;J<q;J++){for(var Q=0;Q<L+4;Q++)t.readBits(1);t.readBits(1)}var Z=0,ee=1,te=1,ie=!0,ne=1,ae=0;t.readBoolean(),t.readBoolean();if(t.readBoolean()){if(t.readBoolean()){var re=t.readUByte();re>0&&re<16?(ee=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][re-1],te=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][re-1]):255===re&&(ee=t.readBits(16),te=t.readBits(16))}if(t.readBoolean()&&t.readBoolean(),t.readBoolean())t.readBits(3),t.readBoolean(),t.readBoolean()&&(t.readUByte(),t.readUByte(),t.readUByte());if(t.readBoolean()&&(t.readUEG(),t.readUEG()),t.readBoolean(),t.readBoolean(),t.readBoolean(),t.readBoolean()&&(t.skipUEG(),t.skipUEG(),t.skipUEG(),t.skipUEG()),t.readBoolean())if(ne=t.readBits(32),ae=t.readBits(32),t.readBoolean()&&t.readUEG(),t.readBoolean()){var oe=t.readBoolean(),se=t.readBoolean(),ue=!1;(oe||se)&&((ue=t.readBoolean())&&(t.readUByte(),t.readBits(5),t.readBoolean(),t.readBits(5)),t.readBits(4),t.readBits(4),ue&&t.readBits(4),t.readBits(5),t.readBits(5),t.readBits(5));for(var le=0;le<=i;le++){var de=!1;(ie=t.readBoolean())||t.readBoolean()?t.readEG():de=t.readBoolean();var he=de?1:t.readUEG()+1;if(oe)for(var ce=0;ce<he;ce++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1);if(se)for(var me=0;me<he;me++)t.readUEG(),t.readUEG(),ue&&(t.readUEG(),t.readUEG()),t.skipBits(1)}}t.readBoolean()&&(t.readBoolean(),t.readBoolean(),t.readBoolean(),Z=t.readUEG())}var fe=E,ve=M;if(T){var pe=1,ge=1;1===S?pe=ge=2:2==S&&(pe=2),fe=E-pe*A-pe*P,ve=M-ge*x-ge*D}for(var ye=n?["A","B","C"][n]:"",be=o<<24|s<<16|u<<8|l,we=0,ke=0;ke<32;ke++)we=(we|(be>>ke&1)<<31-ke)>>>0;var Se=we.toString(16);return 1===r&&"2"===Se&&(Se="6"),{codecString:`hvc1.${ye}${r}.${Se}.${a?"H":"L"}${p}.B0`,params:{general_tier_flag:a,general_profile_idc:r,general_profile_space:n,general_profile_compatibility_flags:[o,s,u,l],general_constraint_indicator_flags:[d,h,c,m,f,v],general_level_idc:p,bit_depth:C+8,bit_depth_luma_minus8:C,bit_depth_chroma_minus8:I,min_spatial_segmentation_idc:Z,chroma_format_idc:S,frame_rate:{fixed:ie,fps:ae/ne}},width:fe,height:ve,pixelRatio:[ee,te]}}},{key:"readPPS",value:function(e){var t=new oC(this.ebsp2rbsp(e));t.readUByte(),t.readUByte(),t.skipUEG(),t.skipUEG(),t.skipBits(2),t.skipBits(3),t.skipBits(2),t.skipUEG(),t.skipUEG(),t.skipEG(),t.skipBits(2),t.readBoolean()&&t.skipUEG(),t.skipEG(),t.skipEG(),t.skipBits(4);var i=t.readBoolean(),n=t.readBoolean(),a=1;return n&&i?a=0:n?a=3:i&&(a=2),{parallelismType:a}}},{key:"matchSPS",value:function(e,t){return String.fromCharCode.apply(null,e).substr(3)===String.fromCharCode.apply(null,t).substr(3)}}])}(),lC=188,dC=function(){function e(t,i,n,a){Q(this,e),this.logger=void 0,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._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=i,this.typeSupported=n,this.logger=a,this.videoParser=null}return ne(e,[{key:"resetInitSegment",value:function(t,i,n,a){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=e.createTrack("video"),this._videoTrack.duration=a,this._audioTrack=e.createTrack("audio",a),this._id3Track=e.createTrack("id3"),this._txtTrack=e.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=i,this.videoCodec=n}},{key:"resetTimeStamp",value:function(){}},{key:"resetContiguity",value:function(){var e=this._audioTrack,t=this._videoTrack,i=this._id3Track;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.remainderData=null}},{key:"demux",value:function(t,i,n=!1,a=!1){var r;n||(this.sampleAes=null);var o=this._videoTrack,s=this._audioTrack,u=this._id3Track,l=this._txtTrack,d=o.pid,h=o.pesData,c=s.pid,m=u.pid,f=s.pesData,v=u.pesData,p=null,g=this.pmtParsed,y=this._pmtId,b=t.length;if(this.remainderData&&(b=(t=BT(this.remainderData,t)).length,this.remainderData=null),b<lC&&!a)return this.remainderData=t,{audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};var w=Math.max(0,e.syncOffset(t));(b-=(b-w)%lC)<t.byteLength&&!a&&(this.remainderData=new Uint8Array(t.buffer,b,t.buffer.byteLength-b));for(var k=0,S=w;S<b;S+=lC)if(71===t[S]){var E=!!(64&t[S+1]),M=hC(t,S),T=void 0;if((48&t[S+3])>>4>1){if((T=S+5+t[S+4])===S+lC)continue}else T=S+4;switch(M){case d:E&&(h&&(r=pC(h,this.logger))&&(this.readyVideoParser(o.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(o,l,r,!1)),h={data:[],size:0}),h&&(h.data.push(t.subarray(T,S+lC)),h.size+=S+lC-T);break;case c:if(E){if(f&&(r=pC(f,this.logger)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r);break;case"ac3":this.parseAC3PES(s,r)}f={data:[],size:0}}f&&(f.data.push(t.subarray(T,S+lC)),f.size+=S+lC-T);break;case m:E&&(v&&(r=pC(v,this.logger))&&this.parseID3PES(u,r),v={data:[],size:0}),v&&(v.data.push(t.subarray(T,S+lC)),v.size+=S+lC-T);break;case 0:E&&(T+=t[T]+1),y=this._pmtId=cC(t,T);break;case y:E&&(T+=t[T]+1);var P=mC(t,T,this.typeSupported,n,this.observer,this.logger);(d=P.videoPid)>0&&(o.pid=d,o.segmentCodec=P.segmentVideoCodec),(c=P.audioPid)>0&&(s.pid=c,s.segmentCodec=P.segmentAudioCodec),(m=P.id3Pid)>0&&(u.pid=m),null===p||g||(this.logger.warn(`MPEG-TS PMT found at ${S} after unknown PID '${p}'. Backtracking to sync byte @${w} to parse all TS packets.`),p=null,S=w-188),g=this.pmtParsed=!0;break;case 17:case 8191:break;default:p=M}}else k++;k>0&&fC(this.observer,new Error(`Found ${k} TS packet/s that do not start with 0x47`),void 0,this.logger),o.pesData=h,s.pesData=f,u.pesData=v;var A={audioTrack:s,videoTrack:o,id3Track:u,textTrack:l};return a&&this.extractRemainingSamples(A),A}},{key:"flush",value:function(){var e,t=this.remainderData;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}},{key:"extractRemainingSamples",value:function(e){var t,i=e.audioTrack,n=e.videoTrack,a=e.id3Track,r=e.textTrack,o=n.pesData,s=i.pesData,u=a.pesData;if(o&&(t=pC(o,this.logger))?(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(n,r,t,!0),n.pesData=null)):n.pesData=o,s&&(t=pC(s,this.logger))){switch(i.segmentCodec){case"aac":this.parseAACPES(i,t);break;case"mp3":this.parseMPEGPES(i,t);break;case"ac3":this.parseAC3PES(i,t)}i.pesData=null}else null!=s&&s.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),i.pesData=s;u&&(t=pC(u,this.logger))?(this.parseID3PES(a,t),a.pesData=null):a.pesData=u}},{key:"demuxSampleAes",value:function(e,t,i){var n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new aC(this.observer,this.config,t);return this.decrypt(n,a)}},{key:"readyVideoParser",value:function(e){null===this.videoParser&&("avc"===e?this.videoParser=new sC:"hevc"===e&&(this.videoParser=new uC))}},{key:"decrypt",value:function(e,t){return new Promise(i=>{var n=e.audioTrack,a=e.videoTrack;n.samples&&"aac"===n.segmentCodec?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}},{key:"destroy",value:function(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}},{key:"parseAACPES",value:function(e,t){var i,n,a,r=0,o=this.aacOverFlow,s=t.data;if(o){this.aacOverFlow=null;var u=o.missing,l=o.sample.unit.byteLength;if(-1===u)s=BT(o.sample.unit,s);else{var d=l-u;o.sample.unit.set(s.subarray(0,u),d),e.samples.push(o.sample),r=o.missing}}for(i=r,n=s.length;i<n-1&&!Sx(s,i);i++);if(i!==r){var h,c=i<n-1;if(h=c?`AAC PES did not start with ADTS header,offset:${i}`:"No ADTS header found in AAC PES",fC(this.observer,new Error(h),c,this.logger),!c)return}if(Mx(e,this.observer,s,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!o)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var m=Tx(e.samplerate);a=o.sample.pts+m}for(var f,v=0;i<n;){if(i+=(f=Px(e,s,i,a,v)).length,f.missing){this.aacOverFlow=f;break}for(v++;i<n-1&&!Sx(s,i);i++);}}},{key:"parseMPEGPES",value:function(e,t){var i=t.data,n=i.length,a=0,r=0,o=t.pts;if(void 0!==o)for(;r<n;)if(Xx(i,r)){var s=Gx(e,i,r,o,a);if(!s)break;r+=s.length,a++}else r++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}},{key:"parseAC3PES",value:function(e,t){var i=t.data,n=t.pts;if(void 0!==n)for(var a,r=i.length,o=0,s=0;s<r&&(a=Zx(e,i,s,n,o++))>0;)s+=a;else this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS")}},{key:"parseID3PES",value:function(e,t){if(void 0!==t.pts){var i=HM({},t,{type:this._videoTrack?Wx.emsg:Wx.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}else this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")}}],[{key:"probe",value:function(t,i){var n=e.syncOffset(t);return n>0&&i.warn(`MPEG2-TS detected but first sync word found @ offset ${n}`),-1!==n}},{key:"syncOffset",value:function(e){for(var t=e.length,i=Math.min(940,t-lC)+1,n=0;n<i;){for(var a=!1,r=-1,o=0,s=n;s<t;s+=lC){if(71!==e[s]||t-s!==lC&&71!==e[s+lC]){if(o)return-1;break}if(o++,-1===r&&0!==(r=s)&&(i=Math.min(r+18612,e.length-lC)+1),a||(a=0===hC(e,s)),a&&o>1&&(0===r&&o>2||s+lC>i))return r}n++}return-1}},{key:"createTrack",value:function(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:TT[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}}])}();function hC(e,t){return((31&e[t+1])<<8)+e[t+2]}function cC(e,t){return(31&e[t+10])<<8|e[t+11]}function mC(e,t,i,n,a,r){var o={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},s=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<s;){var u=hC(e,t),l=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!n){vC("ADTS AAC",r);break}case 15:-1===o.audioPid&&(o.audioPid=u);break;case 21:-1===o.id3Pid&&(o.id3Pid=u);break;case 219:if(!n){vC("H.264",r);break}case 27:-1===o.videoPid&&(o.videoPid=u);break;case 3:case 4:i.mpeg||i.mp3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="mp3"):r.log("MPEG audio found, not supported in this browser");break;case 193:if(!n){vC("AC-3",r);break}case 129:i.ac3?-1===o.audioPid&&(o.audioPid=u,o.segmentAudioCodec="ac3"):r.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===o.audioPid&&l>0)for(var d=t+5,h=l;h>2;){if(106===e[d])!0!==i.ac3?r.log("AC-3 audio found, not supported in this browser for now"):(o.audioPid=u,o.segmentAudioCodec="ac3");var c=e[d+1]+2;d+=c,h-=c}break;case 194:case 135:return fC(a,new Error("Unsupported EC-3 in M2TS found"),void 0,r),o;case 36:-1===o.videoPid&&(o.videoPid=u,o.segmentVideoCodec="hevc",r.log("HEVC in M2TS found"))}t+=l+5}return o}function fC(e,t,i,n){n.warn(`parsing error: ${t.message}`),e.emit(_M.ERROR,_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_PARSING_ERROR,fatal:!1,levelRetry:i,error:t,reason:t.message})}function vC(e,t){t.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function pC(e,t){var i,n,a,r,o,s=0,u=e.data;if(!e||0===e.size)return null;for(;u[0].length<19&&u.length>1;)u[0]=BT(u[0],u[1]),u.splice(1,1);if(1===((i=u[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>e.size-6)return null;var l=i[7];192&l&&(r=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&l?r-(o=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(t.warn(`${Math.round((r-o)/9e4)}s delta between PTS and DTS, align them`),r=o):o=r);var d=(a=i[8])+9;if(e.size<=d)return null;e.size-=d;for(var h=new Uint8Array(e.size),c=0,m=u.length;c<m;c++){var f=(i=u[c]).byteLength;if(d){if(d>f){d-=f;continue}i=i.subarray(d),f-=d,d=0}h.set(i,s),s+=f}return n&&(n-=a+3),{data:h,pts:r,dts:o,len:n}}return null}var gC=function(){return ne(function e(){Q(this,e)},null,[{key:"getSilentFrame",value:function(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}])}(),yC=Math.pow(2,32)-1,bC=function(){function e(){Q(this,e)}return ne(e,null,[{key:"init",value:function(){var t;for(t in e.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},e.types)e.types.hasOwnProperty(t)&&(e.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);var i=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]),n=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]);e.HDLR_TYPES={video:i,audio:n};var a=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);e.STTS=e.STSC=e.STCO=r,e.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),e.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),e.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),e.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var o=new Uint8Array([105,115,111,109]),s=new Uint8Array([97,118,99,49]),u=new Uint8Array([0,0,0,1]);e.FTYP=e.box(e.types.ftyp,o,u,o,s),e.DINF=e.box(e.types.dinf,e.box(e.types.dref,a))}},{key:"box",value:function(e,...t){for(var i=8,n=t.length,a=n;n--;)i+=t[n].byteLength;var r=new Uint8Array(i);for(r[0]=i>>24&255,r[1]=i>>16&255,r[2]=i>>8&255,r[3]=255&i,r.set(e,4),n=0,i=8;n<a;n++)r.set(t[n],i),i+=t[n].byteLength;return r}},{key:"hdlr",value:function(t){return e.box(e.types.hdlr,e.HDLR_TYPES[t])}},{key:"mdat",value:function(t){return e.box(e.types.mdat,t)}},{key:"mdhd",value:function(t,i){i*=t;var n=Math.floor(i/(yC+1)),a=Math.floor(i%(yC+1));return e.box(e.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,85,196,0,0]))}},{key:"mdia",value:function(t){return e.box(e.types.mdia,e.mdhd(t.timescale||0,t.duration||0),e.hdlr(t.type),e.minf(t))}},{key:"mfhd",value:function(t){return e.box(e.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}},{key:"minf",value:function(t){return"audio"===t.type?e.box(e.types.minf,e.box(e.types.smhd,e.SMHD),e.DINF,e.stbl(t)):e.box(e.types.minf,e.box(e.types.vmhd,e.VMHD),e.DINF,e.stbl(t))}},{key:"moof",value:function(t,i,n){return e.box(e.types.moof,e.mfhd(t),e.traf(n,i))}},{key:"moov",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trak(t[i]);return e.box.apply(null,[e.types.moov,e.mvhd(t[0].timescale||0,t[0].duration||0)].concat(n).concat(e.mvex(t)))}},{key:"mvex",value:function(t){for(var i=t.length,n=[];i--;)n[i]=e.trex(t[i]);return e.box.apply(null,[e.types.mvex,...n])}},{key:"mvhd",value:function(t,i){i*=t;var n=Math.floor(i/(yC+1)),a=Math.floor(i%(yC+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,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 e.box(e.types.mvhd,r)}},{key:"sdtp",value:function(t){var i,n,a=t.samples||[],r=new Uint8Array(4+a.length);for(i=0;i<a.length;i++)n=a[i].flags,r[i+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return e.box(e.types.sdtp,r)}},{key:"stbl",value:function(t){return e.box(e.types.stbl,e.stsd(t),e.box(e.types.stts,e.STTS),e.box(e.types.stsc,e.STSC),e.box(e.types.stsz,e.STSZ),e.box(e.types.stco,e.STCO))}},{key:"avc1",value:function(t){var i,n,a,r=[],o=[];for(i=0;i<t.sps.length;i++)a=(n=t.sps[i]).byteLength,r.push(a>>>8&255),r.push(255&a),r=r.concat(Array.prototype.slice.call(n));for(i=0;i<t.pps.length;i++)a=(n=t.pps[i]).byteLength,o.push(a>>>8&255),o.push(255&a),o=o.concat(Array.prototype.slice.call(n));var s=e.box(e.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(o))),u=t.width,l=t.height,d=t.pixelRatio[0],h=t.pixelRatio[1];return e.box(e.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,u>>8&255,255&u,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),s,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([d>>24,d>>16&255,d>>8&255,255&d,h>>24,h>>16&255,h>>8&255,255&h])))}},{key:"esds",value:function(e){var t=e.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...t,6,1,2])}},{key:"audioStsd",value:function(e){var t=e.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount||0,0,16,0,0,0,0,t>>8&255,255&t,0,0])}},{key:"mp4a",value:function(t){return e.box(e.types.mp4a,e.audioStsd(t),e.box(e.types.esds,e.esds(t)))}},{key:"mp3",value:function(t){return e.box(e.types[".mp3"],e.audioStsd(t))}},{key:"ac3",value:function(t){return e.box(e.types["ac-3"],e.audioStsd(t),e.box(e.types.dac3,t.config))}},{key:"stsd",value:function(t){var i=t.segmentCodec;if("audio"===t.type){if("aac"===i)return e.box(e.types.stsd,e.STSD,e.mp4a(t));if("ac3"===i&&t.config)return e.box(e.types.stsd,e.STSD,e.ac3(t));if("mp3"===i&&"mp3"===t.codec)return e.box(e.types.stsd,e.STSD,e.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===i)return e.box(e.types.stsd,e.STSD,e.avc1(t));if("hevc"===i&&t.vps)return e.box(e.types.stsd,e.STSD,e.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${i}/${t.codec})`)}},{key:"tkhd",value:function(t){var i=t.id,n=(t.duration||0)*(t.timescale||0),a=t.width||0,r=t.height||0,o=Math.floor(n/(yC+1)),s=Math.floor(n%(yC+1));return e.box(e.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,s>>24,s>>16&255,s>>8&255,255&s,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,a>>8&255,255&a,0,0,r>>8&255,255&r,0,0]))}},{key:"traf",value:function(t,i){var n=e.sdtp(t),a=t.id,r=Math.floor(i/(yC+1)),o=Math.floor(i%(yC+1));return e.box(e.types.traf,e.box(e.types.tfhd,new Uint8Array([0,0,0,0,a>>24,a>>16&255,a>>8&255,255&a])),e.box(e.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o])),e.trun(t,n.length+16+20+8+16+8+8),n)}},{key:"trak",value:function(t){return t.duration=t.duration||4294967295,e.box(e.types.trak,e.tkhd(t),e.mdia(t))}},{key:"trex",value:function(t){var i=t.id;return e.box(e.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}},{key:"trun",value:function(t,i){var n,a,r,o,s,u,l=t.samples||[],d=l.length,h=12+16*d,c=new Uint8Array(h);for(i+=8+h,c.set(["video"===t.type?1:0,0,15,1,d>>>24&255,d>>>16&255,d>>>8&255,255&d,i>>>24&255,i>>>16&255,i>>>8&255,255&i],0),n=0;n<d;n++)r=(a=l[n]).duration,o=a.size,s=a.flags,u=a.cts,c.set([r>>>24&255,r>>>16&255,r>>>8&255,255&r,o>>>24&255,o>>>16&255,o>>>8&255,255&o,s.isLeading<<2|s.dependsOn,s.isDependedOn<<6|s.hasRedundancy<<4|s.paddingValue<<1|s.isNonSync,61440&s.degradPrio,15&s.degradPrio,u>>>24&255,u>>>16&255,u>>>8&255,255&u],12+16*n);return e.box(e.types.trun,c)}},{key:"initSegment",value:function(t){e.types||e.init();var i=e.moov(t);return BT(e.FTYP,i)}},{key:"hvc1",value:function(t){for(var i=t.params,n=[t.vps,t.sps,t.pps],a=new Uint8Array([1,i.general_profile_space<<6|(i.general_tier_flag?32:0)|i.general_profile_idc,i.general_profile_compatibility_flags[0],i.general_profile_compatibility_flags[1],i.general_profile_compatibility_flags[2],i.general_profile_compatibility_flags[3],i.general_constraint_indicator_flags[0],i.general_constraint_indicator_flags[1],i.general_constraint_indicator_flags[2],i.general_constraint_indicator_flags[3],i.general_constraint_indicator_flags[4],i.general_constraint_indicator_flags[5],i.general_level_idc,240|i.min_spatial_segmentation_idc>>8,255&i.min_spatial_segmentation_idc,252|i.parallelismType,252|i.chroma_format_idc,248|i.bit_depth_luma_minus8,248|i.bit_depth_chroma_minus8,0,parseInt(i.frame_rate.fps),3|i.temporal_id_nested<<2|i.num_temporal_layers<<3|(i.frame_rate.fixed?64:0),n.length]),r=a.length,o=0;o<n.length;o+=1){r+=3;for(var s=0;s<n[o].length;s+=1)r+=2+n[o][s].length}var u=new Uint8Array(r);u.set(a,0),r=a.length;for(var l=n.length-1,d=0;d<n.length;d+=1){u.set(new Uint8Array([32+d|(d===l?128:0),0,n[d].length]),r),r+=3;for(var h=0;h<n[d].length;h+=1)u.set(new Uint8Array([n[d][h].length>>8,255&n[d][h].length]),r),r+=2,u.set(n[d][h],r),r+=n[d][h].length}var c=e.box(e.types.hvcC,u),m=t.width,f=t.height,v=t.pixelRatio[0],p=t.pixelRatio[1];return e.box(e.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,m>>8&255,255&m,f>>8&255,255&f,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]),c,e.box(e.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),e.box(e.types.pasp,new Uint8Array([v>>24,v>>16&255,v>>8&255,255&v,p>>24,p>>16&255,p>>8&255,255&p])))}}])}();bC.types=void 0,bC.HDLR_TYPES=void 0,bC.STTS=void 0,bC.STSC=void 0,bC.STCO=void 0,bC.STSZ=void 0,bC.VMHD=void 0,bC.SMHD=void 0,bC.STSD=void 0,bC.FTYP=void 0,bC.DINF=void 0;function wC(e,t,i=1,n=!1){var a=e*t*i;return n?Math.round(a):a}function kC(e,t=!1){return wC(e,1e3,1/9e4,t)}function SC(e){var t=e.baseTime,i=e.timescale;return`${t/i} (${t}/${i}) trackId: ${e.trackId}`}var EC=null,MC=null;function TC(e,t,i,n){return{duration:t,size:i,cts:n,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}var PC=function(){function e(t,i,n,a){var r;if(Q(this,e),(r=J(this,e,["mp4-remuxer",a])).observer=void 0,r.config=void 0,r.typeSupported=void 0,r.ISGenerated=!1,r._initPTS=null,r._initDTS=null,r.nextVideoTs=null,r.nextAudioTs=null,r.videoSampleDuration=null,r.isAudioContiguous=!1,r.isVideoContiguous=!1,r.videoTrackConfig=void 0,r.observer=t,r.config=i,r.typeSupported=n,r.ISGenerated=!1,null===EC){var o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);EC=o?parseInt(o[1]):0}if(null===MC){var s=navigator.userAgent.match(/Safari\/(\d+)/i);MC=s?parseInt(s[1]):0}return r}return ue(e,KM),ne(e,[{key:"destroy",value:function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}},{key:"resetTimeStamp",value:function(e){var t=this._initPTS;t&&e&&e.trackId===t.trackId&&e.baseTime===t.baseTime&&e.timescale===t.timescale||this.log(`Reset initPTS: ${t?SC(t):t} > ${e?SC(e):e}`),this._initPTS=this._initDTS=e}},{key:"resetNextTimestamp",value:function(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}},{key:"resetInitSegment",value:function(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}},{key:"getVideoStartPts",value:function(e){var t=!1,i=e[0].pts,n=e.reduce((e,n)=>{var a=n.pts,r=a-e;return r<-4294967296&&(t=!0,r=(a=AC(a,i))-e),r>0?e:a},i);return t&&this.debug("PTS rollover detected"),n}},{key:"remux",value:function(e,t,i,n,a,r,o,s){var u,l,d,h,c,m,f=a,v=a,p=e.pid>-1,g=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!g||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,E,M,T=this.videoTrackConfig;(T&&(t.width!==T.width||t.height!==T.height||(null==(k=t.pixelRatio)?void 0:k[0])!==(null==(S=T.pixelRatio)?void 0:S[0])||(null==(E=t.pixelRatio)?void 0:E[1])!==(null==(M=T.pixelRatio)?void 0:M[1]))||!T&&w||null===this.nextAudioTs&&b)&&this.resetInitSegment()}this.ISGenerated||(d=this.generateIS(e,t,a,r));var P,A=this.isVideoContiguous,D=-1;if(w&&(D=function(e){for(var t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!A&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,D>0){this.warn(`Dropped ${D} out of ${y} video samples due to a missing keyframe`);var x=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(D),t.dropped+=D,P=v+=(t.samples[0].pts-x)/t.inputTimeScale}else-1===D&&(this.warn(`No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){var C=this.getVideoStartPts(t.samples),I=(AC(e.samples[0].pts,C)-C)/t.inputTimeScale;f+=Math.max(0,I),v+=Math.max(0,-I)}if(b){if(e.samplerate||(this.warn("regenerate InitSegment as audio detected"),d=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,g||w||s===NM?v:void 0),w){var L=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),d=this.generateIS(e,t,a,r)),u=this.remuxVideo(t,v,A,L)}}else w&&(u=this.remuxVideo(t,v,A,0));u&&(u.firstKeyFrame=D,u.independent=-1!==D,u.firstKeyFramePTS=P)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(c=DC(i,a,this._initPTS,this._initDTS)),n.samples.length&&(h=xC(n,a,this._initPTS))),{audio:l,video:u,initSegment:d,independent:m,text:h,id3:c}}},{key:"computeInitPts",value:function(e,t,i,n){var a=Math.round(i*t),r=AC(e,a);if(r<a+t)for(this.log(`Adjusting PTS for rollover in timeline near ${(a-r)/t} ${n}`);r<a+t;)r+=8589934592;return r-a}},{key:"generateIS",value:function(e,t,i,n){var a,r,o,s=e.samples,u=t.samples,l=this.typeSupported,d={},h=this._initPTS,c=!h||n,m="audio/mp4",f=-1;if(c&&(a=r=1/0),e.config&&s.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":l.mpeg?(m="audio/mpeg",e.codec=""):l.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}d.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&l.mpeg?new Uint8Array(0):bC.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(f=e.id,o=e.inputTimeScale,h&&o===h.timescale?c=!1:a=r=this.computeInitPts(s[0].pts,o,i,"audio"))}if(t.sps&&t.pps&&u.length){if(t.timescale=t.inputTimeScale,d.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:bC.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(f=t.id,o=t.inputTimeScale,h&&o===h.timescale)c=!1;else{var v=this.getVideoStartPts(u),p=AC(u[0].dts,v),g=this.computeInitPts(p,o,i,"video"),y=this.computeInitPts(v,o,i,"video");r=Math.min(r,g),a=Math.min(a,y)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(d).length)return this.ISGenerated=!0,c?(h&&this.warn(`Timestamps at playlist time: ${n?"":"~"}${i} ${a/o} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${i} offset: ${a/o} (${a}/${o}) trackId: ${f}`),this._initPTS={baseTime:a,timescale:o,trackId:f},this._initDTS={baseTime:r,timescale:o,trackId:f}):a=o=void 0,{tracks:d,initPTS:a,timescale:o,trackId:f}}},{key:"remuxVideo",value:function(e,t,i,n){var a,r,o=e.inputTimeScale,s=e.samples,u=[],l=s.length,d=this._initPTS,h=d.baseTime*o/d.timescale,c=this.nextVideoTs,m=8,f=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=!1;if(!i||null===c){var y=h+t*o,b=s[0].pts-AC(s[0].dts,s[0].pts);EC&&null!==c&&Math.abs(y-b-(c+h))<15e3?i=!0:c=y-b-h}for(var w=c+h,k=0;k<l;k++){var S=s[k];S.pts=AC(S.pts,w),S.dts=AC(S.dts,w),S.dts<s[k>0?k-1:k].dts&&(g=!0)}g&&s.sort(function(e,t){var i=e.dts-t.dts,n=e.pts-t.pts;return i||n}),a=s[0].dts;var E=(r=s[s.length-1].dts)-a,M=E?Math.round(E/(l-1)):f||e.inputTimeScale/30;if(i){var T=a-w,P=T>M,A=T<-1;if((P||A)&&(P?this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${kC(T,!0)} ms (${T}dts) hole between fragments detected at ${t.toFixed(3)}`):this.warn(`${(e.segmentCodec||"").toUpperCase()}: ${kC(-T,!0)} ms (${T}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!A||w>=s[0].pts||EC)){a=w;var D=s[0].pts-T;if(P)s[0].dts=a,s[0].pts=D;else for(var x=!0,C=0;C<s.length&&!(s[C].dts>D&&x);C++){var I=s[C].pts;if(s[C].dts-=T,s[C].pts-=T,C<s.length-1){var L=s[C+1].pts;x=L<=s[C].pts==L<=I}}this.log(`Video: Initial PTS/DTS adjusted: ${kC(D,!0)}/${kC(a,!0)}, delta: ${kC(T,!0)} ms`)}}for(var _=0,R=0,F=a=Math.max(0,a),W=0;W<l;W++){for(var O=s[W],$=O.units,N=$.length,j=0,B=0;B<N;B++)j+=$[B].data.length;R+=j,_+=N,O.length=j,O.dts<F?(O.dts=F,F+=M/4|0||1):F=O.dts,v=Math.min(O.pts,v),p=Math.max(O.pts,p)}r=s[l-1].dts;var z,U=R+4*_+8;try{z=new Uint8Array(U)}catch(e){return void this.observer.emit(_M.ERROR,_M.ERROR,{type:IM.MUX_ERROR,details:LM.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:U,reason:`fail allocating video mdat ${U}`})}var H=new DataView(z.buffer);H.setUint32(0,U),z.set(bC.types.mdat,4);for(var G=!1,V=Number.POSITIVE_INFINITY,K=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,Y=Number.NEGATIVE_INFINITY,q=0;q<l;q++){for(var J=s[q],Q=J.units,Z=0,ee=0,te=Q.length;ee<te;ee++){var ie=Q[ee],ne=ie.data,ae=ie.data.byteLength;H.setUint32(m,ae),m+=4,z.set(ne,m),m+=ae,Z+=4+ae}var re=void 0;if(q<l-1)f=s[q+1].dts-J.dts,re=s[q+1].pts-J.pts;else{var oe=this.config,se=q>0?J.dts-s[q-1].dts:M;if(re=q>0?J.pts-s[q-1].pts:M,oe.stretchShortVideoTrack&&null!==this.nextAudioTs){var ue=Math.floor(oe.maxBufferHole*o),le=(n?v+n*o:this.nextAudioTs+h)-J.pts;le>ue?((f=le-se)<0?f=se:G=!0,this.log(`It is approximately ${le/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=se}else f=se}var de=Math.round(J.pts-J.dts);V=Math.min(V,f),X=Math.max(X,f),K=Math.min(K,re),Y=Math.max(Y,re),u.push(TC(J.key,f,Z,de))}if(u.length)if(EC){if(EC<70){var he=u[0].flags;he.dependsOn=2,he.isNonSync=0}}else if(MC&&Y-K<X-V&&M/X<.025&&0===u[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");for(var ce=a,me=0,fe=u.length;me<fe;me++){var ve=ce+u[me].duration,pe=ce+u[me].cts;if(me<fe-1){var ge=ve+u[me+1].cts;u[me].duration=ge-pe}else u[me].duration=me?u[me-1].duration:M;u[me].cts=0,ce=ve}}var ye=r+(f=G||!f?M:f);this.nextVideoTs=c=ye-h,this.videoSampleDuration=f,this.isVideoContiguous=!0;var be={data1:bC.moof(e.sequenceNumber++,a,HM(e,{samples:u})),data2:z,startPTS:(v-h)/o,endPTS:(p+f-h)/o,startDTS:(a-h)/o,endDTS:c/o,type:"video",hasAudio:!1,hasVideo:!0,nb:u.length,dropped:e.dropped};return e.samples=[],e.dropped=0,be}},{key:"getSamplesPerFrame",value:function(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}},{key:"remuxAudio",value:function(e,t,i,n,a){var r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),u=s*o,l=this._initPTS,d="mp3"===e.segmentCodec&&this.typeSupported.mpeg,h=[],c=void 0!==a,m=e.samples,f=d?0:8,v=this.nextAudioTs||-1,p=l.baseTime*r/l.timescale,g=p+t*r;if(this.isAudioContiguous=i=i||m.length&&v>0&&(n&&Math.abs(g-(v+p))<9e3||Math.abs(AC(m[0].pts,g)-(v+p))<20*u),m.forEach(function(e){e.pts=AC(e.pts,g)}),!i||v<0){var y=m.length;if(m=m.filter(e=>e.pts>=0),y!==m.length&&this.warn(`Removed ${m.length-y} of ${y} samples (initPTS ${p} / ${r})`),!m.length)return;v=0===a?0:n&&!c?Math.max(0,g-p):m[0].pts-p}if("aac"===e.segmentCodec)for(var b=this.config.maxAudioFramesDrift,w=0,k=v+p;w<m.length;w++){var S=m[w],E=S.pts,M=E-k,T=Math.abs(1e3*M/r);if(M<=-b*u&&c)0===w&&(this.warn(`Audio frame @ ${(E/r).toFixed(3)}s overlaps marker by ${Math.round(1e3*M/r)} ms.`),this.nextAudioTs=v=E-p,k=E);else if(M>=b*u&&T<1e4&&c){var P=Math.round(M/u);for(k=E-P*u;k<0&&P&&u;)P--,k+=u;0===w&&(this.nextAudioTs=v=k-p),this.warn(`Injecting ${P} audio frames @ ${((k-p)/r).toFixed(3)}s due to ${Math.round(1e3*M/r)} ms gap.`);for(var A=0;A<P;A++){var D=gC.getSilentFrame(e.parsedCodec||e.manifestCodec||e.codec,e.channelCount);D||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),D=S.unit.subarray()),m.splice(w,0,{unit:D,pts:k}),k+=u,w++}}S.pts=k,k+=u}for(var x,C=null,I=null,L=0,_=m.length;_--;)L+=m[_].unit.byteLength;for(var R=0,F=m.length;R<F;R++){var W=m[R],O=W.unit,$=W.pts;if(null!==I){h[R-1].duration=Math.round(($-I)/o)}else{if(i&&"aac"===e.segmentCodec&&($=v+p),C=$,!(L>0))return;L+=f;try{x=new Uint8Array(L)}catch(e){return void this.observer.emit(_M.ERROR,_M.ERROR,{type:IM.MUX_ERROR,details:LM.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:L,reason:`fail allocating audio mdat ${L}`})}d||(new DataView(x.buffer).setUint32(0,L),x.set(bC.types.mdat,4))}x.set(O,f);var N=O.byteLength;f+=N,h.push(TC(!0,s,N,0)),I=$}var j=h.length;if(j){var B=h[h.length-1];v=I-p,this.nextAudioTs=v+o*B.duration;var z=d?new Uint8Array(0):bC.moof(e.sequenceNumber++,C/o,HM({},e,{samples:h}));e.samples=[];var U=(C-p)/r,H=this.nextAudioTs/r,G={data1:z,data2:x,startPTS:U,endPTS:H,startDTS:U,endDTS:H,type:"audio",hasAudio:!0,hasVideo:!1,nb:j};return this.isAudioContiguous=!0,G}}}])}();function AC(e,t){var i;if(null===t)return e;for(i=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=i;return e}function DC(e,t,i,n){var a=e.samples.length;if(a){for(var r=e.inputTimeScale,o=0;o<a;o++){var s=e.samples[o];s.pts=AC(s.pts-i.baseTime*r/i.timescale,t*r)/r,s.dts=AC(s.dts-n.baseTime*r/n.timescale,t*r)/r}var u=e.samples;return e.samples=[],{samples:u}}}function xC(e,t,i){var n=e.samples.length;if(n){for(var a=e.inputTimeScale,r=0;r<n;r++){var o=e.samples[r];o.pts=AC(o.pts-i.baseTime*a/i.timescale,t*a)/a}e.samples.sort((e,t)=>e.pts-t.pts);var s=e.samples;return e.samples=[],{samples:s}}}var CC,IC=function(){function e(t,i,n,a){var r;return Q(this,e),(r=J(this,e,["passthrough-remuxer",a])).emitInitSegment=!1,r.audioCodec=void 0,r.videoCodec=void 0,r.initData=void 0,r.initPTS=null,r.initTracks=void 0,r.lastEndTime=null,r.isVideoContiguous=!1,r}return ue(e,KM),ne(e,[{key:"destroy",value:function(){}},{key:"resetTimeStamp",value:function(e){this.lastEndTime=null;var t=this.initPTS;t&&e&&t.baseTime===e.baseTime&&t.timescale===e.timescale||(this.initPTS=e)}},{key:"resetNextTimestamp",value:function(){this.isVideoContiguous=!1,this.lastEndTime=null}},{key:"resetInitSegment",value:function(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(e,n),this.emitInitSegment=!0}},{key:"generateInitSegment",value:function(e,t){var i=this.audioCodec,n=this.videoCodec;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var a=this.initData=_T(e),r=a.audio,o=a.video;if(t)!function(e,t){if(e&&t){var i=t.keyId;i&&t.isCommonEncryption&&NT(e,(e,t)=>{var n=e.subarray(8,24);n.some(e=>0!==e)||(ZM.log(`[eme] Patching keyId in 'enc${t?"a":"v"}>sinf>>tenc' box: ${nT(n)} -> ${nT(i)}`),e.set(i,8))})}}(e,t);else{var s=r||o;null!=s&&s.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${s.codec}")!`)}r&&(i=_C(r,vT,this)),o&&(n=_C(o,pT,this));var u={};r&&o?u.audiovideo={container:"video/mp4",codec:i+","+n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:r?u.audio={container:"audio/mp4",codec:i,encrypted:r.encrypted,initSegment:e,id:"audio"}:o?u.video={container:"video/mp4",codec:n,supplemental:o.supplemental,encrypted:o.encrypted,initSegment:e,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=u}},{key:"remux",value:function(e,t,i,n,a,r){var o,s,u=this.initPTS,l=this.lastEndTime,d={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};DM(l)||(l=this.lastEndTime=a||0);var h=t.samples;if(!h.length)return d;var c={initPTS:void 0,timescale:void 0,trackId:void 0},m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(h),m=this.initData),null==(s=m)||!s.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var f=function(e,t,i){for(var n={},a=IT(e,["moof","traf"]),r=0;r<a.length;r++){var o=a[r],s=IT(o,["tfhd"])[0],u=DT(s,4),l=t[u];if(l){n[u]||(n[u]={start:NaN,duration:0,sampleCount:0,timescale:l.timescale,type:l.type});var d=n[u],h=IT(o,["tfdt"])[0];if(h){var c=h[0],m=DT(h,4);1===c&&(m===ET?i.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(m*=ET+1,m+=DT(h,8))),DM(m)&&(!DM(d.start)||m<d.start)&&(d.start=m)}var f=l.default,v=DT(s,0)|(null==f?void 0:f.flags),p=(null==f?void 0:f.duration)||0;8&v&&(p=DT(s,2&v?12:8));for(var g=IT(o,["trun"]),y=d.start||0,b=0,w=p,k=0;k<g.length;k++){var S=g[k],E=DT(S,4),M=d.sampleCount;d.sampleCount+=E;var T=1&S[3],P=4&S[3],A=1&S[2],D=2&S[2],x=4&S[2],C=8&S[2],I=8,L=E;for(T&&(I+=4),P&&E&&(1&S[I+1]||void 0!==d.keyFrameIndex||(d.keyFrameIndex=M),I+=4,A?(w=DT(S,I),I+=4):w=p,D&&(I+=4),C&&(I+=4),y+=w,b+=w,L--);L--;)A?(w=DT(S,I),I+=4):w=p,D&&(I+=4),x&&(1&S[I+1]||void 0===d.keyFrameIndex&&(d.keyFrameIndex=d.sampleCount-(L+1),d.keyFrameStart=y),I+=4),C&&(I+=4),y+=w,b+=w;!b&&p&&(b+=p*E)}d.duration+=b}}if(!Object.keys(n).some(e=>n[e].duration)){for(var _=1/0,R=0,F=IT(e,["sidx"]),W=0;W<F.length;W++){var O=LT(F[W]);if(null!=O&&O.references){_=Math.min(_,O.earliestPresentationTime/O.timescale);var $=O.references.reduce((e,t)=>e+t.info.duration||0,0);R=Math.max(R,$+O.earliestPresentationTime/O.timescale)}}R&&DM(R)&&Object.keys(n).forEach(e=>{n[e].duration||(n[e].duration=R*n[e].timescale-n[e].start)})}return n}(h,m,this),v=m.audio?f[m.audio.id]:null,p=m.video?f[m.video.id]:null,g=LC(p,1/0),y=LC(v,1/0),b=LC(p,0,!0),w=LC(v,0,!0),k=a,S=0,E=v&&(!p||!u&&y<g||u&&u.trackId===m.audio.id),M=E?v:p;if(M){var T=M.timescale,P=M.start-a*T,A=E?m.audio.id:m.video.id;k=M.start/T,S=E?w-y:b-g,!r&&u||!function(e,t,i,n){if(null===e)return!0;var a=Math.max(n,1),r=t-e.baseTime/e.timescale;return Math.abs(r-i)>a}(u,k,a,S)&&T===u.timescale||(u&&this.warn(`Timestamps at playlist time: ${r?"":"~"}${a} ${P/T} != initPTS: ${u.baseTime/u.timescale} (${u.baseTime}/${u.timescale}) trackId: ${u.trackId}`),this.log(`Found initPTS at playlist time: ${a} offset: ${k-a} (${P}/${T}) trackId: ${A}`),u=null,c.initPTS=P,c.timescale=T,c.trackId=A)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${a}`);u?(c.initPTS=u.baseTime,c.timescale=u.timescale,c.trackId=u.trackId):(c.timescale&&void 0!==c.trackId&&void 0!==c.initPTS||(this.warn("Could not set initPTS"),c.initPTS=k,c.timescale=1,c.trackId=-1),this.initPTS=u={baseTime:c.initPTS,timescale:c.timescale,trackId:c.trackId});var D=k-u.baseTime/u.timescale,x=D+S;S>0?this.lastEndTime=x:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var C=!!m.audio,I=!!m.video,L="";C&&(L+="audio"),I&&(L+="video");var _={data1:h,startPTS:D,startDTS:D,endPTS:x,endDTS:x,type:L,hasAudio:C,hasVideo:I,nb:1,dropped:0,encrypted:!!m.audio&&m.audio.encrypted||!!m.video&&m.video.encrypted};d.audio=C&&!I?_:void 0,d.video=I?_:void 0;var R=null==p?void 0:p.sampleCount;if(R){var F=p.keyFrameIndex,W=-1!==F;_.nb=R,_.dropped=0===F||this.isVideoContiguous?0:W?F:R,_.independent=W,_.firstKeyFrame=F,W&&p.keyFrameStart&&(_.firstKeyFramePTS=(p.keyFrameStart-u.baseTime)/u.timescale),this.isVideoContiguous||(d.independent=W),this.isVideoContiguous||(this.isVideoContiguous=W),_.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${F}/${R} dropped: ${_.dropped} start: ${_.firstKeyFramePTS||"NA"}`)}return d.initSegment=c,d.id3=DC(i,a,u,u),n.samples.length&&(d.text=xC(n,a,u)),d}}])}();function LC(e,t,i=!1){return void 0!==(null==e?void 0:e.start)?(e.start+(i?e.duration:0))/e.timescale:t}function _C(e,t,i){var n=e.codec;if(n&&n.length>4)return n;if(t===vT){if("ec-3"===n||"ac-3"===n||"alac"===n)return n;if("fLaC"===n||"Opus"===n){return rP(n,!1)}return i.warn(`Unhandled audio codec "${n}" in mp4 MAP`),n||"mp4a"}return i.warn(`Unhandled video codec "${n}" in mp4 MAP`),n||"avc1"}try{CC=self.performance.now.bind(self.performance)}catch(e){CC=Date.now}var RC=[{demux:iC,remux:IC},{demux:dC,remux:PC},{demux:qx,remux:PC},{demux:eC,remux:PC}];RC.splice(2,0,{demux:Qx,remux:PC});var FC=function(){return ne(function e(t,i,n,a,r,o){Q(this,e),this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=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=t,this.typeSupported=i,this.config=n,this.id=r,this.logger=o},[{key:"configure",value:function(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}},{key:"push",value:function(e,t,i,n){var a=i.transmuxing;a.executeStart=CC();var r=new Uint8Array(e),o=this.currentTransmuxState,s=this.transmuxConfig;n&&(this.currentTransmuxState=n);var u=n||o,l=u.contiguous,d=u.discontinuity,h=u.trackSwitch,c=u.accurateTimeOffset,m=u.timeOffset,f=u.initSegmentChange,v=s.audioCodec,p=s.videoCodec,g=s.defaultInitPts,y=s.duration,b=s.initSegmentData,w=function(e,t){var i=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(i=t);return i}(r,t);if(w&&UA(w.method)){var k=this.getDecrypter(),S=HA(w.method);if(!k.isSync())return this.asyncResult=!0,this.decryptionPromise=k.webCryptoDecrypt(r,w.key.buffer,w.iv.buffer,S).then(e=>{var t=this.push(e,null,i);return this.decryptionPromise=null,t}),this.decryptionPromise;var E=k.softwareDecrypt(r,w.key.buffer,w.iv.buffer,S);if(i.part>-1){var M=k.flush();E=M?M.buffer:M}if(!E)return a.executeEnd=CC(),WC(i);r=new Uint8Array(E)}var T=this.needsProbing(d,h);if(T){var P=this.configureTransmuxer(r);if(P)return this.logger.warn(`[transmuxer] ${P.message}`),this.observer.emit(_M.ERROR,_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_PARSING_ERROR,fatal:!1,error:P,reason:P.message}),a.executeEnd=CC(),WC(i)}(d||h||f||T)&&this.resetInitSegment(b,v,p,y,t),(d||f||T)&&this.resetInitialTimestamp(g),l||this.resetContiguity();var A=this.transmux(r,w,m,c,i);this.asyncResult=OC(A);var D=this.currentTransmuxState;return D.contiguous=!0,D.discontinuity=!1,D.trackSwitch=!1,a.executeEnd=CC(),A}},{key:"flush",value:function(e){var t=e.transmuxing;t.executeStart=CC();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return this.asyncResult=!0,a.then(()=>this.flush(e));var r=[],o=n.timeOffset;if(i){var s=i.flush();s&&r.push(this.push(s.buffer,null,e))}var u=this.demuxer,l=this.remuxer;if(!u||!l){t.executeEnd=CC();var d=[WC(e)];return this.asyncResult?Promise.resolve(d):d}var h=u.flush(o);return OC(h)?(this.asyncResult=!0,h.then(t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,h,e),this.asyncResult?Promise.resolve(r):r)}},{key:"flushRemux",value:function(e,t,i){var n=t.audioTrack,a=t.videoTrack,r=t.id3Track,o=t.textTrack,s=this.currentTransmuxState,u=s.accurateTimeOffset,l=s.timeOffset;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${i.sn}${i.part>-1?" part: "+i.part:""} of ${this.id===$M?"level":"track"} ${i.level}`);var d=this.remuxer.remux(n,a,r,o,l,u,!0,this.id);e.push({remuxResult:d,chunkMeta:i}),i.transmuxing.executeEnd=CC()}},{key:"resetInitialTimestamp",value:function(e){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetTimeStamp(e),i.resetTimeStamp(e))}},{key:"resetContiguity",value:function(){var e=this.demuxer,t=this.remuxer;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}},{key:"resetInitSegment",value:function(e,t,i,n,a){var r=this.demuxer,o=this.remuxer;r&&o&&(r.resetInitSegment(e,t,i,n),o.resetInitSegment(e,t,i,a))}},{key:"destroy",value:function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}},{key:"transmux",value:function(e,t,i,n,a){return t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,i,n,a):this.transmuxUnencrypted(e,i,n,a)}},{key:"transmuxUnencrypted",value:function(e,t,i,n){var a=this.demuxer.demux(e,t,!1,!this.config.progressive),r=a.audioTrack,o=a.videoTrack,s=a.id3Track,u=a.textTrack;return{remuxResult:this.remuxer.remux(r,o,s,u,t,i,!1,this.id),chunkMeta:n}}},{key:"transmuxSampleAes",value:function(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:a}))}},{key:"configureTransmuxer",value:function(e){for(var t,i=this.config,n=this.observer,a=this.typeSupported,r=0,o=RC.length;r<o;r++){var s;if(null!=(s=RC[r].demux)&&s.probe(e,this.logger)){t=RC[r];break}}if(!t)return new Error("Failed to find demuxer by probing fragment data");var u=this.demuxer,l=this.remuxer,d=t.remux,h=t.demux;l&&l instanceof d||(this.remuxer=new d(n,i,a,this.logger)),u&&u instanceof h||(this.demuxer=new h(n,i,a,this.logger),this.probe=h.probe)}},{key:"needsProbing",value:function(e,t){return!this.demuxer||!this.remuxer||e||t}},{key:"getDecrypter",value:function(){var e=this.decrypter;return e||(e=this.decrypter=new bA(this.config)),e}}])}();var WC=e=>({remuxResult:{},chunkMeta:e});function OC(e){return"then"in e&&e.then instanceof Function}var $C=ne(function e(t,i,n,a,r){Q(this,e),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=i,this.initSegmentData=n,this.duration=a,this.defaultInitPts=r||null}),NC=ne(function e(t,i,n,a,r,o){Q(this,e),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=i,this.accurateTimeOffset=n,this.trackSwitch=a,this.timeOffset=r,this.initSegmentChange=o}),jC=0,BC=function(){return ne(function e(t,i,n,a){Q(this,e),this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=jC++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=e=>{var t=e.data,i=this.hls;if(i&&null!=t&&t.event&&t.instanceNo===this.instanceNo)switch(t.event){case"init":var n,a=null==(n=this.workerContext)?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":i.logger[t.data.logType]&&i.logger[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.part=this.part,t.data.id=this.id,i.trigger(t.event,t.data)}},this.onWorkerError=e=>{if(this.hls){var t=new Error(`${e.message} (${e.filename}:${e.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:t})}};var r=t.config;this.hls=t,this.id=i,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=n,this.onFlush=a;var o=(e,t)=>{(t=t||{}).frag=this.frag||void 0,e===_M.ERROR&&(t.parent=this.id,t.part=this.part,this.error=t.error),this.hls.trigger(e,t)};this.observer=new cx,this.observer.on(_M.FRAG_DECRYPTED,o),this.observer.on(_M.ERROR,o);var s=lP(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){var u=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(u.log(`loading Web Worker ${r.workerPath} for "${i}"`),this.workerContext=function(e){var t=fx[e];if(t)return t.clientCount++,t;var i=new self.URL(e,self.location.href).href,n={worker:new self.Worker(i),scriptURL:i,clientCount:1};return fx[e]=n,n}(r.workerPath)):(u.log(`injecting Web Worker for "${i}"`),this.workerContext=function(){var e=fx[mx];if(e)return e.clientCount++,e;var t=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),i=self.URL.createObjectURL(t),n={worker:new self.Worker(i),objectURL:i,clientCount:1};return fx[mx]=n,n}());var l=this.workerContext.worker;l.addEventListener("message",this.onWorkerMessage),l.addEventListener("error",this.onWorkerError),l.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:s,id:i,config:AP(r)})}catch(e){u.warn(`Error setting up "${i}" Web Worker, fallback to inline`,e),this.terminateWorker(),this.error=null,this.transmuxer=new FC(this.observer,s,r,"",i,t.logger)}return}}this.transmuxer=new FC(this.observer,s,r,"",i,t.logger)},[{key:"reset",value:function(){if(this.frag=null,this.part=null,this.workerContext){var e=this.instanceNo;this.instanceNo=jC++;var t=this.hls.config,i=lP(t.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:e,typeSupported:i,id:this.id,config:AP(t)})}}},{key:"terminateWorker",value:function(){if(this.workerContext){var e=this.workerContext.worker;this.workerContext=null,e.removeEventListener("message",this.onWorkerMessage),e.removeEventListener("error",this.onWorkerError),function(e){var t=fx[e||mx];if(t&&1===t.clientCount--){var i=t.worker,n=t.objectURL;delete fx[e||mx],n&&self.URL.revokeObjectURL(n),i.terminate()}}(this.hls.config.workerPath)}}},{key:"destroy",value:function(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{var e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}var t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}},{key:"push",value:function(e,t,i,n,a,r,o,s,u,l){var d,h;u.transmuxing.start=self.performance.now();var c=this.instanceNo,m=this.transmuxer,f=r?r.start:a.start,v=a.decryptdata,p=this.frag,g=!(p&&a.cc===p.cc),y=!(p&&u.level===p.level),b=p?u.sn-p.sn:-1,w=this.part?u.part-this.part.index:-1,k=0===b&&u.id>1&&u.id===(null==p?void 0:p.stats.chunkCount),S=!y&&(1===b||0===b&&(1===w||k&&w<=0)),E=self.performance.now();(y||b||0===a.stats.parsing.start)&&(a.stats.parsing.start=E),!r||!w&&S||(r.stats.parsing.start=E);var M=!(p&&(null==(d=a.initSegment)?void 0:d.url)===(null==(h=p.initSegment)?void 0:h.url)),T=new NC(g,S,s,y,f,M);if(!S||g||M){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${a.type} sn: ${u.sn}${u.part>-1?" part: "+u.part:""} ${this.id===$M?"level":"track"}: ${u.level} id: ${u.id}\n discontinuity: ${g}\n trackSwitch: ${y}\n contiguous: ${S}\n accurateTimeOffset: ${s}\n timeOffset: ${f}\n initSegmentChange: ${M}`);var P=new $C(i,n,t,o,l);this.configureTransmuxer(P)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({instanceNo:c,cmd:"demux",data:e,decryptdata:v,chunkMeta:u,state:T},e instanceof ArrayBuffer?[e]:[]);else if(m){var A=m.push(e,v,u,T);OC(A)?A.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,u,"transmuxer-interface push error")}):this.handleTransmuxComplete(A)}}},{key:"flush",value:function(e){e.transmuxing.start=self.performance.now();var t=this.instanceNo,i=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:t,cmd:"flush",chunkMeta:e});else if(i){var n=i.flush(e);OC(n)?n.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}):this.handleFlushResult(n,e)}}},{key:"transmuxerError",value:function(e,t,i){this.hls&&(this.error=e,this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:e,err:e,reason:i}))}},{key:"handleFlushResult",value:function(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}},{key:"configureTransmuxer",value:function(e){var t=this.instanceNo,i=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({instanceNo:t,cmd:"configure",config:e}):i&&i.configure(e)}},{key:"handleTransmuxComplete",value:function(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}])}(),zC=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"audio-stream-controller",NM])).mainAnchor=null,a.mainFragLoading=null,a.audioOnly=!1,a.bufferedTrack=null,a.switchingTrack=null,a.trackId=-1,a.waitingData=null,a.mainDetails=null,a.flushing=!1,a.bufferFlushed=!1,a.cachedTrackLoadedData=null,a.registerListeners(),a}return ue(e,ox),ne(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([]),this.resetItem()}},{key:"resetItem",value:function(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}},{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_M.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(_M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(_M.BUFFER_RESET,this.onBufferReset,this),t.on(_M.BUFFER_CREATED,this.onBufferCreated,this),t.on(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(_M.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(_M.FRAG_LOADING,this.onFragLoading,this),t.on(_M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){var t=this.hls;t&&(pe(e,"unregisterListeners",this)([]),t.off(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_M.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(_M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(_M.BUFFER_RESET,this.onBufferReset,this),t.off(_M.BUFFER_CREATED,this.onBufferCreated,this),t.off(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(_M.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(_M.FRAG_LOADING,this.onFragLoading,this),t.off(_M.FRAG_BUFFERED,this.onFragBuffered,this))}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){if(i===$M){var o=t.cc,s=this.fragCurrent;if(this.initPTS[o]={baseTime:n,timescale:a,trackId:r},this.log(`InitPTS for cc: ${o} found from main: ${n/a} (${n}/${a}) trackId: ${r}`),this.mainAnchor=t,this.state===ax){var u=this.waitingData;(!u&&!this.loadingParts||u&&u.frag.cc!==o)&&this.syncWithAnchor(t,null==u?void 0:u.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==o?(s.abortRequests(),this.syncWithAnchor(t,s)):this.state===YD&&this.tick()}}},{key:"getLoadPosition",value:function(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:pe(e,"getLoadPosition",this)([])}},{key:"syncWithAnchor",value:function(e,t){var i,n=(null==(i=this.mainFragLoading)?void 0:i.frag)||null;if(!t||(null==n?void 0:n.cc)!==t.cc){var a=(n||e).cc,r=BP(this.getLevelDetails(),a,this.getLoadPosition());r&&(this.log(`Syncing with main frag at ${r.start} cc ${r.cc}`),this.startFragRequested=!1,this.nextLoadPosition=r.start,this.resetLoadingState(),this.state===YD&&this.doTickIdle())}}},{key:"startLoad",value:function(e,t){if(!this.levels)return this.startPosition=e,void(this.state=XD);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),i>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i,this.state=YD):this.state=ZD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"doTick",value:function(){switch(this.state){case YD:this.doTickIdle();break;case ZD:var t=this.levels,i=this.trackId,n=null==t?void 0:t[i],a=null==n?void 0:n.details;if(a&&!this.waitForLive(n)){if(this.waitForCdnTuneIn(a))break;this.state=ax}break;case QD:this.checkRetryDate();break;case ax:var r=this.waitingData;if(r){var o=r.frag,s=r.part,u=r.cache,l=r.complete,d=this.mainAnchor;if(void 0!==this.initPTS[o.cc]){this.waitingData=null,this.state=JD;var h={frag:o,part:s,payload:u.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(h),l&&pe(e,"_handleFragmentLoadComplete",this)([h])}else d&&d.cc!==r.frag.cc&&this.syncWithAnchor(d,r.frag)}else this.state=YD}this.onTickEnd()}},{key:"resetLoadingState",value:function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),pe(e,"resetLoadingState",this)([])}},{key:"onTickEnd",value:function(){var e=this.media;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}},{key:"doTickIdle",value:function(){var e,t=this.hls,i=this.levels,n=this.media,a=this.trackId,r=t.config;if(this.buffering&&(n||this.primaryPrefetch||!this.startFragRequested&&r.startFragPrefetch)&&null!=i&&i[a]){var o=i[a],s=o.details;if(!s||this.waitForLive(o)||this.waitForCdnTuneIn(s))return this.state=ZD,void(this.startFragRequested=!1);var u=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&u&&(this.bufferFlushed=!1,this.afterBufferFlushed(u,vT,NM));var l=this.getFwdBufferInfo(u,NM);if(null!==l){if(!this.switchingTrack&&this._streamEnded(l,s))return t.trigger(_M.BUFFER_EOS,{type:"audio"}),void(this.state=ix);var d=l.len,h=t.maxBufferLength,c=s.fragments,m=c[0].start,f=this.getLoadPosition(),v=this.flushing?f:l.end;if(this.switchingTrack&&n){var p=f;s.PTSKnown&&p<m&&(l.end>m||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=m+.05)}if(!(d>=h&&!this.switchingTrack&&v<c[c.length-1].start)){var g=this.getNextFragment(v,s);if(g&&this.isLoopLoading(g,v)&&(g=this.getNextFragmentLoopLoading(g,s,l,$M,h)),g){if(!this.exceedsMaxBuffer(l,h,g)){var y=(null==(e=this.mainFragLoading)?void 0:e.frag)||null;if(!this.audioOnly&&this.startFragRequested&&y&&bT(g)&&!g.endList&&(!s.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(y)===lA&&(this.mainFragLoading=y=null),y&&bT(y))){if(g.start>y.end){var b=this.fragmentTracker.getFragAtPos(v,$M);b&&b.end>y.end&&(y=b,this.mainFragLoading={frag:b,targetBufferTime:null})}if(g.start>y.end)return}this.loadFragment(g,o,v)}}else this.bufferFlushed=!0}}}}},{key:"onMediaDetaching",value:function(t,i){this.bufferFlushed=this.flushing=!1,pe(e,"onMediaDetaching",this)([t,i])}},{key:"onAudioTracksUpdated",value:function(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(e=>new MP(e))}},{key:"onAudioTrackSwitching",value:function(e,t){var i=!!t.url;this.trackId=t.id;var n=this.fragCurrent;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?(this.switchingTrack=t,this.flushAudioIfNeeded(t),this.state!==XD&&(this.setInterval(100),this.state=YD,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=t,this.clearInterval())}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details;var i=this.cachedTrackLoadedData;i&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(_M.AUDIO_TRACK_LOADED,i))}},{key:"onAudioTrackLoaded",value:function(e,t){var i,n=this.levels,a=t.details,r=t.id,o=t.groupId,s=t.track;if(n){var u=this.mainDetails;if(!u||a.endCC>u.endCC||u.expired)return this.cachedTrackLoadedData=t,void(this.state!==XD&&(this.state=ZD));this.cachedTrackLoadedData=null,this.log(`Audio track ${r} "${s.name}" of "${o}" loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);var l=n[r],d=0;if(a.live||null!=(i=l.details)&&i.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;var h;if(l.details)d=this.alignPlaylists(a,l.details,null==(h=this.levelLastLoaded)?void 0:h.details);a.alignedSliding||(UD(a,u),a.alignedSliding||HD(a,u),d=a.fragmentStart)}l.details=a,this.levelLastLoaded=l,this.startFragRequested||this.setStartPosition(u,d),this.hls.trigger(_M.AUDIO_TRACK_UPDATED,{details:a,id:r,groupId:t.groupId}),this.state!==ZD||this.waitForCdnTuneIn(a)||(this.state=YD),this.tick()}else this.warn(`Audio tracks reset while loading track ${r} "${s.name}" of "${o}"`)}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.config,o=this.trackId,s=this.levels;if(s){var u=s[o];if(u){var l=u.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(i.start);var d=r.defaultAudioCodec||u.audioCodec||"mp4a.40.2",h=this.transmuxer;h||(h=this.transmuxer=new BC(this.hls,NM,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var c=this.initPTS[i.cc],m=null==(t=i.initSegment)?void 0:t.data;if(void 0!==c){var f=n?n.index:-1,v=-1!==f,p=new PA(i.level,i.sn,i.stats.chunkCount,a.byteLength,f,v);h.push(a,m,d,"",i,n,l.totalduration,!1,p,c)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${l.startSN} ,${l.endSN}],track ${o}`),(this.waitingData=this.waitingData||{frag:i,part:n,cache:new ux,complete:!1}).cache.push(new Uint8Array(a)),this.state!==XD&&(this.state=ax)}}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"_handleFragmentLoadComplete",value:function(t){this.waitingData?this.waitingData.complete=!0:pe(e,"_handleFragmentLoadComplete",this)([t])}},{key:"onBufferReset",value:function(){this.mediaBuffer=null}},{key:"onBufferCreated",value:function(e,t){this.bufferFlushed=this.flushing=!1;var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null)}},{key:"onFragLoading",value:function(e,t){!this.audioOnly&&t.frag.type===$M&&bT(t.frag)&&(this.mainFragLoading=t,this.state===YD&&this.tick())}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part;if(i.type===NM)if(this.fragContextChanged(i))this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(bT(i)){this.fragPrevious=i;var a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(_M.AUDIO_TRACK_SWITCHED,VM({},a)))}this.fragBufferedComplete(i,n),this.media&&this.tick()}else this.audioOnly||i.type!==$M||i.elementaryStreams.video||i.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}},{key:"onError",value:function(t,i){var n;if(i.fatal)this.state=nx;else switch(i.details){case LM.FRAG_GAP:case LM.FRAG_PARSING_ERROR:case LM.FRAG_DECRYPT_ERROR:case LM.FRAG_LOAD_ERROR:case LM.FRAG_LOAD_TIMEOUT:case LM.KEY_LOAD_ERROR:case LM.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(NM,i);break;case LM.AUDIO_TRACK_LOAD_ERROR:case LM.AUDIO_TRACK_LOAD_TIMEOUT:case LM.LEVEL_PARSING_ERROR:i.levelRetry||this.state!==ZD||(null==(n=i.context)?void 0:n.type)!==WM||(this.state=YD);break;case LM.BUFFER_ADD_CODEC_ERROR:case LM.BUFFER_APPEND_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)||this.resetLoadingState();break;case LM.BUFFER_FULL_ERROR:if("audio"!==i.parent)return;this.reduceLengthAndFlushBuffer(i)&&(this.bufferedTrack=null,pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]));break;case LM.INTERNAL_EXCEPTION:this.recoverWorkerError(i)}}},{key:"onBufferFlushing",value:function(e,{type:t}){t!==pT&&(this.flushing=!0)}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==pT){this.flushing=!1,this.bufferFlushed=!0,this.state===ix&&(this.state=YD);var i=this.mediaBuffer||this.media;i&&(this.afterBufferFlushed(i,t,NM),this.tick())}}},{key:"_handleTransmuxComplete",value:function(e){var t,i="audio",n=this.hls,a=e.remuxResult,r=e.chunkMeta,o=this.getCurrentContext(r);if(o){var s=o.frag,u=o.part,l=o.level,d=l.details,h=a.audio,c=a.text,m=a.id3,f=a.initSegment;if(!this.fragContextChanged(s)&&d){if(this.state=ex,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){var v=s.initSegment||s;if(this.unhandledEncryptionError(f,s))return;this._bufferInitSegment(l,f.tracks,v,r),n.trigger(_M.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:i,tracks:f.tracks})}if(h){var p=h.startPTS,g=h.endPTS,y=h.startDTS,b=h.endDTS;u&&(u.elementaryStreams[vT]={startPTS:p,endPTS:g,startDTS:y,endDTS:b}),s.setElementaryStreamInfo(vT,p,g,y,b),this.bufferFragmentData(h,s,u,r)}if(null!=m&&null!=(t=m.samples)&&t.length){var w=HM({id:i,frag:s,details:d},m);n.trigger(_M.FRAG_PARSING_METADATA,w)}if(c){var k=HM({id:i,frag:s,details:d},c);n.trigger(_M.FRAG_PARSING_USERDATA,k)}}else this.fragmentTracker.removeFragment(s)}else this.resetWhenMissingContext(r)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===ex&&(t.video&&delete t.video,t.audiovideo&&delete t.audiovideo,t.audio)){var a=t.audio;a.id=NM;var r=e.audioCodec;this.log(`Init audio buffer, container:${a.container}, codecs[level/parsed]=[${r}/${a.codec}]`),r&&1===r.split(",").length&&(a.levelCodec=r),this.hls.trigger(_M.BUFFER_CODECS,t);var o=a.initSegment;if(null!=o&&o.byteLength){var s={type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:o};this.hls.trigger(_M.BUFFER_APPENDING,s)}this.tickImmediate()}}},{key:"loadFragment",value:function(t,i,n){var a,r=this.fragmentTracker.getState(t);if(this.switchingTrack||r===oA||r===uA)if(bT(t))if(null!=(a=i.details)&&a.live&&!this.initPTS[t.cc]){this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=ax;var o=this.mainDetails;o&&o.fragmentStart!==i.details.fragmentStart&&HD(i.details,o)}else pe(e,"loadFragment",this)([t,i,n]);else this._loadInitSegment(t,i);else this.clearTrackerIfNeeded(t)}},{key:"flushAudioIfNeeded",value:function(t){if(this.media&&this.bufferedTrack){var i=this.bufferedTrack;LP({name:i.name,lang:i.lang,assocLang:i.assocLang,characteristics:i.characteristics,audioCodec:i.audioCodec,channels:i.channels},t,_P)||(FP(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]),this.bufferedTrack=null):this.bufferedTrack=t)}}},{key:"completeAudioSwitch",value:function(e){var t=this.hls;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(_M.AUDIO_TRACK_SWITCHED,VM({},e))}}])}(),UC=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i,t.logger])).hls=void 0,n.canLoad=!1,n.timer=-1,n.hls=t,n}return ue(e,KM),ne(e,[{key:"destroy",value:function(){this.clearTimer(),this.hls=this.log=this.warn=null}},{key:"clearTimer",value:function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}},{key:"startLoad",value:function(){this.canLoad=!0,this.loadPlaylist()}},{key:"stopLoad",value:function(){this.canLoad=!1,this.clearTimer()}},{key:"switchParams",value:function(e,t,i){var n=null==t?void 0:t.renditionReports;if(n){for(var a=-1,r=0;r<n.length;r++){var o=n[r],s=void 0;try{s=new self.URL(o.URI,t.url).href}catch(e){this.warn(`Could not construct new URL for Rendition Report: ${e}`),s=o.URI||""}if(s===e){a=r;break}s===e.substring(0,s.length)&&(a=r)}if(-1!==a){var u=n[a],l=parseInt(u["LAST-MSN"])||t.lastPartSn,d=parseInt(u["LAST-PART"])||t.lastPartIndex;if(this.hls.config.lowLatencyMode){var h=Math.min(t.age-t.partTarget,t.targetduration);d>=0&&h>t.partTarget&&(d+=1)}var c=i&&SP(i);return new EP(l,d>=0?d:void 0,c)}}}},{key:"loadPlaylist",value:function(e){this.clearTimer()}},{key:"loadingPlaylist",value:function(e,t){this.clearTimer()}},{key:"shouldLoadPlaylist",value:function(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}},{key:"getUrlWithDirectives",value:function(e,t){if(t)try{return t.addDirectives(e)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}return e}},{key:"playlistLoaded",value:function(e,t,i){var n=t.details,a=t.stats,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;n.advancedDateTime=Date.now()-o;var s=this.hls.config.timelineOffset;if(s!==n.appliedTimelineOffset){var u=Math.max(s||0,0);n.appliedTimelineOffset=u,n.fragments.forEach(e=>{e.setStart(e.playlistOffset+u)})}if(n.live||null!=i&&i.live){var l="levelInfo"in t?t.levelInfo:t.track;if(n.reloaded(i),i&&n.fragments.length>0){xD(i,n,this);var d=n.playlistParsingError;if(d){this.warn(d);var h=this.hls;if(!h.config.ignorePlaylistParsingErrors){var c,m=t.networkDetails;return void h.trigger(_M.ERROR,{type:IM.NETWORK_ERROR,details:LM.LEVEL_PARSING_ERROR,fatal:!1,url:n.url,error:d,reason:d.message,level:t.level||void 0,parent:null==(c=n.fragments[0])?void 0:c.type,networkDetails:m,stats:a})}n.playlistParsingError=null}}-1===n.requestScheduled&&(n.requestScheduled=a.loading.start);var f,v=this.hls.mainForwardBufferInfo,p=v?v.end-v.len:0,g=_D(n,1e3*(n.edge-p));if(n.requestScheduled+g<r?n.requestScheduled=r:n.requestScheduled+=g,this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),!this.canLoad||!n.live)return;var y=void 0,b=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var w=this.hls.config.lowLatencyMode,k=n.lastPartSn,S=n.endSN,E=n.lastPartIndex,M=k===S;-1!==E?M?(y=S+1,b=w?0:E):(y=k,b=w?E+1:n.maxPartIndex):y=S+1;var T=n.age,P=T+n.ageHeader,A=Math.min(P-n.partTarget,1.5*n.targetduration);if(A>0){if(P>3*n.targetduration)this.log(`Playlist last advanced ${T.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,b=void 0;else if(null!=i&&i.tuneInGoal&&P-n.partTarget>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${A} with playlist age: ${n.age}`),A=0;else{var D=Math.floor(A/n.targetduration);if(y+=D,void 0!==b)b+=Math.round(A%n.targetduration/n.partTarget);this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${T.toFixed(2)}s goal: ${A} skip sn ${D} to part ${b}`)}n.tuneInGoal=A}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b),w||!M)return n.requestScheduled=r,void this.loadingPlaylist(l,f)}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,y,b));f&&void 0!==y&&n.canBlockReload&&(n.requestScheduled=a.loading.first+Math.max(g-2*o,g/2)),this.scheduleLoading(l,f,n)}else this.clearTimer()}},{key:"scheduleLoading",value:function(e,t,i){var n=i||e.details;if(n){var a=self.performance.now(),r=n.requestScheduled;if(a>=r)this.loadingPlaylist(e,t);else{var o=r-a;this.log(`reload live playlist ${e.name||e.bitrate+"bps"} in ${Math.round(o)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(e,t),o)}}else this.loadingPlaylist(e,t)}},{key:"getDeliveryDirectives",value:function(e,t,i,n){var a=SP(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=bP),new EP(i,n,a)}},{key:"checkRetry",value:function(e){var t=e.details,i=zP(e),n=e.errorAction,a=n||{},r=a.action,o=a.retryCount,s=void 0===o?0:o,u=a.retryConfig,l=!!n&&!!u&&(r===ZP||!n.resolved&&r===JP);if(l){var d;if(s>=u.maxNumRetry)return!1;if(i&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{var h=VP(u,s);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),h),this.warn(`Retrying playlist loading ${s+1}/${u.maxNumRetry} after "${t}" in ${h}ms`)}e.levelRetry=!0,n.resolved=!0}return l}}])}();function HC(e,t){if(e.length!==t.length)return!1;for(var i=0;i<e.length;i++)if(!GC(e[i].attrs,t[i].attrs))return!1;return!0}function GC(e,t,i){var n=e["STABLE-RENDITION-ID"];return n&&!i?n===t["STABLE-RENDITION-ID"]:!(i||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(i=>e[i]!==t[i])}function VC(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}var KC=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t,"audio-track-controller"])).tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.registerListeners(),i}return ue(e,UC),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_M.LEVEL_LOADING,this.onLevelLoading,this),e.on(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_M.LEVEL_LOADING,this.onLevelLoading,this),e.off(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_M.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(_M.ERROR,this.onError,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,pe(e,"destroy",this)([])}},{key:"onManifestLoading",value:function(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.audioTracks||[]}},{key:"onAudioTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Audio track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Audio track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.audioGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.audioPreference;if(!a&&o){var s=IP(o,r,_P);if(s>-1)a=r[s];else{var u=IP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group(s): ${null==i?void 0:i.join(",")}`),this.hls.trigger(_M.AUDIO_TRACKS_UPDATED,d);var h=this.trackId;if(-1!==l&&-1===h)this.setAudioTrack(l);else if(r.length&&-1===h){var c,m=new Error(`No audio track selected for current audio group-ID(s): ${null==(c=this.groupIds)?void 0:c.join(",")} track count: ${r.length}`);this.warn(m.message),this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:m})}}}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==WM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allAudioTracks",get:function(){return this.tracks}},{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}},{key:"setAudioOption",value:function(e){var t=this.hls;if(t.config.audioPreference=e,e){var i=this.allAudioTracks;if(this.selectDefaultTrack=!1,i.length){var n=this.currentTrack;if(n&&LP(e,n,_P))return n;var a=IP(e,this.tracksInGroup,_P);if(a>-1){var r=this.tracksInGroup[a];return this.setAudioTrack(a),r}if(n){var o=t.loadLevel;-1===o&&(o=t.firstAutoLevel);var s=function(e,t,i,n,a){var r=t[n],o=t.reduce((e,t,i)=>{var n=t.uri;return(e[n]||(e[n]=[])).push(i),e},{})[r.uri];o.length>1&&(n=Math.max.apply(Math,o));var s=r.videoRange,u=r.frameRate,l=r.codecSet.substring(0,4),d=RP(t,n,t=>{if(t.videoRange!==s||t.frameRate!==u||t.codecSet.substring(0,4)!==l)return!1;var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return IP(e,r,a)>-1});return d>-1?d:RP(t,n,t=>{var n=t.audioGroups,r=i.filter(e=>!n||-1!==n.indexOf(e.groupId));return IP(e,r,a)>-1})}(e,t.levels,i,o,_P);if(-1===s)return null;t.nextLoadLevel=s}if(e.channels||e.audioCodec){var u=IP(e,i);if(u>-1)return i[u]}}}return null}},{key:"setAudioTrack",value:function(e){var t=this.tracksInGroup;if(e<0||e>=t.length)this.warn(`Invalid audio track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e],a=n.details&&!n.details.live;if(!(e===this.trackId&&n===i&&a||(this.log(`Switching to audio-track ${e} "${n.name}" lang:${n.lang} group:${n.groupId} channels:${n.channels}`),this.trackId=e,this.currentTrack=n,this.hls.trigger(_M.AUDIO_TRACK_SWITCHING,VM({},n)),a))){var r=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(r)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=0;i<t.length;i++){var n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||LP(e,n,_P)))return i}if(e){for(var a=e.name,r=e.lang,o=e.assocLang,s=e.characteristics,u=e.audioCodec,l=e.channels,d=0;d<t.length;d++){if(LP({name:a,lang:r,assocLang:o,characteristics:s,audioCodec:u,channels:l},t[d],_P))return d}for(var h=0;h<t.length;h++){var c=t[h];if(GC(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return h}for(var m=0;m<t.length;m++){var f=t[m];if(GC(e.attrs,f.attrs,["LANGUAGE"]))return m}}return-1}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]);var i=this.currentTrack;this.shouldLoadPlaylist(i)&&FP(i.url,this.hls)&&this.scheduleLoading(i,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading audio-track ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(_M.AUDIO_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}}])}(),XC=function(){return ne(function e(t){Q(this,e),this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t},[{key:"destroy",value:function(){this.tracks=this.queues=null}},{key:"append",value:function(e,t,i){if(null!==this.queues&&null!==this.tracks){var n=this.queues[t];n.push(e),1!==n.length||i||this.executeNext(t)}}},{key:"appendBlocker",value:function(e){return new Promise(t=>{var i={label:"async-blocker",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(i,e)})}},{key:"prependBlocker",value:function(e){return new Promise(t=>{if(this.queues){var i={label:"async-blocker-prepend",execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[e].unshift(i)}})}},{key:"removeBlockers",value:function(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(e=>{var t,i=null==(t=e[0])?void 0:t.label;"async-blocker"!==i&&"async-blocker-prepend"!==i||(e[0].execute(),e.splice(0,1))})}},{key:"unblockAudio",value:function(e){null!==this.queues&&(this.queues.audio[0]===e&&this.shiftAndExecuteNext("audio"))}},{key:"executeNext",value:function(e){if(null!==this.queues&&null!==this.tracks){var t=this.queues[e];if(t.length){var i=t[0];try{i.execute()}catch(t){var n;if(i.onError(t),null===this.queues||null===this.tracks)return;var a=null==(n=this.tracks[e])?void 0:n.buffer;null!=a&&a.updating||this.shiftAndExecuteNext(e)}}}}},{key:"shiftAndExecuteNext",value:function(e){null!==this.queues&&(this.queues[e].shift(),this.executeNext(e))}},{key:"current",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e][0])||null}},{key:"toString",value:function(){var e=this.queues,t=this.tracks;return null===e||null===t?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}},{key:"list",value:function(e){var t,i;return null!=(t=this.queues)&&t[e]||null!=(i=this.tracks)&&i[e]?`${e}: (${this.listSbInfo(e)}) ${this.listOps(e)}`:""}},{key:"listSbInfo",value:function(e){var t,i=null==(t=this.tracks)?void 0:t[e],n=null==i?void 0:i.buffer;return n?`SourceBuffer${n.updating?" updating":""}${i.ended?" ended":""}${i.ending?" ending":""}`:"none"}},{key:"listOps",value:function(e){var t;return(null==(t=this.queues)?void 0:t[e].map(e=>e.label).join(", "))||""}}])}(),YC=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,qC="HlsJsTrackRemovedError",JC=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t])).name=qC,i}return ue(e,ye(Error)),ne(e)}(),QC=function(){function e(t,i){var n,a;return Q(this,e),(n=J(this,e,["buffer-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.details=null,n._objectUrl=null,n.operationQueue=null,n.bufferCodecEventsTotal=0,n.media=null,n.mediaSource=null,n.lastMpegAudioChunk=null,n.blockedAudioAppend=null,n.lastVideoAppendEnd=0,n.appendSource=void 0,n.transferData=void 0,n.overrides=void 0,n.appendErrors={audio:0,video:0,audiovideo:0},n.tracks={},n.sourceBuffers=[[null,null],[null,null]],n._onEndStreaming=e=>{var t;n.hls&&"open"===(null==(t=n.mediaSource)?void 0:t.readyState)&&n.hls.pauseBuffering()},n._onStartStreaming=e=>{n.hls&&n.hls.resumeBuffering()},n._onMediaSourceOpen=e=>{var t=n,i=t.media,a=t.mediaSource;e&&n.log("Media source opened"),i&&a&&(a.removeEventListener("sourceopen",n._onMediaSourceOpen),i.removeEventListener("emptied",n._onMediaEmptied),n.updateDuration(),n.hls.trigger(_M.MEDIA_ATTACHED,{media:i,mediaSource:a}),null!==n.mediaSource&&n.checkPendingTracks())},n._onMediaSourceClose=()=>{n.log("Media source closed")},n._onMediaSourceEnded=()=>{n.log("Media source ended")},n._onMediaEmptied=()=>{var e=n,t=e.mediaSrc,i=e._objectUrl;t!==i&&n.error(`Media element src was set while attaching MediaSource (${i} > ${t})`)},n.hls=t,n.fragmentTracker=i,n.appendSource=(a=eT(t.config.preferManagedMediaSource),"undefined"!=typeof self&&a===self.ManagedMediaSource),n.initTracks(),n.registerListeners(),n}return ue(e,KM),ne(e,[{key:"hasSourceTypes",value:function(){return Object.keys(this.tracks).length>0}},{key:"destroy",value:function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_M.BUFFER_RESET,this.onBufferReset,this),e.on(_M.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_M.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_M.BUFFER_EOS,this.onBufferEos,this),e.on(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_M.FRAG_PARSED,this.onFragParsed,this),e.on(_M.FRAG_CHANGED,this.onFragChanged,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_M.BUFFER_RESET,this.onBufferReset,this),e.off(_M.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_M.BUFFER_EOS,this.onBufferEos,this),e.off(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_M.FRAG_PARSED,this.onFragParsed,this),e.off(_M.FRAG_CHANGED,this.onFragChanged,this),e.off(_M.ERROR,this.onError,this)}},{key:"transferMedia",value:function(){var e=this.media,t=this.mediaSource;if(!e)return null;var i={};if(this.operationQueue){var n=this.isUpdating();n||this.operationQueue.removeBlockers();var a=this.isQueued();(n||a)&&this.warn(`Transfering MediaSource with${a?" operations in queue":""}${n?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}var r=this.transferData;return!this.sourceBufferCount&&r&&r.mediaSource===t?HM(i,r.tracks):this.sourceBuffers.forEach(e=>{var t=e[0];t&&(i[t]=HM({},this.tracks[t]),this.removeBuffer(t)),e[0]=e[1]=null}),{media:e,mediaSource:t,tracks:i}}},{key:"initTracks",value:function(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}},{key:"onManifestLoading",value:function(){this.bufferCodecEventsTotal=0,this.details=null}},{key:"onManifestParsed",value:function(e,t){var i,n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsTotal=n,this.log(`${n} bufferCodec event(s) expected.`),null!=(i=this.transferData)&&i.mediaSource&&this.sourceBufferCount&&n&&this.bufferCreated()}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;this.transferData=this.overrides=void 0;var n=eT(this.appendSource);if(n){var a=!!t.mediaSource;(a||t.overrides)&&(this.transferData=t,this.overrides=t.overrides);var r=this.mediaSource=t.mediaSource||new n;if(this.assignMediaSource(r),a)this._objectUrl=i.src,this.attachTransferred();else{var o=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{i.removeAttribute("src");var s=self.ManagedMediaSource;i.disableRemotePlayback=i.disableRemotePlayback||s&&r instanceof s,ZC(i),function(e,t){var i=self.document.createElement("source");i.type="video/mp4",i.src=t,e.appendChild(i)}(i,o),i.load()}catch(e){i.src=o}else i.src=o}i.addEventListener("emptied",this._onMediaEmptied)}}},{key:"assignMediaSource",value:function(e){var t,i;this.log(`${(null==(t=this.transferData)?void 0:t.mediaSource)===e?"transferred":"created"} media source: ${null==(i=e.constructor)?void 0:i.name}`),e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.addEventListener("startstreaming",this._onStartStreaming),e.addEventListener("endstreaming",this._onEndStreaming))}},{key:"attachTransferred",value:function(){var e=this.media,t=this.transferData;if(t&&e){var i=this.tracks,n=t.tracks,a=n?Object.keys(n):null,r=a?a.length:0,o=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(n&&a&&r){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${AP(i,(e,t)=>"initSegment"===e?void 0:t)};\ntransfer tracks: ${AP(n,(e,t)=>"initSegment"===e?void 0:t)}}`),!tT(n,i)){t.mediaSource=null,t.tracks=void 0;var s=e.currentTime,u=this.details,l=Math.max(s,(null==u?void 0:u.fragments[0].start)||0);return l-s>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${s} -> ${l}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(n)}"->"${Object.keys(i)}") start time: ${l} currentTime: ${s}`),this.onMediaDetaching(_M.MEDIA_DETACHING,{}),this.onMediaAttaching(_M.MEDIA_ATTACHING,t),void(e.currentTime=l))}this.transferData=void 0,a.forEach(e=>{var t=e,i=n[t];if(i){var a=i.buffer;if(a){var r=this.fragmentTracker,o=i.id;if(r.hasFragments(o)||r.hasParts(o)){var s=DA.getBuffered(a);r.detectEvictedFragments(t,s,o,null,!0)}var u=eI(t),l=[t,a];this.sourceBuffers[u]=l,a.updating&&this.operationQueue&&this.operationQueue.prependBlocker(t),this.trackSourceBuffer(t,i)}}}),o(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),o()}}},{key:"mediaSourceOpenOrEnded",get:function(){var e,t=null==(e=this.mediaSource)?void 0:e.readyState;return"open"===t||"ended"===t}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;this.transferData=this.overrides=void 0;var n=this.media,a=this.mediaSource,r=this._objectUrl;if(a){if(this.log("media source "+(i?"transferring":"detaching")),i)this.sourceBuffers.forEach(([e])=>{e&&this.removeBuffer(e)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){var o="open"===a.readyState;try{for(var s=a.sourceBuffers,u=s.length;u--;)o&&s[u].abort(),a.removeSourceBuffer(s[u]);o&&a.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}a.removeEventListener("sourceopen",this._onMediaSourceOpen),a.removeEventListener("sourceended",this._onMediaSourceEnded),a.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.removeEventListener("startstreaming",this._onStartStreaming),a.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}n&&(n.removeEventListener("emptied",this._onMediaEmptied),i||(r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(n.removeAttribute("src"),this.appendSource&&ZC(n),n.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(_M.MEDIA_DETACHED,t)}},{key:"onBufferReset",value:function(){this.sourceBuffers.forEach(([e])=>{e&&this.resetBuffer(e)}),this.initTracks()}},{key:"resetBuffer",value:function(e){var t,i=null==(t=this.tracks[e])?void 0:t.buffer;if(this.removeBuffer(e),i)try{var n;null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(i)}catch(t){this.warn(`onBufferReset ${e}`,t)}delete this.tracks[e]}},{key:"removeBuffer",value:function(e){this.removeBufferListeners(e),this.sourceBuffers[eI(e)]=[null,null];var t=this.tracks[e];t&&(t.buffer=void 0)}},{key:"resetQueue",value:function(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new XC(this.tracks)}},{key:"onBufferCodecs",value:function(e,t){var i,n=this.tracks,a=Object.keys(t);this.log(`BUFFER_CODECS: "${a}" (current SB count ${this.sourceBufferCount})`);var r="audiovideo"in t&&(n.audio||n.video)||n.audiovideo&&("audio"in t||"video"in t),o=!r&&this.sourceBufferCount&&this.media&&a.some(e=>!n[e]);r||o?this.warn(`Unsupported transition between "${Object.keys(n)}" and "${a}" SourceBuffers`):(a.forEach(e=>{var i,a,r=t[e],o=r.id,s=r.codec,u=r.levelCodec,l=r.container,d=r.metadata,h=r.supplemental,c=n[e],m=null==(i=this.transferData)||null==(i=i.tracks)?void 0:i[e],f=null!=m&&m.buffer?m:c,v=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),p=null==f?void 0:f.levelCodec;c||(c=n[e]={buffer:void 0,listeners:[],codec:s,supplemental:h,container:l,levelCodec:u,metadata:d,id:o});var g=oP(v,p),y=null==g?void 0:g.replace(YC,"$1"),b=oP(s,u),w=null==(a=b)?void 0:a.replace(YC,"$1");b&&g&&y!==w&&("audio"===e.slice(0,5)&&(b=rP(b,this.appendSource)),this.log(`switching codec ${v} to ${b}`),b!==(c.pendingCodec||c.codec)&&(c.pendingCodec=b),c.container=l,this.appendChangeType(e,l,b))}),(this.tracksReady||this.sourceBufferCount)&&(t.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!t.video&&"main"===(null==(i=t.audio)?void 0:i.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}},{key:"sourceBufferTracks",get:function(){return Object.keys(this.tracks).reduce((e,t)=>{var i=this.tracks[t];return e[t]={id:i.id,container:i.container,codec:i.codec,levelCodec:i.levelCodec},e},{})}},{key:"appendChangeType",value:function(e,t,i){var n=`${t};codecs=${i}`,a={label:`change-type=${n}`,execute:()=>{var a=this.tracks[e];if(a){var r=a.buffer;null!=r&&r.changeType&&(this.log(`changing ${e} sourceBuffer type to ${n}`),r.changeType(n),a.codec=i,a.container=t)}this.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};this.append(a,e,this.isPending(this.tracks[e]))}},{key:"blockAudio",value:function(e){var t,i=e.start,n=i+.05*e.duration;if(!(!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,$M))?void 0:t.gap))){var a={label:"block-audio",execute:()=>{var e,t=this.tracks.video;(this.lastVideoAppendEnd>n||null!=t&&t.buffer&&DA.isBuffered(t.buffer,n)||!0===(null==(e=this.fragmentTracker.getAppendedFrag(n,$M))?void 0:e.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn("Error executing block-audio operation",e)}};this.blockedAudioAppend={op:a,frag:e},this.append(a,"audio",!0)}}},{key:"unblockAudio",value:function(){var e=this.blockedAudioAppend,t=this.operationQueue;e&&t&&(this.blockedAudioAppend=null,t.unblockAudio(e.op))}},{key:"onBufferAppending",value:function(e,t){var i=this.tracks,n=t.data,a=t.type,r=t.parent,o=t.frag,s=t.part,u=t.chunkMeta,l=t.offset,d=u.buffering[a],h=o.sn,c=o.cc,m=self.performance.now();d.start=m;var f=o.stats.buffering,v=s?s.stats.buffering:null;0===f.start&&(f.start=m),v&&0===v.start&&(v.start=m);var p=i.audio,g=!1;"audio"===a&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);var y=i.video,b=null==y?void 0:y.buffer;if(b&&"initSegment"!==h){var w=s||o,k=this.blockedAudioAppend;if("audio"!==a||"main"===r||this.blockedAudioAppend||y.ending||y.ended){if("video"===a){var S=w.end;if(k){var E=k.frag.start;(S>E||S<this.lastVideoAppendEnd||DA.isBuffered(b,E))&&this.unblockAudio()}this.lastVideoAppendEnd=S}}else{var M=w.start+.05*w.duration,T=b.buffered,P=this.currentOp("video");T.length||P?!P&&!DA.isBuffered(b,M)&&this.lastVideoAppendEnd<M&&this.blockAudio(w):this.blockAudio(w)}}var A=(s||o).start,D={label:`append-${a}`,execute:()=>{var e;d.executeStart=self.performance.now();var t=null==(e=this.tracks[a])?void 0:e.buffer;t&&(g?this.updateTimestampOffset(t,A,.1,a,h,c):void 0!==l&&DM(l)&&this.updateTimestampOffset(t,l,1e-6,a,h,c)),this.appendExecutor(n,a)},onStart:()=>{},onComplete:()=>{var e=self.performance.now();d.executeEnd=d.end=e,0===f.first&&(f.first=e),v&&0===v.first&&(v.first=e);var t={};this.sourceBuffers.forEach(([e,i])=>{e&&(t[e]=DA.getBuffered(i))}),this.appendErrors[a]=0,"audio"===a||"video"===a?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(_M.BUFFER_APPENDED,{type:a,frag:o,part:s,chunkMeta:u,parent:o.type,timeRanges:t})},onError:e=>{var t,i={type:IM.MEDIA_ERROR,parent:o.type,details:LM.BUFFER_APPEND_ERROR,sourceBufferName:a,frag:o,part:s,chunkMeta:u,error:e,err:e,fatal:!1},n=null==(t=this.media)?void 0:t.error;if(e.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==e.name||"quota"in e)i.details=LM.BUFFER_FULL_ERROR;else if(e.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!n)i.errorAction=rA(!0);else if(e.name===qC&&0===this.sourceBufferCount)i.errorAction=rA(!0);else{var r=++this.appendErrors[a];this.warn(`Failed ${r}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${a}" sourceBuffer (${n||"no media error"})`),(r>=this.hls.config.appendErrorMaxRetry||n)&&(i.fatal=!0)}this.hls.trigger(_M.ERROR,i)}};this.log(`queuing "${a}" append sn: ${h}${s?" p: "+s.index:""} of ${o.type===$M?"level":"track"} ${o.level} cc: ${c}`),this.append(D,a,this.isPending(this.tracks[a]))}},{key:"getFlushOp",value:function(e,t,i){return this.log(`queuing "${e}" remove ${t}-${i}`),{label:"remove",execute:()=>{this.removeExecutor(e,t,i)},onStart:()=>{},onComplete:()=>{this.hls.trigger(_M.BUFFER_FLUSHED,{type:e})},onError:n=>{this.warn(`Failed to remove ${t}-${i} from "${e}" SourceBuffer`,n)}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.type,n=t.startOffset,a=t.endOffset;i?this.append(this.getFlushOp(i,n,a),i):this.sourceBuffers.forEach(([e])=>{e&&this.append(this.getFlushOp(e,n,a),e)})}},{key:"onFragParsed",value:function(e,t){var i=t.frag,n=t.part,a=[],r=n?n.elementaryStreams:i.elementaryStreams;r[gT]?a.push("audiovideo"):(r[vT]&&a.push("audio"),r[pT]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(()=>{var e=self.performance.now();i.stats.buffering.end=e,n&&(n.stats.buffering.end=e);var t=n?n.stats:i.stats;this.hls.trigger(_M.FRAG_BUFFERED,{frag:i,part:n,stats:t,id:i.type})},a).catch(e=>{this.warn(`Fragment buffered callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)})}},{key:"onFragChanged",value:function(e,t){this.trimBuffers()}},{key:"bufferedToEnd",get:function(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{if(e){var t=this.tracks[e];if(t)return!t.ended||t.ending}return!1})}},{key:"onBufferEos",value:function(e,t){var i;this.sourceBuffers.forEach(([e])=>{if(e){var i=this.tracks[e];t.type&&t.type!==e||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${e} buffer reached EOS`)))}});var n=!1!==(null==(i=this.overrides)?void 0:i.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([e])=>{var t;return e&&!(null!=(t=this.tracks[e])&&t.ended)})?n?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();var e=this.mediaSource;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream(),this.hls.trigger(_M.BUFFERED_TO_END,void 0)):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})):(this.tracksEnded(),this.hls.trigger(_M.BUFFERED_TO_END,void 0)):"video"===t.type&&this.unblockAudio()}},{key:"tracksEnded",value:function(){this.sourceBuffers.forEach(([e])=>{if(null!==e){var t=this.tracks[e];t&&(t.ending=!1)}})}},{key:"onLevelUpdated",value:function(e,{details:t}){t.fragments.length&&(this.details=t,this.updateDuration())}},{key:"updateDuration",value:function(){this.blockUntilOpen(()=>{var e=this.getDurationAndRange();e&&this.updateMediaSource(e)})}},{key:"onError",value:function(e,t){if(t.details===LM.BUFFER_APPEND_ERROR&&t.frag){var i,n=null==(i=t.errorAction)?void 0:i.nextAutoLevel;DM(n)&&n!==t.frag.level&&this.resetAppendErrors()}}},{key:"resetAppendErrors",value:function(){this.appendErrors={audio:0,video:0,audiovideo:0}}},{key:"trimBuffers",value:function(){var e=this.hls,t=this.details,i=this.media;if(i&&null!==t&&this.sourceBufferCount){var n=e.config,a=i.currentTime,r=t.levelTargetDuration,o=t.live&&null!==n.liveBackBufferLength?n.liveBackBufferLength:n.backBufferLength;if(DM(o)&&o>=0){var s=Math.max(o,r),u=Math.floor(a/r)*r-s;this.flushBackBuffer(a,r,u)}var l=n.frontBufferFlushThreshold;if(DM(l)&&l>0){var d=Math.max(n.maxBufferLength,l),h=Math.max(d,r),c=Math.floor(a/r)*r+h;this.flushFrontBuffer(a,r,c)}}}},{key:"flushBackBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([e,t])=>{if(t){var n=DA.getBuffered(t);if(n.length>0&&i>n.start(0)){var a;this.hls.trigger(_M.BACK_BUFFER_REACHED,{bufferEnd:i});var r=this.tracks[e];if(null!=(a=this.details)&&a.live)this.hls.trigger(_M.LIVE_BACK_BUFFER_REACHED,{bufferEnd:i});else if(null!=r&&r.ended)return void this.log(`Cannot flush ${e} back buffer while SourceBuffer is in ended state`);this.hls.trigger(_M.BUFFER_FLUSHING,{startOffset:0,endOffset:i,type:e})}}})}},{key:"flushFrontBuffer",value:function(e,t,i){this.sourceBuffers.forEach(([t,n])=>{if(n){var a=DA.getBuffered(n),r=a.length;if(r<2)return;var o=a.start(r-1),s=a.end(r-1);if(i>o||e>=o&&e<=s)return;this.hls.trigger(_M.BUFFER_FLUSHING,{startOffset:o,endOffset:1/0,type:t})}})}},{key:"getDurationAndRange",value:function(){var e,t=this.details,i=this.mediaSource;if(!t||!this.media||"open"!==(null==i?void 0:i.readyState))return null;var n=t.edge;if(t.live&&this.hls.config.liveDurationInfinity){if(t.fragments.length&&i.setLiveSeekableRange){var a=Math.max(0,t.fragmentStart);return{duration:1/0,start:a,end:Math.max(a,n)}}return{duration:1/0}}var r=null==(e=this.overrides)?void 0:e.duration;if(r)return DM(r)?{duration:r}:null;var o=this.media.duration;return n>(DM(i.duration)?i.duration:0)&&n>o||!DM(o)?{duration:n}:null}},{key:"updateMediaSource",value:function({duration:e,start:t,end:i}){var n=this.mediaSource;this.media&&n&&"open"===n.readyState&&(n.duration!==e&&(DM(e)&&this.log(`Updating MediaSource duration to ${e.toFixed(3)}`),n.duration=e),void 0!==t&&void 0!==i&&(this.log(`MediaSource duration is set to ${n.duration}. Setting seekable range to ${t}-${i}.`),n.setLiveSeekableRange(t,i)))}},{key:"tracksReady",get:function(){var e=this.pendingTrackCount;return e>0&&(e>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}},{key:"checkPendingTracks",value:function(){var e=this.bufferCodecEventsTotal,t=this.pendingTrackCount,i=this.tracks;if(this.log(`checkPendingTracks (pending: ${t} codec events expected: ${e}) ${AP(i)}`),this.tracksReady){var n,a=null==(n=this.transferData)?void 0:n.tracks;a&&Object.keys(a).length?this.attachTransferred():this.createSourceBuffers()}}},{key:"bufferCreated",value:function(){if(this.sourceBufferCount){var e={};this.sourceBuffers.forEach(([t,i])=>{if(t){var n=this.tracks[t];e[t]={buffer:i,container:n.container,codec:n.codec,supplemental:n.supplemental,levelCodec:n.levelCodec,id:n.id,metadata:n.metadata}}}),this.hls.trigger(_M.BUFFER_CREATED,{tracks:e}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([e])=>{this.executeNext(e)})}else{var t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}},{key:"createSourceBuffers",value:function(){var e=this.tracks,t=this.sourceBuffers,i=this.mediaSource;if(!i)throw new Error("createSourceBuffers called when mediaSource was null");for(var n in e){var a=n,r=e[a];if(this.isPending(r)){var o=this.getTrackCodec(r,a),s=`${r.container};codecs=${o}`;r.codec=o,this.log(`creating sourceBuffer(${s})${this.currentOp(a)?" Queued":""} ${AP(r)}`);try{var u=i.addSourceBuffer(s),l=eI(a),d=[a,u];t[l]=d,r.buffer=u}catch(e){var h;return this.error(`error while trying to add sourceBuffer: ${e.message}`),this.shiftAndExecuteNext(a),null==(h=this.operationQueue)||h.removeBlockers(),delete this.tracks[a],void this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s,parent:r.id})}this.trackSourceBuffer(a,r)}}this.bufferCreated()}},{key:"getTrackCodec",value:function(e,t){var i=e.supplemental,n=e.codec;i&&("video"===t||"audiovideo"===t)&&QT(i,"video")&&(n=function(e,t){var i=[];if(e)for(var n=e.split(","),a=0;a<n.length;a++)JT(n[a],"video")||i.push(n[a]);return t&&i.push(t),i.join(",")}(n,i));var a=oP(n,e.levelCodec);return a?"audio"===t.slice(0,5)?rP(a,this.appendSource):a:""}},{key:"trackSourceBuffer",value:function(e,t){var i=t.buffer;if(i){var n=this.getTrackCodec(t,e);this.tracks[e]={buffer:i,codec:n,container:t.container,levelCodec:t.levelCodec,supplemental:t.supplemental,metadata:t.metadata,id:t.id,listeners:[]},this.removeBufferListeners(e),this.addBufferListener(e,"updatestart",this.onSBUpdateStart),this.addBufferListener(e,"updateend",this.onSBUpdateEnd),this.addBufferListener(e,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(e,"bufferedchange",(e,t)=>{var i=t.removedRanges;null!=i&&i.length&&this.hls.trigger(_M.BUFFER_FLUSHED,{type:e})})}}},{key:"mediaSrc",get:function(){var e,t,i=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==i?void 0:i.src}},{key:"onSBUpdateStart",value:function(e){var t=this.currentOp(e);t&&t.onStart()}},{key:"onSBUpdateEnd",value:function(e){var t;if("closed"!==(null==(t=this.mediaSource)?void 0:t.readyState)){var i=this.currentOp(e);i&&(i.onComplete(),this.shiftAndExecuteNext(e))}else this.resetBuffer(e)}},{key:"onSBUpdateError",value:function(e,t){var i,n=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(i=this.mediaSource)?void 0:i.readyState}`);this.error(`${n}`,t),this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:n,fatal:!1});var a=this.currentOp(e);a&&a.onError(n)}},{key:"updateTimestampOffset",value:function(e,t,i,n,a,r){var o=t-e.timestampOffset;Math.abs(o)>=i&&(this.log(`Updating ${n} SourceBuffer timestampOffset to ${t} (sn: ${a} cc: ${r})`),e.timestampOffset=t)}},{key:"removeExecutor",value:function(e,t,i){var n=this.media,a=this.mediaSource,r=this.tracks[e],o=null==r?void 0:r.buffer;if(!n||!a||!o)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(e);var s=DM(n.duration)?n.duration:1/0,u=DM(a.duration)?a.duration:1/0,l=Math.max(0,t),d=Math.min(i,s,u);d>l&&(!r.ending||r.ended)?(r.ended=!1,this.log(`Removing [${l},${d}] from the ${e} SourceBuffer`),o.remove(l,d)):this.shiftAndExecuteNext(e)}},{key:"appendExecutor",value:function(e,t){var i=this.tracks[t],n=null==i?void 0:i.buffer;if(!n)throw new JC(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);i.ending=!1,i.ended=!1,n.appendBuffer(e)}},{key:"blockUntilOpen",value:function(e){if(this.isUpdating()||this.isQueued())this.blockBuffers(e).catch(e=>{this.warn(`SourceBuffer blocked callback ${e}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{e()}catch(e){this.warn(`Callback run without blocking ${this.operationQueue} ${e}`)}}},{key:"isUpdating",value:function(){return this.sourceBuffers.some(([e,t])=>e&&t.updating)}},{key:"isQueued",value:function(){return this.sourceBuffers.some(([e])=>e&&!!this.currentOp(e))}},{key:"isPending",value:function(e){return!!e&&!e.buffer}},{key:"blockBuffers",value:function(e,t=this.sourceBufferTypes){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);var i=this.operationQueue,n=t.map(e=>this.appendBlocker(e));return t.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(n).then(t=>{i===this.operationQueue&&(e(),this.stepOperationQueue(this.sourceBufferTypes))})}},{key:"stepOperationQueue",value:function(e){e.forEach(e=>{var t,i=null==(t=this.tracks[e])?void 0:t.buffer;i&&!i.updating&&this.shiftAndExecuteNext(e)})}},{key:"append",value:function(e,t,i){this.operationQueue&&this.operationQueue.append(e,t,i)}},{key:"appendBlocker",value:function(e){if(this.operationQueue)return this.operationQueue.appendBlocker(e)}},{key:"currentOp",value:function(e){return this.operationQueue?this.operationQueue.current(e):null}},{key:"executeNext",value:function(e){e&&this.operationQueue&&this.operationQueue.executeNext(e)}},{key:"shiftAndExecuteNext",value:function(e){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(e)}},{key:"pendingTrackCount",get:function(){return Object.keys(this.tracks).reduce((e,t)=>e+(this.isPending(this.tracks[t])?1:0),0)}},{key:"sourceBufferCount",get:function(){return this.sourceBuffers.reduce((e,[t])=>e+(t?1:0),0)}},{key:"sourceBufferTypes",get:function(){return this.sourceBuffers.map(([e])=>e).filter(e=>!!e)}},{key:"addBufferListener",value:function(e,t,i){var n=this.tracks[e];if(n){var a=n.buffer;if(a){var r=i.bind(this,e);n.listeners.push({event:t,listener:r}),a.addEventListener(t,r)}}}},{key:"removeBufferListeners",value:function(e){var t=this.tracks[e];if(t){var i=t.buffer;i&&(t.listeners.forEach(e=>{i.removeEventListener(e.event,e.listener)}),t.listeners.length=0)}}}])}();function ZC(e){var t=e.querySelectorAll("source");[].slice.call(t).forEach(t=>{e.removeChild(t)})}function eI(e){return"audio"===e?1:0}var tI=function(){function e(t){Q(this,e),this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}return ne(e,[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"destroy",value:function(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}},{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_M.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListener",value:function(){var e=this.hls;e.off(_M.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"onFpsDropLevelCapping",value:function(e,t){var i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}},{key:"onManifestParsed",value:function(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onLevelsUpdated",value:function(e,t){this.timer&&DM(this.autoLevelCapping)&&this.detectPlayerSize()}},{key:"onBufferCodecs",value:function(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}},{key:"onMediaDetaching",value:function(){this.stopCapping(),this.media=null}},{key:"detectPlayerSize",value:function(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);var e=this.hls.levels;if(e.length){var t=this.hls,i=this.getMaxLevel(e.length-1);i!==this.autoLevelCapping&&t.logger.log(`Setting autoLevelCapping to ${i}: ${e[i].height}p@${e[i].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=i,t.autoLevelEnabled&&t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}},{key:"getMaxLevel",value:function(t){var i=this.hls.levels;if(!i.length)return-1;var n=i.filter((e,i)=>this.isLevelAllowed(e)&&i<=t);return this.clientRect=null,e.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}},{key:"startCapping",value:function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}},{key:"stopCapping",value:function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}},{key:"getDimensions",value:function(){if(this.clientRect)return this.clientRect;var e=this.media,t={width:0,height:0};if(e){var i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}},{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return Math.min(e,this.hls.config.maxDevicePixelRatio)}},{key:"isLevelAllowed",value:function(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}}],[{key:"getMaxLevelByMediaSize",value:function(e,t,i){if(null==e||!e.length)return-1;for(var n=(e,t)=>!t||(e.width!==t.width||e.height!==t.height),a=e.length-1,r=Math.max(t,i),o=0;o<e.length;o+=1){var s=e[o];if((s.width>=r||s.height>=r)&&n(s,e[o+1])){a=o;break}}return a}}])}(),iI={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"},nI={HLS:"h"},aI=ne(function e(t,i){Q(this,e),Array.isArray(t)&&(t=t.map(t=>t instanceof e?t:new e(t))),this.value=t,this.params=i});function rI(e,t,i,n){return new Error(`failed to ${e} "${a=t,Array.isArray(a)?JSON.stringify(a):a instanceof Map?"Map{}":a instanceof Set?"Set{}":"object"==typeof a?JSON.stringify(a):String(a)}" as ${i}`,{cause:n});var a}function oI(e,t,i){return rI("serialize",e,t,i)}var sI=ne(function e(t){Q(this,e),this.description=t}),uI="Bare Item";function lI(e){if(!1===ArrayBuffer.isView(e))throw oI(e,"Byte Sequence");return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function dI(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw oI(e,"Integer");return e.toString()}function hI(e,t){if(e<0)return-hI(-e,t);var i=Math.pow(10,t);if(Math.abs(e*i%1-.5)<Number.EPSILON){var n=Math.floor(e*i);return(n%2==0?n:n+1)/i}return Math.round(e*i)/i}function cI(e){var t=hI(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw oI(e,"Decimal");var i=t.toString();return i.includes(".")?i:`${i}.0`}var mI=/[\x00-\x1f\x7f]+/;function fI(e){var t,i=(t=e).description||t.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(i))throw oI(i,"Token");return i}function vI(e){switch(typeof e){case"number":if(!DM(e))throw oI(e,uI);return Number.isInteger(e)?dI(e):cI(e);case"string":return function(e){if(mI.test(e))throw oI(e,"String");return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return fI(e);case"boolean":return function(e){if("boolean"!=typeof e)throw oI(e,"Boolean");return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${dI(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return lI(e);if(e instanceof sI)return fI(e);default:throw oI(e,uI)}}function pI(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw oI(e,"Key");return e}function gI(e){return null==e?"":Object.entries(e).map(([e,t])=>!0===t?`;${pI(e)}`:`;${pI(e)}=${vI(t)}`).join("")}function yI(e){return e instanceof aI?`${vI(e.value)}${gI(e.params)}`:vI(e)}function bI(e,t={whitespace:!0}){if("object"!=typeof e||null==e)throw oI(e,"Dict");var i=e instanceof Map?e.entries():Object.entries(e),n=(null==t?void 0:t.whitespace)?" ":"";return Array.from(i).map(([e,t])=>{t instanceof aI==!1&&(t=new aI(t));var i,n=pI(e);return!0===t.value?n+=gI(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map(yI).join(" ")})${gI(i.params)}`:n+=yI(t)),n}).join(`,${n}`)}function wI(e,t){return bI(e,t)}var kI="CMCD-Object",SI="CMCD-Request",EI="CMCD-Session",MI="CMCD-Status",TI={br:kI,ab:kI,d:kI,ot:kI,tb:kI,tpb:kI,lb:kI,tab:kI,lab:kI,url:kI,pb:SI,bl:SI,tbl:SI,dl:SI,ltc:SI,mtp:SI,nor:SI,nrr:SI,rc:SI,sn:SI,sta:SI,su:SI,ttfb:SI,ttfbb:SI,ttlb:SI,cmsdd:SI,cmsds:SI,smrt:SI,df:SI,cs:SI,ts:SI,cid:EI,pr:EI,sf:EI,sid:EI,st:EI,v:EI,msd:EI,bs:MI,bsd:MI,cdn:MI,rtp:MI,bg:MI,pt:MI,ec:MI,e:MI},PI=SI;function AI(e,t){var i={};if(!e)return i;var n,a=Object.keys(e),r=t?(n=t,Object.keys(n).reduce((e,t)=>{var i;return null===(i=n[t])||void 0===i||i.forEach(i=>e[i]=t),e},{})):{};return a.reduce((t,i)=>{var n,a=TI[i]||r[i]||PI;return(null!==(n=t[a])&&void 0!==n?n:t[a]={})[i]=e[i],t},i)}var DI="event";var xI=e=>Math.round(e),CI=(e,t)=>Array.isArray(e)?e.map(e=>CI(e,t)):e instanceof aI&&"string"==typeof e.value?new aI(CI(e.value,t),e.params):(t.baseUrl&&(e=function(e,t){var i=new URL(e),n=new URL(t);if(i.origin!==n.origin)return e;for(var a=i.pathname.split("/").slice(1),r=n.pathname.split("/").slice(1,-1);a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")+i.search+i.hash}(e,t.baseUrl)),1===t.version?encodeURIComponent(e):e),II=e=>100*xI(e/100),LI={br:xI,d:xI,bl:II,dl:II,mtp:II,nor:(e,t)=>{var i=e;return t.version>=2&&(e instanceof aI&&"string"==typeof e.value?i=new aI([e]):"string"==typeof e&&(i=[e])),CI(i,t)},rtp:II,tb:xI},_I="request",RI="response",FI=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],WI=["e"],OI=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function $I(e){return OI.test(e)}var NI=["d","dl","nor","ot","rtp","su"];var jI=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"];var BI=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function zI(e){return BI.includes(e)||$I(e)}var UI={[RI]:function(e){return FI.includes(e)||NI.includes(e)||jI.includes(e)||$I(e)},[DI]:function(e){return FI.includes(e)||WI.includes(e)||$I(e)},[_I]:function(e){return FI.includes(e)||NI.includes(e)||$I(e)}};function HI(e,t={}){var i={};if(null==e||"object"!=typeof e)return i;var n=t.version||e.v||1,a=t.reportingMode||_I,r=1===n?zI:UI[a],o=Object.keys(e).filter(r),s=t.filter;"function"==typeof s&&(o=o.filter(s));var u=a===RI||a===DI;u&&!o.includes("ts")&&o.push("ts"),n>1&&!o.includes("v")&&o.push("v");var l=HM({},LI,t.formatters),d={version:n,reportingMode:a,baseUrl:t.baseUrl};return o.sort().forEach(t=>{var a=e[t],r=l[t];if("function"==typeof r&&(a=r(a,d)),"v"===t){if(1===n)return;a=n}"pr"==t&&1===a||(u&&"ts"===t&&!DM(a)&&(a=Date.now()),function(e){return"number"==typeof e?DM(e):null!=e&&""!==e&&!1!==e}(a)&&(function(e){return["ot","sf","st","e","sta"].includes(e)}(t)&&"string"==typeof a&&(a=new sI(a)),i[t]=a))}),i}function GI(e,t,i){return HM(e,function(e,t={}){var i={};if(!e)return i;var n=AI(HI(e,t),null==t?void 0:t.customHeaderMap);return Object.entries(n).reduce((e,[t,i])=>{var n=wI(i,{whitespace:!1});return n&&(e[t]=n),e},i)}(t,i))}function VI(e,t={}){if(!e)return"";var i=function(e,t={}){return e?wI(HI(e,t),{whitespace:!1}):""}(e,t);return encodeURIComponent(i)}var KI=/CMCD=[^&#]+/;function XI(e,t,i){var n=function(e,t={}){return e?`CMCD=${VI(e,t)}`:""}(t,i);if(!n)return e;if(KI.test(e))return e.replace(KI,n);var a=e.includes("?")?"&":"?";return`${e}${a}${n}`}var YI=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:iI.MANIFEST,su:!this.initialized})}catch(e){this.hls.logger.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,i=e.part,n=this.hls.levels[t.level],a=this.getObjectType(t),r={d:1e3*(i||t).duration,ot:a};a!==iI.VIDEO&&a!==iI.AUDIO&&a!=iI.MUXED||(r.br=n.bitrate/1e3,r.tb=this.getTopBandwidth(a)/1e3,r.bl=this.getBufferLength(a));var o=i?this.getNextPart(i):this.getNextFrag(t);null!=o&&o.url&&o.url!==t.url&&(r.nor=o.url),this.apply(e,r)}catch(e){this.hls.logger.warn("Could not generate segment CMCD data.",e)}},this.hls=t;var i=this.config=t.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.sessionId,this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())},[{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHED,this.onMediaDetached,this),e.on(_M.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHED,this.onMediaDetached,this),e.off(_M.BUFFER_CREATED,this.onBufferCreated,this)}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}},{key:"onMediaDetached",value:function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}},{key:"onBufferCreated",value:function(e,t){var i,n;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(n=t.tracks.video)?void 0:n.buffer}},{key:"createData",value:function(){var e;return{v:1,sf:nI.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}},{key:"apply",value:function(e,t={}){HM(t,this.createData());var i=t.ot===iI.INIT||t.ot===iI.VIDEO||t.ot===iI.MUXED;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);var n=this.includeKeys;n&&(t=Object.keys(t).reduce((e,i)=>(n.includes(i)&&(e[i]=t[i]),e),{}));var a={baseUrl:e.url};this.useHeaders?(e.headers||(e.headers={}),GI(e.headers,t,a)):e.url=XI(e.url,t,a)}},{key:"getNextFrag",value:function(e){var t,i=null==(t=this.hls.levels[e.level])?void 0:t.details;if(i){var n=e.sn-i.startSN;return i.fragments[n+1]}}},{key:"getNextPart",value:function(e){var t,i=e.index,n=e.fragment,a=null==(t=this.hls.levels[n.level])||null==(t=t.details)?void 0:t.partList;if(a)for(var r=n.sn,o=a.length-1;o>=0;o--){var s=a[o];if(s.index===i&&s.fragment.sn===r)return a[o+1]}}},{key:"getObjectType",value:function(e){var t=e.type;return"subtitle"===t?iI.TIMED_TEXT:"initSegment"===e.sn?iI.INIT:"audio"===t?iI.AUDIO:"main"===t?this.hls.audioTracks.length?iI.VIDEO:iI.MUXED:void 0}},{key:"getTopBandwidth",value:function(e){var t,i=0,n=this.hls;if(e===iI.AUDIO)t=n.audioTracks;else{var a=n.maxAutoLevel,r=a>-1?a+1:n.levels.length;t=n.levels.slice(0,r)}return t.forEach(e=>{e.bitrate>i&&(i=e.bitrate)}),i>0?i:NaN}},{key:"getBufferLength",value:function(e){var t=this.media,i=e===iI.AUDIO?this.audioBuffer:this.videoBuffer;return i&&t?1e3*DA.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len:NaN}},{key:"createPlaylistLoader",value:function(){var e=this.config.pLoader,t=this.applyPlaylistData,i=e||this.config.loader;return function(){return ne(function e(t){Q(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}},{key:"createFragmentLoader",value:function(){var e=this.config.fLoader,t=this.applyFragmentData,i=e||this.config.loader;return function(){return ne(function e(t){Q(this,e),this.loader=void 0,this.loader=new i(t)},[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}},{key:"destroy",value:function(){this.loader.destroy()}},{key:"abort",value:function(){this.loader.abort()}},{key:"load",value:function(e,i,n){t(e),this.loader.load(e,i,n)}}])}()}}])}(),qI=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["content-steering",t.logger])).hls=void 0,i.loader=null,i.uri=null,i.pathwayId=".",i._pathwayPriority=null,i.timeToLoad=300,i.reloadTimer=-1,i.updated=0,i.started=!1,i.enabled=!0,i.levels=null,i.audioTracks=null,i.subtitleTracks=null,i.penalizedPathways={},i.hls=t,i.registerListeners(),i}return ue(e,KM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_M.ERROR,this.onError,this))}},{key:"pathways",value:function(){return(this.levels||[]).reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])}},{key:"pathwayPriority",get:function(){return this._pathwayPriority},set:function(e){this.updatePathwayPriority(e)}},{key:"startLoad",value:function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}},{key:"stopLoad",value:function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}},{key:"clearTimeout",value:function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"removeLevel",value:function(e){var t=this.levels;t&&(this.levels=t.filter(t=>t!==e))}},{key:"onManifestLoading",value:function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}},{key:"onManifestLoaded",value:function(e,t){var i=t.contentSteering;null!==i&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}},{key:"onManifestParsed",value:function(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}},{key:"onError",value:function(e,t){var i=t.errorAction;if((null==i?void 0:i.action)===JP&&i.flags===tA){var n=this.levels,a=this._pathwayPriority,r=this.pathwayId;if(t.context){var o=t.context,s=o.groupId,u=o.pathwayId,l=o.type;s&&n?r=this.getPathwayForGroupId(s,l,r):u&&(r=u)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!a&&n&&(a=this.pathways()),a&&a.length>1&&(this.updatePathwayPriority(a),i.resolved=this.pathwayId!==r),t.details!==LM.BUFFER_APPEND_ERROR||t.fatal?i.resolved||this.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${r} levels: ${n?n.length:n} priorities: ${AP(a)} penalized: ${AP(this.penalizedPathways)}`):i.resolved=!0}}},{key:"filterParsedLevels",value:function(e){this.levels=e;var t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){var i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length&&this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t}},{key:"getLevelsForPathway",value:function(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}},{key:"updatePathwayPriority",value:function(e){var t;this._pathwayPriority=e;var i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(e=>{n-i[e]>3e5&&delete i[e]});for(var a=0;a<e.length;a++){var r=e[a];if(!(r in i)){if(r===this.pathwayId)return;var o=this.hls.nextLoadLevel,s=this.hls.levels[o];if((t=this.getLevelsForPathway(r)).length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,OD(t),this.hls.trigger(_M.LEVELS_UPDATED,{levels:t});var u=this.hls.levels[o];s&&u&&this.levels&&(u.attrs["STABLE-VARIANT-ID"]!==s.attrs["STABLE-VARIANT-ID"]&&u.bitrate!==s.bitrate&&this.log(`Unstable Pathways change from bitrate ${s.bitrate} to ${u.bitrate}`),this.hls.nextLoadLevel=o);break}}}}},{key:"getPathwayForGroupId",value:function(e,t,i){for(var n=this.getLevelsForPathway(i).concat(this.levels||[]),a=0;a<n.length;a++)if(t===WM&&n[a].hasAudioGroup(e)||t===OM&&n[a].hasSubtitleGroup(e))return n[a].pathwayId;return i}},{key:"clonePathways",value:function(e){var t=this.levels;if(t){var i={},n={};e.forEach(e=>{var a=e.ID,r=e["BASE-ID"],o=e["URI-REPLACEMENT"];if(!t.some(e=>e.pathwayId===a)){var s=this.getLevelsForPathway(r).map(e=>{var t=new WA(e.attrs);t["PATHWAY-ID"]=a;var r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(i[t.AUDIO]=r,t.AUDIO=r),s&&(n[t.SUBTITLES]=s,t.SUBTITLES=s);var u=QI(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new MP({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:u,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(var d=1;d<e.audioGroups.length;d++)l.addGroupId("audio",`${e.audioGroups[d]}_clone_${a}`);if(e.subtitleGroups)for(var h=1;h<e.subtitleGroups.length;h++)l.addGroupId("text",`${e.subtitleGroups[h]}_clone_${a}`);return l});t.push(...s),JI(this.audioTracks,i,o,a),JI(this.subtitleTracks,n,o,a)}})}}},{key:"loadSteeringManifest",value:function(e){var t,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{t=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==t.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);t.searchParams.set("_HLS_pathway",this.pathwayId),t.searchParams.set("_HLS_throughput",""+a)}var r={responseType:"json",url:t.href},o=i.steeringManifestLoadPolicy.default,s=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},l={onSuccess:(e,i,n,a)=>{this.log(`Loaded steering manifest: "${t}"`);var r=e.data;if(1===(null==r?void 0:r.VERSION)){this.updated=performance.now(),this.timeToLoad=r.TTL;var o=r["RELOAD-URI"],s=r["PATHWAY-CLONES"],u=r["PATHWAY-PRIORITY"];if(o)try{this.uri=new self.URL(o,t).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||n.url),s&&this.clonePathways(s);var l={steeringManifest:r,url:t.toString()};this.hls.trigger(_M.STEERING_MANIFEST_LOADED,l),u&&this.updatePathwayPriority(u)}else this.log(`Steering VERSION ${r.VERSION} not supported!`)},onError:(e,t,i,n)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);var a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{var r=this.loader;if("function"==typeof(null==r?void 0:r.getResponseHeader)){var o=r.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${t}`),this.loader.load(r,u,l)}},{key:"scheduleRefresh",value:function(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var t,i=null==(t=this.hls)?void 0:t.media;!i||i.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)},t)}}])}();function JI(e,t,i,n){e&&Object.keys(t).forEach(a=>{var r=e.filter(e=>e.groupId===a).map(e=>{var r=HM({},e);return r.details=void 0,r.attrs=new WA(r.attrs),r.url=r.attrs.URI=QI(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",i),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=n,r});e.push(...r)})}function QI(e,t,i,n){var a,r=n.HOST,o=n.PARAMS,s=n[i];t&&(a=null==s?void 0:s[t])&&(e=a);var u=new self.URL(e);return r&&!a&&(u.host=r),o&&Object.keys(o).sort().forEach(e=>{e&&u.searchParams.set(e,o[e])}),u.href}var ZI=function(){function e(t){var i;return Q(this,e),(i=J(this,e,["eme",t.logger])).hls=void 0,i.config=void 0,i.media=null,i.mediaResolved=void 0,i.keyFormatPromise=null,i.keySystemAccessPromises={},i._requestLicenseFailureCount=0,i.mediaKeySessions=[],i.keyIdToKeySessionPromise={},i.mediaKeys=null,i.setMediaKeysQueue=e.CDMCleanupPromise?[e.CDMCleanupPromise]:[],i.bannedKeyIds={},i.onMediaEncrypted=e=>{var t=e.initDataType,n=e.initData,a=`"${e.type}" event: init data type: "${t}"`;if(i.debug(a),null!==n){if(!i.keyFormatPromise){var r=Object.keys(i.keySystemAccessPromises);r.length||(r=nD(i.config));var o=r.map(iD).filter(e=>!!e);i.keyFormatPromise=i.getKeyFormatPromise(o)}i.keyFormatPromise.then(r=>{var o=tD(r);if("sinf"===t&&o===qA.FAIRPLAY){var s;try{var u=PT(new Uint8Array(n)),l=jT(GA(JSON.parse(u).sinf));if(!l)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");s=new Uint8Array(l.subarray(8,24))}catch(e){return void i.warn(`${a} Failed to parse sinf: ${e}`)}for(var d,h=nT(s),c=i,m=c.keyIdToKeySessionPromise,f=c.mediaKeySessions,v=m[h],p=function(){var e=f[g],a=e.decryptdata;if(!a.keyId)return 0;var r=nT(a.keyId);return BA(s,a.keyId)||-1!==a.uri.replace(/-/g,"").indexOf(h)?(v=m[r])?(a.pssh||(delete m[r],a.pssh=new Uint8Array(n),a.keyId=s,(v=m[h]=v.then(()=>i.generateRequestWithPreferredKeySession(e,t,n,"encrypted-event-key-match"))).catch(e=>i.handleError(e))),1):0:void 0},g=0;g<f.length&&(0===(d=p())||1!==d);g++);v||i.handleError(new Error(`Key ID ${h} not encountered in playlist. Key-system sessions ${f.length}.`))}else i.log(`Ignoring "${e.type}" event with init data type: "${t}" for selected key-system ${o}`)}).catch(e=>i.handleError(e))}},i.onWaitingForKey=e=>{i.log(`"${e.type}" event`)},i.hls=t,i.config=t.config,i.registerListeners(),i}return ue(e,KM),ne(e,[{key:"destroy",value:function(){this.onDestroying(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}},{key:"registerListeners",value:function(){this.hls.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_M.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_M.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(_M.DESTROYING,this.onDestroying,this)}},{key:"unregisterListeners",value:function(){this.hls.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_M.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_M.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(_M.DESTROYING,this.onDestroying,this)}},{key:"getLicenseServerUrl",value:function(e){var t=this.config,i=t.drmSystems,n=t.widevineLicenseUrl,a=null==i?void 0:i[e];return a?a.licenseUrl:e===qA.WIDEVINE&&n?n:void 0}},{key:"getLicenseServerUrlOrThrow",value:function(e){var t=this.getLicenseServerUrl(e);if(void 0===t)throw new Error(`no license server URL configured for key-system "${e}"`);return t}},{key:"getServerCertificateUrl",value:function(e){var t=this.config.drmSystems,i=null==t?void 0:t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}},{key:"attemptKeySystemAccess",value:function(e){var t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t,n=t.map(e=>e.audioCodec).filter(i),a=t.map(e=>e.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((t,i)=>{var r=e=>{var o=e.shift();this.getMediaKeysPromise(o,n,a).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?r(e):i(t instanceof iL?t:new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};r(e)})}},{key:"requestMediaKeySystemAccess",value:function(e,t){var i=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof i){var n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return null===rD&&"http:"===self.location.protocol&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}},{key:"getMediaKeysPromise",value:function(e,t,i){var n,a=function(e,t,i,n){var a;switch(e){case qA.FAIRPLAY:a=["cenc","sinf"];break;case qA.WIDEVINE:case qA.PLAYREADY:a=["cenc"];break;case qA.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,i,n){return[{initDataTypes:e,persistentState:n.persistentState||"optional",distinctiveIdentifier:n.distinctiveIdentifier||"optional",sessionTypes:n.sessionTypes||[n.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs=${e}`,robustness:n.audioRobustness||"",encryptionScheme:n.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs=${e}`,robustness:n.videoRobustness||"",encryptionScheme:n.videoEncryptionScheme||null}))}]}(a,t,i,n)}(e,t,i,this.config.drmSystemOptions||{}),r=this.keySystemAccessPromises[e],o=null==(n=r)?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${AP(a)}`),o=this.requestMediaKeySystemAccess(e,a);var s=r=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),o.then(t=>{this.log(`Access for key-system "${t.keySystem}" obtained`);var i=this.fetchServerCertificate(e);this.log(`Create media-keys for "${e}"`);var n=s.mediaKeys=t.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),s.hasMediaKeys=!0,i.then(i=>i?this.setMediaKeysServerCertificate(t,e,i):t)));return n.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),n})}return o.then(()=>r.mediaKeys)}},{key:"createMediaKeySessionContext",value:function({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${nT(e.keyId||[])} keyUri: ${e.uri}`);var n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}},{key:"renewKeySession",value:function(e){var t=e.decryptdata;if(t.pssh){var i=this.createMediaKeySessionContext(e),n=eL(t);this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,"cenc",t.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}},{key:"updateKeySession",value:function(e,t){var i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyId ${nT(e.decryptdata.keyId||[])}\n } (data length: ${t.byteLength})`),i.update(t)}},{key:"getSelectedKeySystemFormats",value:function(){return Object.keys(this.keySystemAccessPromises).map(e=>({keySystem:e,hasMediaKeys:this.keySystemAccessPromises[e].hasMediaKeys})).filter(({hasMediaKeys:e})=>!!e).map(({keySystem:e})=>iD(e)).filter(e=>!!e)}},{key:"getKeySystemAccess",value:function(e){return this.getKeySystemSelectionPromise(e).then(({keySystem:e,mediaKeys:t})=>this.attemptSetMediaKeys(e,t))}},{key:"selectKeySystem",value:function(e){return new Promise((t,i)=>{this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var n=iD(e);n?t(n):i(new Error(`Unable to find format for key-system "${e}"`))}).catch(i)})}},{key:"selectKeySystemFormat",value:function(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}},{key:"getKeyFormatPromise",value:function(e){var t=nD(this.config),i=e.map(tD).filter(e=>!!e&&-1!==t.indexOf(e));return this.selectKeySystem(i)}},{key:"getKeyStatus",value:function(e){for(var t=this.mediaKeySessions,i=0;i<t.length;i++){var n=tL(e,t[i]);if(n)return n}}},{key:"loadKey",value:function(e){var t=e.keyInfo.decryptdata,i=eL(t),n=this.bannedKeyIds[i];if(n||"internal-error"===this.getKeyStatus(t)){var a=nL(n||"internal-error",t);return this.handleError(a,e.frag),Promise.reject(a)}var r=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);var o=this.keyIdToKeySessionPromise[i];if(!o){var s=this.getKeySystemForKeyPromise(t).then(({keySystem:i,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(i,n).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:i,mediaKeys:n,decryptdata:t}))))).then(e=>{var i=t.pssh?t.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(e,"cenc",i,"playlist-key")});return s.catch(t=>this.handleError(t,e.frag)),this.keyIdToKeySessionPromise[i]=s,s}return o.catch(i=>{if(i instanceof iL){var n=VM({},i.data);"internal-error"===this.getKeyStatus(t)&&(n.decryptdata=t);var a=new iL(n,i.message);this.handleError(a,e.frag)}}),o}},{key:"throwIfDestroyed",value:function(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}},{key:"handleError",value:function(e,t){if(this.hls)if(e instanceof iL){t&&(e.data.frag=t);var i=e.data.decryptdata;this.error(`${e.message}${i?` (${nT(i.keyId||[])})`:""}`),this.hls.trigger(_M.ERROR,e.data)}else this.error(e.message),this.hls.trigger(_M.ERROR,{type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0})}},{key:"getKeySystemForKeyPromise",value:function(e){var t=eL(e),i=this.keyIdToKeySessionPromise[t];if(!i){var n=tD(e.keyFormat),a=n?[n]:nD(this.config);return this.attemptKeySystemAccess(a)}return i}},{key:"getKeySystemSelectionPromise",value:function(e){if(e.length||(e=nD(this.config)),0===e.length)throw new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${AP({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}},{key:"attemptSetMediaKeys",value:function(e,t){if(this.mediaResolved=void 0,this.mediaKeys===t)return Promise.resolve();var i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);var n=Promise.all(i).then(()=>this.media?this.media.setMediaKeys(t):new Promise((e,i)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return i(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=t,this.media.setMediaKeys(t).then(e).catch(i)}}));return this.mediaKeys=t,this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}},{key:"generateRequestWithPreferredKeySession",value:function(e,t,i,n){var a,r=null==(a=this.config.drmSystems)||null==(a=a[e.keySystem])?void 0:a.generateRequest;if(r)try{var o=r.call(this.hls,t,i,e);if(!o)throw new Error("Invalid response from configured generateRequest filter");t=o.initDataType,i=o.initData?o.initData:null,e.decryptdata.pssh=i?new Uint8Array(i):null}catch(e){if(this.warn(e.message),this.hls&&this.hls.config.debug)throw e}if(null===i)return this.log(`Skipping key-session request for "${n}" (no initData)`),Promise.resolve(e);var s=eL(e.decryptdata),u=e.decryptdata.uri;this.log(`Generating key-session request for "${n}" keyId: ${s} URI: ${u} (init data type: ${t} length: ${i.byteLength})`);var l=new cx,d=e._onmessage=t=>{var i=e.mediaKeysSession;if(i){var n=t.messageType,a=t.message;this.log(`"${n}" message event for session "${i.sessionId}" message size: ${a.byteLength}`),"license-request"===n||"license-renewal"===n?this.renewLicense(e,a).catch(e=>{l.eventNames().length?l.emit("error",e):this.handleError(e)}):"license-release"===n?e.keySystem===qA.FAIRPLAY&&this.updateKeySession(e,VA("acknowledged")).then(()=>this.removeSession(e)).catch(e=>this.handleError(e)):this.warn(`unhandled media key message type "${n}"`)}else l.emit("error",new Error("invalid state"))},h=(e,t)=>{var i;t.keyStatus=e,e.startsWith("usable")?l.emit("resolved"):"internal-error"===e||"output-restricted"===e||"output-downscaled"===e?i=nL(e,t.decryptdata):"expired"===e?i=new Error(`key expired (keyId: ${s})`):"released"===e?i=new Error("key released"):"status-pending"===e||this.warn(`unhandled key status change "${e}" (keyId: ${s})`),i&&(l.eventNames().length?l.emit("error",i):this.handleError(i))},c=e._onkeystatuseschange=t=>{if(e.mediaKeysSession){var i=this.getKeyStatuses(e);if(Object.keys(i).some(e=>"status-pending"!==i[e])){if("expired"===i[s])return this.log(`Expired key ${AP(i)} in key-session "${e.mediaKeysSession.sessionId}"`),void this.renewKeySession(e);var n=i[s];if(n)h(n,e);else{var a;e.keyStatusTimeouts||(e.keyStatusTimeouts={}),(a=e.keyStatusTimeouts)[s]||(a[s]=self.setTimeout(()=>{if(e.mediaKeysSession&&this.mediaKeys){var t=this.getKeyStatus(e.decryptdata);if(t&&"status-pending"!==t)return this.log(`No status for keyId ${s} in key-session "${e.mediaKeysSession.sessionId}". Using session key-status ${t} from other session.`),h(t,e);this.log(`key status for ${s} in key-session "${e.mediaKeysSession.sessionId}" timed out after 1000ms`),h(n="internal-error",e)}},1e3)),this.log(`No status for keyId ${s} (${AP(i)}).`)}}}else l.emit("error",new Error("invalid state"))};GD(e.mediaKeysSession,"message",d),GD(e.mediaKeysSession,"keystatuseschange",c);var m=new Promise((e,t)=>{l.on("error",t),l.on("resolved",e)});return e.mediaKeysSession.generateRequest(t,i).then(()=>{this.log(`Request generated for key-session "${e.mediaKeysSession.sessionId}" keyId: ${s} URI: ${u}`)}).catch(t=>{throw new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_NO_SESSION,error:t,decryptdata:e.decryptdata,fatal:!1},`Error generating key-session request: ${t}`)}).then(()=>m).catch(t=>(l.removeAllListeners(),this.removeSession(e).then(()=>{throw t}))).then(()=>(l.removeAllListeners(),e))}},{key:"getKeyStatuses",value:function(e){var t={};return e.mediaKeysSession.keyStatuses.forEach((i,n)=>{if("string"==typeof n&&"object"==typeof i){var a=n;n=i,i=a}var r="buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n);if(e.keySystem===qA.PLAYREADY&&16===r.length){var o=nT(r);t[o]=i,KA(r)}var s=nT(r);"internal-error"===i&&(this.bannedKeyIds[s]=i),this.log(`key status change "${i}" for keyStatuses keyId: ${s} key-session "${e.mediaKeysSession.sessionId}"`),t[s]=i}),t}},{key:"fetchServerCertificate",value:function(e){var t=this.config,i=new(0,t.loader)(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,r)=>{var o={responseType:"arraybuffer",url:n},s=t.certLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{a(e.data)},onError:(t,i,a,s)=>{r(new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:VM({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${n}). Status: ${t.code} (${t.text})`))},onTimeout:(t,i,a)=>{r(new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(e,t,i)=>{r(new Error("aborted"))}};i.load(o,u,l)})):Promise.resolve()}},{key:"setMediaKeysServerCertificate",value:function(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${i.byteLength}) on "${t}"`),n(e)}).catch(e=>{a(new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}},{key:"renewLicense",value:function(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(t=>{throw new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:e.decryptdata,error:t,fatal:!1},t.message)}))}},{key:"unpackPlayReadyKeyMessage",value:function(e,t){var i=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!i.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;var n=(new DOMParser).parseFromString(i,"application/xml"),a=n.querySelectorAll("HttpHeader");if(a.length>0)for(var r,o=0,s=a.length;o<s;o++){var u,l,d=null==(u=(r=a[o]).querySelector("name"))?void 0:u.textContent,h=null==(l=r.querySelector("value"))?void 0:l.textContent;d&&h&&e.setRequestHeader(d,h)}var c=n.querySelector("Challenge"),m=null==c?void 0:c.textContent;if(!m)throw new Error("Cannot find <Challenge> in key message");return VA(atob(m))}},{key:"setupLicenseXHR",value:function(e,t,i,n){var a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(r=>{if(!i.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(i=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:i||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}},{key:"requestLicense",value:function(e,t){var i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{var r=this.getLicenseServerUrlOrThrow(e.keySystem);this.log(`Sending license request to URL: ${r}`);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;var s=o.response;this.log(`License received ${s instanceof ArrayBuffer?s.byteLength:s}`);var u=this.config.licenseResponseCallback;if(u)try{s=u.call(this.hls,o,r,e)}catch(e){this.error(e)}n(s)}else{var l=i.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new iL({type:IM.KEY_SYSTEM_ERROR,details:LM.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:e.decryptdata,fatal:!0,networkDetails:o,response:{url:r,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${r}). Status: ${o.status} (${o.statusText})`));else{var h=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${h} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then(({xhr:t,licenseChallenge:i})=>{e.keySystem==qA.PLAYREADY&&(i=this.unpackPlayReadyKeyMessage(t,i)),t.send(i)}).catch(a)})}},{key:"onDestroying",value:function(){this.unregisterListeners(),this._clear()}},{key:"onMediaAttached",value:function(e,t){if(this.config.emeEnabled){var i=t.media;this.media=i,GD(i,"encrypted",this.onMediaEncrypted),GD(i,"waitingforkey",this.onWaitingForKey);var n=this.mediaResolved;n?n():this.mediaKeys=i.mediaKeys}}},{key:"onMediaDetached",value:function(){var e=this.media;e&&(VD(e,"encrypted",this.onMediaEncrypted),VD(e,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}},{key:"_clear",value:function(){var t;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};var i=this.mediaResolved;if(i&&i(),this.mediaKeys||this.mediaKeySessions.length){var n=this.media,a=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,uD.clearKeyUriToKeyIdMap();var r=a.length;e.CDMCleanupPromise=Promise.all(a.map(e=>this.removeSession(e)).concat((null==n||null==(t=n.setMediaKeys(null))?void 0:t.catch(e=>{this.log(`Could not clear media keys: ${e}`),this.hls&&this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${e}`)})}))||Promise.resolve())).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}`),this.hls&&this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${e}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}}},{key:"onManifestLoading",value:function(){this._clear()}},{key:"onManifestLoaded",value:function(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){var i=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}},{key:"removeSession",value:function(e){var t=e.mediaKeysSession,i=e.licenseXhr,n=e.decryptdata;if(t){this.log(`Remove licenses and keys and close session "${t.sessionId}" keyId: ${nT((null==n?void 0:n.keyId)||[])}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;var a=this.mediaKeySessions.indexOf(e);a>-1&&this.mediaKeySessions.splice(a,1);var r=e.keyStatusTimeouts;r&&Object.keys(r).forEach(e=>self.clearTimeout(r[e]));var o=function(e){var t;return!(!e||"persistent-license"!==e.sessionType&&(null==(t=e.sessionTypes)||!t.some(e=>"persistent-license"===e)))}(this.config.drmSystemOptions)?new Promise((e,i)=>{self.setTimeout(()=>i(new Error("MediaKeySession.remove() timeout")),8e3),t.remove().then(e).catch(i)}):Promise.resolve();return o.catch(e=>{this.log(`Could not remove session: ${e}`),this.hls&&this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${e}`)})}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`),this.hls&&this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${e}`)})})}return Promise.resolve()}}])}();function eL(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return nT(e.keyId)}function tL(e,t){return e.keyId&&t.mediaKeysSession.keyStatuses.has(e.keyId)?t.mediaKeysSession.keyStatuses.get(e.keyId):e.matches(t.decryptdata)?t.keyStatus:void 0}ZI.CDMCleanupPromise=void 0;var iL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[i])).data=void 0,t.error||(t.error=new Error(i)),n.data=t,t.err=t.error,n}return ue(e,ye(Error)),ne(e)}();function nL(e,t){var i="output-restricted"===e,n=i?LM.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:LM.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new iL({type:IM.KEY_SYSTEM_ERROR,details:n,fatal:!1,decryptdata:t},i?"HDCP level output restricted":`key status changed to "${e}"`)}var aL=function(){return ne(function e(t){Q(this,e),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=t,this.registerListeners()},[{key:"setStreamController",value:function(e){this.streamController=e}},{key:"registerListeners",value:function(){this.hls.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"unregisterListeners",value:function(){this.hls.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this)}},{key:"destroy",value:function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}},{key:"onMediaAttaching",value:function(e,t){var i=this.hls.config;if(i.capLevelOnFPSDrop){var n=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=n,n&&"function"==typeof n.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}},{key:"onMediaDetaching",value:function(){this.media=null}},{key:"checkFPS",value:function(e,t,i){var n=performance.now();if(t){if(this.lastTime){var a=n-this.lastTime,r=i-this.lastDroppedFrames,o=t-this.lastDecodedFrames,s=1e3*r/a,u=this.hls;if(u.trigger(_M.FPS_DROP,{currentDropped:r,currentDecoded:o,totalDroppedFrames:i}),s>0&&r>u.config.fpsDroppedMonitoringThreshold*o){var l=u.currentLevel;u.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+l),l>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=l)&&(l-=1,u.trigger(_M.FPS_DROP_LEVEL_CAPPING,{level:l,droppedLevel:u.currentLevel}),u.autoLevelCapping=l,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}},{key:"checkFPSInterval",value:function(){var e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){var t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}])}();function rL(e,t){var i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function oL(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){ZM.debug(`[texttrack-utils]: ${i}`);try{var n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){ZM.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===i&&(e.mode=i)}function sL(e,t){var i=e.mode;if("disabled"===i&&(e.mode="hidden"),e.cues)for(var n=e.cues.length;n--;)t&&e.cues[n].removeEventListener("enter",t),e.removeCue(e.cues[n]);"disabled"===i&&(e.mode=i)}function uL(e,t,i,n){var a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0)for(var r=function(e,t,i){var n=[],a=function(e,t){if(t<=e[0].startTime)return 0;var i=e.length-1;if(t>e[i].endTime)return-1;var n,a=0,r=i;for(;a<=r;)if(t<e[n=Math.floor((r+a)/2)].startTime)r=n-1;else{if(!(t>e[n].startTime&&a<i))return n;a=n+1}return e[a].startTime-t<t-e[r].startTime?a:r}(e,t);if(a>-1)for(var r=a,o=e.length;r<o;r++){var s=e[r];if(s.startTime>=t&&s.endTime<=i)n.push(s);else if(s.startTime>i)return n}return n}(e.cues,t,i),o=0;o<r.length;o++)n&&!n(r[o])||e.removeCue(r[o]);"disabled"===a&&(e.mode=a)}function lL(e){for(var t=[],i=0;i<e.length;i++){var n=e[i];"subtitles"!==n.kind&&"captions"!==n.kind||!n.label||t.push(e[i])}return t}var dL=function(){function e(t){var i;return Q(this,e),(i=J(this,e,[t,"subtitle-track-controller"])).media=null,i.tracks=[],i.groupIds=null,i.tracksInGroup=[],i.trackId=-1,i.currentTrack=null,i.selectDefaultTrack=!0,i.queuedDefaultTrack=-1,i.useTextTrackPolling=!1,i.subtitlePollingInterval=-1,i._subtitleDisplay=!0,i.asyncPollTrackChange=()=>i.pollTrackChange(0),i.onTextTracksChanged=()=>{if(i.useTextTrackPolling||self.clearInterval(i.subtitlePollingInterval),i.media&&i.hls.config.renderTextTracksNatively){for(var e=null,t=lL(i.media.textTracks),n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}var a=i.findTrackForTextTrack(e);i.subtitleTrack!==a&&i.setSubtitleTrack(a)}},i.registerListeners(),i}return ue(e,UC),ne(e,[{key:"destroy",value:function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,pe(e,"destroy",this)([])}},{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_M.LEVEL_LOADING,this.onLevelLoading,this),e.on(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(_M.ERROR,this.onError,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_M.LEVEL_LOADING,this.onLevelLoading,this),e.off(_M.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(_M.ERROR,this.onError,this)}},{key:"onMediaAttached",value:function(e,t){this.media=t.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))}},{key:"pollTrackChange",value:function(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}},{key:"onMediaDetaching",value:function(e,t){var i=this.media;if(i){var n=!!t.transferMedia;if(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||i.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,!n)lL(i.textTracks).forEach(e=>{sL(e)})}}},{key:"onManifestLoading",value:function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}},{key:"onManifestParsed",value:function(e,t){this.tracks=t.subtitleTracks}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i=t.id,n=t.groupId,a=t.details,r=this.tracksInGroup[i];if(r&&r.groupId===n){var o=r.details;r.details=t.details,this.log(`Subtitle track ${i} "${r.name}" lang:${r.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,o)}else this.warn(`Subtitle track with id:${i} and group:${n} not found in active group ${null==r?void 0:r.groupId}`)}},{key:"onLevelLoading",value:function(e,t){this.switchLevel(t.level)}},{key:"onLevelSwitching",value:function(e,t){this.switchLevel(t.level)}},{key:"switchLevel",value:function(e){var t=this.hls.levels[e];if(t){var i=t.subtitleGroups||null,n=this.groupIds,a=this.currentTrack;if(!i||(null==n?void 0:n.length)!==(null==i?void 0:i.length)||null!=i&&i.some(e=>-1===(null==n?void 0:n.indexOf(e)))){this.groupIds=i,this.trackId=-1,this.currentTrack=null;var r=this.tracks.filter(e=>!i||-1!==i.indexOf(e.groupId));if(r.length)this.selectDefaultTrack&&!r.some(e=>e.default)&&(this.selectDefaultTrack=!1),r.forEach((e,t)=>{e.id=t});else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=r;var o=this.hls.config.subtitlePreference;if(!a&&o){this.selectDefaultTrack=!1;var s=IP(o,r);if(s>-1)a=r[s];else{var u=IP(o,this.tracks);a=this.tracks[u]}}var l=this.findTrackId(a);-1===l&&a&&(l=this.findTrackId(null));var d={subtitleTracks:r};this.log(`Updating subtitle tracks, ${r.length} track(s) found in "${null==i?void 0:i.join(",")}" group-id`),this.hls.trigger(_M.SUBTITLE_TRACKS_UPDATED,d),-1!==l&&-1===this.trackId&&this.setSubtitleTrack(l)}}}},{key:"findTrackId",value:function(e){for(var t=this.tracksInGroup,i=this.selectDefaultTrack,n=0;n<t.length;n++){var a=t[n];if((!i||a.default)&&(i||e)&&(!e||LP(a,e)))return n}if(e){for(var r=0;r<t.length;r++){var o=t[r];if(GC(e.attrs,o.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(var s=0;s<t.length;s++){var u=t[s];if(GC(e.attrs,u.attrs,["LANGUAGE"]))return s}}return-1}},{key:"findTrackForTextTrack",value:function(e){if(e)for(var t=this.tracksInGroup,i=0;i<t.length;i++){if(VC(t[i],e))return i}return-1}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&(t.context.type!==OM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}},{key:"setSubtitleOption",value:function(e){if(this.hls.config.subtitlePreference=e,e){if(-1===e.id)return this.setSubtitleTrack(-1),null;var t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){var i=this.currentTrack;if(i&&LP(e,i))return i;var n=IP(e,this.tracksInGroup);if(n>-1){var a=this.tracksInGroup[n];return this.setSubtitleTrack(n),a}if(i)return null;var r=IP(e,t);if(r>-1)return t[r]}}return null}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=t.id,a=t.groupId,r=this.getUrlWithDirectives(t.url,i),o=t.details,s=null==o?void 0:o.age;this.log(`Loading subtitle ${n} "${t.name}" lang:${t.lang} group:${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${r}`),this.hls.trigger(_M.SUBTITLE_TRACK_LOADING,{url:r,id:n,groupId:a,deliveryDirectives:i||null,track:t})}},{key:"toggleTrackModes",value:function(){var e=this.media;if(e){var t,i=lL(e.textTracks),n=this.currentTrack;if(n&&((t=i.filter(e=>VC(n,e))[0])||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(i).forEach(e=>{"disabled"!==e.mode&&e!==t&&(e.mode="disabled")}),t){var a=this.subtitleDisplay?"showing":"hidden";t.mode!==a&&(t.mode=a)}}}},{key:"setSubtitleTrack",value:function(e){var t=this.tracksInGroup;if(this.media)if(e<-1||e>=t.length||!DM(e))this.warn(`Invalid subtitle track id: ${e}`);else{this.selectDefaultTrack=!1;var i=this.currentTrack,n=t[e]||null;if(this.trackId=e,this.currentTrack=n,this.toggleTrackModes(),n){var a=!!n.details&&!n.details.live;if(e!==this.trackId||n!==i||!a){this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:""));var r=n.id,o=n.groupId,s=void 0===o?"":o,u=n.name,l=n.type,d=n.url;this.hls.trigger(_M.SUBTITLE_TRACK_SWITCH,{id:r,groupId:s,name:u,type:l,url:d});var h=this.switchParams(n.url,null==i?void 0:i.details,n.details);this.loadPlaylist(h)}}else this.hls.trigger(_M.SUBTITLE_TRACK_SWITCH,{id:e})}else this.queuedDefaultTrack=e}}])}();function hL(e){for(var t=5381,i=e.length;i;)t=33*t^e.charCodeAt(--i);return(t>>>0).toString()}var cL=.025,mL=function(e){return e[e.Point=0]="Point",e[e.Range=1]="Range",e}({});function fL(e,t,i){return`${e.identifier}-${i+1}-${hL(t)}`}var vL=function(){return ne(function e(t,i){Q(this,e),this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=i,this.dateRange=t,this.setDateRange(t)},[{key:"setDateRange",value:function(e){this.dateRange=e,this.resumeOffset=e.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=e.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=e.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=e.attr.enumeratedStringList("X-SNAP",this.snapOptions)}},{key:"reset",value:function(){var e;this.appendInPlaceStarted=!1,null==(e=this.assetListLoader)||e.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}},{key:"isAssetPastPlayoutLimit",value:function(e){var t;if(e>0&&e>=this.assetList.length)return!0;var i=this.playoutLimit;return!(e<=0||isNaN(i))&&(0===i||((null==(t=this.assetList[e])?void 0:t.startOffset)||0)>i)}},{key:"findAssetIndex",value:function(e){return this.assetList.indexOf(e)}},{key:"identifier",get:function(){return this.dateRange.id}},{key:"startDate",get:function(){return this.dateRange.startDate}},{key:"startTime",get:function(){var e=this.dateRange.startTime;if(this.snapOptions.out){var t=this.dateRange.tagAnchor;if(t)return pL(e,t)}return e}},{key:"startOffset",get:function(){return this.cue.pre?0:this.startTime}},{key:"startIsAligned",get:function(){if(0===this.startTime||this.snapOptions.out)return!0;var e=this.dateRange.tagAnchor;if(e){var t=this.dateRange.startTime;return t-pL(t,e)<.1}return!1}},{key:"resumptionOffset",get:function(){var e=this.resumeOffset,t=DM(e)?e:this.duration;return this.cumulativeDuration+t}},{key:"resumeTime",get:function(){var e=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){var t=this.resumeAnchor;if(t)return pL(e,t)}return e}},{key:"appendInPlace",get:function(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<cL))},set:function(e){this.appendInPlaceStarted?this.resetOnResume=!e:this.appendInPlaceDisabled=!e}},{key:"timelineStart",get:function(){return null!==this._timelineStart?this._timelineStart:this.startTime},set:function(e){this._timelineStart=e}},{key:"duration",get:function(){var e,t=this.playoutLimit;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e},set:function(e){this._duration=e}},{key:"cue",get:function(){return this.dateRange.cue}},{key:"timelineOccupancy",get:function(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?mL.Range:mL.Point}},{key:"supplementsPrimary",get:function(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}},{key:"contentMayVary",get:function(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}},{key:"assetUrl",get:function(){return this.dateRange.attr["X-ASSET-URI"]}},{key:"assetListUrl",get:function(){return this.dateRange.attr["X-ASSET-LIST"]}},{key:"baseUrl",get:function(){return this.base.url}},{key:"assetListLoaded",get:function(){return this.assetList.length>0||null!==this.assetListResponse}},{key:"toString",value:function(){return`["${(e=this).identifier}" ${e.cue.pre?"<pre>":e.cue.post?"<post>":""}${e.timelineStart.toFixed(2)}-${e.resumeTime.toFixed(2)}]`;var e}}])}();function pL(e,t){return e-t.start<t.duration/2&&!(Math.abs(e-(t.start+t.duration))<cL)?t.start:t.start+t.duration}function gL(e,t,i){var n=new self.URL(e,i);return"data:"!==n.protocol&&n.searchParams.set("_HLS_primary_id",t),n}function yL(e,t){for(;null!=(i=e.assetList[++t])&&i.error;)var i;return t}function bL(e){var t=e.timelineStart,i=e.duration||0;return`["${e.identifier}" ${t.toFixed(2)}-${(t+i).toFixed(2)}]`}var wL=function(){return ne(function e(t,i,n,a){Q(this,e),this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(_M.PLAYOUT_LIMIT_REACHED,{})};var r=this.hls=new t(i);this.interstitial=n,this.assetItem=a;var o=()=>{this.hasDetails=!0};r.once(_M.LEVEL_LOADED,o),r.once(_M.AUDIO_TRACK_LOADED,o),r.once(_M.SUBTITLE_TRACK_LOADED,o),r.on(_M.MEDIA_ATTACHING,(e,{media:t})=>{this.removeMediaListeners(),this.mediaAttached=t,this.interstitial.playoutLimit&&(t.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(_M.BUFFER_APPENDED,()=>{var e=this.bufferedEnd;this.reachedPlayout(e)&&(this._bufferedEosTime=e,r.trigger(_M.BUFFERED_TO_END,void 0))}))})},[{key:"appendInPlace",get:function(){return this.interstitial.appendInPlace}},{key:"loadSource",value:function(){var e=this.hls;if(e)if(e.url)e.levels.length&&!e.started&&e.startLoad(-1,!0);else{var t=this.assetItem.uri;try{t=gL(t,e.config.primarySessionId||"").href}catch(e){}e.loadSource(t)}}},{key:"bufferedInPlaceToEnd",value:function(e){var t;if(!this.appendInPlace)return!1;if(null!=(t=this.hls)&&t.bufferedToEnd)return!0;if(!e)return!1;var i=Math.min(this._bufferedEosTime||1/0,this.duration),n=this.timelineOffset,a=DA.bufferInfo(e,n,0);return this.getAssetTime(a.end)>=i-.02}},{key:"reachedPlayout",value:function(e){var t=this.interstitial.playoutLimit;return this.startOffset+e>=t}},{key:"destroyed",get:function(){var e;return!(null!=(e=this.hls)&&e.userConfig)}},{key:"assetId",get:function(){return this.assetItem.identifier}},{key:"interstitialId",get:function(){return this.assetItem.parentIdentifier}},{key:"media",get:function(){var e;return(null==(e=this.hls)?void 0:e.media)||null}},{key:"bufferedEnd",get:function(){var e=this.media||this.mediaAttached;if(!e)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;var t=DA.bufferInfo(e,e.currentTime,.001);return this.getAssetTime(t.end)}},{key:"currentTime",get:function(){var e=this.media||this.mediaAttached;return e?this.getAssetTime(e.currentTime):this._currentTime||0}},{key:"duration",get:function(){var e=this.assetItem.duration;if(!e)return 0;var t=this.interstitial.playoutLimit;if(t){var i=t-this.startOffset;if(i>0&&i<e)return i}return e}},{key:"remaining",get:function(){var e=this.duration;return e?Math.max(0,e-this.currentTime):0}},{key:"startOffset",get:function(){return this.assetItem.startOffset}},{key:"timelineOffset",get:function(){var e;return(null==(e=this.hls)?void 0:e.config.timelineOffset)||0},set:function(e){var t=this.timelineOffset;if(e!==t){var i=e-t;if(Math.abs(i)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=e}}}},{key:"getAssetTime",value:function(e){var t=this.timelineOffset,i=this.duration;return Math.min(Math.max(0,e-t),i)}},{key:"removeMediaListeners",value:function(){var e=this.mediaAttached;e&&(this._currentTime=e.currentTime,this.bufferSnapShot(),e.removeEventListener("timeupdate",this.checkPlayout))}},{key:"bufferSnapShot",value:function(){var e;this.mediaAttached&&(null!=(e=this.hls)&&e.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd))}},{key:"destroy",value:function(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}},{key:"attachMedia",value:function(e){var t;this.loadSource(),null==(t=this.hls)||t.attachMedia(e)}},{key:"detachMedia",value:function(){var e;this.removeMediaListeners(),this.mediaAttached=null,null==(e=this.hls)||e.detachMedia()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.hls)||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.hls)||e.pauseBuffering()}},{key:"transferMedia",value:function(){var e;return this.bufferSnapShot(),(null==(e=this.hls)?void 0:e.transferMedia())||null}},{key:"resetDetails",value:function(){var e=this.hls;if(e&&this.hasDetails){e.stopLoad();var t=e=>delete e.details;e.levels.forEach(t),e.allAudioTracks.forEach(t),e.allSubtitleTracks.forEach(t),this.hasDetails=!1}}},{key:"on",value:function(e,t,i){var n;null==(n=this.hls)||n.on(e,t)}},{key:"once",value:function(e,t,i){var n;null==(n=this.hls)||n.once(e,t)}},{key:"off",value:function(e,t,i){var n;null==(n=this.hls)||n.off(e,t)}},{key:"toString",value:function(){var e;return`HlsAssetPlayer: ${bL(this.assetItem)} ${null==(e=this.hls)?void 0:e.sessionId} ${this.appendInPlace?"append-in-place":""}`}}])}(),kL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["interstitials-sched",i])).onScheduleUpdate=void 0,n.eventMap={},n.events=null,n.items=null,n.durations={primary:0,playout:0,integrated:0},n.onScheduleUpdate=t,n}return ue(e,KM),ne(e,[{key:"destroy",value:function(){this.reset(),this.onScheduleUpdate=null}},{key:"reset",value:function(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(e=>e.reset()),this.events=this.items=null}},{key:"resetErrorsInRange",value:function(e,t){return this.events?this.events.reduce((i,n)=>e<=n.startOffset&&t>n.startOffset?(delete n.error,i+1):i,0):0}},{key:"duration",get:function(){var e=this.items;return e?e[e.length-1].end:0}},{key:"length",get:function(){return this.items?this.items.length:0}},{key:"getEvent",value:function(e){return e&&this.eventMap[e]||null}},{key:"hasEvent",value:function(e){return e in this.eventMap}},{key:"findItemIndex",value:function(e,t){if(e.event)return this.findEventIndex(e.event.identifier);var i=-1;e.nextEvent?i=this.findEventIndex(e.nextEvent.identifier)-1:e.previousEvent&&(i=this.findEventIndex(e.previousEvent.identifier)+1);var n=this.items;if(n)for(n[i]||(void 0===t&&(t=e.start),i=this.findItemIndexAtTime(t));i>=0&&null!=(a=n[i])&&a.event;){var a;i--}return i}},{key:"findItemIndexAtTime",value:function(e,t){var i=this.items;if(i)for(var n=0;n<i.length;n++){var a=i[n];if(t&&"primary"!==t&&(a=a[t]),e===a.start||e>a.start&&e<a.end)return n}return-1}},{key:"findJumpRestrictedIndex",value:function(e,t){var i=this.items;if(i)for(var n=e;n<=t&&i[n];n++){var a=i[n].event;if(null!=a&&a.restrictions.jump&&!a.appendInPlace)return n}return-1}},{key:"findEventIndex",value:function(e){var t=this.items;if(t)for(var i=t.length;i--;){var n;if((null==(n=t[i].event)?void 0:n.identifier)===e)return i}return-1}},{key:"findAssetIndex",value:function(e,t){var i=e.assetList,n=i.length;if(n>1)for(var a=0;a<n;a++){var r=i[a];if(!r.error){var o=r.timelineStart;if(t===o||t>o&&(t<o+(r.duration||0)||a===n-1))return a}}return 0}},{key:"assetIdAtEnd",get:function(){var e,t=null==(e=this.items)||null==(e=e[this.length-1])?void 0:e.event;if(t){var i=t.assetList,n=i[i.length-1];if(n)return n.identifier}return null}},{key:"parseInterstitialDateRanges",value:function(e,t){var i=e.main.details,n=i.dateRanges,a=this.events,r=this.parseDateRanges(n,{url:i.url},t),o=Object.keys(n),s=a?a.filter(e=>!o.includes(e.identifier)):[];r.length&&r.sort((e,t)=>{var i=e.cue.pre,n=e.cue.post,a=t.cue.pre,r=t.cue.post;if(i&&!a)return-1;if(a&&!i)return 1;if(n&&!r)return 1;if(r&&!n)return-1;if(!(i||a||n||r)){var o=e.startTime,s=t.startTime;if(o!==s)return o-s}return e.dateRange.tagOrder-t.dateRange.tagOrder}),this.events=r,s.forEach(e=>{this.removeEvent(e)}),this.updateSchedule(e,s)}},{key:"updateSchedule",value:function(e,t=[],i=!1){var n=this.events||[];if(n.length||t.length||this.length<2){var a=this.items,r=this.parseSchedule(n,e),o=i||t.length||(null==a?void 0:a.length)!==r.length||r.some((e,t)=>Math.abs(e.playout.start-a[t].playout.start)>.005||Math.abs(e.playout.end-a[t].playout.end)>.005);o&&(this.items=r,this.onScheduleUpdate(t,a))}}},{key:"parseDateRanges",value:function(e,t,i){for(var n=[],a=Object.keys(e),r=0;r<a.length;r++){var o=a[r],s=e[o];if(s.isInterstitial){var u=this.eventMap[o];u?u.setDateRange(s):(u=new vL(s,t),this.eventMap[o]=u,!1===i&&(u.appendInPlace=i)),n.push(u)}}return n}},{key:"parseSchedule",value:function(e,t){var i=[],n=t.main.details,a=n.live?1/0:n.edge,r=0;if((e=e.filter(e=>!(e.error||e.cue.once&&e.hasPlayed))).length){this.resolveOffsets(e,t);var o=0,s=0;if(e.forEach((t,n)=>{var u=t.cue.pre,l=t.cue.post,d=e[n-1]||null,h=t.appendInPlace,c=l?a:t.startOffset,m=t.duration,f=t.timelineOccupancy===mL.Range?m:0,v=t.resumptionOffset,p=(null==d?void 0:d.startTime)===c,g=c+t.cumulativeDuration,y=h?g+m:c+v;if(u||!l&&c<=0){var b=s;s+=f,t.timelineStart=g;var w=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:w,end:r},integrated:{start:b,end:s}})}else{if(!(c<=a))return;if(!p){var k=c-o;if(k>.033){var S=o,E=s;s+=k;var M=r;r+=k;var T={previousEvent:e[n-1]||null,nextEvent:t,start:S,end:S+k,playout:{start:M,end:r},integrated:{start:E,end:s}};i.push(T)}else k>0&&d&&(d.cumulativeDuration+=k,i[i.length-1].end=c)}l&&(y=g),t.timelineStart=g;var P=s;s+=f;var A=r;r+=m,i.push({event:t,start:g,end:y,playout:{start:A,end:r},integrated:{start:P,end:s}})}var D=t.resumeTime;o=l||D>a?a:D}),o<a){var u,l=o,d=s,h=a-o;s+=h;var c=r;r+=h,i.push({previousEvent:(null==(u=i[i.length-1])?void 0:u.event)||null,nextEvent:null,start:o,end:l+h,playout:{start:c,end:r},integrated:{start:d,end:s}})}this.setDurations(a,r,s)}else{i.push({previousEvent:null,nextEvent:null,start:0,end:a,playout:{start:0,end:a},integrated:{start:0,end:a}}),this.setDurations(a,a,a)}return i}},{key:"setDurations",value:function(e,t,i){this.durations={primary:e,playout:t,integrated:i}}},{key:"resolveOffsets",value:function(e,t){var i=t.main.details,n=i.live?1/0:i.edge,a=0,r=-1;e.forEach((o,s)=>{var u=o.cue.pre,l=o.cue.post,d=u?0:l?n:o.startTime;(this.updateAssetDurations(o),r===d?o.cumulativeDuration=a:(a=0,r=d),!l&&o.snapOptions.in&&(o.resumeAnchor=$P(null,i.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted)&&(this.primaryCanResumeInPlaceAt(o,t)||(o.appendInPlace=!1));!o.appendInPlace&&s+1<e.length&&(e[s+1].startTime-e[s].resumeTime<.033&&(e[s+1].appendInPlace=!1,e[s+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`)));var h=DM(o.resumeOffset)?o.resumeOffset:o.duration;a+=h})}},{key:"primaryCanResumeInPlaceAt",value:function(e,t){var i=e.resumeTime,n=e.startTime+e.resumptionOffset;return Math.abs(i-n)>cL?(this.log(`"${e.identifier}" resumption ${i} not aligned with estimated timeline end ${n}`),!1):!Object.keys(t).some(n=>{var a=t[n].details,r=a.edge;if(i>=r)return this.log(`"${e.identifier}" resumption ${i} past ${n} playlist end ${r}`),!1;var o=$P(null,a.fragments,i);if(!o)return this.log(`"${e.identifier}" resumption ${i} does not align with any fragments in ${n} playlist (${a.fragStart}-${a.fragmentEnd})`),!0;var s="audio"===n?.175:0;return!(Math.abs(o.start-i)<cL+s||Math.abs(o.end-i)<cL+s)&&(this.log(`"${e.identifier}" resumption ${i} not aligned with ${n} fragment bounds (${o.start}-${o.end} sn: ${o.sn} cc: ${o.cc})`),!0)})}},{key:"updateAssetDurations",value:function(e){if(e.assetListLoaded){for(var t=e.timelineStart,i=0,n=!1,a=!1,r=0;r<e.assetList.length;r++){var o=e.assetList[r],s=t+i;o.startOffset=i,o.timelineStart=s,n||(n=null===o.duration),a||(a=!!o.error),i+=o.error?0:o.duration||0}e.duration=n&&!a?Math.max(i,e.duration):i}}},{key:"removeEvent",value:function(e){e.reset(),delete this.eventMap[e.identifier]}}])}();function SL(e){return`[${e.event?'"'+e.event.identifier+'"':"primary"}: ${e.start.toFixed(2)}-${e.end.toFixed(2)}]`}var EL=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.hls=t},[{key:"destroy",value:function(){this.hls=null}},{key:"loadAssetList",value:function(e,t){var i,n=e.assetListUrl;try{i=gL(n,this.hls.sessionId,e.baseUrl)}catch(t){var a=this.assignAssetListError(e,LM.ASSET_LIST_LOAD_ERROR,t,n);return void this.hls.trigger(_M.ERROR,a)}t&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+t);var r=this.hls.config,o=new(0,r.loader)(r),s={responseType:"json",url:i.href},u=r.interstitialAssetListLoadPolicy.default,l={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,i,n,a)=>{var r=t.data,o=null==r?void 0:r.ASSETS;if(Array.isArray(o))e.assetListResponse=r,this.hls.trigger(_M.ASSET_LIST_LOADED,{event:e,assetListResponse:r,networkDetails:a});else{var s=this.assignAssetListError(e,LM.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),n.url,i,a);this.hls.trigger(_M.ERROR,s)}},onError:(t,i,n,a)=>{var r=this.assignAssetListError(e,LM.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${t.code} ${t.text} (${i.url})`),i.url,a,n);this.hls.trigger(_M.ERROR,r)},onTimeout:(t,i,n)=>{var a=this.assignAssetListError(e,LM.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${i.url})`),i.url,t,n);this.hls.trigger(_M.ERROR,a)}};return o.load(s,l,d),this.hls.trigger(_M.ASSET_LIST_LOADING,{event:e}),o}},{key:"assignAssetListError",value:function(e,t,i,n,a,r){return e.error=i,{type:IM.NETWORK_ERROR,details:t,fatal:!1,interstitial:e,url:n,error:i,networkDetails:r,stats:a}}}])}();function ML(e){var t;null==e||null==(t=e.play())||t.catch(()=>{})}function TL(e,t){return`[${e}] Advancing timeline position to ${t}`}var PL=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["interstitials",t.logger])).HlsPlayerClass=void 0,n.hls=void 0,n.assetListLoader=void 0,n.mediaSelection=null,n.altSelection=null,n.media=null,n.detachedData=null,n.requiredTracks=null,n.manager=null,n.playerQueue=[],n.bufferedPos=-1,n.timelinePos=-1,n.schedule=void 0,n.playingItem=null,n.bufferingItem=null,n.waitingItem=null,n.endedItem=null,n.playingAsset=null,n.endedAsset=null,n.bufferingAsset=null,n.shouldPlay=!1,n.onPlay=()=>{n.shouldPlay=!0},n.onPause=()=>{n.shouldPlay=!1},n.onSeeking=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&n.schedule){var t=e-n.timelinePos;if(!(Math.abs(t)<1/7056e5)){var i=t<=-.01;-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),n.timelinePos=e,n.bufferedPos=e;var a=n.playingItem;if(a){if(i)n.schedule.resetErrorsInRange(e,e-t)&&n.updateSchedule(!0);if(n.checkBuffer(),i&&e<a.start||e>=a.end){var r,o=n.findItemIndex(a),s=n.schedule.findItemIndexAtTime(e);if(-1===s&&(s=o+(i?-1:1),n.log(`seeked ${i?"back ":""}to position not covered by schedule ${e} (resolving from ${o} to ${s})`)),!n.isInterstitial(a)&&null!=(r=n.media)&&r.paused&&(n.shouldPlay=!1),!i&&s>o){var u=n.schedule.findJumpRestrictedIndex(o+1,s);if(u>o)return void n.setSchedulePosition(u)}n.setSchedulePosition(s)}else{var l=n.playingAsset;if(l){var d,h=l.timelineStart,c=l.duration||0;if(i&&e<h||e>=h+c)null!=(d=a.event)&&d.appendInPlace&&(n.clearAssetPlayers(a.event,a),n.flushFrontBuffer(e)),n.setScheduleToAssetAtTime(e,l)}else if(n.playingLastItem&&n.isInterstitial(a)){var m=a.event.assetList[0];m&&(n.endedItem=n.playingItem,n.playingItem=null,n.setScheduleToAssetAtTime(e,m))}}}else n.checkBuffer()}}},n.onTimeupdate=()=>{var e=n.currentTime;if(void 0!==e&&!n.playbackDisabled&&(-1!==n.timelinePos||n.effectivePlayingItem||n.checkStart(),e>n.timelinePos)){n.timelinePos=e,e>n.bufferedPos&&n.checkBuffer();var t=n.playingItem;if(t&&!n.playingLastItem){if(e>=t.end){n.timelinePos=t.end;var i=n.findItemIndex(t);n.setSchedulePosition(i+1)}var a=n.playingAsset;if(a)e>=a.timelineStart+(a.duration||0)&&n.setScheduleToAssetAtTime(e,a)}}},n.onScheduleUpdate=(e,t)=>{var i=n.schedule;if(i){var a=n.playingItem,r=i.events||[],o=i.items||[],s=i.durations,u=e.map(e=>e.identifier),l=!(!r.length&&!u.length);(l||t)&&n.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${o.map(e=>SL(e))} pos: ${n.timelinePos}`),u.length&&n.log(`Removed events ${u}`);var d=null,h=null;a&&(d=n.updateItem(a,n.timelinePos),n.itemsMatch(a,d)?n.playingItem=d:n.waitingItem=n.endedItem=null),n.waitingItem=n.updateItem(n.waitingItem),n.endedItem=n.updateItem(n.endedItem);var c=n.bufferingItem;if(c&&(h=n.updateItem(c,n.bufferedPos),n.itemsMatch(c,h)?n.bufferingItem=h:c.event&&(n.bufferingItem=n.playingItem,n.clearInterstitial(c.event,null))),e.forEach(e=>{e.assetList.forEach(e=>{n.clearAssetPlayer(e.identifier,null)})}),n.playerQueue.forEach(e=>{if(e.interstitial.appendInPlace){var t=e.assetItem.timelineStart,i=e.timelineOffset-t;if(i)try{e.timelineOffset=t}catch(a){Math.abs(i)>cL&&n.warn(`${a} ("${e.assetId}" ${e.timelineOffset}->${t})`)}}}),l||t){if(n.hls.trigger(_M.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:o.slice(0),durations:s,removedIds:u}),n.isInterstitial(a)&&u.includes(a.event.identifier))return n.warn(`Interstitial "${a.event.identifier}" removed while playing`),void n.primaryFallback(a.event);a&&n.trimInPlace(d,a),c&&h!==d&&n.trimInPlace(h,c),n.checkBuffer()}}},n.hls=t,n.HlsPlayerClass=i,n.assetListLoader=new EL(t),n.schedule=new kL(n.onScheduleUpdate,t.logger),n.registerListeners(),n}return ue(e,KM),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_M.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.on(_M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(_M.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.on(_M.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.on(_M.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.on(_M.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_M.BUFFERED_TO_END,this.onBufferedToEnd,this),e.on(_M.MEDIA_ENDED,this.onMediaEnded,this),e.on(_M.ERROR,this.onError,this),e.on(_M.DESTROYING,this.onDestroying,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_M.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),e.off(_M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(_M.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),e.off(_M.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),e.off(_M.ASSET_LIST_LOADED,this.onAssetListLoaded,this),e.off(_M.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_M.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_M.BUFFERED_TO_END,this.onBufferedToEnd,this),e.off(_M.MEDIA_ENDED,this.onMediaEnded,this),e.off(_M.ERROR,this.onError,this),e.off(_M.DESTROYING,this.onDestroying,this))}},{key:"startLoad",value:function(){this.resumeBuffering()}},{key:"stopLoad",value:function(){this.pauseBuffering()}},{key:"resumeBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.resumeBuffering()}},{key:"pauseBuffering",value:function(){var e;null==(e=this.getBufferingPlayer())||e.pauseBuffering()}},{key:"destroy",value:function(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}},{key:"onDestroying",value:function(){var e=this.primaryMedia||this.media;e&&this.removeMediaListeners(e)}},{key:"removeMediaListeners",value:function(e){VD(e,"play",this.onPlay),VD(e,"pause",this.onPause),VD(e,"seeking",this.onSeeking),VD(e,"timeupdate",this.onTimeupdate)}},{key:"onMediaAttaching",value:function(e,t){var i=this.media=t.media;GD(i,"seeking",this.onSeeking),GD(i,"timeupdate",this.onTimeupdate),GD(i,"play",this.onPlay),GD(i,"pause",this.onPause)}},{key:"onMediaAttached",value:function(e,t){var i=this.effectivePlayingItem,n=this.detachedData;if(this.detachedData=null,null===i)this.checkStart();else if(!n){this.clearScheduleState();var a=this.findItemIndex(i);this.setSchedulePosition(a)}}},{key:"clearScheduleState",value:function(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia,n=this.media;if(this.media=null,!i&&(n&&this.removeMediaListeners(n),this.detachedData)){var a=this.getBufferingPlayer();a&&(this.log(`Removing schedule state for detachedData and ${a}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,a.detachMedia()),this.shouldPlay=!1}}},{key:"interstitialsManager",get:function(){if(!this.hls)return null;if(this.manager)return this.manager;var e=this,t=()=>e.bufferingItem||e.waitingItem,i=t=>t?e.getAssetPlayer(t.identifier):t,n=(t,n,r,o,s)=>{if(t){var u=t[n].start,l=t.event;if(l){if("playout"===n||l.timelineOccupancy!==mL.Point){var d=i(r);(null==d?void 0:d.interstitial)===l&&(u+=d.assetItem.startOffset+d[s])}}else u+=("bufferedPos"===o?a():e[o])-t.start;return u}return 0},a=()=>{var t=e.bufferedPos;return t===Number.MAX_VALUE?r("primary"):Math.max(t,0)},r=t=>{var i,n;return null!=(i=e.primaryDetails)&&i.live?e.primaryDetails.edge:(null==(n=e.schedule)?void 0:n.durations[t])||0},o=(t,a)=>{var r,o,s=e.effectivePlayingItem;if((null==s||null==(r=s.event)||!r.restrictions.skip)&&e.schedule){e.log(`seek to ${t} "${a}"`);var u=e.effectivePlayingItem,l=e.schedule.findItemIndexAtTime(t,a),d=null==(o=e.schedule.items)?void 0:o[l],h=e.getBufferingPlayer(),c=null==h?void 0:h.interstitial,m=null==c?void 0:c.appendInPlace,f=u&&e.itemsMatch(u,d);if(u&&(m||f)){var v=i(e.playingAsset),p=(null==v?void 0:v.media)||e.primaryMedia;if(p){var g="primary"===a?p.currentTime:n(u,a,e.playingAsset,"timelinePos","currentTime"),y=t-g,b=(m?g:p.currentTime)+y;if(b>=0&&(!v||m||b<=v.duration))return void(p.currentTime=b)}}if(d){var w=t;if("primary"!==a){var k=t-d[a].start;w=d.start+k}var S=!e.isInterstitial(d);if(e.isInterstitial(u)&&!u.event.appendInPlace||!S&&!d.event.appendInPlace){if(u){var E=e.findItemIndex(u);if(l>E){var M=e.schedule.findJumpRestrictedIndex(E+1,l);if(M>E)return void e.setSchedulePosition(M)}var T=0;if(S)e.timelinePos=w,e.checkBuffer();else for(var P=d.event.assetList,A=t-(d[a]||d).start,D=P.length;D--;){var x=P[D];if(x.duration&&A>=x.startOffset&&A<x.startOffset+x.duration){T=D;break}}e.setSchedulePosition(l,T)}}else{var C=e.media||(m?null==h?void 0:h.media:null);C&&(C.currentTime=w)}}}},s=()=>{var i=e.effectivePlayingItem;if(e.isInterstitial(i))return i;var n=t();return e.isInterstitial(n)?n:null},u={get bufferedEnd(){var i,a=t(),r=e.bufferingItem;return r&&r===a&&(n(r,"playout",e.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(i=e.bufferingAsset)?void 0:i.startOffset))||0},get currentTime(){var t=s(),i=e.effectivePlayingItem;return i&&i===t?n(i,"playout",e.effectivePlayingAsset,"timelinePos","currentTime")-i.playout.start:0},set currentTime(t){var i=s(),n=e.effectivePlayingItem;n&&n===i&&o(t+n.playout.start,"playout")},get duration(){var e=s();return e?e.playout.end-e.playout.start:0},get assetPlayers(){var t,i=null==(t=s())?void 0:t.event.assetList;return i?i.map(t=>e.getAssetPlayer(t.identifier)):[]},get playingIndex(){var t,i=null==(t=s())?void 0:t.event;return i&&e.effectivePlayingAsset?i.findAssetIndex(e.effectivePlayingAsset):-1},get scheduleItem(){return s()}};return this.manager={get events(){var t;return(null==(t=e.schedule)||null==(t=t.events)?void 0:t.slice(0))||[]},get schedule(){var t;return(null==(t=e.schedule)||null==(t=t.items)?void 0:t.slice(0))||[]},get interstitialPlayer(){return s()?u:null},get playerQueue(){return e.playerQueue.slice(0)},get bufferingAsset(){return e.bufferingAsset},get bufferingItem(){return t()},get bufferingIndex(){var i=t();return e.findItemIndex(i)},get playingAsset(){return e.effectivePlayingAsset},get playingItem(){return e.effectivePlayingItem},get playingIndex(){var t=e.effectivePlayingItem;return e.findItemIndex(t)},primary:{get bufferedEnd(){return a()},get currentTime(){var t=e.timelinePos;return t>0?t:0},set currentTime(e){o(e,"primary")},get duration(){return r("primary")},get seekableStart(){var t;return(null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0}},integrated:{get bufferedEnd(){return n(t(),"integrated",e.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return n(e.effectivePlayingItem,"integrated",e.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(e){o(e,"integrated")},get duration(){return r("integrated")},get seekableStart(){var t;return((t,i)=>{var n;if(0!==t&&"primary"!==i&&null!=(n=e.schedule)&&n.length){var a,r=e.schedule.findItemIndexAtTime(t),o=null==(a=e.schedule.items)?void 0:a[r];if(o)return t+(o[i].start-o.start)}return t})((null==(t=e.primaryDetails)?void 0:t.fragmentStart)||0,"integrated")}},skip:()=>{var t=e.effectivePlayingItem,i=null==t?void 0:t.event;if(i&&!i.restrictions.skip){var n=e.findItemIndex(t);if(i.appendInPlace){var a=t.playout.start+t.event.duration;o(a+.001,"playout")}else e.advanceAfterAssetEnded(i,n,1/0)}}}}},{key:"effectivePlayingItem",get:function(){return this.waitingItem||this.playingItem||this.endedItem}},{key:"effectivePlayingAsset",get:function(){return this.playingAsset||this.endedAsset}},{key:"playingLastItem",get:function(){var e,t=this.playingItem,i=null==(e=this.schedule)?void 0:e.items;return!!(this.playbackStarted&&t&&i)&&this.findItemIndex(t)===i.length-1}},{key:"playbackStarted",get:function(){return null!==this.effectivePlayingItem}},{key:"currentTime",get:function(){var e,t;if(null!==this.mediaSelection){var i=this.waitingItem||this.playingItem;if(!this.isInterstitial(i)||i.event.appendInPlace){var n=this.media;!n&&null!=(e=this.bufferingItem)&&null!=(e=e.event)&&e.appendInPlace&&(n=this.primaryMedia);var a=null==(t=n)?void 0:t.currentTime;if(void 0!==a&&DM(a))return a}}}},{key:"primaryMedia",get:function(){var e;return this.media||(null==(e=this.detachedData)?void 0:e.media)||null}},{key:"isInterstitial",value:function(e){return!(null==e||!e.event)}},{key:"retreiveMediaSource",value:function(e,t){var i=this.getAssetPlayer(e);i&&this.transferMediaFromPlayer(i,t)}},{key:"transferMediaFromPlayer",value:function(e,t){var i=e.interstitial.appendInPlace,n=e.media;if(i&&n===this.primaryMedia){if(this.bufferingAsset=null,(!t||this.isInterstitial(t)&&!t.event.appendInPlace)&&t&&n)return void(this.detachedData={media:n});var a=e.transferMedia();this.log(`transfer MediaSource from ${e} ${AP(a)}`),this.detachedData=a}else t&&n&&(this.shouldPlay||(this.shouldPlay=!n.paused))}},{key:"transferMediaTo",value:function(e,t){var i,n;if(e.media!==t){var a,r=null,o=this.hls,s=e!==o,u=s&&e.interstitial.appendInPlace,l=null==(i=this.detachedData)?void 0:i.mediaSource;if(o.media)u&&(r=o.transferMedia(),this.detachedData=r),a="Primary";else if(l){var d=this.getBufferingPlayer();d?(r=d.transferMedia(),a=`${d}`):a="detached MediaSource"}else a="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${AP(r)}`);else if(!this.detachedData||o.media===t){var h=this.playerQueue;h.length>1&&h.forEach(e=>{if(s&&e.interstitial.appendInPlace!==u){var t=e.interstitial;this.clearInterstitial(e.interstitial,null),t.appendInPlace=!1,t.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${t}`)}}),this.hls.detachMedia(),this.detachedData={media:t}}var c=r&&"mediaSource"in r&&"closed"!==(null==(n=r.mediaSource)?void 0:n.readyState),m=c&&r?r:t;this.log(`${c?"transfering MediaSource":"attaching media"} to ${s?e:"Primary"} from ${a} (media.currentTime: ${t.currentTime})`);var f=this.schedule;if(m===r&&f){var v=s&&e.assetId===f.assetIdAtEnd;m.overrides={duration:f.duration,endOfStream:!s||v,cueRemoval:!s}}e.attachMedia(m)}}},{key:"onInterstitialCueEnter",value:function(){this.onTimeupdate()}},{key:"checkStart",value:function(){var e=this.schedule,t=null==e?void 0:e.events;if(t&&!this.playbackDisabled&&this.media){-1===this.bufferedPos&&(this.bufferedPos=0);var i=this.timelinePos,n=this.effectivePlayingItem;if(-1===i){var a=this.hls.startPosition;if(this.timelinePos=a,0===t.length)this.setSchedulePosition(0);else if(t[0].cue.pre){this.log(TL("checkStart (preroll)",a));var r=e.findEventIndex(t[0].identifier);this.setSchedulePosition(r)}else if(a>=0||!this.primaryLive){this.log(TL("checkStart",a));var o=this.timelinePos=a>0?a:0,s=e.findItemIndexAtTime(o);this.setSchedulePosition(s)}else 0===this.hls.liveSyncPosition?this.setSchedulePosition(0):this.log("[checkStart] waiting for live start")}else if(n&&!this.playingItem){this.log(TL("checkStart (playing item)",n.start));var u=e.findItemIndex(n);this.setSchedulePosition(u)}}}},{key:"advanceAssetBuffering",value:function(e,t){var i=e.event,n=i.findAssetIndex(t),a=yL(i,n);if(i.isAssetPastPlayoutLimit(a)){if(this.schedule){var r,o=null==(r=this.schedule.items)?void 0:r[this.findItemIndex(e)+1];o&&this.bufferedToItem(o)}}else this.bufferedToEvent(e,a)}},{key:"advanceAfterAssetEnded",value:function(e,t,i){var n=yL(e,i);if(e.isAssetPastPlayoutLimit(n)){if(this.schedule){var a=this.schedule.items;if(a){var r=t+1;if(r>=a.length)return void this.setSchedulePosition(-1);var o=e.resumeTime;this.timelinePos<o&&(this.log(TL("advanceAfterAssetEnded",o)),this.timelinePos=o,e.appendInPlace&&this.advanceInPlace(o),this.checkBuffer(this.bufferedPos<o)),this.setSchedulePosition(r)}}}else{if(e.appendInPlace){var s=e.assetList[n];s&&this.advanceInPlace(s.timelineStart)}this.setSchedulePosition(t,n)}}},{key:"setScheduleToAssetAtTime",value:function(e,t){var i=this.schedule;if(i){var n=t.parentIdentifier,a=i.getEvent(n);if(a){var r=i.findEventIndex(n),o=i.findAssetIndex(a,e);this.advanceAfterAssetEnded(a,r,o-1)}}}},{key:"setSchedulePosition",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;if(n&&!this.playbackDisabled){var a=e>=0?n[e]:null;this.log(`setSchedulePosition ${e}, ${t} (${a?SL(a):a}) pos: ${this.timelinePos}`);var r=this.waitingItem||this.playingItem,o=this.playingLastItem;if(this.isInterstitial(r)){var s=r.event,u=this.playingAsset,l=null==u?void 0:u.identifier,d=l?this.getAssetPlayer(l):null;if(d&&l&&(!this.eventItemsMatch(r,a)||void 0!==t&&l!==s.assetList[t].identifier)){var h,c=s.findAssetIndex(u);if(this.log(`INTERSTITIAL_ASSET_ENDED ${c+1}/${s.assetList.length} ${bL(u)}`),this.endedAsset=u,this.playingAsset=null,this.hls.trigger(_M.INTERSTITIAL_ASSET_ENDED,{asset:u,assetListIndex:c,event:s,schedule:n.slice(0),scheduleIndex:e,player:d}),r!==this.playingItem)return void(this.itemsMatch(r,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),c));this.retreiveMediaSource(l,a),!d.media||null!=(h=this.detachedData)&&h.mediaSource||d.detachMedia()}if(!this.eventItemsMatch(r,a)&&(this.endedItem=r,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${SL(r)}`),s.hasPlayed=!0,this.hls.trigger(_M.INTERSTITIAL_ENDED,{event:s,schedule:n.slice(0),scheduleIndex:e}),s.cue.once)){var m;this.updateSchedule();var f=null==(m=this.schedule)?void 0:m.items;if(a&&f){var v=this.findItemIndex(a);this.advanceSchedule(v,f,t,r,o)}return}}this.advanceSchedule(e,n,t,r,o)}}},{key:"advanceSchedule",value:function(e,t,i,n,a){var r=this.schedule;if(r){var o=t[e]||null,s=this.primaryMedia,u=this.playerQueue;if(u.length&&u.forEach(t=>{var i=t.interstitial,n=r.findEventIndex(i.identifier);(n<e||n>e+1)&&this.clearInterstitial(i,o)}),this.isInterstitial(o)){this.timelinePos=Math.min(Math.max(this.timelinePos,o.start),o.end);var l=o.event;if(void 0===i){var d=yL(l,(i=r.findAssetIndex(l,this.timelinePos))-1);if(l.isAssetPastPlayoutLimit(d)||l.appendInPlace&&this.timelinePos===o.end)return void this.advanceAfterAssetEnded(l,e,i);i=d}var h=this.waitingItem;this.assetsBuffered(o,s)||this.setBufferingItem(o);var c=this.preloadAssets(l,i);if(this.eventItemsMatch(o,h||n)||(this.waitingItem=o,this.log(`INTERSTITIAL_STARTED ${SL(o)} ${l.appendInPlace?"append in place":""}`),this.hls.trigger(_M.INTERSTITIAL_STARTED,{event:l,schedule:t.slice(0),scheduleIndex:e})),!l.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${l}`);if(l.assetListLoader&&(l.assetListLoader.destroy(),l.assetListLoader=void 0),!s)return void this.log(`Waiting for attachMedia to start Interstitial ${l}`);this.waitingItem=this.endedItem=null,this.playingItem=o;var m=l.assetList[i];if(!m)return void this.advanceAfterAssetEnded(l,e,i||0);if(c||(c=this.getAssetPlayer(m.identifier)),null===c||c.destroyed){var f=l.assetList.length;this.warn(`asset ${i+1}/${f} player destroyed ${l}`),(c=this.createAssetPlayer(l,m,i)).loadSource()}if(!this.eventItemsMatch(o,this.bufferingItem)&&l.appendInPlace&&this.isAssetBuffered(m))return;this.startAssetPlayer(c,i,t,e,s),this.shouldPlay&&ML(c.media)}else o?(this.resumePrimary(o,e,n),this.shouldPlay&&ML(this.hls.media)):a&&this.isInterstitial(n)&&(this.endedItem=null,this.playingItem=n,n.event.appendInPlace||this.attachPrimary(r.durations.primary,null))}}},{key:"playbackDisabled",get:function(){return!1===this.hls.config.enableInterstitialPlayback}},{key:"primaryDetails",get:function(){var e;return null==(e=this.mediaSelection)?void 0:e.main.details}},{key:"primaryLive",get:function(){var e;return!(null==(e=this.primaryDetails)||!e.live)}},{key:"resumePrimary",value:function(e,t,i){var n,a;if(this.playingItem=e,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(e),this.log(`resuming ${SL(e)}`),null==(n=this.detachedData)||!n.mediaSource){var r=this.timelinePos;(r<e.start||r>=e.end)&&(r=this.getPrimaryResumption(e,t),this.log(TL("resumePrimary",r)),this.timelinePos=r),this.attachPrimary(r,e)}if(i){var o=null==(a=this.schedule)?void 0:a.items;o&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${SL(e)}`),this.hls.trigger(_M.INTERSTITIALS_PRIMARY_RESUMED,{schedule:o.slice(0),scheduleIndex:t}),this.checkBuffer())}}},{key:"getPrimaryResumption",value:function(e,t){var i=e.start;if(this.primaryLive){var n=this.primaryDetails;if(0===t)return this.hls.startPosition;if(n&&(i<n.fragmentStart||i>n.edge))return this.hls.liveSyncPosition||-1}return i}},{key:"isAssetBuffered",value:function(e){var t=this.getAssetPlayer(e.identifier);return null!=t&&t.hls?t.hls.bufferedToEnd:DA.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=e.timelineStart+(e.duration||0)}},{key:"attachPrimary",value:function(e,t,i){t?this.setBufferingItem(t):this.bufferingItem=this.playingItem,this.bufferingAsset=null;var n=this.primaryMedia;if(n){var a=this.hls;a.media?this.checkBuffer():(this.transferMediaTo(a,n),i&&this.startLoadingPrimaryAt(e,i)),i||(this.log(TL("attachPrimary",e)),this.timelinePos=e,this.startLoadingPrimaryAt(e,i))}}},{key:"startLoadingPrimaryAt",value:function(e,t){var i,n=this.hls;!n.loadingEnabled||!n.media||Math.abs(((null==(i=n.mainForwardBufferInfo)?void 0:i.start)||n.media.currentTime)-e)>.5?n.startLoad(e,t):n.bufferingEnabled||n.resumeBuffering()}},{key:"onManifestLoading",value:function(){var e;this.stopLoad(),null==(e=this.schedule)||e.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(_M.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(_M.BUFFER_CODECS,this.onBufferCodecs,this)}},{key:"onLevelUpdated",value:function(e,t){if(-1!==t.level&&this.schedule){var i=this.hls.levels[t.level];if(i.details){var n=VM(VM({},this.mediaSelection||this.altSelection),{},{main:i});this.mediaSelection=n,this.schedule.parseInterstitialDateRanges(n,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}}}},{key:"onAudioTrackUpdated",value:function(e,t){var i=this.hls.audioTracks[t.id],n=this.mediaSelection;if(n){var a=VM(VM({},n),{},{audio:i});this.mediaSelection=a}else this.altSelection=VM(VM({},this.altSelection),{},{audio:i})}},{key:"onSubtitleTrackUpdated",value:function(e,t){var i=this.hls.subtitleTracks[t.id],n=this.mediaSelection;if(n){var a=VM(VM({},n),{},{subtitles:i});this.mediaSelection=a}else this.altSelection=VM(VM({},this.altSelection),{},{subtitles:i})}},{key:"onAudioTrackSwitching",value:function(e,t){var i=CP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setAudioOption(t)||e.setAudioOption(i)))}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i=CP(t);this.playerQueue.forEach(({hls:e})=>e&&(e.setSubtitleOption(t)||-1!==t.id&&e.setSubtitleOption(i)))}},{key:"onBufferCodecs",value:function(e,t){var i=t.tracks;i&&(this.requiredTracks=i)}},{key:"onBufferAppended",value:function(e,t){this.checkBuffer()}},{key:"onBufferFlushed",value:function(e,t){var i=this.playingItem;if(i&&!this.itemsMatch(i,this.bufferingItem)&&!this.isInterstitial(i)){var n=this.timelinePos;this.bufferedPos=n,this.checkBuffer()}}},{key:"onBufferedToEnd",value:function(e){if(this.schedule){var t=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&t){for(var i=0;i<t.length;i++){var n=t[i];if(n.cue.post){var a,r=this.schedule.findEventIndex(n.identifier),o=null==(a=this.schedule.items)?void 0:a[r];this.isInterstitial(o)&&this.eventItemsMatch(o,this.bufferingItem)&&this.bufferedToItem(o,0);break}}this.bufferedPos=Number.MAX_VALUE}}}},{key:"onMediaEnded",value:function(e){var t=this.playingItem;if(!this.playingLastItem&&t){var i=this.findItemIndex(t);this.setSchedulePosition(i+1)}else this.shouldPlay=!1}},{key:"updateItem",value:function(e,t){var i,n=null==(i=this.schedule)?void 0:i.items;return e&&n&&n[this.findItemIndex(e,t)]||null}},{key:"trimInPlace",value:function(e,t){if(this.isInterstitial(e)&&e.event.appendInPlace&&t.end-e.end>.25){e.event.assetList.forEach((t,i)=>{e.event.isAssetPastPlayoutLimit(i)&&this.clearAssetPlayer(t.identifier,null)});var i=e.end+.25,n=DA.bufferInfo(this.primaryMedia,i,0);if(n.end>i||(n.nextStart||0)>i){this.log(`trim buffered interstitial ${SL(e)} (was ${SL(t)})`);this.attachPrimary(i,null,!0),this.flushFrontBuffer(i)}}}},{key:"itemsMatch",value:function(e,t){return!!t&&(e===t||e.event&&t.event&&this.eventItemsMatch(e,t)||!e.event&&!t.event&&this.findItemIndex(e)===this.findItemIndex(t))}},{key:"eventItemsMatch",value:function(e,t){var i;return!!t&&(e===t||e.event.identifier===(null==(i=t.event)?void 0:i.identifier))}},{key:"findItemIndex",value:function(e,t){return e&&this.schedule?this.schedule.findItemIndex(e,t):-1}},{key:"updateSchedule",value:function(e=!1){var t,i=this.mediaSelection;i&&(null==(t=this.schedule)||t.updateSchedule(i,[],e))}},{key:"checkBuffer",value:function(e){var t,i=null==(t=this.schedule)?void 0:t.items;if(i){var n=DA.bufferInfo(this.primaryMedia,this.timelinePos,0);e&&(this.bufferedPos=this.timelinePos),e||(e=n.len<1),this.updateBufferedPos(n.end,i,e)}}},{key:"updateBufferedPos",value:function(e,t,i){var n=this.schedule,a=this.bufferingItem;if(!(this.bufferedPos>e)&&n)if(1===t.length&&this.itemsMatch(t[0],a))this.bufferedPos=e;else{var r=this.playingItem,o=this.findItemIndex(r),s=n.findItemIndexAtTime(e);if(this.bufferedPos<e){var u,l=this.findItemIndex(a),d=Math.min(l+1,t.length-1),h=t[d];if((-1===s&&a&&e>=a.end||null!=(u=h.event)&&u.appendInPlace&&e+.01>=h.start)&&(s=d),this.isInterstitial(a)){var c=a.event;if(d-o>1&&!1===c.appendInPlace)return;if(0===c.assetList.length&&c.assetListLoader)return}if(this.bufferedPos=e,s>l&&s>o)this.bufferedToItem(h);else{var m=this.primaryDetails;this.primaryLive&&m&&e>m.edge-m.targetduration&&h.start<m.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(h)&&this.preloadAssets(h.event,0)}}else i&&r&&!this.itemsMatch(r,a)&&(s===o?this.bufferedToItem(r):s===o+1&&this.bufferedToItem(t[s]))}}},{key:"assetsBuffered",value:function(e,t){return 0!==e.event.assetList.length&&!e.event.assetList.some(e=>{var i=this.getAssetPlayer(e.identifier);return!(null!=i&&i.bufferedInPlaceToEnd(t))})}},{key:"setBufferingItem",value:function(e){var t=this.bufferingItem,i=this.schedule;if(!this.itemsMatch(e,t)&&i){var n=i.items,a=i.events;if(!n||!a)return t;var r=this.isInterstitial(e),o=this.getBufferingPlayer();this.bufferingItem=e,this.bufferedPos=Math.max(e.start,Math.min(e.end,this.timelinePos));var s=o?o.remaining:t?t.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${SL(e)}`+(t?` (${s.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(r){var u=i.findAssetIndex(e.event,this.bufferedPos);e.event.assetList.forEach((e,t)=>{var i=this.getAssetPlayer(e.identifier);i&&(t===u&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(e=>e.pauseBuffering());this.hls.trigger(_M.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:a.slice(0),schedule:n.slice(0),bufferingIndex:this.findItemIndex(e),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==e&&(this.bufferingItem=e);return t}},{key:"bufferedToItem",value:function(e,t=0){var i=this.setBufferingItem(e);if(!this.playbackDisabled)if(this.isInterstitial(e))this.bufferedToEvent(e,t);else if(null!==i){this.bufferingAsset=null;var n=this.detachedData;if(n)if(n.mediaSource){this.attachPrimary(e.start,e,!0)}else this.preloadPrimary(e);else this.preloadPrimary(e)}}},{key:"preloadPrimary",value:function(e){var t=this.findItemIndex(e),i=this.getPrimaryResumption(e,t);this.startLoadingPrimaryAt(i)}},{key:"bufferedToEvent",value:function(e,t){var i=e.event,n=0===i.assetList.length&&!i.assetListLoader,a=i.cue.once;if(n||!a){var r=this.preloadAssets(i,t);if(null!=r&&r.interstitial.appendInPlace){var o=this.primaryMedia;o&&this.bufferAssetPlayer(r,o)}}}},{key:"preloadAssets",value:function(e,t){var i=e.assetUrl,n=e.assetList.length,a=0===n&&!e.assetListLoader,r=e.cue.once;if(a){var o,s=e.timelineStart;if(e.appendInPlace){var u,l=this.playingItem;this.isInterstitial(l)||(null==l||null==(u=l.nextEvent)?void 0:u.identifier)!==e.identifier||this.flushFrontBuffer(s+.25)}var d=0;if(!this.playingItem&&this.primaryLive&&-1===(d=this.hls.startPosition)&&(d=this.hls.liveSyncPosition||0),d&&!e.cue.pre&&!e.cue.post){var h=d-s;h>0&&(o=Math.round(1e3*h)/1e3)}if(this.log(`Load interstitial asset ${t+1}/${i?1:n} ${e}${o?` live-start: ${d} start-offset: ${o}`:""}`),i)return this.createAsset(e,0,0,s,e.duration,i);var c=this.assetListLoader.loadAssetList(e,o);c&&(e.assetListLoader=c)}else if(!r&&n){for(var m=t;m<n;m++){var f=e.assetList[m],v=this.getAssetPlayerQueueIndex(f.identifier);-1!==v&&!this.playerQueue[v].destroyed||f.error||this.createAssetPlayer(e,f,m)}var p=e.assetList[t];if(p){var g=this.getAssetPlayer(p.identifier);return g&&g.loadSource(),g}}return null}},{key:"flushFrontBuffer",value:function(e){var t=this.requiredTracks;t&&(this.log(`Removing front buffer starting at ${e}`),Object.keys(t).forEach(t=>{this.hls.trigger(_M.BUFFER_FLUSHING,{startOffset:e,endOffset:1/0,type:t})}))}},{key:"getAssetPlayerQueueIndex",value:function(e){for(var t=this.playerQueue,i=0;i<t.length;i++)if(e===t[i].assetId)return i;return-1}},{key:"getAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);return this.playerQueue[t]||null}},{key:"getBufferingPlayer",value:function(){var e=this.playerQueue,t=this.primaryMedia;if(t)for(var i=0;i<e.length;i++)if(e[i].media===t)return e[i];return null}},{key:"createAsset",value:function(e,t,i,n,a,r){var o={parentIdentifier:e.identifier,identifier:fL(e,r,t),duration:a,startOffset:i,timelineStart:n,uri:r};return this.createAssetPlayer(e,o,t)}},{key:"createAssetPlayer",value:function(e,t,i){var n=this.hls,a=n.userConfig,r=a.videoPreference,o=n.loadLevelObj||n.levels[n.currentLevel];(r||o)&&(r=HM({},r),o.videoCodec&&(r.videoCodec=o.videoCodec),o.videoRange&&(r.allowedVideoRanges=[o.videoRange]));var s=n.audioTracks[n.audioTrack],u=n.subtitleTracks[n.subtitleTrack],l=0;if(this.primaryLive||e.appendInPlace){var d=this.timelinePos-t.timelineStart;if(d>1){var h=t.duration;h&&d<h&&(l=d)}}var c=t.identifier,m=VM(VM({},a),{},{maxMaxBufferLength:Math.min(180,n.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:n.sessionId,assetPlayerId:c,abrEwmaDefaultEstimate:n.bandwidthEstimate,interstitialsController:void 0,startPosition:l,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:r,audioPreference:s||a.audioPreference,subtitlePreference:u||a.subtitlePreference});e.appendInPlace&&(e.appendInPlaceStarted=!0,t.timelineStart&&(m.timelineOffset=t.timelineStart));var f=m.cmcd;null!=f&&f.sessionId&&f.contentId&&(m.cmcd=HM({},f,{contentId:hL(t.uri)})),this.getAssetPlayer(c)&&this.warn(`Duplicate date range identifier ${e} and asset ${c}`);var v=new wL(this.HlsPlayerClass,m,e,t);this.playerQueue.push(v),e.assetList[i]=t;var p=!0,g=n=>{if(n.live){var a,r=new Error(`Interstitials MUST be VOD assets ${e}`),o={fatal:!0,type:IM.OTHER_ERROR,details:LM.INTERSTITIAL_ASSET_ITEM_ERROR,error:r},s=(null==(a=this.schedule)?void 0:a.findEventIndex(e.identifier))||-1;this.handleAssetItemError(o,e,s,i,r.message)}else{var u=n.edge-n.fragmentStart,l=t.duration;(p||null===l||u>l)&&(p=!1,this.log(`Interstitial asset "${c}" duration change ${l} > ${u}`),t.duration=u,this.updateSchedule())}};v.on(_M.LEVEL_UPDATED,(e,{details:t})=>g(t)),v.on(_M.LEVEL_PTS_UPDATED,(e,{details:t})=>g(t)),v.on(_M.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());var y=(e,t)=>{var i=this.getAssetPlayer(c);if(i&&t.tracks){i.off(_M.BUFFER_CODECS,y),i.tracks=t.tracks;var n=this.primaryMedia;this.bufferingAsset===i.assetItem&&n&&!i.media&&this.bufferAssetPlayer(i,n)}};v.on(_M.BUFFER_CODECS,y);v.on(_M.BUFFERED_TO_END,()=>{var i,n=this.getAssetPlayer(c);if(this.log(`buffered to end of asset ${n}`),n&&this.schedule){var a=this.schedule.findEventIndex(e.identifier),r=null==(i=this.schedule.items)?void 0:i[a];this.isInterstitial(r)&&this.advanceAssetBuffering(r,t)}});var b=t=>()=>{if(this.getAssetPlayer(c)&&this.schedule){this.shouldPlay=!0;var i=this.schedule.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,i,t)}};return v.once(_M.MEDIA_ENDED,b(i)),v.once(_M.PLAYOUT_LIMIT_REACHED,b(1/0)),v.on(_M.ERROR,(t,n)=>{if(this.schedule){var a=this.getAssetPlayer(c);if(n.details===LM.BUFFER_STALLED_ERROR)return null!=a&&a.appendInPlace?void this.handleInPlaceStall(e):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,`Asset player error ${n.error} ${e}`)}}),v.on(_M.DESTROYING,()=>{if(this.getAssetPlayer(c)&&this.schedule){var t=new Error(`Asset player destroyed unexpectedly ${c}`),n={fatal:!0,type:IM.OTHER_ERROR,details:LM.INTERSTITIAL_ASSET_ITEM_ERROR,error:t};this.handleAssetItemError(n,e,this.schedule.findEventIndex(e.identifier),i,t.message)}}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${bL(t)}`),this.hls.trigger(_M.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:t,assetListIndex:i,event:e,player:v}),v}},{key:"clearInterstitial",value:function(e,t){this.clearAssetPlayers(e,t),e.reset()}},{key:"clearAssetPlayers",value:function(e,t){e.assetList.forEach(e=>{this.clearAssetPlayer(e.identifier,t)})}},{key:"resetAssetPlayer",value:function(e){var t=this.getAssetPlayerQueueIndex(e);if(-1!==t){this.log(`reset asset player "${e}" after error`);var i=this.playerQueue[t];this.transferMediaFromPlayer(i,null),i.resetDetails()}}},{key:"clearAssetPlayer",value:function(e,t){var i=this.getAssetPlayerQueueIndex(e);if(-1!==i){var n=this.playerQueue[i];this.log(`clear ${n} toSegment: ${t?SL(t):t}`),this.transferMediaFromPlayer(n,t),this.playerQueue.splice(i,1),n.destroy()}}},{key:"emptyPlayerQueue",value:function(){for(var e;e=this.playerQueue.pop();)e.destroy();this.playerQueue=[]}},{key:"startAssetPlayer",value:function(e,t,i,n,a){var r=e.interstitial,o=e.assetItem,s=e.assetId,u=r.assetList.length,l=this.playingAsset;this.endedAsset=null,this.playingAsset=o,l&&l.identifier===s||(l&&(this.clearAssetPlayer(l.identifier,i[n]),delete l.error),this.log(`INTERSTITIAL_ASSET_STARTED ${t+1}/${u} ${bL(o)}`),this.hls.trigger(_M.INTERSTITIAL_ASSET_STARTED,{asset:o,assetListIndex:t,event:r,schedule:i.slice(0),scheduleIndex:n,player:e})),this.bufferAssetPlayer(e,a)}},{key:"bufferAssetPlayer",value:function(e,t){var i,n;if(this.schedule){var a=e.interstitial,r=e.assetItem,o=this.schedule.findEventIndex(a.identifier),s=null==(i=this.schedule.items)?void 0:i[o];if(s){e.loadSource(),this.setBufferingItem(s),this.bufferingAsset=r;var u=this.getBufferingPlayer();if(u!==e){var l=a.appendInPlace;if(!l||!1!==(null==u?void 0:u.interstitial.appendInPlace)){var d=(null==u?void 0:u.tracks)||(null==(n=this.detachedData)?void 0:n.tracks)||this.requiredTracks;if(l&&r!==this.playingAsset){if(!e.tracks)return void this.log(`Waiting for track info before buffering ${e}`);if(d&&!tT(d,e.tracks)){var h=new Error(`Asset ${bL(r)} SourceBuffer tracks ('${Object.keys(e.tracks)}') are not compatible with primary content tracks ('${Object.keys(d)}')`),c={fatal:!0,type:IM.OTHER_ERROR,details:LM.INTERSTITIAL_ASSET_ITEM_ERROR,error:h},m=a.findAssetIndex(r);return void this.handleAssetItemError(c,a,o,m,h.message)}}this.transferMediaTo(e,t)}}}}}},{key:"handleInPlaceStall",value:function(e){var t=this.schedule,i=this.primaryMedia;if(t&&i){var n=i.currentTime,a=t.findAssetIndex(e,n),r=e.assetList[a];if(r){var o=this.getAssetPlayer(r.identifier);if(o){var s=o.currentTime||n-r.timelineStart,u=o.duration-s;if(this.warn(`Stalled at ${s} of ${s+u} in ${o} ${e} (media.currentTime: ${n})`),s&&(u/i.playbackRate<.5||o.bufferedInPlaceToEnd(i))&&o.hls){var l=t.findEventIndex(e.identifier);this.advanceAfterAssetEnded(e,l,a)}}}}}},{key:"advanceInPlace",value:function(e){var t=this.primaryMedia;t&&t.currentTime<e&&(t.currentTime=e)}},{key:"handleAssetItemError",value:function(e,t,i,n,a){if(e.details!==LM.BUFFER_STALLED_ERROR){var r=t.assetList[n]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${r?bL(r):r} ${e.error}`),this.schedule){var o=(null==r?void 0:r.identifier)||"",s=this.getAssetPlayerQueueIndex(o),u=this.playerQueue[s]||null,l=this.schedule.items,d=HM({},e,{fatal:!1,errorAction:rA(!0),asset:r,assetListIndex:n,event:t,schedule:l,scheduleIndex:i,player:u});if(this.hls.trigger(_M.INTERSTITIAL_ASSET_ERROR,d),e.fatal){var h=this.playingAsset,c=this.bufferingAsset,m=new Error(a);if(r&&(this.clearAssetPlayer(o,null),r.error=m),t.assetList.some(e=>!e.error))for(var f=n;f<t.assetList.length;f++)this.resetAssetPlayer(t.assetList[f].identifier);else t.error=m;this.updateSchedule(!0),t.error?this.primaryFallback(t):h&&h.identifier===o?this.advanceAfterAssetEnded(t,i,n):c&&c.identifier===o&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,c)}}}}},{key:"primaryFallback",value:function(e){var t=e.timelineStart,i=this.effectivePlayingItem,n=this.timelinePos;if(i){this.log(`Fallback to primary from event "${e.identifier}" start: ${t} pos: ${n} playing: ${SL(i)} error: ${e.error}`),-1===n&&(n=this.hls.startPosition);var a=this.updateItem(i,n);this.itemsMatch(i,a)&&this.clearInterstitial(e,null),e.appendInPlace&&(this.attachPrimary(t,null),this.flushFrontBuffer(t))}else if(-1===n)return void this.checkStart();if(this.schedule){var r=this.schedule.findItemIndexAtTime(n);this.setSchedulePosition(r)}}},{key:"onAssetListLoaded",value:function(e,t){var i,n,a=t.event,r=a.identifier,o=t.assetListResponse.ASSETS;if(null!=(i=this.schedule)&&i.hasEvent(r)){var s=a.timelineStart,u=a.duration,l=0;o.forEach((e,t)=>{var i=parseFloat(e.DURATION);this.createAsset(a,t,l,s+l,i,e.URI),l+=i}),a.duration=l,this.log(`Loaded asset-list with duration: ${l} (was: ${u}) ${a}`);var d=this.waitingItem,h=(null==d?void 0:d.event.identifier)===r;this.updateSchedule();var c=null==(n=this.bufferingItem)?void 0:n.event;if(h){var m,f=this.schedule.findEventIndex(r),v=null==(m=this.schedule.items)?void 0:m[f];if(v){if(!this.playingItem&&this.timelinePos>v.end)if(this.schedule.findItemIndexAtTime(this.timelinePos)!==f)return a.error=new Error(`Interstitial ${o.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${a}`),this.log(a.error.message),this.updateSchedule(!0),void this.primaryFallback(a);this.setBufferingItem(v)}this.setSchedulePosition(f)}else if((null==c?void 0:c.identifier)===r){var p=a.assetList[0];if(p){var g=this.getAssetPlayer(p.identifier);if(c.appendInPlace){var y=this.primaryMedia;g&&y&&this.bufferAssetPlayer(g,y)}else g&&g.loadSource()}}}}},{key:"onError",value:function(e,t){if(this.schedule)switch(t.details){case LM.ASSET_LIST_PARSING_ERROR:case LM.ASSET_LIST_LOAD_ERROR:case LM.ASSET_LIST_LOAD_TIMEOUT:var i=t.interstitial;i&&(this.updateSchedule(!0),this.primaryFallback(i));break;case LM.BUFFER_STALLED_ERROR:var n=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(n)&&n.event.appendInPlace)return void this.handleInPlaceStall(n.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0)}}}])}(),AL=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"subtitle-stream-controller",jM])).currentTrackId=-1,a.tracksBuffered=[],a.mainDetails=null,a.registerListeners(),a}return ue(e,ox),ne(e,[{key:"onHandlerDestroying",value:function(){this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([]),this.mainDetails=null}},{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(_M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(_M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(_M.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(_M.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"unregisterListeners",value:function(){pe(e,"unregisterListeners",this)([]);var t=this.hls;t.off(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(_M.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(_M.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(_M.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(_M.BUFFER_FLUSHING,this.onBufferFlushing,this)}},{key:"startLoad",value:function(e,t){this.stopLoad(),this.state=YD,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.mainDetails=null}},{key:"onMediaDetaching",value:function(t,i){this.tracksBuffered=[],pe(e,"onMediaDetaching",this)([t,i])}},{key:"onLevelLoaded",value:function(e,t){this.mainDetails=t.details}},{key:"onSubtitleFragProcessed",value:function(e,t){var i=t.frag,n=t.success;if(this.fragContextChanged(i)||(bT(i)&&(this.fragPrevious=i),this.state=YD),n){var a=this.tracksBuffered[this.currentTrackId];if(a){for(var r,o=i.start,s=0;s<a.length;s++)if(o>=a[s].start&&o<=a[s].end){r=a[s];break}var u=i.start+i.duration;r?r.end=u:(r={start:o,end:u},a.push(r)),this.fragmentTracker.fragBuffered(i),this.fragBufferedComplete(i,null),this.media&&this.tick()}}}},{key:"onBufferFlushing",value:function(e,t){var i=t.startOffset,n=t.endOffset;if(0===i&&n!==Number.POSITIVE_INFINITY){var a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(e=>{for(var t=0;t<e.length;)if(e[t].end<=a)e.shift();else{if(!(e[t].start<a))break;e[t].start=a,t++}}),this.fragmentTracker.removeFragmentsInRange(i,a,jM)}}},{key:"onError",value:function(e,t){var i=t.frag;(null==i?void 0:i.type)===jM&&(t.details===LM.FRAG_GAP&&this.fragmentTracker.fragBuffered(i,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==XD&&(this.state=YD))}},{key:"onSubtitleTracksUpdated",value:function(e,{subtitleTracks:t}){this.levels&&HC(this.levels,t)?this.levels=t.map(e=>new MP(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{var t=new MP(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,jM),this.fragPrevious=null,this.mediaBuffer=null)}},{key:"onSubtitleTrackSwitch",value:function(e,t){var i;if(this.currentTrackId=t.id,null!=(i=this.levels)&&i.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];null!=n&&n.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,n&&this.state!==XD&&this.setInterval(500)}else this.clearInterval()}},{key:"onSubtitleTrackLoaded",value:function(e,t){var i,n=this.currentTrackId,a=this.levels,r=t.details,o=t.id;if(a){var s=a[o];if(!(o>=a.length)&&s){this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;var u=0;if(r.live||null!=(i=s.details)&&i.live){if(r.deltaUpdateFailed)return;var l=this.mainDetails;if(!l)return void(this.startFragRequested=!1);var d,h=l.fragments[0];if(s.details)0===(u=this.alignPlaylists(r,s.details,null==(d=this.levelLastLoaded)?void 0:d.details))&&h&&LD(r,u=h.start);else r.hasProgramDateTime&&l.hasProgramDateTime?(HD(r,l),u=r.fragmentStart):h&&LD(r,u=h.start);l&&!this.startFragRequested&&this.setStartPosition(l,u)}if(s.details=r,this.levelLastLoaded=s,o===n)if(this.hls.trigger(_M.SUBTITLE_TRACK_UPDATED,{details:r,id:o,groupId:t.groupId}),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===YD)$P(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}else this.warn(`Subtitle tracks were reset while loading level ${o}`)}},{key:"_handleFragmentLoadComplete",value:function(e){var t=e.frag,i=e.payload,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&UA(n.method)){var r=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer,HA(n.method)).catch(e=>{throw a.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(e=>{var i=performance.now();a.trigger(_M.FRAG_DECRYPTED,{frag:t,payload:e,stats:{tstart:r,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=YD})}}},{key:"doTick",value:function(){if(this.media){if(this.state===YD){var e=this.currentTrackId,t=this.levels,i=null==t?void 0:t[e];if(!i||!t.length||!i.details)return;if(this.waitForLive(i))return;var n=this.config,a=this.getLoadPosition(),r=DA.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),o=r.end,s=r.len,u=i.details;if(s>this.hls.maxBufferLength+u.levelTargetDuration)return;var l=u.fragments,d=l.length,h=u.edge,c=null,m=this.fragPrevious;if(o<h){var f=n.maxFragLookUpTolerance,v=o>h-f?0:f;!(c=$P(m,l,Math.max(l[0].start,o),v))&&m&&m.start<l[0].start&&(c=l[0])}else c=l[d-1];if(!(c=this.filterReplacedPrimary(c,i.details)))return;var p=l[c.sn-u.startSN-1];if(p&&p.cc===c.cc&&this.fragmentTracker.getState(p)===oA&&(c=p),this.fragmentTracker.getState(c)===oA){var g=this.mapToInitFragWhenRequired(c);g&&this.loadFragment(g,i,o)}}}else this.state=YD}},{key:"loadFragment",value:function(t,i,n){bT(t)?pe(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i)}},{key:"mediaBufferTimeRanges",get:function(){return new DL(this.tracksBuffered[this.currentTrackId]||[])}}])}(),DL=ne(function e(t){Q(this,e),this.buffered=void 0;var i=(e,i,n)=>{if((i>>>=0)>n-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${i}) is greater than the maximum bound (${n})`);return t[i][e]};this.buffered={get length(){return t.length},end:e=>i("end",e,t.length),start:e=>i("start",e,t.length)}}),xL={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},CL=e=>String.fromCharCode(xL[e]||e),IL=15,LL=100,_L={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},RL={17:2,18:4,21:6,22:8,23:10,19:13,20:15},FL={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},WL={25:2,26:4,29:6,30:8,31:10,27:13,28:15},OL=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],$L=function(){return ne(function e(){Q(this,e),this.time=null,this.verboseLevel=0},[{key:"log",value:function(e,t){if(this.verboseLevel>=e){var i="function"==typeof t?t():t;ZM.log(`${this.time} [${e}] ${i}`)}}}])}(),NL=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].toString(16));return t},jL=function(){return ne(function e(){Q(this,e),this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},[{key:"reset",value:function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}},{key:"setStyles",value:function(e){for(var t=["foreground","underline","italics","background","flash"],i=0;i<t.length;i++){var n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}},{key:"isDefault",value:function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}},{key:"equals",value:function(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}},{key:"copy",value:function(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}},{key:"toString",value:function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}])}(),BL=function(){return ne(function e(){Q(this,e),this.uchar=" ",this.penState=new jL},[{key:"reset",value:function(){this.uchar=" ",this.penState.reset()}},{key:"setChar",value:function(e,t){this.uchar=e,this.penState.copy(t)}},{key:"setPenState",value:function(e){this.penState.copy(e)}},{key:"equals",value:function(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}},{key:"copy",value:function(e){this.uchar=e.uchar,this.penState.copy(e.penState)}},{key:"isEmpty",value:function(){return" "===this.uchar&&this.penState.isDefault()}}])}(),zL=function(){return ne(function e(t){Q(this,e),this.chars=[],this.pos=0,this.currPenState=new jL,this.cueStartTime=null,this.logger=void 0;for(var i=0;i<LL;i++)this.chars.push(new BL);this.logger=t},[{key:"equals",value:function(e){for(var t=0;t<LL;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}},{key:"copy",value:function(e){for(var t=0;t<LL;t++)this.chars[t].copy(e.chars[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<LL;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}},{key:"setCursor",value:function(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>LL&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=LL)}},{key:"moveCursor",value:function(e){var t=this.pos+e;if(e>1)for(var i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}},{key:"backSpace",value:function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}},{key:"insertChar",value:function(e){e>=144&&this.backSpace();var t=CL(e);this.pos>=LL?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}},{key:"clearFromPos",value:function(e){var t;for(t=e;t<LL;t++)this.chars[t].reset()}},{key:"clear",value:function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}},{key:"clearToEndOfRow",value:function(){this.clearFromPos(this.pos)}},{key:"getTextString",value:function(){for(var e=[],t=!0,i=0;i<LL;i++){var n=this.chars[i].uchar;" "!==n&&(t=!1),e.push(n)}return t?"":e.join("")}},{key:"setPenStyles",value:function(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}])}(),UL=function(){return ne(function e(t){Q(this,e),this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(var i=0;i<IL;i++)this.rows.push(new zL(t));this.logger=t},[{key:"reset",value:function(){for(var e=0;e<IL;e++)this.rows[e].clear();this.currRow=14}},{key:"equals",value:function(e){for(var t=!0,i=0;i<IL;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}},{key:"copy",value:function(e){for(var t=0;t<IL;t++)this.rows[t].copy(e.rows[t])}},{key:"isEmpty",value:function(){for(var e=!0,t=0;t<IL;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}},{key:"backSpace",value:function(){this.rows[this.currRow].backSpace()}},{key:"clearToEndOfRow",value:function(){this.rows[this.currRow].clearToEndOfRow()}},{key:"insertChar",value:function(e){this.rows[this.currRow].insertChar(e)}},{key:"setPen",value:function(e){this.rows[this.currRow].setPenStyles(e)}},{key:"moveCursor",value:function(e){this.rows[this.currRow].moveCursor(e)}},{key:"setCursor",value:function(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}},{key:"setPAC",value:function(e){this.logger.log(2,()=>"pacData = "+AP(e));var t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(var i=0;i<IL;i++)this.rows[i].clear();var n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){var r=a.rows[n].cueStartTime,o=this.logger.time;if(null!==r&&null!==o&&r<o)for(var s=0;s<this.nrRollUpRows;s++)this.rows[t-this.nrRollUpRows+s+1].copy(a.rows[n+s])}}this.currRow=t;var u=this.rows[this.currRow];if(null!==e.indent){var l=e.indent,d=Math.max(l-1,0);u.setCursor(e.indent),e.color=u.chars[d].penState.foreground}var h={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(h)}},{key:"setBkgData",value:function(e){this.logger.log(2,()=>"bkgData = "+AP(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}},{key:"setRollUpRows",value:function(e){this.nrRollUpRows=e}},{key:"rollUp",value:function(){if(null!==this.nrRollUpRows){this.logger.log(1,()=>this.getDisplayText());var e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}else this.logger.log(3,"roll_up but nrRollUpRows not set yet")}},{key:"getDisplayText",value:function(e){e=e||!1;for(var t=[],i="",n=-1,a=0;a<IL;a++){var r=this.rows[a].getTextString();r&&(n=a+1,e?t.push("Row "+n+": '"+r+"'"):t.push(r.trim()))}return t.length>0&&(i=e?"["+t.join(" | ")+"]":t.join("\n")),i}},{key:"getTextAndFormat",value:function(){return this.rows}}])}(),HL=function(){return ne(function e(t,i,n){Q(this,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=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new UL(n),this.nonDisplayedMemory=new UL(n),this.lastOutputScreen=new UL(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n},[{key:"reset",value:function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}},{key:"getHandler",value:function(){return this.outputFilter}},{key:"setHandler",value:function(e){this.outputFilter=e}},{key:"setPAC",value:function(e){this.writeScreen.setPAC(e)}},{key:"setBkgData",value:function(e){this.writeScreen.setBkgData(e)}},{key:"setMode",value:function(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}},{key:"insertChars",value:function(e){for(var t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);var i=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>i+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}},{key:"ccRCL",value:function(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}},{key:"ccBS",value:function(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}},{key:"ccAOF",value:function(){}},{key:"ccAON",value:function(){}},{key:"ccDER",value:function(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}},{key:"ccRU",value:function(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}},{key:"ccFON",value:function(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}},{key:"ccRDC",value:function(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}},{key:"ccTR",value:function(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}},{key:"ccRTD",value:function(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}},{key:"ccEDM",value:function(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}},{key:"ccCR",value:function(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}},{key:"ccENM",value:function(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}},{key:"ccEOC",value:function(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}},{key:"ccTO",value:function(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}},{key:"ccMIDROW",value:function(e){var t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{var i=Math.floor(e/2)-16;t.foreground=["white","green","blue","cyan","red","yellow","magenta"][i]}this.logger.log(2,"MIDROW: "+AP(t)),this.writeScreen.setPen(t)}},{key:"outputDataUpdate",value:function(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}},{key:"cueSplitAtTime",value:function(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}])}(),GL=function(){return ne(function e(t,i,n){Q(this,e),this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var a=this.logger=new $L;this.channels=[null,new HL(t,i,a),new HL(t+1,n,a)]},[{key:"getHandler",value:function(e){return this.channels[e].getHandler()}},{key:"setHandler",value:function(e,t){this.channels[e].setHandler(t)}},{key:"addData",value:function(e,t){var i=this;this.logger.time=e;for(var n=function(e){var n=127&t[e],a=127&t[e+1],r=!1,o=null;if(0===n&&0===a)return 0;i.logger.log(3,()=>"["+NL([t[e],t[e+1]])+"] -> ("+NL([n,a])+")");var s=i.cmdHistory;if(n>=16&&n<=31){if(function(e,t,i){return i.a===e&&i.b===t}(n,a,s))return VL(null,null,s),i.logger.log(3,()=>"Repeated command ("+NL([n,a])+") is dropped"),0;VL(n,a,i.cmdHistory),(r=i.parseCmd(n,a))||(r=i.parseMidrow(n,a)),r||(r=i.parsePAC(n,a)),r||(r=i.parseBackgroundAttributes(n,a))}else VL(null,null,s);if(!r&&(o=i.parseChars(n,a))){var u=i.currentChannel;if(u&&u>0)i.channels[u].insertChars(o);else i.logger.log(2,"No channel found yet. TEXT-MODE?")}r||o||i.logger.log(2,()=>"Couldn't parse cleaned data "+NL([n,a])+" orig: "+NL([t[e],t[e+1]]))},a=0;a<t.length;a+=2)n(a)}},{key:"parseCmd",value:function(e,t){if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=33&&t<=35))return!1;var i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),this.currentChannel=i,!0}},{key:"parseMidrow",value:function(e,t){var i=0;if((17===e||25===e)&&t>=32&&t<=47){if((i=17===e?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var n=this.channels[i];return!!n&&(n.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+NL([e,t])+")"),!0)}return!1}},{key:"parsePAC",value:function(e,t){var i;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;var n=e<=23?1:2;i=t>=64&&t<=95?1===n?_L[e]:FL[e]:1===n?RL[e]:WL[e];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(i,t)),this.currentChannel=n,!0)}},{key:"interpretPAC",value:function(e,t){var i,n={color:null,italics:!1,indent:null,underline:!1,row:e};return i=t>95?t-96:t-64,n.underline=!(1&~i),i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=4*Math.floor((i-16)/2),n}},{key:"parseChars",value:function(e,t){var i,n,a=null,r=null;(e>=25?(i=2,r=e-8):(i=1,r=e),r>=17&&r<=19)?(n=17===r?t+80:18===r?t+112:t+144,this.logger.log(2,()=>"Special char '"+CL(n)+"' in channel "+i),a=[n]):e>=32&&e<=127&&(a=0===t?[e]:[e,t]);return a&&this.logger.log(3,()=>"Char codes = "+NL(a).join(",")),a}},{key:"parseBackgroundAttributes",value:function(e,t){var i;if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;var n={};16===e||24===e?(i=Math.floor((t-32)/2),n.background=OL[i],t%2==1&&(n.background=n.background+"_semi")):45===t?n.background="transparent":(n.foreground="black",47===t&&(n.underline=!0));var a=e<=23?1:2;return this.channels[a].setBkgData(n),!0}},{key:"reset",value:function(){for(var e=0;e<Object.keys(this.channels).length;e++){var t=this.channels[e];t&&t.reset()}VL(null,null,this.cmdHistory)}},{key:"cueSplitAtTime",value:function(e){for(var t=0;t<this.channels.length;t++){var i=this.channels[t];i&&i.cueSplitAtTime(e)}}}])}();function VL(e,t,i){i.a=e,i.b=t}var KL=function(){if(null!=YA&&YA.VTTCue)return self.VTTCue;var e=["","lr","rl"],t=["start","middle","end","left","right"];function i(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;var i=t.toLowerCase();return!!~e.indexOf(i)&&i}function n(e){return i(t,e)}function a(e,...t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var a in n)e[a]=n[a]}return e}function r(t,r,o){var s=this,u={enumerable:!0};s.hasBeenReset=!1;var l="",d=!1,h=t,c=r,m=o,f=null,v="",p=!0,g="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},u,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},u,{get:function(){return d},set:function(e){d=!!e}})),Object.defineProperty(s,"startTime",a({},u,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},u,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},u,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},u,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},u,{get:function(){return v},set:function(t){var n=function(t){return i(e,t)}(t);if(!1===n)throw new SyntaxError("An invalid or illegal string was specified.");v=n,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},u,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},u,{get:function(){return g},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");g=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},u,{get:function(){return y},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},u,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"positionAlign",a({},u,{get:function(){return w},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},u,{get:function(){return k},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");k=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"align",a({},u,{get:function(){return S},set:function(e){var t=n(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");S=t,this.hasBeenReset=!0}})),s.displayState=void 0}return r.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},r}(),XL=function(){return ne(function e(){Q(this,e)},[{key:"decode",value:function(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}])}();function YL(e){function t(e,t,i,n){return 3600*(0|e)+60*(0|t)+(0|i)+parseFloat(n||0)}var i=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return i?parseFloat(i[2])>59?t(i[2],i[3],0,i[4]):t(i[1],i[2],i[3],i[4]):null}var qL=function(){return ne(function e(){Q(this,e),this.values=Object.create(null)},[{key:"set",value:function(e,t){this.get(e)||""===t||(this.values[e]=t)}},{key:"get",value:function(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}},{key:"has",value:function(e){return e in this.values}},{key:"alt",value:function(e,t,i){for(var n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}},{key:"integer",value:function(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}},{key:"percent",value:function(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){var i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}])}();function JL(e,t,i,n){var a=n?e.split(n):[e];for(var r in a)if("string"==typeof a[r]){var o=a[r].split(i);if(2===o.length)t(o[0],o[1])}}var QL=new KL(0,0,""),ZL="middle"===QL.align?"middle":"center";function e_(e,t,i){var n=e;function a(){var t=YL(e);if(null===t)throw new Error("Malformed timestamp: "+n);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function r(){e=e.replace(/^\s+/,"")}if(r(),t.startTime=a(),r(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+n);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){var n=new qL;JL(e,function(e,t){var a;switch(e){case"region":for(var r=i.length-1;r>=0;r--)if(i[r].id===t){n.set(e,i[r].region);break}break;case"vertical":n.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),n.integer(e,a[0]),n.percent(e,a[0])&&n.set("snapToLines",!1),n.alt(e,a[0],["auto"]),2===a.length&&n.alt("lineAlign",a[1],["start",ZL,"end"]);break;case"position":a=t.split(","),n.percent(e,a[0]),2===a.length&&n.alt("positionAlign",a[1],["start",ZL,"end","line-left","line-right","auto"]);break;case"size":n.percent(e,t);break;case"align":n.alt(e,t,["start",ZL,"end","left","right"])}},/:/,/\s/),t.region=n.get("region",null),t.vertical=n.get("vertical","");var a=n.get("line","auto");"auto"===a&&-1===QL.line&&(a=-1),t.line=a,t.lineAlign=n.get("lineAlign","start"),t.snapToLines=n.get("snapToLines",!0),t.size=n.get("size",100),t.align=n.get("align",ZL);var r=n.get("position","auto");"auto"===r&&50===QL.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function t_(e){return e.replace(/<br(?: \/)?>/gi,"\n")}var i_=function(){return ne(function e(){Q(this,e),this.state="INITIAL",this.buffer="",this.decoder=new XL,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0},[{key:"parse",value:function(e){var t=this;function i(){var e=t.buffer,i=0;for(e=t_(e);i<e.length&&"\r"!==e[i]&&"\n"!==e[i];)++i;var n=e.slice(0,i);return"\r"===e[i]&&++i,"\n"===e[i]&&++i,t.buffer=e.slice(i),n}function n(e){JL(e,function(e,t){},/:/)}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{var a="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;var r=(a=i()).match(/^()?WEBVTT([ \t].*)?$/);if(null==r||!r[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}for(var o=!1;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new KL(0,0,""),t.state="CUE",-1===a.indexOf("--\x3e")){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{e_(a,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":var s=-1!==a.indexOf("--\x3e");if(!a||s&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(null===t.cue)continue;t.cue.text&&(t.cue.text+="\n"),t.cue.text+=a;continue;case"BADCUE":a||(t.state="ID")}}}catch(e){"CUETEXT"===t.state&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state="INITIAL"===t.state?"BADWEBVTT":"BADCUE"}return this}},{key:"flush",value:function(){var e=this;try{if((e.cue||"HEADER"===e.state)&&(e.buffer+="\n\n",e.parse()),"INITIAL"===e.state||"BADWEBVTT"===e.state)throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}])}(),n_=/\r\n|\n\r|\n|\r/g,a_=function(e,t,i=0){return e.slice(i,i+t.length)===t};function r_(e,t,i){return hL(e.toString())+hL(t.toString())+hL(i)}function o_(e,t,i,n,a,r,o){var s,u=new i_,l=iT(new Uint8Array(e)).trim().replace(n_,"\n").split("\n"),d=[],h=t?function(e,t=1){return wC(e,9e4,1/t)}(t.baseTime,t.timescale):0,c="00:00.000",m=0,f=0,v=!0;u.oncue=function(e){var r=i[n],o=i.ccOffset,u=(m-h)/9e4;if(null!=r&&r.new&&(void 0!==f?o=i.ccOffset=r.start:function(e,t,i){var n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new)return e.ccOffset=e.presentationOffset=n.start,void(n.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=n.start-a.start,n.new=!1,a=e[(n=a).prevCC]}e.presentationOffset=i}(i,n,u)),u){if(!t)return void(s=new Error("Missing initPTS for VTT MPEGTS"));o=u-i.presentationOffset}var l=e.endTime-e.startTime,c=AC(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(c,0),e.endTime=Math.max(c+l,0);var v=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(v)),e.id||(e.id=r_(e.startTime,e.endTime,v)),e.endTime>0&&d.push(e)},u.onparsingerror=function(e){s=e},u.onflush=function(){s?o(s):r(d)},l.forEach(e=>{if(v){if(a_(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{a_(e,"LOCAL:")?c=e.slice(6):a_(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))});try{f=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(DM(t)&&DM(i)&&DM(n)&&DM(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=6e4*n,t+36e5*a}(c)/1e3}catch(e){s=e}return}""===e&&(v=!1)}u.parse(e+"\n")}),u.flush()}var s_="stpp.ttml.im1t",u_=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,l_=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,d_={left:"start",center:"center",right:"end",start:"start",end:"end"};function h_(e,t,i,n){var a=IT(new Uint8Array(e),["mdat"]);if(0!==a.length){var r=a.map(e=>iT(e)),o=function(e,t,i=1,n=!1){return wC(e,t,1/i,n)}(t.baseTime,1,t.timescale);try{r.forEach(e=>i(function(e,t){var i=(new DOMParser).parseFromString(e,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce((e,t)=>(e[t]=n.getAttribute(`ttp:${t}`)||a[t],e),{}),o="preserve"!==n.getAttribute("xml:space"),s=m_(c_(n,"styling","style")),u=m_(c_(n,"layout","region")),l=c_(n,"body","[begin]");return[].map.call(l,e=>{var i=f_(e,o);if(!i||!e.hasAttribute("begin"))return null;var n=g_(e.getAttribute("begin"),r),a=g_(e.getAttribute("dur"),r),l=g_(e.getAttribute("end"),r);if(null===n)throw p_(e);if(null===l){if(null===a)throw p_(e);l=n+a}var d=new KL(n-t,l-t,i);d.id=r_(d.startTime,d.endTime,d.text);var h=function(e,t,i){var n="http://www.w3.org/ns/ttml#styling",a=null,r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&i.hasOwnProperty(o)&&(a=i[o]);return r.reduce((i,r)=>{var o=v_(t,n,r)||v_(e,n,r)||v_(a,n,r);return o&&(i[r]=o),i},{})}(u[e.getAttribute("region")],s[e.getAttribute("style")],s),c=h.textAlign;if(c){var m=d_[c];m&&(d.lineAlign=m),d.align=c}return HM(d,h),d}).filter(e=>null!==e)}(e,o)))}catch(e){n(e)}}else n(new Error("Could not parse IMSC1 mdat"))}function c_(e,t,i){var n=e.getElementsByTagName(t)[0];return n?[].slice.call(n.querySelectorAll(i)):[]}function m_(e){return e.reduce((e,t)=>{var i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function f_(e,t){return[].slice.call(e.childNodes).reduce((e,i,n)=>{var a;return"br"===i.nodeName&&n?e+"\n":null!=(a=i.childNodes)&&a.length?f_(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function v_(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function p_(e){return new Error(`Could not parse ttml timestamp ${e}`)}function g_(e,t){if(!e)return null;var i=YL(e);return null===i&&(u_.test(e)?i=function(e,t){var i=u_.exec(e),n=(0|i[4])+(0|i[5])/t.subFrameRate;return 3600*(0|i[1])+60*(0|i[2])+(0|i[3])+n/t.frameRate}(e,t):l_.test(e)&&(i=function(e,t){var i=l_.exec(e),n=Number(i[1]);switch(i[2]){case"h":return 3600*n;case"m":return 60*n;case"ms":return 1e3*n;case"f":return n/t.frameRate;case"t":return n/t.tickRate}return n}(e,t))),i}var y_=function(){return ne(function e(t,i){Q(this,e),this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=i},[{key:"dispatchCue",value:function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}},{key:"newCue",value:function(e,t,i){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}},{key:"reset",value:function(){this.cueRanges=[],this.startTime=null}}])}(),b_=function(){return ne(function e(t){Q(this,e),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.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},t.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),t.on(_M.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(_M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(_M.FRAG_LOADING,this.onFragLoading,this),t.on(_M.FRAG_LOADED,this.onFragLoaded,this),t.on(_M.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(_M.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(_M.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(_M.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(_M.BUFFER_FLUSHING,this.onBufferFlushing,this)},[{key:"destroy",value:function(){var e=this.hls;e.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_M.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_M.FRAG_LOADING,this.onFragLoading,this),e.off(_M.FRAG_LOADED,this.onFragLoaded,this),e.off(_M.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(_M.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(_M.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_M.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}},{key:"initCea608Parsers",value:function(){var e=new y_(this,"textTrack1"),t=new y_(this,"textTrack2"),i=new y_(this,"textTrack3"),n=new y_(this,"textTrack4");this.cea608Parser1=new GL(1,e,t),this.cea608Parser2=new GL(3,i,n)}},{key:"addCues",value:function(e,t,i,n,a){for(var r=!1,o=a.length;o--;){var s=a[o],u=S_(s[0],s[1],t,i);if(u>=0&&(s[0]=Math.min(s[0],t),s[1]=Math.max(s[1],i),r=!0,u/(i-t)>.5))return}if(r||a.push([t,i]),this.config.renderTextTracksNatively){var l=this.captionsTracks[e];this.Cues.newCue(l,t,i,n)}else{var d=this.Cues.newCue(null,t,i,n);this.hls.trigger(_M.CUES_PARSED,{type:"captions",cues:d,track:e})}}},{key:"onInitPtsFound",value:function(e,{frag:t,id:i,initPTS:n,timescale:a,trackId:r}){var o=this.unparsedVttFrags;i===$M&&(this.initPTS[t.cc]={baseTime:n,timescale:a,trackId:r}),o.length&&(this.unparsedVttFrags=[],o.forEach(e=>{this.initPTS[e.frag.cc]?this.onFragLoaded(_M.FRAG_LOADED,e):this.hls.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}},{key:"getExistingTrack",value:function(e,t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var a=i.textTracks[n];if(k_(a,{name:e,lang:t,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return a}return null}},{key:"createCaptionsTrack",value:function(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}},{key:"createNativeTrack",value:function(e){if(!this.captionsTracks[e]){var t=this.captionsProperties,i=this.captionsTracks,n=this.media,a=t[e],r=a.label,o=a.languageCode,s=this.getExistingTrack(r,o);if(s)i[e]=s,sL(i[e]),rL(i[e],n);else{var u=this.createTextTrack("captions",r,o);u&&(u[e]=!0,i[e]=u)}}}},{key:"createNonNativeTrack",value:function(e){if(!this.nonNativeCaptionsTracks[e]){var t=this.captionsProperties[e];if(t){var i={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=i,this.hls.trigger(_M.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[i]})}}}},{key:"createTextTrack",value:function(e,t,i){var n=this.media;if(n)return n.addTextTrack(e,t,i)}},{key:"onMediaAttaching",value:function(e,t){this.media=t.media,t.mediaSource||this._cleanTracks()}},{key:"onMediaDetaching",value:function(e,t){var i=!!t.transferMedia;if(this.media=null,!i){var n=this.captionsTracks;Object.keys(n).forEach(e=>{sL(n[e]),delete n[e]}),this.nonNativeCaptionsTracks={}}}},{key:"onManifestLoading",value:function(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}},{key:"_cleanTracks",value:function(){var e=this.media;if(e){var t=e.textTracks;if(t)for(var i=0;i<t.length;i++)sL(t[i])}}},{key:"onSubtitleTracksUpdated",value:function(e,t){var i=t.subtitleTracks||[],n=i.some(e=>e.textCodec===s_);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(HC(this.tracks,i))return void(this.tracks=i);if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){var a=this.media,r=a?lL(a.textTracks):null;if(this.tracks.forEach((e,t)=>{var i;if(r){for(var n=null,a=0;a<r.length;a++)if(r[a]&&k_(r[a],e)){n=r[a],r[a]=null;break}n&&(i=n)}if(i)sL(i);else{var o=w_(e);(i=this.createTextTrack(o,e.name,e.lang))&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=r&&r.length){var o=r.filter(e=>null!==e).map(e=>e.label);o.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${o.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){var s=this.tracks.map(e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(_M.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:s})}}}},{key:"onManifestLoaded",value:function(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(t){var i=`textTrack${t[1]}`,n=this.captionsProperties[i];n&&(n.label=e.name,e.lang&&(n.languageCode=e.lang),n.media=e)}})}},{key:"closedCaptionsForLevel",value:function(e){var t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}},{key:"onFragLoading",value:function(e,t){if(this.enabled&&t.frag.type===$M){var i,n,a=this.cea608Parser1,r=this.cea608Parser2,o=this.lastSn,s=t.frag,u=s.cc,l=s.sn,d=null!=(i=null==(n=t.part)?void 0:n.index)?i:-1;a&&r&&(l!==o+1||l===o&&d!==this.lastPartIndex+1||u!==this.lastCc)&&(a.reset(),r.reset()),this.lastCc=u,this.lastSn=l,this.lastPartIndex=d}}},{key:"onFragLoaded",value:function(e,t){var i=t.frag,n=t.payload;if(i.type===jM)if(n.byteLength){var a=i.decryptdata,r="stats"in t;if(null==a||!a.encrypted||r){var o=this.tracks[i.level],s=this.vttCCs;s[i.cc]||(s[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),o&&o.textCodec===s_?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}},{key:"_parseIMSC1",value:function(e,t){var i=this.hls;h_(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),i.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{i.logger.log(`Failed to parse IMSC1: ${t}`),i.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}},{key:"_parseVTTs",value:function(e){var t,i=e.frag,n=e.payload,a=this.initPTS,r=this.unparsedVttFrags,o=a.length-1;if(a[i.cc]||-1!==o){var s=this.hls;o_(null!=(t=i.initSegment)&&t.data?BT(i.initSegment.data,new Uint8Array(n)).buffer:n,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,e=>{this._appendCues(e,i.level),s.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},t=>{var a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(i,n),s.logger.log(`Failed to parse VTT cue: ${t}`),a&&o>i.cc||s.trigger(_M.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:t})})}else r.push(e)}},{key:"_fallbackToIMSC1",value:function(e,t){var i=this.tracks[e.level];i.textCodec||h_(t,this.initPTS[e.cc],()=>{i.textCodec=s_,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}},{key:"_appendCues",value:function(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){var n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach(e=>oL(n,e))}else{var a=this.tracks[t];if(!a)return;var r=a.default?"default":"subtitles"+t;i.trigger(_M.CUES_PARSED,{type:"subtitles",cues:e,track:r})}}},{key:"onFragDecrypted",value:function(e,t){t.frag.type===jM&&this.onFragLoaded(_M.FRAG_LOADED,t)}},{key:"onSubtitleTracksCleared",value:function(){this.tracks=[],this.captionsTracks={}}},{key:"onFragParsingUserdata",value:function(e,t){if(this.enabled&&this.config.enableCEA708Captions){var i=t.frag,n=t.samples;if(i.type!==$M||"NONE"!==this.closedCaptionsForLevel(i))for(var a=0;a<n.length;a++){var r=n[a].bytes;if(r){this.cea608Parser1||this.initCea608Parsers();var o=this.extractCea608Data(r);this.cea608Parser1.addData(n[a].pts,o[0]),this.cea608Parser2.addData(n[a].pts,o[1])}}}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){var r=this.media;if(r&&!(r.currentTime<i)){if(!a||"video"===a){var o=this.captionsTracks;Object.keys(o).forEach(e=>uL(o[e],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==n){var s=this.textTracks;Object.keys(s).forEach(e=>uL(s[e],t,n))}}}},{key:"extractCea608Data",value:function(e){for(var t=[[],[]],i=31&e[0],n=2,a=0;a<i;a++){var r=e[n++],o=127&e[n++],s=127&e[n++];if(0!==o||0!==s)if(!!(4&r)){var u=3&r;0!==u&&1!==u||(t[u].push(o),t[u].push(s))}}return t}}])}();function w_(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function k_(e,t){return!!e&&e.kind===w_(t)&&VC(t,e)}function S_(e,t,i,n){return Math.min(t,n)-Math.max(e,i)}var E_=/\s/,M_={newCue(e,t,i,n){for(var a,r,o,s,u,l=[],d=self.VTTCue||self.TextTrackCue,h=0;h<n.rows.length;h++)if(o=!0,s=0,u="",!(a=n.rows[h]).isEmpty()){for(var c,m=0;m<a.chars.length;m++)E_.test(a.chars[m].uchar)&&o?s++:(u+=a.chars[m].uchar,o=!1);a.cueStartTime=t,t===i&&(i+=1e-4),s>=16?s--:s++;var f=t_(u.trim()),v=r_(t,i,f);null!=e&&null!=(c=e.cues)&&c.getCueById(v)||((r=new d(t,i,f)).id=v,r.line=h+1,r.align="left",r.position=10+Math.min(80,10*Math.floor(8*s/32)),l.push(r))}return e&&l.length&&(l.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),l.forEach(t=>oL(e,t))),l}};var T_=/(\d+)-(\d+)\/(\d+)/,P_=function(){return ne(function e(t){Q(this,e),this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||A_,this.controller=new self.AbortController,this.stats=new fT},[{key:"destroy",value:function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}},{key:"abortInternal",value:function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}},{key:"load",value:function(e,t,i){var n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(e,t){var i={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(HM({},e.headers))};e.rangeEnd&&i.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return i}(e,this.controller.signal),r="arraybuffer"===e.responseType,o=r?"byteLength":"length",s=t.loadPolicy,u=s.maxTimeToFirstByteMs,l=s.maxLoadTimeMs;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=u&&DM(u)?u:l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},t.timeout),(OC(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(i=>{var a;this.response=this.loader=i;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(n,e,this.response))},l-(o-n.loading.start)),!i.ok){var s=i.status,u=i.statusText;throw new D_(u||"fetch, bad network response",s,i)}n.loading.first=o,n.total=function(e){var t=e.get("Content-Range");if(t){var i=function(e){var t=T_.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(DM(i))return i}var n=e.get("Content-Length");if(n)return parseInt(n)}(i.headers)||n.total;var d=null==(a=this.callbacks)?void 0:a.onProgress;return d&&DM(t.highWaterMark)?this.loadProgressively(i,n,e,t.highWaterMark,d):r?i.arrayBuffer():"json"===e.responseType?i.json():i.text()}).then(i=>{var a,r,s=this.response;if(!s)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var u=i[o];u&&(n.loaded=n.total=u);var l={url:s.url,data:i,code:s.status},d=null==(a=this.callbacks)?void 0:a.onProgress;d&&!DM(t.highWaterMark)&&d(n,e,i,s),null==(r=this.callbacks)||r.onSuccess(l,n,e,s)}).catch(t=>{var i;if(self.clearTimeout(this.requestTimeout),!n.aborted){var a=t&&t.code||0,r=t?t.message:null;null==(i=this.callbacks)||i.onError({code:a,text:r},e,t?t.details:null,n)}})}},{key:"getCacheAge",value:function(){var e=null;if(this.response){var t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.response?this.response.headers.get(e):null}},{key:"loadProgressively",value:function(e,t,i,n=0,a){var r=new ux,o=e.body.getReader(),s=()=>o.read().then(o=>{if(o.done)return r.dataLength&&a(t,i,r.flush().buffer,e),Promise.resolve(new ArrayBuffer(0));var u=o.value,l=u.length;return t.loaded+=l,l<n||r.dataLength?(r.push(u),r.dataLength>=n&&a(t,i,r.flush().buffer,e)):a(t,i,u.buffer,e),s()}).catch(()=>Promise.reject());return s()}}])}();function A_(e,t){return new self.Request(e.url,t)}var D_=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t])).code=void 0,a.details=void 0,a.code=i,a.details=n,a}return ue(e,ye(Error)),ne(e)}(),x_=/^age:\s*[\d.]+\s*$/im,C_=function(){return ne(function e(t){Q(this,e),this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new fT,this.retryDelay=0},[{key:"destroy",value:function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}},{key:"abortInternal",value:function(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}},{key:"abort",value:function(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}},{key:"load",value:function(e,t,i){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=t,this.callbacks=i,this.loadInternal()}},{key:"loadInternal",value:function(){var e=this.config,t=this.context;if(e&&t){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then(()=>{if(this.loader===i&&!this.stats.aborted)return a(i,t.url)}).catch(e=>{if(this.loader===i&&!this.stats.aborted)return i.open("GET",t.url,!0),a(i,t.url)}).then(()=>{this.loader!==i||this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{var a;null==(a=this.callbacks)||a.onError({code:i.status,text:e.message},t,i,n)}):this.openAndSendXhr(i,t,e)}}},{key:"openAndSendXhr",value:function(e,t,i){e.readyState||e.open("GET",t.url,!0);var n=t.headers,a=i.loadPolicy,r=a.maxTimeToFirstByteMs,o=a.maxLoadTimeMs;if(n)for(var s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&DM(r)?r:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}},{key:"readystatechange",value:function(){var e=this.context,t=this.loader,i=this.stats;if(e&&t){var n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(0===i.loading.first&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),4===n)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;var r=t.status,o="text"===t.responseType?t.responseText:null;if(r>=200&&r<300){var s=null!=o?o:t.response;if(null!=s){var u,l;i.loading.end=Math.max(self.performance.now(),i.loading.first);var d="arraybuffer"===t.responseType?s.byteLength:s.length;i.loaded=i.total=d,i.bwEstimate=8e3*i.total/(i.loading.end-i.loading.first);var h=null==(u=this.callbacks)?void 0:u.onProgress;h&&h(i,e,s,t);var c={url:t.responseURL,data:s,code:r};return void(null==(l=this.callbacks)||l.onSuccess(c,i,e,t))}}var m,f=a.loadPolicy.errorRetry;if(XP(f,i.retry,!1,{url:e.url,data:void 0,code:r}))this.retry(f);else ZM.error(`${r} while loading ${e.url}`),null==(m=this.callbacks)||m.onError({code:r,text:t.statusText},e,t,i)}}}},{key:"loadtimeout",value:function(){if(this.config){var e=this.config.loadPolicy.timeoutRetry;if(XP(e,this.stats.retry,!0))this.retry(e);else{var t;ZM.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}}}},{key:"retry",value:function(e){var t=this.context,i=this.stats;this.retryDelay=VP(e,i.retry),i.retry++,ZM.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}},{key:"loadprogress",value:function(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}},{key:"getCacheAge",value:function(){var e=null;if(this.loader&&x_.test(this.loader.getAllResponseHeaders())){var t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}},{key:"getResponseHeader",value:function(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}])}(),I_=VM(VM({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:C_,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:WP,bufferController:QC,capLevelController:tI,errorController:aA,fpsController:aL,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:rD,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:M_,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:AL,subtitleTrackController:dL,timelineController:b_,audioStreamController:zC,audioTrackController:KC,emeController:ZI,cmcdController:YI,contentSteeringController:qI,interstitialsController:PL});function L_(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(L_):Object.keys(e).reduce((t,i)=>(t[i]=L_(e[i]),t),{}):e}function __(e,t){var i=e.loader;i!==P_&&i!==C_?(t.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=P_,e.progressive=!0,e.enableSoftwareAES=!0,t.log("[config]: Progressive streaming enabled, using FetchLoader"))}var R_=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["gap-controller",t.logger])).hls=void 0,n.fragmentTracker=void 0,n.media=null,n.mediaSource=void 0,n.nudgeRetry=0,n.stallReported=!1,n.stalled=null,n.moved=!1,n.seeking=!1,n.buffered={},n.lastCurrentTime=0,n.ended=0,n.waiting=0,n.onMediaPlaying=()=>{n.ended=0,n.waiting=0},n.onMediaWaiting=()=>{var e;null!=(e=n.media)&&e.seeking||(n.waiting=self.performance.now(),n.tick())},n.onMediaEnded=()=>{var e;n.hls&&(n.ended=(null==(e=n.media)?void 0:e.currentTime)||1,n.hls.trigger(_M.MEDIA_ENDED,{stalled:!1}))},n.hls=t,n.fragmentTracker=i,n.registerListeners(),n}return ue(e,TA),ne(e,[{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.BUFFER_APPENDED,this.onBufferAppended,this))}},{key:"destroy",value:function(){pe(e,"destroy",this)([]),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}},{key:"onMediaAttached",value:function(e,t){this.setInterval(100),this.mediaSource=t.mediaSource;var i=this.media=t.media;GD(i,"playing",this.onMediaPlaying),GD(i,"waiting",this.onMediaWaiting),GD(i,"ended",this.onMediaEnded)}},{key:"onMediaDetaching",value:function(e,t){this.clearInterval();var i=this.media;i&&(VD(i,"playing",this.onMediaPlaying),VD(i,"waiting",this.onMediaWaiting),VD(i,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}},{key:"onBufferAppended",value:function(e,t){this.buffered=t.timeRanges}},{key:"hasBuffered",get:function(){return Object.keys(this.buffered).length>0}},{key:"tick",value:function(){var e;if(null!=(e=this.media)&&e.readyState&&this.hasBuffered){var t=this.media.currentTime;this.poll(t,this.lastCurrentTime),this.lastCurrentTime=t}}},{key:"poll",value:function(e,t){var i,n,a=null==(i=this.hls)?void 0:i.config;if(a){var r=this.media;if(r){var o=r.seeking,s=this.seeking&&!o,u=!this.seeking&&o,l=r.paused&&!o||r.ended||0===r.playbackRate;if(this.seeking=o,e!==t)return t&&(this.ended=0),this.moved=!0,o||(this.nudgeRetry=0,a.nudgeOnVideoHole&&!l&&e>t&&this.nudgeOnVideoHole(e,t)),void(0===this.waiting&&this.stallResolved(e));if(u||s)s&&this.stallResolved(e);else{if(l)return this.nudgeRetry=0,this.stallResolved(e),void(!this.ended&&r.ended&&this.hls&&(this.ended=e||1,this.hls.trigger(_M.MEDIA_ENDED,{stalled:!1})));if(DA.getBuffered(r).length){var d=DA.bufferInfo(r,e,0),h=d.nextStart||0,c=this.fragmentTracker;if(o&&c&&this.hls){var m=F_(this.hls.inFlightFragments,e),f=d.len>2,v=!h||m||h-e>2&&!c.getPartialFragment(e);if(f||v)return;this.moved=!1}var p=null==(n=this.hls)?void 0:n.latestLevelDetails;if(!this.moved&&null!==this.stalled&&c){if(!(d.len>0)&&!h)return;var g=Math.max(h,d.start||0)-e,y=!(null==p||!p.live)?2*p.targetduration:2,b=O_(e,c);if(g>0&&(g<=y||b))return void(r.paused||this._trySkipBufferHole(b))}var w=a.detectStallWithCurrentTimeMs,k=self.performance.now(),S=this.waiting,E=this.stalled;if(null===E){if(!(S>0&&k-S<w))return void(this.stalled=k);E=this.stalled=S}var M=k-E;if(!o&&(M>=w||S)&&this.hls){var T;if("ended"===(null==(T=this.mediaSource)?void 0:T.readyState)&&(null==p||!p.live)&&Math.abs(e-((null==p?void 0:p.edge)||0))<1){if(this.ended)return;return this.ended=e||1,void this.hls.trigger(_M.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}var P=DA.bufferInfo(r,e,a.maxBufferHole);this._tryFixBufferStall(P,M,e)}else this.nudgeRetry=0}}}}},{key:"stallResolved",value:function(e){var t=this.stalled;if(t&&this.hls&&(this.stalled=null,this.stallReported)){var i=self.performance.now()-t;this.log(`playback not stuck anymore @${e}, after ${Math.round(i)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(_M.STALL_RESOLVED,{})}}},{key:"nudgeOnVideoHole",value:function(e,t){var i,n=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(i=this.buffered.audio)&&i.length&&n&&n.length>1&&e>n.end(0)){var a=DA.bufferedInfo(DA.timeRangesToArray(this.buffered.audio),e,0);if(a.len>1&&t>=a.start){var r=DA.timeRangesToArray(n),o=DA.bufferedInfo(r,t,0).bufferedIndex;if(o>-1&&o<r.length-1){var s=DA.bufferedInfo(r,e,0).bufferedIndex,u=r[o].end,l=r[o+1].start;if((-1===s||s>o)&&l-u<1&&e-u<2){var d=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${e} hole: ${u} -> ${l} buffered index: ${s}`);this.warn(d.message),this.media.currentTime+=1e-6;var h=O_(e,this.fragmentTracker);h&&"fragment"in h?h=h.fragment:h||(h=void 0);var c=DA.bufferInfo(this.media,e,0);this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:d,reason:d.message,frag:h,buffer:c.len,bufferInfo:c})}}}}}},{key:"_tryFixBufferStall",value:function(e,t,i){var n,a,r=this.fragmentTracker,o=this.media,s=null==(n=this.hls)?void 0:n.config;if(o&&r&&s){var u=null==(a=this.hls)?void 0:a.latestLevelDetails,l=O_(i,r);if(l||null!=u&&u.live&&i<u.fragmentStart)if(this._trySkipBufferHole(l)||!this.media)return;var d=e.buffered,h=this.adjacentTraversal(e,i);(d&&d.length>1&&e.len>s.maxBufferHole||e.nextStart&&(e.nextStart-i<s.maxBufferHole||h))&&(t>1e3*s.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(e))}}},{key:"adjacentTraversal",value:function(e,t){var i=this.fragmentTracker,n=e.nextStart;if(i&&n){var a=i.getFragAtPos(t,$M),r=i.getFragAtPos(n,$M);if(a&&r)return r.sn-a.sn<2}return!1}},{key:"_reportStall",value:function(e){var t=this.hls,i=this.media,n=this.stallReported,a=this.stalled;if(!n&&null!==a&&i&&t){this.stallReported=!0;var r=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${AP(e)})`);this.warn(r.message),t.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_STALLED_ERROR,fatal:!1,error:r,buffer:e.len,bufferInfo:e,stalled:{start:a}})}}},{key:"_trySkipBufferHole",value:function(e){var t,i=this.fragmentTracker,n=this.media,a=null==(t=this.hls)?void 0:t.config;if(!n||!i||!a)return 0;var r=n.currentTime,o=DA.bufferInfo(n,r,0),s=r<o.start?o.start:o.nextStart;if(s&&this.hls){var u=o.len<=a.maxBufferHole,l=o.len>0&&o.len<1&&n.readyState<3,d=s-r;if(d>0&&(u||l)){if(d>a.maxBufferHole){var h=!1;if(0===r){var c=i.getAppendedFrag(0,$M);c&&s<c.end&&(h=!0)}if(!h&&e){var m;if(null==(m=this.hls.loadLevelObj)||!m.details)return 0;if(F_(this.hls.inFlightFragments,s))return 0;for(var f=!1,v=e.end;v<s;){var p=O_(v,i);if(!p){f=!0;break}v+=p.duration}if(f)return 0}}var g=Math.max(s+.05,r+.1);if(this.warn(`skipping hole, adjusting currentTime from ${r} to ${g}`),this.moved=!0,n.currentTime=g,null==e||!e.gap){var y=new Error(`fragment loaded with buffer holes, seeking from ${r} to ${g}`),b={type:IM.MEDIA_ERROR,details:LM.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:y,reason:y.message,buffer:o.len,bufferInfo:o};e&&("fragment"in e?b.part=e:b.frag=e),this.hls.trigger(_M.ERROR,b)}return g}}return 0}},{key:"_tryNudgeBuffer",value:function(e){var t=this.hls,i=this.media,n=this.nudgeRetry,a=null==t?void 0:t.config;if(!i||!a)return 0;var r=i.currentTime;if(this.nudgeRetry++,n<a.nudgeMaxRetry){var o=r+(n+1)*a.nudgeOffset,s=new Error(`Nudging 'currentTime' from ${r} to ${o}`);this.warn(s.message),i.currentTime=o,t.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_NUDGE_ON_STALL,error:s,fatal:!1,buffer:e.len,bufferInfo:e})}else{var u=new Error(`Playhead still not moving while enough data buffered @${r} after ${a.nudgeMaxRetry} nudges`);this.error(u.message),t.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.BUFFER_STALLED_ERROR,error:u,fatal:!0,buffer:e.len,bufferInfo:e})}}}])}();function F_(e,t){var i=W_(e.main);if(i&&i.start<=t)return i;var n=W_(e.audio);return n&&n.start<=t?n:null}function W_(e){if(!e)return null;switch(e.state){case YD:case XD:case ix:case nx:return null}return e.frag}function O_(e,t){return t.getAppendedFrag(e,$M)||t.getPartialFragment(e)}function $_(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function N_(e,t,i,n,a){var r=new e(t,i,"");try{r.value=n,a&&(r.type=a)}catch(o){r=new e(t,i,AP(a?VM({type:a},n):n))}return r}var j_=(()=>{var e=$_();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})(),B_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(_M.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()},[{key:"destroy",value:function(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}},{key:"_registerListeners",value:function(){var e=this.hls;e&&(e.on(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"_unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_M.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_M.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}},{key:"onMediaAttaching",value:function(e,t){var i;this.media=t.media,!1===(null==(i=t.overrides)?void 0:i.cueRemoval)&&(this.removeCues=!1)}},{key:"onMediaAttached",value:function(){var e,t=null==(e=this.hls)?void 0:e.latestLevelDetails;t&&this.updateDateRangeCues(t)}},{key:"onMediaDetaching",value:function(e,t){this.media=null,!!t.transferMedia||(this.id3Track&&(this.removeCues&&sL(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}},{key:"onManifestLoading",value:function(){this.dateRangeCuesAppended={}}},{key:"createTrack",value:function(e){var t=this.getID3Track(e.textTracks);return t.mode="hidden",t}},{key:"getID3Track",value:function(e){if(this.media){for(var t=0;t<e.length;t++){var i=e[t];if("metadata"===i.kind&&"id3"===i.label)return rL(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}},{key:"onFragParsingMetadata",value:function(e,t){if(this.media&&this.hls){var i=this.hls.config,n=i.enableEmsgMetadataCues,a=i.enableID3MetadataCues;if(n||a){var r=t.samples;this.id3Track||(this.id3Track=this.createTrack(this.media));var o=$_();if(o)for(var s=0;s<r.length;s++){var u=r[s].type;if((u!==Wx.emsg||n)&&a){var l=Lx(r[s].data),d=r[s].pts,h=d+r[s].duration;h>j_&&(h=j_),h-d<=0&&(h=d+.25);for(var c=0;c<l.length;c++){var m=l[c];if(!_x(m)){this.updateId3CueEnds(d,u);var f=N_(o,d,h,m,u);f&&this.id3Track.addCue(f)}}}}}}}},{key:"updateId3CueEnds",value:function(e,t){var i,n=null==(i=this.id3Track)?void 0:i.cues;if(n)for(var a=n.length;a--;){var r=n[a];r.type===t&&r.startTime<e&&r.endTime===j_&&(r.endTime=e)}}},{key:"onBufferFlushing",value:function(e,{startOffset:t,endOffset:i,type:n}){var a=this.id3Track,r=this.hls;if(r){var o=r.config,s=o.enableEmsgMetadataCues,u=o.enableID3MetadataCues;if(a&&(s||u))uL(a,t,i,"audio"===n?e=>e.type===Wx.audioId3&&u:"video"===n?e=>e.type===Wx.emsg&&s:e=>e.type===Wx.audioId3&&u||e.type===Wx.emsg&&s)}}},{key:"onLevelUpdated",value:function(e,{details:t}){this.updateDateRangeCues(t,!0)}},{key:"onLevelPtsUpdated",value:function(e,t){Math.abs(t.drift)>.01&&this.updateDateRangeCues(t.details)}},{key:"updateDateRangeCues",value:function(e,t){var i=this;if(this.hls&&this.media){var n=this.hls.config,a=n.assetPlayerId,r=n.timelineOffset,o=n.enableDateRangeMetadataCues,s=n.interstitialsController;if(o){var u=$_();if(a&&r&&!s){var l=e.fragmentStart,d=e.fragmentEnd,h=this.assetCue;h?(h.startTime=l,h.endTime=d):u&&(h=this.assetCue=N_(u,l,d,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"))&&(h.id=a,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(h),h.addEventListener("enter",this.onEventCueEnter))}if(e.hasProgramDateTime){var c,m=this.id3Track,f=e.dateRanges,v=Object.keys(f),p=this.dateRangeCuesAppended;if(m&&t)if(null!=(c=m.cues)&&c.length)for(var g,y=Object.keys(p).filter(e=>!v.includes(e)),b=function(){var e=y[w],t=null==(g=p[e])?void 0:g.cues;delete p[e],t&&Object.keys(t).forEach(e=>{var n=t[e];if(n){n.removeEventListener("enter",i.onEventCueEnter);try{m.removeCue(n)}catch(e){}}})},w=y.length;w--;)b();else p=this.dateRangeCuesAppended={};var k=e.fragments[e.fragments.length-1];if(0!==v.length&&DM(null==k?void 0:k.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(var S=function(){var e=v[E],t=f[e],n=t.startTime,a=p[e],r=(null==a?void 0:a.cues)||{},o=(null==a?void 0:a.durationKnown)||!1,l=j_,d=t.duration;if(t.endDate&&null!==d)l=n+d,o=!0;else if(t.endOnNext&&!o){var h=v.reduce((e,i)=>{if(i!==t.id){var n=f[i];if(n.class===t.class&&n.startDate>t.startDate&&(!e||t.startDate<e.startDate))return n}return e},null);h&&(l=h.startTime,o=!0)}for(var c=Object.keys(t.attr),m=0;m<c.length;m++){var g=c[m];if(OA(g)){var y=r[g];if(y)!o||null!=a&&a.durationKnown?Math.abs(y.startTime-n)>.01&&(y.startTime=n,y.endTime=l):y.endTime=l;else if(u){var b=t.attr[g];$A(g)&&(b=aT(b));var w=N_(u,n,l,{key:g,data:b},Wx.dateRange);w&&(w.id=e,i.id3Track.addCue(w),r[g]=w,s&&("X-ASSET-LIST"!==g&&"X-ASSET-URL"!==g||w.addEventListener("enter",i.onEventCueEnter)))}}}p[e]={cues:r,dateRange:t,durationKnown:o}},E=0;E<v.length;E++)S()}}}}}}])}(),z_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{var e=this.media,t=this.levelDetails;if(e&&t){this.currentTime=e.currentTime;var i=this.computeLatency();if(null!==i){this._latency=i;var n=this.config,a=n.lowLatencyMode,r=n.maxLiveSyncPlaybackRate;if(a&&1!==r&&t.live){var o=this.targetLatency;if(null!==o){var s=i-o;if(s<Math.min(this.maxLatency,o+t.targetduration)&&s>.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,r)),l=Math.round(2/(1+Math.exp(-.75*s-this.edgeStalled))*20)/20,d=Math.min(u,Math.max(1,l));this.changeMediaPlaybackRate(e,d)}else 1!==e.playbackRate&&0!==e.playbackRate&&this.changeMediaPlaybackRate(e,1)}}}}},this.hls=t,this.config=t.config,this.registerListeners()},[{key:"levelDetails",get:function(){var e;return(null==(e=this.hls)?void 0:e.latestLevelDetails)||null}},{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var e=this.config;if(void 0!==e.liveMaxLatencyDuration)return e.liveMaxLatencyDuration;var t=this.levelDetails;return t?e.liveMaxLatencyDurationCount*t.targetduration:0}},{key:"targetLatency",get:function(){var e=this.levelDetails;if(null===e||null===this.hls)return null;var t=e.holdBack,i=e.partHoldBack,n=e.targetduration,a=this.config,r=a.liveSyncDuration,o=a.liveSyncDurationCount,s=a.lowLatencyMode,u=this.hls.userConfig,l=s&&i||t;(this._targetLatencyUpdated||u.liveSyncDuration||u.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:o*n);var d=n;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,d)},set:function(e){this.stallCount=0,this.config.liveSyncDuration=e,this._targetLatencyUpdated=!0}},{key:"liveSyncPosition",get:function(){var e=this.estimateLiveEdge(),t=this.targetLatency;if(null===e||null===t)return null;var i=this.levelDetails;if(null===i)return null;var n=i.edge,a=e-t-this.edgeStalled,r=n-i.totalduration,o=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(r,a),o)}},{key:"drift",get:function(){var e=this.levelDetails;return null===e?1:e.drift}},{key:"edgeStalled",get:function(){var e=this.levelDetails;if(null===e)return 0;var t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}},{key:"forwardBufferLength",get:function(){var e=this.media,t=this.levelDetails;if(!e||!t)return 0;var i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}},{key:"destroy",value:function(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}},{key:"registerListeners",value:function(){var e=this.hls;e&&(e.on(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_M.ERROR,this.onError,this))}},{key:"unregisterListeners",value:function(){var e=this.hls;e&&(e.off(_M.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_M.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_M.ERROR,this.onError,this))}},{key:"onMediaAttached",value:function(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}},{key:"onMediaDetaching",value:function(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}},{key:"onManifestLoading",value:function(){this._latency=null,this.stallCount=0}},{key:"onLevelUpdated",value:function(e,{details:t}){t.advanced&&this.onTimeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}},{key:"onError",value:function(e,t){var i;t.details===LM.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(i=this.levelDetails)&&i.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}},{key:"changeMediaPlaybackRate",value:function(e,t){var i,n;e.playbackRate!==t&&(null==(i=this.hls)||i.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(n=this.targetLatency)?void 0:n.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${e.playbackRate} to ${t}`),e.playbackRate=t)}},{key:"estimateLiveEdge",value:function(){var e=this.levelDetails;return null===e?null:e.edge+e.age}},{key:"computeLatency",value:function(){var e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}])}(),U_=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,[t,"level-controller"]))._levels=[],n._firstLevel=-1,n._maxAutoLevel=-1,n._startLevel=void 0,n.currentLevel=null,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.steering=void 0,n.onParsedComplete=void 0,n.steering=i,n._registerListeners(),n}return ue(e,UC),ne(e,[{key:"_registerListeners",value:function(){var e=this.hls;e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_M.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_M.ERROR,this.onError,this)}},{key:"_unregisterListeners",value:function(){var e=this.hls;e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_M.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_M.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_M.ERROR,this.onError,this)}},{key:"destroy",value:function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),pe(e,"destroy",this)([])}},{key:"stopLoad",value:function(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),pe(e,"stopLoad",this)([])}},{key:"resetLevels",value:function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}},{key:"onManifestLoading",value:function(e,t){this.resetLevels()}},{key:"onManifestLoaded",value:function(e,t){var i=this.hls.config.preferManagedMediaSource,n=[],a={},r={},o=!1,s=!1,u=!1;t.levels.forEach(e=>{var t=e.attrs,l=e.audioCodec,d=e.videoCodec;l&&(e.audioCodec=l=rP(l,i)||void 0),d&&(d=e.videoCodec=function(e){for(var t=e.split(","),i=0;i<t.length;i++){var n=t[i].split(".");n.length>2&&"avc1"===n[0]&&(t[i]=`avc1.${parseInt(n[1]).toString(16)}${("000"+parseInt(n[2]).toString(16)).slice(-4)}`)}return t.join(",")}(d));var h=e.width,c=e.height,m=e.unknownCodecs,f=(null==m?void 0:m.length)||0;if(o||(o=!(!h||!c)),s||(s=!!d),u||(u=!!l),f||l&&!this.isAudioSupported(l)||d&&!this.isVideoSupported(d))this.log(`Some or all CODECS not supported "${t.CODECS}"`);else{var v=t.CODECS,p=t["FRAME-RATE"],g=t["HDCP-LEVEL"],y=t["PATHWAY-ID"],b=t.RESOLUTION,w=t["VIDEO-RANGE"],k=`${`${y||"."}-`}${e.bitrate}-${b}-${p}-${v}-${w}-${g}`;if(a[k])if(a[k].uri===e.url||e.attrs["PATHWAY-ID"])a[k].addGroupId("audio",t.AUDIO),a[k].addGroupId("text",t.SUBTITLES);else{var S=r[k]+=1;e.attrs["PATHWAY-ID"]=new Array(S+1).join(".");var E=this.createLevel(e);a[k]=E,n.push(E)}else{var M=this.createLevel(e);a[k]=M,r[k]=1,n.push(M)}}}),this.filterAndSortMediaOptions(n,t,o,s,u)}},{key:"createLevel",value:function(e){var t=new MP(e),i=e.supplemental;if(null!=i&&i.videoCodec&&!this.isVideoSupported(i.videoCodec)){var n=new Error(`SUPPLEMENTAL-CODECS not supported "${i.videoCodec}"`);this.log(n.message),t.supportedResult=mP(n,[])}return t}},{key:"isAudioSupported",value:function(e){return QT(e,"audio",this.hls.config.preferManagedMediaSource)}},{key:"isVideoSupported",value:function(e){return QT(e,"video",this.hls.config.preferManagedMediaSource)}},{key:"filterAndSortMediaOptions",value:function(e,t,i,n,a){var r,o=[],s=[],u=e,l=(null==(r=t.stats)?void 0:r.parsing)||{};if((i||n)&&a&&(u=u.filter(({videoCodec:e,videoRange:t,width:i,height:n})=>{return(!!e||!(!i||!n))&&(!!(a=t)&&yP.indexOf(a)>-1);var a})),0===u.length)return Promise.resolve().then(()=>{if(this.hls){var e="no level with compatible codecs found in manifest",i=e;t.levels.length&&(i=`one or more CODECS in variant not supported: ${AP(t.levels.map(e=>e.attrs.CODECS).filter((e,t,i)=>i.indexOf(e)===t))}`,this.warn(i),e+=` (${i})`);var n=new Error(e);this.hls.trigger(_M.ERROR,{type:IM.MEDIA_ERROR,details:LM.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:n,reason:i})}}),void(l.end=performance.now());t.audioTracks&&H_(o=t.audioTracks.filter(e=>!e.audioCodec||this.isAudioSupported(e.audioCodec))),t.subtitles&&H_(s=t.subtitles);var d=u.slice(0);u.sort((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(i&&e.height!==t.height)return e.height-t.height;if(e.frameRate!==t.frameRate)return e.frameRate-t.frameRate;if(e.videoRange!==t.videoRange)return yP.indexOf(e.videoRange)-yP.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){var n=tP(e.videoCodec),a=tP(t.videoCodec);if(n!==a)return a-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){var r=iP(e.codecSet),o=iP(t.codecSet);if(r!==o)return o-r}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0});var h=d[0];if(this.steering&&(u=this.steering.filterParsedLevels(u)).length!==d.length)for(var c=0;c<d.length;c++)if(d[c].pathwayId===u[0].pathwayId){h=d[c];break}this._levels=u;for(var m=0;m<u.length;m++)if(u[m]===h){var f;this._firstLevel=m;var v=h.bitrate,p=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${u.length} level(s) found, first bitrate: ${v}`),void 0===(null==(f=this.hls.userConfig)?void 0:f.abrEwmaDefaultEstimate)){var g=Math.min(v,this.hls.config.abrEwmaDefaultEstimateMax);g>p&&p===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=g)}break}var y=a&&!n,b=this.hls.config,w=!(!b.audioStreamController||!b.audioTrackController),k={levels:u,audioTracks:o,subtitleTracks:s,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:n,altAudio:w&&!y&&o.some(e=>!!e.url)};l.end=performance.now(),this.hls.trigger(_M.MANIFEST_PARSED,k)}},{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"loadLevelObj",get:function(){return this.currentLevel}},{key:"level",get:function(){return this.currentLevelIndex},set:function(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,t.length-1)}var a=this.currentLevelIndex,r=this.currentLevel,o=r?r.attrs["PATHWAY-ID"]:void 0,s=t[e],u=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,a!==e||!r||o!==u){this.log(`Switching to level ${e} (${s.height?s.height+"p ":""}${s.videoRange?s.videoRange+" ":""}${s.codecSet?s.codecSet+" ":""}@${s.bitrate})${u?" with Pathway "+u:""} from level ${a}${o?" with Pathway "+o:""}`);var l={level:e,attrs:s.attrs,details:s.details,bitrate:s.bitrate,averageBitrate:s.averageBitrate,maxBitrate:s.maxBitrate,realBitrate:s.realBitrate,width:s.width,height:s.height,codecSet:s.codecSet,audioCodec:s.audioCodec,videoCodec:s.videoCodec,audioGroups:s.audioGroups,subtitleGroups:s.subtitleGroups,loaded:s.loaded,loadError:s.loadError,fragmentError:s.fragmentError,name:s.name,id:s.id,uri:s.uri,url:s.url,urlId:0,audioGroupIds:s.audioGroupIds,textGroupIds:s.textGroupIds};this.hls.trigger(_M.LEVEL_SWITCHING,l);var d=s.details;if(!d||d.live){var h=this.switchParams(s.uri,null==r?void 0:r.details,d);this.loadPlaylist(h)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(e){this._firstLevel=e}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel},set:function(e){this._startLevel=e}},{key:"pathways",get:function(){return this.steering?this.steering.pathways():[]}},{key:"pathwayPriority",get:function(){return this.steering?this.steering.pathwayPriority:null},set:function(e){if(this.steering){var t=this.steering.pathways(),i=e.filter(e=>-1!==t.indexOf(e));if(e.length<1)return void this.warn(`pathwayPriority ${e} should contain at least one pathway from list: ${t}`);this.steering.pathwayPriority=i}}},{key:"onError",value:function(e,t){!t.fatal&&t.context&&t.context.type===FM&&t.context.level===this.level&&this.checkRetry(t)}},{key:"onFragBuffered",value:function(e,{frag:t}){if(void 0!==t&&t.type===$M){var i=t.elementaryStreams;if(!Object.keys(i).some(e=>!!i[e]))return;var n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}},{key:"onLevelLoaded",value:function(e,t){var i,n,a=t.level,r=t.details,o=t.levelInfo;if(!o)return this.warn(`Invalid level index ${a}`),void(null!=(n=t.deliveryDirectives)&&n.skip&&(r.deltaUpdateFailed=!0));if(o===this.currentLevel||t.withoutMultiVariant){0===o.fragmentError&&(o.loadError=0);var s=o.details;s===t.details&&s.advanced&&(s=void 0),this.playlistLoaded(a,t,s)}else null!=(i=t.deliveryDirectives)&&i.skip&&(r.deltaUpdateFailed=!0)}},{key:"loadPlaylist",value:function(t){pe(e,"loadPlaylist",this)([]),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}},{key:"loadingPlaylist",value:function(t,i){pe(e,"loadingPlaylist",this)([t,i]);var n=this.getUrlWithDirectives(t.uri,i),a=this.currentLevelIndex,r=t.attrs["PATHWAY-ID"],o=t.details,s=null==o?void 0:o.age;this.log(`Loading level index ${a}${void 0!==(null==i?void 0:i.msn)?" at sn "+i.msn+" part "+i.part:""}${r?" Pathway "+r:""}${s&&o.live?" age "+s.toFixed(1)+(o.type&&" "+o.type||""):""} ${n}`),this.hls.trigger(_M.LEVEL_LOADING,{url:n,level:a,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:i||null})}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}},{key:"removeLevel",value:function(e){var t;if(1!==this._levels.length){var i=this._levels.filter((t,i)=>i!==e||(this.steering&&this.steering.removeLevel(t),t===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,t.details&&t.details.fragments.forEach(e=>e.level=-1)),!1));OD(i),this._levels=i,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);var n=i.length-1;this._firstLevel=Math.min(this._firstLevel,n),this._startLevel&&(this._startLevel=Math.min(this._startLevel,n)),this.hls.trigger(_M.LEVELS_UPDATED,{levels:i})}}},{key:"onLevelsUpdated",value:function(e,{levels:t}){this._levels=t}},{key:"checkMaxAutoUpdated",value:function(){var e=this.hls,t=e.autoLevelCapping,i=e.maxAutoLevel,n=e.maxHdcpLevel;this._maxAutoLevel!==i&&(this._maxAutoLevel=i,this.hls.trigger(_M.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:i,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}])}();function H_(e){var t={};e.forEach(e=>{var i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}function G_(){return self.SourceBuffer||self.WebKitSourceBuffer}function V_(){if(!eT())return!1;var e=G_();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}var K_=function(){function e(t,i,n){var a;return Q(this,e),(a=J(this,e,[t,i,n,"stream-controller",$M])).audioCodecSwap=!1,a.level=-1,a._forceStartLoad=!1,a._hasEnoughToStart=!1,a.altAudio=0,a.audioOnly=!1,a.fragPlaying=null,a.fragLastKbps=0,a.couldBacktrack=!1,a.backtrackFragment=null,a.audioCodecSwitch=!1,a.videoBuffer=null,a.onMediaPlaying=()=>{a.tick()},a.onMediaSeeked=()=>{var e=a.media,t=e?e.currentTime:null;if(null!==t&&DM(t)&&(a.log(`Media seeked to ${t.toFixed(3)}`),a.getBufferedFrag(t))){var i=a.getFwdBufferInfoAtPos(e,t,$M,0);null!==i&&0!==i.len?a.tick():a.warn(`Main forward buffer length at ${t} on "seeked" event ${i?i.len:"empty"})`)}},a.registerListeners(),a}return ue(e,ox),ne(e,[{key:"registerListeners",value:function(){pe(e,"registerListeners",this)([]);var t=this.hls;t.on(_M.MANIFEST_PARSED,this.onManifestParsed,this),t.on(_M.LEVEL_LOADING,this.onLevelLoading,this),t.on(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.on(_M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(_M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(_M.BUFFER_CREATED,this.onBufferCreated,this),t.on(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(_M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"unregisterListeners",value:function(){pe(e,"unregisterListeners",this)([]);var t=this.hls;t.off(_M.MANIFEST_PARSED,this.onManifestParsed,this),t.off(_M.LEVEL_LOADED,this.onLevelLoaded,this),t.off(_M.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(_M.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(_M.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(_M.BUFFER_CREATED,this.onBufferCreated,this),t.off(_M.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(_M.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(_M.FRAG_BUFFERED,this.onFragBuffered,this)}},{key:"onHandlerDestroying",value:function(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),pe(e,"onHandlerDestroying",this)([])}},{key:"startLoad",value:function(e,t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){var a=n.startLevel;-1===a&&(n.config.testBandwidth&&this.levels.length>1?(a=0,this.bitrateTest=!0):a=n.firstAutoLevel),n.nextLoadLevel=a,this.level=n.loadLevel,this._hasEnoughToStart=!!t}i>0&&-1===e&&!t&&(this.log(`Override startPosition with lastCurrentTime @${i.toFixed(3)}`),e=i),this.state=YD,this.nextLoadPosition=this.lastCurrentTime=e+this.timelineOffset,this.startPosition=t?-1:e,this.tick()}else this._forceStartLoad=!0,this.state=XD}},{key:"stopLoad",value:function(){this._forceStartLoad=!1,pe(e,"stopLoad",this)([])}},{key:"doTick",value:function(){switch(this.state){case rx:var e=this.levels,t=this.level,i=null==e?void 0:e[t],n=null==i?void 0:i.details;if(n&&(!n.live||this.levelLastLoaded===i&&!this.waitForLive(i))){if(this.waitForCdnTuneIn(n))break;this.state=YD;break}if(this.hls.nextLoadLevel!==this.level){this.state=YD;break}break;case QD:this.checkRetryDate()}this.state===YD&&this.doTickIdle(),this.onTickEnd()}},{key:"onTickEnd",value:function(){var t;pe(e,"onTickEnd",this)([]),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}},{key:"doTickIdle",value:function(){var e=this.hls,t=this.levelLastLoaded,i=this.levels,n=this.media;if(null!==t&&(n||this.primaryPrefetch||!this.startFragRequested&&e.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var a=this.buffering?e.nextLoadLevel:e.loadLevel;if(null!=i&&i[a]){var r=i[a],o=this.getMainFwdBufferInfo();if(null!==o){var s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){var u={};return 2===this.altAudio&&(u.type="video"),this.hls.trigger(_M.BUFFER_EOS,u),void(this.state=ix)}if(this.buffering){e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;var l=r.details;if(!l||this.state===rx||this.waitForLive(r))return this.level=a,this.state=rx,void(this.startFragRequested=!1);var d=o.len,h=this.getMaxBufferLength(r.maxBitrate);if(!(d>=h)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:o.end,m=this.getNextFragment(c,l);if(this.couldBacktrack&&!this.fragPrevious&&m&&bT(m)&&this.fragmentTracker.getState(m)!==lA){var f,v=(null!=(f=this.backtrackFragment)?f:m).sn-l.startSN,p=l.fragments[v-1];p&&m.cc===p.cc&&(m=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(m&&this.isLoopLoading(m,c)){if(!m.gap){var g=this.audioOnly&&!this.altAudio?vT:pT,y=(g===pT?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,g,$M)}m=this.getNextFragmentLoopLoading(m,l,o,$M,h)}m&&(this.exceedsMaxBuffer(o,h,m)||(!m.initSegment||m.initSegment.data||this.bitrateTest||(m=m.initSegment),this.loadFragment(m,r,c)))}}}}}}},{key:"loadFragment",value:function(t,i,n){var a=this.fragmentTracker.getState(t);a===oA||a===uA?bT(t)?this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,i)):pe(e,"loadFragment",this)([t,i,n]):this._loadInitSegment(t,i):this.clearTrackerIfNeeded(t)}},{key:"getBufferedFrag",value:function(e){return this.fragmentTracker.getBufferedFrag(e,$M)}},{key:"followingBufferedFrag",value:function(e){return e?this.getBufferedFrag(e.end+.5):null}},{key:"immediateLevelSwitch",value:function(){var t;(this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY),0!==this.altAudio)&&(((null==(t=this.getLevelDetails())?void 0:t.fragmentStart)||0)>this.lastCurrentTime&&pe(e,"flushMainBuffer",this)([0,Number.POSITIVE_INFINITY,"audio"]))}},{key:"nextLevelSwitch",value:function(){var e=this.levels,t=this.media;if(null!=t&&t.readyState){var i,n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);var a=this.getLevelDetails();if(null!=a&&a.live){var r=this.getMainFwdBufferInfo();if(!r||r.len<2*a.targetduration)return}if(!t.paused&&e){var o=e[this.hls.nextLoadLevel],s=this.fragLastKbps;i=s&&this.fragCurrent?this.fragCurrent.duration*o.maxBitrate/(1e3*s)+1:0}else i=0;var u=this.getBufferedFrag(t.currentTime+i);if(u){var l=this.followingBufferedFrag(u);if(l){this.abortCurrentFrag();var d=l.maxStartPTS?l.maxStartPTS:l.start,h=l.duration,c=Math.max(u.end,d+Math.min(Math.max(h-this.config.maxFragLookUpTolerance,h*(this.couldBacktrack?.5:.125)),h*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}}},{key:"abortCurrentFrag",value:function(){var e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case qD:case JD:case QD:case ex:case tx:this.state=YD}this.nextLoadPosition=this.getLoadPosition()}},{key:"flushMainBuffer",value:function(t,i){pe(e,"flushMainBuffer",this)([t,i,2===this.altAudio?"video":null])}},{key:"onMediaAttached",value:function(t,i){pe(e,"onMediaAttached",this)([t,i]);var n=i.media;GD(n,"playing",this.onMediaPlaying),GD(n,"seeked",this.onMediaSeeked)}},{key:"onMediaDetaching",value:function(t,i){var n=this.media;n&&(VD(n,"playing",this.onMediaPlaying),VD(n,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,pe(e,"onMediaDetaching",this)([t,i]),!!i.transferMedia||(this._hasEnoughToStart=!1)}},{key:"onManifestLoading",value:function(){pe(e,"onManifestLoading",this)([]),this.log("Trigger BUFFER_RESET"),this.hls.trigger(_M.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}},{key:"onManifestParsed",value:function(e,t){for(var i,n,a=!1,r=!1,o=0;o<t.levels.length;o++){var s=t.levels[o].audioCodec;s&&(a=a||-1!==s.indexOf("mp4a.40.2"),r=r||-1!==s.indexOf("mp4a.40.5"))}this.audioCodecSwitch=a&&r&&!("function"==typeof(null==(n=G_())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}},{key:"onLevelLoading",value:function(e,t){if(this.levels&&this.state===YD){var i=t.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=rx)}}},{key:"onLevelLoaded",value:function(e,t){var i,n=this.levels,a=this.startFragRequested,r=t.level,o=t.details,s=o.totalduration;if(n){this.log(`Level ${r} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${s}`);var u=t.levelInfo,l=this.fragCurrent;!l||this.state!==JD&&this.state!==QD||l.level!==t.level&&l.loader&&this.abortCurrentFrag();var d=0;if(o.live||null!=(i=u.details)&&i.live){var h;if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;d=this.alignPlaylists(o,u.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(u.details=o,this.levelLastLoaded=u,a||this.setStartPosition(o,d),this.hls.trigger(_M.LEVEL_UPDATED,{details:o,level:r}),this.state===rx){if(this.waitForCdnTuneIn(o))return;this.state=YD}a&&o.live&&this.synchronizeToLiveEdge(o),this.tick()}else this.warn(`Levels were reset while loading level ${r}`)}},{key:"synchronizeToLiveEdge",value:function(e){var t=this.config,i=this.media;if(i){var n=this.hls.liveSyncPosition,a=this.getLoadPosition(),r=e.fragmentStart,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==n&&i.duration>n&&(a<n||!s)){var u=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;if((!s&&i.readyState<4||a<o-u)&&(this._hasEnoughToStart||(this.nextLoadPosition=n),i.readyState))if(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${n.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l,d=DA.bufferInfo(i,n,0);if(null==(l=d.buffered)||!l.length)return void(i.currentTime=n);if(d.start<=a)return void(i.currentTime=n);var h=DA.bufferedInfo(d.buffered,a,0).nextStart;h&&(i.currentTime=h)}else i.currentTime=n}}}},{key:"_handleFragmentLoadProgress",value:function(e){var t,i=e.frag,n=e.part,a=e.payload,r=this.levels;if(r){var o=r[i.level];if(o){var s=o.details;if(!s)return this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),void this.fragmentTracker.removeFragment(i);var u=o.videoCodec,l=s.PTSKnown||!s.live,d=null==(t=i.initSegment)?void 0:t.data,h=this._getAudioCodec(o),c=this.transmuxer=this.transmuxer||new BC(this.hls,$M,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=n?n.index:-1,f=-1!==m,v=new PA(i.level,i.sn,i.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[i.cc];c.push(a,d,h,u,i,n,s.totalduration,l,v,p)}else this.warn(`Level ${i.level} not found on progress`)}else this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`)}},{key:"onAudioTrackSwitching",value:function(e,t){var i=this.hls,n=0!==this.altAudio;if(FP(t.url,i))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(n)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),i.once(_M.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(_M.AUDIO_TRACK_SWITCHED,t)}),void i.trigger(_M.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});i.trigger(_M.AUDIO_TRACK_SWITCHED,t)}}},{key:"onAudioTrackSwitched",value:function(e,t){var i=FP(t.url,this.hls);if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i?2:0,this.tick()}},{key:"onBufferCreated",value:function(e,t){var i,n,a=t.tracks,r=!1;for(var o in a){var s=a[o];if("main"===s.id){if(n=o,i=s,"video"===o){var u=a[o];u&&(this.videoBuffer=u.buffer)}}else r=!0}r&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}},{key:"onFragBuffered",value:function(e,t){var i=t.frag,n=t.part,a=i.type===$M;if(a){if(this.fragContextChanged(i))return this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===tx&&(this.state=YD));var r=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*r.total/(r.buffering.end-r.loading.first)),bT(i)&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}var o=this.media;o&&(!this._hasEnoughToStart&&DA.getBuffered(o).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),a&&this.tick())}},{key:"hasEnoughToStart",get:function(){return this._hasEnoughToStart}},{key:"onError",value:function(e,t){var i;if(t.fatal)this.state=nx;else switch(t.details){case LM.FRAG_GAP:case LM.FRAG_PARSING_ERROR:case LM.FRAG_DECRYPT_ERROR:case LM.FRAG_LOAD_ERROR:case LM.FRAG_LOAD_TIMEOUT:case LM.KEY_LOAD_ERROR:case LM.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError($M,t);break;case LM.LEVEL_LOAD_ERROR:case LM.LEVEL_LOAD_TIMEOUT:case LM.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==rx||(null==(i=t.context)?void 0:i.type)!==FM||(this.state=YD);break;case LM.BUFFER_ADD_CODEC_ERROR:case LM.BUFFER_APPEND_ERROR:if("main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.resetLoadingState();break;case LM.BUFFER_FULL_ERROR:if("main"!==t.parent)return;if(this.reduceLengthAndFlushBuffer(t))!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case LM.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}},{key:"onFragLoadEmergencyAborted",value:function(){this.state=YD,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}},{key:"onBufferFlushed",value:function(e,{type:t}){if(t!==vT||!this.altAudio){var i=(t===pT?this.videoBuffer:this.mediaBuffer)||this.media;i&&(this.afterBufferFlushed(i,t,$M),this.tick())}}},{key:"onLevelsUpdated",value:function(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=t.levels}},{key:"swapAudioCodec",value:function(){this.audioCodecSwap=!this.audioCodecSwap}},{key:"seekToStartPos",value:function(){var e=this.media;if(e){var t=e.currentTime,i=this.startPosition;if(i>=0&&t<i){if(e.seeking)return void this.log(`could not seek to ${i}, already seeking at ${t}`);var n=this.timelineOffset;n&&i&&(i+=n);var a=this.getLevelDetails(),r=DA.getBuffered(e),o=r.length?r.start(0):0,s=o-i,u=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||s>0&&(s<u||this.loadingParts&&s<2*((null==a?void 0:a.partTarget)||0)))&&(this.log(`adjusting start position by ${s} to match buffer start`),i+=s,this.startPosition=i),t<i&&(this.log(`seek to target start position ${i} from current time ${t} buffer start ${o}`),e.currentTime=i)}}}},{key:"_getAudioCodec",value:function(e){var t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),t}},{key:"_loadBitrateTestFrag",value:function(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(e=>{var i=this.hls,n=null==e?void 0:e.frag;if(n&&!this.fragContextChanged(n)){t.fragmentError=0,this.state=YD,this.startFragRequested=!1,this.bitrateTest=!1;var a=n.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(_M.FRAG_LOADED,e),n.bitrateTest=!1}}).catch(t=>{this.state!==XD&&this.state!==nx&&(this.warn(t),this.resetFragmentLoading(e))})}},{key:"_handleTransmuxComplete",value:function(e){var t=this.playlistType,i=this.hls,n=e.remuxResult,a=e.chunkMeta,r=this.getCurrentContext(a);if(r){var o=r.frag,s=r.part,u=r.level,l=n.video,d=n.text,h=n.id3,c=n.initSegment,m=u.details,f=this.altAudio?void 0:n.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=ex,c){var v=c.tracks;if(v){var p=o.initSegment||o;if(this.unhandledEncryptionError(c,o))return;this._bufferInitSegment(u,v,p,a),i.trigger(_M.FRAG_PARSING_INIT_SEGMENT,{frag:p,id:t,tracks:v})}var g=c.initPTS,y=c.timescale,b=this.initPTS[o.cc];if(DM(g)&&(!b||b.baseTime!==g||b.timescale!==y)){var w=c.trackId;this.initPTS[o.cc]={baseTime:g,timescale:y,trackId:w},i.trigger(_M.INIT_PTS_FOUND,{frag:o,id:t,initPTS:g,timescale:y,trackId:w})}}if(l&&m){f&&"audiovideo"===l.type&&this.logMuxedErr(o);var k=m.fragments[o.sn-1-m.startSN],S=o.sn===m.startSN,E=!k||o.cc>k.cc;if(!1!==n.independent){var M=l.startPTS,T=l.endPTS,P=l.startDTS,A=l.endDTS;if(s)s.elementaryStreams[l.type]={startPTS:M,endPTS:T,startDTS:P,endDTS:A};else if(l.firstKeyFrame&&l.independent&&1===a.id&&!E&&(this.couldBacktrack=!0),l.dropped&&l.independent){var D=this.getMainFwdBufferInfo(),x=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,C=l.firstKeyFramePTS?l.firstKeyFramePTS:M;if(!S&&x<C-this.config.maxBufferHole&&!E)return void this.backtrack(o);E&&(o.gap=!0),o.setElementaryStreamInfo(l.type,o.start,T,o.start,A,!0)}else S&&M-(m.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(l.type,M,T,P,A),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(l,o,s,a,S||E)}else{if(!S&&!E)return void this.backtrack(o);o.gap=!0}}if(f){var I=f.startPTS,L=f.endPTS,_=f.startDTS,R=f.endDTS;s&&(s.elementaryStreams[vT]={startPTS:I,endPTS:L,startDTS:_,endDTS:R}),o.setElementaryStreamInfo(vT,I,L,_,R),this.bufferFragmentData(f,o,s,a)}if(m&&null!=h&&h.samples.length){var F={id:t,frag:o,details:m,samples:h.samples};i.trigger(_M.FRAG_PARSING_METADATA,F)}if(m&&d){var W={id:t,frag:o,details:m,samples:d.samples};i.trigger(_M.FRAG_PARSING_USERDATA,W)}}}else this.resetWhenMissingContext(a)}},{key:"logMuxedErr",value:function(e){this.warn(`${bT(e)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${e.url}`)}},{key:"_bufferInitSegment",value:function(e,t,i,n){if(this.state===ex){this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&(delete t.audio,t.audiovideo&&this.logMuxedErr(i));var a=t.audio,r=t.video,o=t.audiovideo;if(a){var s=e.audioCodec,u=oP(a.codec,s);"mp4a"===u&&(u="mp4a.40.5");var l=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){u&&(u=-1!==u.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");var d=a.metadata;d&&"channelCount"in d&&1!==(d.channelCount||1)&&-1===l.indexOf("firefox")&&(u="mp4a.40.5")}u&&-1!==u.indexOf("mp4a.40.5")&&-1!==l.indexOf("android")&&"audio/mpeg"!==a.container&&(u="mp4a.40.2",this.log(`Android: force audio codec to ${u}`)),s&&s!==u&&this.log(`Swapping manifest audio codec "${s}" for "${u}"`),a.levelCodec=u,a.id=$M,this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${u||""}/${s||""}/${a.codec}]`),delete t.audiovideo}if(r){r.levelCodec=e.videoCodec,r.id=$M;var h=r.codec;if(4===(null==h?void 0:h.length))switch(h){case"hvc1":case"hev1":r.codec="hvc1.1.6.L120.90";break;case"av01":r.codec="av01.0.04M.08";break;case"avc1":r.codec="avc1.42e01e"}this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${h}]${r.codec!==h?" parsed-corrected="+r.codec:""}${r.supplemental?" supplemental="+r.supplemental:""}`),delete t.audiovideo}o&&(this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),delete t.video,delete t.audio);var c=Object.keys(t);if(c.length){if(this.hls.trigger(_M.BUFFER_CODECS,t),!this.hls)return;c.forEach(e=>{var a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(_M.BUFFER_APPENDING,{type:e,data:a,frag:i,part:null,chunkMeta:n,parent:i.type})})}this.tickImmediate()}}},{key:"getMainFwdBufferInfo",value:function(){var e=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(e,$M)}},{key:"maxBufferLength",get:function(){var e=this.levels,t=this.level,i=null==e?void 0:e[t];return i?this.getMaxBufferLength(i.maxBitrate):this.config.maxBufferLength}},{key:"backtrack",value:function(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=YD}},{key:"checkFragmentChanged",value:function(){var e=this.media,t=null;if(e&&e.readyState>1&&!1===e.seeking){var i=e.currentTime;if(DA.isBuffered(e,i)?t=this.getAppendedFrag(i):DA.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;var n=this.fragPlaying,a=t.level;n&&t.sn===n.sn&&n.level===a||(this.fragPlaying=t,this.hls.trigger(_M.FRAG_CHANGED,{frag:t}),n&&n.level===a||this.hls.trigger(_M.LEVEL_SWITCHED,{level:a}))}}}},{key:"nextLevel",get:function(){var e=this.nextBufferedFrag;return e?e.level:-1}},{key:"currentFrag",get:function(){var e;if(this.fragPlaying)return this.fragPlaying;var t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;return DM(t)?this.getAppendedFrag(t):null}},{key:"currentProgramDateTime",get:function(){var e,t=(null==(e=this.media)?void 0:e.currentTime)||this.lastCurrentTime;if(DM(t)){var i=this.getLevelDetails(),n=this.currentFrag||(i?$P(null,i.fragments,t):null);if(n){var a=n.programDateTime;if(null!==a){var r=a+1e3*(t-n.start);return new Date(r)}}}return null}},{key:"currentLevel",get:function(){var e=this.currentFrag;return e?e.level:-1}},{key:"nextBufferedFrag",get:function(){var e=this.currentFrag;return e?this.followingBufferedFrag(e):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])}(),X_=function(){function e(t,i){var n;return Q(this,e),(n=J(this,e,["key-loader",i])).config=void 0,n.keyIdToKeyInfo={},n.emeController=null,n.config=t,n}return ue(e,KM),ne(e,[{key:"abort",value:function(e){for(var t in this.keyIdToKeyInfo){var i=this.keyIdToKeyInfo[t].loader;if(i){var n;if(e&&e!==(null==(n=i.context)?void 0:n.frag.type))return;i.abort()}}}},{key:"detach",value:function(){for(var e in this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[e]}}},{key:"destroy",value:function(){for(var e in this.detach(),this.keyIdToKeyInfo){var t=this.keyIdToKeyInfo[e].loader;t&&t.destroy()}this.keyIdToKeyInfo={}}},{key:"createKeyLoadError",value:function(e,t=LM.KEY_LOAD_ERROR,i,n,a){return new MA({type:IM.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}},{key:"loadClear",value:function(e,t,i){var n=this;if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(t.length)for(var a,r=function(){var a=t[o];if(e.cc<=a.cc&&(!bT(e)||!bT(a)||e.sn<a.sn)||!i&&o==s-1)return{v:n.emeController.selectKeySystemFormat(a).then(e=>{if(n.emeController){a.setKeyFormat(e);var t=tD(e);return t?n.emeController.getKeySystemAccess([t]):void 0}})}},o=0,s=t.length;o<s;o++)if(a=r())return a.v;if(this.config.requireKeySystemAccessOnStart){var u=nD(this.config);if(u.length)return this.emeController.getKeySystemAccess(u)}}return null}},{key:"load",value:function(e){return!e.decryptdata&&e.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}},{key:"loadInternal",value:function(e,t){var i,n;t&&e.setKeyFormat(t);var a=e.decryptdata;if(!a){var r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(e,LM.KEY_LOAD_ERROR,r))}var o=a.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,LM.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));var s=Y_(a),u=this.keyIdToKeyInfo[s];if(null!=(i=u)&&i.decryptdata.key)return a.key=u.decryptdata.key,Promise.resolve({frag:e,keyInfo:u});if(this.emeController&&null!=(n=u)&&n.keyLoadPromise)switch(this.emeController.getKeyStatus(u.decryptdata)){case"usable":case"usable-in-future":return u.keyLoadPromise.then(t=>{var i=t.keyInfo;return a.key=i.decryptdata.key,{frag:e,keyInfo:i}})}switch(this.log(`${this.keyIdToKeyInfo[s]?"Rel":"L"}oading${a.keyId?" keyId: "+nT(a.keyId):""} URI: ${a.uri} from ${e.type} ${e.level}`),u=this.keyIdToKeyInfo[s]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(u,e):this.loadKeyEME(u,e);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(u,e);default:return Promise.reject(this.createKeyLoadError(e,LM.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}},{key:"loadKeyEME",value:function(e,t){var i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){var n;if(!e.decryptdata.keyId&&null!=(n=t.initSegment)&&n.data){var a=function(e){var t=[];return NT(e,e=>t.push(e.subarray(8,24))),t}(t.initSegment.data);if(a.length){var r=a[0];r.some(e=>0!==e)?(this.log(`Using keyId found in init segment ${nT(r)}`),uD.setKeyIdForUri(e.decryptdata.uri,r)):(r=uD.addKeyIdForUri(e.decryptdata.uri),this.log(`Generating keyId to patch media ${nT(r)}`)),e.decryptdata.keyId=r}}if(!e.decryptdata.keyId&&!bT(t))return Promise.resolve(i);var o=this.emeController.loadKey(i);return(e.keyLoadPromise=o.then(t=>(e.mediaKeySessionContext=t,i))).catch(i=>{throw e.keyLoadPromise=null,"data"in i&&(i.data.frag=t),i})}return Promise.resolve(i)}},{key:"loadKeyHTTP",value:function(e,t){var i=this.config,n=new(0,i.loader)(i);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,r)=>{var o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=i.keyLoadPolicy.default,u={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,i,n)=>{var o=i.frag,s=i.keyInfo,u=Y_(s.decryptdata);if(!o.decryptdata||s!==this.keyIdToKeyInfo[u])return r(this.createKeyLoadError(o,LM.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,i,n,a)=>{this.resetLoader(i),r(this.createKeyLoadError(t,LM.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),n,VM({url:o.url,data:void 0},e)))},onTimeout:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,LM.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),n))},onAbort:(e,i,n)=>{this.resetLoader(i),r(this.createKeyLoadError(t,LM.INTERNAL_ABORTED,new Error("key loading aborted"),n))}};n.load(o,u,l)})}},{key:"resetLoader",value:function(e){var t=e.frag,i=e.keyInfo,n=e.url,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null);var r=Y_(i.decryptdata)||n;delete this.keyIdToKeyInfo[r],a&&a.destroy()}}])}();function Y_(e){if(e.keyFormat!==QA){var t=e.keyId;if(t)return nT(t)}return e.uri}function q_(e){switch(e.type){case WM:return NM;case OM:return jM;default:return $M}}function J_(e,t){var i=e.url;return void 0!==i&&0!==i.indexOf("data:")||(i=t.url),i}var Q_=function(){return ne(function e(t){Q(this,e),this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()},[{key:"startLoad",value:function(e){}},{key:"stopLoad",value:function(){this.destroyInternalLoaders()}},{key:"registerListeners",value:function(){var e=this.hls;e.on(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_M.LEVEL_LOADING,this.onLevelLoading,this),e.on(_M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.on(_M.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"unregisterListeners",value:function(){var e=this.hls;e.off(_M.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_M.LEVEL_LOADING,this.onLevelLoading,this),e.off(_M.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_M.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),e.off(_M.LEVELS_UPDATED,this.onLevelsUpdated,this)}},{key:"createInternalLoader",value:function(e){var t=this.hls.config,i=t.pLoader,n=t.loader,a=new(i||n)(t);return this.loaders[e.type]=a,a}},{key:"getInternalLoader",value:function(e){return this.loaders[e.type]}},{key:"resetInternalLoader",value:function(e){this.loaders[e]&&delete this.loaders[e]}},{key:"destroyInternalLoaders",value:function(){for(var e in this.loaders){var t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}},{key:"destroy",value:function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}},{key:"onManifestLoading",value:function(e,t){var i=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:RM,url:i,deliveryDirectives:null,levelOrTrack:null})}},{key:"onLevelLoading",value:function(e,t){var i=t.id,n=t.level,a=t.pathwayId,r=t.url,o=t.deliveryDirectives,s=t.levelInfo;this.load({id:i,level:n,pathwayId:a,responseType:"text",type:FM,url:r,deliveryDirectives:o,levelOrTrack:s})}},{key:"onAudioTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:WM,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onSubtitleTrackLoading",value:function(e,t){var i=t.id,n=t.groupId,a=t.url,r=t.deliveryDirectives,o=t.track;this.load({id:i,groupId:n,level:null,responseType:"text",type:OM,url:a,deliveryDirectives:r,levelOrTrack:o})}},{key:"onLevelsUpdated",value:function(e,t){var i=this.loaders[FM];if(i){var n=i.context;n&&!t.levels.some(e=>e===n.levelOrTrack)&&(i.abort(),delete this.loaders[FM])}}},{key:"load",value:function(e){var t,i,n,a=this.hls.config,r=this.getInternalLoader(e);if(r){var o=this.hls.logger,s=r.context;if(s&&s.levelOrTrack===e.levelOrTrack&&(s.url===e.url||s.deliveryDirectives&&!e.deliveryDirectives))return void(s.url===e.url?o.log(`[playlist-loader]: ignore ${e.url} ongoing request`):o.log(`[playlist-loader]: ignore ${e.url} in favor of ${s.url}`));o.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}if((i=e.type===RM?a.manifestLoadPolicy.default:HM({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),DM(null==(t=e.deliveryDirectives)?void 0:t.part))&&(e.type===FM&&null!==e.level?n=this.hls.levels[e.level].details:e.type===WM&&null!==e.id?n=this.hls.audioTracks[e.id].details:e.type===OM&&null!==e.id&&(n=this.hls.subtitleTracks[e.id].details),n)){var u=n.partTarget,l=n.targetduration;if(u&&l){var d=1e3*Math.max(3*u,.8*l);i=HM({},i,{maxTimeToFirstByteMs:Math.min(d,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,i.maxTimeToFirstByteMs)})}}var h=i.errorRetry||i.timeoutRetry||{},c={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},m={onSuccess:(e,t,i,n)=>{var a=this.getInternalLoader(i);this.resetInternalLoader(i.type);var r=e.data;t.parsing.start=performance.now(),vD.isMediaPlaylist(r)||i.type!==RM?this.handleTrackOrLevelPlaylist(e,t,i,n||null,a):this.handleMasterPlaylist(e,t,i,n)},onError:(e,t,i,n)=>{this.handleNetworkError(t,i,!1,e,n)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}};r.load(e,c,m)}},{key:"checkAutostartLoad",value:function(){if(this.hls){var e=this.hls,t=e.config,i=t.autoStartLoad,n=t.startPosition,a=e.forceStartLoad;(i||a)&&(this.hls.logger.log(`${i?"auto":"force"} startLoad with configured startPosition ${n}`),this.hls.startLoad(n))}}},{key:"handleMasterPlaylist",value:function(e,t,i,n){var a=this.hls,r=e.data,o=J_(e,i),s=vD.parseMasterPlaylist(r,o);if(s.playlistParsingError)return t.parsing.end=performance.now(),void this.handleManifestParsingError(e,i,s.playlistParsingError,n,t);var u=s.contentSteering,l=s.levels,d=s.sessionData,h=s.sessionKeys,c=s.startTimeOffset,m=s.variableList;this.variableList=m,l.forEach(e=>{var t=e.unknownCodecs;if(t)for(var i=this.hls.config.preferManagedMediaSource,n=e.audioCodec,a=e.videoCodec,r=t.length;r--;){var o=t[r];QT(o,"audio",i)?(e.audioCodec=n=n?`${n},${o}`:o,qT.audio[n.substring(0,4)]=2,t.splice(r,1)):QT(o,"video",i)&&(e.videoCodec=a=a?`${a},${o}`:o,qT.video[a.substring(0,4)]=2,t.splice(r,1))}});var f=vD.parseMasterPlaylistMedia(r,o,s),v=f.AUDIO,p=void 0===v?[]:v,g=f.SUBTITLES,y=f["CLOSED-CAPTIONS"];p.length&&(p.some(e=>!e.url)||!l[0].audioCodec||l[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new WA({}),bitrate:0,url:""})));a.trigger(_M.MANIFEST_LOADED,{levels:l,audioTracks:p,subtitles:g,captions:y,contentSteering:u,url:o,stats:t,networkDetails:n,sessionData:d,sessionKeys:h,startTimeOffset:c,variableList:m})}},{key:"handleTrackOrLevelPlaylist",value:function(e,t,i,n,a){var r=this.hls,o=i.id,s=i.level,u=i.type,l=J_(e,i),d=DM(s)?s:DM(o)?o:0,h=q_(i),c=vD.parseLevelPlaylist(e.data,l,d,h,0,this.variableList);if(u===RM){var m={attrs:new WA({}),bitrate:0,details:c,name:"",url:l};c.requestScheduled=t.loading.start+_D(c,0),r.trigger(_M.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:l,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=c,this.handlePlaylistLoaded(c,e,t,i,n,a)}},{key:"handleManifestParsingError",value:function(e,t,i,n,a){this.hls.trigger(_M.ERROR,{type:IM.NETWORK_ERROR,details:LM.MANIFEST_PARSING_ERROR,fatal:t.type===RM,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}},{key:"handleNetworkError",value:function(e,t,i=!1,n,a){var r=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===FM?r+=`: ${e.level} id: ${e.id}`:e.type!==WM&&e.type!==OM||(r+=` id: ${e.id} group-id: "${e.groupId}"`);var o=new Error(r);this.hls.logger.warn(`[playlist-loader]: ${r}`);var s=LM.UNKNOWN,u=!1,l=this.getInternalLoader(e);switch(e.type){case RM:s=i?LM.MANIFEST_LOAD_TIMEOUT:LM.MANIFEST_LOAD_ERROR,u=!0;break;case FM:s=i?LM.LEVEL_LOAD_TIMEOUT:LM.LEVEL_LOAD_ERROR,u=!1;break;case WM:s=i?LM.AUDIO_TRACK_LOAD_TIMEOUT:LM.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case OM:s=i?LM.SUBTITLE_TRACK_LOAD_TIMEOUT:LM.SUBTITLE_LOAD_ERROR,u=!1}l&&this.resetInternalLoader(e.type);var d={type:IM.NETWORK_ERROR,details:s,fatal:u,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(n){var h=(null==t?void 0:t.url)||e.url;d.response=VM({url:h,data:void 0},n)}this.hls.trigger(_M.ERROR,d)}},{key:"handlePlaylistLoaded",value:function(e,t,i,n,a,r){var o=this.hls,s=n.type,u=n.level,l=n.levelOrTrack,d=n.id,h=n.groupId,c=n.deliveryDirectives,m=J_(t,n),f=q_(n),v="number"==typeof n.level&&f===$M?u:void 0,p=e.playlistParsingError;if(p){if(this.hls.logger.warn(`${p} ${e.url}`),!o.config.ignorePlaylistParsingErrors)return void o.trigger(_M.ERROR,{type:IM.NETWORK_ERROR,details:LM.LEVEL_PARSING_ERROR,fatal:!1,url:m,error:p,reason:p.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i});e.playlistParsingError=null}if(e.fragments.length)switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case RM:case FM:if(v)if(l){if(l!==o.levels[v]){var g=o.levels.indexOf(l);g>-1&&(v=g)}}else v=0;o.trigger(_M.LEVEL_LOADED,{details:e,levelInfo:l||o.levels[0],level:v||0,id:d||0,stats:i,networkDetails:a,deliveryDirectives:c,withoutMultiVariant:s===RM});break;case WM:o.trigger(_M.AUDIO_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c});break;case OM:o.trigger(_M.SUBTITLE_TRACK_LOADED,{details:e,track:l,id:d||0,groupId:h||"",stats:i,networkDetails:a,deliveryDirectives:c})}else{var y=e.playlistParsingError=new Error("No Segments found in Playlist");o.trigger(_M.ERROR,{type:IM.NETWORK_ERROR,details:LM.LEVEL_EMPTY_ERROR,fatal:!1,url:m,error:y,reason:y.message,response:t,context:n,level:v,parent:f,networkDetails:a,stats:i})}}}])}(),Z_=function(){function e(t={}){Q(this,e),this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new cx,this._autoLevelCapping=-1,this._maxHdcpLevel=null,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.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;var i=this.logger=function(e,t,i){var n=qM();if("object"==typeof console&&!0===e||"object"==typeof e){var a=["debug","log","info","warn","error"];a.forEach(t=>{n[t]=JM(t,e,i)});try{n.log(`Debug logs enabled for "${t}" in hls.js version 1.6.16`)}catch(e){return qM()}a.forEach(t=>{QM[t]=JM(t,e)})}else HM(QM,n);return n}(t.debug||!1,"Hls instance",t.assetPlayerId),n=this.config=function(e,t,i){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var n=L_(e),a=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{var r=`${"level"===e?"playlist":e}LoadPolicy`,o=void 0===t[r],s=[];a.forEach(i=>{var a=`${e}Loading${i}`,u=t[a];if(void 0!==u&&o){s.push(a);var l=n[r].default;switch(t[r]={default:l},i){case"TimeOut":l.maxLoadTimeMs=u,l.maxTimeToFirstByteMs=u;break;case"MaxRetry":l.errorRetry.maxNumRetry=u,l.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":l.errorRetry.retryDelayMs=u,l.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":l.errorRetry.maxRetryDelayMs=u,l.timeoutRetry.maxRetryDelayMs=u}}}),s.length&&i.warn(`hls.js config: "${s.join('", "')}" setting(s) are deprecated, use "${r}": ${AP(t[r])}`)}),VM(VM({},n),t)}(e.DefaultConfig,t,i);this.userConfig=t,n.progressive&&__(n,i);var a=n.abrController,r=n.bufferController,o=n.capLevelController,s=n.errorController,u=n.fpsController,l=new s(this),d=this.abrController=new a(this),h=new dA(this),c=n.interstitialsController,m=c?this.interstitialsController=new c(this,e):null,f=this.bufferController=new r(this,h),v=this.capLevelController=new o(this),p=new u(this),g=new Q_(this),y=n.contentSteeringController,b=y?new y(this):null,w=this.levelController=new U_(this,b),k=new B_(this),S=new X_(this.config,this.logger),E=this.streamController=new K_(this,h,S),M=this.gapController=new R_(this,h);v.setStreamController(E),p.setStreamController(E);var T=[g,w,E];m&&T.splice(1,0,m),b&&T.splice(1,0,b),this.networkControllers=T;var P=[d,f,M,v,p,k,h];this.audioTrackController=this.createController(n.audioTrackController,T);var A=n.audioStreamController;A&&T.push(this.audioStreamController=new A(this,h,S)),this.subtitleTrackController=this.createController(n.subtitleTrackController,T);var D=n.subtitleStreamController;D&&T.push(this.subtititleStreamController=new D(this,h,S)),this.createController(n.timelineController,P),S.emeController=this.emeController=this.createController(n.emeController,P),this.cmcdController=this.createController(n.cmcdController,P),this.latencyController=this.createController(z_,P),this.coreComponents=P,T.push(l);var x=l.onErrorOut;"function"==typeof x&&this.on(_M.ERROR,x,l),this.on(_M.MANIFEST_LOADED,g.onManifestLoaded,g)}return ne(e,[{key:"createController",value:function(e,t){if(e){var i=new e(this);return t&&t.push(i),i}return null}},{key:"on",value:function(e,t,i=this){this._emitter.on(e,t,i)}},{key:"once",value:function(e,t,i=this){this._emitter.once(e,t,i)}},{key:"removeAllListeners",value:function(e){this._emitter.removeAllListeners(e)}},{key:"off",value:function(e,t,i=this,n){this._emitter.off(e,t,i,n)}},{key:"listeners",value:function(e){return this._emitter.listeners(e)}},{key:"emit",value:function(e,t,i){return this._emitter.emit(e,t,i)}},{key:"trigger",value:function(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(this.logger.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;var i=e===_M.ERROR;this.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.INTERNAL_EXCEPTION,fatal:i,event:e,error:t}),this.triggeringException=!1}}return!1}},{key:"listenerCount",value:function(e){return this._emitter.listenerCount(e)}},{key:"destroy",value:function(){this.logger.log("destroy"),this.trigger(_M.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}},{key:"attachMedia",value:function(e){if(!e||"media"in e&&!e.media){var t=new Error(`attachMedia failed: invalid argument (${e})`);this.trigger(_M.ERROR,{type:IM.OTHER_ERROR,details:LM.ATTACH_MEDIA_ERROR,fatal:!0,error:t})}else{this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());var i="media"in e,n=i?e.media:e,a=i?e:{media:n};this._media=n,this.trigger(_M.MEDIA_ATTACHING,a)}}},{key:"detachMedia",value:function(){this.logger.log("detachMedia"),this.trigger(_M.MEDIA_DETACHING,{}),this._media=null}},{key:"transferMedia",value:function(){this._media=null;var e=this.bufferController.transferMedia();return this.trigger(_M.MEDIA_DETACHING,{transferMedia:e}),e}},{key:"loadSource",value:function(e){this.stopLoad();var t=this.media,i=this._url,n=this._url=mT.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_M.MANIFEST_LOADING,{url:e})}},{key:"url",get:function(){return this._url}},{key:"hasEnoughToStart",get:function(){return this.streamController.hasEnoughToStart}},{key:"startPosition",get:function(){return this.streamController.startPositionValue}},{key:"startLoad",value:function(e=-1,t){this.logger.log(`startLoad(${e+(t?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(var i=0;i<this.networkControllers.length&&(this.networkControllers[i].startLoad(e,t),this.started&&this.networkControllers);i++);}},{key:"stopLoad",value:function(){this.logger.log("stopLoad"),this.started=!1;for(var e=0;e<this.networkControllers.length&&(this.networkControllers[e].stopLoad(),!this.started&&this.networkControllers);e++);}},{key:"loadingEnabled",get:function(){return this.started}},{key:"bufferingEnabled",get:function(){return this.streamController.bufferingEnabled}},{key:"resumeBuffering",value:function(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(e=>{e.resumeBuffering&&e.resumeBuffering()}))}},{key:"pauseBuffering",value:function(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(e=>{e.pauseBuffering&&e.pauseBuffering()}))}},{key:"inFlightFragments",get:function(){var e={[$M]:this.streamController.inFlightFrag};return this.audioStreamController&&(e[NM]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(e[jM]=this.subtititleStreamController.inFlightFrag),e}},{key:"swapAudioCodec",value:function(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}},{key:"recoverMediaError",value:function(){this.logger.log("recoverMediaError");var e=this._media,t=null==e?void 0:e.currentTime;this.detachMedia(),e&&(this.attachMedia(e),t&&this.startLoad(t))}},{key:"removeLevel",value:function(e){this.levelController.removeLevel(e)}},{key:"sessionId",get:function(){var e=this._sessionId;return e||(e=this._sessionId=function(){try{return crypto.randomUUID()}catch(a){try{var e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){var i=(new Date).getTime(),n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{var t=(i+16*Math.random())%16|0;return i=Math.floor(i/16),("x"==e?t:3&t|8).toString(16)});return n}}}()),e}},{key:"levels",get:function(){var e=this.levelController.levels;return e||[]}},{key:"latestLevelDetails",get:function(){return this.streamController.getLevelDetails()||null}},{key:"loadLevelObj",get:function(){return this.levelController.loadLevelObj}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(e){this.logger.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(e){this.logger.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(e){this.logger.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(e){this.levelController.nextLoadLevel=e}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(e){this.logger.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}},{key:"startLevel",get:function(){var e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e},set:function(e){this.logger.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(e){var t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(e){this._autoLevelCapping!==e&&(this.logger.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimate():NaN},set:function(e){this.abrController.resetEstimator(e)}},{key:"abrEwmaDefaultEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.defaultEstimate:NaN}},{key:"ttfbEstimate",get:function(){var e=this.abrController.bwEstimator;return e?e.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(e){(function(e){return gP.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var e=this.levels,t=this.config.minAutoBitrate;if(!e)return 0;for(var i=e.length,n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}},{key:"maxAutoLevel",get:function(){var e,t=this.levels,i=this.autoLevelCapping,n=this.maxHdcpLevel;if(e=-1===i&&null!=t&&t.length?t.length-1:i,n)for(var a=e;a--;){var r=t[a].attrs["HDCP-LEVEL"];if(r&&r<=n)return a}return e}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(e){this.abrController.nextAutoLevel=e}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"maxBufferLength",get:function(){return this.streamController.maxBufferLength}},{key:"setAudioOption",value:function(e){var t;return(null==(t=this.audioTrackController)?void 0:t.setAudioOption(e))||null}},{key:"setSubtitleOption",value:function(e){var t;return(null==(t=this.subtitleTrackController)?void 0:t.setSubtitleOption(e))||null}},{key:"allAudioTracks",get:function(){var e=this.audioTrackController;return e?e.allAudioTracks:[]}},{key:"audioTracks",get:function(){var e=this.audioTrackController;return e?e.audioTracks:[]}},{key:"audioTrack",get:function(){var e=this.audioTrackController;return e?e.audioTrack:-1},set:function(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}},{key:"allSubtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay},set:function(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(e){this.config.lowLatencyMode=e}},{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},set:function(e){this.latencyController.targetLatency=e}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}},{key:"pathways",get:function(){return this.levelController.pathways}},{key:"pathwayPriority",get:function(){return this.levelController.pathwayPriority},set:function(e){this.levelController.pathwayPriority=e}},{key:"bufferedToEnd",get:function(){var e;return!(null==(e=this.bufferController)||!e.bufferedToEnd)}},{key:"interstitialsManager",get:function(){var e;return(null==(e=this.interstitialsController)?void 0:e.interstitialsManager)||null}},{key:"getMediaDecodingInfo",value:function(e,t=this.allAudioTracks){return fP(e,xP(t),navigator.mediaCapabilities)}}],[{key:"version",get:function(){return mx}},{key:"isMSESupported",value:function(){return V_()}},{key:"isSupported",value:function(){return function(){if(!V_())return!1;var e=eT();return"function"==typeof(null==e?void 0:e.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(t=>e.isTypeSupported(eP(t,"video")))||["mp4a.40.2","fLaC"].some(t=>e.isTypeSupported(eP(t,"audio"))))}()}},{key:"getMediaSource",value:function(){return eT()}},{key:"Events",get:function(){return _M}},{key:"MetadataSchema",get:function(){return Wx}},{key:"ErrorTypes",get:function(){return IM}},{key:"ErrorDetails",get:function(){return LM}},{key:"DefaultConfig",get:function(){return e.defaultConfig?e.defaultConfig:I_},set:function(t){e.defaultConfig=t}}])}();Z_.defaultConfig=void 0;var eR,tR=e=>e,iR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.bgVideo=!1,t}return ue(e,lu),ne(e,[{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),ps.instance&&(ps.instance.removeVideoEvents(),ps.instance=null)}},{key:"styles",value:function(){var e,t,i=this.component,n=i.url,a=i.imageCropping,r=i.alignment,o=i.rightMargin,s=i.spacing,u="fit"===a,l=null!==(e=null===(t=this.getRootNode().host)||void 0===t?void 0:t.tagName.toLowerCase())&&void 0!==e?e:"";this.bgVideo=l.includes("background");var d=u?"":U(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return U(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${n});\n background-size: ${u?"contain":"cover"};\n background-position: ${r||""} center;\n background-repeat: no-repeat;\n ${Lu(this.component,this.scaleFactor)};\n margin-right: ${o||s||0}px;\n ${Ou(this.component,this.scaleFactor,!1)}\n ${this.component.hidden?"display:none;":""}\n ${d}\n }\n :host(:focus) {\n ${Ou(this.component,this.scaleFactor,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n #nami-video {\n ${Lu(this.component,this.scaleFactor)};\n object-fit: ${u?"contain":"cover"};\n }\n `)}},{key:"loadMediaSrc",value:function(e){var t=this.component.url;if(t&&!t.includes(r)&&e.src!==t)if(!t.includes("m3u8")||e.canPlayType("application/vnd.apple.mpegurl"))e.src=t;else if(Z_.isSupported()){var i=new Z_;i.loadSource(t),i.attachMedia(e)}}},{key:"updated",value:function(){var e,t;Object.keys(this.component).forEach(e=>{this.component[e]=ja(this.contextProvider,this.component[e])});var i=this.component,n=i.id,a=i.title,r=i.autoplayVideo,o=i.mute,s=i.loopVideo,u=i.controlsType,l=i.fallbackImage,d=null===(e=this.shadowRoot)||void 0===e?void 0:e.getElementById("nami-video");d&&(d.autoplay=null!=r&&r,d.loop=null!=s&&s,d.muted=null!=o&&o,d.controls="none"!==u,d.poster=null!=l?l:"",d.playsInline=null!=r?r:this.bgVideo,this.loadMediaSrc(d),null===(t=ps.instance)||void 0===t||t.removeVideoEvents(),ps.instance=new ps(this.contextProvider,d,a,n))}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor,r=t.screenreaderText,o=t.title;return this.ariaLabel=null!==(e=null!=r?r:o)&&void 0!==e?e:"",!i&&Ka(a,n)||(this.tabIndex=0),B(eR||(eR=tR`<video id="nami-video" preload="auto"></video>`))}}])}();gt([qt({type:Object})],iR.prototype,"component",void 0),gt([qt({type:Boolean})],iR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],iR.prototype,"scaleFactor",void 0),iR=gt([Tt("nami-video")],iR);var nR,aR=e=>e,rR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.height=0,t.scaleFactor=1,t.isCollapsed=!0,t._handleClick=()=>{var e,i;t.isCollapsed=!t.isCollapsed,t.contextProvider.setOpenHeaderIds(t.component.id||"",t.component.sku),t.height=(null===(e=t.shadowRoot)||void 0===e||null===(e=e.getElementById("collapse"))||void 0===e?void 0:e.scrollHeight)||0,null===(i=t.shadowRoot)||void 0===i||null===(i=i.getElementById("collapse"))||void 0===i||i.classList.toggle("hidden")},t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component,t=this.height,i=this.scaleFactor,n=e.backgroundBlur,a="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${Mu(e,!1)};\n ${Tu(this.component)}\n ${Ou(e,i,!1)}\n cursor: pointer;\n }\n :host > *:not(:first-child) {\n ${a}: ${e.spacing?e.spacing*i:0}px;\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,i,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n overflow: hidden;\n padding: 0;\n margin: 0;\n }\n #collapse {\n ${Lu(e,i)}\n max-height: ${t}px;\n opacity: 1;\n transition: all linear 0.5s;\n overflow: hidden;\n }\n #collapse-btn{\n background: transparent;\n border: none;\n width: 100%;\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.components,i=e.collapseHeader,n=e.focusedBorderColor,a=e.focusedFillColor,r=e.fillColor;!n&&Ka(r,a)||(this.tabIndex=0);var o=t.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion));return B(nR||(nR=aR`
|
|
471
471
|
<button
|
|
472
472
|
id="collapse-btn"
|
|
473
473
|
aria-label="${0}"
|
|
@@ -485,18 +485,18 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
485
485
|
>
|
|
486
486
|
${0}
|
|
487
487
|
</div>
|
|
488
|
-
`),this.isCollapsed?"Expand":"Collapse",!this.isCollapsed,this._handleClick,kl(this.contextProvider,i,this.scaleFactor,this.inFocusedState,this.minSDKVersion),this.isCollapsed,this.isCollapsed?"-1":"0",o)}}])}();gt([qt({type:Object})],
|
|
488
|
+
`),this.isCollapsed?"Expand":"Collapse",!this.isCollapsed,this._handleClick,kl(this.contextProvider,i,this.scaleFactor,this.inFocusedState,this.minSDKVersion),this.isCollapsed,this.isCollapsed?"-1":"0",o)}}])}();gt([qt({type:Object})],rR.prototype,"component",void 0),gt([qt({type:Boolean})],rR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],rR.prototype,"height",void 0),gt([qt({type:Number})],rR.prototype,"scaleFactor",void 0),gt([qt({type:Object})],rR.prototype,"minSDKVersion",void 0),rR=gt([Tt("nami-collapse-container")],rR);var oR,sR,uR,lR,dR,hR,cR,mR=e=>e,fR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.timelineDots=[],t.railHeight=0,t.mouseDown=!1,t.startDragging=e=>{e.preventDefault(),t.mouseDown=!0,t.startX=e.pageX-t.offsetLeft},t.stopDragging=()=>{t.mouseDown=!1},t.move=e=>{e.preventDefault(),t.mouseDown&&(t.scrollLeft=t.scrollLeft-(e.pageX-t.offsetLeft-t.startX))},t._rowMouseDown=!1,t._rowStartX=0,t._rowStartDragging=e=>{e.preventDefault(),t._rowMouseDown=!0,t._rowStartX=e.pageX},t._rowStopDragging=()=>{t._rowMouseDown=!1},t._rowMove=e=>{(e.preventDefault(),t._rowMouseDown)&&(e.currentTarget.scrollLeft-=e.pageX-t._rowStartX,t._rowStartX=e.pageX)},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.addEventListener("mousemove",this.move,!1),this.addEventListener("mousedown",this.startDragging,!1),this.addEventListener("mouseup",this.stopDragging,!1),this.addEventListener("mouseleave",this.stopDragging,!1)}},{key:"disconnectedCallback",value:function(){var t;pe(e,"disconnectedCallback",this)([]),this.removeEventListener("mousemove",this.move,!1),this.removeEventListener("mousedown",this.startDragging,!1),this.removeEventListener("mouseup",this.stopDragging,!1),this.removeEventListener("mouseleave",this.stopDragging,!1),null===(t=this.timelineResizeObserver)||void 0===t||t.disconnect()}},{key:"isGroupedHorizontal",value:function(){return"horizontal"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate}},{key:"isTimelineActive",value:function(){return!!this.component.timeline&&Xa(this.component.timeline).width>0&&"vertical"===this.component.direction&&!!this.component.groupBy&&!!this.component.groupHeaderTemplate&&"television"!==c()}},{key:"styles",value:function(){var e="vertical"===this.component.direction,t=this.isGroupedHorizontal(),i=e?"margin-top":"margin-left",n=this.component.spacing?this.component.spacing*this.scaleFactor:0;if(this.isTimelineActive()){var a=Xa(this.component.timeline),r=(a.width+a.railSpacing)*this.scaleFactor+bu(1,this.component.leftPadding);return U(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n position: relative;\n grid-auto-flow: row;\n grid-template-columns: minmax(0, 1fr);\n grid-gap: ${n}px;\n align-items: center;\n justify-items: stretch;\n overflow: visible;\n ${Mu(this.component,!1)}\n ${$u(this.component,!1)}\n align-self: baseline;\n box-sizing: border-box;\n padding-left: ${r}px;\n }\n :host(:focus) {\n ${Mu(this.component,!0)}\n ${$u(this.component,!0)}\n padding-left: ${r}px;\n }\n :host(:focus-visible) { ${Uu(this.component)} }\n .nami-group-header { width: 100%; }\n .nami-timeline-rail {\n position: absolute;\n top: 0; bottom: 0; left: 0;\n width: ${a.width*this.scaleFactor}px;\n pointer-events: none;\n }\n .nami-timeline-line, .nami-timeline-dot {\n position: absolute;\n box-sizing: border-box;\n }\n `)}return U(t?`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: column;\n overflow: visible;\n ${Mu(this.component,!1)}\n ${$u(this.component,!1)}\n align-self: baseline;\n }\n :host(:focus) {\n ${Mu(this.component,!0)}\n ${$u(this.component,!0)}\n }\n :host(:focus-visible) {\n ${Uu(this.component)}\n }\n .nami-group-header {\n width: 100%;\n }\n .nami-group-items-row {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n align-items: flex-start;\n overflow-x: auto;\n width: 100%;\n cursor: -webkit-grab;\n cursor: grab;\n gap: ${n}px;\n }\n .nami-group-items-row > * {\n flex: 0 0 auto;\n }\n `:`\n :host {\n display: ${this.component.hidden?"none":"flex"};\n flex-direction: ${e?"column":"row"};\n flex-wrap: ${e?"nowrap":"wrap"};\n overflow: auto;\n align-items: center;\n justify-content: center;\n ${Mu(this.component,!1)}\n ${$u(this.component,!1)}\n align-self: baseline;\n cursor: -webkit-grab;\n cursor: grab;\n }\n :host(:focus){\n ${Mu(this.component,!0)}\n ${$u(this.component,!0)}\n }\n :host(:focus-visible){\n ${Uu(this.component)}\n }\n @supports not (display: grid) {\n :host > *:not(:first-child) {\n ${i}: ${n}px;\n }\n }\n @supports (display: grid) {\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-row-gap: ${n}px;\n grid-column-gap: ${n}px;\n grid-gap: ${n}px;\n grid-auto-flow: ${e?"row":"column"};\n ${e?"grid-template-columns: minmax(0, 1fr);":""}\n align-items: center;\n justify-items: center;\n place-items: center;\n }\n :host > * {\n margin: 0;\n }\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.focusedBorderColor,i=e.focusedFillColor,n=e.fillColor;!t&&Ka(n,i)||(this.tabIndex=0);var a,r,o=e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion);if(this.isTimelineActive()){var s=Xa(this.component.timeline),u=this.scaleFactor,l=Oa(this.contextProvider,this.component),d=new Map(l.map(e=>[e.key,Ya(this.contextProvider,this.component.timeline,e.key)])),h=function(e){var t=e.lineTopOffset,i=e.railHeight-e.lineBottomOffset;if(i<=t)return[];for(var n,a=e.dots.map(t=>[t.centerY-t.size/2-e.dotLineSpacing,t.centerY+t.size/2+e.dotLineSpacing]).sort((e,t)=>e[0]-t[0]),r=[],o=t,s=ae(a);!(n=s()).done;){var u=n.value,l=u[0],d=u[1];l>o&&r.push({top:o,height:l-o}),o=Math.max(o,d)}return i>o&&r.push({top:o,height:i-o}),r.filter(e=>e.height>0)}({railHeight:this.railHeight,lineTopOffset:s.lineTopOffset*u,lineBottomOffset:s.lineBottomOffset*u,dotLineSpacing:s.dotLineSpacing*u,dots:this.timelineDots.map(e=>{var t,i;return{centerY:e.centerY,size:(null!==(t=null===(i=d.get(e.key))||void 0===i?void 0:i.dotSize)&&void 0!==t?t:s.dotSize)*u}})}),c=s.width*u/2;return B(oR||(oR=mR`
|
|
489
489
|
<div class="nami-timeline-rail">
|
|
490
490
|
${0}
|
|
491
491
|
${0}
|
|
492
492
|
</div>
|
|
493
493
|
${0}
|
|
494
|
-
`),h.map(e=>B(
|
|
494
|
+
`),h.map(e=>B(sR||(sR=mR`
|
|
495
495
|
<div class="nami-timeline-line" style="left:${0}px;top:${0}px;width:${0}px;height:${0}px;background:${0};border-radius:${0}px;"></div>
|
|
496
|
-
`),c-s.lineWidth*u/2,e.top,s.lineWidth*u,e.height,s.lineColor,s.lineCornerRadius*u)),this.timelineDots.map(e=>{var t=d.get(e.key);if(!t)return null;var i=t.dotSize*u;return B(
|
|
496
|
+
`),c-s.lineWidth*u/2,e.top,s.lineWidth*u,e.height,s.lineColor,s.lineCornerRadius*u)),this.timelineDots.map(e=>{var t=d.get(e.key);if(!t)return null;var i=t.dotSize*u;return B(uR||(uR=mR`<div class="nami-timeline-dot" style="left:${0}px;top:${0}px;width:${0}px;height:${0}px;background:${0};border-radius:${0}px;${0}"></div>`),c-i/2,e.centerY-i/2,i,i,t.dotColor,t.dotCornerRadius*u,t.dotBorderWidth>0?`border:${t.dotBorderWidth*u}px solid ${t.dotBorderColor};`:"")}),l.map(e=>B(lR||(lR=mR`
|
|
497
497
|
${0}
|
|
498
498
|
${0}
|
|
499
|
-
`),e.header?B(
|
|
499
|
+
`),e.header?B(dR||(dR=mR`<div class="nami-group-header" data-group-key=${0}>${0}</div>`),e.key,e.header.map(o)):null,e.items.map(e=>e.map(o)))))}return this.isGroupedHorizontal()?Oa(this.contextProvider,this.component).map(e=>B(hR||(hR=mR`
|
|
500
500
|
${0}
|
|
501
501
|
<div
|
|
502
502
|
class="nami-group-items-row"
|
|
@@ -507,10 +507,10 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
507
507
|
>
|
|
508
508
|
${0}
|
|
509
509
|
</div>
|
|
510
|
-
`),e.header?B(
|
|
510
|
+
`),e.header?B(cR||(cR=mR`<div class="nami-group-header">${0}</div>`),e.header.map(o)):null,this._rowStartDragging,this._rowMove,this._rowStopDragging,this._rowStopDragging,e.items.map(e=>e.map(o)))):(a=this.contextProvider,r=this.component,Oa(a,r).flatMap(e=>e.header?[e.header,...e.items]:e.items)).map(e=>e.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion)))}},{key:"updated",value:function(){this.isTimelineActive()&&this.measureTimeline()}},{key:"measureTimeline",value:function(){this.renderRoot.querySelector(".nami-timeline-rail")&&("undefined"==typeof ResizeObserver||this.timelineResizeObserver||(this.timelineResizeObserver=new ResizeObserver(()=>this.readTimelineGeometry()),this.timelineResizeObserver.observe(this),this.renderRoot.querySelectorAll(".nami-group-header").forEach(e=>{this.timelineResizeObserver.observe(e)})),this.readTimelineGeometry())}},{key:"readTimelineGeometry",value:function(){var e=this.renderRoot.querySelector(".nami-timeline-rail");if(e){var t=e.getBoundingClientRect(),i=Array.from(this.renderRoot.querySelectorAll(".nami-group-header")).map(e=>{var i,n=e.getBoundingClientRect();return{key:null!==(i=e.dataset.groupKey)&&void 0!==i?i:"",centerY:n.top+n.height/2-t.top}}),n=t.height,a=Math.abs(n-this.railHeight)>.5||i.length!==this.timelineDots.length||i.some((e,t)=>{var i;return e.key!==(null===(i=this.timelineDots[t])||void 0===i?void 0:i.key)||Math.abs(e.centerY-this.timelineDots[t].centerY)>.5});a&&(this.railHeight=n,this.timelineDots=i)}}}])}();gt([qt({type:Object})],fR.prototype,"component",void 0),gt([qt({type:Boolean})],fR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],fR.prototype,"scaleFactor",void 0),gt([qt({type:Object})],fR.prototype,"minSDKVersion",void 0),gt([Jt()],fR.prototype,"timelineDots",void 0),gt([Jt()],fR.prototype,"railHeight",void 0),fR=gt([Tt("nami-responsive-grid")],fR);var vR,pR,gR=e=>e,yR=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e,t,i,n,a=Math.max(1,null!==(e=this.component.columns)&&void 0!==e?e:2),r=(null!==(t=this.component.columnSpacing)&&void 0!==t?t:0)*this.scaleFactor,o=(null!==(i=this.component.rowSpacing)&&void 0!==i?i:0)*this.scaleFactor,s=null!==(n=this.component.itemAlignment)&&void 0!==n?n:"start";return U(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-template-columns: repeat(${a}, 1fr);\n column-gap: ${r}px;\n row-gap: ${o}px;\n justify-items: ${s};\n ${Mu(this.component,!1)}\n ${$u(this.component,!1)}\n }\n .nami-group-header {\n grid-column: 1 / -1;\n justify-self: stretch;\n }\n :host(:focus) {\n ${Mu(this.component,!0)}\n ${$u(this.component,!0)}\n }\n :host(:focus-visible) {\n ${Uu(this.component)}\n }\n `)}},{key:"render",value:function(){var e=this.component,t=e.focusedBorderColor,i=e.focusedFillColor,n=e.fillColor;!t&&Ka(n,i)||(this.tabIndex=0);var a=e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion);return Oa(this.contextProvider,this.component).map(e=>B(vR||(vR=gR`
|
|
511
511
|
${0}
|
|
512
512
|
${0}
|
|
513
|
-
`),e.header?B(vR||(vR=pR`<div class="nami-group-header">${0}</div>`),e.header.map(a)):null,e.items.map(e=>e.map(a))))}}])}();function yR(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function bR(e={},t={}){var i=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>i.indexOf(e)<0).forEach(i=>{void 0===e[i]?e[i]=t[i]:yR(t[i])&&yR(e[i])&&Object.keys(t[i]).length>0&&bR(e[i],t[i])})}gt([qt({type:Object})],gR.prototype,"component",void 0),gt([qt({type:Boolean})],gR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],gR.prototype,"scaleFactor",void 0),gt([qt({type:Object})],gR.prototype,"minSDKVersion",void 0),gR=gt([Tt("nami-repeating-grid")],gR);var wR={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function kR(){var e="undefined"!=typeof document?document:{};return bR(e,wR),e}var SR,ER,MR,TR={document:wR,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function PR(){var e="undefined"!=typeof window?window:{};return bR(e,TR),e}function AR(e,t=0){return setTimeout(e,t)}function DR(){return Date.now()}function xR(e,t="x"){var i,n,a,r=PR(),o=function(e){var t,i=PR();return i.getComputedStyle&&(t=i.getComputedStyle(e,null)),!t&&e.currentStyle&&(t=e.currentStyle),t||(t=e.style),t}(e);return r.WebKitCSSMatrix?((n=o.transform||o.webkitTransform).split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),a=new r.WebKitCSSMatrix("none"===n?"":n)):i=(a=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,")).toString().split(","),"x"===t&&(n=r.WebKitCSSMatrix?a.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?a.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function CR(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function IR(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function LR(...e){for(var t=Object(e[0]),i=1;i<e.length;i+=1){var n=e[i];if(null!=n&&!IR(n))for(var a=Object.keys(Object(n)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e),r=0,o=a.length;r<o;r+=1){var s=a[r],u=Object.getOwnPropertyDescriptor(n,s);void 0!==u&&u.enumerable&&(CR(t[s])&&CR(n[s])?n[s].__swiper__?t[s]=n[s]:LR(t[s],n[s]):!CR(t[s])&&CR(n[s])?(t[s]={},n[s].__swiper__?t[s]=n[s]:LR(t[s],n[s])):t[s]=n[s])}}return t}function _R(e,t,i){e.style.setProperty(t,i)}function RR({swiper:e,targetPosition:t,side:i}){var n,a=PR(),r=-e.translate,o=null,s=e.params.speed;e.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(e.cssModeFrameID);var u=t>r?"next":"prev",l=(e,t)=>"next"===u&&e>=t||"prev"===u&&e<=t,d=()=>{n=(new Date).getTime(),null===o&&(o=n);var u=Math.max(Math.min((n-o)/s,1),0),h=.5-Math.cos(u*Math.PI)/2,c=r+h*(t-r);if(l(c,t)&&(c=t),e.wrapperEl.scrollTo({[i]:c}),l(c,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:c})}),void a.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=a.requestAnimationFrame(d)};d()}function FR(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function WR(e,t=""){var i=PR(),n=[...e.children];return i.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function OR(e){try{return void console.warn(e)}catch(e){}}function $R(e,t=[]){var i=document.createElement(e);return i.classList.add(...Array.isArray(t)?t:function(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}(t)),i}function NR(e,t){return PR().getComputedStyle(e,null).getPropertyValue(t)}function jR(e){var t,i=e;if(i){for(t=0;null!==(i=i.previousSibling);)1===i.nodeType&&(t+=1);return t}}function BR(e,t){for(var i=[],n=e.parentElement;n;)t?n.matches(t)&&i.push(n):i.push(n),n=n.parentElement;return i}function zR(e,t,i){var n=PR();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function UR(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function HR(e,t=""){"undefined"!=typeof trustedTypes?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:e=>e}).createHTML(t):e.innerHTML=t}function GR(){return SR||(SR=function(){var e=PR(),t=kR();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),SR}function VR(e={}){return ER||(ER=function({userAgent:e}={}){var t=GR(),i=PR(),n=i.navigator.platform,a=e||i.navigator.userAgent,r={ios:!1,android:!1},o=i.screen.width,s=i.screen.height,u=a.match(/(Android);?[\s\/]+([\d.]+)?/),l=a.match(/(iPad)(?!\1).*OS\s([\d_]+)/),d=a.match(/(iPod)(.*OS\s([\d_]+))?/),h=!l&&a.match(/(iPhone\sOS|iOS)\s([\d_]+)/),c="Win32"===n,m="MacIntel"===n;return!l&&m&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${s}`)>=0&&((l=a.match(/(Version)\/([\d.]+)/))||(l=[0,1,"13_0_0"]),m=!1),u&&!c&&(r.os="android",r.android=!0),(l||h||d)&&(r.os="ios",r.ios=!0),r}(e)),ER}function KR(){return MR||(MR=function(){var e=PR(),t=VR(),i=!1;function n(){var t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(n()){var a=String(e.navigator.userAgent);if(a.includes("Version/")){var r=a.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e)),o=r[0],s=r[1];i=o<16||16===o&&s<2}}var u=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),l=n();return{isSafari:i||l,needPerspectiveFix:i,need3dFix:l||u&&t.ios,isWebView:u}}()),MR}var XR={on(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;var a=i?"unshift":"push";return e.split(" ").forEach(e=>{n.eventsListeners[e]||(n.eventsListeners[e]=[]),n.eventsListeners[e][a](t)}),n},once(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;function a(...i){n.off(e,a),a.__emitterProxy&&delete a.__emitterProxy,t.apply(n,i)}return a.__emitterProxy=t,n.on(e,a,i)},onAny(e,t){var i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;var n=t?"unshift":"push";return i.eventsAnyListeners.indexOf(e)<0&&i.eventsAnyListeners[n](e),i},offAny(e){var t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;var i=t.eventsAnyListeners.indexOf(e);return i>=0&&t.eventsAnyListeners.splice(i,1),t},off(e,t){var i=this;return!i.eventsListeners||i.destroyed?i:i.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?i.eventsListeners[e]=[]:i.eventsListeners[e]&&i.eventsListeners[e].forEach((n,a)=>{(n===t||n.__emitterProxy&&n.__emitterProxy===t)&&i.eventsListeners[e].splice(a,1)})}),i):i},emit(...e){var t,i,n,a=this;return!a.eventsListeners||a.destroyed?a:a.eventsListeners?("string"==typeof e[0]||Array.isArray(e[0])?(t=e[0],i=e.slice(1,e.length),n=a):(t=e[0].events,i=e[0].data,n=e[0].context||a),i.unshift(n),(Array.isArray(t)?t:t.split(" ")).forEach(e=>{a.eventsAnyListeners&&a.eventsAnyListeners.length&&a.eventsAnyListeners.forEach(t=>{t.apply(n,[e,...i])}),a.eventsListeners&&a.eventsListeners[e]&&a.eventsListeners[e].forEach(e=>{e.apply(n,i)})}),a):a}};var YR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var qR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var JR=(e,t)=>{if(e&&!e.destroyed&&e.params){var i=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(i){var n=i.querySelector(`.${e.params.lazyPreloaderClass}`);!n&&e.isElement&&(i.shadowRoot?n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`))&&!n.lazyPreloaderManaged&&n.remove()})),n&&!n.lazyPreloaderManaged&&n.remove()}}},QR=(e,t)=>{if(e.slides[t]){var i=e.slides[t].querySelector('[loading="lazy"]');i&&i.removeAttribute("loading")}},ZR=e=>{if(e&&!e.destroyed&&e.params){var t=e.params.lazyPreloadPrevNext,i=e.slides.length;if(i&&t&&!(t<0)){t=Math.min(t,i);var n="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){var r=a,o=[r-t];return o.push(...Array.from({length:t}).map((e,t)=>r+n+t)),void e.slides.forEach((t,i)=>{o.includes(t.column)&&QR(e,i)})}var s=a+n-1;if(e.params.rewind||e.params.loop)for(var u=a-t;u<=s+t;u+=1){var l=(u%i+i)%i;(l<a||l>s)&&QR(e,l)}else for(var d=Math.max(a-t,0);d<=Math.min(s+t,i-1);d+=1)d!==a&&(d>s||d<a)&&QR(e,d)}}};var eF={updateSize:function(){var e,t,i=this,n=i.el;e=void 0!==i.params.width&&null!==i.params.width?i.params.width:n.clientWidth,t=void 0!==i.params.height&&null!==i.params.height?i.params.height:n.clientHeight,0===e&&i.isHorizontal()||0===t&&i.isVertical()||(e=e-parseInt(NR(n,"padding-left")||0,10)-parseInt(NR(n,"padding-right")||0,10),t=t-parseInt(NR(n,"padding-top")||0,10)-parseInt(NR(n,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(i,{width:e,height:t,size:i.isHorizontal()?e:t}))},updateSlides:function(){var e=this;function t(t,i){return parseFloat(t.getPropertyValue(e.getDirectionLabel(i))||0)}var i=e.params,n=e.wrapperEl,a=e.slidesEl,r=e.rtlTranslate,o=e.wrongRTL,s=e.virtual&&i.virtual.enabled,u=s?e.virtual.slides.length:e.slides.length,l=WR(a,`.${e.params.slideClass}, swiper-slide`),d=s?e.virtual.slides.length:l.length,h=[],c=[],m=[],f=i.slidesOffsetBefore;"function"==typeof f&&(f=i.slidesOffsetBefore.call(e));var v=i.slidesOffsetAfter;"function"==typeof v&&(v=i.slidesOffsetAfter.call(e));var p=e.snapGrid.length,g=e.slidesGrid.length,y=e.size-f-v,b=i.spaceBetween,w=-f,k=0,S=0;if(void 0!==y){"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*y:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b-f-v,l.forEach(e=>{r?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),i.centeredSlides&&i.cssMode&&(_R(n,"--swiper-centered-offset-before",""),_R(n,"--swiper-centered-offset-after","")),i.cssMode&&(_R(n,"--swiper-slides-offset-before",`${f}px`),_R(n,"--swiper-slides-offset-after",`${v}px`));var E,M=i.grid&&i.grid.rows>1&&e.grid;M?e.grid.initSlides(l):e.grid&&e.grid.unsetSlides();for(var T="auto"===i.slidesPerView&&i.breakpoints&&Object.keys(i.breakpoints).filter(e=>void 0!==i.breakpoints[e].slidesPerView).length>0,P=0;P<d;P+=1){E=0;var A=l[P];if(!A||(M&&e.grid.updateSlide(P,A,l),"none"!==NR(A,"display"))){if(s&&"auto"===i.slidesPerView)i.virtual.slidesPerViewAutoSlideSize&&(E=i.virtual.slidesPerViewAutoSlideSize),E&&A&&(i.roundLengths&&(E=Math.floor(E)),A.style[e.getDirectionLabel("width")]=`${E}px`);else if("auto"===i.slidesPerView){T&&(A.style[e.getDirectionLabel("width")]="");var D=getComputedStyle(A),x=A.style.transform,C=A.style.webkitTransform;if(x&&(A.style.transform="none"),C&&(A.style.webkitTransform="none"),i.roundLengths)E=e.isHorizontal()?zR(A,"width"):zR(A,"height");else{var I=t(D,"width"),L=t(D,"padding-left"),_=t(D,"padding-right"),R=t(D,"margin-left"),F=t(D,"margin-right"),W=D.getPropertyValue("box-sizing");if(W&&"border-box"===W)E=I+R+F;else{var O=A.clientWidth;E=I+L+_+R+F+(A.offsetWidth-O)}}x&&(A.style.transform=x),C&&(A.style.webkitTransform=C),i.roundLengths&&(E=Math.floor(E))}else E=(y-(i.slidesPerView-1)*b)/i.slidesPerView,i.roundLengths&&(E=Math.floor(E)),A&&(A.style[e.getDirectionLabel("width")]=`${E}px`);A&&(A.swiperSlideSize=E),m.push(E),i.centeredSlides?(w=w+E/2+k/2+b,0===k&&0!==P&&(w=w-y/2-b),0===P&&(w=w-y/2-b),Math.abs(w)<.001&&(w=0),i.roundLengths&&(w=Math.floor(w)),S%i.slidesPerGroup===0&&h.push(w),c.push(w)):(i.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(w),c.push(w),w=w+E+b),e.virtualSize+=E+b,k=E,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,y)+v,r&&o&&("slide"===i.effect||"coverflow"===i.effect)&&(n.style.width=`${e.virtualSize+b}px`),i.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),M&&e.grid.updateWrapperSize(E,h),!i.centeredSlides){var $="auto"!==i.slidesPerView&&i.slidesPerView%1!=0,N=i.snapToSlideEdge&&!i.loop&&("auto"===i.slidesPerView||$),j=h.length;if(N){var B;if("auto"===i.slidesPerView){B=1;for(var z=0,U=m.length-1;U>=0&&(z+=m[U]+(U<m.length-1?b:0))<=y;U-=1)B=m.length-U}else B=Math.floor(i.slidesPerView);j=Math.max(d-B,0)}for(var H=[],G=0;G<h.length;G+=1){var V=h[G];i.roundLengths&&(V=Math.floor(V)),N?G<=j&&H.push(V):h[G]<=e.virtualSize-y&&H.push(V)}h=H,Math.floor(e.virtualSize-y)-Math.floor(h[h.length-1])>1&&(N||h.push(e.virtualSize-y))}if(s&&i.loop){var K=m[0]+b;if(i.slidesPerGroup>1)for(var X=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/i.slidesPerGroup),Y=K*i.slidesPerGroup,q=0;q<X;q+=1)h.push(h[h.length-1]+Y);for(var J=0;J<e.virtual.slidesBefore+e.virtual.slidesAfter;J+=1)1===i.slidesPerGroup&&h.push(h[h.length-1]+K),c.push(c[c.length-1]+K),e.virtualSize+=K}if(0===h.length&&(h=[0]),0!==b){var Q=e.isHorizontal()&&r?"marginLeft":e.getDirectionLabel("marginRight");l.filter((e,t)=>!(i.cssMode&&!i.loop)||t!==l.length-1).forEach(e=>{e.style[Q]=`${b}px`})}if(i.centeredSlides&&i.centeredSlidesBounds){var Z=0;m.forEach(e=>{Z+=e+(b||0)});var ee=(Z-=b)>y?Z-y:0;h=h.map(e=>e<=0?-f:e>ee?ee+v:e)}if(i.centerInsufficientSlides){var te=0;if(m.forEach(e=>{te+=e+(b||0)}),(te-=b)<y){var ie=(y-te)/2;h.forEach((e,t)=>{h[t]=e-ie}),c.forEach((e,t)=>{c[t]=e+ie})}}if(Object.assign(e,{slides:l,snapGrid:h,slidesGrid:c,slidesSizesGrid:m}),i.centeredSlides&&i.cssMode&&!i.centeredSlidesBounds){_R(n,"--swiper-centered-offset-before",-h[0]+"px"),_R(n,"--swiper-centered-offset-after",e.size/2-m[m.length-1]/2+"px");var ne=-e.snapGrid[0],ae=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+ne),e.slidesGrid=e.slidesGrid.map(e=>e+ae)}if(d!==u&&e.emit("slidesLengthChange"),h.length!==p&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),c.length!==g&&e.emit("slidesGridLengthChange"),i.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(s||i.cssMode||"slide"!==i.effect&&"fade"!==i.effect)){var re=`${i.containerModifierClass}backface-hidden`,oe=e.el.classList.contains(re);d<=i.maxBackfaceHiddenSlides?oe||e.el.classList.add(re):oe&&e.el.classList.remove(re)}}},updateAutoHeight:function(e){var t,i=this,n=[],a=i.virtual&&i.params.virtual.enabled,r=0;"number"==typeof e?i.setTransition(e):!0===e&&i.setTransition(i.params.speed);var o=e=>a?i.slides[i.getSlideIndexByData(e)]:i.slides[e];if("auto"!==i.params.slidesPerView&&i.params.slidesPerView>1)if(i.params.centeredSlides)(i.visibleSlides||[]).forEach(e=>{n.push(e)});else for(t=0;t<Math.ceil(i.params.slidesPerView);t+=1){var s=i.activeIndex+t;if(s>i.slides.length&&!a)break;n.push(o(s))}else n.push(o(i.activeIndex));for(t=0;t<n.length;t+=1)if(void 0!==n[t]){var u=n[t].offsetHeight;r=u>r?u:r}(r||0===r)&&(i.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){for(var e=this,t=e.slides,i=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0,n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-i-e.cssOverflowAdjustment()},updateSlidesProgress:function(e=this&&this.translate||0){var t=this,i=t.params,n=t.slides,a=t.rtlTranslate,r=t.snapGrid;if(0!==n.length){void 0===n[0].swiperSlideOffset&&t.updateSlidesOffset();var o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];var s=i.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(var u=0;u<n.length;u+=1){var l=n[u],d=l.swiperSlideOffset;i.cssMode&&i.centeredSlides&&(d-=n[0].swiperSlideOffset);var h=(o+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),c=(o-r[0]+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),m=-(o-d),f=m+t.slidesSizesGrid[u],v=m>=0&&m<=t.size-t.slidesSizesGrid[u],p=m>=0&&m<t.size-1||f>1&&f<=t.size||m<=0&&f>=t.size;p&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(u)),YR(l,p,i.slideVisibleClass),YR(l,v,i.slideFullyVisibleClass),l.progress=a?-h:h,l.originalProgress=a?-c:c}}},updateProgress:function(e){var t=this;if(void 0===e){var i=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*i||0}var n=t.params,a=t.maxTranslate()-t.minTranslate(),r=t.progress,o=t.isBeginning,s=t.isEnd,u=t.progressLoop,l=o,d=s;if(0===a)r=0,o=!0,s=!0;else{r=(e-t.minTranslate())/a;var h=Math.abs(e-t.minTranslate())<1,c=Math.abs(e-t.maxTranslate())<1;o=h||r<=0,s=c||r>=1,h&&(r=0),c&&(r=1)}if(n.loop){var m=t.getSlideIndexByData(0),f=t.getSlideIndexByData(t.slides.length-1),v=t.slidesGrid[m],p=t.slidesGrid[f],g=t.slidesGrid[t.slidesGrid.length-1],y=Math.abs(e);(u=y>=v?(y-v)/g:(y+g-p)/g)>1&&(u-=1)}Object.assign(t,{progress:r,progressLoop:u,isBeginning:o,isEnd:s}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),o&&!l&&t.emit("reachBeginning toEdge"),s&&!d&&t.emit("reachEnd toEdge"),(l&&!o||d&&!s)&&t.emit("fromEdge"),t.emit("progress",r)},updateSlidesClasses:function(){var e,t,i,n=this,a=n.slides,r=n.params,o=n.slidesEl,s=n.activeIndex,u=n.virtual&&r.virtual.enabled,l=n.grid&&r.grid&&r.grid.rows>1,d=e=>WR(o,`.${r.slideClass}${e}, swiper-slide${e}`)[0];if(u)if(r.loop){var h=s-n.virtual.slidesBefore;h<0&&(h=n.virtual.slides.length+h),h>=n.virtual.slides.length&&(h-=n.virtual.slides.length),e=d(`[data-swiper-slide-index="${h}"]`)}else e=d(`[data-swiper-slide-index="${s}"]`);else l?(e=a.find(e=>e.column===s),i=a.find(e=>e.column===s+1),t=a.find(e=>e.column===s-1)):e=a[s];e&&(l||(i=function(e,t){for(var i=[];e.nextElementSibling;){var n=e.nextElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!i&&(i=a[0]),t=function(e,t){for(var i=[];e.previousElementSibling;){var n=e.previousElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!t&&(t=a[a.length-1]))),a.forEach(n=>{qR(n,n===e,r.slideActiveClass),qR(n,n===i,r.slideNextClass),qR(n,n===t,r.slidePrevClass)}),n.emitSlidesClasses()},updateActiveIndex:function(e){var t,i=this,n=i.rtlTranslate?i.translate:-i.translate,a=i.snapGrid,r=i.params,o=i.activeIndex,s=i.realIndex,u=i.snapIndex,l=e,d=e=>{var t=e-i.virtual.slidesBefore;return t<0&&(t=i.virtual.slides.length+t),t>=i.virtual.slides.length&&(t-=i.virtual.slides.length),t};if(void 0===l&&(l=function(e){for(var t,i=e.slidesGrid,n=e.params,a=e.rtlTranslate?e.translate:-e.translate,r=0;r<i.length;r+=1)void 0!==i[r+1]?a>=i[r]&&a<i[r+1]-(i[r+1]-i[r])/2?t=r:a>=i[r]&&a<i[r+1]&&(t=r+1):a>=i[r]&&(t=r);return n.normalizeSlideIndex&&(t<0||void 0===t)&&(t=0),t}(i)),a.indexOf(n)>=0)t=a.indexOf(n);else{var h=Math.min(r.slidesPerGroupSkip,l);t=h+Math.floor((l-h)/r.slidesPerGroup)}if(t>=a.length&&(t=a.length-1),l!==o||i.params.loop)if(l===o&&i.params.loop&&i.virtual&&i.params.virtual.enabled)i.realIndex=d(l);else{var c,m=i.grid&&r.grid&&r.grid.rows>1;if(i.virtual&&r.virtual.enabled)c=r.loop?d(l):l;else if(m){var f=i.slides.find(e=>e.column===l),v=parseInt(f.getAttribute("data-swiper-slide-index"),10);Number.isNaN(v)&&(v=Math.max(i.slides.indexOf(f),0)),c=Math.floor(v/r.grid.rows)}else if(i.slides[l]){var p=i.slides[l].getAttribute("data-swiper-slide-index");c=p?parseInt(p,10):l}else c=l;Object.assign(i,{previousSnapIndex:u,snapIndex:t,previousRealIndex:s,realIndex:c,previousIndex:o,activeIndex:l}),i.initialized&&ZR(i),i.emit("activeIndexChange"),i.emit("snapIndexChange"),(i.initialized||i.params.runCallbacksOnInit)&&(s!==c&&i.emit("realIndexChange"),i.emit("slideChange"))}else t!==u&&(i.snapIndex=t,i.emit("snapIndexChange"))},updateClickedSlide:function(e,t){var i=this,n=i.params,a=e.closest(`.${n.slideClass}, swiper-slide`);!a&&i.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!a&&e.matches&&e.matches(`.${n.slideClass}, swiper-slide`)&&(a=e)});var r,o=!1;if(a)for(var s=0;s<i.slides.length;s+=1)if(i.slides[s]===a){o=!0,r=s;break}if(!a||!o)return i.clickedSlide=void 0,void(i.clickedIndex=void 0);i.clickedSlide=a,i.virtual&&i.params.virtual.enabled?i.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):i.clickedIndex=r,n.slideToClickedSlide&&void 0!==i.clickedIndex&&i.clickedIndex!==i.activeIndex&&i.slideToClickedSlide()}};var tF={getTranslate:function(e=(this.isHorizontal()?"x":"y")){var t=this,i=t.params,n=t.rtlTranslate,a=t.translate,r=t.wrapperEl;if(i.virtualTranslate)return n?-a:a;if(i.cssMode)return a;var o=xR(r,e);return o+=t.cssOverflowAdjustment(),n&&(o=-o),o||0},setTranslate:function(e,t){var i=this,n=i.rtlTranslate,a=i.params,r=i.wrapperEl,o=i.progress,s=0,u=0;i.isHorizontal()?s=n?-e:e:u=e,a.roundLengths&&(s=Math.floor(s),u=Math.floor(u)),i.previousTranslate=i.translate,i.translate=i.isHorizontal()?s:u,a.cssMode?r[i.isHorizontal()?"scrollLeft":"scrollTop"]=i.isHorizontal()?-s:-u:a.virtualTranslate||(i.isHorizontal()?s-=i.cssOverflowAdjustment():u-=i.cssOverflowAdjustment(),r.style.transform=`translate3d(${s}px, ${u}px, 0px)`);var l=i.maxTranslate()-i.minTranslate();(0===l?0:(e-i.minTranslate())/l)!==o&&i.updateProgress(e),i.emit("setTranslate",i.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e=0,t=this.params.speed,i=!0,n=!0,a){var r=this,o=r.params,s=r.wrapperEl;if(r.animating&&o.preventInteractionOnTransition)return!1;var u,l=r.minTranslate(),d=r.maxTranslate();if(u=n&&e>l?l:n&&e<d?d:e,r.updateProgress(u),o.cssMode){var h=r.isHorizontal();if(0===t)s[h?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return RR({swiper:r,targetPosition:-u,side:h?"left":"top"}),!0;s.scrollTo({[h?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionStart")),r.animating||(r.animating=!0,r.onTranslateToWrapperTransitionEnd||(r.onTranslateToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onTranslateToWrapperTransitionEnd),r.onTranslateToWrapperTransitionEnd=null,delete r.onTranslateToWrapperTransitionEnd,r.animating=!1,i&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function iF({swiper:e,runCallbacks:t,direction:i,step:n}){var a=e.activeIndex,r=e.previousIndex,o=i;o||(o=a>r?"next":a<r?"prev":"reset"),e.emit(`transition${n}`),t&&"reset"===o?e.emit(`slideResetTransition${n}`):t&&a!==r&&(e.emit(`slideChangeTransition${n}`),"next"===o?e.emit(`slideNextTransition${n}`):e.emit(`slidePrevTransition${n}`))}var nF={slideTo:function(e=0,t,i=!0,n,a){"string"==typeof e&&(e=parseInt(e,10));var r=this,o=e;o<0&&(o=0);var s=r.params,u=r.snapGrid,l=r.slidesGrid,d=r.previousIndex,h=r.activeIndex,c=r.rtlTranslate,m=r.wrapperEl;if(!r.enabled&&!n&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);var f=Math.min(r.params.slidesPerGroupSkip,o),v=f+Math.floor((o-f)/r.params.slidesPerGroup);v>=u.length&&(v=u.length-1);var p,g=-u[v];if(s.normalizeSlideIndex)for(var y=0;y<l.length;y+=1){var b=-Math.floor(100*g),w=Math.floor(100*l[y]),k=Math.floor(100*l[y+1]);void 0!==l[y+1]?b>=w&&b<k-(k-w)/2?o=y:b>=w&&b<k&&(o=y+1):b>=w&&(o=y)}if(r.initialized&&o!==h){if(!r.allowSlideNext&&(c?g>r.translate&&g>r.minTranslate():g<r.translate&&g<r.minTranslate()))return!1;if(!r.allowSlidePrev&&g>r.translate&&g>r.maxTranslate()&&(h||0)!==o)return!1}o!==(d||0)&&i&&r.emit("beforeSlideChangeStart"),r.updateProgress(g),p=o>h?"next":o<h?"prev":"reset";var S=r.virtual&&r.params.virtual.enabled;if(!(S&&a)&&(c&&-g===r.translate||!c&&g===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(g),"reset"!==p&&(r.transitionStart(i,p),r.transitionEnd(i,p)),!1;if(s.cssMode){var E=r.isHorizontal(),M=c?g:-g;if(0===t)S&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),S&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{m[E?"scrollLeft":"scrollTop"]=M})):m[E?"scrollLeft":"scrollTop"]=M,S&&requestAnimationFrame(()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1});else{if(!r.support.smoothScroll)return RR({swiper:r,targetPosition:M,side:E?"left":"top"}),!0;m.scrollTo({[E?"left":"top"]:M,behavior:"smooth"})}return!0}var T=KR().isSafari;return S&&!a&&T&&r.isElement&&r.virtual.update(!1,!1,o),r.setTransition(t),r.setTranslate(g),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,n),r.transitionStart(i,p),0===t?r.transitionEnd(i,p):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(i,p))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t,i=!0,n){"string"==typeof e&&(e=parseInt(e,10));var a=this;if(!a.destroyed){void 0===t&&(t=a.params.speed);var r=a.grid&&a.params.grid&&a.params.grid.rows>1,o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{var s;if(r){var u=o*a.params.grid.rows;s=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===u).column}else s=a.getSlideIndexByData(o);var l=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,d=a.params,h=d.centeredSlides,c=d.slidesOffsetBefore,m=d.slidesOffsetAfter,f=h||!!c||!!m,v=a.params.slidesPerView;"auto"===v?v=a.slidesPerViewDynamic():(v=Math.ceil(parseFloat(a.params.slidesPerView,10)),f&&v%2==0&&(v+=1));var p=l-s<v;if(f&&(p=p||s<Math.ceil(v/2)),n&&f&&"auto"!==a.params.slidesPerView&&!r&&(p=!1),p){var g=f?s<a.activeIndex?"prev":"next":s-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:g,slideTo:!0,activeSlideIndex:"next"===g?s+1:s-l+1,slideRealIndex:"next"===g?a.realIndex:void 0})}if(r){var y=o*a.params.grid.rows;o=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===y).column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame(()=>{a.slideTo(o,t,i,n)}),a}},slideNext:function(e,t=!0,i){var n=this,a=n.enabled,r=n.params,o=n.animating;if(!a||n.destroyed)return n;void 0===e&&(e=n.params.speed);var s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(n.slidesPerViewDynamic("current",!0),1));var u=n.activeIndex<r.slidesPerGroupSkip?1:s,l=n.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&r.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+u,e,t,i)}),!0}return r.rewind&&n.isEnd?n.slideTo(0,e,t,i):n.slideTo(n.activeIndex+u,e,t,i)},slidePrev:function(e,t=!0,i){var n=this,a=n.params,r=n.snapGrid,o=n.slidesGrid,s=n.rtlTranslate,u=n.enabled,l=n.animating;if(!u||n.destroyed)return n;void 0===e&&(e=n.params.speed);var d=n.virtual&&a.virtual.enabled;if(a.loop){if(l&&!d&&a.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}function h(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}var c,m=h(s?n.translate:-n.translate),f=r.map(e=>h(e)),v=a.freeMode&&a.freeMode.enabled,p=r[f.indexOf(m)-1];void 0===p&&(a.cssMode||v)&&(r.forEach((e,t)=>{m>=e&&(c=t)}),void 0!==c&&(p=v?r[c]:r[c>0?c-1:c]));var g=0;if(void 0!==p&&((g=o.indexOf(p))<0&&(g=n.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-n.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&n.isBeginning){var y=n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1;return n.slideTo(y,e,t,i)}return a.loop&&0===n.activeIndex&&a.cssMode?(requestAnimationFrame(()=>{n.slideTo(g,e,t,i)}),!0):n.slideTo(g,e,t,i)},slideReset:function(e,t=!0,i){var n=this;if(!n.destroyed)return void 0===e&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,i)},slideToClosest:function(e,t=!0,i,n=.5){var a=this;if(!a.destroyed){void 0===e&&(e=a.params.speed);var r=a.activeIndex,o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),u=a.rtlTranslate?a.translate:-a.translate;if(u>=a.snapGrid[s]){var l=a.snapGrid[s];u-l>(a.snapGrid[s+1]-l)*n&&(r+=a.params.slidesPerGroup)}else{var d=a.snapGrid[s-1];u-d<=(a.snapGrid[s]-d)*n&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,i)}},slideToClickedSlide:function(){var e=this;if(!e.destroyed){var t,i=e.params,n=e.slidesEl,a="auto"===i.slidesPerView?e.slidesPerViewDynamic():i.slidesPerView,r=e.getSlideIndexWhenGrid(e.clickedIndex),o=e.isElement?"swiper-slide":`.${i.slideClass}`,s=e.grid&&e.params.grid&&e.params.grid.rows>1;if(i.loop){if(e.animating)return;t=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),i.centeredSlides?e.slideToLoop(t):r>(s?(e.slides.length-a)/2-(e.params.grid.rows-1):e.slides.length-a)?(e.loopFix(),r=e.getSlideIndex(WR(n,`${o}[data-swiper-slide-index="${t}"]`)[0]),AR(()=>{e.slideTo(r)})):e.slideTo(r)}else e.slideTo(r)}}};var aF={loopCreate:function(e,t){var i=this,n=i.params,a=i.slidesEl;if(!(!n.loop||i.virtual&&i.params.virtual.enabled)){var r,o=()=>{WR(a,`.${n.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=i.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||s)&&((r=WR(a,`.${n.slideBlankClass}`)).forEach(e=>{e.remove()}),r.length>0&&(i.recalcSlides(),i.updateSlides()));var u=n.slidesPerGroup*(s?n.grid.rows:1),l=i.slides.length%u!==0,d=s&&i.slides.length%n.grid.rows!==0,h=e=>{for(var t=0;t<e;t+=1){var a=i.isElement?$R("swiper-slide",[n.slideBlankClass]):$R("div",[n.slideClass,n.slideBlankClass]);i.slidesEl.append(a)}};if(l){if(n.loopAddBlankSlides)h(u-i.slides.length%u),i.recalcSlides(),i.updateSlides();else OR("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else if(d){if(n.loopAddBlankSlides)h(n.grid.rows-i.slides.length%n.grid.rows),i.recalcSlides(),i.updateSlides();else OR("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else o();var c=n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter;i.loopFix({slideRealIndex:e,direction:c?void 0:"next",initial:t})}},loopFix:function({slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:n,activeSlideIndex:a,initial:r,byController:o,byMousewheel:s}={}){var u=this;if(u.params.loop){u.emit("beforeLoopFix");var l=u.slides,d=u.allowSlidePrev,h=u.allowSlideNext,c=u.slidesEl,m=u.params,f=m.centeredSlides,v=m.slidesOffsetBefore,p=m.slidesOffsetAfter,g=m.initialSlide,y=f||!!v||!!p;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&m.virtual.enabled)return t&&(y||0!==u.snapIndex?y&&u.snapIndex<m.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0):u.slideTo(u.virtual.slides.length,0,!1,!0)),u.allowSlidePrev=d,u.allowSlideNext=h,void u.emit("loopFix");var b=m.slidesPerView;"auto"===b?b=u.slidesPerViewDynamic():(b=Math.ceil(parseFloat(m.slidesPerView,10)),y&&b%2==0&&(b+=1));var w=m.slidesPerGroupAuto?b:m.slidesPerGroup,k=y?Math.max(w,Math.ceil(b/2)):w;k%w!==0&&(k+=w-k%w),k+=m.loopAdditionalSlides,u.loopedSlides=k;var S=u.grid&&m.grid&&m.grid.rows>1;l.length<b+k||"cards"===u.params.effect&&l.length<b+2*k?OR("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):S&&"row"===m.grid.fill&&OR("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");var E=[],M=[],T=S?Math.ceil(l.length/m.grid.rows):l.length,P=r&&T-g<b&&!y,A=P?g:u.activeIndex;void 0===a?a=u.getSlideIndex(l.find(e=>e.classList.contains(m.slideActiveClass))):A=a;var D="next"===i||!i,x="prev"===i||!i,C=0,I=0,L=(S?l[a].column:a)+(y&&void 0===n?-b/2+.5:0);if(L<k){C=Math.max(k-L,w);for(var _=0;_<k-L;_+=1){var R=_-Math.floor(_/T)*T;if(S)for(var F=T-R-1,W=l.length-1;W>=0;W-=1)l[W].column===F&&E.push(W);else E.push(T-R-1)}}else if(L+b>T-k){I=Math.max(L-(T-2*k),w),P&&(I=Math.max(I,b-T+g+1));for(var O=function(){var e=$-Math.floor($/T)*T;S?l.forEach((t,i)=>{t.column===e&&M.push(i)}):M.push(e)},$=0;$<I;$+=1)O()}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),"cards"===u.params.effect&&l.length<b+2*k&&(M.includes(a)&&M.splice(M.indexOf(a),1),E.includes(a)&&E.splice(E.indexOf(a),1)),x&&E.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.prepend(l[e]),l[e].swiperLoopMoveDOM=!1}),D&&M.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.append(l[e]),l[e].swiperLoopMoveDOM=!1}),u.recalcSlides(),"auto"===m.slidesPerView?u.updateSlides():S&&(E.length>0&&x||M.length>0&&D)&&u.slides.forEach((e,t)=>{u.grid.updateSlide(t,e,u.slides)}),m.watchSlidesProgress&&u.updateSlidesOffset(),t)if(E.length>0&&x){if(void 0===e){var N=u.slidesGrid[A],j=u.slidesGrid[A+C]-N;s?u.setTranslate(u.translate-j):(u.slideTo(A+Math.ceil(C),0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-j,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-j))}else if(n){var B=S?E.length/m.grid.rows:E.length;u.slideTo(u.activeIndex+B,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(M.length>0&&D)if(void 0===e){var z=u.slidesGrid[A],U=u.slidesGrid[A-I]-z;s?u.setTranslate(u.translate-U):(u.slideTo(A-I,0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-U,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-U))}else{var H=S?M.length/m.grid.rows:M.length;u.slideTo(u.activeIndex-H,0,!1,!0)}if(u.allowSlidePrev=d,u.allowSlideNext=h,u.controller&&u.controller.control&&!o){var G={slideRealIndex:e,direction:i,setTranslate:n,activeSlideIndex:a,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(e=>{!e.destroyed&&e.params.loop&&e.loopFix(re({},G,{slideTo:e.params.slidesPerView===m.slidesPerView&&t}))}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix(re({},G,{slideTo:u.controller.control.params.slidesPerView===m.slidesPerView&&t}))}u.emit("loopFix")}},loopDestroy:function(){var e=this,t=e.params,i=e.slidesEl;if(t.loop&&i&&(!e.virtual||!e.params.virtual.enabled)){e.recalcSlides();var n=[];e.slides.forEach(e=>{var t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;n[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),n.forEach(e=>{i.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}}};var rF={setGrabCursor:function(e){var t=this;if(!(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)){var i="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),i.style.cursor="move",i.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}},unsetGrabCursor:function(){var e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}};function oF(e,t,i){var n=PR(),a=e.params,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(i<=o||i>=n.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function sF(e){var t=this,i=kR(),n=e;n.originalEvent&&(n=n.originalEvent);var a=t.touchEventsData;if("pointerdown"===n.type){if(null!==a.pointerId&&a.pointerId!==n.pointerId)return;a.pointerId=n.pointerId}else"touchstart"===n.type&&1===n.targetTouches.length&&(a.touchId=n.targetTouches[0].identifier);if("touchstart"!==n.type){var r=t.params,o=t.touches;if(t.enabled&&(r.simulateTouch||"mouse"!==n.pointerType)&&(!t.animating||!r.preventInteractionOnTransition)){!t.animating&&r.cssMode&&r.loop&&t.loopFix();var s=n.target;if(("wrapper"!==r.touchEventsTarget||function(e,t){var i=PR(),n=t.contains(e);return!n&&i.HTMLSlotElement&&t instanceof HTMLSlotElement&&((n=[...t.assignedElements()].includes(e))||(n=function(e,t){for(var i=[t];i.length>0;){var n=i.shift();if(e===n)return!0;i.push(...n.children,...n.shadowRoot?n.shadowRoot.children:[],...n.assignedElements?n.assignedElements():[])}}(e,t))),n}(s,t.wrapperEl))&&!("which"in n&&3===n.which||"button"in n&&n.button>0||a.isTouched&&a.isMoved)){var u=!!r.noSwipingClass&&""!==r.noSwipingClass,l=n.composedPath?n.composedPath():n.path;u&&n.target&&n.target.shadowRoot&&l&&(s=l[0]);var d=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!n.target||!n.target.shadowRoot);if(r.noSwiping&&(h?function(e,t=this){return function t(i){if(!i||i===kR()||i===PR())return null;i.assignedSlot&&(i=i.assignedSlot);var n=i.closest(e);return n||i.getRootNode?n||t(i.getRootNode().host):null}(t)}(d,s):s.closest(d)))t.allowClick=!0;else if(!r.swipeHandler||s.closest(r.swipeHandler)){o.currentX=n.pageX,o.currentY=n.pageY;var c=o.currentX,m=o.currentY;if(oF(t,n,c)){Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=c,o.startY=m,a.touchStartTime=DR(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);var f=!0;s.matches(a.focusableElements)&&(f=!1,"SELECT"===s.nodeName&&(a.isTouched=!1)),i.activeElement&&i.activeElement.matches(a.focusableElements)&&i.activeElement!==s&&("mouse"===n.pointerType||"mouse"!==n.pointerType&&!s.matches(a.focusableElements))&&i.activeElement.blur();var v=f&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!v||s.isContentEditable||n.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}}}}}else oF(t,n,n.targetTouches[0].pageX)}function uF(e){var t=kR(),i=this,n=i.touchEventsData,a=i.params,r=i.touches,o=i.rtlTranslate;if(i.enabled&&(a.simulateTouch||"mouse"!==e.pointerType)){var s,u=e;if(u.originalEvent&&(u=u.originalEvent),"pointermove"===u.type){if(null!==n.touchId)return;if(u.pointerId!==n.pointerId)return}if("touchmove"===u.type){if(s=[...u.changedTouches].find(e=>e.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else s=u;if(n.isTouched){var l=s.pageX,d=s.pageY;if(u.preventedByNestedSwiper)return r.startX=l,void(r.startY=d);if(!i.allowTouchMove)return u.target.matches(n.focusableElements)||(i.allowClick=!1),void(n.isTouched&&(Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d}),n.touchStartTime=DR()));if(a.touchReleaseOnEdges&&!a.loop)if(i.isVertical()){if(d<r.startY&&i.translate<=i.maxTranslate()||d>r.startY&&i.translate>=i.minTranslate())return n.isTouched=!1,void(n.isMoved=!1)}else{if(o&&(l>r.startX&&-i.translate<=i.maxTranslate()||l<r.startX&&-i.translate>=i.minTranslate()))return;if(!o&&(l<r.startX&&i.translate<=i.maxTranslate()||l>r.startX&&i.translate>=i.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==u.target&&"mouse"!==u.pointerType&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(n.focusableElements))return n.isMoved=!0,void(i.allowClick=!1);n.allowTouchCallbacks&&i.emit("touchMove",u),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=l,r.currentY=d;var h=r.currentX-r.startX,c=r.currentY-r.startY;if(!(i.params.threshold&&Math.sqrt(h**2+c**2)<i.params.threshold)){var m;if(void 0===n.isScrolling)i.isHorizontal()&&r.currentY===r.startY||i.isVertical()&&r.currentX===r.startX?n.isScrolling=!1:h*h+c*c>=25&&(m=180*Math.atan2(Math.abs(c),Math.abs(h))/Math.PI,n.isScrolling=i.isHorizontal()?m>a.touchAngle:90-m>a.touchAngle);if(n.isScrolling&&i.emit("touchMoveOpposite",u),void 0===n.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(n.startMoving=!0)),n.isScrolling||"touchmove"===u.type&&n.preventTouchMoveFromPointerMove)n.isTouched=!1;else if(n.startMoving){i.allowClick=!1,!a.cssMode&&u.cancelable&&u.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&u.stopPropagation();var f=i.isHorizontal()?h:c,v=i.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),v=Math.abs(v)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,v=-v);var p=i.touchesDirection;i.swipeDirection=f>0?"prev":"next",i.touchesDirection=v>0?"prev":"next";var g=i.params.loop&&!a.cssMode,y="next"===i.touchesDirection&&i.allowSlideNext||"prev"===i.touchesDirection&&i.allowSlidePrev;if(!n.isMoved){if(g&&y&&i.loopFix({direction:i.swipeDirection}),n.startTranslate=i.getTranslate(),i.setTransition(0),i.animating){var b=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});i.wrapperEl.dispatchEvent(b)}n.allowMomentumBounce=!1,!a.grabCursor||!0!==i.allowSlideNext&&!0!==i.allowSlidePrev||i.setGrabCursor(!0),i.emit("sliderFirstMove",u)}if((new Date).getTime(),!1!==a._loopSwapReset&&n.isMoved&&n.allowThresholdMove&&p!==i.touchesDirection&&g&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,void(n.startTranslate=n.currentTranslate);i.emit("sliderMove",u),n.isMoved=!0,n.currentTranslate=f+n.startTranslate;var w=!0,k=a.resistanceRatio;if(a.touchReleaseOnEdges&&(k=0),f>0?(g&&y&&n.allowThresholdMove&&n.currentTranslate>(a.centeredSlides?i.minTranslate()-i.slidesSizesGrid[i.activeIndex+1]-("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.activeIndex+1]+i.params.spaceBetween:0)-i.params.spaceBetween:i.minTranslate())&&i.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>i.minTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.minTranslate()-1+(-i.minTranslate()+n.startTranslate+f)**k))):f<0&&(g&&y&&n.allowThresholdMove&&n.currentTranslate<(a.centeredSlides?i.maxTranslate()+i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween+("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween:0):i.maxTranslate())&&i.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:i.slides.length-("auto"===a.slidesPerView?i.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),n.currentTranslate<i.maxTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.maxTranslate()+1-(i.maxTranslate()-n.startTranslate-f)**k))),w&&(u.preventedByNestedSwiper=!0),!i.allowSlideNext&&"next"===i.swipeDirection&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!i.allowSlidePrev&&"prev"===i.swipeDirection&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),i.allowSlidePrev||i.allowSlideNext||(n.currentTranslate=n.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||n.allowThresholdMove))return void(n.currentTranslate=n.startTranslate);if(!n.allowThresholdMove)return n.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,n.currentTranslate=n.startTranslate,void(r.diff=i.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&i.freeMode||a.watchSlidesProgress)&&(i.updateActiveIndex(),i.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&i.freeMode&&i.freeMode.onTouchMove(),i.updateProgress(n.currentTranslate),i.setTranslate(n.currentTranslate))}}}else n.startMoving&&n.isScrolling&&i.emit("touchMoveOpposite",u)}}function lF(e){var t,i=this,n=i.touchEventsData,a=e;if(a.originalEvent&&(a=a.originalEvent),"touchend"===a.type||"touchcancel"===a.type){if(t=[...a.changedTouches].find(e=>e.identifier===n.touchId),!t||t.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;t=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)&&!(["pointercancel","contextmenu"].includes(a.type)&&(i.browser.isSafari||i.browser.isWebView)))return;n.pointerId=null,n.touchId=null;var r=i.params,o=i.touches,s=i.rtlTranslate,u=i.slidesGrid;if(i.enabled&&(r.simulateTouch||"mouse"!==a.pointerType)){if(n.allowTouchCallbacks&&i.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&i.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===i.allowSlideNext||!0===i.allowSlidePrev)&&i.setGrabCursor(!1);var l,d=DR(),h=d-n.touchStartTime;if(i.allowClick){var c=a.path||a.composedPath&&a.composedPath();i.updateClickedSlide(c&&c[0]||a.target,c),i.emit("tap click",a),h<300&&d-n.lastClickTime<300&&i.emit("doubleTap doubleClick",a)}if(n.lastClickTime=DR(),AR(()=>{i.destroyed||(i.allowClick=!0)}),!n.isTouched||!n.isMoved||!i.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,l=r.followFinger?s?i.translate:-i.translate:-n.currentTranslate,!r.cssMode)if(r.freeMode&&r.freeMode.enabled)i.freeMode.onTouchEnd({currentPos:l});else{for(var m=l>=-i.maxTranslate()&&!i.params.loop,f=0,v=i.slidesSizesGrid[0],p=0;p<u.length;p+=p<r.slidesPerGroupSkip?1:r.slidesPerGroup){var g=p<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==u[p+g]?(m||l>=u[p]&&l<u[p+g])&&(f=p,v=u[p+g]-u[p]):(m||l>=u[p])&&(f=p,v=u[u.length-1]-u[u.length-2])}var y=null,b=null;r.rewind&&(i.isBeginning?b=r.virtual&&r.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1:i.isEnd&&(y=0));var w=(l-u[f])/v,k=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(h>r.longSwipesMs){if(!r.longSwipes)return void i.slideTo(i.activeIndex);"next"===i.swipeDirection&&(w>=r.longSwipesRatio?i.slideTo(r.rewind&&i.isEnd?y:f+k):i.slideTo(f)),"prev"===i.swipeDirection&&(w>1-r.longSwipesRatio?i.slideTo(f+k):null!==b&&w<0&&Math.abs(w)>r.longSwipesRatio?i.slideTo(b):i.slideTo(f))}else{if(!r.shortSwipes)return void i.slideTo(i.activeIndex);i.navigation&&(a.target===i.navigation.nextEl||a.target===i.navigation.prevEl)?a.target===i.navigation.nextEl?i.slideTo(f+k):i.slideTo(f):("next"===i.swipeDirection&&i.slideTo(null!==y?y:f+k),"prev"===i.swipeDirection&&i.slideTo(null!==b?b:f))}}}}function dF(){var e=this,t=e.params,i=e.el;if(!i||0!==i.offsetWidth){t.breakpoints&&e.setBreakpoint();var n=e.allowSlideNext,a=e.allowSlidePrev,r=e.snapGrid,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();var s=o&&t.loop;if(!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||s)e.params.loop&&!o?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);else{var u=o?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=a,e.allowSlideNext=n,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}}function hF(e){var t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function cF(){var e=this,t=e.wrapperEl,i=e.rtlTranslate;if(e.enabled){e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();var n=e.maxTranslate()-e.minTranslate();(0===n?0:(e.translate-e.minTranslate())/n)!==e.progress&&e.updateProgress(i?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}}function mF(e){var t=this;JR(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function fF(){var e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}var vF=(e,t)=>{var i=kR(),n=e.params,a=e.el,r=e.wrapperEl,o=e.device,s=!!n.nested,u="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(i[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[u]("touchstart",e.onTouchStart,{passive:!1}),a[u]("pointerdown",e.onTouchStart,{passive:!1}),i[u]("touchmove",e.onTouchMove,{passive:!1,capture:s}),i[u]("pointermove",e.onTouchMove,{passive:!1,capture:s}),i[u]("touchend",e.onTouchEnd,{passive:!0}),i[u]("pointerup",e.onTouchEnd,{passive:!0}),i[u]("pointercancel",e.onTouchEnd,{passive:!0}),i[u]("touchcancel",e.onTouchEnd,{passive:!0}),i[u]("pointerout",e.onTouchEnd,{passive:!0}),i[u]("pointerleave",e.onTouchEnd,{passive:!0}),i[u]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&a[u]("click",e.onClick,!0),n.cssMode&&r[u]("scroll",e.onScroll),n.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",dF,!0):e[l]("observerUpdate",dF,!0),a[u]("load",e.onLoad,{capture:!0}))};var pF=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var gF={setBreakpoint:function(){var e=this,t=e.realIndex,i=e.initialized,n=e.params,a=e.el,r=n.breakpoints;if(r&&(!r||0!==Object.keys(r).length)){var o=kR(),s="window"!==n.breakpointsBase&&n.breakpointsBase?"container":n.breakpointsBase,u=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:o.querySelector(n.breakpointsBase),l=e.getBreakpoint(r,s,u);if(l&&e.currentBreakpoint!==l){var d=(l in r?r[l]:void 0)||e.originalParams,h=pF(e,n),c=pF(e,d),m=e.params.grabCursor,f=d.grabCursor,v=n.enabled;h&&!c?(a.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!h&&c&&(a.classList.add(`${n.containerModifierClass}grid`),(d.grid.fill&&"column"===d.grid.fill||!d.grid.fill&&"column"===n.grid.fill)&&a.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),m&&!f?e.unsetGrabCursor():!m&&f&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0!==d[t]){var i=n[t]&&n[t].enabled,a=d[t]&&d[t].enabled;i&&!a&&e[t].disable(),!i&&a&&e[t].enable()}});var p=d.direction&&d.direction!==n.direction,g=n.loop&&(d.slidesPerView!==n.slidesPerView||p),y=n.loop;p&&i&&e.changeDirection(),LR(e.params,d);var b=e.params.enabled,w=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),v&&!b?e.disable():!v&&b&&e.enable(),e.currentBreakpoint=l,e.emit("_beforeBreakpoint",d),i&&(g?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!y&&w?(e.loopCreate(t),e.updateSlides()):y&&!w&&e.loopDestroy()),e.emit("breakpoint",d)}}},getBreakpoint:function(e,t="window",i){if(e&&("container"!==t||i)){var n=!1,a=PR(),r="window"===t?a.innerHeight:i.clientHeight,o=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){var t=parseFloat(e.substr(1));return{value:r*t,point:e}}return{value:e,point:e}});o.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(var s=0;s<o.length;s+=1){var u=o[s],l=u.point,d=u.value;"window"===t?a.matchMedia(`(min-width: ${d}px)`).matches&&(n=l):d<=i.clientWidth&&(n=l)}return n||"max"}}};var yF={addClasses:function(){var e,t,i,n=this,a=n.classNames,r=n.params,o=n.rtl,s=n.el,u=n.device,l=(e=["initialized",r.direction,{"free-mode":n.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:o},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:u.android},{ios:u.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],t=r.containerModifierClass,i=[],e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(n=>{e[n]&&i.push(t+n)}):"string"==typeof e&&i.push(t+e)}),i);a.push(...l),s.classList.add(...a),n.emitContainerClasses()},removeClasses:function(){var e=this,t=e.el,i=e.classNames;t&&"string"!=typeof t&&(t.classList.remove(...i),e.emitContainerClasses())}};var bF={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function wF(e,t){return function(i={}){var n=Object.keys(i)[0],a=i[n];"object"==typeof a&&null!==a?(!0===e[n]&&(e[n]={enabled:!0}),"navigation"===n&&e[n]&&e[n].enabled&&!e[n].prevEl&&!e[n].nextEl&&(e[n].auto=!0),["pagination","scrollbar"].indexOf(n)>=0&&e[n]&&e[n].enabled&&!e[n].el&&(e[n].auto=!0),n in e&&"enabled"in a?("object"!=typeof e[n]||"enabled"in e[n]||(e[n].enabled=!0),e[n]||(e[n]={enabled:!1}),LR(t,i)):LR(t,i)):LR(t,i)}}var kF={eventsEmitter:XR,update:eF,translate:tF,transition:{setTransition:function(e,t){var i=this;i.params.cssMode||(i.wrapperEl.style.transitionDuration=`${e}ms`,i.wrapperEl.style.transitionDelay=0===e?"0ms":""),i.emit("setTransition",e,t)},transitionStart:function(e=!0,t){var i=this,n=i.params;n.cssMode||(n.autoHeight&&i.updateAutoHeight(),iF({swiper:i,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e=!0,t){var i=this,n=i.params;i.animating=!1,n.cssMode||(i.setTransition(0),iF({swiper:i,runCallbacks:e,direction:t,step:"End"}))}},slide:nF,loop:aF,grabCursor:rF,events:{attachEvents:function(){var e=this,t=e.params;e.onTouchStart=sF.bind(e),e.onTouchMove=uF.bind(e),e.onTouchEnd=lF.bind(e),e.onDocumentTouchStart=fF.bind(e),t.cssMode&&(e.onScroll=cF.bind(e)),e.onClick=hF.bind(e),e.onLoad=mF.bind(e),vF(e,"on")},detachEvents:function(){vF(this,"off")}},breakpoints:gF,checkOverflow:{checkOverflow:function(){var e=this,t=e.isLocked,i=e.params,n=i.slidesOffsetBefore;if(n){var a=e.slides.length-1,r=e.slidesGrid[a]+e.slidesSizesGrid[a]+2*n;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===i.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===i.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:yF},SF={},EF=function(){function e(...t){var i,n;Q(this,e),1===t.length&&t[0].constructor&&"Object"===Object.prototype.toString.call(t[0]).slice(8,-1)?n=t[0]:(i=t[0],n=t[1]),n||(n={}),n=LR({},n),i&&!n.el&&(n.el=i);var a=kR();if(n.el&&"string"==typeof n.el&&a.querySelectorAll(n.el).length>1){var r=[];return a.querySelectorAll(n.el).forEach(t=>{var i=LR({},n,{el:t});r.push(new e(i))}),r}var o=this;o.__swiper__=!0,o.support=GR(),o.device=VR({userAgent:n.userAgent}),o.browser=KR(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],n.modules&&Array.isArray(n.modules)&&n.modules.forEach(e=>{"function"==typeof e&&o.modules.indexOf(e)<0&&o.modules.push(e)});var s={};o.modules.forEach(e=>{e({params:n,swiper:o,extendParams:wF(n,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});var u=LR({},bF,s);return o.params=LR({},u,SF,n),o.originalParams=LR({},o.params),o.passedParams=LR({},n),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:i,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}return ne(e,[{key:"getDirectionLabel",value:function(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}},{key:"getSlideIndex",value:function(e){var t=jR(WR(this.slidesEl,`.${this.params.slideClass}, swiper-slide`)[0]);return jR(e)-t}},{key:"getSlideIndexByData",value:function(e){return this.getSlideIndex(this.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e))}},{key:"getSlideIndexWhenGrid",value:function(e){return this.grid&&this.params.grid&&this.params.grid.rows>1&&("column"===this.params.grid.fill?e=Math.floor(e/this.params.grid.rows):"row"===this.params.grid.fill&&(e%=Math.ceil(this.slides.length/this.params.grid.rows))),e}},{key:"recalcSlides",value:function(){var e=this,t=e.slidesEl,i=e.params;e.slides=WR(t,`.${i.slideClass}, swiper-slide`)}},{key:"enable",value:function(){var e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}},{key:"disable",value:function(){var e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}},{key:"setProgress",value:function(e,t){var i=this;e=Math.min(Math.max(e,0),1);var n=i.minTranslate(),a=(i.maxTranslate()-n)*e+n;i.translateTo(a,void 0===t?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}},{key:"emitContainerClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}}},{key:"getSlideClasses",value:function(e){var t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}},{key:"emitSlidesClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=[];e.slides.forEach(i=>{var n=e.getSlideClasses(i);t.push({slideEl:i,classNames:n}),e.emit("_slideClass",i,n)}),e.emit("_slideClasses",t)}}},{key:"slidesPerViewDynamic",value:function(e="current",t=!1){var i=this,n=i.params,a=i.slides,r=i.slidesGrid,o=i.slidesSizesGrid,s=i.size,u=i.activeIndex,l=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){for(var d,h=a[u]?Math.ceil(a[u].swiperSlideSize):0,c=u+1;c<a.length;c+=1)a[c]&&!d&&(l+=1,(h+=Math.ceil(a[c].swiperSlideSize))>s&&(d=!0));for(var m=u-1;m>=0;m-=1)a[m]&&!d&&(l+=1,(h+=a[m].swiperSlideSize)>s&&(d=!0))}else if("current"===e)for(var f=u+1;f<a.length;f+=1){(t?r[f]+o[f]-r[u]<s:r[f]-r[u]<s)&&(l+=1)}else for(var v=u-1;v>=0;v-=1){r[u]-r[v]<s&&(l+=1)}return l}},{key:"update",value:function(){var e=this;if(e&&!e.destroyed){var t,i=e.snapGrid,n=e.params;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&JR(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)r(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){var a=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;t=e.slideTo(a.length-1,0,!1,!0)}else t=e.slideTo(e.activeIndex,0,!1,!0);t||r()}n.watchOverflow&&i!==e.snapGrid&&e.checkOverflow(),e.emit("update")}function r(){var t=e.rtlTranslate?-1*e.translate:e.translate,i=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(i),e.updateActiveIndex(),e.updateSlidesClasses()}}},{key:"changeDirection",value:function(e,t=!0){var i=this,n=i.params.direction;return e||(e="horizontal"===n?"vertical":"horizontal"),e===n||"horizontal"!==e&&"vertical"!==e||(i.el.classList.remove(`${i.params.containerModifierClass}${n}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}},{key:"changeLanguageDirection",value:function(e){var t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}},{key:"mount",value:function(e){var t=this;if(t.mounted)return!0;var i=e||t.params.el;if("string"==typeof i&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);var n=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`,a=i&&i.shadowRoot&&i.shadowRoot.querySelector?i.shadowRoot.querySelector(n()):WR(i,n())[0];return!a&&t.params.createElements&&(a=$R("div",t.params.wrapperClass),i.append(a),WR(i,`.${t.params.slideClass}`).forEach(e=>{a.append(e)})),Object.assign(t,{el:i,wrapperEl:a,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:a,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:"rtl"===i.dir.toLowerCase()||"rtl"===NR(i,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===i.dir.toLowerCase()||"rtl"===NR(i,"direction")),wrongRTL:"-webkit-box"===NR(a,"display")}),!0}},{key:"init",value:function(e){var t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(void 0,!0),t.attachEvents();var i=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&i.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),i.forEach(e=>{e.complete?JR(t,e):e.addEventListener("load",e=>{JR(t,e.target)})}),ZR(t),t.initialized=!0,ZR(t),t.emit("init"),t.emit("afterInit"),t}},{key:"destroy",value:function(e=!0,t=!0){var i=this,n=i.params,a=i.el,r=i.wrapperEl,o=i.slides;return void 0===i.params||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),n.loop&&i.loopDestroy(),t&&(i.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach(e=>{e.classList.remove(n.slideVisibleClass,n.slideFullyVisibleClass,n.slideActiveClass,n.slideNextClass,n.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(e=>{i.off(e)}),!1!==e&&(i.el&&"string"!=typeof i.el&&(i.el.swiper=null),function(e){var t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(i)),i.destroyed=!0),null}}],[{key:"extendDefaults",value:function(e){LR(SF,e)}},{key:"extendedDefaults",get:function(){return SF}},{key:"defaults",get:function(){return bF}},{key:"installModule",value:function(t){e.prototype.__modules__||(e.prototype.__modules__=[]);var i=e.prototype.__modules__;"function"==typeof t&&i.indexOf(t)<0&&i.push(t)}},{key:"use",value:function(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}}])}();function MF(e=""){return`.${e.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g,"\\$1").replace(/ /g,".")}`}function TF({swiper:e,extendParams:t,on:i,emit:n}){var a,r="swiper-pagination";t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${r}-bullet`,bulletActiveClass:`${r}-bullet-active`,modifierClass:`${r}-`,currentClass:`${r}-current`,totalClass:`${r}-total`,hiddenClass:`${r}-hidden`,progressbarFillClass:`${r}-progressbar-fill`,progressbarOppositeClass:`${r}-progressbar-opposite`,clickableClass:`${r}-clickable`,lockClass:`${r}-lock`,horizontalClass:`${r}-horizontal`,verticalClass:`${r}-vertical`,paginationDisabledClass:`${r}-disabled`}}),e.pagination={el:null,bullets:[]};var o=0;function s(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function u(t,i){var n=e.params.pagination.bulletActiveClass;t&&(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${n}-${i}`),(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&t.classList.add(`${n}-${i}-${i}`))}function l(t){var i=t.target.closest(MF(e.params.pagination.bulletClass));if(i){t.preventDefault();var n,a,r,o=jR(i)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===o)return;var s=(n=e.realIndex,a=o,r=e.slides.length,(a%=r)===1+(n%=r)?"next":a===n-1?"previous":void 0);"next"===s?e.slideNext():"previous"===s?e.slidePrev():e.slideToLoop(o)}else e.slideTo(o)}}function d(){var t=e.rtl,i=e.params.pagination;if(!s()){var r,l,d=e.pagination.el;d=UR(d);var h=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,c=e.params.loop?Math.ceil(h/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(l=e.previousRealIndex||0,r=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(r=e.snapIndex,l=e.previousSnapIndex):(l=e.previousIndex||0,r=e.activeIndex||0),"bullets"===i.type&&e.pagination.bullets&&e.pagination.bullets.length>0){var m,f,v,p=e.pagination.bullets;if(i.dynamicBullets&&(a=zR(p[0],e.isHorizontal()?"width":"height"),d.forEach(t=>{t.style[e.isHorizontal()?"width":"height"]=a*(i.dynamicMainBullets+4)+"px"}),i.dynamicMainBullets>1&&void 0!==l&&((o+=r-(l||0))>i.dynamicMainBullets-1?o=i.dynamicMainBullets-1:o<0&&(o=0)),m=Math.max(r-o,0),v=((f=m+(Math.min(p.length,i.dynamicMainBullets)-1))+m)/2),p.forEach(e=>{var t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map(e=>`${i.bulletActiveClass}${e}`)].map(e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e).flat();e.classList.remove(...t)}),d.length>1)p.forEach(t=>{var n=jR(t);n===r?t.classList.add(...i.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),i.dynamicBullets&&(n>=m&&n<=f&&t.classList.add(...`${i.bulletActiveClass}-main`.split(" ")),n===m&&u(t,"prev"),n===f&&u(t,"next"))});else{var g=p[r];if(g&&g.classList.add(...i.bulletActiveClass.split(" ")),e.isElement&&p.forEach((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")}),i.dynamicBullets){for(var y=p[m],b=p[f],w=m;w<=f;w+=1)p[w]&&p[w].classList.add(...`${i.bulletActiveClass}-main`.split(" "));u(y,"prev"),u(b,"next")}}if(i.dynamicBullets){var k=Math.min(p.length,i.dynamicMainBullets+4),S=(a*k-a)/2-v*a,E=t?"right":"left";p.forEach(t=>{t.style[e.isHorizontal()?E:"top"]=`${S}px`})}}d.forEach((t,a)=>{if("fraction"===i.type&&(t.querySelectorAll(MF(i.currentClass)).forEach(e=>{e.textContent=i.formatFractionCurrent(r+1)}),t.querySelectorAll(MF(i.totalClass)).forEach(e=>{e.textContent=i.formatFractionTotal(c)})),"progressbar"===i.type){var o;o=i.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";var s=(r+1)/c,u=1,l=1;"horizontal"===o?u=s:l=s,t.querySelectorAll(MF(i.progressbarFillClass)).forEach(t=>{t.style.transform=`translate3d(0,0,0) scaleX(${u}) scaleY(${l})`,t.style.transitionDuration=`${e.params.speed}ms`})}"custom"===i.type&&i.renderCustom?(HR(t,i.renderCustom(e,r+1,c)),0===a&&n("paginationRender",t)):(0===a&&n("paginationRender",t),n("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](i.lockClass)})}}function h(){var t=e.params.pagination;if(!s()){var i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.grid&&e.params.grid.rows>1?e.slides.length/Math.ceil(e.params.grid.rows):e.slides.length,a=e.pagination.el;a=UR(a);var r="";if("bullets"===t.type){var o=e.params.loop?Math.ceil(i/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&o>i&&(o=i);for(var u=0;u<o;u+=1)t.renderBullet?r+=t.renderBullet.call(e,u,t.bulletClass):r+=`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(r=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(r=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],a.forEach(i=>{"custom"!==t.type&&HR(i,r||""),"bullets"===t.type&&e.pagination.bullets.push(...i.querySelectorAll(MF(t.bulletClass)))}),"custom"!==t.type&&n("paginationRender",a[0])}}function c(){e.params.pagination=function(e,t,i,n){return e.params.createElements&&Object.keys(n).forEach(a=>{if(!i[a]&&!0===i.auto){var r=WR(e.el,`.${n[a]}`)[0];r||((r=$R("div",n[a])).className=n[a],e.el.append(r)),i[a]=r,t[a]=r}}),i}(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});var t,i=e.params.pagination;i.el&&("string"==typeof i.el&&e.isElement&&(t=e.el.querySelector(i.el)),t||"string"!=typeof i.el||(t=[...document.querySelectorAll(i.el)]),t||(t=i.el),t&&0!==t.length&&(e.params.uniqueNavElements&&"string"==typeof i.el&&Array.isArray(t)&&t.length>1&&(t=[...e.el.querySelectorAll(i.el)]).length>1&&(t=t.find(t=>BR(t,".swiper")[0]===e.el)),Array.isArray(t)&&1===t.length&&(t=t[0]),Object.assign(e.pagination,{el:t}),(t=UR(t)).forEach(t=>{"bullets"===i.type&&i.clickable&&t.classList.add(...(i.clickableClass||"").split(" ")),t.classList.add(i.modifierClass+i.type),t.classList.add(e.isHorizontal()?i.horizontalClass:i.verticalClass),"bullets"===i.type&&i.dynamicBullets&&(t.classList.add(`${i.modifierClass}${i.type}-dynamic`),o=0,i.dynamicMainBullets<1&&(i.dynamicMainBullets=1)),"progressbar"===i.type&&i.progressbarOpposite&&t.classList.add(i.progressbarOppositeClass),i.clickable&&t.addEventListener("click",l),e.enabled||t.classList.add(i.lockClass)})))}function m(){var t=e.params.pagination;if(!s()){var i=e.pagination.el;i&&(i=UR(i)).forEach(i=>{i.classList.remove(t.hiddenClass),i.classList.remove(t.modifierClass+t.type),i.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(i.classList.remove(...(t.clickableClass||"").split(" ")),i.removeEventListener("click",l))}),e.pagination.bullets&&e.pagination.bullets.forEach(e=>e.classList.remove(...t.bulletActiveClass.split(" ")))}}i("changeDirection",()=>{if(e.pagination&&e.pagination.el){var t=e.params.pagination,i=e.pagination.el;(i=UR(i)).forEach(i=>{i.classList.remove(t.horizontalClass,t.verticalClass),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)})}}),i("init",()=>{!1===e.params.pagination.enabled?f():(c(),h(),d())}),i("activeIndexChange",()=>{void 0===e.snapIndex&&d()}),i("snapIndexChange",()=>{d()}),i("snapGridLengthChange",()=>{h(),d()}),i("destroy",()=>{m()}),i("enable disable",()=>{var t=e.pagination.el;t&&(t=UR(t)).forEach(t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass))}),i("lock unlock",()=>{d()}),i("click",(t,i)=>{var a=i.target,r=UR(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&r&&r.length>0&&!a.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&a===e.navigation.nextEl||e.navigation.prevEl&&a===e.navigation.prevEl))return;var o=r[0].classList.contains(e.params.pagination.hiddenClass);n(!0===o?"paginationShow":"paginationHide"),r.forEach(t=>t.classList.toggle(e.params.pagination.hiddenClass))}});var f=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=UR(t)).forEach(t=>t.classList.add(e.params.pagination.paginationDisabledClass)),m()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=UR(t)).forEach(t=>t.classList.remove(e.params.pagination.paginationDisabledClass)),c(),h(),d()},disable:f,render:h,update:d,init:c,destroy:m})}function PF({swiper:e,extendParams:t,on:i,emit:n,params:a}){var r,o;e.autoplay={running:!1,paused:!1,timeLeft:0},t({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});var s,u,l,d,h,c,m,f=a&&a.autoplay?a.autoplay.delay:3e3,v=a&&a.autoplay?a.autoplay.delay:3e3,p=(new Date).getTime();function g(t){e&&!e.destroyed&&e.wrapperEl&&t.target===e.wrapperEl&&(e.wrapperEl.removeEventListener("transitionend",g),m||t.detail&&t.detail.bySwiperTouchMove||M())}var y=()=>{if(!e.destroyed&&e.autoplay.running){e.autoplay.paused?u=!0:u&&(v=s,u=!1);var t=e.autoplay.paused?s:p+v-(new Date).getTime();e.autoplay.timeLeft=t,n("autoplayTimeLeft",t,t/f),o=requestAnimationFrame(()=>{y()})}},b=()=>{var t=e.params.autoplay.delay,i=(()=>{var t;if(t=e.virtual&&e.params.virtual.enabled?e.slides.find(e=>e.classList.contains("swiper-slide-active")):e.slides[e.activeIndex])return parseInt(t.getAttribute("data-swiper-autoplay"),10)})();return!Number.isNaN(i)&&i>0&&(t=i),t},w=t=>{if(!e.destroyed&&e.autoplay.running){cancelAnimationFrame(o),y();var i=t;void 0===i&&(i=b(),f=i,v=i),s=i;var a=e.params.speed,u=()=>{e&&!e.destroyed&&(e.params.autoplay.reverseDirection?!e.isBeginning||e.params.loop||e.params.rewind?(e.slidePrev(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(e.slides.length-1,a,!0,!0),n("autoplay")):!e.isEnd||e.params.loop||e.params.rewind?(e.slideNext(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(0,a,!0,!0),n("autoplay")),e.params.cssMode&&(p=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return i>0?(clearTimeout(r),r=setTimeout(()=>{u()},i)):requestAnimationFrame(()=>{u()}),i}},k=()=>{p=(new Date).getTime(),e.autoplay.running=!0,w(),n("autoplayStart")},S=()=>{e.autoplay.running=!1,clearTimeout(r),cancelAnimationFrame(o),n("autoplayStop")},E=(t,i)=>{if(!e.destroyed&&e.autoplay.running){clearTimeout(r),t||(c=!0);var a=()=>{n("autoplayPause"),e.params.autoplay.waitForTransition?e.wrapperEl.addEventListener("transitionend",g):M()};if(e.autoplay.paused=!0,i)a();else{var o=s||e.params.autoplay.delay;s=o-((new Date).getTime()-p),e.isEnd&&s<0&&!e.params.loop||(s<0&&(s=0),a())}}},M=()=>{e.isEnd&&s<0&&!e.params.loop||e.destroyed||!e.autoplay.running||(p=(new Date).getTime(),c?(c=!1,w(s)):w(),e.autoplay.paused=!1,n("autoplayResume"))},T=()=>{if(!e.destroyed&&e.autoplay.running){var t=kR();"hidden"===t.visibilityState&&(c=!0,E(!0)),"visible"===t.visibilityState&&M()}},P=t=>{"mouse"===t.pointerType&&(c=!0,m=!0,e.animating||e.autoplay.paused||E(!0))},A=t=>{"mouse"===t.pointerType&&(m=!1,e.autoplay.paused&&M())};i("init",()=>{e.params.autoplay.enabled&&(e.params.autoplay.pauseOnMouseEnter&&(e.el.addEventListener("pointerenter",P),e.el.addEventListener("pointerleave",A)),kR().addEventListener("visibilitychange",T),k())}),i("destroy",()=>{e.el&&"string"!=typeof e.el&&(e.el.removeEventListener("pointerenter",P),e.el.removeEventListener("pointerleave",A)),kR().removeEventListener("visibilitychange",T),e.autoplay.running&&S()}),i("_freeModeStaticRelease",()=>{(d||c)&&M()}),i("_freeModeNoMomentumRelease",()=>{e.params.autoplay.disableOnInteraction?S():E(!0,!0)}),i("beforeTransitionStart",(t,i,n)=>{!e.destroyed&&e.autoplay.running&&(n||!e.params.autoplay.disableOnInteraction?E(!0,!0):S())}),i("sliderFirstMove",()=>{!e.destroyed&&e.autoplay.running&&(e.params.autoplay.disableOnInteraction?S():(l=!0,d=!1,c=!1,h=setTimeout(()=>{c=!0,d=!0,E(!0)},200)))}),i("touchEnd",()=>{if(!e.destroyed&&e.autoplay.running&&l){if(clearTimeout(h),clearTimeout(r),e.params.autoplay.disableOnInteraction)return d=!1,void(l=!1);d&&e.params.cssMode&&M(),d=!1,l=!1}}),i("slideChange",()=>{!e.destroyed&&e.autoplay.running&&e.autoplay.paused&&(s=b(),f=b())}),Object.assign(e.autoplay,{start:k,stop:S,pause:E,resume:M})}function AF(e,t){var i=FR(t);return i!==t&&(i.style.backfaceVisibility="hidden",i.style["-webkit-backface-visibility"]="hidden"),i}function DF(e,t,i){var n=`swiper-slide-shadow${i?`-${i}`:""} swiper-slide-shadow-${e}`,a=FR(t),r=a.querySelector(`.${n.split(" ").join(".")}`);return r||(r=$R("div",n.split(" ")),a.append(r)),r}function xF({swiper:e,extendParams:t,on:i}){t({coverflowEffect:{rotate:50,stretch:0,depth:100,scale:1,modifier:1,slideShadows:!0}});!function(e){var t,i=e.effect,n=e.swiper,a=e.on,r=e.setTranslate,o=e.setTransition,s=e.overwriteParams,u=e.perspective,l=e.recreateShadows,d=e.getEffectParams;a("beforeInit",()=>{if(n.params.effect===i){n.classNames.push(`${n.params.containerModifierClass}${i}`),u&&u()&&n.classNames.push(`${n.params.containerModifierClass}3d`);var e=s?s():{};Object.assign(n.params,e),Object.assign(n.originalParams,e)}}),a("setTranslate _virtualUpdated",()=>{n.params.effect===i&&r()}),a("setTransition",(e,t)=>{n.params.effect===i&&o(t)}),a("transitionEnd",()=>{if(n.params.effect===i&&l){if(!d||!d().slideShadows)return;n.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),a("virtualUpdate",()=>{n.params.effect===i&&(n.slides.length||(t=!0),requestAnimationFrame(()=>{t&&n.slides&&n.slides.length&&(r(),t=!1)}))})}({effect:"coverflow",swiper:e,on:i,setTranslate:()=>{for(var t=e.width,i=e.height,n=e.slides,a=e.slidesSizesGrid,r=e.params.coverflowEffect,o=e.isHorizontal(),s=e.translate,u=o?t/2-s:i/2-s,l=o?r.rotate:-r.rotate,d=r.depth,h=function(e){return t=>Math.abs(t)>0&&e.browser&&e.browser.need3dFix&&Math.abs(t)%90==0?t+.001:t}(e),c=0,m=n.length;c<m;c+=1){var f=n[c],v=a[c],p=(u-f.swiperSlideOffset-v/2)/v,g="function"==typeof r.modifier?r.modifier(p):p*r.modifier,y=o?l*g:0,b=o?0:l*g,w=-d*Math.abs(g),k=r.stretch;"string"==typeof k&&-1!==k.indexOf("%")&&(k=parseFloat(r.stretch)/100*v);var S=o?0:k*g,E=o?k*g:0,M=1-(1-r.scale)*Math.abs(g);Math.abs(E)<.001&&(E=0),Math.abs(S)<.001&&(S=0),Math.abs(w)<.001&&(w=0),Math.abs(y)<.001&&(y=0),Math.abs(b)<.001&&(b=0),Math.abs(M)<.001&&(M=0);var T=`translate3d(${E}px,${S}px,${w}px) rotateX(${h(b)}deg) rotateY(${h(y)}deg) scale(${M})`;if(AF(0,f).style.transform=T,f.style.zIndex=1-Math.abs(Math.round(g)),r.slideShadows){var P=o?f.querySelector(".swiper-slide-shadow-left"):f.querySelector(".swiper-slide-shadow-top"),A=o?f.querySelector(".swiper-slide-shadow-right"):f.querySelector(".swiper-slide-shadow-bottom");P||(P=DF("coverflow",f,o?"left":"top")),A||(A=DF("coverflow",f,o?"right":"bottom")),P&&(P.style.opacity=g>0?g:0),A&&(A.style.opacity=-g>0?-g:0)}}},setTransition:t=>{e.slides.map(e=>FR(e)).forEach(e=>{e.style.transitionDuration=`${t}ms`,e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>{e.style.transitionDuration=`${t}ms`})})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0})})}Object.keys(kF).forEach(e=>{Object.keys(kF[e]).forEach(t=>{EF.prototype[t]=kF[e][t]})}),EF.use([function({swiper:e,on:t,emit:i}){var n=PR(),a=null,r=null,o=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},s=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};t("init",()=>{e.params.resizeObserver&&void 0!==n.ResizeObserver?e&&!e.destroyed&&e.initialized&&(a=new ResizeObserver(t=>{r=n.requestAnimationFrame(()=>{var i=e.width,n=e.height,a=i,r=n;t.forEach(({contentBoxSize:t,contentRect:i,target:n})=>{n&&n!==e.el||(a=i?i.width:(t[0]||t).inlineSize,r=i?i.height:(t[0]||t).blockSize)}),a===i&&r===n||o()})})).observe(e.el):(n.addEventListener("resize",o),n.addEventListener("orientationchange",s))}),t("destroy",()=>{r&&n.cancelAnimationFrame(r),a&&a.unobserve&&e.el&&(a.unobserve(e.el),a=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",s)})},function({swiper:e,extendParams:t,on:i,emit:n}){var a=[],r=PR(),o=(t,i={})=>{var o=new(r.MutationObserver||r.WebkitMutationObserver)(t=>{if(!e.__preventObserver__)if(1!==t.length){var i=function(){n("observerUpdate",t[0])};r.requestAnimationFrame?r.requestAnimationFrame(i):r.setTimeout(i,0)}else n("observerUpdate",t[0])});o.observe(t,{attributes:void 0===i.attributes||i.attributes,childList:e.isElement||(void 0===i.childList||i).childList,characterData:void 0===i.characterData||i.characterData}),a.push(o)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(e.params.observer){if(e.params.observeParents)for(var t=BR(e.hostEl),i=0;i<t.length;i+=1)o(t[i]);o(e.hostEl,{childList:e.params.observeSlideChildren}),o(e.wrapperEl,{attributes:!1})}}),i("destroy",()=>{a.forEach(e=>{e.disconnect()}),a.splice(0,a.length)})}]);var CF,IF,LF=e=>e,_F=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.updateSpacing=e=>{t.slideSpacing=e.detail.spacing,t.swiperInstance&&(t.swiperInstance.params.spaceBetween=t.slideSpacing,t.swiperInstance.update())},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),window.addEventListener("child-spacing",this.updateSpacing,!1)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),window.removeEventListener("child-spacing",this.updateSpacing,!1)}},{key:"styles",value:function(){var e,t,i,n=this.scaleFactor,a=this.component,r=a.backgroundBlur,o=a.indicator,s=a.activeIndicator,u=a.previousSlidePadding,l=a.nextSlidePadding,d="vertical"===a.direction?"margin-top":"margin-left";return U(`\n :host {\n display: ${a.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Nu(a.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n ${r?`backdrop-filter: blur(${r}px);`:""}\n z-index: ${null!==(e=a.zIndex)&&void 0!==e?e:1};\n top: 0px;\n transition: all 0.3s;\n ${xu(a,n)}\n ${function(e,t){return`\n padding-right: ${bu(t,e.nextSlidePadding)}px !important;\n padding-left: ${bu(t,e.previousSlidePadding)}px !important;\n `}(a,n)}\n ${Tu(a)}\n ${Mu(a,!1)}\n max-width: 100vw;\n }\n :host(:focus){\n ${Mu(a,!0)}\n ${Ou(a,n,!0)}\n }\n :host(:focus-visible){\n ${Uu(a)}\n }\n :host > *:not(:first-child) {\n ${d}: ${a.spacing?a.spacing*n:0}px;\n }\n .swiper-container {\n ${Lu(a,n)};\n padding-left: ${null!=u?u:0}px;\n padding-right: ${null!=l?l:0}px;\n box-sizing: border-box;\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n opacity: 1 !important;\n ${null!=(null==o?void 0:o.width)?`width: ${o.width}px !important;`:""}\n ${null!=(null==o?void 0:o.height)?`height: ${o.height}px !important;`:""}\n ${null!=(null==o?void 0:o.borderRadius)?`border-radius: ${o.borderRadius}px !important;`:""}\n background: ${null!==(t=null==o?void 0:o.fillColor)&&void 0!==t?t:a.indicatorColor} !important;\n }\n .swiper-pagination-bullet-active {\n ${null!=(null==s?void 0:s.width)?`width: ${s.width}px !important;`:""}\n ${null!=(null==s?void 0:s.height)?`height: ${s.height}px !important;`:""}\n ${null!=(null==s?void 0:s.borderRadius)?`border-radius: ${s.borderRadius}px !important;`:""}\n background: ${null!==(i=null==s?void 0:s.fillColor)&&void 0!==i?i:a.activeIndicatorColor} !important;\n }\n `)}},{key:"updated",value:function(){var e,t,i=[TF,PF],n=this.component,a=n.autoplay,r=n.autoplaySeconds,o=n.showIndicators,s=n.slideSpacing,u=n.inactiveSlideScale;u&&i.push(xF),EF.use(i);var l=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".swiper-container"),d=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".swiper-pagination");if(l&&!this.swiperInstance){var h,c={initialSlide:0,slidesPerView:1,loop:a,spaceBetween:null!==(h=null!=s?s:this.slideSpacing)&&void 0!==h?h:0,autoplay:!!a&&{delay:1e3*r,disableOnInteraction:!1},pagination:!(null!=o&&!o)&&{el:d,clickable:!0},on:{init:e=>{this.handleSlideChange(e)},slideChange:e=>{this.handleSlideChange(e)}}};u&&(c.effect="coverflow",c.coverflowEffect={rotate:0,stretch:0,depth:100,modifier:1,slideShadows:!1,scale:u}),this.swiperInstance=new EF(l,c)}}},{key:"handleSlideChange",value:function(e){if(this.contextProvider.setCurrentSlideIndex(e.realIndex),this.component.onChange){var t,i=this.getCarouselOnChange(this.component),n=null==i||null===(t=i.parameters)||void 0===t||null===(t=t.partialState)||void 0===t?void 0:t.currentGroupId;n&&this.contextProvider.setCurrentGroupData(n,"")}}},{key:"getCarouselOnChange",value:function(e){var t;if(e.onChange&&e.onChange.parameters){var i=this.contextProvider.state.slides,n="string"==typeof e.loopSource?e.loopSource:"",a=null==i||null===(t=i[n])||void 0===t||null===(t=t.carouselName)||void 0===t?void 0:t[this.contextProvider.state.currentSlideIndex];return Fa(e.onChange,{slide:a,sku:this.contextProvider.state.sku,state:this.contextProvider.state,launch:this.contextProvider.state.launch,customer:this.contextProvider.state.customer})}}},{key:"getCarouselSlides",value:function(e){var t,i;if(!e.loopSource)return[];var n,a=this.contextProvider.state,r=a.slides,o=a.selectedProducts,s="string"==typeof e.loopSource?e.loopSource:"",u=xa(this.contextProvider.productDetails,null!==(t=null===(i=this.contextProvider.getSelectedPaywall())||void 0===i?void 0:i.sku_menus)&&void 0!==t?t:[],s),l=[];A(r)||(l=""!=s?r[s].carouselName:null!==(n=e.loopSource)&&void 0!==n?n:[]);var d=this.contextProvider.filteredSkuMenus.map(e=>e.id);return l.filter(e=>!e.productGroupId||d.includes(e.productGroupId)).map(t=>{var i=u.find(e=>e.id==o[t.productGroupId]);return Fa(e.components,Fa({slide:t},{sku:re({},Ia(null==i?void 0:i.product_details,t,u))}))||[]})}},{key:"render",value:function(){var e=this.getCarouselSlides(this.component),t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&Ka(a,n)||(this.tabIndex=0),B(CF||(CF=LF`
|
|
513
|
+
`),e.header?B(pR||(pR=gR`<div class="nami-group-header">${0}</div>`),e.header.map(a)):null,e.items.map(e=>e.map(a))))}}])}();function bR(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function wR(e={},t={}){var i=["__proto__","constructor","prototype"];Object.keys(t).filter(e=>i.indexOf(e)<0).forEach(i=>{void 0===e[i]?e[i]=t[i]:bR(t[i])&&bR(e[i])&&Object.keys(t[i]).length>0&&wR(e[i],t[i])})}gt([qt({type:Object})],yR.prototype,"component",void 0),gt([qt({type:Boolean})],yR.prototype,"inFocusedState",void 0),gt([qt({type:Number})],yR.prototype,"scaleFactor",void 0),gt([qt({type:Object})],yR.prototype,"minSDKVersion",void 0),yR=gt([Tt("nami-repeating-grid")],yR);var kR={body:{},addEventListener(){},removeEventListener(){},activeElement:{blur(){},nodeName:""},querySelector:()=>null,querySelectorAll:()=>[],getElementById:()=>null,createEvent:()=>({initEvent(){}}),createElement:()=>({children:[],childNodes:[],style:{},setAttribute(){},getElementsByTagName:()=>[]}),createElementNS:()=>({}),importNode:()=>null,location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""}};function SR(){var e="undefined"!=typeof document?document:{};return wR(e,kR),e}var ER,MR,TR,PR={document:kR,navigator:{userAgent:""},location:{hash:"",host:"",hostname:"",href:"",origin:"",pathname:"",protocol:"",search:""},history:{replaceState(){},pushState(){},go(){},back(){}},CustomEvent:function(){return this},addEventListener(){},removeEventListener(){},getComputedStyle:()=>({getPropertyValue:()=>""}),Image(){},Date(){},screen:{},setTimeout(){},clearTimeout(){},matchMedia:()=>({}),requestAnimationFrame:e=>"undefined"==typeof setTimeout?(e(),null):setTimeout(e,0),cancelAnimationFrame(e){"undefined"!=typeof setTimeout&&clearTimeout(e)}};function AR(){var e="undefined"!=typeof window?window:{};return wR(e,PR),e}function DR(e,t=0){return setTimeout(e,t)}function xR(){return Date.now()}function CR(e,t="x"){var i,n,a,r=AR(),o=function(e){var t,i=AR();return i.getComputedStyle&&(t=i.getComputedStyle(e,null)),!t&&e.currentStyle&&(t=e.currentStyle),t||(t=e.style),t}(e);return r.WebKitCSSMatrix?((n=o.transform||o.webkitTransform).split(",").length>6&&(n=n.split(", ").map(e=>e.replace(",",".")).join(", ")),a=new r.WebKitCSSMatrix("none"===n?"":n)):i=(a=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,")).toString().split(","),"x"===t&&(n=r.WebKitCSSMatrix?a.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(n=r.WebKitCSSMatrix?a.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),n||0}function IR(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function LR(e){return"undefined"!=typeof window&&void 0!==window.HTMLElement?e instanceof HTMLElement:e&&(1===e.nodeType||11===e.nodeType)}function _R(...e){for(var t=Object(e[0]),i=1;i<e.length;i+=1){var n=e[i];if(null!=n&&!LR(n))for(var a=Object.keys(Object(n)).filter(e=>"__proto__"!==e&&"constructor"!==e&&"prototype"!==e),r=0,o=a.length;r<o;r+=1){var s=a[r],u=Object.getOwnPropertyDescriptor(n,s);void 0!==u&&u.enumerable&&(IR(t[s])&&IR(n[s])?n[s].__swiper__?t[s]=n[s]:_R(t[s],n[s]):!IR(t[s])&&IR(n[s])?(t[s]={},n[s].__swiper__?t[s]=n[s]:_R(t[s],n[s])):t[s]=n[s])}}return t}function RR(e,t,i){e.style.setProperty(t,i)}function FR({swiper:e,targetPosition:t,side:i}){var n,a=AR(),r=-e.translate,o=null,s=e.params.speed;e.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(e.cssModeFrameID);var u=t>r?"next":"prev",l=(e,t)=>"next"===u&&e>=t||"prev"===u&&e<=t,d=()=>{n=(new Date).getTime(),null===o&&(o=n);var u=Math.max(Math.min((n-o)/s,1),0),h=.5-Math.cos(u*Math.PI)/2,c=r+h*(t-r);if(l(c,t)&&(c=t),e.wrapperEl.scrollTo({[i]:c}),l(c,t))return e.wrapperEl.style.overflow="hidden",e.wrapperEl.style.scrollSnapType="",setTimeout(()=>{e.wrapperEl.style.overflow="",e.wrapperEl.scrollTo({[i]:c})}),void a.cancelAnimationFrame(e.cssModeFrameID);e.cssModeFrameID=a.requestAnimationFrame(d)};d()}function WR(e){return e.querySelector(".swiper-slide-transform")||e.shadowRoot&&e.shadowRoot.querySelector(".swiper-slide-transform")||e}function OR(e,t=""){var i=AR(),n=[...e.children];return i.HTMLSlotElement&&e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter(e=>e.matches(t)):n}function $R(e){try{return void console.warn(e)}catch(e){}}function NR(e,t=[]){var i=document.createElement(e);return i.classList.add(...Array.isArray(t)?t:function(e=""){return e.trim().split(" ").filter(e=>!!e.trim())}(t)),i}function jR(e,t){return AR().getComputedStyle(e,null).getPropertyValue(t)}function BR(e){var t,i=e;if(i){for(t=0;null!==(i=i.previousSibling);)1===i.nodeType&&(t+=1);return t}}function zR(e,t){for(var i=[],n=e.parentElement;n;)t?n.matches(t)&&i.push(n):i.push(n),n=n.parentElement;return i}function UR(e,t,i){var n=AR();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(n.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function HR(e){return(Array.isArray(e)?e:[e]).filter(e=>!!e)}function GR(e,t=""){"undefined"!=typeof trustedTypes?e.innerHTML=trustedTypes.createPolicy("html",{createHTML:e=>e}).createHTML(t):e.innerHTML=t}function VR(){return ER||(ER=function(){var e=AR(),t=SR();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),ER}function KR(e={}){return MR||(MR=function({userAgent:e}={}){var t=VR(),i=AR(),n=i.navigator.platform,a=e||i.navigator.userAgent,r={ios:!1,android:!1},o=i.screen.width,s=i.screen.height,u=a.match(/(Android);?[\s\/]+([\d.]+)?/),l=a.match(/(iPad)(?!\1).*OS\s([\d_]+)/),d=a.match(/(iPod)(.*OS\s([\d_]+))?/),h=!l&&a.match(/(iPhone\sOS|iOS)\s([\d_]+)/),c="Win32"===n,m="MacIntel"===n;return!l&&m&&t.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${o}x${s}`)>=0&&((l=a.match(/(Version)\/([\d.]+)/))||(l=[0,1,"13_0_0"]),m=!1),u&&!c&&(r.os="android",r.android=!0),(l||h||d)&&(r.os="ios",r.ios=!0),r}(e)),MR}function XR(){return TR||(TR=function(){var e=AR(),t=KR(),i=!1;function n(){var t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(n()){var a=String(e.navigator.userAgent);if(a.includes("Version/")){var r=a.split("Version/")[1].split(" ")[0].split(".").map(e=>Number(e)),o=r[0],s=r[1];i=o<16||16===o&&s<2}}var u=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),l=n();return{isSafari:i||l,needPerspectiveFix:i,need3dFix:l||u&&t.ios,isWebView:u}}()),TR}var YR={on(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;var a=i?"unshift":"push";return e.split(" ").forEach(e=>{n.eventsListeners[e]||(n.eventsListeners[e]=[]),n.eventsListeners[e][a](t)}),n},once(e,t,i){var n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof t)return n;function a(...i){n.off(e,a),a.__emitterProxy&&delete a.__emitterProxy,t.apply(n,i)}return a.__emitterProxy=t,n.on(e,a,i)},onAny(e,t){var i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof e)return i;var n=t?"unshift":"push";return i.eventsAnyListeners.indexOf(e)<0&&i.eventsAnyListeners[n](e),i},offAny(e){var t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;var i=t.eventsAnyListeners.indexOf(e);return i>=0&&t.eventsAnyListeners.splice(i,1),t},off(e,t){var i=this;return!i.eventsListeners||i.destroyed?i:i.eventsListeners?(e.split(" ").forEach(e=>{void 0===t?i.eventsListeners[e]=[]:i.eventsListeners[e]&&i.eventsListeners[e].forEach((n,a)=>{(n===t||n.__emitterProxy&&n.__emitterProxy===t)&&i.eventsListeners[e].splice(a,1)})}),i):i},emit(...e){var t,i,n,a=this;return!a.eventsListeners||a.destroyed?a:a.eventsListeners?("string"==typeof e[0]||Array.isArray(e[0])?(t=e[0],i=e.slice(1,e.length),n=a):(t=e[0].events,i=e[0].data,n=e[0].context||a),i.unshift(n),(Array.isArray(t)?t:t.split(" ")).forEach(e=>{a.eventsAnyListeners&&a.eventsAnyListeners.length&&a.eventsAnyListeners.forEach(t=>{t.apply(n,[e,...i])}),a.eventsListeners&&a.eventsListeners[e]&&a.eventsListeners[e].forEach(e=>{e.apply(n,i)})}),a):a}};var qR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var JR=(e,t,i)=>{t&&!e.classList.contains(i)?e.classList.add(i):!t&&e.classList.contains(i)&&e.classList.remove(i)};var QR=(e,t)=>{if(e&&!e.destroyed&&e.params){var i=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(i){var n=i.querySelector(`.${e.params.lazyPreloaderClass}`);!n&&e.isElement&&(i.shadowRoot?n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame(()=>{i.shadowRoot&&(n=i.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`))&&!n.lazyPreloaderManaged&&n.remove()})),n&&!n.lazyPreloaderManaged&&n.remove()}}},ZR=(e,t)=>{if(e.slides[t]){var i=e.slides[t].querySelector('[loading="lazy"]');i&&i.removeAttribute("loading")}},eF=e=>{if(e&&!e.destroyed&&e.params){var t=e.params.lazyPreloadPrevNext,i=e.slides.length;if(i&&t&&!(t<0)){t=Math.min(t,i);var n="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){var r=a,o=[r-t];return o.push(...Array.from({length:t}).map((e,t)=>r+n+t)),void e.slides.forEach((t,i)=>{o.includes(t.column)&&ZR(e,i)})}var s=a+n-1;if(e.params.rewind||e.params.loop)for(var u=a-t;u<=s+t;u+=1){var l=(u%i+i)%i;(l<a||l>s)&&ZR(e,l)}else for(var d=Math.max(a-t,0);d<=Math.min(s+t,i-1);d+=1)d!==a&&(d>s||d<a)&&ZR(e,d)}}};var tF={updateSize:function(){var e,t,i=this,n=i.el;e=void 0!==i.params.width&&null!==i.params.width?i.params.width:n.clientWidth,t=void 0!==i.params.height&&null!==i.params.height?i.params.height:n.clientHeight,0===e&&i.isHorizontal()||0===t&&i.isVertical()||(e=e-parseInt(jR(n,"padding-left")||0,10)-parseInt(jR(n,"padding-right")||0,10),t=t-parseInt(jR(n,"padding-top")||0,10)-parseInt(jR(n,"padding-bottom")||0,10),Number.isNaN(e)&&(e=0),Number.isNaN(t)&&(t=0),Object.assign(i,{width:e,height:t,size:i.isHorizontal()?e:t}))},updateSlides:function(){var e=this;function t(t,i){return parseFloat(t.getPropertyValue(e.getDirectionLabel(i))||0)}var i=e.params,n=e.wrapperEl,a=e.slidesEl,r=e.rtlTranslate,o=e.wrongRTL,s=e.virtual&&i.virtual.enabled,u=s?e.virtual.slides.length:e.slides.length,l=OR(a,`.${e.params.slideClass}, swiper-slide`),d=s?e.virtual.slides.length:l.length,h=[],c=[],m=[],f=i.slidesOffsetBefore;"function"==typeof f&&(f=i.slidesOffsetBefore.call(e));var v=i.slidesOffsetAfter;"function"==typeof v&&(v=i.slidesOffsetAfter.call(e));var p=e.snapGrid.length,g=e.slidesGrid.length,y=e.size-f-v,b=i.spaceBetween,w=-f,k=0,S=0;if(void 0!==y){"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*y:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b-f-v,l.forEach(e=>{r?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""}),i.centeredSlides&&i.cssMode&&(RR(n,"--swiper-centered-offset-before",""),RR(n,"--swiper-centered-offset-after","")),i.cssMode&&(RR(n,"--swiper-slides-offset-before",`${f}px`),RR(n,"--swiper-slides-offset-after",`${v}px`));var E,M=i.grid&&i.grid.rows>1&&e.grid;M?e.grid.initSlides(l):e.grid&&e.grid.unsetSlides();for(var T="auto"===i.slidesPerView&&i.breakpoints&&Object.keys(i.breakpoints).filter(e=>void 0!==i.breakpoints[e].slidesPerView).length>0,P=0;P<d;P+=1){E=0;var A=l[P];if(!A||(M&&e.grid.updateSlide(P,A,l),"none"!==jR(A,"display"))){if(s&&"auto"===i.slidesPerView)i.virtual.slidesPerViewAutoSlideSize&&(E=i.virtual.slidesPerViewAutoSlideSize),E&&A&&(i.roundLengths&&(E=Math.floor(E)),A.style[e.getDirectionLabel("width")]=`${E}px`);else if("auto"===i.slidesPerView){T&&(A.style[e.getDirectionLabel("width")]="");var D=getComputedStyle(A),x=A.style.transform,C=A.style.webkitTransform;if(x&&(A.style.transform="none"),C&&(A.style.webkitTransform="none"),i.roundLengths)E=e.isHorizontal()?UR(A,"width"):UR(A,"height");else{var I=t(D,"width"),L=t(D,"padding-left"),_=t(D,"padding-right"),R=t(D,"margin-left"),F=t(D,"margin-right"),W=D.getPropertyValue("box-sizing");if(W&&"border-box"===W)E=I+R+F;else{var O=A.clientWidth;E=I+L+_+R+F+(A.offsetWidth-O)}}x&&(A.style.transform=x),C&&(A.style.webkitTransform=C),i.roundLengths&&(E=Math.floor(E))}else E=(y-(i.slidesPerView-1)*b)/i.slidesPerView,i.roundLengths&&(E=Math.floor(E)),A&&(A.style[e.getDirectionLabel("width")]=`${E}px`);A&&(A.swiperSlideSize=E),m.push(E),i.centeredSlides?(w=w+E/2+k/2+b,0===k&&0!==P&&(w=w-y/2-b),0===P&&(w=w-y/2-b),Math.abs(w)<.001&&(w=0),i.roundLengths&&(w=Math.floor(w)),S%i.slidesPerGroup===0&&h.push(w),c.push(w)):(i.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup===0&&h.push(w),c.push(w),w=w+E+b),e.virtualSize+=E+b,k=E,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,y)+v,r&&o&&("slide"===i.effect||"coverflow"===i.effect)&&(n.style.width=`${e.virtualSize+b}px`),i.setWrapperSize&&(n.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),M&&e.grid.updateWrapperSize(E,h),!i.centeredSlides){var $="auto"!==i.slidesPerView&&i.slidesPerView%1!=0,N=i.snapToSlideEdge&&!i.loop&&("auto"===i.slidesPerView||$),j=h.length;if(N){var B;if("auto"===i.slidesPerView){B=1;for(var z=0,U=m.length-1;U>=0&&(z+=m[U]+(U<m.length-1?b:0))<=y;U-=1)B=m.length-U}else B=Math.floor(i.slidesPerView);j=Math.max(d-B,0)}for(var H=[],G=0;G<h.length;G+=1){var V=h[G];i.roundLengths&&(V=Math.floor(V)),N?G<=j&&H.push(V):h[G]<=e.virtualSize-y&&H.push(V)}h=H,Math.floor(e.virtualSize-y)-Math.floor(h[h.length-1])>1&&(N||h.push(e.virtualSize-y))}if(s&&i.loop){var K=m[0]+b;if(i.slidesPerGroup>1)for(var X=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/i.slidesPerGroup),Y=K*i.slidesPerGroup,q=0;q<X;q+=1)h.push(h[h.length-1]+Y);for(var J=0;J<e.virtual.slidesBefore+e.virtual.slidesAfter;J+=1)1===i.slidesPerGroup&&h.push(h[h.length-1]+K),c.push(c[c.length-1]+K),e.virtualSize+=K}if(0===h.length&&(h=[0]),0!==b){var Q=e.isHorizontal()&&r?"marginLeft":e.getDirectionLabel("marginRight");l.filter((e,t)=>!(i.cssMode&&!i.loop)||t!==l.length-1).forEach(e=>{e.style[Q]=`${b}px`})}if(i.centeredSlides&&i.centeredSlidesBounds){var Z=0;m.forEach(e=>{Z+=e+(b||0)});var ee=(Z-=b)>y?Z-y:0;h=h.map(e=>e<=0?-f:e>ee?ee+v:e)}if(i.centerInsufficientSlides){var te=0;if(m.forEach(e=>{te+=e+(b||0)}),(te-=b)<y){var ie=(y-te)/2;h.forEach((e,t)=>{h[t]=e-ie}),c.forEach((e,t)=>{c[t]=e+ie})}}if(Object.assign(e,{slides:l,snapGrid:h,slidesGrid:c,slidesSizesGrid:m}),i.centeredSlides&&i.cssMode&&!i.centeredSlidesBounds){RR(n,"--swiper-centered-offset-before",-h[0]+"px"),RR(n,"--swiper-centered-offset-after",e.size/2-m[m.length-1]/2+"px");var ne=-e.snapGrid[0],ae=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map(e=>e+ne),e.slidesGrid=e.slidesGrid.map(e=>e+ae)}if(d!==u&&e.emit("slidesLengthChange"),h.length!==p&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),c.length!==g&&e.emit("slidesGridLengthChange"),i.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(s||i.cssMode||"slide"!==i.effect&&"fade"!==i.effect)){var re=`${i.containerModifierClass}backface-hidden`,oe=e.el.classList.contains(re);d<=i.maxBackfaceHiddenSlides?oe||e.el.classList.add(re):oe&&e.el.classList.remove(re)}}},updateAutoHeight:function(e){var t,i=this,n=[],a=i.virtual&&i.params.virtual.enabled,r=0;"number"==typeof e?i.setTransition(e):!0===e&&i.setTransition(i.params.speed);var o=e=>a?i.slides[i.getSlideIndexByData(e)]:i.slides[e];if("auto"!==i.params.slidesPerView&&i.params.slidesPerView>1)if(i.params.centeredSlides)(i.visibleSlides||[]).forEach(e=>{n.push(e)});else for(t=0;t<Math.ceil(i.params.slidesPerView);t+=1){var s=i.activeIndex+t;if(s>i.slides.length&&!a)break;n.push(o(s))}else n.push(o(i.activeIndex));for(t=0;t<n.length;t+=1)if(void 0!==n[t]){var u=n[t].offsetHeight;r=u>r?u:r}(r||0===r)&&(i.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){for(var e=this,t=e.slides,i=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0,n=0;n<t.length;n+=1)t[n].swiperSlideOffset=(e.isHorizontal()?t[n].offsetLeft:t[n].offsetTop)-i-e.cssOverflowAdjustment()},updateSlidesProgress:function(e=this&&this.translate||0){var t=this,i=t.params,n=t.slides,a=t.rtlTranslate,r=t.snapGrid;if(0!==n.length){void 0===n[0].swiperSlideOffset&&t.updateSlidesOffset();var o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];var s=i.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(var u=0;u<n.length;u+=1){var l=n[u],d=l.swiperSlideOffset;i.cssMode&&i.centeredSlides&&(d-=n[0].swiperSlideOffset);var h=(o+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),c=(o-r[0]+(i.centeredSlides?t.minTranslate():0)-d)/(l.swiperSlideSize+s),m=-(o-d),f=m+t.slidesSizesGrid[u],v=m>=0&&m<=t.size-t.slidesSizesGrid[u],p=m>=0&&m<t.size-1||f>1&&f<=t.size||m<=0&&f>=t.size;p&&(t.visibleSlides.push(l),t.visibleSlidesIndexes.push(u)),qR(l,p,i.slideVisibleClass),qR(l,v,i.slideFullyVisibleClass),l.progress=a?-h:h,l.originalProgress=a?-c:c}}},updateProgress:function(e){var t=this;if(void 0===e){var i=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*i||0}var n=t.params,a=t.maxTranslate()-t.minTranslate(),r=t.progress,o=t.isBeginning,s=t.isEnd,u=t.progressLoop,l=o,d=s;if(0===a)r=0,o=!0,s=!0;else{r=(e-t.minTranslate())/a;var h=Math.abs(e-t.minTranslate())<1,c=Math.abs(e-t.maxTranslate())<1;o=h||r<=0,s=c||r>=1,h&&(r=0),c&&(r=1)}if(n.loop){var m=t.getSlideIndexByData(0),f=t.getSlideIndexByData(t.slides.length-1),v=t.slidesGrid[m],p=t.slidesGrid[f],g=t.slidesGrid[t.slidesGrid.length-1],y=Math.abs(e);(u=y>=v?(y-v)/g:(y+g-p)/g)>1&&(u-=1)}Object.assign(t,{progress:r,progressLoop:u,isBeginning:o,isEnd:s}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),o&&!l&&t.emit("reachBeginning toEdge"),s&&!d&&t.emit("reachEnd toEdge"),(l&&!o||d&&!s)&&t.emit("fromEdge"),t.emit("progress",r)},updateSlidesClasses:function(){var e,t,i,n=this,a=n.slides,r=n.params,o=n.slidesEl,s=n.activeIndex,u=n.virtual&&r.virtual.enabled,l=n.grid&&r.grid&&r.grid.rows>1,d=e=>OR(o,`.${r.slideClass}${e}, swiper-slide${e}`)[0];if(u)if(r.loop){var h=s-n.virtual.slidesBefore;h<0&&(h=n.virtual.slides.length+h),h>=n.virtual.slides.length&&(h-=n.virtual.slides.length),e=d(`[data-swiper-slide-index="${h}"]`)}else e=d(`[data-swiper-slide-index="${s}"]`);else l?(e=a.find(e=>e.column===s),i=a.find(e=>e.column===s+1),t=a.find(e=>e.column===s-1)):e=a[s];e&&(l||(i=function(e,t){for(var i=[];e.nextElementSibling;){var n=e.nextElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&!i&&(i=a[0]),t=function(e,t){for(var i=[];e.previousElementSibling;){var n=e.previousElementSibling;t?n.matches(t)&&i.push(n):i.push(n),e=n}return i}(e,`.${r.slideClass}, swiper-slide`)[0],r.loop&&0===!t&&(t=a[a.length-1]))),a.forEach(n=>{JR(n,n===e,r.slideActiveClass),JR(n,n===i,r.slideNextClass),JR(n,n===t,r.slidePrevClass)}),n.emitSlidesClasses()},updateActiveIndex:function(e){var t,i=this,n=i.rtlTranslate?i.translate:-i.translate,a=i.snapGrid,r=i.params,o=i.activeIndex,s=i.realIndex,u=i.snapIndex,l=e,d=e=>{var t=e-i.virtual.slidesBefore;return t<0&&(t=i.virtual.slides.length+t),t>=i.virtual.slides.length&&(t-=i.virtual.slides.length),t};if(void 0===l&&(l=function(e){for(var t,i=e.slidesGrid,n=e.params,a=e.rtlTranslate?e.translate:-e.translate,r=0;r<i.length;r+=1)void 0!==i[r+1]?a>=i[r]&&a<i[r+1]-(i[r+1]-i[r])/2?t=r:a>=i[r]&&a<i[r+1]&&(t=r+1):a>=i[r]&&(t=r);return n.normalizeSlideIndex&&(t<0||void 0===t)&&(t=0),t}(i)),a.indexOf(n)>=0)t=a.indexOf(n);else{var h=Math.min(r.slidesPerGroupSkip,l);t=h+Math.floor((l-h)/r.slidesPerGroup)}if(t>=a.length&&(t=a.length-1),l!==o||i.params.loop)if(l===o&&i.params.loop&&i.virtual&&i.params.virtual.enabled)i.realIndex=d(l);else{var c,m=i.grid&&r.grid&&r.grid.rows>1;if(i.virtual&&r.virtual.enabled)c=r.loop?d(l):l;else if(m){var f=i.slides.find(e=>e.column===l),v=parseInt(f.getAttribute("data-swiper-slide-index"),10);Number.isNaN(v)&&(v=Math.max(i.slides.indexOf(f),0)),c=Math.floor(v/r.grid.rows)}else if(i.slides[l]){var p=i.slides[l].getAttribute("data-swiper-slide-index");c=p?parseInt(p,10):l}else c=l;Object.assign(i,{previousSnapIndex:u,snapIndex:t,previousRealIndex:s,realIndex:c,previousIndex:o,activeIndex:l}),i.initialized&&eF(i),i.emit("activeIndexChange"),i.emit("snapIndexChange"),(i.initialized||i.params.runCallbacksOnInit)&&(s!==c&&i.emit("realIndexChange"),i.emit("slideChange"))}else t!==u&&(i.snapIndex=t,i.emit("snapIndexChange"))},updateClickedSlide:function(e,t){var i=this,n=i.params,a=e.closest(`.${n.slideClass}, swiper-slide`);!a&&i.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach(e=>{!a&&e.matches&&e.matches(`.${n.slideClass}, swiper-slide`)&&(a=e)});var r,o=!1;if(a)for(var s=0;s<i.slides.length;s+=1)if(i.slides[s]===a){o=!0,r=s;break}if(!a||!o)return i.clickedSlide=void 0,void(i.clickedIndex=void 0);i.clickedSlide=a,i.virtual&&i.params.virtual.enabled?i.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):i.clickedIndex=r,n.slideToClickedSlide&&void 0!==i.clickedIndex&&i.clickedIndex!==i.activeIndex&&i.slideToClickedSlide()}};var iF={getTranslate:function(e=(this.isHorizontal()?"x":"y")){var t=this,i=t.params,n=t.rtlTranslate,a=t.translate,r=t.wrapperEl;if(i.virtualTranslate)return n?-a:a;if(i.cssMode)return a;var o=CR(r,e);return o+=t.cssOverflowAdjustment(),n&&(o=-o),o||0},setTranslate:function(e,t){var i=this,n=i.rtlTranslate,a=i.params,r=i.wrapperEl,o=i.progress,s=0,u=0;i.isHorizontal()?s=n?-e:e:u=e,a.roundLengths&&(s=Math.floor(s),u=Math.floor(u)),i.previousTranslate=i.translate,i.translate=i.isHorizontal()?s:u,a.cssMode?r[i.isHorizontal()?"scrollLeft":"scrollTop"]=i.isHorizontal()?-s:-u:a.virtualTranslate||(i.isHorizontal()?s-=i.cssOverflowAdjustment():u-=i.cssOverflowAdjustment(),r.style.transform=`translate3d(${s}px, ${u}px, 0px)`);var l=i.maxTranslate()-i.minTranslate();(0===l?0:(e-i.minTranslate())/l)!==o&&i.updateProgress(e),i.emit("setTranslate",i.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e=0,t=this.params.speed,i=!0,n=!0,a){var r=this,o=r.params,s=r.wrapperEl;if(r.animating&&o.preventInteractionOnTransition)return!1;var u,l=r.minTranslate(),d=r.maxTranslate();if(u=n&&e>l?l:n&&e<d?d:e,r.updateProgress(u),o.cssMode){var h=r.isHorizontal();if(0===t)s[h?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return FR({swiper:r,targetPosition:-u,side:h?"left":"top"}),!0;s.scrollTo({[h?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),i&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionStart")),r.animating||(r.animating=!0,r.onTranslateToWrapperTransitionEnd||(r.onTranslateToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onTranslateToWrapperTransitionEnd),r.onTranslateToWrapperTransitionEnd=null,delete r.onTranslateToWrapperTransitionEnd,r.animating=!1,i&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function nF({swiper:e,runCallbacks:t,direction:i,step:n}){var a=e.activeIndex,r=e.previousIndex,o=i;o||(o=a>r?"next":a<r?"prev":"reset"),e.emit(`transition${n}`),t&&"reset"===o?e.emit(`slideResetTransition${n}`):t&&a!==r&&(e.emit(`slideChangeTransition${n}`),"next"===o?e.emit(`slideNextTransition${n}`):e.emit(`slidePrevTransition${n}`))}var aF={slideTo:function(e=0,t,i=!0,n,a){"string"==typeof e&&(e=parseInt(e,10));var r=this,o=e;o<0&&(o=0);var s=r.params,u=r.snapGrid,l=r.slidesGrid,d=r.previousIndex,h=r.activeIndex,c=r.rtlTranslate,m=r.wrapperEl;if(!r.enabled&&!n&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);var f=Math.min(r.params.slidesPerGroupSkip,o),v=f+Math.floor((o-f)/r.params.slidesPerGroup);v>=u.length&&(v=u.length-1);var p,g=-u[v];if(s.normalizeSlideIndex)for(var y=0;y<l.length;y+=1){var b=-Math.floor(100*g),w=Math.floor(100*l[y]),k=Math.floor(100*l[y+1]);void 0!==l[y+1]?b>=w&&b<k-(k-w)/2?o=y:b>=w&&b<k&&(o=y+1):b>=w&&(o=y)}if(r.initialized&&o!==h){if(!r.allowSlideNext&&(c?g>r.translate&&g>r.minTranslate():g<r.translate&&g<r.minTranslate()))return!1;if(!r.allowSlidePrev&&g>r.translate&&g>r.maxTranslate()&&(h||0)!==o)return!1}o!==(d||0)&&i&&r.emit("beforeSlideChangeStart"),r.updateProgress(g),p=o>h?"next":o<h?"prev":"reset";var S=r.virtual&&r.params.virtual.enabled;if(!(S&&a)&&(c&&-g===r.translate||!c&&g===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(g),"reset"!==p&&(r.transitionStart(i,p),r.transitionEnd(i,p)),!1;if(s.cssMode){var E=r.isHorizontal(),M=c?g:-g;if(0===t)S&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),S&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame(()=>{m[E?"scrollLeft":"scrollTop"]=M})):m[E?"scrollLeft":"scrollTop"]=M,S&&requestAnimationFrame(()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1});else{if(!r.support.smoothScroll)return FR({swiper:r,targetPosition:M,side:E?"left":"top"}),!0;m.scrollTo({[E?"left":"top"]:M,behavior:"smooth"})}return!0}var T=XR().isSafari;return S&&!a&&T&&r.isElement&&r.virtual.update(!1,!1,o),r.setTransition(t),r.setTranslate(g),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,n),r.transitionStart(i,p),0===t?r.transitionEnd(i,p):r.animating||(r.animating=!0,r.onSlideToWrapperTransitionEnd||(r.onSlideToWrapperTransitionEnd=function(e){r&&!r.destroyed&&e.target===this&&(r.wrapperEl.removeEventListener("transitionend",r.onSlideToWrapperTransitionEnd),r.onSlideToWrapperTransitionEnd=null,delete r.onSlideToWrapperTransitionEnd,r.transitionEnd(i,p))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e=0,t,i=!0,n){"string"==typeof e&&(e=parseInt(e,10));var a=this;if(!a.destroyed){void 0===t&&(t=a.params.speed);var r=a.grid&&a.params.grid&&a.params.grid.rows>1,o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{var s;if(r){var u=o*a.params.grid.rows;s=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===u).column}else s=a.getSlideIndexByData(o);var l=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,d=a.params,h=d.centeredSlides,c=d.slidesOffsetBefore,m=d.slidesOffsetAfter,f=h||!!c||!!m,v=a.params.slidesPerView;"auto"===v?v=a.slidesPerViewDynamic():(v=Math.ceil(parseFloat(a.params.slidesPerView,10)),f&&v%2==0&&(v+=1));var p=l-s<v;if(f&&(p=p||s<Math.ceil(v/2)),n&&f&&"auto"!==a.params.slidesPerView&&!r&&(p=!1),p){var g=f?s<a.activeIndex?"prev":"next":s-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:g,slideTo:!0,activeSlideIndex:"next"===g?s+1:s-l+1,slideRealIndex:"next"===g?a.realIndex:void 0})}if(r){var y=o*a.params.grid.rows;o=a.slides.find(e=>1*e.getAttribute("data-swiper-slide-index")===y).column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame(()=>{a.slideTo(o,t,i,n)}),a}},slideNext:function(e,t=!0,i){var n=this,a=n.enabled,r=n.params,o=n.animating;if(!a||n.destroyed)return n;void 0===e&&(e=n.params.speed);var s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(n.slidesPerViewDynamic("current",!0),1));var u=n.activeIndex<r.slidesPerGroupSkip?1:s,l=n.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(n.loopFix({direction:"next"}),n._clientLeft=n.wrapperEl.clientLeft,n.activeIndex===n.slides.length-1&&r.cssMode)return requestAnimationFrame(()=>{n.slideTo(n.activeIndex+u,e,t,i)}),!0}return r.rewind&&n.isEnd?n.slideTo(0,e,t,i):n.slideTo(n.activeIndex+u,e,t,i)},slidePrev:function(e,t=!0,i){var n=this,a=n.params,r=n.snapGrid,o=n.slidesGrid,s=n.rtlTranslate,u=n.enabled,l=n.animating;if(!u||n.destroyed)return n;void 0===e&&(e=n.params.speed);var d=n.virtual&&a.virtual.enabled;if(a.loop){if(l&&!d&&a.loopPreventsSliding)return!1;n.loopFix({direction:"prev"}),n._clientLeft=n.wrapperEl.clientLeft}function h(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}var c,m=h(s?n.translate:-n.translate),f=r.map(e=>h(e)),v=a.freeMode&&a.freeMode.enabled,p=r[f.indexOf(m)-1];void 0===p&&(a.cssMode||v)&&(r.forEach((e,t)=>{m>=e&&(c=t)}),void 0!==c&&(p=v?r[c]:r[c>0?c-1:c]));var g=0;if(void 0!==p&&((g=o.indexOf(p))<0&&(g=n.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-n.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&n.isBeginning){var y=n.params.virtual&&n.params.virtual.enabled&&n.virtual?n.virtual.slides.length-1:n.slides.length-1;return n.slideTo(y,e,t,i)}return a.loop&&0===n.activeIndex&&a.cssMode?(requestAnimationFrame(()=>{n.slideTo(g,e,t,i)}),!0):n.slideTo(g,e,t,i)},slideReset:function(e,t=!0,i){var n=this;if(!n.destroyed)return void 0===e&&(e=n.params.speed),n.slideTo(n.activeIndex,e,t,i)},slideToClosest:function(e,t=!0,i,n=.5){var a=this;if(!a.destroyed){void 0===e&&(e=a.params.speed);var r=a.activeIndex,o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),u=a.rtlTranslate?a.translate:-a.translate;if(u>=a.snapGrid[s]){var l=a.snapGrid[s];u-l>(a.snapGrid[s+1]-l)*n&&(r+=a.params.slidesPerGroup)}else{var d=a.snapGrid[s-1];u-d<=(a.snapGrid[s]-d)*n&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,i)}},slideToClickedSlide:function(){var e=this;if(!e.destroyed){var t,i=e.params,n=e.slidesEl,a="auto"===i.slidesPerView?e.slidesPerViewDynamic():i.slidesPerView,r=e.getSlideIndexWhenGrid(e.clickedIndex),o=e.isElement?"swiper-slide":`.${i.slideClass}`,s=e.grid&&e.params.grid&&e.params.grid.rows>1;if(i.loop){if(e.animating)return;t=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),i.centeredSlides?e.slideToLoop(t):r>(s?(e.slides.length-a)/2-(e.params.grid.rows-1):e.slides.length-a)?(e.loopFix(),r=e.getSlideIndex(OR(n,`${o}[data-swiper-slide-index="${t}"]`)[0]),DR(()=>{e.slideTo(r)})):e.slideTo(r)}else e.slideTo(r)}}};var rF={loopCreate:function(e,t){var i=this,n=i.params,a=i.slidesEl;if(!(!n.loop||i.virtual&&i.params.virtual.enabled)){var r,o=()=>{OR(a,`.${n.slideClass}, swiper-slide`).forEach((e,t)=>{e.setAttribute("data-swiper-slide-index",t)})},s=i.grid&&n.grid&&n.grid.rows>1;n.loopAddBlankSlides&&(n.slidesPerGroup>1||s)&&((r=OR(a,`.${n.slideBlankClass}`)).forEach(e=>{e.remove()}),r.length>0&&(i.recalcSlides(),i.updateSlides()));var u=n.slidesPerGroup*(s?n.grid.rows:1),l=i.slides.length%u!==0,d=s&&i.slides.length%n.grid.rows!==0,h=e=>{for(var t=0;t<e;t+=1){var a=i.isElement?NR("swiper-slide",[n.slideBlankClass]):NR("div",[n.slideClass,n.slideBlankClass]);i.slidesEl.append(a)}};if(l){if(n.loopAddBlankSlides)h(u-i.slides.length%u),i.recalcSlides(),i.updateSlides();else $R("Swiper Loop Warning: The number of slides is not even to slidesPerGroup, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else if(d){if(n.loopAddBlankSlides)h(n.grid.rows-i.slides.length%n.grid.rows),i.recalcSlides(),i.updateSlides();else $R("Swiper Loop Warning: The number of slides is not even to grid.rows, loop mode may not function properly. You need to add more slides (or make duplicates, or empty slides)");o()}else o();var c=n.centeredSlides||!!n.slidesOffsetBefore||!!n.slidesOffsetAfter;i.loopFix({slideRealIndex:e,direction:c?void 0:"next",initial:t})}},loopFix:function({slideRealIndex:e,slideTo:t=!0,direction:i,setTranslate:n,activeSlideIndex:a,initial:r,byController:o,byMousewheel:s}={}){var u=this;if(u.params.loop){u.emit("beforeLoopFix");var l=u.slides,d=u.allowSlidePrev,h=u.allowSlideNext,c=u.slidesEl,m=u.params,f=m.centeredSlides,v=m.slidesOffsetBefore,p=m.slidesOffsetAfter,g=m.initialSlide,y=f||!!v||!!p;if(u.allowSlidePrev=!0,u.allowSlideNext=!0,u.virtual&&m.virtual.enabled)return t&&(y||0!==u.snapIndex?y&&u.snapIndex<m.slidesPerView?u.slideTo(u.virtual.slides.length+u.snapIndex,0,!1,!0):u.snapIndex===u.snapGrid.length-1&&u.slideTo(u.virtual.slidesBefore,0,!1,!0):u.slideTo(u.virtual.slides.length,0,!1,!0)),u.allowSlidePrev=d,u.allowSlideNext=h,void u.emit("loopFix");var b=m.slidesPerView;"auto"===b?b=u.slidesPerViewDynamic():(b=Math.ceil(parseFloat(m.slidesPerView,10)),y&&b%2==0&&(b+=1));var w=m.slidesPerGroupAuto?b:m.slidesPerGroup,k=y?Math.max(w,Math.ceil(b/2)):w;k%w!==0&&(k+=w-k%w),k+=m.loopAdditionalSlides,u.loopedSlides=k;var S=u.grid&&m.grid&&m.grid.rows>1;l.length<b+k||"cards"===u.params.effect&&l.length<b+2*k?$R("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled or not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):S&&"row"===m.grid.fill&&$R("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");var E=[],M=[],T=S?Math.ceil(l.length/m.grid.rows):l.length,P=r&&T-g<b&&!y,A=P?g:u.activeIndex;void 0===a?a=u.getSlideIndex(l.find(e=>e.classList.contains(m.slideActiveClass))):A=a;var D="next"===i||!i,x="prev"===i||!i,C=0,I=0,L=(S?l[a].column:a)+(y&&void 0===n?-b/2+.5:0);if(L<k){C=Math.max(k-L,w);for(var _=0;_<k-L;_+=1){var R=_-Math.floor(_/T)*T;if(S)for(var F=T-R-1,W=l.length-1;W>=0;W-=1)l[W].column===F&&E.push(W);else E.push(T-R-1)}}else if(L+b>T-k){I=Math.max(L-(T-2*k),w),P&&(I=Math.max(I,b-T+g+1));for(var O=function(){var e=$-Math.floor($/T)*T;S?l.forEach((t,i)=>{t.column===e&&M.push(i)}):M.push(e)},$=0;$<I;$+=1)O()}if(u.__preventObserver__=!0,requestAnimationFrame(()=>{u.__preventObserver__=!1}),"cards"===u.params.effect&&l.length<b+2*k&&(M.includes(a)&&M.splice(M.indexOf(a),1),E.includes(a)&&E.splice(E.indexOf(a),1)),x&&E.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.prepend(l[e]),l[e].swiperLoopMoveDOM=!1}),D&&M.forEach(e=>{l[e].swiperLoopMoveDOM=!0,c.append(l[e]),l[e].swiperLoopMoveDOM=!1}),u.recalcSlides(),"auto"===m.slidesPerView?u.updateSlides():S&&(E.length>0&&x||M.length>0&&D)&&u.slides.forEach((e,t)=>{u.grid.updateSlide(t,e,u.slides)}),m.watchSlidesProgress&&u.updateSlidesOffset(),t)if(E.length>0&&x){if(void 0===e){var N=u.slidesGrid[A],j=u.slidesGrid[A+C]-N;s?u.setTranslate(u.translate-j):(u.slideTo(A+Math.ceil(C),0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-j,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-j))}else if(n){var B=S?E.length/m.grid.rows:E.length;u.slideTo(u.activeIndex+B,0,!1,!0),u.touchEventsData.currentTranslate=u.translate}}else if(M.length>0&&D)if(void 0===e){var z=u.slidesGrid[A],U=u.slidesGrid[A-I]-z;s?u.setTranslate(u.translate-U):(u.slideTo(A-I,0,!1,!0),n&&(u.touchEventsData.startTranslate=u.touchEventsData.startTranslate-U,u.touchEventsData.currentTranslate=u.touchEventsData.currentTranslate-U))}else{var H=S?M.length/m.grid.rows:M.length;u.slideTo(u.activeIndex-H,0,!1,!0)}if(u.allowSlidePrev=d,u.allowSlideNext=h,u.controller&&u.controller.control&&!o){var G={slideRealIndex:e,direction:i,setTranslate:n,activeSlideIndex:a,byController:!0};Array.isArray(u.controller.control)?u.controller.control.forEach(e=>{!e.destroyed&&e.params.loop&&e.loopFix(re({},G,{slideTo:e.params.slidesPerView===m.slidesPerView&&t}))}):u.controller.control instanceof u.constructor&&u.controller.control.params.loop&&u.controller.control.loopFix(re({},G,{slideTo:u.controller.control.params.slidesPerView===m.slidesPerView&&t}))}u.emit("loopFix")}},loopDestroy:function(){var e=this,t=e.params,i=e.slidesEl;if(t.loop&&i&&(!e.virtual||!e.params.virtual.enabled)){e.recalcSlides();var n=[];e.slides.forEach(e=>{var t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;n[t]=e}),e.slides.forEach(e=>{e.removeAttribute("data-swiper-slide-index")}),n.forEach(e=>{i.append(e)}),e.recalcSlides(),e.slideTo(e.realIndex,0)}}};var oF={setGrabCursor:function(e){var t=this;if(!(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)){var i="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),i.style.cursor="move",i.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame(()=>{t.__preventObserver__=!1})}},unsetGrabCursor:function(){var e=this;e.params.watchOverflow&&e.isLocked||e.params.cssMode||(e.isElement&&(e.__preventObserver__=!0),e["container"===e.params.touchEventsTarget?"el":"wrapperEl"].style.cursor="",e.isElement&&requestAnimationFrame(()=>{e.__preventObserver__=!1}))}};function sF(e,t,i){var n=AR(),a=e.params,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(i<=o||i>=n.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function uF(e){var t=this,i=SR(),n=e;n.originalEvent&&(n=n.originalEvent);var a=t.touchEventsData;if("pointerdown"===n.type){if(null!==a.pointerId&&a.pointerId!==n.pointerId)return;a.pointerId=n.pointerId}else"touchstart"===n.type&&1===n.targetTouches.length&&(a.touchId=n.targetTouches[0].identifier);if("touchstart"!==n.type){var r=t.params,o=t.touches;if(t.enabled&&(r.simulateTouch||"mouse"!==n.pointerType)&&(!t.animating||!r.preventInteractionOnTransition)){!t.animating&&r.cssMode&&r.loop&&t.loopFix();var s=n.target;if(("wrapper"!==r.touchEventsTarget||function(e,t){var i=AR(),n=t.contains(e);return!n&&i.HTMLSlotElement&&t instanceof HTMLSlotElement&&((n=[...t.assignedElements()].includes(e))||(n=function(e,t){for(var i=[t];i.length>0;){var n=i.shift();if(e===n)return!0;i.push(...n.children,...n.shadowRoot?n.shadowRoot.children:[],...n.assignedElements?n.assignedElements():[])}}(e,t))),n}(s,t.wrapperEl))&&!("which"in n&&3===n.which||"button"in n&&n.button>0||a.isTouched&&a.isMoved)){var u=!!r.noSwipingClass&&""!==r.noSwipingClass,l=n.composedPath?n.composedPath():n.path;u&&n.target&&n.target.shadowRoot&&l&&(s=l[0]);var d=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!n.target||!n.target.shadowRoot);if(r.noSwiping&&(h?function(e,t=this){return function t(i){if(!i||i===SR()||i===AR())return null;i.assignedSlot&&(i=i.assignedSlot);var n=i.closest(e);return n||i.getRootNode?n||t(i.getRootNode().host):null}(t)}(d,s):s.closest(d)))t.allowClick=!0;else if(!r.swipeHandler||s.closest(r.swipeHandler)){o.currentX=n.pageX,o.currentY=n.pageY;var c=o.currentX,m=o.currentY;if(sF(t,n,c)){Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=c,o.startY=m,a.touchStartTime=xR(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);var f=!0;s.matches(a.focusableElements)&&(f=!1,"SELECT"===s.nodeName&&(a.isTouched=!1)),i.activeElement&&i.activeElement.matches(a.focusableElements)&&i.activeElement!==s&&("mouse"===n.pointerType||"mouse"!==n.pointerType&&!s.matches(a.focusableElements))&&i.activeElement.blur();var v=f&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!v||s.isContentEditable||n.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",n)}}}}}else sF(t,n,n.targetTouches[0].pageX)}function lF(e){var t=SR(),i=this,n=i.touchEventsData,a=i.params,r=i.touches,o=i.rtlTranslate;if(i.enabled&&(a.simulateTouch||"mouse"!==e.pointerType)){var s,u=e;if(u.originalEvent&&(u=u.originalEvent),"pointermove"===u.type){if(null!==n.touchId)return;if(u.pointerId!==n.pointerId)return}if("touchmove"===u.type){if(s=[...u.changedTouches].find(e=>e.identifier===n.touchId),!s||s.identifier!==n.touchId)return}else s=u;if(n.isTouched){var l=s.pageX,d=s.pageY;if(u.preventedByNestedSwiper)return r.startX=l,void(r.startY=d);if(!i.allowTouchMove)return u.target.matches(n.focusableElements)||(i.allowClick=!1),void(n.isTouched&&(Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d}),n.touchStartTime=xR()));if(a.touchReleaseOnEdges&&!a.loop)if(i.isVertical()){if(d<r.startY&&i.translate<=i.maxTranslate()||d>r.startY&&i.translate>=i.minTranslate())return n.isTouched=!1,void(n.isMoved=!1)}else{if(o&&(l>r.startX&&-i.translate<=i.maxTranslate()||l<r.startX&&-i.translate>=i.minTranslate()))return;if(!o&&(l<r.startX&&i.translate<=i.maxTranslate()||l>r.startX&&i.translate>=i.minTranslate()))return}if(t.activeElement&&t.activeElement.matches(n.focusableElements)&&t.activeElement!==u.target&&"mouse"!==u.pointerType&&t.activeElement.blur(),t.activeElement&&u.target===t.activeElement&&u.target.matches(n.focusableElements))return n.isMoved=!0,void(i.allowClick=!1);n.allowTouchCallbacks&&i.emit("touchMove",u),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=l,r.currentY=d;var h=r.currentX-r.startX,c=r.currentY-r.startY;if(!(i.params.threshold&&Math.sqrt(h**2+c**2)<i.params.threshold)){var m;if(void 0===n.isScrolling)i.isHorizontal()&&r.currentY===r.startY||i.isVertical()&&r.currentX===r.startX?n.isScrolling=!1:h*h+c*c>=25&&(m=180*Math.atan2(Math.abs(c),Math.abs(h))/Math.PI,n.isScrolling=i.isHorizontal()?m>a.touchAngle:90-m>a.touchAngle);if(n.isScrolling&&i.emit("touchMoveOpposite",u),void 0===n.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(n.startMoving=!0)),n.isScrolling||"touchmove"===u.type&&n.preventTouchMoveFromPointerMove)n.isTouched=!1;else if(n.startMoving){i.allowClick=!1,!a.cssMode&&u.cancelable&&u.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&u.stopPropagation();var f=i.isHorizontal()?h:c,v=i.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),v=Math.abs(v)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,v=-v);var p=i.touchesDirection;i.swipeDirection=f>0?"prev":"next",i.touchesDirection=v>0?"prev":"next";var g=i.params.loop&&!a.cssMode,y="next"===i.touchesDirection&&i.allowSlideNext||"prev"===i.touchesDirection&&i.allowSlidePrev;if(!n.isMoved){if(g&&y&&i.loopFix({direction:i.swipeDirection}),n.startTranslate=i.getTranslate(),i.setTransition(0),i.animating){var b=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});i.wrapperEl.dispatchEvent(b)}n.allowMomentumBounce=!1,!a.grabCursor||!0!==i.allowSlideNext&&!0!==i.allowSlidePrev||i.setGrabCursor(!0),i.emit("sliderFirstMove",u)}if((new Date).getTime(),!1!==a._loopSwapReset&&n.isMoved&&n.allowThresholdMove&&p!==i.touchesDirection&&g&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:l,startY:d,currentX:l,currentY:d,startTranslate:n.currentTranslate}),n.loopSwapReset=!0,void(n.startTranslate=n.currentTranslate);i.emit("sliderMove",u),n.isMoved=!0,n.currentTranslate=f+n.startTranslate;var w=!0,k=a.resistanceRatio;if(a.touchReleaseOnEdges&&(k=0),f>0?(g&&y&&n.allowThresholdMove&&n.currentTranslate>(a.centeredSlides?i.minTranslate()-i.slidesSizesGrid[i.activeIndex+1]-("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.activeIndex+1]+i.params.spaceBetween:0)-i.params.spaceBetween:i.minTranslate())&&i.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),n.currentTranslate>i.minTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.minTranslate()-1+(-i.minTranslate()+n.startTranslate+f)**k))):f<0&&(g&&y&&n.allowThresholdMove&&n.currentTranslate<(a.centeredSlides?i.maxTranslate()+i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween+("auto"!==a.slidesPerView&&i.slides.length-a.slidesPerView>=2?i.slidesSizesGrid[i.slidesSizesGrid.length-1]+i.params.spaceBetween:0):i.maxTranslate())&&i.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:i.slides.length-("auto"===a.slidesPerView?i.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),n.currentTranslate<i.maxTranslate()&&(w=!1,a.resistance&&(n.currentTranslate=i.maxTranslate()+1-(i.maxTranslate()-n.startTranslate-f)**k))),w&&(u.preventedByNestedSwiper=!0),!i.allowSlideNext&&"next"===i.swipeDirection&&n.currentTranslate<n.startTranslate&&(n.currentTranslate=n.startTranslate),!i.allowSlidePrev&&"prev"===i.swipeDirection&&n.currentTranslate>n.startTranslate&&(n.currentTranslate=n.startTranslate),i.allowSlidePrev||i.allowSlideNext||(n.currentTranslate=n.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||n.allowThresholdMove))return void(n.currentTranslate=n.startTranslate);if(!n.allowThresholdMove)return n.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,n.currentTranslate=n.startTranslate,void(r.diff=i.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&i.freeMode||a.watchSlidesProgress)&&(i.updateActiveIndex(),i.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&i.freeMode&&i.freeMode.onTouchMove(),i.updateProgress(n.currentTranslate),i.setTranslate(n.currentTranslate))}}}else n.startMoving&&n.isScrolling&&i.emit("touchMoveOpposite",u)}}function dF(e){var t,i=this,n=i.touchEventsData,a=e;if(a.originalEvent&&(a=a.originalEvent),"touchend"===a.type||"touchcancel"===a.type){if(t=[...a.changedTouches].find(e=>e.identifier===n.touchId),!t||t.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;t=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)&&!(["pointercancel","contextmenu"].includes(a.type)&&(i.browser.isSafari||i.browser.isWebView)))return;n.pointerId=null,n.touchId=null;var r=i.params,o=i.touches,s=i.rtlTranslate,u=i.slidesGrid;if(i.enabled&&(r.simulateTouch||"mouse"!==a.pointerType)){if(n.allowTouchCallbacks&&i.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&i.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===i.allowSlideNext||!0===i.allowSlidePrev)&&i.setGrabCursor(!1);var l,d=xR(),h=d-n.touchStartTime;if(i.allowClick){var c=a.path||a.composedPath&&a.composedPath();i.updateClickedSlide(c&&c[0]||a.target,c),i.emit("tap click",a),h<300&&d-n.lastClickTime<300&&i.emit("doubleTap doubleClick",a)}if(n.lastClickTime=xR(),DR(()=>{i.destroyed||(i.allowClick=!0)}),!n.isTouched||!n.isMoved||!i.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,l=r.followFinger?s?i.translate:-i.translate:-n.currentTranslate,!r.cssMode)if(r.freeMode&&r.freeMode.enabled)i.freeMode.onTouchEnd({currentPos:l});else{for(var m=l>=-i.maxTranslate()&&!i.params.loop,f=0,v=i.slidesSizesGrid[0],p=0;p<u.length;p+=p<r.slidesPerGroupSkip?1:r.slidesPerGroup){var g=p<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==u[p+g]?(m||l>=u[p]&&l<u[p+g])&&(f=p,v=u[p+g]-u[p]):(m||l>=u[p])&&(f=p,v=u[u.length-1]-u[u.length-2])}var y=null,b=null;r.rewind&&(i.isBeginning?b=r.virtual&&r.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1:i.isEnd&&(y=0));var w=(l-u[f])/v,k=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(h>r.longSwipesMs){if(!r.longSwipes)return void i.slideTo(i.activeIndex);"next"===i.swipeDirection&&(w>=r.longSwipesRatio?i.slideTo(r.rewind&&i.isEnd?y:f+k):i.slideTo(f)),"prev"===i.swipeDirection&&(w>1-r.longSwipesRatio?i.slideTo(f+k):null!==b&&w<0&&Math.abs(w)>r.longSwipesRatio?i.slideTo(b):i.slideTo(f))}else{if(!r.shortSwipes)return void i.slideTo(i.activeIndex);i.navigation&&(a.target===i.navigation.nextEl||a.target===i.navigation.prevEl)?a.target===i.navigation.nextEl?i.slideTo(f+k):i.slideTo(f):("next"===i.swipeDirection&&i.slideTo(null!==y?y:f+k),"prev"===i.swipeDirection&&i.slideTo(null!==b?b:f))}}}}function hF(){var e=this,t=e.params,i=e.el;if(!i||0!==i.offsetWidth){t.breakpoints&&e.setBreakpoint();var n=e.allowSlideNext,a=e.allowSlidePrev,r=e.snapGrid,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();var s=o&&t.loop;if(!("auto"===t.slidesPerView||t.slidesPerView>1)||!e.isEnd||e.isBeginning||e.params.centeredSlides||s)e.params.loop&&!o?e.slideToLoop(e.realIndex,0,!1,!0):e.slideTo(e.activeIndex,0,!1,!0);else{var u=o?e.virtual.slides:e.slides;e.slideTo(u.length-1,0,!1,!0)}e.autoplay&&e.autoplay.running&&e.autoplay.paused&&(clearTimeout(e.autoplay.resizeTimeout),e.autoplay.resizeTimeout=setTimeout(()=>{e.autoplay&&e.autoplay.running&&e.autoplay.paused&&e.autoplay.resume()},500)),e.allowSlidePrev=a,e.allowSlideNext=n,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}}function cF(e){var t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function mF(){var e=this,t=e.wrapperEl,i=e.rtlTranslate;if(e.enabled){e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();var n=e.maxTranslate()-e.minTranslate();(0===n?0:(e.translate-e.minTranslate())/n)!==e.progress&&e.updateProgress(i?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}}function fF(e){var t=this;QR(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function vF(){var e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}var pF=(e,t)=>{var i=SR(),n=e.params,a=e.el,r=e.wrapperEl,o=e.device,s=!!n.nested,u="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(i[u]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[u]("touchstart",e.onTouchStart,{passive:!1}),a[u]("pointerdown",e.onTouchStart,{passive:!1}),i[u]("touchmove",e.onTouchMove,{passive:!1,capture:s}),i[u]("pointermove",e.onTouchMove,{passive:!1,capture:s}),i[u]("touchend",e.onTouchEnd,{passive:!0}),i[u]("pointerup",e.onTouchEnd,{passive:!0}),i[u]("pointercancel",e.onTouchEnd,{passive:!0}),i[u]("touchcancel",e.onTouchEnd,{passive:!0}),i[u]("pointerout",e.onTouchEnd,{passive:!0}),i[u]("pointerleave",e.onTouchEnd,{passive:!0}),i[u]("contextmenu",e.onTouchEnd,{passive:!0}),(n.preventClicks||n.preventClicksPropagation)&&a[u]("click",e.onClick,!0),n.cssMode&&r[u]("scroll",e.onScroll),n.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",hF,!0):e[l]("observerUpdate",hF,!0),a[u]("load",e.onLoad,{capture:!0}))};var gF=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var yF={setBreakpoint:function(){var e=this,t=e.realIndex,i=e.initialized,n=e.params,a=e.el,r=n.breakpoints;if(r&&(!r||0!==Object.keys(r).length)){var o=SR(),s="window"!==n.breakpointsBase&&n.breakpointsBase?"container":n.breakpointsBase,u=["window","container"].includes(n.breakpointsBase)||!n.breakpointsBase?e.el:o.querySelector(n.breakpointsBase),l=e.getBreakpoint(r,s,u);if(l&&e.currentBreakpoint!==l){var d=(l in r?r[l]:void 0)||e.originalParams,h=gF(e,n),c=gF(e,d),m=e.params.grabCursor,f=d.grabCursor,v=n.enabled;h&&!c?(a.classList.remove(`${n.containerModifierClass}grid`,`${n.containerModifierClass}grid-column`),e.emitContainerClasses()):!h&&c&&(a.classList.add(`${n.containerModifierClass}grid`),(d.grid.fill&&"column"===d.grid.fill||!d.grid.fill&&"column"===n.grid.fill)&&a.classList.add(`${n.containerModifierClass}grid-column`),e.emitContainerClasses()),m&&!f?e.unsetGrabCursor():!m&&f&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach(t=>{if(void 0!==d[t]){var i=n[t]&&n[t].enabled,a=d[t]&&d[t].enabled;i&&!a&&e[t].disable(),!i&&a&&e[t].enable()}});var p=d.direction&&d.direction!==n.direction,g=n.loop&&(d.slidesPerView!==n.slidesPerView||p),y=n.loop;p&&i&&e.changeDirection(),_R(e.params,d);var b=e.params.enabled,w=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),v&&!b?e.disable():!v&&b&&e.enable(),e.currentBreakpoint=l,e.emit("_beforeBreakpoint",d),i&&(g?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!y&&w?(e.loopCreate(t),e.updateSlides()):y&&!w&&e.loopDestroy()),e.emit("breakpoint",d)}}},getBreakpoint:function(e,t="window",i){if(e&&("container"!==t||i)){var n=!1,a=AR(),r="window"===t?a.innerHeight:i.clientHeight,o=Object.keys(e).map(e=>{if("string"==typeof e&&0===e.indexOf("@")){var t=parseFloat(e.substr(1));return{value:r*t,point:e}}return{value:e,point:e}});o.sort((e,t)=>parseInt(e.value,10)-parseInt(t.value,10));for(var s=0;s<o.length;s+=1){var u=o[s],l=u.point,d=u.value;"window"===t?a.matchMedia(`(min-width: ${d}px)`).matches&&(n=l):d<=i.clientWidth&&(n=l)}return n||"max"}}};var bF={addClasses:function(){var e,t,i,n=this,a=n.classNames,r=n.params,o=n.rtl,s=n.el,u=n.device,l=(e=["initialized",r.direction,{"free-mode":n.params.freeMode&&r.freeMode.enabled},{autoheight:r.autoHeight},{rtl:o},{grid:r.grid&&r.grid.rows>1},{"grid-column":r.grid&&r.grid.rows>1&&"column"===r.grid.fill},{android:u.android},{ios:u.ios},{"css-mode":r.cssMode},{centered:r.cssMode&&r.centeredSlides},{"watch-progress":r.watchSlidesProgress}],t=r.containerModifierClass,i=[],e.forEach(e=>{"object"==typeof e?Object.keys(e).forEach(n=>{e[n]&&i.push(t+n)}):"string"==typeof e&&i.push(t+e)}),i);a.push(...l),s.classList.add(...a),n.emitContainerClasses()},removeClasses:function(){var e=this,t=e.el,i=e.classNames;t&&"string"!=typeof t&&(t.classList.remove(...i),e.emitContainerClasses())}};var wF={init:!0,direction:"horizontal",oneWayMovement:!1,swiperElementNodeName:"SWIPER-CONTAINER",touchEventsTarget:"wrapper",initialSlide:0,speed:300,cssMode:!1,updateOnWindowResize:!0,resizeObserver:!0,nested:!1,createElements:!1,eventsPrefix:"swiper",enabled:!0,focusableElements:"input, select, option, textarea, button, video, label",width:null,height:null,preventInteractionOnTransition:!1,userAgent:null,url:null,edgeSwipeDetection:!1,edgeSwipeThreshold:20,autoHeight:!1,setWrapperSize:!1,virtualTranslate:!1,effect:"slide",breakpoints:void 0,breakpointsBase:"window",spaceBetween:0,slidesPerView:1,slidesPerGroup:1,slidesPerGroupSkip:0,slidesPerGroupAuto:!1,centeredSlides:!1,centeredSlidesBounds:!1,slidesOffsetBefore:0,slidesOffsetAfter:0,normalizeSlideIndex:!0,centerInsufficientSlides:!1,snapToSlideEdge:!1,watchOverflow:!0,roundLengths:!1,touchRatio:1,touchAngle:45,simulateTouch:!0,shortSwipes:!0,longSwipes:!0,longSwipesRatio:.5,longSwipesMs:300,followFinger:!0,allowTouchMove:!0,threshold:5,touchMoveStopPropagation:!1,touchStartPreventDefault:!0,touchStartForcePreventDefault:!1,touchReleaseOnEdges:!1,uniqueNavElements:!0,resistance:!0,resistanceRatio:.85,watchSlidesProgress:!1,grabCursor:!1,preventClicks:!0,preventClicksPropagation:!0,slideToClickedSlide:!1,loop:!1,loopAddBlankSlides:!0,loopAdditionalSlides:0,loopPreventsSliding:!0,rewind:!1,allowSlidePrev:!0,allowSlideNext:!0,swipeHandler:null,noSwiping:!0,noSwipingClass:"swiper-no-swiping",noSwipingSelector:null,passiveListeners:!0,maxBackfaceHiddenSlides:10,containerModifierClass:"swiper-",slideClass:"swiper-slide",slideBlankClass:"swiper-slide-blank",slideActiveClass:"swiper-slide-active",slideVisibleClass:"swiper-slide-visible",slideFullyVisibleClass:"swiper-slide-fully-visible",slideNextClass:"swiper-slide-next",slidePrevClass:"swiper-slide-prev",wrapperClass:"swiper-wrapper",lazyPreloaderClass:"swiper-lazy-preloader",lazyPreloadPrevNext:0,runCallbacksOnInit:!0,_emitClasses:!1};function kF(e,t){return function(i={}){var n=Object.keys(i)[0],a=i[n];"object"==typeof a&&null!==a?(!0===e[n]&&(e[n]={enabled:!0}),"navigation"===n&&e[n]&&e[n].enabled&&!e[n].prevEl&&!e[n].nextEl&&(e[n].auto=!0),["pagination","scrollbar"].indexOf(n)>=0&&e[n]&&e[n].enabled&&!e[n].el&&(e[n].auto=!0),n in e&&"enabled"in a?("object"!=typeof e[n]||"enabled"in e[n]||(e[n].enabled=!0),e[n]||(e[n]={enabled:!1}),_R(t,i)):_R(t,i)):_R(t,i)}}var SF={eventsEmitter:YR,update:tF,translate:iF,transition:{setTransition:function(e,t){var i=this;i.params.cssMode||(i.wrapperEl.style.transitionDuration=`${e}ms`,i.wrapperEl.style.transitionDelay=0===e?"0ms":""),i.emit("setTransition",e,t)},transitionStart:function(e=!0,t){var i=this,n=i.params;n.cssMode||(n.autoHeight&&i.updateAutoHeight(),nF({swiper:i,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e=!0,t){var i=this,n=i.params;i.animating=!1,n.cssMode||(i.setTransition(0),nF({swiper:i,runCallbacks:e,direction:t,step:"End"}))}},slide:aF,loop:rF,grabCursor:oF,events:{attachEvents:function(){var e=this,t=e.params;e.onTouchStart=uF.bind(e),e.onTouchMove=lF.bind(e),e.onTouchEnd=dF.bind(e),e.onDocumentTouchStart=vF.bind(e),t.cssMode&&(e.onScroll=mF.bind(e)),e.onClick=cF.bind(e),e.onLoad=fF.bind(e),pF(e,"on")},detachEvents:function(){pF(this,"off")}},breakpoints:yF,checkOverflow:{checkOverflow:function(){var e=this,t=e.isLocked,i=e.params,n=i.slidesOffsetBefore;if(n){var a=e.slides.length-1,r=e.slidesGrid[a]+e.slidesSizesGrid[a]+2*n;e.isLocked=e.size>r}else e.isLocked=1===e.snapGrid.length;!0===i.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===i.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:bF},EF={},MF=function(){function e(...t){var i,n;Q(this,e),1===t.length&&t[0].constructor&&"Object"===Object.prototype.toString.call(t[0]).slice(8,-1)?n=t[0]:(i=t[0],n=t[1]),n||(n={}),n=_R({},n),i&&!n.el&&(n.el=i);var a=SR();if(n.el&&"string"==typeof n.el&&a.querySelectorAll(n.el).length>1){var r=[];return a.querySelectorAll(n.el).forEach(t=>{var i=_R({},n,{el:t});r.push(new e(i))}),r}var o=this;o.__swiper__=!0,o.support=VR(),o.device=KR({userAgent:n.userAgent}),o.browser=XR(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],n.modules&&Array.isArray(n.modules)&&n.modules.forEach(e=>{"function"==typeof e&&o.modules.indexOf(e)<0&&o.modules.push(e)});var s={};o.modules.forEach(e=>{e({params:n,swiper:o,extendParams:kF(n,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})});var u=_R({},wF,s);return o.params=_R({},u,EF,n),o.originalParams=_R({},o.params),o.passedParams=_R({},n),o.params&&o.params.on&&Object.keys(o.params.on).forEach(e=>{o.on(e,o.params.on[e])}),o.params&&o.params.onAny&&o.onAny(o.params.onAny),Object.assign(o,{enabled:o.params.enabled,el:i,classNames:[],slides:[],slidesGrid:[],snapGrid:[],slidesSizesGrid:[],isHorizontal:()=>"horizontal"===o.params.direction,isVertical:()=>"vertical"===o.params.direction,activeIndex:0,realIndex:0,isBeginning:!0,isEnd:!1,translate:0,previousTranslate:0,progress:0,velocity:0,animating:!1,cssOverflowAdjustment(){return Math.trunc(this.translate/2**23)*2**23},allowSlideNext:o.params.allowSlideNext,allowSlidePrev:o.params.allowSlidePrev,touchEventsData:{isTouched:void 0,isMoved:void 0,allowTouchCallbacks:void 0,touchStartTime:void 0,isScrolling:void 0,currentTranslate:void 0,startTranslate:void 0,allowThresholdMove:void 0,focusableElements:o.params.focusableElements,lastClickTime:0,clickTimeout:void 0,velocities:[],allowMomentumBounce:void 0,startMoving:void 0,pointerId:null,touchId:null},allowClick:!0,allowTouchMove:o.params.allowTouchMove,touches:{startX:0,startY:0,currentX:0,currentY:0,diff:0},imagesToLoad:[],imagesLoaded:0}),o.emit("_swiper"),o.params.init&&o.init(),o}return ne(e,[{key:"getDirectionLabel",value:function(e){return this.isHorizontal()?e:{width:"height","margin-top":"margin-left","margin-bottom ":"margin-right","margin-left":"margin-top","margin-right":"margin-bottom","padding-left":"padding-top","padding-right":"padding-bottom",marginRight:"marginBottom"}[e]}},{key:"getSlideIndex",value:function(e){var t=BR(OR(this.slidesEl,`.${this.params.slideClass}, swiper-slide`)[0]);return BR(e)-t}},{key:"getSlideIndexByData",value:function(e){return this.getSlideIndex(this.slides.find(t=>1*t.getAttribute("data-swiper-slide-index")===e))}},{key:"getSlideIndexWhenGrid",value:function(e){return this.grid&&this.params.grid&&this.params.grid.rows>1&&("column"===this.params.grid.fill?e=Math.floor(e/this.params.grid.rows):"row"===this.params.grid.fill&&(e%=Math.ceil(this.slides.length/this.params.grid.rows))),e}},{key:"recalcSlides",value:function(){var e=this,t=e.slidesEl,i=e.params;e.slides=OR(t,`.${i.slideClass}, swiper-slide`)}},{key:"enable",value:function(){var e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}},{key:"disable",value:function(){var e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}},{key:"setProgress",value:function(e,t){var i=this;e=Math.min(Math.max(e,0),1);var n=i.minTranslate(),a=(i.maxTranslate()-n)*e+n;i.translateTo(a,void 0===t?0:t),i.updateActiveIndex(),i.updateSlidesClasses()}},{key:"emitContainerClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=e.el.className.split(" ").filter(t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass));e.emit("_containerClasses",t.join(" "))}}},{key:"getSlideClasses",value:function(e){var t=this;return t.destroyed?"":e.className.split(" ").filter(e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass)).join(" ")}},{key:"emitSlidesClasses",value:function(){var e=this;if(e.params._emitClasses&&e.el){var t=[];e.slides.forEach(i=>{var n=e.getSlideClasses(i);t.push({slideEl:i,classNames:n}),e.emit("_slideClass",i,n)}),e.emit("_slideClasses",t)}}},{key:"slidesPerViewDynamic",value:function(e="current",t=!1){var i=this,n=i.params,a=i.slides,r=i.slidesGrid,o=i.slidesSizesGrid,s=i.size,u=i.activeIndex,l=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){for(var d,h=a[u]?Math.ceil(a[u].swiperSlideSize):0,c=u+1;c<a.length;c+=1)a[c]&&!d&&(l+=1,(h+=Math.ceil(a[c].swiperSlideSize))>s&&(d=!0));for(var m=u-1;m>=0;m-=1)a[m]&&!d&&(l+=1,(h+=a[m].swiperSlideSize)>s&&(d=!0))}else if("current"===e)for(var f=u+1;f<a.length;f+=1){(t?r[f]+o[f]-r[u]<s:r[f]-r[u]<s)&&(l+=1)}else for(var v=u-1;v>=0;v-=1){r[u]-r[v]<s&&(l+=1)}return l}},{key:"update",value:function(){var e=this;if(e&&!e.destroyed){var t,i=e.snapGrid,n=e.params;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach(t=>{t.complete&&QR(e,t)}),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)r(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){var a=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;t=e.slideTo(a.length-1,0,!1,!0)}else t=e.slideTo(e.activeIndex,0,!1,!0);t||r()}n.watchOverflow&&i!==e.snapGrid&&e.checkOverflow(),e.emit("update")}function r(){var t=e.rtlTranslate?-1*e.translate:e.translate,i=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(i),e.updateActiveIndex(),e.updateSlidesClasses()}}},{key:"changeDirection",value:function(e,t=!0){var i=this,n=i.params.direction;return e||(e="horizontal"===n?"vertical":"horizontal"),e===n||"horizontal"!==e&&"vertical"!==e||(i.el.classList.remove(`${i.params.containerModifierClass}${n}`),i.el.classList.add(`${i.params.containerModifierClass}${e}`),i.emitContainerClasses(),i.params.direction=e,i.slides.forEach(t=>{"vertical"===e?t.style.width="":t.style.height=""}),i.emit("changeDirection"),t&&i.update()),i}},{key:"changeLanguageDirection",value:function(e){var t=this;t.rtl&&"rtl"===e||!t.rtl&&"ltr"===e||(t.rtl="rtl"===e,t.rtlTranslate="horizontal"===t.params.direction&&t.rtl,t.rtl?(t.el.classList.add(`${t.params.containerModifierClass}rtl`),t.el.dir="rtl"):(t.el.classList.remove(`${t.params.containerModifierClass}rtl`),t.el.dir="ltr"),t.update())}},{key:"mount",value:function(e){var t=this;if(t.mounted)return!0;var i=e||t.params.el;if("string"==typeof i&&(i=document.querySelector(i)),!i)return!1;i.swiper=t,i.parentNode&&i.parentNode.host&&i.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);var n=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`,a=i&&i.shadowRoot&&i.shadowRoot.querySelector?i.shadowRoot.querySelector(n()):OR(i,n())[0];return!a&&t.params.createElements&&(a=NR("div",t.params.wrapperClass),i.append(a),OR(i,`.${t.params.slideClass}`).forEach(e=>{a.append(e)})),Object.assign(t,{el:i,wrapperEl:a,slidesEl:t.isElement&&!i.parentNode.host.slideSlots?i.parentNode.host:a,hostEl:t.isElement?i.parentNode.host:i,mounted:!0,rtl:"rtl"===i.dir.toLowerCase()||"rtl"===jR(i,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===i.dir.toLowerCase()||"rtl"===jR(i,"direction")),wrongRTL:"-webkit-box"===jR(a,"display")}),!0}},{key:"init",value:function(e){var t=this;if(t.initialized)return t;if(!1===t.mount(e))return t;t.emit("beforeInit"),t.params.breakpoints&&t.setBreakpoint(),t.addClasses(),t.updateSize(),t.updateSlides(),t.params.watchOverflow&&t.checkOverflow(),t.params.grabCursor&&t.enabled&&t.setGrabCursor(),t.params.loop&&t.virtual&&t.params.virtual.enabled?t.slideTo(t.params.initialSlide+t.virtual.slidesBefore,0,t.params.runCallbacksOnInit,!1,!0):t.slideTo(t.params.initialSlide,0,t.params.runCallbacksOnInit,!1,!0),t.params.loop&&t.loopCreate(void 0,!0),t.attachEvents();var i=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&i.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),i.forEach(e=>{e.complete?QR(t,e):e.addEventListener("load",e=>{QR(t,e.target)})}),eF(t),t.initialized=!0,eF(t),t.emit("init"),t.emit("afterInit"),t}},{key:"destroy",value:function(e=!0,t=!0){var i=this,n=i.params,a=i.el,r=i.wrapperEl,o=i.slides;return void 0===i.params||i.destroyed||(i.emit("beforeDestroy"),i.initialized=!1,i.detachEvents(),n.loop&&i.loopDestroy(),t&&(i.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach(e=>{e.classList.remove(n.slideVisibleClass,n.slideFullyVisibleClass,n.slideActiveClass,n.slideNextClass,n.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")})),i.emit("destroy"),Object.keys(i.eventsListeners).forEach(e=>{i.off(e)}),!1!==e&&(i.el&&"string"!=typeof i.el&&(i.el.swiper=null),function(e){var t=e;Object.keys(t).forEach(e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}})}(i)),i.destroyed=!0),null}}],[{key:"extendDefaults",value:function(e){_R(EF,e)}},{key:"extendedDefaults",get:function(){return EF}},{key:"defaults",get:function(){return wF}},{key:"installModule",value:function(t){e.prototype.__modules__||(e.prototype.__modules__=[]);var i=e.prototype.__modules__;"function"==typeof t&&i.indexOf(t)<0&&i.push(t)}},{key:"use",value:function(t){return Array.isArray(t)?(t.forEach(t=>e.installModule(t)),e):(e.installModule(t),e)}}])}();function TF(e=""){return`.${e.trim().replace(/([\.:!+\/()[\]#>~*^$|=,'"@{}\\])/g,"\\$1").replace(/ /g,".")}`}function PF({swiper:e,extendParams:t,on:i,emit:n}){var a,r="swiper-pagination";t({pagination:{el:null,bulletElement:"span",clickable:!1,hideOnClick:!1,renderBullet:null,renderProgressbar:null,renderFraction:null,renderCustom:null,progressbarOpposite:!1,type:"bullets",dynamicBullets:!1,dynamicMainBullets:1,formatFractionCurrent:e=>e,formatFractionTotal:e=>e,bulletClass:`${r}-bullet`,bulletActiveClass:`${r}-bullet-active`,modifierClass:`${r}-`,currentClass:`${r}-current`,totalClass:`${r}-total`,hiddenClass:`${r}-hidden`,progressbarFillClass:`${r}-progressbar-fill`,progressbarOppositeClass:`${r}-progressbar-opposite`,clickableClass:`${r}-clickable`,lockClass:`${r}-lock`,horizontalClass:`${r}-horizontal`,verticalClass:`${r}-vertical`,paginationDisabledClass:`${r}-disabled`}}),e.pagination={el:null,bullets:[]};var o=0;function s(){return!e.params.pagination.el||!e.pagination.el||Array.isArray(e.pagination.el)&&0===e.pagination.el.length}function u(t,i){var n=e.params.pagination.bulletActiveClass;t&&(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&(t.classList.add(`${n}-${i}`),(t=t[("prev"===i?"previous":"next")+"ElementSibling"])&&t.classList.add(`${n}-${i}-${i}`))}function l(t){var i=t.target.closest(TF(e.params.pagination.bulletClass));if(i){t.preventDefault();var n,a,r,o=BR(i)*e.params.slidesPerGroup;if(e.params.loop){if(e.realIndex===o)return;var s=(n=e.realIndex,a=o,r=e.slides.length,(a%=r)===1+(n%=r)?"next":a===n-1?"previous":void 0);"next"===s?e.slideNext():"previous"===s?e.slidePrev():e.slideToLoop(o)}else e.slideTo(o)}}function d(){var t=e.rtl,i=e.params.pagination;if(!s()){var r,l,d=e.pagination.el;d=HR(d);var h=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.slides.length,c=e.params.loop?Math.ceil(h/e.params.slidesPerGroup):e.snapGrid.length;if(e.params.loop?(l=e.previousRealIndex||0,r=e.params.slidesPerGroup>1?Math.floor(e.realIndex/e.params.slidesPerGroup):e.realIndex):void 0!==e.snapIndex?(r=e.snapIndex,l=e.previousSnapIndex):(l=e.previousIndex||0,r=e.activeIndex||0),"bullets"===i.type&&e.pagination.bullets&&e.pagination.bullets.length>0){var m,f,v,p=e.pagination.bullets;if(i.dynamicBullets&&(a=UR(p[0],e.isHorizontal()?"width":"height"),d.forEach(t=>{t.style[e.isHorizontal()?"width":"height"]=a*(i.dynamicMainBullets+4)+"px"}),i.dynamicMainBullets>1&&void 0!==l&&((o+=r-(l||0))>i.dynamicMainBullets-1?o=i.dynamicMainBullets-1:o<0&&(o=0)),m=Math.max(r-o,0),v=((f=m+(Math.min(p.length,i.dynamicMainBullets)-1))+m)/2),p.forEach(e=>{var t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map(e=>`${i.bulletActiveClass}${e}`)].map(e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e).flat();e.classList.remove(...t)}),d.length>1)p.forEach(t=>{var n=BR(t);n===r?t.classList.add(...i.bulletActiveClass.split(" ")):e.isElement&&t.setAttribute("part","bullet"),i.dynamicBullets&&(n>=m&&n<=f&&t.classList.add(...`${i.bulletActiveClass}-main`.split(" ")),n===m&&u(t,"prev"),n===f&&u(t,"next"))});else{var g=p[r];if(g&&g.classList.add(...i.bulletActiveClass.split(" ")),e.isElement&&p.forEach((e,t)=>{e.setAttribute("part",t===r?"bullet-active":"bullet")}),i.dynamicBullets){for(var y=p[m],b=p[f],w=m;w<=f;w+=1)p[w]&&p[w].classList.add(...`${i.bulletActiveClass}-main`.split(" "));u(y,"prev"),u(b,"next")}}if(i.dynamicBullets){var k=Math.min(p.length,i.dynamicMainBullets+4),S=(a*k-a)/2-v*a,E=t?"right":"left";p.forEach(t=>{t.style[e.isHorizontal()?E:"top"]=`${S}px`})}}d.forEach((t,a)=>{if("fraction"===i.type&&(t.querySelectorAll(TF(i.currentClass)).forEach(e=>{e.textContent=i.formatFractionCurrent(r+1)}),t.querySelectorAll(TF(i.totalClass)).forEach(e=>{e.textContent=i.formatFractionTotal(c)})),"progressbar"===i.type){var o;o=i.progressbarOpposite?e.isHorizontal()?"vertical":"horizontal":e.isHorizontal()?"horizontal":"vertical";var s=(r+1)/c,u=1,l=1;"horizontal"===o?u=s:l=s,t.querySelectorAll(TF(i.progressbarFillClass)).forEach(t=>{t.style.transform=`translate3d(0,0,0) scaleX(${u}) scaleY(${l})`,t.style.transitionDuration=`${e.params.speed}ms`})}"custom"===i.type&&i.renderCustom?(GR(t,i.renderCustom(e,r+1,c)),0===a&&n("paginationRender",t)):(0===a&&n("paginationRender",t),n("paginationUpdate",t)),e.params.watchOverflow&&e.enabled&&t.classList[e.isLocked?"add":"remove"](i.lockClass)})}}function h(){var t=e.params.pagination;if(!s()){var i=e.virtual&&e.params.virtual.enabled?e.virtual.slides.length:e.grid&&e.params.grid.rows>1?e.slides.length/Math.ceil(e.params.grid.rows):e.slides.length,a=e.pagination.el;a=HR(a);var r="";if("bullets"===t.type){var o=e.params.loop?Math.ceil(i/e.params.slidesPerGroup):e.snapGrid.length;e.params.freeMode&&e.params.freeMode.enabled&&o>i&&(o=i);for(var u=0;u<o;u+=1)t.renderBullet?r+=t.renderBullet.call(e,u,t.bulletClass):r+=`<${t.bulletElement} ${e.isElement?'part="bullet"':""} class="${t.bulletClass}"></${t.bulletElement}>`}"fraction"===t.type&&(r=t.renderFraction?t.renderFraction.call(e,t.currentClass,t.totalClass):`<span class="${t.currentClass}"></span> / <span class="${t.totalClass}"></span>`),"progressbar"===t.type&&(r=t.renderProgressbar?t.renderProgressbar.call(e,t.progressbarFillClass):`<span class="${t.progressbarFillClass}"></span>`),e.pagination.bullets=[],a.forEach(i=>{"custom"!==t.type&&GR(i,r||""),"bullets"===t.type&&e.pagination.bullets.push(...i.querySelectorAll(TF(t.bulletClass)))}),"custom"!==t.type&&n("paginationRender",a[0])}}function c(){e.params.pagination=function(e,t,i,n){return e.params.createElements&&Object.keys(n).forEach(a=>{if(!i[a]&&!0===i.auto){var r=OR(e.el,`.${n[a]}`)[0];r||((r=NR("div",n[a])).className=n[a],e.el.append(r)),i[a]=r,t[a]=r}}),i}(e,e.originalParams.pagination,e.params.pagination,{el:"swiper-pagination"});var t,i=e.params.pagination;i.el&&("string"==typeof i.el&&e.isElement&&(t=e.el.querySelector(i.el)),t||"string"!=typeof i.el||(t=[...document.querySelectorAll(i.el)]),t||(t=i.el),t&&0!==t.length&&(e.params.uniqueNavElements&&"string"==typeof i.el&&Array.isArray(t)&&t.length>1&&(t=[...e.el.querySelectorAll(i.el)]).length>1&&(t=t.find(t=>zR(t,".swiper")[0]===e.el)),Array.isArray(t)&&1===t.length&&(t=t[0]),Object.assign(e.pagination,{el:t}),(t=HR(t)).forEach(t=>{"bullets"===i.type&&i.clickable&&t.classList.add(...(i.clickableClass||"").split(" ")),t.classList.add(i.modifierClass+i.type),t.classList.add(e.isHorizontal()?i.horizontalClass:i.verticalClass),"bullets"===i.type&&i.dynamicBullets&&(t.classList.add(`${i.modifierClass}${i.type}-dynamic`),o=0,i.dynamicMainBullets<1&&(i.dynamicMainBullets=1)),"progressbar"===i.type&&i.progressbarOpposite&&t.classList.add(i.progressbarOppositeClass),i.clickable&&t.addEventListener("click",l),e.enabled||t.classList.add(i.lockClass)})))}function m(){var t=e.params.pagination;if(!s()){var i=e.pagination.el;i&&(i=HR(i)).forEach(i=>{i.classList.remove(t.hiddenClass),i.classList.remove(t.modifierClass+t.type),i.classList.remove(e.isHorizontal()?t.horizontalClass:t.verticalClass),t.clickable&&(i.classList.remove(...(t.clickableClass||"").split(" ")),i.removeEventListener("click",l))}),e.pagination.bullets&&e.pagination.bullets.forEach(e=>e.classList.remove(...t.bulletActiveClass.split(" ")))}}i("changeDirection",()=>{if(e.pagination&&e.pagination.el){var t=e.params.pagination,i=e.pagination.el;(i=HR(i)).forEach(i=>{i.classList.remove(t.horizontalClass,t.verticalClass),i.classList.add(e.isHorizontal()?t.horizontalClass:t.verticalClass)})}}),i("init",()=>{!1===e.params.pagination.enabled?f():(c(),h(),d())}),i("activeIndexChange",()=>{void 0===e.snapIndex&&d()}),i("snapIndexChange",()=>{d()}),i("snapGridLengthChange",()=>{h(),d()}),i("destroy",()=>{m()}),i("enable disable",()=>{var t=e.pagination.el;t&&(t=HR(t)).forEach(t=>t.classList[e.enabled?"remove":"add"](e.params.pagination.lockClass))}),i("lock unlock",()=>{d()}),i("click",(t,i)=>{var a=i.target,r=HR(e.pagination.el);if(e.params.pagination.el&&e.params.pagination.hideOnClick&&r&&r.length>0&&!a.classList.contains(e.params.pagination.bulletClass)){if(e.navigation&&(e.navigation.nextEl&&a===e.navigation.nextEl||e.navigation.prevEl&&a===e.navigation.prevEl))return;var o=r[0].classList.contains(e.params.pagination.hiddenClass);n(!0===o?"paginationShow":"paginationHide"),r.forEach(t=>t.classList.toggle(e.params.pagination.hiddenClass))}});var f=()=>{e.el.classList.add(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=HR(t)).forEach(t=>t.classList.add(e.params.pagination.paginationDisabledClass)),m()};Object.assign(e.pagination,{enable:()=>{e.el.classList.remove(e.params.pagination.paginationDisabledClass);var t=e.pagination.el;t&&(t=HR(t)).forEach(t=>t.classList.remove(e.params.pagination.paginationDisabledClass)),c(),h(),d()},disable:f,render:h,update:d,init:c,destroy:m})}function AF({swiper:e,extendParams:t,on:i,emit:n,params:a}){var r,o;e.autoplay={running:!1,paused:!1,timeLeft:0},t({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});var s,u,l,d,h,c,m,f=a&&a.autoplay?a.autoplay.delay:3e3,v=a&&a.autoplay?a.autoplay.delay:3e3,p=(new Date).getTime();function g(t){e&&!e.destroyed&&e.wrapperEl&&t.target===e.wrapperEl&&(e.wrapperEl.removeEventListener("transitionend",g),m||t.detail&&t.detail.bySwiperTouchMove||M())}var y=()=>{if(!e.destroyed&&e.autoplay.running){e.autoplay.paused?u=!0:u&&(v=s,u=!1);var t=e.autoplay.paused?s:p+v-(new Date).getTime();e.autoplay.timeLeft=t,n("autoplayTimeLeft",t,t/f),o=requestAnimationFrame(()=>{y()})}},b=()=>{var t=e.params.autoplay.delay,i=(()=>{var t;if(t=e.virtual&&e.params.virtual.enabled?e.slides.find(e=>e.classList.contains("swiper-slide-active")):e.slides[e.activeIndex])return parseInt(t.getAttribute("data-swiper-autoplay"),10)})();return!Number.isNaN(i)&&i>0&&(t=i),t},w=t=>{if(!e.destroyed&&e.autoplay.running){cancelAnimationFrame(o),y();var i=t;void 0===i&&(i=b(),f=i,v=i),s=i;var a=e.params.speed,u=()=>{e&&!e.destroyed&&(e.params.autoplay.reverseDirection?!e.isBeginning||e.params.loop||e.params.rewind?(e.slidePrev(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(e.slides.length-1,a,!0,!0),n("autoplay")):!e.isEnd||e.params.loop||e.params.rewind?(e.slideNext(a,!0,!0),n("autoplay")):e.params.autoplay.stopOnLastSlide||(e.slideTo(0,a,!0,!0),n("autoplay")),e.params.cssMode&&(p=(new Date).getTime(),requestAnimationFrame(()=>{w()})))};return i>0?(clearTimeout(r),r=setTimeout(()=>{u()},i)):requestAnimationFrame(()=>{u()}),i}},k=()=>{p=(new Date).getTime(),e.autoplay.running=!0,w(),n("autoplayStart")},S=()=>{e.autoplay.running=!1,clearTimeout(r),cancelAnimationFrame(o),n("autoplayStop")},E=(t,i)=>{if(!e.destroyed&&e.autoplay.running){clearTimeout(r),t||(c=!0);var a=()=>{n("autoplayPause"),e.params.autoplay.waitForTransition?e.wrapperEl.addEventListener("transitionend",g):M()};if(e.autoplay.paused=!0,i)a();else{var o=s||e.params.autoplay.delay;s=o-((new Date).getTime()-p),e.isEnd&&s<0&&!e.params.loop||(s<0&&(s=0),a())}}},M=()=>{e.isEnd&&s<0&&!e.params.loop||e.destroyed||!e.autoplay.running||(p=(new Date).getTime(),c?(c=!1,w(s)):w(),e.autoplay.paused=!1,n("autoplayResume"))},T=()=>{if(!e.destroyed&&e.autoplay.running){var t=SR();"hidden"===t.visibilityState&&(c=!0,E(!0)),"visible"===t.visibilityState&&M()}},P=t=>{"mouse"===t.pointerType&&(c=!0,m=!0,e.animating||e.autoplay.paused||E(!0))},A=t=>{"mouse"===t.pointerType&&(m=!1,e.autoplay.paused&&M())};i("init",()=>{e.params.autoplay.enabled&&(e.params.autoplay.pauseOnMouseEnter&&(e.el.addEventListener("pointerenter",P),e.el.addEventListener("pointerleave",A)),SR().addEventListener("visibilitychange",T),k())}),i("destroy",()=>{e.el&&"string"!=typeof e.el&&(e.el.removeEventListener("pointerenter",P),e.el.removeEventListener("pointerleave",A)),SR().removeEventListener("visibilitychange",T),e.autoplay.running&&S()}),i("_freeModeStaticRelease",()=>{(d||c)&&M()}),i("_freeModeNoMomentumRelease",()=>{e.params.autoplay.disableOnInteraction?S():E(!0,!0)}),i("beforeTransitionStart",(t,i,n)=>{!e.destroyed&&e.autoplay.running&&(n||!e.params.autoplay.disableOnInteraction?E(!0,!0):S())}),i("sliderFirstMove",()=>{!e.destroyed&&e.autoplay.running&&(e.params.autoplay.disableOnInteraction?S():(l=!0,d=!1,c=!1,h=setTimeout(()=>{c=!0,d=!0,E(!0)},200)))}),i("touchEnd",()=>{if(!e.destroyed&&e.autoplay.running&&l){if(clearTimeout(h),clearTimeout(r),e.params.autoplay.disableOnInteraction)return d=!1,void(l=!1);d&&e.params.cssMode&&M(),d=!1,l=!1}}),i("slideChange",()=>{!e.destroyed&&e.autoplay.running&&e.autoplay.paused&&(s=b(),f=b())}),Object.assign(e.autoplay,{start:k,stop:S,pause:E,resume:M})}function DF(e,t){var i=WR(t);return i!==t&&(i.style.backfaceVisibility="hidden",i.style["-webkit-backface-visibility"]="hidden"),i}function xF(e,t,i){var n=`swiper-slide-shadow${i?`-${i}`:""} swiper-slide-shadow-${e}`,a=WR(t),r=a.querySelector(`.${n.split(" ").join(".")}`);return r||(r=NR("div",n.split(" ")),a.append(r)),r}function CF({swiper:e,extendParams:t,on:i}){t({coverflowEffect:{rotate:50,stretch:0,depth:100,scale:1,modifier:1,slideShadows:!0}});!function(e){var t,i=e.effect,n=e.swiper,a=e.on,r=e.setTranslate,o=e.setTransition,s=e.overwriteParams,u=e.perspective,l=e.recreateShadows,d=e.getEffectParams;a("beforeInit",()=>{if(n.params.effect===i){n.classNames.push(`${n.params.containerModifierClass}${i}`),u&&u()&&n.classNames.push(`${n.params.containerModifierClass}3d`);var e=s?s():{};Object.assign(n.params,e),Object.assign(n.originalParams,e)}}),a("setTranslate _virtualUpdated",()=>{n.params.effect===i&&r()}),a("setTransition",(e,t)=>{n.params.effect===i&&o(t)}),a("transitionEnd",()=>{if(n.params.effect===i&&l){if(!d||!d().slideShadows)return;n.slides.forEach(e=>{e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>e.remove())}),l()}}),a("virtualUpdate",()=>{n.params.effect===i&&(n.slides.length||(t=!0),requestAnimationFrame(()=>{t&&n.slides&&n.slides.length&&(r(),t=!1)}))})}({effect:"coverflow",swiper:e,on:i,setTranslate:()=>{for(var t=e.width,i=e.height,n=e.slides,a=e.slidesSizesGrid,r=e.params.coverflowEffect,o=e.isHorizontal(),s=e.translate,u=o?t/2-s:i/2-s,l=o?r.rotate:-r.rotate,d=r.depth,h=function(e){return t=>Math.abs(t)>0&&e.browser&&e.browser.need3dFix&&Math.abs(t)%90==0?t+.001:t}(e),c=0,m=n.length;c<m;c+=1){var f=n[c],v=a[c],p=(u-f.swiperSlideOffset-v/2)/v,g="function"==typeof r.modifier?r.modifier(p):p*r.modifier,y=o?l*g:0,b=o?0:l*g,w=-d*Math.abs(g),k=r.stretch;"string"==typeof k&&-1!==k.indexOf("%")&&(k=parseFloat(r.stretch)/100*v);var S=o?0:k*g,E=o?k*g:0,M=1-(1-r.scale)*Math.abs(g);Math.abs(E)<.001&&(E=0),Math.abs(S)<.001&&(S=0),Math.abs(w)<.001&&(w=0),Math.abs(y)<.001&&(y=0),Math.abs(b)<.001&&(b=0),Math.abs(M)<.001&&(M=0);var T=`translate3d(${E}px,${S}px,${w}px) rotateX(${h(b)}deg) rotateY(${h(y)}deg) scale(${M})`;if(DF(0,f).style.transform=T,f.style.zIndex=1-Math.abs(Math.round(g)),r.slideShadows){var P=o?f.querySelector(".swiper-slide-shadow-left"):f.querySelector(".swiper-slide-shadow-top"),A=o?f.querySelector(".swiper-slide-shadow-right"):f.querySelector(".swiper-slide-shadow-bottom");P||(P=xF("coverflow",f,o?"left":"top")),A||(A=xF("coverflow",f,o?"right":"bottom")),P&&(P.style.opacity=g>0?g:0),A&&(A.style.opacity=-g>0?-g:0)}}},setTransition:t=>{e.slides.map(e=>WR(e)).forEach(e=>{e.style.transitionDuration=`${t}ms`,e.querySelectorAll(".swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left").forEach(e=>{e.style.transitionDuration=`${t}ms`})})},perspective:()=>!0,overwriteParams:()=>({watchSlidesProgress:!0})})}Object.keys(SF).forEach(e=>{Object.keys(SF[e]).forEach(t=>{MF.prototype[t]=SF[e][t]})}),MF.use([function({swiper:e,on:t,emit:i}){var n=AR(),a=null,r=null,o=()=>{e&&!e.destroyed&&e.initialized&&(i("beforeResize"),i("resize"))},s=()=>{e&&!e.destroyed&&e.initialized&&i("orientationchange")};t("init",()=>{e.params.resizeObserver&&void 0!==n.ResizeObserver?e&&!e.destroyed&&e.initialized&&(a=new ResizeObserver(t=>{r=n.requestAnimationFrame(()=>{var i=e.width,n=e.height,a=i,r=n;t.forEach(({contentBoxSize:t,contentRect:i,target:n})=>{n&&n!==e.el||(a=i?i.width:(t[0]||t).inlineSize,r=i?i.height:(t[0]||t).blockSize)}),a===i&&r===n||o()})})).observe(e.el):(n.addEventListener("resize",o),n.addEventListener("orientationchange",s))}),t("destroy",()=>{r&&n.cancelAnimationFrame(r),a&&a.unobserve&&e.el&&(a.unobserve(e.el),a=null),n.removeEventListener("resize",o),n.removeEventListener("orientationchange",s)})},function({swiper:e,extendParams:t,on:i,emit:n}){var a=[],r=AR(),o=(t,i={})=>{var o=new(r.MutationObserver||r.WebkitMutationObserver)(t=>{if(!e.__preventObserver__)if(1!==t.length){var i=function(){n("observerUpdate",t[0])};r.requestAnimationFrame?r.requestAnimationFrame(i):r.setTimeout(i,0)}else n("observerUpdate",t[0])});o.observe(t,{attributes:void 0===i.attributes||i.attributes,childList:e.isElement||(void 0===i.childList||i).childList,characterData:void 0===i.characterData||i.characterData}),a.push(o)};t({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",()=>{if(e.params.observer){if(e.params.observeParents)for(var t=zR(e.hostEl),i=0;i<t.length;i+=1)o(t[i]);o(e.hostEl,{childList:e.params.observeSlideChildren}),o(e.wrapperEl,{attributes:!1})}}),i("destroy",()=>{a.forEach(e=>{e.disconnect()}),a.splice(0,a.length)})}]);var IF,LF,_F=e=>e,RF=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.updateSpacing=e=>{t.slideSpacing=e.detail.spacing,t.swiperInstance&&(t.swiperInstance.params.spaceBetween=t.slideSpacing,t.swiperInstance.update())},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),window.addEventListener("child-spacing",this.updateSpacing,!1)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),window.removeEventListener("child-spacing",this.updateSpacing,!1)}},{key:"styles",value:function(){var e,t,i,n=this.scaleFactor,a=this.component,r=a.backgroundBlur,o=a.indicator,s=a.activeIndicator,u=a.previousSlidePadding,l=a.nextSlidePadding,d="vertical"===a.direction?"margin-top":"margin-left";return U(`\n :host {\n display: ${a.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Nu(a.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n ${r?`backdrop-filter: blur(${r}px);`:""}\n z-index: ${null!==(e=a.zIndex)&&void 0!==e?e:1};\n top: 0px;\n transition: all 0.3s;\n ${xu(a,n)}\n ${function(e,t){return`\n padding-right: ${bu(t,e.nextSlidePadding)}px !important;\n padding-left: ${bu(t,e.previousSlidePadding)}px !important;\n `}(a,n)}\n ${Tu(a)}\n ${Mu(a,!1)}\n max-width: 100vw;\n }\n :host(:focus){\n ${Mu(a,!0)}\n ${Ou(a,n,!0)}\n }\n :host(:focus-visible){\n ${Uu(a)}\n }\n :host > *:not(:first-child) {\n ${d}: ${a.spacing?a.spacing*n:0}px;\n }\n .swiper-container {\n ${Lu(a,n)};\n padding-left: ${null!=u?u:0}px;\n padding-right: ${null!=l?l:0}px;\n box-sizing: border-box;\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n opacity: 1 !important;\n ${null!=(null==o?void 0:o.width)?`width: ${o.width}px !important;`:""}\n ${null!=(null==o?void 0:o.height)?`height: ${o.height}px !important;`:""}\n ${null!=(null==o?void 0:o.borderRadius)?`border-radius: ${o.borderRadius}px !important;`:""}\n background: ${null!==(t=null==o?void 0:o.fillColor)&&void 0!==t?t:a.indicatorColor} !important;\n }\n .swiper-pagination-bullet-active {\n ${null!=(null==s?void 0:s.width)?`width: ${s.width}px !important;`:""}\n ${null!=(null==s?void 0:s.height)?`height: ${s.height}px !important;`:""}\n ${null!=(null==s?void 0:s.borderRadius)?`border-radius: ${s.borderRadius}px !important;`:""}\n background: ${null!==(i=null==s?void 0:s.fillColor)&&void 0!==i?i:a.activeIndicatorColor} !important;\n }\n `)}},{key:"updated",value:function(){var e,t,i=[PF,AF],n=this.component,a=n.autoplay,r=n.autoplaySeconds,o=n.showIndicators,s=n.slideSpacing,u=n.inactiveSlideScale;u&&i.push(CF),MF.use(i);var l=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".swiper-container"),d=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector(".swiper-pagination");if(l&&!this.swiperInstance){var h,c={initialSlide:0,slidesPerView:1,loop:a,spaceBetween:null!==(h=null!=s?s:this.slideSpacing)&&void 0!==h?h:0,autoplay:!!a&&{delay:1e3*r,disableOnInteraction:!1},pagination:!(null!=o&&!o)&&{el:d,clickable:!0},on:{init:e=>{this.handleSlideChange(e)},slideChange:e=>{this.handleSlideChange(e)}}};u&&(c.effect="coverflow",c.coverflowEffect={rotate:0,stretch:0,depth:100,modifier:1,slideShadows:!1,scale:u}),this.swiperInstance=new MF(l,c)}}},{key:"handleSlideChange",value:function(e){if(this.contextProvider.setCurrentSlideIndex(e.realIndex),this.component.onChange){var t,i=this.getCarouselOnChange(this.component),n=null==i||null===(t=i.parameters)||void 0===t||null===(t=t.partialState)||void 0===t?void 0:t.currentGroupId;n&&this.contextProvider.setCurrentGroupData(n,"")}}},{key:"getCarouselOnChange",value:function(e){var t;if(e.onChange&&e.onChange.parameters){var i=this.contextProvider.state.slides,n="string"==typeof e.loopSource?e.loopSource:"",a=null==i||null===(t=i[n])||void 0===t||null===(t=t.carouselName)||void 0===t?void 0:t[this.contextProvider.state.currentSlideIndex];return Fa(e.onChange,{slide:a,sku:this.contextProvider.state.sku,state:this.contextProvider.state,launch:this.contextProvider.state.launch,customer:this.contextProvider.state.customer})}}},{key:"getCarouselSlides",value:function(e){var t,i;if(!e.loopSource)return[];var n,a=this.contextProvider.state,r=a.slides,o=a.selectedProducts,s="string"==typeof e.loopSource?e.loopSource:"",u=xa(this.contextProvider.productDetails,null!==(t=null===(i=this.contextProvider.getSelectedPaywall())||void 0===i?void 0:i.sku_menus)&&void 0!==t?t:[],s),l=[];A(r)||(l=""!=s?r[s].carouselName:null!==(n=e.loopSource)&&void 0!==n?n:[]);var d=this.contextProvider.filteredSkuMenus.map(e=>e.id);return l.filter(e=>!e.productGroupId||d.includes(e.productGroupId)).map(t=>{var i=u.find(e=>e.id==o[t.productGroupId]);return Fa(e.components,Fa({slide:t},{sku:re({},Ia(null==i?void 0:i.product_details,t,u))}))||[]})}},{key:"render",value:function(){var e=this.getCarouselSlides(this.component),t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&Ka(a,n)||(this.tabIndex=0),B(IF||(IF=_F`
|
|
514
514
|
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"/>
|
|
515
515
|
<div class="swiper-container" aria-live="assertive" aria-atomic="true">
|
|
516
516
|
<div class="swiper-wrapper">
|
|
@@ -518,10 +518,10 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
518
518
|
</div>
|
|
519
519
|
</div>
|
|
520
520
|
<div class="swiper-pagination"></div>
|
|
521
|
-
`),e.map(e=>e.map(e=>(e.spacing&&(this.slideSpacing=2*e.spacing),B(
|
|
521
|
+
`),e.map(e=>e.map(e=>(e.spacing&&(this.slideSpacing=2*e.spacing),B(LF||(LF=_F`
|
|
522
522
|
<div class="swiper-slide">
|
|
523
523
|
${0}
|
|
524
|
-
</div>`),kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))))))}}])}();gt([qt({type:Object})],_F.prototype,"component",void 0),gt([qt({type:Boolean})],_F.prototype,"inFocusedState",void 0),gt([qt({type:Number})],_F.prototype,"scaleFactor",void 0),gt([qt({type:Object})],_F.prototype,"minSDKVersion",void 0),_F=gt([Tt("nami-carousel-container")],_F);var RF=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{gs({contextProvider:t.contextProvider,onTap:t.muted?t.component.mutedOnTap:t.component.volumeOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return ue(e,lu),ne(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Mu(e,!1)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > *:not(:first-child) {\n ${i}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;this.muted=null!==(e=null===(t=ps.instance)||void 0===t?void 0:t.muted)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0});var i=this.muted?this.component.mutedComponents:this.component.volumeComponents;return null==i?void 0:i.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],RF.prototype,"component",void 0),gt([qt({type:Boolean})],RF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],RF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],RF.prototype,"minSDKVersion",void 0),RF=gt([Tt("nami-volume-button")],RF);var FF=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{gs({contextProvider:t.contextProvider,onTap:t.playing?t.component.playingOnTap:t.component.pausedOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return ue(e,lu),ne(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Mu(e,!1)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > *:not(:first-child) {\n ${i}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;return this.playing=null!==(e=null===(t=ps.instance)||void 0===t?void 0:t.playing)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0}),(this.playing?this.component.playingComponents:this.component.pausedComponents).map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],FF.prototype,"component",void 0),gt([qt({type:Boolean})],FF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],FF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],FF.prototype,"minSDKVersion",void 0),FF=gt([Tt("nami-play-pause-button")],FF);var WF=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.minSDKVersion,n=e.backgroundBlur,a="vertical"===e.direction,r=a?"width":"height",o=a?"margin-top":"margin-left",s=e.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):U(Mu(e,!1));return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${s};\n ${Nu(e.position)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n display: ${e.hidden?"none":"flex"};\n align-items: center;\n justify-content: center;\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n /* Overlapping children center on both axes like the other SDKs' ZStack;\n the flex center on :host doesn't reach absolutely-positioned boxes. */\n :host > *:not(nami-text) {\n position: absolute;\n inset: 0;\n margin: auto;\n }\n :host > * {\n ${Au(i,r)}\n }\n :host > nami-text:not(:first-child) {\n ${o}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&Ka(a,n)||(this.tabIndex=0),(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();gt([qt({type:Object})],WF.prototype,"component",void 0),gt([qt({type:Boolean})],WF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],WF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],WF.prototype,"minSDKVersion",void 0),WF=gt([Tt("nami-stack")],WF);var OF,$F,NF,jF=e=>e,BF="nami-disabled",zF=(OF=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).active=!0,t.timeSpentOnPaywall=0,t.activeTemplate=null,t}return ue(e,z),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.minSDKVersion=W(this.paywall.template.min_sdk_version),this.contextProvider=Qt.create(this.paywall,this.context,this.campaign),this.contextConsumer=new eu(this,this.contextProvider),this.flow&&this.contextProvider.setFlow(this.flow),this.contextProvider.setTimeSpentOnPaywall(this.timeSpentOnPaywall),this.contextProvider.state.userInteractionEnabled||this.classList.add(BF),this.teardownEvent=this.contextProvider.onEvent("user-interaction-changed",this.userInteractionListener.bind(this))}},{key:"disconnectedCallback",value:function(){var t;pe(e,"disconnectedCallback",this)([]),Qt.remove(this.contextProvider),this.teardownEvent(),null===(t=this.footerResizeObserver)||void 0===t||t.disconnect(),this.active&&vs()}},{key:"userInteractionListener",value:function(e){this.classList.toggle(BF,!e.enabled)}},{key:"firstUpdated",value:function(){this.postImpression(),this.postPaywallScreenData(),this.updateActiveRenderRoot(),this.observeFooterHeight()}},{key:"updated",value:function(){this.updateActiveRenderRoot()}},{key:"updateActiveRenderRoot",value:function(){this.active&&this.activeTemplate&&(us(this.activeTemplate,this.contextProvider),function(e){if(_r("setActivePageRenderRoot:enter",{hasRoot:!!e,rootType:e instanceof Element?Fr(e):e instanceof DocumentFragment?"document-fragment":String(e),activePageKey:sr,activePageAnnounced:or,activeElement:Fr(Ur())}),rr=e,e&&nr&&!or){var t=Ur();if(t&&"contains"in e&&e.contains(t))ls(t);else if(e instanceof DocumentFragment){var i=e.activeElement;i&&ls(i)}}}(this.renderRoot))}},{key:"observeFooterHeight",value:function(){if("undefined"!=typeof ResizeObserver){var e=this.renderRoot.querySelector("nami-footer");e&&(this.footerResizeObserver=new ResizeObserver(e=>{var t,i,n=e[e.length-1];if(n){var a=null!==(t=null===(i=n.borderBoxSize)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.blockSize)&&void 0!==t?t:n.contentRect.height;this.style.setProperty("--nami-footer-height",`${a}px`)}}),this.footerResizeObserver.observe(e))}}},{key:"postImpression",value:function(){var e,t;null!==(e=this.paywall)&&void 0!==e&&e.id&&(e=>{var t,i,a;ce(function(r){for(;;)switch(r.p=r.n){case 0:if(!F()){r.n=1;break}return n.info("Skipping paywall impression - anonymous mode"),r.a(2);case 1:return(t=p.getSessionId())&&(e.session=t),(i=p.getLaunchId())&&(e.launch_id=i),e.app_env="production",e.url_params=s(),n.info("Post paywall impression - segment ",e.segment),r.p=2,r.n=3,q(R.instance.postImpression(e));case 3:r.n=5;break;case 4:r.p=4,a=r.v,n.error("Error posting impression",a);case 5:return r.a(2)}},null,null,[[2,4]],Promise)})({segment:null===(t=this.campaign)||void 0===t?void 0:t.segment,call_to_action:this.paywall.id})}},{key:"postPaywallScreenData",value:function(){f.getInstance().emit(v,re({},this.contextProvider.getPaywallActionEventData(),{action:m.SHOW_PAYWALL}))}},{key:"getTemplate",value:function(){var e,t,i,n;this.contextProvider.state.selectedPaywall===this.paywall?t=this.contextProvider.state.currentPage:t=null!==(i=null===(n=this.paywall.template)||void 0===n||null===(n=n.initialState)||void 0===n?void 0:n.currentPage)&&void 0!==i?i:"page1";var a=null===(e=this.paywall.template)||void 0===e?void 0:e.pages.find(e=>e.name===t);if(!a)throw new Error(`Page with name ${t} not found in paywall template.`);return this.activeTemplate=a,this.active&&us(a,this.contextProvider),a}},{key:"render",value:function(){var e,t=this.getTemplate(),i=t.backgroundContainer,n=t.header,a=void 0===n?[]:n,r=t.footer,o=void 0===r?[]:r,s=t.contentContainer,u=null!==(e=this.contextProvider.state.fullScreenPresentation)&&void 0!==e&&e,l=this.contextProvider.getFormFactor(),d=O(l);return B($F||($F=jF`
|
|
524
|
+
</div>`),kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))))))}}])}();gt([qt({type:Object})],RF.prototype,"component",void 0),gt([qt({type:Boolean})],RF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],RF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],RF.prototype,"minSDKVersion",void 0),RF=gt([Tt("nami-carousel-container")],RF);var FF=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{gs({contextProvider:t.contextProvider,onTap:t.muted?t.component.mutedOnTap:t.component.volumeOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return ue(e,lu),ne(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Mu(e,!1)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > *:not(:first-child) {\n ${i}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;this.muted=null!==(e=null===(t=ps.instance)||void 0===t?void 0:t.muted)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0});var i=this.muted?this.component.mutedComponents:this.component.volumeComponents;return null==i?void 0:i.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],FF.prototype,"component",void 0),gt([qt({type:Boolean})],FF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],FF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],FF.prototype,"minSDKVersion",void 0),FF=gt([Tt("nami-volume-button")],FF);var WF=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleBlur=()=>{t.inFocusedState=!1},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t._handleClick=()=>{gs({contextProvider:t.contextProvider,onTap:t.playing?t.component.playingOnTap:t.component.pausedOnTap}),t.requestUpdate()},t.addEventListener("click",t._handleClick,!1),t.addEventListener("focus",t._handleFocus,!1),t.addEventListener("blur",t._handleBlur,!1),t.addEventListener("keydown",t._handleKeyDown,!1),t}return ue(e,lu),ne(e,[{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i="vertical"===e.direction?"margin-top":"margin-left";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n cursor: pointer;\n ${Mu(e,!1)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n :host > *:not(:first-child) {\n ${i}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t;return this.playing=null!==(e=null===(t=ps.instance)||void 0===t?void 0:t.playing)&&void 0!==e&&e,this.tabIndex=0,this.role="button",1==this.inFocusedState&&this.focus({preventScroll:!0}),(this.playing?this.component.playingComponents:this.component.pausedComponents).map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],WF.prototype,"component",void 0),gt([qt({type:Boolean})],WF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],WF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],WF.prototype,"minSDKVersion",void 0),WF=gt([Tt("nami-play-pause-button")],WF);var OF=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.minSDKVersion,n=e.backgroundBlur,a="vertical"===e.direction,r=a?"width":"height",o=a?"margin-top":"margin-left",s=e.fillImage?U(`\n line-height: 1.5715;\n background-image: url(${e.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):U(Mu(e,!1));return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n ${n?`backdrop-filter: blur(${n}px);`:""}\n ${s};\n ${Nu(e.position)}\n ${Tu(e)}\n ${Ou(e,t,!1)}\n display: ${e.hidden?"none":"flex"};\n align-items: center;\n justify-content: center;\n }\n :host(:focus){\n ${Mu(e,!0)}\n ${Ou(e,t,!0)}\n }\n :host(:focus-visible){\n ${Uu(e)}\n }\n /* Overlapping children center on both axes like the other SDKs' ZStack;\n the flex center on :host doesn't reach absolutely-positioned boxes. */\n :host > *:not(nami-text) {\n position: absolute;\n inset: 0;\n margin: auto;\n }\n :host > * {\n ${Au(i,r)}\n }\n :host > nami-text:not(:first-child) {\n ${o}: ${e.spacing?e.spacing*t:0}px;\n }\n `)}},{key:"render",value:function(){var e,t=this.component,i=t.focusedBorderColor,n=t.focusedFillColor,a=t.fillColor;return!i&&Ka(a,n)||(this.tabIndex=0),(null!==(e=this.component.components)&&void 0!==e?e:[]).map(e=>kl(this.contextProvider,e,this.scaleFactor,void 0,this.minSDKVersion))}}])}();gt([qt({type:Object})],OF.prototype,"component",void 0),gt([qt({type:Boolean})],OF.prototype,"inFocusedState",void 0),gt([qt({type:Number})],OF.prototype,"scaleFactor",void 0),gt([qt({type:Object})],OF.prototype,"minSDKVersion",void 0),OF=gt([Tt("nami-stack")],OF);var $F,NF,jF,BF=e=>e,zF="nami-disabled",UF=($F=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).active=!0,t.timeSpentOnPaywall=0,t.activeTemplate=null,t}return ue(e,z),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.minSDKVersion=W(this.paywall.template.min_sdk_version),this.contextProvider=Qt.create(this.paywall,this.context,this.campaign),this.contextConsumer=new eu(this,this.contextProvider),this.flow&&this.contextProvider.setFlow(this.flow),this.contextProvider.setTimeSpentOnPaywall(this.timeSpentOnPaywall),this.contextProvider.state.userInteractionEnabled||this.classList.add(zF),this.teardownEvent=this.contextProvider.onEvent("user-interaction-changed",this.userInteractionListener.bind(this))}},{key:"disconnectedCallback",value:function(){var t;pe(e,"disconnectedCallback",this)([]),Qt.remove(this.contextProvider),this.teardownEvent(),null===(t=this.footerResizeObserver)||void 0===t||t.disconnect(),this.active&&vs()}},{key:"userInteractionListener",value:function(e){this.classList.toggle(zF,!e.enabled)}},{key:"firstUpdated",value:function(){this.postImpression(),this.postPaywallScreenData(),this.updateActiveRenderRoot(),this.observeFooterHeight()}},{key:"updated",value:function(){this.updateActiveRenderRoot()}},{key:"updateActiveRenderRoot",value:function(){this.active&&this.activeTemplate&&(us(this.activeTemplate,this.contextProvider),function(e){if(_r("setActivePageRenderRoot:enter",{hasRoot:!!e,rootType:e instanceof Element?Fr(e):e instanceof DocumentFragment?"document-fragment":String(e),activePageKey:sr,activePageAnnounced:or,activeElement:Fr(Ur())}),rr=e,e&&nr&&!or){var t=Ur();if(t&&"contains"in e&&e.contains(t))ls(t);else if(e instanceof DocumentFragment){var i=e.activeElement;i&&ls(i)}}}(this.renderRoot))}},{key:"observeFooterHeight",value:function(){if("undefined"!=typeof ResizeObserver){var e=this.renderRoot.querySelector("nami-footer");e&&(this.footerResizeObserver=new ResizeObserver(e=>{var t,i,n=e[e.length-1];if(n){var a=null!==(t=null===(i=n.borderBoxSize)||void 0===i||null===(i=i[0])||void 0===i?void 0:i.blockSize)&&void 0!==t?t:n.contentRect.height;this.style.setProperty("--nami-footer-height",`${a}px`)}}),this.footerResizeObserver.observe(e))}}},{key:"postImpression",value:function(){var e,t;null!==(e=this.paywall)&&void 0!==e&&e.id&&(e=>{var t,i,a;ce(function(r){for(;;)switch(r.p=r.n){case 0:if(!F()){r.n=1;break}return n.info("Skipping paywall impression - anonymous mode"),r.a(2);case 1:return(t=p.getSessionId())&&(e.session=t),(i=p.getLaunchId())&&(e.launch_id=i),e.app_env="production",e.url_params=s(),n.info("Post paywall impression - segment ",e.segment),r.p=2,r.n=3,q(R.instance.postImpression(e));case 3:r.n=5;break;case 4:r.p=4,a=r.v,n.error("Error posting impression",a);case 5:return r.a(2)}},null,null,[[2,4]],Promise)})({segment:null===(t=this.campaign)||void 0===t?void 0:t.segment,call_to_action:this.paywall.id})}},{key:"postPaywallScreenData",value:function(){f.getInstance().emit(v,re({},this.contextProvider.getPaywallActionEventData(),{action:m.SHOW_PAYWALL}))}},{key:"getTemplate",value:function(){var e,t,i,n;this.contextProvider.state.selectedPaywall===this.paywall?t=this.contextProvider.state.currentPage:t=null!==(i=null===(n=this.paywall.template)||void 0===n||null===(n=n.initialState)||void 0===n?void 0:n.currentPage)&&void 0!==i?i:"page1";var a=null===(e=this.paywall.template)||void 0===e?void 0:e.pages.find(e=>e.name===t);if(!a)throw new Error(`Page with name ${t} not found in paywall template.`);return this.activeTemplate=a,this.active&&us(a,this.contextProvider),a}},{key:"render",value:function(){var e,t=this.getTemplate(),i=t.backgroundContainer,n=t.header,a=void 0===n?[]:n,r=t.footer,o=void 0===r?[]:r,s=t.contentContainer,u=null!==(e=this.contextProvider.state.fullScreenPresentation)&&void 0!==e&&e,l=this.contextProvider.getFormFactor(),d=O(l);return B(NF||(NF=BF`
|
|
525
525
|
<nami-background-container
|
|
526
526
|
.component=${0}
|
|
527
527
|
.scaleFactor=${0}
|
|
@@ -545,7 +545,7 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
545
545
|
.scaleFactor=${0}
|
|
546
546
|
.minSDKVersion=${0}
|
|
547
547
|
></nami-footer>
|
|
548
|
-
`),i,d,this.minSDKVersion,a,l,d,u,this.minSDKVersion,s,d,l,this.minSDKVersion,o,d,this.minSDKVersion)}}])}()
|
|
548
|
+
`),i,d,this.minSDKVersion,a,l,d,u,this.minSDKVersion,s,d,l,this.minSDKVersion,o,d,this.minSDKVersion)}}])}(),$F.styles=j(jF||(jF=BF`
|
|
549
549
|
:host {
|
|
550
550
|
display: flex;
|
|
551
551
|
flex-direction: column;
|
|
@@ -554,15 +554,15 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
554
554
|
min-height: 0;
|
|
555
555
|
overflow: hidden;
|
|
556
556
|
}
|
|
557
|
-
`)),OF);gt([qt({type:Object})],zF.prototype,"paywall",void 0),gt([qt({type:Object})],zF.prototype,"campaign",void 0),gt([qt({type:Object})],zF.prototype,"context",void 0),gt([qt({type:Boolean})],zF.prototype,"active",void 0),gt([function({context:e}){return(t,i)=>{var n=new WeakMap;if("object"==typeof i)return{get(){return t.get.call(this)},set(e){return n.get(this).setValue(e),t.set.call(this,e)},init(t){return n.set(this,new Zs(this,{context:e,initialValue:t})),t}};t.constructor.addInitializer(t=>{n.set(t,new Zs(t,{context:e}))});var a,r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var o=new WeakMap;a={get(){return o.get(this)},set(e){n.get(this).setValue(e),o.set(this,e)},configurable:!0,enumerable:!0}}else{var s=r.set;a=re({},r,{set(e){n.get(this).setValue(e),null==s||s.call(this,e)}})}Object.defineProperty(t,i,a)}}({context:tu})],zF.prototype,"contextProvider",void 0),zF=gt([Tt("nami-paywall-screen")],zF);var UF,HF,GF={};function VF(){return HF?UF:(HF=1,UF=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var KF,XF={},YF={};function qF(){if(KF)return YF;var e;KF=1;var t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return YF.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},YF.getSymbolTotalCodewords=function(e){return t[e]},YF.getBCHDigit=function(e){for(var t=0;0!==e;)t++,e>>>=1;return t},YF.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},YF.isKanjiModeEnabled=function(){return void 0!==e},YF.toSJIS=function(t){return e(t)},YF}var JF,QF,ZF,eW,tW,iW={};function nW(){return JF||(JF=1,function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2},e.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(e){return i}}}(iW)),iW}var aW,rW={};var oW,sW={};var uW,lW={};var dW,hW={};function cW(){if(dW)return hW;dW=1;var e=nW(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return hW.getBlocksCount=function(i,n){switch(n){case e.L:return t[4*(i-1)+0];case e.M:return t[4*(i-1)+1];case e.Q:return t[4*(i-1)+2];case e.H:return t[4*(i-1)+3];default:return}},hW.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return i[4*(t-1)+0];case e.M:return i[4*(t-1)+1];case e.Q:return i[4*(t-1)+2];case e.H:return i[4*(t-1)+3];default:return}},hW}var mW,fW,vW,pW,gW={},yW={};function bW(){return fW||(fW=1,function(e){var t=function(){if(mW)return yW;mW=1;var e=new Uint8Array(512),t=new Uint8Array(256);return function(){for(var i=1,n=0;n<255;n++)e[n]=i,t[i]=n,256&(i<<=1)&&(i^=285);for(var a=255;a<512;a++)e[a]=e[a-255]}(),yW.log=function(e){if(e<1)throw new Error("log("+e+")");return t[e]},yW.exp=function(t){return e[t]},yW.mul=function(i,n){return 0===i||0===n?0:e[t[i]+t[n]]},yW}();e.mul=function(e,i){for(var n=new Uint8Array(e.length+i.length-1),a=0;a<e.length;a++)for(var r=0;r<i.length;r++)n[a+r]^=t.mul(e[a],i[r]);return n},e.mod=function(e,i){for(var n=new Uint8Array(e);n.length-i.length>=0;){for(var a=n[0],r=0;r<i.length;r++)n[r]^=t.mul(i[r],a);for(var o=0;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},e.generateECPolynomial=function(i){for(var n=new Uint8Array([1]),a=0;a<i;a++)n=e.mul(n,new Uint8Array([1,t.exp(a)]));return n}}(gW)),gW}var wW,kW={},SW={},EW={};function MW(){return wW||(wW=1,EW.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),EW}var TW,PW,AW,DW={};function xW(){if(TW)return DW;TW=1;var e="[0-9]+",t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",i="(?:(?![A-Z0-9 $%*+\\-./:]|"+(t=t.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";DW.KANJI=new RegExp(t,"g"),DW.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),DW.BYTE=new RegExp(i,"g"),DW.NUMERIC=new RegExp(e,"g"),DW.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+t+"$"),a=new RegExp("^"+e+"$"),r=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return DW.testKanji=function(e){return n.test(e)},DW.testNumeric=function(e){return a.test(e)},DW.testAlphanumeric=function(e){return r.test(e)},DW}function CW(){return PW||(PW=1,function(e){var t=MW(),i=xW();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,i){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?e.ccBits[0]:i<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return i.testNumeric(t)?e.NUMERIC:i.testAlphanumeric(t)?e.ALPHANUMERIC:i.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return i}}}(SW)),SW}function IW(){return AW||(AW=1,function(e){var t=qF(),i=cW(),n=nW(),a=CW(),r=MW(),o=t.getBCHDigit(7973);function s(e,t){return a.getCharCountIndicator(e,t)+4}function u(e,t){var i=0;return e.forEach(function(e){var n=s(e.mode,t);i+=n+e.getBitsLength()}),i}e.from=function(e,t){return r.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,n,o){if(!r.isValid(e))throw new Error("Invalid QR Code version");void 0===o&&(o=a.BYTE);var u=8*(t.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,n));if(o===a.MIXED)return u;var l=u-s(o,e);switch(o){case a.NUMERIC:return Math.floor(l/10*3);case a.ALPHANUMERIC:return Math.floor(l/11*2);case a.KANJI:return Math.floor(l/13);case a.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,i){var r,o=n.from(i,n.M);if(Array.isArray(t)){if(t.length>1)return function(t,i){for(var n=1;n<=40;n++)if(u(t,n)<=e.getCapacity(n,i,a.MIXED))return n}(t,o);if(0===t.length)return 1;r=t[0]}else r=t;return function(t,i,n){for(var a=1;a<=40;a++)if(i<=e.getCapacity(a,n,t))return a}(r.mode,r.getLength(),o)},e.getEncodedBits=function(e){if(!r.isValid(e)||e<7)throw new Error("Invalid QR Code version");for(var i=e<<12;t.getBCHDigit(i)-o>=0;)i^=7973<<t.getBCHDigit(i)-o;return e<<12|i}}(kW)),kW}var LW,_W={};var RW,FW,WW,OW,$W,NW,jW,BW,zW={};var UW,HW,GW,VW={exports:{}};function KW(){return UW||(UW=1,function(e){var t={single_source_shortest_paths:function(e,i,n){var a={},r={};r[i]=0;var o,s,u,l,d,h,c,m=t.PriorityQueue.make();for(m.push(i,0);!m.empty();)for(u in s=(o=m.pop()).value,l=o.cost,d=e[s]||{})d.hasOwnProperty(u)&&(h=l+d[u],c=r[u],(void 0===r[u]||c>h)&&(r[u]=h,m.push(u,h),a[u]=s));if(void 0!==n&&void 0===r[n]){var f=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(f)}return a},extract_shortest_path_from_predecessor_list:function(e,t){for(var i=[],n=t;n;)i.push(n),e[n],n=e[n];return i.reverse(),i},find_path:function(e,i,n){var a=t.single_source_shortest_paths(e,i,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(e){var i,n=t.PriorityQueue,a={};for(i in e=e||{},n)n.hasOwnProperty(i)&&(a[i]=n[i]);return a.queue=[],a.sorter=e.sorter||n.default_sorter,a},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var i={value:e,cost:t};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(VW)),VW.exports}function XW(){return HW||(HW=1,function(e){var t=CW(),i=function(){if(FW)return RW;FW=1;var e=CW();function t(t){this.mode=e.NUMERIC,this.data=t.toString()}return t.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var a=this.data.length-t;a>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,3*a+1))},RW=t}(),n=function(){if(OW)return WW;OW=1;var e=CW(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=e.ALPHANUMERIC,this.data=t}return i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i+2<=this.data.length;i+=2){var n=45*t.indexOf(this.data[i]);n+=t.indexOf(this.data[i+1]),e.put(n,11)}this.data.length%2&&e.put(t.indexOf(this.data[i]),6)},WW=i}(),a=function(){if(NW)return $W;NW=1;var e=CW();function t(t){this.mode=e.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}return t.getBitsLength=function(e){return 8*e},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){for(var t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)},$W=t}(),r=function(){if(BW)return jW;BW=1;var e=CW(),t=qF();function i(t){this.mode=e.KANJI,this.data=t}return i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i<this.data.length;i++){var n=t.toSJIS(this.data[i]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[i]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}},jW=i}(),o=xW(),s=qF(),u=KW();function l(e){return unescape(encodeURIComponent(e)).length}function d(e,t,i){for(var n,a=[];null!==(n=e.exec(i));)a.push({data:n[0],index:n.index,mode:t,length:n[0].length});return a}function h(e){var i,n,a=d(o.NUMERIC,t.NUMERIC,e),r=d(o.ALPHANUMERIC,t.ALPHANUMERIC,e);return s.isKanjiModeEnabled()?(i=d(o.BYTE,t.BYTE,e),n=d(o.KANJI,t.KANJI,e)):(i=d(o.BYTE_KANJI,t.BYTE,e),n=[]),a.concat(r,i,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function c(e,o){switch(o){case t.NUMERIC:return i.getBitsLength(e);case t.ALPHANUMERIC:return n.getBitsLength(e);case t.KANJI:return r.getBitsLength(e);case t.BYTE:return a.getBitsLength(e)}}function m(e,o){var u,l=t.getBestModeForData(e);if((u=t.from(o,l))!==t.BYTE&&u.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(u)+".\n Suggested mode is: "+t.toString(l));switch(u!==t.KANJI||s.isKanjiModeEnabled()||(u=t.BYTE),u){case t.NUMERIC:return new i(e);case t.ALPHANUMERIC:return new n(e);case t.KANJI:return new r(e);case t.BYTE:return new a(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},e.fromString=function(i,n){for(var a=function(e){for(var i=[],n=0;n<e.length;n++){var a=e[n];switch(a.mode){case t.NUMERIC:i.push([a,{data:a.data,mode:t.ALPHANUMERIC,length:a.length},{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.ALPHANUMERIC:i.push([a,{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.KANJI:i.push([a,{data:a.data,mode:t.BYTE,length:l(a.data)}]);break;case t.BYTE:i.push([{data:a.data,mode:t.BYTE,length:l(a.data)}])}}return i}(h(i,s.isKanjiModeEnabled())),r=function(e,i){for(var n={},a={start:{}},r=["start"],o=0;o<e.length;o++){for(var s=e[o],u=[],l=0;l<s.length;l++){var d=s[l],h=""+o+l;u.push(h),n[h]={node:d,lastCount:0},a[h]={};for(var m=0;m<r.length;m++){var f=r[m];n[f]&&n[f].node.mode===d.mode?(a[f][h]=c(n[f].lastCount+d.length,d.mode)-c(n[f].lastCount,d.mode),n[f].lastCount+=d.length):(n[f]&&(n[f].lastCount=d.length),a[f][h]=c(d.length,d.mode)+4+t.getCharCountIndicator(d.mode,i))}}r=u}for(var v=0;v<r.length;v++)a[r[v]].end=0;return{map:a,table:n}}(a,n),o=u.find_path(r.map,"start","end"),d=[],m=1;m<o.length-1;m++)d.push(r.table[o[m]].node);return e.fromArray(function(e){return e.reduce(function(e,t){var i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(d))},e.rawSplit=function(t){return e.fromArray(h(t,s.isKanjiModeEnabled()))}}(zW)),zW}function YW(){if(GW)return XF;GW=1;var e=qF(),t=nW(),i=function(){if(ZF)return QF;function e(){this.buffer=[],this.length=0}return ZF=1,e.prototype={get:function(e){var t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(var i=0;i<t;i++)this.putBit(1==(e>>>t-i-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},QF=e}(),n=function(){if(tW)return eW;function e(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return tW=1,e.prototype.set=function(e,t,i,n){var a=e*this.size+t;this.data[a]=i,n&&(this.reservedBit[a]=!0)},e.prototype.get=function(e,t){return this.data[e*this.size+t]},e.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i},e.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},eW=e}(),a=(aW||(aW=1,function(e){var t=qF().getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];for(var i=Math.floor(e/7)+2,n=t(e),a=145===n?26:2*Math.ceil((n-13)/(2*i-2)),r=[n-7],o=1;o<i-1;o++)r[o]=r[o-1]-a;return r.push(6),r.reverse()},e.getPositions=function(t){for(var i=[],n=e.getRowColCoords(t),a=n.length,r=0;r<a;r++)for(var o=0;o<a;o++)0===r&&0===o||0===r&&o===a-1||r===a-1&&0===o||i.push([n[r],n[o]]);return i}}(rW)),rW),r=function(){if(oW)return sW;oW=1;var e=qF().getSymbolSize;return sW.getPositions=function(t){var i=e(t);return[[0,0],[i-7,0],[0,i-7]]},sW}(),o=(uW||(uW=1,function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t=3,i=3,n=40,a=10;function r(t,i,n){switch(t){case e.Patterns.PATTERN000:return(i+n)%2==0;case e.Patterns.PATTERN001:return i%2==0;case e.Patterns.PATTERN010:return n%3==0;case e.Patterns.PATTERN011:return(i+n)%3==0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(n/3))%2==0;case e.Patterns.PATTERN101:return i*n%2+i*n%3==0;case e.Patterns.PATTERN110:return(i*n%2+i*n%3)%2==0;case e.Patterns.PATTERN111:return(i*n%3+(i+n)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){for(var i=e.size,n=0,a=0,r=0,o=null,s=null,u=0;u<i;u++){a=r=0,o=s=null;for(var l=0;l<i;l++){var d=e.get(u,l);d===o?a++:(a>=5&&(n+=t+(a-5)),o=d,a=1),(d=e.get(l,u))===s?r++:(r>=5&&(n+=t+(r-5)),s=d,r=1)}a>=5&&(n+=t+(a-5)),r>=5&&(n+=t+(r-5))}return n},e.getPenaltyN2=function(e){for(var t=e.size,n=0,a=0;a<t-1;a++)for(var r=0;r<t-1;r++){var o=e.get(a,r)+e.get(a,r+1)+e.get(a+1,r)+e.get(a+1,r+1);4!==o&&0!==o||n++}return n*i},e.getPenaltyN3=function(e){for(var t=e.size,i=0,a=0,r=0,o=0;o<t;o++){a=r=0;for(var s=0;s<t;s++)a=a<<1&2047|e.get(o,s),s>=10&&(1488===a||93===a)&&i++,r=r<<1&2047|e.get(s,o),s>=10&&(1488===r||93===r)&&i++}return i*n},e.getPenaltyN4=function(e){for(var t=0,i=e.data.length,n=0;n<i;n++)t+=e.data[n];return Math.abs(Math.ceil(100*t/i/5)-10)*a},e.applyMask=function(e,t){for(var i=t.size,n=0;n<i;n++)for(var a=0;a<i;a++)t.isReserved(a,n)||t.xor(a,n,r(e,a,n))},e.getBestMask=function(t,i){for(var n=Object.keys(e.Patterns).length,a=0,r=1/0,o=0;o<n;o++){i(o),e.applyMask(o,t);var s=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),s<r&&(r=s,a=o)}return a}}(lW)),lW),s=cW(),u=function(){if(pW)return vW;pW=1;var e=bW();function t(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(t){this.degree=t,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var i=new Uint8Array(t.length+this.degree);i.set(t);var n=e.mod(i,this.genPoly),a=this.degree-n.length;if(a>0){var r=new Uint8Array(this.degree);return r.set(n,a),r}return n},vW=t}(),l=IW(),d=function(){if(LW)return _W;LW=1;var e=qF(),t=e.getBCHDigit(1335);return _W.getEncodedBits=function(i,n){for(var a=i.bit<<3|n,r=a<<10;e.getBCHDigit(r)-t>=0;)r^=1335<<e.getBCHDigit(r)-t;return 21522^(a<<10|r)},_W}(),h=CW(),c=XW();function m(e,t,i){var n,a,r=e.size,o=d.getEncodedBits(t,i);for(n=0;n<15;n++)a=1==(o>>n&1),n<6?e.set(n,8,a,!0):n<8?e.set(n+1,8,a,!0):e.set(r-15+n,8,a,!0),n<8?e.set(8,r-n-1,a,!0):n<9?e.set(8,15-n-1+1,a,!0):e.set(8,15-n-1,a,!0);e.set(r-8,8,1,!0)}function f(t,n,a){var r=new i;a.forEach(function(e){r.put(e.mode.bit,4),r.put(e.getLength(),h.getCharCountIndicator(e.mode,t)),e.write(r)});var o=8*(e.getSymbolTotalCodewords(t)-s.getTotalCodewordsCount(t,n));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);for(var l=(o-r.getLengthInBits())/8,d=0;d<l;d++)r.put(d%2?17:236,8);return function(t,i,n){for(var a=e.getSymbolTotalCodewords(i),r=s.getTotalCodewordsCount(i,n),o=a-r,l=s.getBlocksCount(i,n),d=l-a%l,h=Math.floor(a/l),c=Math.floor(o/l),m=c+1,f=h-c,v=new u(f),p=0,g=new Array(l),y=new Array(l),b=0,w=new Uint8Array(t.buffer),k=0;k<l;k++){var S=k<d?c:m;g[k]=w.slice(p,p+S),y[k]=v.encode(g[k]),p+=S,b=Math.max(b,S)}var E,M,T=new Uint8Array(a),P=0;for(E=0;E<b;E++)for(M=0;M<l;M++)E<g[M].length&&(T[P++]=g[M][E]);for(E=0;E<f;E++)for(M=0;M<l;M++)T[P++]=y[M][E];return T}(r,t,n)}function v(t,i,s,u){var d;if(Array.isArray(t))d=c.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");var h=i;if(!h){var v=c.rawSplit(t);h=l.getBestVersionForData(v,s)}d=c.fromString(t,h||40)}var p=l.getBestVersionForData(d,s);if(!p)throw new Error("The amount of data is too big to be stored in a QR Code");if(i){if(i<p)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+p+".\n")}else i=p;var g=f(i,s,d),y=e.getSymbolSize(i),b=new n(y);return function(e,t){for(var i=e.size,n=r.getPositions(t),a=0;a<n.length;a++)for(var o=n[a][0],s=n[a][1],u=-1;u<=7;u++)if(!(o+u<=-1||i<=o+u))for(var l=-1;l<=7;l++)s+l<=-1||i<=s+l||(u>=0&&u<=6&&(0===l||6===l)||l>=0&&l<=6&&(0===u||6===u)||u>=2&&u<=4&&l>=2&&l<=4?e.set(o+u,s+l,!0,!0):e.set(o+u,s+l,!1,!0))}(b,i),function(e){for(var t=e.size,i=8;i<t-8;i++){var n=i%2==0;e.set(i,6,n,!0),e.set(6,i,n,!0)}}(b),function(e,t){for(var i=a.getPositions(t),n=0;n<i.length;n++)for(var r=i[n][0],o=i[n][1],s=-2;s<=2;s++)for(var u=-2;u<=2;u++)-2===s||2===s||-2===u||2===u||0===s&&0===u?e.set(r+s,o+u,!0,!0):e.set(r+s,o+u,!1,!0)}(b,i),m(b,s,0),i>=7&&function(e,t){for(var i,n,a,r=e.size,o=l.getEncodedBits(t),s=0;s<18;s++)i=Math.floor(s/3),n=s%3+r-8-3,a=1==(o>>s&1),e.set(i,n,a,!0),e.set(n,i,a,!0)}(b,i),function(e,t){for(var i=e.size,n=-1,a=i-1,r=7,o=0,s=i-1;s>0;s-=2)for(6===s&&s--;;){for(var u=0;u<2;u++)if(!e.isReserved(a,s-u)){var l=!1;o<t.length&&(l=1==(t[o]>>>r&1)),e.set(a,s-u,l),-1===--r&&(o++,r=7)}if((a+=n)<0||i<=a){a-=n,n=-n;break}}}(b,g),isNaN(u)&&(u=o.getBestMask(b,m.bind(null,b,s))),o.applyMask(u,b),m(b,s,u),{modules:b,version:i,errorCorrectionLevel:s,maskPattern:u,segments:d}}return XF.create=function(i,n){if(void 0===i||""===i)throw new Error("No input text");var a,r,s=t.M;return void 0!==n&&(s=t.from(n.errorCorrectionLevel,t.M),a=l.from(n.version),r=o.from(n.maskPattern),n.toSJISFunc&&e.setToSJISFunction(n.toSJISFunc)),v(i,a,s,r)},XF}var qW,JW,QW={},ZW={};function eO(){return qW||(qW=1,function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");var t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");var i=parseInt(t.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:255&i,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});var i=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,n=e.width&&e.width>=21?e.width:void 0,a=e.scale||4;return{width:n,scale:n?4:a,margin:i,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,i){var n=e.getScale(t,i);return Math.floor((t+2*i.margin)*n)},e.qrToImageData=function(t,i,n){for(var a=i.modules.size,r=i.modules.data,o=e.getScale(a,n),s=Math.floor((a+2*n.margin)*o),u=n.margin*o,l=[n.color.light,n.color.dark],d=0;d<s;d++)for(var h=0;h<s;h++){var c=4*(d*s+h),m=n.color.light;if(d>=u&&h>=u&&d<s-u&&h<s-u)m=l[r[Math.floor((d-u)/o)*a+Math.floor((h-u)/o)]?1:0];t[c++]=m.r,t[c++]=m.g,t[c++]=m.b,t[c]=m.a}}}(ZW)),ZW}function tO(){return JW||(JW=1,function(e){var t=eO();e.render=function(e,i,n){var a=n,r=i;void 0!==a||i&&i.getContext||(a=i,i=void 0),i||(r=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),a=t.getOptions(a);var o=t.getImageWidth(e.modules.size,a),s=r.getContext("2d"),u=s.createImageData(o,o);return t.qrToImageData(u.data,e,a),function(e,t,i){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=i,t.width=i,t.style.height=i+"px",t.style.width=i+"px"}(s,r,o),s.putImageData(u,0,0),r},e.renderToDataURL=function(t,i,n){var a=n;void 0!==a||i&&i.getContext||(a=i,i=void 0),a||(a={});var r=e.render(t,i,a),o=a.type||"image/png",s=a.rendererOpts||{};return r.toDataURL(o,s.quality)}}(QW)),QW}var iO,nO,aO={};function rO(){if(iO)return aO;iO=1;var e=eO();function t(e,t){var i=e.a/255,n=t+'="'+e.hex+'"';return i<1?n+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':n}function i(e,t,i){var n=e+t;return void 0!==i&&(n+=" "+i),n}return aO.render=function(n,a,r){var o=e.getOptions(a),s=n.modules.size,u=n.modules.data,l=s+2*o.margin,d=o.color.light.a?"<path "+t(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",h="<path "+t(o.color.dark,"stroke")+' d="'+function(e,t,n){for(var a="",r=0,o=!1,s=0,u=0;u<e.length;u++){var l=Math.floor(u%t),d=Math.floor(u/t);l||o||(o=!0),e[u]?(s++,u>0&&l>0&&e[u-1]||(a+=o?i("M",l+n,.5+d+n):i("m",r,0),r=0,o=!1),l+1<t&&e[u+1]||(a+=i("h",s),s=0)):r++}return a}(u,s,o.margin)+'"/>',c='viewBox="0 0 '+l+" "+l+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+c+' shape-rendering="crispEdges">'+d+h+"</svg>\n";return"function"==typeof r&&r(null,m),m},aO}var oO,sO,uO=function(){if(nO)return GF;nO=1;var e=VF(),t=YW(),i=tO(),n=rO();function a(i,n,a,r,o){var s=[].slice.call(arguments,1),u=s.length,l="function"==typeof s[u-1];if(!l&&!e())throw new Error("Callback required as last argument");if(!l){if(u<1)throw new Error("Too few arguments provided");return 1===u?(a=n,n=r=void 0):2!==u||n.getContext||(r=a,a=n,n=void 0),new Promise(function(e,o){try{var s=t.create(a,r);e(i(s,n,r))}catch(e){o(e)}})}if(u<2)throw new Error("Too few arguments provided");2===u?(o=a,a=n,n=r=void 0):3===u&&(n.getContext&&void 0===o?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0));try{var d=t.create(a,r);o(null,i(d,n,r))}catch(e){o(e)}}return GF.create=t.create,GF.toCanvas=a.bind(null,i.render),GF.toDataURL=a.bind(null,i.renderToDataURL),GF.toString=a.bind(null,function(e,t,i){return n.render(e,i)}),GF}(),lO=lt(uO),dO=e=>e,hO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e;return this.component?U(`\n :host {\n box-sizing: border-box;\n ${Lu(this.component,this.scaleFactor)}\n ${xu(this.component,this.scaleFactor)}\n background-color: ${this.component.fillColor||this.component.borderColor||"transparent"};\n border-width: ${null!==(e=this.component.borderWidth)&&void 0!==e?e:0}px;\n ${Su(this.component.borderColor||"transparent")}\n border-style: solid;\n display: inline-block;\n }`):U(":host { box-sizing: border-box; display: inline-block; }")}},{key:"renderQr",value:function(){var e,t,i,a,r,o,s,u;return ce(function(l){for(;;)switch(l.p=l.n){case 0:if((a=this.renderRoot.querySelector("canvas"))&&null!==(e=this.component)&&void 0!==e&&e.url){l.n=1;break}return l.a(2);case 1:return r=this.computedSize,a.width=r,a.height=r,a.style.width=`${r}px`,a.style.height=`${r}px`,o=null!==(t=Va(this.component.color))&&void 0!==t?t:"#000000",s=null!==(i=Va(this.component.fillColor))&&void 0!==i?i:"#ffffff",l.p=2,l.n=3,q(lO.toCanvas(a,this.component.url,{width:r,color:{dark:o,light:s},margin:0}));case 3:l.n=5;break;case 4:l.p=4,u=l.v,n.error(`QR render failed for URL "${this.component.url}":`,u);case 5:return l.a(2)}},null,this,[[2,4]],Promise)}},{key:"firstUpdated",value:function(){this.renderQr()}},{key:"updated",value:function(e){(e.has("component")||e.has("scaleFactor"))&&Promise.resolve().then(()=>this.renderQr())}},{key:"computedSize",get:function(){var e,t=Number(null!==(e=this.component.borderWidth)&&void 0!==e?e:0),i=Number(this.component.width)*this.scaleFactor,n=Math.floor(this.component.width?i-2*t:360);return Math.max(1,n)}},{key:"render",value:function(){if(this.component){var e=this.computedSize;return B(oO||(oO=dO`<canvas width="${0}" height="${0}" style="width:${0}px;height:${0}px;"></canvas>`),e,e,e,e)}return B(sO||(sO=dO`<canvas></canvas>`))}}])}();gt([qt({type:Object})],hO.prototype,"component",void 0),gt([qt({type:Number})],hO.prototype,"scaleFactor",void 0),hO=gt([Tt("nami-qr-code")],hO);var cO,mO=e=>e,fO=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.isActive=!!this.component.checked,this.contextProvider.setFormState(this.component.formId,this.isActive),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown)}},{key:"_handleClick",value:function(){var e=this.component,t=e.onTap,i=e.disabled,a=e.formId;if(!0!==i){this.component.checked=!this.component.checked,this.isActive=this.component.checked;var r=void 0;r=a?{function:(null==t?void 0:t.function)||"",parameters:re({},null==t?void 0:t.parameters,{formId:a||""})}:t,!this.contextProvider.flow||a?gs({onTap:r,contextProvider:this.contextProvider}):this.component.id?(n.debug(`Trigger NamiFlow action for component ${this.component.id}`),this.contextProvider.flow.triggerActions(this.component.id)):n.warn("Cannot trigger button hoisting without an id")}}},{key:"styles",value:function(){return U(`\n :host {\n box-sizing: border-box;\n }\n :host .toggle-plate {\n display: flex;\n position: relative;\n ${this.applyPlateStyles()}\n }\n :host .toggle-handle {\n display: flex;\n position: relative;\n ${this.applyHandleStyles()}\n }\n `)}},{key:"applyPlateStyles",value:function(){var e=this.component,t=this.scaleFactor,i=this.isActive||e.checked||!1,n=i?e.activePlateFillColor||"transparent":e.inactivePlateFillColor||"transparent",a=i?e.activePlateBorderColor||"transparent":e.inactivePlateBorderColor||"transparent";return`\n transition: all 0.3s;\n ${Lu(e,t)};\n ${Su(a)}\n border-width: ${i?e.activePlateBorderWidth||0:e.inactivePlateBorderWidth||0}px !important;\n border-style: solid;\n border-radius: ${e.borderRadius||0}px !important;\n padding: ${e.innerPadding||0}px !important;\n ${ku(n)}\n `}},{key:"applyHandleStyles",value:function(){var e=this.component,t=e.checked||!1,i=t?e.activeHandleFillColor||"transparent":e.inactiveHandleFillColor||"transparent",n=t?e.activeHandleBorderColor||"transparent":e.inactiveHandleBorderColor||"transparent";return`\n transition: all 0.3s;\n height: 100%;\n width: 50%;\n border-radius: ${e.borderRadius}px !important;\n ${Su(n)}\n border-width: ${t?e.activeHandleBorderWidth||0:e.inactiveHandleBorderWidth||0}px !important;\n ${Ru(e.dropShadow)}\n border-style: solid;\n left: ${t?"50%":0};\n ${ku(i)}\n `}},{key:"render",value:function(){return this.tabIndex=0,this.role="switch",B(cO||(cO=mO`
|
|
557
|
+
`)),$F);gt([qt({type:Object})],UF.prototype,"paywall",void 0),gt([qt({type:Object})],UF.prototype,"campaign",void 0),gt([qt({type:Object})],UF.prototype,"context",void 0),gt([qt({type:Boolean})],UF.prototype,"active",void 0),gt([function({context:e}){return(t,i)=>{var n=new WeakMap;if("object"==typeof i)return{get(){return t.get.call(this)},set(e){return n.get(this).setValue(e),t.set.call(this,e)},init(t){return n.set(this,new Zs(this,{context:e,initialValue:t})),t}};t.constructor.addInitializer(t=>{n.set(t,new Zs(t,{context:e}))});var a,r=Object.getOwnPropertyDescriptor(t,i);if(void 0===r){var o=new WeakMap;a={get(){return o.get(this)},set(e){n.get(this).setValue(e),o.set(this,e)},configurable:!0,enumerable:!0}}else{var s=r.set;a=re({},r,{set(e){n.get(this).setValue(e),null==s||s.call(this,e)}})}Object.defineProperty(t,i,a)}}({context:tu})],UF.prototype,"contextProvider",void 0),UF=gt([Tt("nami-paywall-screen")],UF);var HF,GF,VF={};function KF(){return GF?HF:(GF=1,HF=function(){return"function"==typeof Promise&&Promise.prototype&&Promise.prototype.then})}var XF,YF={},qF={};function JF(){if(XF)return qF;var e;XF=1;var t=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return qF.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return 4*e+17},qF.getSymbolTotalCodewords=function(e){return t[e]},qF.getBCHDigit=function(e){for(var t=0;0!==e;)t++,e>>>=1;return t},qF.setToSJISFunction=function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');e=t},qF.isKanjiModeEnabled=function(){return void 0!==e},qF.toSJIS=function(t){return e(t)},qF}var QF,ZF,eW,tW,iW,nW={};function aW(){return QF||(QF=1,function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2},e.isValid=function(e){return e&&void 0!==e.bit&&e.bit>=0&&e.bit<4},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+t)}}(t)}catch(e){return i}}}(nW)),nW}var rW,oW={};var sW,uW={};var lW,dW={};var hW,cW={};function mW(){if(hW)return cW;hW=1;var e=aW(),t=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];return cW.getBlocksCount=function(i,n){switch(n){case e.L:return t[4*(i-1)+0];case e.M:return t[4*(i-1)+1];case e.Q:return t[4*(i-1)+2];case e.H:return t[4*(i-1)+3];default:return}},cW.getTotalCodewordsCount=function(t,n){switch(n){case e.L:return i[4*(t-1)+0];case e.M:return i[4*(t-1)+1];case e.Q:return i[4*(t-1)+2];case e.H:return i[4*(t-1)+3];default:return}},cW}var fW,vW,pW,gW,yW={},bW={};function wW(){return vW||(vW=1,function(e){var t=function(){if(fW)return bW;fW=1;var e=new Uint8Array(512),t=new Uint8Array(256);return function(){for(var i=1,n=0;n<255;n++)e[n]=i,t[i]=n,256&(i<<=1)&&(i^=285);for(var a=255;a<512;a++)e[a]=e[a-255]}(),bW.log=function(e){if(e<1)throw new Error("log("+e+")");return t[e]},bW.exp=function(t){return e[t]},bW.mul=function(i,n){return 0===i||0===n?0:e[t[i]+t[n]]},bW}();e.mul=function(e,i){for(var n=new Uint8Array(e.length+i.length-1),a=0;a<e.length;a++)for(var r=0;r<i.length;r++)n[a+r]^=t.mul(e[a],i[r]);return n},e.mod=function(e,i){for(var n=new Uint8Array(e);n.length-i.length>=0;){for(var a=n[0],r=0;r<i.length;r++)n[r]^=t.mul(i[r],a);for(var o=0;o<n.length&&0===n[o];)o++;n=n.slice(o)}return n},e.generateECPolynomial=function(i){for(var n=new Uint8Array([1]),a=0;a<i;a++)n=e.mul(n,new Uint8Array([1,t.exp(a)]));return n}}(yW)),yW}var kW,SW={},EW={},MW={};function TW(){return kW||(kW=1,MW.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}),MW}var PW,AW,DW,xW={};function CW(){if(PW)return xW;PW=1;var e="[0-9]+",t="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+",i="(?:(?![A-Z0-9 $%*+\\-./:]|"+(t=t.replace(/u/g,"\\u"))+")(?:.|[\r\n]))+";xW.KANJI=new RegExp(t,"g"),xW.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),xW.BYTE=new RegExp(i,"g"),xW.NUMERIC=new RegExp(e,"g"),xW.ALPHANUMERIC=new RegExp("[A-Z $%*+\\-./:]+","g");var n=new RegExp("^"+t+"$"),a=new RegExp("^"+e+"$"),r=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return xW.testKanji=function(e){return n.test(e)},xW.testNumeric=function(e){return a.test(e)},xW.testAlphanumeric=function(e){return r.test(e)},xW}function IW(){return AW||(AW=1,function(e){var t=TW(),i=CW();e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,i){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!t.isValid(i))throw new Error("Invalid version: "+i);return i>=1&&i<10?e.ccBits[0]:i<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return i.testNumeric(t)?e.NUMERIC:i.testAlphanumeric(t)?e.ALPHANUMERIC:i.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")},e.isValid=function(e){return e&&e.bit&&e.ccBits},e.from=function(t,i){if(e.isValid(t))return t;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+t)}}(t)}catch(e){return i}}}(EW)),EW}function LW(){return DW||(DW=1,function(e){var t=JF(),i=mW(),n=aW(),a=IW(),r=TW(),o=t.getBCHDigit(7973);function s(e,t){return a.getCharCountIndicator(e,t)+4}function u(e,t){var i=0;return e.forEach(function(e){var n=s(e.mode,t);i+=n+e.getBitsLength()}),i}e.from=function(e,t){return r.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,n,o){if(!r.isValid(e))throw new Error("Invalid QR Code version");void 0===o&&(o=a.BYTE);var u=8*(t.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,n));if(o===a.MIXED)return u;var l=u-s(o,e);switch(o){case a.NUMERIC:return Math.floor(l/10*3);case a.ALPHANUMERIC:return Math.floor(l/11*2);case a.KANJI:return Math.floor(l/13);case a.BYTE:default:return Math.floor(l/8)}},e.getBestVersionForData=function(t,i){var r,o=n.from(i,n.M);if(Array.isArray(t)){if(t.length>1)return function(t,i){for(var n=1;n<=40;n++)if(u(t,n)<=e.getCapacity(n,i,a.MIXED))return n}(t,o);if(0===t.length)return 1;r=t[0]}else r=t;return function(t,i,n){for(var a=1;a<=40;a++)if(i<=e.getCapacity(a,n,t))return a}(r.mode,r.getLength(),o)},e.getEncodedBits=function(e){if(!r.isValid(e)||e<7)throw new Error("Invalid QR Code version");for(var i=e<<12;t.getBCHDigit(i)-o>=0;)i^=7973<<t.getBCHDigit(i)-o;return e<<12|i}}(SW)),SW}var _W,RW={};var FW,WW,OW,$W,NW,jW,BW,zW,UW={};var HW,GW,VW,KW={exports:{}};function XW(){return HW||(HW=1,function(e){var t={single_source_shortest_paths:function(e,i,n){var a={},r={};r[i]=0;var o,s,u,l,d,h,c,m=t.PriorityQueue.make();for(m.push(i,0);!m.empty();)for(u in s=(o=m.pop()).value,l=o.cost,d=e[s]||{})d.hasOwnProperty(u)&&(h=l+d[u],c=r[u],(void 0===r[u]||c>h)&&(r[u]=h,m.push(u,h),a[u]=s));if(void 0!==n&&void 0===r[n]){var f=["Could not find a path from ",i," to ",n,"."].join("");throw new Error(f)}return a},extract_shortest_path_from_predecessor_list:function(e,t){for(var i=[],n=t;n;)i.push(n),e[n],n=e[n];return i.reverse(),i},find_path:function(e,i,n){var a=t.single_source_shortest_paths(e,i,n);return t.extract_shortest_path_from_predecessor_list(a,n)},PriorityQueue:{make:function(e){var i,n=t.PriorityQueue,a={};for(i in e=e||{},n)n.hasOwnProperty(i)&&(a[i]=n[i]);return a.queue=[],a.sorter=e.sorter||n.default_sorter,a},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var i={value:e,cost:t};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return 0===this.queue.length}}};e.exports=t}(KW)),KW.exports}function YW(){return GW||(GW=1,function(e){var t=IW(),i=function(){if(WW)return FW;WW=1;var e=IW();function t(t){this.mode=e.NUMERIC,this.data=t.toString()}return t.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){var t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);var a=this.data.length-t;a>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,3*a+1))},FW=t}(),n=function(){if($W)return OW;$W=1;var e=IW(),t=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function i(t){this.mode=e.ALPHANUMERIC,this.data=t}return i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i+2<=this.data.length;i+=2){var n=45*t.indexOf(this.data[i]);n+=t.indexOf(this.data[i+1]),e.put(n,11)}this.data.length%2&&e.put(t.indexOf(this.data[i]),6)},OW=i}(),a=function(){if(jW)return NW;jW=1;var e=IW();function t(t){this.mode=e.BYTE,this.data="string"==typeof t?(new TextEncoder).encode(t):new Uint8Array(t)}return t.getBitsLength=function(e){return 8*e},t.prototype.getLength=function(){return this.data.length},t.prototype.getBitsLength=function(){return t.getBitsLength(this.data.length)},t.prototype.write=function(e){for(var t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)},NW=t}(),r=function(){if(zW)return BW;zW=1;var e=IW(),t=JF();function i(t){this.mode=e.KANJI,this.data=t}return i.getBitsLength=function(e){return 13*e},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){var i;for(i=0;i<this.data.length;i++){var n=t.toSJIS(this.data[i]);if(n>=33088&&n<=40956)n-=33088;else{if(!(n>=57408&&n<=60351))throw new Error("Invalid SJIS character: "+this.data[i]+"\nMake sure your charset is UTF-8");n-=49472}n=192*(n>>>8&255)+(255&n),e.put(n,13)}},BW=i}(),o=CW(),s=JF(),u=XW();function l(e){return unescape(encodeURIComponent(e)).length}function d(e,t,i){for(var n,a=[];null!==(n=e.exec(i));)a.push({data:n[0],index:n.index,mode:t,length:n[0].length});return a}function h(e){var i,n,a=d(o.NUMERIC,t.NUMERIC,e),r=d(o.ALPHANUMERIC,t.ALPHANUMERIC,e);return s.isKanjiModeEnabled()?(i=d(o.BYTE,t.BYTE,e),n=d(o.KANJI,t.KANJI,e)):(i=d(o.BYTE_KANJI,t.BYTE,e),n=[]),a.concat(r,i,n).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function c(e,o){switch(o){case t.NUMERIC:return i.getBitsLength(e);case t.ALPHANUMERIC:return n.getBitsLength(e);case t.KANJI:return r.getBitsLength(e);case t.BYTE:return a.getBitsLength(e)}}function m(e,o){var u,l=t.getBestModeForData(e);if((u=t.from(o,l))!==t.BYTE&&u.bit<l.bit)throw new Error('"'+e+'" cannot be encoded with mode '+t.toString(u)+".\n Suggested mode is: "+t.toString(l));switch(u!==t.KANJI||s.isKanjiModeEnabled()||(u=t.BYTE),u){case t.NUMERIC:return new i(e);case t.ALPHANUMERIC:return new n(e);case t.KANJI:return new r(e);case t.BYTE:return new a(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return"string"==typeof t?e.push(m(t,null)):t.data&&e.push(m(t.data,t.mode)),e},[])},e.fromString=function(i,n){for(var a=function(e){for(var i=[],n=0;n<e.length;n++){var a=e[n];switch(a.mode){case t.NUMERIC:i.push([a,{data:a.data,mode:t.ALPHANUMERIC,length:a.length},{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.ALPHANUMERIC:i.push([a,{data:a.data,mode:t.BYTE,length:a.length}]);break;case t.KANJI:i.push([a,{data:a.data,mode:t.BYTE,length:l(a.data)}]);break;case t.BYTE:i.push([{data:a.data,mode:t.BYTE,length:l(a.data)}])}}return i}(h(i,s.isKanjiModeEnabled())),r=function(e,i){for(var n={},a={start:{}},r=["start"],o=0;o<e.length;o++){for(var s=e[o],u=[],l=0;l<s.length;l++){var d=s[l],h=""+o+l;u.push(h),n[h]={node:d,lastCount:0},a[h]={};for(var m=0;m<r.length;m++){var f=r[m];n[f]&&n[f].node.mode===d.mode?(a[f][h]=c(n[f].lastCount+d.length,d.mode)-c(n[f].lastCount,d.mode),n[f].lastCount+=d.length):(n[f]&&(n[f].lastCount=d.length),a[f][h]=c(d.length,d.mode)+4+t.getCharCountIndicator(d.mode,i))}}r=u}for(var v=0;v<r.length;v++)a[r[v]].end=0;return{map:a,table:n}}(a,n),o=u.find_path(r.map,"start","end"),d=[],m=1;m<o.length-1;m++)d.push(r.table[o[m]].node);return e.fromArray(function(e){return e.reduce(function(e,t){var i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}(d))},e.rawSplit=function(t){return e.fromArray(h(t,s.isKanjiModeEnabled()))}}(UW)),UW}function qW(){if(VW)return YF;VW=1;var e=JF(),t=aW(),i=function(){if(eW)return ZF;function e(){this.buffer=[],this.length=0}return eW=1,e.prototype={get:function(e){var t=Math.floor(e/8);return 1==(this.buffer[t]>>>7-e%8&1)},put:function(e,t){for(var i=0;i<t;i++)this.putBit(1==(e>>>t-i-1&1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},ZF=e}(),n=function(){if(iW)return tW;function e(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}return iW=1,e.prototype.set=function(e,t,i,n){var a=e*this.size+t;this.data[a]=i,n&&(this.reservedBit[a]=!0)},e.prototype.get=function(e,t){return this.data[e*this.size+t]},e.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i},e.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},tW=e}(),a=(rW||(rW=1,function(e){var t=JF().getSymbolSize;e.getRowColCoords=function(e){if(1===e)return[];for(var i=Math.floor(e/7)+2,n=t(e),a=145===n?26:2*Math.ceil((n-13)/(2*i-2)),r=[n-7],o=1;o<i-1;o++)r[o]=r[o-1]-a;return r.push(6),r.reverse()},e.getPositions=function(t){for(var i=[],n=e.getRowColCoords(t),a=n.length,r=0;r<a;r++)for(var o=0;o<a;o++)0===r&&0===o||0===r&&o===a-1||r===a-1&&0===o||i.push([n[r],n[o]]);return i}}(oW)),oW),r=function(){if(sW)return uW;sW=1;var e=JF().getSymbolSize;return uW.getPositions=function(t){var i=e(t);return[[0,0],[i-7,0],[0,i-7]]},uW}(),o=(lW||(lW=1,function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t=3,i=3,n=40,a=10;function r(t,i,n){switch(t){case e.Patterns.PATTERN000:return(i+n)%2==0;case e.Patterns.PATTERN001:return i%2==0;case e.Patterns.PATTERN010:return n%3==0;case e.Patterns.PATTERN011:return(i+n)%3==0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(n/3))%2==0;case e.Patterns.PATTERN101:return i*n%2+i*n%3==0;case e.Patterns.PATTERN110:return(i*n%2+i*n%3)%2==0;case e.Patterns.PATTERN111:return(i*n%3+(i+n)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}}e.isValid=function(e){return null!=e&&""!==e&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){for(var i=e.size,n=0,a=0,r=0,o=null,s=null,u=0;u<i;u++){a=r=0,o=s=null;for(var l=0;l<i;l++){var d=e.get(u,l);d===o?a++:(a>=5&&(n+=t+(a-5)),o=d,a=1),(d=e.get(l,u))===s?r++:(r>=5&&(n+=t+(r-5)),s=d,r=1)}a>=5&&(n+=t+(a-5)),r>=5&&(n+=t+(r-5))}return n},e.getPenaltyN2=function(e){for(var t=e.size,n=0,a=0;a<t-1;a++)for(var r=0;r<t-1;r++){var o=e.get(a,r)+e.get(a,r+1)+e.get(a+1,r)+e.get(a+1,r+1);4!==o&&0!==o||n++}return n*i},e.getPenaltyN3=function(e){for(var t=e.size,i=0,a=0,r=0,o=0;o<t;o++){a=r=0;for(var s=0;s<t;s++)a=a<<1&2047|e.get(o,s),s>=10&&(1488===a||93===a)&&i++,r=r<<1&2047|e.get(s,o),s>=10&&(1488===r||93===r)&&i++}return i*n},e.getPenaltyN4=function(e){for(var t=0,i=e.data.length,n=0;n<i;n++)t+=e.data[n];return Math.abs(Math.ceil(100*t/i/5)-10)*a},e.applyMask=function(e,t){for(var i=t.size,n=0;n<i;n++)for(var a=0;a<i;a++)t.isReserved(a,n)||t.xor(a,n,r(e,a,n))},e.getBestMask=function(t,i){for(var n=Object.keys(e.Patterns).length,a=0,r=1/0,o=0;o<n;o++){i(o),e.applyMask(o,t);var s=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),s<r&&(r=s,a=o)}return a}}(dW)),dW),s=mW(),u=function(){if(gW)return pW;gW=1;var e=wW();function t(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}return t.prototype.initialize=function(t){this.degree=t,this.genPoly=e.generateECPolynomial(this.degree)},t.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var i=new Uint8Array(t.length+this.degree);i.set(t);var n=e.mod(i,this.genPoly),a=this.degree-n.length;if(a>0){var r=new Uint8Array(this.degree);return r.set(n,a),r}return n},pW=t}(),l=LW(),d=function(){if(_W)return RW;_W=1;var e=JF(),t=e.getBCHDigit(1335);return RW.getEncodedBits=function(i,n){for(var a=i.bit<<3|n,r=a<<10;e.getBCHDigit(r)-t>=0;)r^=1335<<e.getBCHDigit(r)-t;return 21522^(a<<10|r)},RW}(),h=IW(),c=YW();function m(e,t,i){var n,a,r=e.size,o=d.getEncodedBits(t,i);for(n=0;n<15;n++)a=1==(o>>n&1),n<6?e.set(n,8,a,!0):n<8?e.set(n+1,8,a,!0):e.set(r-15+n,8,a,!0),n<8?e.set(8,r-n-1,a,!0):n<9?e.set(8,15-n-1+1,a,!0):e.set(8,15-n-1,a,!0);e.set(r-8,8,1,!0)}function f(t,n,a){var r=new i;a.forEach(function(e){r.put(e.mode.bit,4),r.put(e.getLength(),h.getCharCountIndicator(e.mode,t)),e.write(r)});var o=8*(e.getSymbolTotalCodewords(t)-s.getTotalCodewordsCount(t,n));for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(0);for(var l=(o-r.getLengthInBits())/8,d=0;d<l;d++)r.put(d%2?17:236,8);return function(t,i,n){for(var a=e.getSymbolTotalCodewords(i),r=s.getTotalCodewordsCount(i,n),o=a-r,l=s.getBlocksCount(i,n),d=l-a%l,h=Math.floor(a/l),c=Math.floor(o/l),m=c+1,f=h-c,v=new u(f),p=0,g=new Array(l),y=new Array(l),b=0,w=new Uint8Array(t.buffer),k=0;k<l;k++){var S=k<d?c:m;g[k]=w.slice(p,p+S),y[k]=v.encode(g[k]),p+=S,b=Math.max(b,S)}var E,M,T=new Uint8Array(a),P=0;for(E=0;E<b;E++)for(M=0;M<l;M++)E<g[M].length&&(T[P++]=g[M][E]);for(E=0;E<f;E++)for(M=0;M<l;M++)T[P++]=y[M][E];return T}(r,t,n)}function v(t,i,s,u){var d;if(Array.isArray(t))d=c.fromArray(t);else{if("string"!=typeof t)throw new Error("Invalid data");var h=i;if(!h){var v=c.rawSplit(t);h=l.getBestVersionForData(v,s)}d=c.fromString(t,h||40)}var p=l.getBestVersionForData(d,s);if(!p)throw new Error("The amount of data is too big to be stored in a QR Code");if(i){if(i<p)throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: "+p+".\n")}else i=p;var g=f(i,s,d),y=e.getSymbolSize(i),b=new n(y);return function(e,t){for(var i=e.size,n=r.getPositions(t),a=0;a<n.length;a++)for(var o=n[a][0],s=n[a][1],u=-1;u<=7;u++)if(!(o+u<=-1||i<=o+u))for(var l=-1;l<=7;l++)s+l<=-1||i<=s+l||(u>=0&&u<=6&&(0===l||6===l)||l>=0&&l<=6&&(0===u||6===u)||u>=2&&u<=4&&l>=2&&l<=4?e.set(o+u,s+l,!0,!0):e.set(o+u,s+l,!1,!0))}(b,i),function(e){for(var t=e.size,i=8;i<t-8;i++){var n=i%2==0;e.set(i,6,n,!0),e.set(6,i,n,!0)}}(b),function(e,t){for(var i=a.getPositions(t),n=0;n<i.length;n++)for(var r=i[n][0],o=i[n][1],s=-2;s<=2;s++)for(var u=-2;u<=2;u++)-2===s||2===s||-2===u||2===u||0===s&&0===u?e.set(r+s,o+u,!0,!0):e.set(r+s,o+u,!1,!0)}(b,i),m(b,s,0),i>=7&&function(e,t){for(var i,n,a,r=e.size,o=l.getEncodedBits(t),s=0;s<18;s++)i=Math.floor(s/3),n=s%3+r-8-3,a=1==(o>>s&1),e.set(i,n,a,!0),e.set(n,i,a,!0)}(b,i),function(e,t){for(var i=e.size,n=-1,a=i-1,r=7,o=0,s=i-1;s>0;s-=2)for(6===s&&s--;;){for(var u=0;u<2;u++)if(!e.isReserved(a,s-u)){var l=!1;o<t.length&&(l=1==(t[o]>>>r&1)),e.set(a,s-u,l),-1===--r&&(o++,r=7)}if((a+=n)<0||i<=a){a-=n,n=-n;break}}}(b,g),isNaN(u)&&(u=o.getBestMask(b,m.bind(null,b,s))),o.applyMask(u,b),m(b,s,u),{modules:b,version:i,errorCorrectionLevel:s,maskPattern:u,segments:d}}return YF.create=function(i,n){if(void 0===i||""===i)throw new Error("No input text");var a,r,s=t.M;return void 0!==n&&(s=t.from(n.errorCorrectionLevel,t.M),a=l.from(n.version),r=o.from(n.maskPattern),n.toSJISFunc&&e.setToSJISFunction(n.toSJISFunc)),v(i,a,s,r)},YF}var JW,QW,ZW={},eO={};function tO(){return JW||(JW=1,function(e){function t(e){if("number"==typeof e&&(e=e.toString()),"string"!=typeof e)throw new Error("Color should be defined as hex string");var t=e.slice().replace("#","").split("");if(t.length<3||5===t.length||t.length>8)throw new Error("Invalid hex color: "+e);3!==t.length&&4!==t.length||(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),6===t.length&&t.push("F","F");var i=parseInt(t.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:255&i,hex:"#"+t.slice(0,6).join("")}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});var i=void 0===e.margin||null===e.margin||e.margin<0?4:e.margin,n=e.width&&e.width>=21?e.width:void 0,a=e.scale||4;return{width:n,scale:n?4:a,margin:i,color:{dark:t(e.color.dark||"#000000ff"),light:t(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+2*t.margin?t.width/(e+2*t.margin):t.scale},e.getImageWidth=function(t,i){var n=e.getScale(t,i);return Math.floor((t+2*i.margin)*n)},e.qrToImageData=function(t,i,n){for(var a=i.modules.size,r=i.modules.data,o=e.getScale(a,n),s=Math.floor((a+2*n.margin)*o),u=n.margin*o,l=[n.color.light,n.color.dark],d=0;d<s;d++)for(var h=0;h<s;h++){var c=4*(d*s+h),m=n.color.light;if(d>=u&&h>=u&&d<s-u&&h<s-u)m=l[r[Math.floor((d-u)/o)*a+Math.floor((h-u)/o)]?1:0];t[c++]=m.r,t[c++]=m.g,t[c++]=m.b,t[c]=m.a}}}(eO)),eO}function iO(){return QW||(QW=1,function(e){var t=tO();e.render=function(e,i,n){var a=n,r=i;void 0!==a||i&&i.getContext||(a=i,i=void 0),i||(r=function(){try{return document.createElement("canvas")}catch(e){throw new Error("You need to specify a canvas element")}}()),a=t.getOptions(a);var o=t.getImageWidth(e.modules.size,a),s=r.getContext("2d"),u=s.createImageData(o,o);return t.qrToImageData(u.data,e,a),function(e,t,i){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=i,t.width=i,t.style.height=i+"px",t.style.width=i+"px"}(s,r,o),s.putImageData(u,0,0),r},e.renderToDataURL=function(t,i,n){var a=n;void 0!==a||i&&i.getContext||(a=i,i=void 0),a||(a={});var r=e.render(t,i,a),o=a.type||"image/png",s=a.rendererOpts||{};return r.toDataURL(o,s.quality)}}(ZW)),ZW}var nO,aO,rO={};function oO(){if(nO)return rO;nO=1;var e=tO();function t(e,t){var i=e.a/255,n=t+'="'+e.hex+'"';return i<1?n+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':n}function i(e,t,i){var n=e+t;return void 0!==i&&(n+=" "+i),n}return rO.render=function(n,a,r){var o=e.getOptions(a),s=n.modules.size,u=n.modules.data,l=s+2*o.margin,d=o.color.light.a?"<path "+t(o.color.light,"fill")+' d="M0 0h'+l+"v"+l+'H0z"/>':"",h="<path "+t(o.color.dark,"stroke")+' d="'+function(e,t,n){for(var a="",r=0,o=!1,s=0,u=0;u<e.length;u++){var l=Math.floor(u%t),d=Math.floor(u/t);l||o||(o=!0),e[u]?(s++,u>0&&l>0&&e[u-1]||(a+=o?i("M",l+n,.5+d+n):i("m",r,0),r=0,o=!1),l+1<t&&e[u+1]||(a+=i("h",s),s=0)):r++}return a}(u,s,o.margin)+'"/>',c='viewBox="0 0 '+l+" "+l+'"',m='<svg xmlns="http://www.w3.org/2000/svg" '+(o.width?'width="'+o.width+'" height="'+o.width+'" ':"")+c+' shape-rendering="crispEdges">'+d+h+"</svg>\n";return"function"==typeof r&&r(null,m),m},rO}var sO,uO,lO=function(){if(aO)return VF;aO=1;var e=KF(),t=qW(),i=iO(),n=oO();function a(i,n,a,r,o){var s=[].slice.call(arguments,1),u=s.length,l="function"==typeof s[u-1];if(!l&&!e())throw new Error("Callback required as last argument");if(!l){if(u<1)throw new Error("Too few arguments provided");return 1===u?(a=n,n=r=void 0):2!==u||n.getContext||(r=a,a=n,n=void 0),new Promise(function(e,o){try{var s=t.create(a,r);e(i(s,n,r))}catch(e){o(e)}})}if(u<2)throw new Error("Too few arguments provided");2===u?(o=a,a=n,n=r=void 0):3===u&&(n.getContext&&void 0===o?(o=r,r=void 0):(o=r,r=a,a=n,n=void 0));try{var d=t.create(a,r);o(null,i(d,n,r))}catch(e){o(e)}}return VF.create=t.create,VF.toCanvas=a.bind(null,i.render),VF.toDataURL=a.bind(null,i.renderToDataURL),VF.toString=a.bind(null,function(e,t,i){return n.render(e,i)}),VF}(),dO=lt(lO),hO=e=>e,cO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).scaleFactor=1,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e;return this.component?U(`\n :host {\n box-sizing: border-box;\n ${Lu(this.component,this.scaleFactor)}\n ${xu(this.component,this.scaleFactor)}\n background-color: ${this.component.fillColor||this.component.borderColor||"transparent"};\n border-width: ${null!==(e=this.component.borderWidth)&&void 0!==e?e:0}px;\n ${Su(this.component.borderColor||"transparent")}\n border-style: solid;\n display: inline-block;\n }`):U(":host { box-sizing: border-box; display: inline-block; }")}},{key:"renderQr",value:function(){var e,t,i,a,r,o,s,u;return ce(function(l){for(;;)switch(l.p=l.n){case 0:if((a=this.renderRoot.querySelector("canvas"))&&null!==(e=this.component)&&void 0!==e&&e.url){l.n=1;break}return l.a(2);case 1:return r=this.computedSize,a.width=r,a.height=r,a.style.width=`${r}px`,a.style.height=`${r}px`,o=null!==(t=Va(this.component.color))&&void 0!==t?t:"#000000",s=null!==(i=Va(this.component.fillColor))&&void 0!==i?i:"#ffffff",l.p=2,l.n=3,q(dO.toCanvas(a,this.component.url,{width:r,color:{dark:o,light:s},margin:0}));case 3:l.n=5;break;case 4:l.p=4,u=l.v,n.error(`QR render failed for URL "${this.component.url}":`,u);case 5:return l.a(2)}},null,this,[[2,4]],Promise)}},{key:"firstUpdated",value:function(){this.renderQr()}},{key:"updated",value:function(e){(e.has("component")||e.has("scaleFactor"))&&Promise.resolve().then(()=>this.renderQr())}},{key:"computedSize",get:function(){var e,t=Number(null!==(e=this.component.borderWidth)&&void 0!==e?e:0),i=Number(this.component.width)*this.scaleFactor,n=Math.floor(this.component.width?i-2*t:360);return Math.max(1,n)}},{key:"render",value:function(){if(this.component){var e=this.computedSize;return B(sO||(sO=hO`<canvas width="${0}" height="${0}" style="width:${0}px;height:${0}px;"></canvas>`),e,e,e,e)}return B(uO||(uO=hO`<canvas></canvas>`))}}])}();gt([qt({type:Object})],cO.prototype,"component",void 0),gt([qt({type:Number})],cO.prototype,"scaleFactor",void 0),cO=gt([Tt("nami-qr-code")],cO);var mO,fO=e=>e,vO=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.isActive=!!this.component.checked,this.contextProvider.setFormState(this.component.formId,this.isActive),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown)}},{key:"_handleClick",value:function(){var e=this.component,t=e.onTap,i=e.disabled,a=e.formId;if(!0!==i){this.component.checked=!this.component.checked,this.isActive=this.component.checked;var r=void 0;r=a?{function:(null==t?void 0:t.function)||"",parameters:re({},null==t?void 0:t.parameters,{formId:a||""})}:t,!this.contextProvider.flow||a?gs({onTap:r,contextProvider:this.contextProvider}):this.component.id?(n.debug(`Trigger NamiFlow action for component ${this.component.id}`),this.contextProvider.flow.triggerActions(this.component.id)):n.warn("Cannot trigger button hoisting without an id")}}},{key:"styles",value:function(){return U(`\n :host {\n box-sizing: border-box;\n }\n :host .toggle-plate {\n display: flex;\n position: relative;\n ${this.applyPlateStyles()}\n }\n :host .toggle-handle {\n display: flex;\n position: relative;\n ${this.applyHandleStyles()}\n }\n `)}},{key:"applyPlateStyles",value:function(){var e=this.component,t=this.scaleFactor,i=this.isActive||e.checked||!1,n=i?e.activePlateFillColor||"transparent":e.inactivePlateFillColor||"transparent",a=i?e.activePlateBorderColor||"transparent":e.inactivePlateBorderColor||"transparent";return`\n transition: all 0.3s;\n ${Lu(e,t)};\n ${Su(a)}\n border-width: ${i?e.activePlateBorderWidth||0:e.inactivePlateBorderWidth||0}px !important;\n border-style: solid;\n border-radius: ${e.borderRadius||0}px !important;\n padding: ${e.innerPadding||0}px !important;\n ${ku(n)}\n `}},{key:"applyHandleStyles",value:function(){var e=this.component,t=e.checked||!1,i=t?e.activeHandleFillColor||"transparent":e.inactiveHandleFillColor||"transparent",n=t?e.activeHandleBorderColor||"transparent":e.inactiveHandleBorderColor||"transparent";return`\n transition: all 0.3s;\n height: 100%;\n width: 50%;\n border-radius: ${e.borderRadius}px !important;\n ${Su(n)}\n border-width: ${t?e.activeHandleBorderWidth||0:e.inactiveHandleBorderWidth||0}px !important;\n ${Ru(e.dropShadow)}\n border-style: solid;\n left: ${t?"50%":0};\n ${ku(i)}\n `}},{key:"render",value:function(){return this.tabIndex=0,this.role="switch",B(mO||(mO=fO`
|
|
558
558
|
<div class="toggle-plate">
|
|
559
559
|
<div class="toggle-handle"></div>
|
|
560
560
|
</div>
|
|
561
|
-
`))}}])}();gt([qt({type:Object})],
|
|
561
|
+
`))}}])}();gt([qt({type:Object})],vO.prototype,"component",void 0),gt([qt({type:Boolean})],vO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],vO.prototype,"scaleFactor",void 0),gt([qt({type:Boolean})],vO.prototype,"isActive",void 0),vO=gt([Tt("nami-toggle-switch")],vO);var pO,gO=e=>e,yO=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t.tabIndex=0,t}return ue(e,lu),ne(e,[{key:"styles",value:function(){var e=this.component;return U(`\n :host {\n box-sizing: border-box;\n }\n :host .radio-button-wrapper {\n display: flex;\n transition: all 0.3s;\n ${Lu(e,this.scaleFactor)}\n ${Su(e.inactiveBorderColor||"transparent")}\n border-width: ${e.inactiveBorderWidth||0}px !important;\n border-style: solid;\n border-radius: 100%;\n padding: ${e.innerPadding||0}px !important;\n }\n :host .radio-button-wrapper.active {\n ${Su(e.activeBorderColor||"transparent")}\n border-width: ${e.activeBorderWidth||0}px !important;\n ${Ru(e.dropShadow)}\n }\n :host .radio-button-inner {\n ${ku(e.inactiveFillColor||"transparent")}\n width: 100%;\n height: 100%;\n border-radius: 100%;\n }\n :host .radio-button-wrapper.active .radio-button-inner {\n ${ku(e.activeFillColor||"transparent")}\n }\n `)}},{key:"isActive",get:function(){var e,t,i=null!==(e=null===(t=this.component.sku)||void 0===t?void 0:t.id)&&void 0!==e?e:"";return Object.values(this.contextProvider.selectedProducts()).includes(i)}},{key:"render",value:function(){var e=this.isActive?"active":"";return B(pO||(pO=gO`
|
|
562
562
|
<div class="radio-button-wrapper ${0}">
|
|
563
563
|
<div class="radio-button-inner"></div>
|
|
564
564
|
</div>
|
|
565
|
-
`),e)}}])}();gt([qt({type:Object})],
|
|
565
|
+
`),e)}}])}();gt([qt({type:Object})],yO.prototype,"component",void 0),gt([qt({type:Boolean})],yO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],yO.prototype,"scaleFactor",void 0),yO=gt([Tt("nami-radio-button")],yO);var bO,wO=e=>e,kO=S.NamiFlowManager,SO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).scaleFactor=1,t.inFocusedState=!1,t.currentWidth=0,t.hasInitialized=!1,t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),$(this.minSDKVersion,"ProgressIndicator")}},{key:"firstUpdated",value:function(t){var i;pe(e,"firstUpdated",this)([t]),this.currentWidth=100*kO.getLastAnimatedFlowProgress((null===(i=this.component)||void 0===i?void 0:i.id)||"default"),this.hasInitialized=!0,this.animateProgress(!0)}},{key:"updated",value:function(t){pe(e,"updated",this)([t]),this.hasInitialized&&this.animateProgress(!1)}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.inFocusedState,n=e.inactiveFillColor,a=e.inactiveFillColorFallback,r=e.inactiveBorderRadius,o=e.activeFillColor,s=e.activeFillColorFallback,u=e.activeBorderRadius,l=e.innerPadding,d=void 0===l?0:l,h=e.activeDropShadow,c=e.inactiveDropShadow;return U(`\n :host {\n display: ${e.hidden?"none":"block"};\n ${Ou(e,t,i)}\n }\n \n .progress-container {\n ${Lu(e,t)} \n background: ${n||a};\n border-radius: ${r||0}px;\n overflow: hidden;\n position: relative;\n padding: ${d*t}px;\n box-sizing: border-box;\n ${Ru(c)}\n }\n \n .progress-bar {\n height: 100%;\n background: ${o||s};\n border-radius: ${u||0}px;\n box-sizing: border-box;\n transition: width 0.8s ease-in-out;\n ${Ru(h)}\n }\n `)}},{key:"getProgressPercentage",value:function(){var e,t=null!==(e=this.component.percentage)&&void 0!==e?e:0;return"auto"===t&&(t=kO.getCurrentFlowProgress(this.component.id)),Math.min(100,Math.max(0,100*Number(t)))}},{key:"animateProgress",value:function(e){var t=this.component,i=t.id,n=t.percentage,a=this.getProgressPercentage();if(this.currentWidth!==a){var r=()=>{this.currentWidth=a,"auto"===n&&kO.setLastAnimatedFlowProgress(i||"default",a/100)};e?requestAnimationFrame(()=>requestAnimationFrame(r)):requestAnimationFrame(r)}}},{key:"render",value:function(){return B(bO||(bO=wO`
|
|
566
566
|
<div class="progress-container">
|
|
567
567
|
<div
|
|
568
568
|
class="progress-bar"
|
|
@@ -573,20 +573,20 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
573
573
|
aria-valuemax="100"
|
|
574
574
|
></div>
|
|
575
575
|
</div>
|
|
576
|
-
`),this.currentWidth,Math.round(this.currentWidth))}}])}();gt([qt({type:Object})],kO.prototype,"component",void 0),gt([qt({type:Number})],kO.prototype,"scaleFactor",void 0),gt([qt({type:Boolean})],kO.prototype,"inFocusedState",void 0),gt([qt({type:Object})],kO.prototype,"minSDKVersion",void 0),gt([qt({type:Number})],kO.prototype,"currentWidth",void 0),kO=gt([Tt("nami-progress-indicator")],kO);var SO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_handleClick",value:function(){var e,t,i=null===(e=this.component.onTap)||void 0===e?void 0:e.function;if(i){var n={function:i,parameters:re({},null===(t=this.component.onTap)||void 0===t?void 0:t.parameters,{formId:this.component.formId||"",value:"radio"===this.component.mode?this.component.value:void 0})};gs({onTap:n,contextProvider:this.contextProvider})}}},{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.contextProvider.getCurrentFormId(e.formId||""),i=!0===t||t===e.value;this.inFocusedState=i;var n=i?e.activeFillColor||e.activeFillColorFallback||"transparent":e.inactiveFillColor||e.inactiveFillColorFallback||"transparent",a=i?e.activeBorderColor||"transparent":e.inactiveBorderColor||"transparent";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius}px !important;\n ${Ou(e,this.scaleFactor,this.inFocusedState)}\n ${Su(a)}\n border-width: ${i?e.activeBorderWidth||0:e.inactiveBorderWidth||0}px !important;\n ${Ru(i?e.activeDropShadow:e.inactiveDropShadow)};\n border-style: solid;\n ${ku(n)}\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.component.components.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],SO.prototype,"component",void 0),gt([qt({type:Boolean})],SO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],SO.prototype,"scaleFactor",void 0),gt([qt({type:Object})],SO.prototype,"minSDKVersion",void 0),gt([qt({type:Boolean})],SO.prototype,"isActive",void 0),SO=gt([Tt("nami-toggle-button")],SO);var EO,MO,TO,PO,AO,DO,xO,CO,IO,LO,_O=e=>e,RO=(EO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.timer=null,t.startTime=0,t.initialDuration=0,t.hasEmittedCompletion=!1,t}return ue(e,lu),ne(e,[{key:"firstUpdated",value:function(){this.loadTimerState(),this.startTimer()}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.saveTimerState(),this.clearTimer()}},{key:"getTimerId",value:function(){var e,t;return null!==(e=null===(t=this.component)||void 0===t?void 0:t.id)&&void 0!==e?e:""}},{key:"loadTimerState",value:function(){var e;null!==(e=this.contextProvider)&&void 0!==e&&e.flow&&(this.timerState=this.contextProvider.flow.timerStates[this.getTimerId()])}},{key:"saveTimerState",value:function(){var e;if(null!==(e=this.contextProvider)&&void 0!==e&&e.flow){var t=this.component,i=t.mode,n=t.durationSeconds;if("duration"===i&&void 0!==n){var a=this.calculateCurrentRemainingSeconds();this.contextProvider.flow.timerStates[this.getTimerId()]={remainingSeconds:a,savedAt:Date.now(),hasEmittedCompletion:this.hasEmittedCompletion}}}}},{key:"getSavedTimerState",value:function(){var e;return null===(e=this.contextProvider)||void 0===e||null===(e=e.flow)||void 0===e?void 0:e.timerStates[this.getTimerId()]}},{key:"startTimer",value:function(){this.initializeTimerState(),this.clearTimer(),this.timer=setInterval(()=>this.onTimerTick(),LO.TIMER_INTERVAL_MS)}},{key:"initializeTimerState",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.resetOnRemount;"duration"===t&&void 0!==i&&(this.timerState&&!n?this.restoreTimerFromState(this.timerState,i):this.resetTimerState(i))}},{key:"restoreTimerFromState",value:function(e,t){var i=(Date.now()-e.savedAt)/1e3,n=Math.max(0,e.remainingSeconds-i);this.initialDuration=t,this.startTime=Date.now()-1e3*(this.initialDuration-n),this.hasEmittedCompletion=e.hasEmittedCompletion}},{key:"resetTimerState",value:function(e){this.initialDuration=e,this.startTime=Date.now(),this.hasEmittedCompletion=!1}},{key:"onTimerTick",value:function(){var e=this.calculateTimeValues().isCompleted;this.requestUpdate(),e&&this.clearTimer()}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"calculateTimeValues",value:function(){var e=this.calculateTotalRemainingSeconds(),t=e<=0,i=this.component.units||LO.DEFAULT_UNITS,n=i.days,a=i.hours,r=i.minutes,o=i.seconds;return re({},this.convertSecondsToTimeUnits(e,{days:n,hours:a,minutes:r,seconds:o}),{isCompleted:t})}},{key:"calculateTotalRemainingSeconds",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.targetDateTime;return"duration"===t?this.calculateDurationRemainingSeconds(i):"targetDateTime"===t&&n?this.calculateTargetDateTimeRemainingSeconds(n):0}},{key:"calculateDurationRemainingSeconds",value:function(e){var t=this.getSavedTimerState();if(t){var i=(Date.now()-t.savedAt)/1e3;return Math.max(0,t.remainingSeconds-i)}if(this.initialDuration>0&&this.startTime>0){var n=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-n)}return void 0!==e?Math.max(0,e):0}},{key:"calculateTargetDateTimeRemainingSeconds",value:function(e){var t=new Date(e).getTime(),i=Date.now();return Math.max(0,(t-i)/1e3)}},{key:"calculateCurrentRemainingSeconds",value:function(){var e=this.component.durationSeconds;if(this.initialDuration>0&&this.startTime>0){var t=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-t)}return null!=e?e:0}},{key:"convertSecondsToTimeUnits",value:function(e,t){var i=t.days?Math.floor(e/LO.SECONDS_PER_DAY):0,n=e-i*LO.SECONDS_PER_DAY,a=t.hours?Math.floor(n/LO.SECONDS_PER_HOUR):0,r=n-a*LO.SECONDS_PER_HOUR,o=t.minutes?Math.floor(r/LO.SECONDS_PER_MINUTE):0,s=r-o*LO.SECONDS_PER_MINUTE;return{days:i,hours:a,minutes:o,seconds:t.seconds?Math.floor(s):0}}},{key:"formatValue",value:function(e,t){return t?e.toString().padStart(2,"0"):e.toString()}},{key:"emitCompletionEvent",value:function(){!this.hasEmittedCompletion&&this.contextProvider&&(this.hasEmittedCompletion=!0,f.getInstance().emit(v,re({},this.contextProvider.getPaywallActionEventData(),{action:m.COUNTDOWN_TIMER_COMPLETED,componentChange:{id:this.component.id,name:this.component.title}})))}},{key:"updated",value:function(e){this.updateAccessibilityAttributes(),e.has("component")&&this.handleComponentChange(e.get("component"))}},{key:"updateAccessibilityAttributes",value:function(){this.ariaLabel=this.component.screenreaderText||"",this.ariaDescription=this.component.screenreaderHint||""}},{key:"handleComponentChange",value:function(e){if(e){var t=this.component,i=t.mode,n=t.durationSeconds,a=t.targetDateTime;(i!==e.mode||n!==e.durationSeconds||a!==e.targetDateTime)&&this.startTimer()}}},{key:"styles",value:function(){var e=this.component,t=e.labels,i=e.separator,n=e.labelPosition,a=void 0===n?"none":n,r=e.direction,o=void 0===r?"horizontal":r,s=e.labelFontSize,u=e.labelFontColor,l=e.labelFontName,d=e.labelSpacing,h=e.spacing,c=e.fontSize,m=e.fontColor,f=e.fontName,v=e.alignment,p="below"===a?"bottom":"above"===a?"top":a,g="vertical"===o,y=t&&(t.days||t.hours||t.minutes||t.seconds)||"none"!==p;return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius||0}px !important;\n flex-direction: ${g?"column":"row"};\n align-items: center;\n justify-content: flex-start;\n ${Mu(e,this.inFocusedState)}\n ${xu(e,this.scaleFactor)}\n ${Iu(e,this.scaleFactor,this.inFocusedState)}\n ${Pu(e)}\n ${Lu(e,this.scaleFactor)}\n }\n .timer-text {\n display: flex;\n flex-direction: ${g?"column":"row"};\n align-items: center;\n gap: ${g?h?h*this.scaleFactor:4:0}px;\n }\n .timer-unit {\n display: flex;\n flex-direction: ${"top"===p||"bottom"===p?"column":"row"};\n align-items: center;\n ${g?`margin-top: ${h?h*this.scaleFactor:4}px;`:`margin-right: ${h?h*this.scaleFactor:4}px;`} \n }\n .timer-text-value-days,\n .timer-text-value-hours,\n .timer-text-value-minutes,\n .timer-text-value-seconds {\n ${c?`font-size: ${c*this.scaleFactor}px;`:""}\n ${m?Eu(m):""}\n ${Wu(f)}\n ${v?`text-align: ${v};`:""}\n ${Ru(e.dropShadow,!0)}\n line-height: 1;\n }\n .timer-text-value-label {\n font-size: ${s?s*this.scaleFactor:12*this.scaleFactor}px;\n color: ${u||"inherit"};\n ${Wu(l)}\n ${"top"===p?`margin-bottom: ${d?d*this.scaleFactor:2}px;`:""}\n ${"bottom"===p?`margin-top: ${d?d*this.scaleFactor:2}px;`:""}\n ${y?"":"display: none;"}\n }\n .timer-text-value-separator {\n ${i?`\n display: flex;\n align-items: center;\n ${c?`font-size: ${c*this.scaleFactor}px;`:""}\n ${m?Eu(m):""}\n ${Wu(f)}\n line-height: 1;\n ${g?`margin-top: ${h?h*this.scaleFactor:4}px;`:`margin-right: ${h?h*this.scaleFactor:4}px;`} \n ${"bottom"===p||"top"===p?"align-self: flex-start;":""}\n `:"display: none;"}\n }\n `)}},{key:"render",value:function(){this.tabIndex=0;var e=this.component.showWhenCompleted,t=void 0===e?"zero":e,i=this.calculateTimeValues();if(i.isCompleted&&(this.emitCompletionEvent(),"hidden"===t))return B(MO||(MO=_O``));var n=this.buildUnitsToRender(i);return 0===n.length?B(TO||(TO=_O`<div class="timer-text"></div>`)):this.renderTimerUnits(n)}},{key:"buildUnitsToRender",value:function(e){var t=this.component,i=t.labels,n=t.units,a=t.labelPosition,r=void 0===a?"none":a,o=n||{},s=o.days,u=o.hours,l=o.minutes,d=o.seconds,h=this.normalizeLabelPosition(r),c=this.shouldDisplayLabels(i,h);return[{enabled:s,value:e.days,label:this.getLabel("days",i,c),class:"timer-text-value-days"},{enabled:u,value:e.hours,label:this.getLabel("hours",i,c),class:"timer-text-value-hours"},{enabled:l,value:e.minutes,label:this.getLabel("minutes",i,c),class:"timer-text-value-minutes"},{enabled:d,value:e.seconds,label:this.getLabel("seconds",i,c),class:"timer-text-value-seconds"}].filter(e=>e.enabled).map(e=>({value:e.value,label:e.label,unitClass:e.class,showUnit:!0}))}},{key:"normalizeLabelPosition",value:function(e){return"below"===e?"bottom":"above"===e?"top":e}},{key:"shouldDisplayLabels",value:function(e,t){return Boolean(e&&(e.days||e.hours||e.minutes||e.seconds))||"none"!==t&&void 0!==t}},{key:"getLabel",value:function(e,t,i){var n;return null!==(n=null==t?void 0:t[e])&&void 0!==n?n:i?LO.DEFAULT_LABELS[e]:""}},{key:"renderTimerUnits",value:function(e){var t=this.component,i=t.separator,n=t.zeroPad,a=void 0===n||n,r=t.labelPosition,o=void 0===r?"none":r,s=this.component.labels,u=this.normalizeLabelPosition(o),l=s&&(s.days||s.hours||s.minutes||s.seconds),d=Boolean(l||"none"!==u),h=null!=i?i:":";return B(PO||(PO=_O`
|
|
576
|
+
`),this.currentWidth,Math.round(this.currentWidth))}}])}();gt([qt({type:Object})],SO.prototype,"component",void 0),gt([qt({type:Number})],SO.prototype,"scaleFactor",void 0),gt([qt({type:Boolean})],SO.prototype,"inFocusedState",void 0),gt([qt({type:Object})],SO.prototype,"minSDKVersion",void 0),gt([qt({type:Number})],SO.prototype,"currentWidth",void 0),SO=gt([Tt("nami-progress-indicator")],SO);var EO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.isActive=!1,t._handleFocus=()=>{t.inFocusedState=!0},t._handleKeyDown=e=>{"Enter"!==e.key&&" "!==e.key&&142!==e.keyCode&&195!==e.keyCode||t._handleClick()},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),this.addEventListener("click",this._handleClick,!1),this.addEventListener("keydown",this._handleKeyDown),this.addEventListener("focus",this._handleFocus)}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.removeEventListener("click",this._handleClick),this.removeEventListener("keydown",this._handleKeyDown),this.removeEventListener("focus",this._handleFocus)}},{key:"_handleClick",value:function(){var e,t,i=null===(e=this.component.onTap)||void 0===e?void 0:e.function;if(i){var n={function:i,parameters:re({},null===(t=this.component.onTap)||void 0===t?void 0:t.parameters,{formId:this.component.formId||"",value:"radio"===this.component.mode?this.component.value:void 0})};gs({onTap:n,contextProvider:this.contextProvider})}}},{key:"updated",value:function(){var e;this.ariaLabel=this.component.screenreaderText||this.component.title||"",this.ariaDescription=null!==(e=this.component.screenreaderHint)&&void 0!==e?e:""}},{key:"styles",value:function(){var e=this.component,t=this.contextProvider.getCurrentFormId(e.formId||""),i=!0===t||t===e.value;this.inFocusedState=i;var n=i?e.activeFillColor||e.activeFillColorFallback||"transparent":e.inactiveFillColor||e.inactiveFillColorFallback||"transparent",a=i?e.activeBorderColor||"transparent":e.inactiveBorderColor||"transparent";return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius}px !important;\n ${Ou(e,this.scaleFactor,this.inFocusedState)}\n ${Su(a)}\n border-width: ${i?e.activeBorderWidth||0:e.inactiveBorderWidth||0}px !important;\n ${Ru(i?e.activeDropShadow:e.inactiveDropShadow)};\n border-style: solid;\n ${ku(n)}\n }\n `)}},{key:"render",value:function(){return this.tabIndex=0,this.component.components.map(e=>kl(this.contextProvider,e,this.scaleFactor,this.inFocusedState,this.minSDKVersion))}}])}();gt([qt({type:Object})],EO.prototype,"component",void 0),gt([qt({type:Boolean})],EO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],EO.prototype,"scaleFactor",void 0),gt([qt({type:Object})],EO.prototype,"minSDKVersion",void 0),gt([qt({type:Boolean})],EO.prototype,"isActive",void 0),EO=gt([Tt("nami-toggle-button")],EO);var MO,TO,PO,AO,DO,xO,CO,IO,LO,_O,RO=e=>e,FO=(MO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).inFocusedState=!1,t.scaleFactor=1,t.timer=null,t.startTime=0,t.initialDuration=0,t.hasEmittedCompletion=!1,t}return ue(e,lu),ne(e,[{key:"firstUpdated",value:function(){this.loadTimerState(),this.startTimer()}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.saveTimerState(),this.clearTimer()}},{key:"getTimerId",value:function(){var e,t;return null!==(e=null===(t=this.component)||void 0===t?void 0:t.id)&&void 0!==e?e:""}},{key:"loadTimerState",value:function(){var e;null!==(e=this.contextProvider)&&void 0!==e&&e.flow&&(this.timerState=this.contextProvider.flow.timerStates[this.getTimerId()])}},{key:"saveTimerState",value:function(){var e;if(null!==(e=this.contextProvider)&&void 0!==e&&e.flow){var t=this.component,i=t.mode,n=t.durationSeconds;if("duration"===i&&void 0!==n){var a=this.calculateCurrentRemainingSeconds();this.contextProvider.flow.timerStates[this.getTimerId()]={remainingSeconds:a,savedAt:Date.now(),hasEmittedCompletion:this.hasEmittedCompletion}}}}},{key:"getSavedTimerState",value:function(){var e;return null===(e=this.contextProvider)||void 0===e||null===(e=e.flow)||void 0===e?void 0:e.timerStates[this.getTimerId()]}},{key:"startTimer",value:function(){this.initializeTimerState(),this.clearTimer(),this.timer=setInterval(()=>this.onTimerTick(),_O.TIMER_INTERVAL_MS)}},{key:"initializeTimerState",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.resetOnRemount;"duration"===t&&void 0!==i&&(this.timerState&&!n?this.restoreTimerFromState(this.timerState,i):this.resetTimerState(i))}},{key:"restoreTimerFromState",value:function(e,t){var i=(Date.now()-e.savedAt)/1e3,n=Math.max(0,e.remainingSeconds-i);this.initialDuration=t,this.startTime=Date.now()-1e3*(this.initialDuration-n),this.hasEmittedCompletion=e.hasEmittedCompletion}},{key:"resetTimerState",value:function(e){this.initialDuration=e,this.startTime=Date.now(),this.hasEmittedCompletion=!1}},{key:"onTimerTick",value:function(){var e=this.calculateTimeValues().isCompleted;this.requestUpdate(),e&&this.clearTimer()}},{key:"clearTimer",value:function(){this.timer&&(clearInterval(this.timer),this.timer=null)}},{key:"calculateTimeValues",value:function(){var e=this.calculateTotalRemainingSeconds(),t=e<=0,i=this.component.units||_O.DEFAULT_UNITS,n=i.days,a=i.hours,r=i.minutes,o=i.seconds;return re({},this.convertSecondsToTimeUnits(e,{days:n,hours:a,minutes:r,seconds:o}),{isCompleted:t})}},{key:"calculateTotalRemainingSeconds",value:function(){var e=this.component,t=e.mode,i=e.durationSeconds,n=e.targetDateTime;return"duration"===t?this.calculateDurationRemainingSeconds(i):"targetDateTime"===t&&n?this.calculateTargetDateTimeRemainingSeconds(n):0}},{key:"calculateDurationRemainingSeconds",value:function(e){var t=this.getSavedTimerState();if(t){var i=(Date.now()-t.savedAt)/1e3;return Math.max(0,t.remainingSeconds-i)}if(this.initialDuration>0&&this.startTime>0){var n=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-n)}return void 0!==e?Math.max(0,e):0}},{key:"calculateTargetDateTimeRemainingSeconds",value:function(e){var t=new Date(e).getTime(),i=Date.now();return Math.max(0,(t-i)/1e3)}},{key:"calculateCurrentRemainingSeconds",value:function(){var e=this.component.durationSeconds;if(this.initialDuration>0&&this.startTime>0){var t=(Date.now()-this.startTime)/1e3;return Math.max(0,this.initialDuration-t)}return null!=e?e:0}},{key:"convertSecondsToTimeUnits",value:function(e,t){var i=t.days?Math.floor(e/_O.SECONDS_PER_DAY):0,n=e-i*_O.SECONDS_PER_DAY,a=t.hours?Math.floor(n/_O.SECONDS_PER_HOUR):0,r=n-a*_O.SECONDS_PER_HOUR,o=t.minutes?Math.floor(r/_O.SECONDS_PER_MINUTE):0,s=r-o*_O.SECONDS_PER_MINUTE;return{days:i,hours:a,minutes:o,seconds:t.seconds?Math.floor(s):0}}},{key:"formatValue",value:function(e,t){return t?e.toString().padStart(2,"0"):e.toString()}},{key:"emitCompletionEvent",value:function(){!this.hasEmittedCompletion&&this.contextProvider&&(this.hasEmittedCompletion=!0,f.getInstance().emit(v,re({},this.contextProvider.getPaywallActionEventData(),{action:m.COUNTDOWN_TIMER_COMPLETED,componentChange:{id:this.component.id,name:this.component.title}})))}},{key:"updated",value:function(e){this.updateAccessibilityAttributes(),e.has("component")&&this.handleComponentChange(e.get("component"))}},{key:"updateAccessibilityAttributes",value:function(){this.ariaLabel=this.component.screenreaderText||"",this.ariaDescription=this.component.screenreaderHint||""}},{key:"handleComponentChange",value:function(e){if(e){var t=this.component,i=t.mode,n=t.durationSeconds,a=t.targetDateTime;(i!==e.mode||n!==e.durationSeconds||a!==e.targetDateTime)&&this.startTimer()}}},{key:"styles",value:function(){var e=this.component,t=e.labels,i=e.separator,n=e.labelPosition,a=void 0===n?"none":n,r=e.direction,o=void 0===r?"horizontal":r,s=e.labelFontSize,u=e.labelFontColor,l=e.labelFontName,d=e.labelSpacing,h=e.spacing,c=e.fontSize,m=e.fontColor,f=e.fontName,v=e.alignment,p="below"===a?"bottom":"above"===a?"top":a,g="vertical"===o,y=t&&(t.days||t.hours||t.minutes||t.seconds)||"none"!==p;return U(`\n :host {\n box-sizing: border-box;\n display: ${e.hidden?"none":"flex"};\n position: relative;\n cursor: pointer;\n height: 100%;\n border-radius: ${e.borderRadius||0}px !important;\n flex-direction: ${g?"column":"row"};\n align-items: center;\n justify-content: flex-start;\n ${Mu(e,this.inFocusedState)}\n ${xu(e,this.scaleFactor)}\n ${Iu(e,this.scaleFactor,this.inFocusedState)}\n ${Pu(e)}\n ${Lu(e,this.scaleFactor)}\n }\n .timer-text {\n display: flex;\n flex-direction: ${g?"column":"row"};\n align-items: center;\n gap: ${g?h?h*this.scaleFactor:4:0}px;\n }\n .timer-unit {\n display: flex;\n flex-direction: ${"top"===p||"bottom"===p?"column":"row"};\n align-items: center;\n ${g?`margin-top: ${h?h*this.scaleFactor:4}px;`:`margin-right: ${h?h*this.scaleFactor:4}px;`} \n }\n .timer-text-value-days,\n .timer-text-value-hours,\n .timer-text-value-minutes,\n .timer-text-value-seconds {\n ${c?`font-size: ${c*this.scaleFactor}px;`:""}\n ${m?Eu(m):""}\n ${Wu(f)}\n ${v?`text-align: ${v};`:""}\n ${Ru(e.dropShadow,!0)}\n line-height: 1;\n }\n .timer-text-value-label {\n font-size: ${s?s*this.scaleFactor:12*this.scaleFactor}px;\n color: ${u||"inherit"};\n ${Wu(l)}\n ${"top"===p?`margin-bottom: ${d?d*this.scaleFactor:2}px;`:""}\n ${"bottom"===p?`margin-top: ${d?d*this.scaleFactor:2}px;`:""}\n ${y?"":"display: none;"}\n }\n .timer-text-value-separator {\n ${i?`\n display: flex;\n align-items: center;\n ${c?`font-size: ${c*this.scaleFactor}px;`:""}\n ${m?Eu(m):""}\n ${Wu(f)}\n line-height: 1;\n ${g?`margin-top: ${h?h*this.scaleFactor:4}px;`:`margin-right: ${h?h*this.scaleFactor:4}px;`} \n ${"bottom"===p||"top"===p?"align-self: flex-start;":""}\n `:"display: none;"}\n }\n `)}},{key:"render",value:function(){this.tabIndex=0;var e=this.component.showWhenCompleted,t=void 0===e?"zero":e,i=this.calculateTimeValues();if(i.isCompleted&&(this.emitCompletionEvent(),"hidden"===t))return B(TO||(TO=RO``));var n=this.buildUnitsToRender(i);return 0===n.length?B(PO||(PO=RO`<div class="timer-text"></div>`)):this.renderTimerUnits(n)}},{key:"buildUnitsToRender",value:function(e){var t=this.component,i=t.labels,n=t.units,a=t.labelPosition,r=void 0===a?"none":a,o=n||{},s=o.days,u=o.hours,l=o.minutes,d=o.seconds,h=this.normalizeLabelPosition(r),c=this.shouldDisplayLabels(i,h);return[{enabled:s,value:e.days,label:this.getLabel("days",i,c),class:"timer-text-value-days"},{enabled:u,value:e.hours,label:this.getLabel("hours",i,c),class:"timer-text-value-hours"},{enabled:l,value:e.minutes,label:this.getLabel("minutes",i,c),class:"timer-text-value-minutes"},{enabled:d,value:e.seconds,label:this.getLabel("seconds",i,c),class:"timer-text-value-seconds"}].filter(e=>e.enabled).map(e=>({value:e.value,label:e.label,unitClass:e.class,showUnit:!0}))}},{key:"normalizeLabelPosition",value:function(e){return"below"===e?"bottom":"above"===e?"top":e}},{key:"shouldDisplayLabels",value:function(e,t){return Boolean(e&&(e.days||e.hours||e.minutes||e.seconds))||"none"!==t&&void 0!==t}},{key:"getLabel",value:function(e,t,i){var n;return null!==(n=null==t?void 0:t[e])&&void 0!==n?n:i?_O.DEFAULT_LABELS[e]:""}},{key:"renderTimerUnits",value:function(e){var t=this.component,i=t.separator,n=t.zeroPad,a=void 0===n||n,r=t.labelPosition,o=void 0===r?"none":r,s=this.component.labels,u=this.normalizeLabelPosition(o),l=s&&(s.days||s.hours||s.minutes||s.seconds),d=Boolean(l||"none"!==u),h=null!=i?i:":";return B(AO||(AO=RO`
|
|
577
577
|
<div class="timer-text">
|
|
578
578
|
${0}
|
|
579
579
|
</div>
|
|
580
|
-
`),e.map((t,i)=>B(
|
|
580
|
+
`),e.map((t,i)=>B(DO||(DO=RO`
|
|
581
581
|
${0}
|
|
582
582
|
${0}
|
|
583
|
-
`),this.renderUnit(t.value,t.label,t.unitClass,t.showUnit,a,u,d),i<e.length-1&&h?B(
|
|
583
|
+
`),this.renderUnit(t.value,t.label,t.unitClass,t.showUnit,a,u,d),i<e.length-1&&h?B(xO||(xO=RO`<span class="timer-text-value-separator">${0}</span>`),h):"")))}},{key:"renderUnit",value:function(e,t,i,n,a,r,o){if(!n)return null;var s=Boolean(t&&o);return B(CO||(CO=RO`
|
|
584
584
|
<div class="timer-unit">
|
|
585
585
|
${0}
|
|
586
586
|
<span class="${0}">${0}</span>
|
|
587
587
|
${0}
|
|
588
588
|
</div>
|
|
589
|
-
`),s&&"top"===r?B(
|
|
589
|
+
`),s&&"top"===r?B(IO||(IO=RO`<span class="timer-text-value-label">${0}</span>`),t):"",i,this.formatValue(e,a),s&&"bottom"===r?B(LO||(LO=RO`<span class="timer-text-value-label">${0}</span>`),t):"")}}])}(),_O=MO,MO.DEFAULT_LABELS={days:"days",hours:"hours",minutes:"minutes",seconds:"seconds"},MO.DEFAULT_UNITS={days:!1,hours:!0,minutes:!0,seconds:!0},MO.SECONDS_PER_DAY=86400,MO.SECONDS_PER_HOUR=3600,MO.SECONDS_PER_MINUTE=60,MO.TIMER_INTERVAL_MS=1e3,MO);gt([qt({type:Object})],FO.prototype,"component",void 0),gt([qt({type:Boolean})],FO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],FO.prototype,"scaleFactor",void 0),gt([qt({type:Object})],FO.prototype,"minSDKVersion",void 0),FO=_O=gt([Tt("nami-countdown-timer-text")],FO);var WO,OO=e=>e,$O=S.NamiFlowManager,NO=function(){function e(){var t;return Q(this,e),(t=J(this,e,arguments)).scaleFactor=1,t.inFocusedState=!1,t.currentProgress=0,t.isAnimating=!1,t.screenreaderAnnouncement="",t.hasInitialized=!1,t.delayTimeoutId=null,t.animationFrameId=null,t.animationStartTime=null,t.startPercentage=0,t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){pe(e,"connectedCallback",this)([]),$(this.minSDKVersion,"ProgressBar")}},{key:"disconnectedCallback",value:function(){pe(e,"disconnectedCallback",this)([]),this.cleanup()}},{key:"firstUpdated",value:function(t){pe(e,"firstUpdated",this)([t]),this.hasInitialized=!0,this.startAnimation()}},{key:"updated",value:function(t){pe(e,"updated",this)([t]),this.hasInitialized&&t.has("component")&&(this.cleanup(),this.startAnimation())}},{key:"cleanup",value:function(){null!==this.delayTimeoutId&&(clearTimeout(this.delayTimeoutId),this.delayTimeoutId=null),null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.animationStartTime=null,this.isAnimating=!1}},{key:"getResolvedDuration",value:function(){var e=this.component,t=e.duration,i=e.mode;if("auto"===t&&"determinate"===i){var n=$O.getCurrentFlowStepAutoAdvanceDelay();return null!=n?n:3}return"number"==typeof t&&t>0?t:"determinate"===i?3:2}},{key:"startAnimation",value:function(){var e=this.component,t=e.mode,i=e.delay,n=e.percentage,a=void 0===n?0:n,r="number"==typeof a&&!Number.isInteger(a);this.startPercentage="number"==typeof a?r?100*a:a:0,this.currentProgress=this.startPercentage;var o="number"==typeof i&&i>0?1e3*i:0;o>0?this.delayTimeoutId=setTimeout(()=>{this.delayTimeoutId=null,this.beginAnimation(t)},o):this.beginAnimation(t)}},{key:"beginAnimation",value:function(e){this.isAnimating=!0;var t=this.component.screenreaderText||"Loading";this.screenreaderAnnouncement=t,setTimeout(()=>{this.screenreaderAnnouncement=""},1e3),"determinate"===e&&this.animateDeterminate()}},{key:"animateDeterminate",value:function(){if(!this.isAnimating||null===this.animationFrameId){var e=1e3*this.getResolvedDuration(),t=this.startPercentage;this.animationStartTime=null;var i=n=>{null===this.animationStartTime&&(this.animationStartTime=n);var a=n-this.animationStartTime,r=Math.min(1,a/e);this.currentProgress=t+(100-t)*r,r<1?this.animationFrameId=requestAnimationFrame(i):(this.currentProgress=100,this.isAnimating=!1,this.animationFrameId=null,this.animationStartTime=null)};this.animationFrameId=requestAnimationFrame(i)}}},{key:"getActiveWidthCss",value:function(){var e=this.component.activeWidth;return null==e?"30%":"number"==typeof e?`${e}px`:String(e).trim()}},{key:"isActiveWidthPercent",value:function(){var e=this.component.activeWidth;return null==e||"number"!=typeof e&&String(e).endsWith("%")}},{key:"styles",value:function(){var e=this.component,t=this.scaleFactor,i=this.inFocusedState,n=e.mode,a=e.inactiveFillColor,r=e.inactiveFillColorFallback,o=e.inactiveBorderRadius,s=e.activeFillColor,u=e.activeFillColorFallback,l=e.activeBorderRadius,d=e.innerPadding,h=void 0===d?0:d,c=e.activeDropShadow,m=e.inactiveDropShadow,f=this.getActiveWidthCss(),v=this.getResolvedDuration(),p=this.isActiveWidthPercent(),g=p&&parseFloat(f)||30,y=(100-g)/g*100,b=p?0:parseFloat(f)||0;return U(`\n :host {\n display: ${e.hidden?"none":"block"};\n ${Ou(e,t,i)}\n }\n \n .progress-container {\n ${Lu(e,t)} \n background: ${a||r};\n border-radius: ${o||0}px;\n overflow: hidden;\n position: relative;\n padding: ${h*t}px;\n box-sizing: border-box;\n ${Ru(m)}\n }\n \n .progress-bar {\n height: 100%;\n background: ${s||u};\n border-radius: ${l||0}px;\n box-sizing: border-box;\n ${Ru(c)}\n ${"indeterminate"===n?`\n position: absolute;\n left: 0;\n top: ${h*t}px;\n bottom: ${h*t}px;\n width: ${f};\n animation: slide ${v}s linear infinite;\n `:""}\n }\n\n ${"indeterminate"===n?p?`\n @keyframes slide {\n 0% {\n transform: translateX(-${y}%);\n }\n 100% {\n transform: translateX(${y+100}%);\n }\n }\n `:`\n @keyframes slide {\n 0% {\n left: -${b}px;\n }\n 100% {\n left: 100%;\n }\n }\n `:""}\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n `)}},{key:"render",value:function(){var e=this.component.mode;return B(WO||(WO=OO`
|
|
590
590
|
<div class="progress-container">
|
|
591
591
|
<div
|
|
592
592
|
class="progress-bar"
|
|
@@ -603,7 +603,7 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
603
603
|
aria-live="polite"
|
|
604
604
|
aria-atomic="true"
|
|
605
605
|
>${0}</span>
|
|
606
|
-
`),"indeterminate"===e?"":`width: ${this.currentProgress}%`,"indeterminate"===e?void 0:Math.round(this.currentProgress),"indeterminate"===e?void 0:0,"indeterminate"===e?void 0:100,this.isAnimating,this.screenreaderAnnouncement)}}])}();gt([qt({type:Object})]
|
|
606
|
+
`),"indeterminate"===e?"":`width: ${this.currentProgress}%`,"indeterminate"===e?void 0:Math.round(this.currentProgress),"indeterminate"===e?void 0:0,"indeterminate"===e?void 0:100,this.isAnimating,this.screenreaderAnnouncement)}}])}();gt([qt({type:Object})],NO.prototype,"component",void 0),gt([qt({type:Number})],NO.prototype,"scaleFactor",void 0),gt([qt({type:Boolean})],NO.prototype,"inFocusedState",void 0),gt([qt({type:Object})],NO.prototype,"minSDKVersion",void 0),gt([Jt()],NO.prototype,"currentProgress",void 0),gt([Jt()],NO.prototype,"isAnimating",void 0),gt([Jt()],NO.prototype,"screenreaderAnnouncement",void 0),NO=gt([Tt("nami-progress-bar")],NO);var jO,BO,zO=e=>e,UO=2,HO=6,GO=20,VO=16,KO=16,XO=function(){function e(){var t;return Q(this,e),(t=J(this,e)).inFocusedState=!1,t.scaleFactor=1,t._value="",t._focused=!1,t._handleInput=e=>{var i=e.target.value;t._value=i;var n=t.component,a=n.formId,r=n.validateOn;if(t.contextProvider.setFormState(a,i),"change"===r){var o,s=N(t.validatorType(),!0===t.component.reqed,i);if(s)t.contextProvider.setFormFieldError(a,null!==(o=t.component.validationMessage)&&void 0!==o?o:s);else t.contextProvider.clearFormFieldError(a)}t.requestUpdate()},t._handleFocus=()=>{t._focused=!0,t.requestUpdate()},t._handleBlur=()=>{t._focused=!1,t.requestUpdate()},t}return ue(e,lu),ne(e,[{key:"connectedCallback",value:function(){var t;pe(e,"connectedCallback",this)([]);var i=this.component.formId,n=null===(t=this.contextProvider.state.formStates)||void 0===t?void 0:t[i];this._value="string"==typeof n?n:"",this.contextProvider.setFormState(i,this._value),this.contextProvider.registerFormFieldValidator(i,this.validator())}},{key:"isTelevision",get:function(){return"television"===c()}},{key:"validatorType",value:function(){return"email"===this.component.type?"email":"name"}},{key:"validator",value:function(){return{type:this.validatorType(),required:!0===this.component.reqed,message:this.component.validationMessage}}},{key:"currentError",get:function(){return this.contextProvider.getFormFieldErrors()[this.component.formId]}},{key:"styles",value:function(){return U(`\n :host {\n box-sizing: border-box;\n display: block;\n ${"100%"===this.component.width?"width: 100%;":""}\n }\n :host .nami-text-input-wrapper {\n display: flex;\n flex-direction: column;\n gap: ${this.resolvedSpacing()}px;\n ${"100%"===this.component.width?"width: 100%;":""}\n }\n :host label {\n ${this.applyLabelStyles()}\n }\n :host input {\n ${this.applyInputStyles()}\n }\n :host input::placeholder {\n ${this.component.placeholderFontColor?`color: ${this.component.placeholderFontColor};`:""}\n }\n :host .nami-text-input-error {\n ${this.applyErrorStyles()}\n }\n `)}},{key:"resolvedSpacing",value:function(){var e=this.component.spacing;return null==e?this.isTelevision?VO:0:Number(e)}},{key:"resolvedBorderWidth",value:function(e){return null==e?this.isTelevision?UO:0:Number(e)}},{key:"applyLabelStyles",value:function(){var e,t=this.component,i=null!==(e=t.labelFontSize)&&void 0!==e?e:this.isTelevision?GO:void 0;return`\n ${Eu(t.labelFontColor||"inherit")}\n ${Wu(t.labelFontName)}\n ${null!=i?`font-size: ${wu(i,this.scaleFactor)};`:""}\n `}},{key:"applyInputStyles",value:function(){var e,t,i,n,a,r,o,s,u,l,d,h,c=this.component,m=!!this.currentError,f=this._focused,v=c.borderColor||"transparent",p=this.resolvedBorderWidth(c.borderWidth),g=Number(null!==(e=c.borderRadius)&&void 0!==e?e:this.isTelevision?HO:0),y=c.fillColor||"transparent";f&&(v=c.focusedBorderColor||v,p=this.resolvedBorderWidth(null!==(o=c.focusedBorderWidth)&&void 0!==o?o:c.borderWidth),g=Number(null!==(s=null!==(u=c.focusedBorderRadius)&&void 0!==u?u:c.borderRadius)&&void 0!==s?s:g),y=c.focusedFillColor||y);m&&(v=c.errorBorderColor||v,p=this.resolvedBorderWidth(null!==(l=c.errorBorderWidth)&&void 0!==l?l:c.borderWidth),g=Number(null!==(d=null!==(h=c.errorBorderRadius)&&void 0!==h?h:c.borderRadius)&&void 0!==d?d:g));var b=null!==(t=c.fontSize)&&void 0!==t?t:this.isTelevision?GO:void 0,w=null!==(i=c.innerTopPadding)&&void 0!==i?i:this.isTelevision?KO:0,k=null!==(n=c.innerBottomPadding)&&void 0!==n?n:this.isTelevision?KO:0,S=null!==(a=c.innerLeftPadding)&&void 0!==a?a:this.isTelevision?KO:0,E=null!==(r=c.innerRightPadding)&&void 0!==r?r:this.isTelevision?KO:0;return`\n box-sizing: border-box;\n width: 100%;\n outline: none;\n ${Eu(c.fontColor||"inherit")}\n ${Wu(c.fontName)}\n ${null!=b?`font-size: ${wu(b,this.scaleFactor)};`:""}\n ${ku(y)}\n ${Su(v)}\n border-style: solid;\n border-width: ${p}px !important;\n border-radius: ${g}px !important;\n padding: ${Number(w)}px ${Number(E)}px ${Number(k)}px ${Number(S)}px !important;\n text-align: ${c.alignment||"left"};\n `}},{key:"applyErrorStyles",value:function(){var e,t=this.component,i=null!==(e=t.validationTextFontSize)&&void 0!==e?e:this.isTelevision?GO:void 0;return`\n ${Eu(t.validationTextFontColor||"#D83A58")}\n ${Wu(t.validationTextFontName)}\n ${null!=i?`font-size: ${wu(i,this.scaleFactor)};`:""}\n `}},{key:"render",value:function(){var e,t,i,n,a=this.component,r=`nami-text-input-${a.formId}`,o=this.currentError,s="none"!==a.labelPosition&&!!a.labelText,u=!0===a.reqed?`${a.labelText} *`:a.labelText,l="email"===a.type?"email":"text",d="email"===a.type?"email":"text";return B(jO||(jO=zO`
|
|
607
607
|
<div class="nami-text-input-wrapper">
|
|
608
608
|
${0}
|
|
609
609
|
<input
|
|
@@ -626,4 +626,4 @@ import{NAMI_SDK_VERSION as e,getExtendedClientInfo as t,PaywallState as i,logger
|
|
|
626
626
|
aria-live="polite"
|
|
627
627
|
>${0}</div>
|
|
628
628
|
</div>
|
|
629
|
-
`),s?B(
|
|
629
|
+
`),s?B(BO||(BO=zO`<label for=${0}>${0}</label>`),r,u):G,r,l,d,this._value,null!==(e=a.placeholderText)&&void 0!==e?e:"",null!==(t=null!==(i=a.screenreaderText)&&void 0!==i?i:u)&&void 0!==t?t:G,null!==(n=a.screenreaderHint)&&void 0!==n?n:G,o?"true":G,o?`${r}-error`:G,this._handleInput,this._handleFocus,this._handleBlur,`${r}-error`,null!=o?o:"")}}])}();gt([qt({type:Object})],XO.prototype,"component",void 0),gt([qt({type:Boolean})],XO.prototype,"inFocusedState",void 0),gt([qt({type:Number})],XO.prototype,"scaleFactor",void 0),XO=gt([Tt("nami-text-input")],XO);
|