@namiml/web-sdk 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/dist/components/ContextProvider.d.ts +2 -2
- package/dist/nami-web.cjs +2 -2
- package/dist/nami-web.js +2 -2
- package/dist/nami-web.mjs +2 -2
- package/dist/nami-web.umd.js +2 -2
- package/dist/types/components/index.d.ts +12 -9
- package/dist/types/paywall.d.ts +2 -2
- package/package.json +1 -1
package/dist/nami-web.cjs
CHANGED
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
`}render(){return this.renderSvgIcon(this.shouldRenderCurrentIcon()?this.component.name:this.previousSymbolName)}};o([fs({type:Object})],Rw.prototype,"component",void 0),o([fs({type:Boolean})],Rw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Rw.prototype,"scaleFactor",void 0),Rw=o([Uo("nami-symbol")],Rw);let Ww=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1}styles(){return e.unsafeCSS(`\n :host {\n line-height: 1.5715;\n display: ${this.component.hidden?"none":"grid"};\n overflow-wrap: anywhere;\n width: fit-content;\n ${Is(this.component,this.inFocusedState)}\n color: ${this.inFocusedState&&this.component.focusedFontColor?this.component.focusedFontColor:this.component.fontColor??""};\n font-size: ${(this.component.fontSize??12)*this.scaleFactor}px;\n text-align: ${this.component.alignment||"center"};\n ${Us("string"!=typeof this.component.strikethrough&&this.component.strikethrough)}\n ${Bs(this.component)}\n ${Gs(this.component,this.scaleFactor,this.inFocusedState)}\n ${Dw(this.component)}\n ${_s(this.component)}\n ${js(this.component)}\n }\n :host > :not(:first-child) {\n margin-top: ${this.component.spacing||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: 1.5715;\n display: inline;\n overflow-wrap: anywhere;\n width: fit-content;\n ${Is(this.component,this.inFocusedState)}\n color: ${this.inFocusedState&&this.component.focusedFontColor?this.component.focusedFontColor:this.component.fontColor??""};\n font-size: ${(this.component.fontSize??12)*this.scaleFactor}px;\n text-align: ${this.component.alignment||"center"};\n ${Us("string"!=typeof this.component.strikethrough&&this.component.strikethrough)}\n ${Bs(this.component)}\n }\n :host .bullet-text-wrapper p {\n margin: 0;\n line-height: 1.2em;\n }\n ${Dw(this.component,":host .bullet-text-wrapper")}\n `)}render(){const{fontColor:t,fontSize:n,bulletComponent:i,texts:a,spacing:r}=this.component,o=i?{fontColor:t,fontSize:n,spacing:r,...i}:null;if(!Array.isArray(a))return e.html``;const s=a.map((t=>t?e.html`<nami-text-list-item-wrapper .component=${this.component}>
|
|
57
57
|
${o&&e.html`<nami-symbol .component=${o}></nami-symbol>`}
|
|
58
58
|
<div class="bullet-text-wrapper" .innerHTML="${au(t)}"></div>
|
|
59
|
-
</nami-text-list-item-wrapper>`:null));return e.html`${s}`}};o([fs({type:Object})],Ww.prototype,"component",void 0),o([fs({type:Boolean})],Ww.prototype,"inFocusedState",void 0),o([fs({type:Number})],Ww.prototype,"scaleFactor",void 0),Ww=o([Uo("nami-text-list")],Ww);let Nw=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this.addEventListener("focus",(()=>{this.inFocusedState=!0}),!1),this.addEventListener("blur",(()=>{this.inFocusedState=!1}),!1),this.addEventListener("focus-changed",(e=>{this.inFocusedState=1==e.detail.inFocusedState}),!1)}styles(){const{component:t,inFocusedState:n,scaleFactor:i}=this,a=t.fillImage?e.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${t.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):e.unsafeCSS(Is(t,n));return e.unsafeCSS(`\n :host {\n display: ${t.hidden?"none":"flex"};\n gap: ${t.spacing}px;\n ${a};\n ${Xs(t.position)}\n ${_s(t)}\n ${Gs(t,i,n)}\n ${Rs(this.component)} \n }\n `)}render(){return(this.component.components??[]).map((e=>sd(e,this.scaleFactor)))}};o([fs({type:Object})],Nw.prototype,"component",void 0),o([fs({type:Boolean})],Nw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Nw.prototype,"scaleFactor",void 0),Nw=o([Uo("nami-container")],Nw);let Ow=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1}styles(){const t="vertical"===this.component.direction,n=t?"width":"height",i=t?"margin-top":"margin-left",a=this.component.fillImage?e.unsafeCSS(`\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 `):e.unsafeCSS(Is(this.component,this.inFocusedState));return e.unsafeCSS(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${a};\n ${Xs(this.component.position)}\n ${_s(this.component)}\n ${Gs(this.component,this.scaleFactor,this.inFocusedState)}\n ${Rs(this.component)} \n transition: transform .5s ease-in;\n }\n :host > * {\n ${n}: 100%;\n }\n :host > :not(:first-child) {\n ${i}: ${this.component.spacing||0}px;\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 `)}updated(){const{currentGroupId:e}=Do.state;Ma(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout((()=>this.classList.add("fade-in")),100),this.currentGroupId=e)}render(){const{mediaList:e,selectedPaywall:t,currentGroupId:n,formFactor:i}=Do.state;return Qs(So(Do.productDetails,t?.sku_menus||[],this.component?.subsetGroup||n),this.component,e).map((([e,t])=>(this.inFocusedState="television"==i?e:this.inFocusedState,t.map((e=>sd(e,this.scaleFactor,this.inFocusedState))))))}};o([fs({type:Object})],Ow.prototype,"component",void 0),o([fs({type:Boolean})],Ow.prototype,"inFocusedState",void 0),o([fs({type:Number})],Ow.prototype,"scaleFactor",void 0),Ow=o([Uo("nami-product-container")],Ow);let Fw=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1}styles(){const{url:t,imageCropping:n,alignment:i,height:a,width:r,rightMargin:o,spacing:s}=this.component,d="fit"===n;return e.unsafeCSS(`\n :host {\n box-sizing: border-box;\n position: relative;\n transition: all 0.3s;\n background-image: url(${t});\n background-size: ${d?"contain":"cover"};\n background-position: ${i||""} center;\n background-repeat: no-repeat;\n height: ${Ls(a??"100%",this.scaleFactor)};\n width: ${Ls(("fitContent"==r?a:r)??"100%",this.scaleFactor)};\n margin-right: ${o||s||0}px;\n ${Ns(this.component,this.scaleFactor)}\n ${this.component.hidden?"display:none":""}\n }\n `)}render(){const{focusedBorderColor:t,focusedFillColor:n,fillColor:i}=this.component;return!t&&od(i,n)||(this.tabIndex=0),e.html``}};o([fs({type:Object})],Fw.prototype,"component",void 0),o([fs({type:Boolean})],Fw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Fw.prototype,"scaleFactor",void 0),Fw=o([Uo("nami-image")],Fw);let jw=class extends gs{constructor(){super(...arguments),this.fullscreen=!1,this.inFocusedState=!1,this.scaleFactor=1}styles(){const{inFocusedState:t,component:n,scaleFactor:i}=this;return e.unsafeCSS(`\n :host {\n display: ${n.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Rs(n)}\n position: absolute;\n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${n.zIndex??1};\n top: 0px;\n ${Is(n,t)}\n transition: all 0.3s;\n ${Ns(n,i)}\n }\n `)}updated(){const e=Array.from(document.getElementsByTagName("nami-paywall")),t=this.component.fillColor?.includes("gradient"),n=this.shadowRoot?.innerHTML.includes("nami-image");e[0].style.position=!n||t?"relative":"",e[0].style.minHeight=!n||t?"100vh":"100%"}render(){return(this.component.components??[]).map((e=>sd(e,this.scaleFactor)))}};o([fs({type:Object})],jw.prototype,"component",void 0),o([fs({type:Boolean})],jw.prototype,"fullscreen",void 0),o([fs({type:Boolean})],jw.prototype,"inFocusedState",void 0),o([fs({type:Number})],jw.prototype,"scaleFactor",void 0),jw=o([Uo("nami-background-container")],jw);let zw=class extends gs{constructor(){super(...arguments),this.zIndex=2,this.inFocusedState=!1,this.scaleFactor=1}styles(){const{contextConsumer:t,component:n,zIndex:i,scaleFactor:a,inFocusedState:r}=this,{formFactor:o}=t.state,s="phone"!==o?"width: 100%;":"",d="100%"==n.height?"height:100vh !important;":"",l=n.spacing??0;return e.unsafeCSS(`\n :host {\n display: ${n.hidden?"none":"flex"};\n gap: ${l}px;\n position: relative;\n ${_s(n)}\n ${zs(n,a)}\n ${s}\n ${d}\n ${Rs(n)}\n z-index: ${i};\n transition: all 0.3s;\n overflow-y: 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 ${Ns(n,a)}\n ${Is(n,r)}\n }\n :host > * {\n width: 100%;\n }\n \n :host > *:not(:first-child) {\n ${"vertical"===n.direction?`margin-top: ${l}px;`:`margin-left: ${l}px;`}\n `)}firstUpdated(){const e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}render(){return this.component.components.map((e=>sd(e,this.scaleFactor,this.inFocusedState)))}};o([fs({type:Object})],zw.prototype,"component",void 0),o([fs({type:Number})],zw.prototype,"zIndex",void 0),o([fs({type:Boolean})],zw.prototype,"inFocusedState",void 0),o([fs({type:Number})],zw.prototype,"scaleFactor",void 0),zw=o([Uo("nami-content-container")],zw);let $w=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this._handleClick=()=>{Wd(this.component.onTap)},this.addEventListener("click",this._handleClick)}styles(){const t=Ys("active",this.component.components[0]);return e.unsafeCSS(`\n :host {\n cursor: pointer;\n ${Is(this.component,this.inFocusedState)}\n ${Gs(this.component,this.scaleFactor,this.inFocusedState)}\n ${this.component.hidden?"display:none":""}\n }\n\n .toggle{\n position: absolute !important;\n top: 0;\n bottom: 0;\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Vs(t,this.scaleFactor,this.inFocusedState)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n }\n `)}render(){const t=this.component.components.map((e=>sd(e,this.scaleFactor,this.inFocusedState)));return e.html`${t}<div class="toggle"></div>`}};o([fs({type:Object})],$w.prototype,"component",void 0),o([fs({type:Boolean})],$w.prototype,"inFocusedState",void 0),o([fs({type:Number})],$w.prototype,"scaleFactor",void 0),$w=o([Uo("nami-segment-picker")],$w);let Hw=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this._handleClick=()=>{this.component.id&&Do.setCurrentGroupData(this.component.id,this.component.text||"")},this._handleHover=()=>{this.inFocusedState=!0},this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover)}styles(){const t=Ys("active",this.component),n=Ys("inactive",this.component);return e.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Vs({...n,...this.component},this.scaleFactor,this.inFocusedState)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${Ks({...t,...this.component},this.scaleFactor)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}render(){const{focusedBorderColor:t,focusedFillColor:n,fillColor:i}=this.component;!t&&od(i,n)||(this.tabIndex=0);const a=this.component.id===Do.state.currentGroupId;return this.classList.toggle("active",a),e.html`<input type="radio" id="${this.component.text}" name="${this.component.text}" value="${this.component.text}" checked="${a}" />
|
|
59
|
+
</nami-text-list-item-wrapper>`:null));return e.html`${s}`}};o([fs({type:Object})],Ww.prototype,"component",void 0),o([fs({type:Boolean})],Ww.prototype,"inFocusedState",void 0),o([fs({type:Number})],Ww.prototype,"scaleFactor",void 0),Ww=o([Uo("nami-text-list")],Ww);let Nw=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this.addEventListener("focus",(()=>{this.inFocusedState=!0}),!1),this.addEventListener("blur",(()=>{this.inFocusedState=!1}),!1),this.addEventListener("focus-changed",(e=>{this.inFocusedState=1==e.detail.inFocusedState}),!1)}styles(){const{component:t,inFocusedState:n,scaleFactor:i}=this,a=t.fillImage?e.unsafeCSS(`\n line-height: 1.5715;\n background-image: url(${t.fillImage});\n background-position: center;\n background-repeat: no-repeat;\n background-size: cover;\n height: 100%;\n width: 100%;\n `):e.unsafeCSS(Is(t,n));return e.unsafeCSS(`\n :host {\n display: ${t.hidden?"none":"flex"};\n gap: ${t.spacing}px;\n ${a};\n ${Xs(t.position)}\n ${_s(t)}\n ${Gs(t,i,n)}\n ${Rs(this.component)} \n }\n `)}render(){return(this.component.components??[]).map((e=>sd(e,this.scaleFactor)))}};o([fs({type:Object})],Nw.prototype,"component",void 0),o([fs({type:Boolean})],Nw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Nw.prototype,"scaleFactor",void 0),Nw=o([Uo("nami-container")],Nw);let Ow=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1}styles(){const t="vertical"===this.component.direction,n=t?"width":"height",i=t?"margin-top":"margin-left",a=this.component.fillImage?e.unsafeCSS(`\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 `):e.unsafeCSS(Is(this.component,this.inFocusedState));return e.unsafeCSS(`\n :host {\n opacity: 0;\n display: ${this.component.hidden?"none":"flex"};\n ${a};\n ${Xs(this.component.position)}\n ${_s(this.component)}\n ${Gs(this.component,this.scaleFactor,this.inFocusedState)}\n ${Rs(this.component)} \n transition: transform .5s ease-in;\n }\n :host > * {\n ${n}: 100%;\n }\n :host > :not(:first-child) {\n ${i}: ${this.component.spacing||0}px;\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 `)}updated(){const{currentGroupId:e}=Do.state;Ma(e,this.currentGroupId)||(this.classList.remove("fade-in"),setTimeout((()=>this.classList.add("fade-in")),100),this.currentGroupId=e)}render(){const{mediaList:e,selectedPaywall:t,currentGroupId:n,formFactor:i}=Do.state;return Qs(So(Do.productDetails,t?.sku_menus||[],this.component?.subsetGroup||n),this.component,e).map((([e,t])=>(this.inFocusedState="television"==i?e:this.inFocusedState,t.map((e=>sd(e,this.scaleFactor,this.inFocusedState))))))}};o([fs({type:Object})],Ow.prototype,"component",void 0),o([fs({type:Boolean})],Ow.prototype,"inFocusedState",void 0),o([fs({type:Number})],Ow.prototype,"scaleFactor",void 0),Ow=o([Uo("nami-product-container")],Ow);let Fw=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1}styles(){const{url:t,imageCropping:n,alignment:i,height:a,width:r,rightMargin:o,spacing:s}=this.component,d="fit"===n;return e.unsafeCSS(`\n :host {\n box-sizing: border-box;\n position: relative;\n transition: all 0.3s;\n background-image: url(${t});\n background-size: ${d?"contain":"cover"};\n background-position: ${i||""} center;\n background-repeat: no-repeat;\n height: ${Ls(a??"100%",this.scaleFactor)};\n width: ${Ls(("fitContent"==r?a:r)??"100%",this.scaleFactor)};\n margin-right: ${o||s||0}px;\n ${Ns(this.component,this.scaleFactor)}\n ${this.component.hidden?"display:none":""}\n }\n `)}render(){const{focusedBorderColor:t,focusedFillColor:n,fillColor:i}=this.component;return!t&&od(i,n)||(this.tabIndex=0),e.html``}};o([fs({type:Object})],Fw.prototype,"component",void 0),o([fs({type:Boolean})],Fw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Fw.prototype,"scaleFactor",void 0),Fw=o([Uo("nami-image")],Fw);let jw=class extends gs{constructor(){super(...arguments),this.fullscreen=!1,this.inFocusedState=!1,this.scaleFactor=1}styles(){const{inFocusedState:t,component:n,scaleFactor:i}=this;return e.unsafeCSS(`\n :host {\n display: ${n.hidden?"none":"flex"};\n flex-direction: column;\n overflow: hidden;\n ${Rs(n)}\n position: absolute;\n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${n.zIndex??1};\n top: 0px;\n ${Is(n,t)}\n transition: all 0.3s;\n ${Ns(n,i)}\n }\n `)}updated(){const e=Array.from(document.getElementsByTagName("nami-paywall")),t=this.component.fillColor?.includes("gradient"),n=this.shadowRoot?.innerHTML.includes("nami-image");e[0].style.position=!n||t?"relative":"",e[0].style.minHeight=!n||t?"100vh":"100%"}render(){return(this.component.components??[]).map((e=>sd(e,this.scaleFactor)))}};o([fs({type:Object})],jw.prototype,"component",void 0),o([fs({type:Boolean})],jw.prototype,"fullscreen",void 0),o([fs({type:Boolean})],jw.prototype,"inFocusedState",void 0),o([fs({type:Number})],jw.prototype,"scaleFactor",void 0),jw=o([Uo("nami-background-container")],jw);let zw=class extends gs{constructor(){super(...arguments),this.zIndex=2,this.inFocusedState=!1,this.scaleFactor=1}styles(){const{contextConsumer:t,component:n,zIndex:i,scaleFactor:a,inFocusedState:r}=this,{formFactor:o}=t.state,s="phone"!==o?"width: 100%;":"",d="100%"==n.height?"height:100vh !important;":"",l=n.spacing??0;return e.unsafeCSS(`\n :host {\n display: ${n.hidden?"none":"flex"};\n gap: ${l}px;\n position: relative;\n ${_s(n)}\n ${zs(n,a)}\n ${s}\n ${d}\n ${Rs(n)}\n z-index: ${i};\n transition: all 0.3s;\n overflow-y: 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 ${Ns(n,a)}\n ${Is(n,r)}\n }\n :host > * {\n width: 100%;\n }\n \n :host > *:not(:first-child) {\n ${"vertical"===n.direction?`margin-top: ${l}px;`:`margin-left: ${l}px;`}\n `)}firstUpdated(){const e=new CustomEvent("child-spacing",{detail:{spacing:this.component.spacing},bubbles:!0,composed:!0});this.dispatchEvent(e)}render(){return this.component.components?.map((e=>sd(e,this.scaleFactor,this.inFocusedState)))||[]}};o([fs({type:Object})],zw.prototype,"component",void 0),o([fs({type:Number})],zw.prototype,"zIndex",void 0),o([fs({type:Boolean})],zw.prototype,"inFocusedState",void 0),o([fs({type:Number})],zw.prototype,"scaleFactor",void 0),zw=o([Uo("nami-content-container")],zw);let $w=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this._handleClick=()=>{Wd(this.component.onTap)},this.addEventListener("click",this._handleClick)}styles(){const t=Ys("active",this.component.components[0]);return e.unsafeCSS(`\n :host {\n cursor: pointer;\n ${Is(this.component,this.inFocusedState)}\n ${Gs(this.component,this.scaleFactor,this.inFocusedState)}\n ${this.component.hidden?"display:none":""}\n }\n\n .toggle{\n position: absolute !important;\n top: 0;\n bottom: 0;\n transition: transform .5s cubic-bezier(.77, 0, .175, 1);\n ${Vs(t,this.scaleFactor,this.inFocusedState)}\n }\n \n nami-segment-picker-item:nth-of-type(1).active~.toggle {\n transform: translateX(0%);\n }\n\n nami-segment-picker-item:nth-of-type(2).active~.toggle {\n transform: translateX(100%);\n }\n `)}render(){const t=this.component.components.map((e=>sd(e,this.scaleFactor,this.inFocusedState)));return e.html`${t}<div class="toggle"></div>`}};o([fs({type:Object})],$w.prototype,"component",void 0),o([fs({type:Boolean})],$w.prototype,"inFocusedState",void 0),o([fs({type:Number})],$w.prototype,"scaleFactor",void 0),$w=o([Uo("nami-segment-picker")],$w);let Hw=class extends gs{constructor(){super(),this.inFocusedState=!1,this.scaleFactor=1,this._handleClick=()=>{this.component.id&&Do.setCurrentGroupData(this.component.id,this.component.text||"")},this._handleHover=()=>{this.inFocusedState=!0},this.addEventListener("click",this._handleClick),this.addEventListener("mouseover",this._handleHover)}styles(){const t=Ys("active",this.component),n=Ys("inactive",this.component);return e.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"inline-flex"};\n position: relative;\n ${Vs({...n,...this.component},this.scaleFactor,this.inFocusedState)}\n }\n\n :host > * {\n cursor: pointer;\n }\n\n :host(.active) {\n z-index: 1 !important;\n ${Ks({...t,...this.component},this.scaleFactor)}\n }\n\n input {\n visibility: hidden;\n position: absolute;\n top: 0;\n }\n `)}render(){const{focusedBorderColor:t,focusedFillColor:n,fillColor:i}=this.component;!t&&od(i,n)||(this.tabIndex=0);const a=this.component.id===Do.state.currentGroupId;return this.classList.toggle("active",a),e.html`<input type="radio" id="${this.component.text}" name="${this.component.text}" value="${this.component.text}" checked="${a}" />
|
|
60
60
|
<label for="${this.component.text}">${this.component.text}</label>`}};function Uw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}o([fs({type:Object})],Hw.prototype,"component",void 0),o([fs({type:Boolean})],Hw.prototype,"inFocusedState",void 0),o([fs({type:Number})],Hw.prototype,"scaleFactor",void 0),Hw=o([Uo("nami-segment-picker-item")],Hw);var Bw,Gw,Xw,Yw,Vw,Kw={exports:{}};Bw=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,Gw=/^(?=([^\/?#]*))\1([^]*)$/,Xw=/(?:\/|^)\.(?=\/)/g,Yw=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g;var qw=Kw.exports=Vw={buildAbsoluteURL:function(e,t,n){if(n=n||{},e=e.trim(),!(t=t.trim())){if(!n.alwaysNormalize)return e;var i=Vw.parseURL(e);if(!i)throw new Error("Error trying to parse base URL.");return i.path=Vw.normalizePath(i.path),Vw.buildURLFromParts(i)}var a=Vw.parseURL(t);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return n.alwaysNormalize?(a.path=Vw.normalizePath(a.path),Vw.buildURLFromParts(a)):t;var r=Vw.parseURL(e);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){var o=Gw.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 d=r.path,l=d.substring(0,d.lastIndexOf("/")+1)+a.path;s.path=Vw.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=n.alwaysNormalize?Vw.normalizePath(a.path):a.path),Vw.buildURLFromParts(s)},parseURL:function(e){var t=Bw.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(Xw,"");e.length!==(e=e.replace(Yw,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}};function Jw(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function Qw(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jw(Object(n),!0).forEach((function(t){ek(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jw(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Zw(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function ek(e,t,n){return(t=Zw(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tk(){return tk=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},tk.apply(this,arguments)}const nk=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},ik=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=ak},ak=Number.MAX_SAFE_INTEGER||9007199254740991;let rk=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",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.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.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_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}({}),ok=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}({}),sk=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.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.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.UNKNOWN="unknown",e}({});const dk=function(){},lk={trace:dk,debug:dk,log:dk,warn:dk,info:dk,error:dk};let uk=lk;function ck(e,...t){t.forEach((function(t){uk[t]=e[t]?e[t].bind(e):function(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):dk}(t)}))}const hk=uk,mk=/^(\d+)x(\d+)$/,fk=/(.+?)=(".*?"|.*?)(?:,|$)/g;class gk{constructor(e){"string"==typeof e&&(e=gk.parseAttrList(e)),tk(this,e)}get clientAttrs(){return Object.keys(this).filter((e=>"X-"===e.substring(0,2)))}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const n=new Uint8Array(t.length/2);for(let e=0;e<t.length/2;e++)n[e]=parseInt(t.slice(2*e,2*e+2),16);return n}return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const n=this[e];return n?parseFloat(n):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=mk.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const n={};for(fk.lastIndex=0;null!==(t=fk.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1));n[t[1].trim()]=e}return n}}function pk(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class vk{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const n=t.attr;for(const t in n)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==n[t]){hk.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=tk(new gk({}),n,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);nk(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(nk(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&nk(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class yk{constructor(){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}}}var bk="audio",wk="video",kk="audiovideo";class Sk{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[bk]:null,[wk]:null,[kk]:null},this.baseurl=e}setByteRange(e,t){const n=e.split("@",2);let i;i=1===n.length?(null==t?void 0:t.byteRangeEndOffset)||0:parseInt(n[1]),this._byteRange=[i,parseInt(n[0])+i]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=qw.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Mk extends Sk{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new yk,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!nk(this.programDateTime))return null;const e=nk(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,n,i,a,r=!1){const{elementaryStreams:o}=this,s=o[e];s?(s.startPTS=Math.min(s.startPTS,t),s.endPTS=Math.max(s.endPTS,n),s.startDTS=Math.min(s.startDTS,i),s.endDTS=Math.max(s.endDTS,a)):o[e]={startPTS:t,endPTS:n,startDTS:i,endDTS:a,partial:r}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[bk]=null,e[wk]=null,e[kk]=null}}class Tk extends Sk{constructor(e,t,n,i,a){super(n),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new yk,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const r=e.enumeratedString("BYTERANGE");r&&this.setByteRange(r,a),a&&(this.fragOffset=a.fragOffset+a.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}class Ek{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.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.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,n=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!n||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&n>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&nk(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;if(e>0){return 1e3*(this.driftEnd-this.driftStart)/e}return 1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Pk(e){return Uint8Array.from(atob(e),(e=>e.charCodeAt(0)))}function Ak(e){const t=e.split(":");let n=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],a=i[1];t?(e.splice(-1,1),n=Pk(a)):n=function(e){const t=xk(e).subarray(0,16),n=new Uint8Array(16);return n.set(t,16-t.length),n}(a)}}return n}function xk(e){return Uint8Array.from(unescape(encodeURIComponent(e)),(e=>e.charCodeAt(0)))}const Ck="undefined"!=typeof self?self:void 0;var Lk={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Dk="org.w3.clearkey",Ik="com.apple.streamingkeydelivery",_k="com.microsoft.playready",Rk="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Wk(e){switch(e){case Ik:return Lk.FAIRPLAY;case _k:return Lk.PLAYREADY;case Rk:return Lk.WIDEVINE;case Dk:return Lk.CLEARKEY}}var Nk="1077efecc0b24d02ace33c1e52e2fb4b",Ok="e2719d58a985b3c9781ab030af78d30e",Fk="9a04f07998404286ab92e65be0885f95",jk="edef8ba979d64acea3c827dcd51d21ed";function zk(e){return e===jk?Lk.WIDEVINE:e===Fk?Lk.PLAYREADY:e===Nk||e===Ok?Lk.CLEARKEY:void 0}function $k(e){switch(e){case Lk.FAIRPLAY:return Ik;case Lk.PLAYREADY:return _k;case Lk.WIDEVINE:return Rk;case Lk.CLEARKEY:return Dk}}function Hk(e){const{drmSystems:t,widevineLicenseUrl:n}=e,i=t?[Lk.FAIRPLAY,Lk.WIDEVINE,Lk.PLAYREADY,Lk.CLEARKEY].filter((e=>!!t[e])):[];return!i[Lk.WIDEVINE]&&n&&i.push(Lk.WIDEVINE),i}const Uk=null!=Ck&&null!=(Bk=Ck.navigator)&&Bk.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var Bk;function Gk(e,t,n){return Uint8Array.prototype.slice?e.slice(t,n):new Uint8Array(Array.prototype.slice.call(e,t,n))}const Xk=(e,t)=>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,Yk=(e,t)=>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,Vk=(e,t)=>{const n=t;let i=0;for(;Xk(e,t);){i+=10;i+=Kk(e,t+6),Yk(e,t+10)&&(i+=10),t+=i}if(i>0)return e.subarray(n,n+i)},Kk=(e,t)=>{let n=0;return n=(127&e[t])<<21,n|=(127&e[t+1])<<14,n|=(127&e[t+2])<<7,n|=127&e[t+3],n},qk=(e,t)=>Xk(e,t)&&Kk(e,t+6)+10<=e.length-t,Jk=e=>{const t=eS(e);for(let e=0;e<t.length;e++){const n=t[e];if(Qk(n))return rS(n)}},Qk=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,Zk=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),n=Kk(e,4);return{type:t,size:n,data:e.subarray(10,10+n)}},eS=e=>{let t=0;const n=[];for(;Xk(e,t);){const i=Kk(e,t+6);t+=10;const a=t+i;for(;t+8<a;){const i=Zk(e.subarray(t)),a=tS(i);a&&n.push(a),t+=i.size+10}Yk(e,t)&&(t+=10)}return n},tS=e=>"PRIV"===e.type?nS(e):"W"===e.type[0]?aS(e):iS(e),nS=e=>{if(e.size<2)return;const t=oS(e.data,!0),n=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:n.buffer}},iS=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const n=oS(e.data.subarray(t),!0);t+=n.length+1;const i=oS(e.data.subarray(t));return{key:e.type,info:n,data:i}}const t=oS(e.data.subarray(1));return{key:e.type,data:t}},aS=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const n=oS(e.data.subarray(t),!0);t+=n.length+1;const i=oS(e.data.subarray(t));return{key:e.type,info:n,data:i}}const t=oS(e.data);return{key:e.type,data:t}},rS=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),n=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,n&&(i+=47721858.84),Math.round(i)}},oS=(e,t=!1)=>{const n=dS();if(n){const i=n.decode(e);if(t){const e=i.indexOf("\0");return-1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}const i=e.length;let a,r,o,s="",d=0;for(;d<i;){if(a=e[d++],0===a&&t)return s;if(0!==a&&3!==a)switch(a>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:s+=String.fromCharCode(a);break;case 12:case 13:r=e[d++],s+=String.fromCharCode((31&a)<<6|63&r);break;case 14:r=e[d++],o=e[d++],s+=String.fromCharCode((15&a)<<12|(63&r)<<6|63&o)}}return s};let sS;function dS(){if(!navigator.userAgent.includes("PlayStation 4"))return sS||void 0===self.TextDecoder||(sS=new self.TextDecoder("utf-8")),sS}const lS={hexDump:function(e){let t="";for(let n=0;n<e.length;n++){let i=e[n].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},uS=Math.pow(2,32)-1,cS=[].push,hS={video:1,audio:2,id3:3,text:4};function mS(e){return String.fromCharCode.apply(null,e)}function fS(e,t){const n=e[t]<<8|e[t+1];return n<0?65536+n:n}function gS(e,t){const n=vS(e,t);return n<0?4294967296+n:n}function pS(e,t){let n=gS(e,t);return n*=Math.pow(2,32),n+=gS(e,t+4),n}function vS(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function yS(e,t,n){e[t]=n>>24,e[t+1]=n>>16&255,e[t+2]=n>>8&255,e[t+3]=255&n}function bS(e,t){const n=[];if(!t.length)return n;const i=e.byteLength;for(let a=0;a<i;){const r=gS(e,a),o=r>1?a+r:i;if(mS(e.subarray(a+4,a+8))===t[0])if(1===t.length)n.push(e.subarray(a+8,o));else{const i=bS(e.subarray(a+8,o),t.slice(1));i.length&&cS.apply(n,i)}a=o}return n}function wS(e){const t=[],n=e[0];let i=8;const a=gS(e,i);i+=4;let r=0,o=0;0===n?(r=gS(e,i),o=gS(e,i+4),i+=8):(r=pS(e,i),o=pS(e,i+8),i+=16),i+=2;let s=e.length+o;const d=fS(e,i);i+=2;for(let n=0;n<d;n++){let n=i;const r=gS(e,n);n+=4;const o=2147483647&r;if(1===(2147483648&r)>>>31)return hk.warn("SIDX has hierarchical references (not supported)"),null;const d=gS(e,n);n+=4,t.push({referenceSize:o,subsegmentDuration:d,info:{duration:d/a,start:s,end:s+o-1}}),s+=o,n+=4,i=n}return{earliestPresentationTime:r,timescale:a,version:n,referencesCount:d,references:t}}function kS(e){const t=[],n=bS(e,["moov","trak"]);for(let e=0;e<n.length;e++){const i=n[e],a=bS(i,["tkhd"])[0];if(a){let e=a[0];const n=gS(a,0===e?12:20),r=bS(i,["mdia","mdhd"])[0];if(r){e=r[0];const a=gS(r,0===e?12:20),o=bS(i,["mdia","hdlr"])[0];if(o){const e=mS(o.subarray(8,12)),r={soun:bk,vide:wk}[e];if(r){const e=SS(bS(i,["mdia","minf","stbl","stsd"])[0]);t[n]={timescale:a,type:r},t[r]=Qw({timescale:a,id:n},e)}}}}}return bS(e,["moov","mvex","trex"]).forEach((e=>{const n=gS(e,4),i=t[n];i&&(i.default={duration:gS(e,12),flags:gS(e,20)})})),t}function SS(e){const t=e.subarray(8),n=t.subarray(86),i=mS(t.subarray(4,8));let a=i;const r="enca"===i||"encv"===i;if(r){const e=bS(t,[i])[0];bS(e.subarray("enca"===i?28:78),["sinf"]).forEach((e=>{const t=bS(e,["schm"])[0];if(t){const n=mS(t.subarray(4,8));if("cbcs"===n||"cenc"===n){const t=bS(e,["frma"])[0];t&&(a=mS(t))}}}))}switch(a){case"avc1":case"avc2":case"avc3":case"avc4":{const e=bS(n,["avcC"])[0];a+="."+TS(e[1])+TS(e[2])+TS(e[3]);break}case"mp4a":{const e=bS(t,[i])[0],n=bS(e.subarray(28),["esds"])[0];if(n&&n.length>12){let e=4;if(3!==n[e++])break;e=MS(n,e),e+=2;const t=n[e++];if(128&t&&(e+=2),64&t&&(e+=n[e++]),4!==n[e++])break;e=MS(n,e);const i=n[e++];if(64!==i)break;if(a+="."+TS(i),e+=12,5!==n[e++])break;e=MS(n,e);const r=n[e++];let o=(248&r)>>3;31===o&&(o+=1+((7&r)<<3)+((224&n[e])>>5)),a+="."+o}break}case"hvc1":case"hev1":{const e=bS(n,["hvcC"])[0],t=e[1],i=["","A","B","C"][t>>6],r=31&t,o=gS(e,2),s=(32&t)>>5?"H":"L",d=e[12],l=e.subarray(6,12);a+="."+i+r,a+="."+o.toString(16).toUpperCase(),a+="."+s+d;let u="";for(let e=l.length;e--;){const t=l[e];if(t||u){u="."+t.toString(16).toUpperCase()+u}}a+=u;break}case"dvh1":case"dvhe":{const e=bS(n,["dvcC"])[0],t=e[2]>>1&127,i=e[2]<<5&32|e[3]>>3&31;a+="."+ES(t)+"."+ES(i);break}case"vp09":{const e=bS(n,["vpcC"])[0],t=e[4],i=e[5],r=e[6]>>4&15;a+="."+ES(t)+"."+ES(i)+"."+ES(r);break}case"av01":{const e=bS(n,["av1C"])[0],t=e[1]>>>5,i=31&e[1],r=e[2]>>>7?"H":"M",o=(64&e[2])>>6,s=(32&e[2])>>5,d=2===t&&o?s?12:10:o?10:8,l=(16&e[2])>>4,u=(8&e[2])>>3,c=(4&e[2])>>2,h=3&e[2],m=1,f=1,g=1,p=0;a+="."+t+"."+ES(i)+r+"."+ES(d)+"."+l+"."+u+c+h+"."+ES(m)+"."+ES(f)+"."+ES(g)+"."+p;break}}return{codec:a,encrypted:r}}function MS(e,t){const n=t+5;for(;128&e[t++]&&t<n;);return t}function TS(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function ES(e){return(e<10?"0":"")+e}function PS(e){const t=bS(e,["schm"])[0];if(t){const n=mS(t.subarray(4,8));if("cbcs"===n||"cenc"===n)return bS(e,["schi","tenc"])[0]}return null}function AS(e){const t=gS(e,0);let n=8;1&t&&(n+=4),4&t&&(n+=4);let i=0;const a=gS(e,4);for(let r=0;r<a;r++){if(256&t){i+=gS(e,n),n+=4}512&t&&(n+=4),1024&t&&(n+=4),2048&t&&(n+=4)}return i}function xS(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function CS(e,t){const n=[],i=t.samples,a=t.timescale,r=t.id;let o=!1;return bS(i,["moof"]).map((s=>{const d=s.byteOffset-8;bS(s,["traf"]).map((s=>{const l=bS(s,["tfdt"]).map((e=>{const t=e[0];let n=gS(e,4);return 1===t&&(n*=Math.pow(2,32),n+=gS(e,8)),n/a}))[0];return void 0!==l&&(e=l),bS(s,["tfhd"]).map((l=>{const u=gS(l,4),c=16777215&gS(l,0);let h=0;const m=!!(16&c);let f=0;const g=!!(32&c);let p=8;u===r&&(!!(1&c)&&(p+=8),!!(2&c)&&(p+=4),!!(8&c)&&(h=gS(l,p),p+=4),m&&(f=gS(l,p),p+=4),g&&(p+=4),"video"===t.type&&(o=function(e){if(!e)return!1;const t=e.indexOf("."),n=t<0?e:e.substring(0,t);return"hvc1"===n||"hev1"===n||"dvh1"===n||"dvhe"===n}(t.codec)),bS(s,["trun"]).map((r=>{const s=r[0],l=16777215&gS(r,0),u=!!(1&l);let c=0;const m=!!(4&l),g=!!(256&l);let p=0;const v=!!(512&l);let y=0;const b=!!(1024&l),w=!!(2048&l);let k=0;const S=gS(r,4);let M=8;u&&(c=gS(r,M),M+=4),m&&(M+=4);let T=c+d;for(let d=0;d<S;d++){if(g?(p=gS(r,M),M+=4):p=h,v?(y=gS(r,M),M+=4):y=f,b&&(M+=4),w&&(k=0===s?gS(r,M):vS(r,M),M+=4),t.type===wk){let t=0;for(;t<y;){const r=gS(i,T);if(T+=4,LS(o,i[T])){DS(i.subarray(T,T+r),o?2:1,e+k/a,n)}T+=r,t+=r+4}}e+=p/a}})))}))}))})),n}function LS(e,t){if(e){const e=t>>1&63;return 39===e||40===e}return 6===(31&t)}function DS(e,t,n,i){const a=IS(e);let r=0;r+=t;let o=0,s=0,d=0;for(;r<a.length;){o=0;do{if(r>=a.length)break;d=a[r++],o+=d}while(255===d);s=0;do{if(r>=a.length)break;d=a[r++],s+=d}while(255===d);const e=a.length-r;let t=r;if(s<e)r+=s;else if(s>e){hk.error(`Malformed SEI payload. ${s} is too small, only ${e} bytes left to parse.`);break}if(4===o){if(181===a[t++]){const e=fS(a,t);if(t+=2,49===e){const e=gS(a,t);if(t+=4,1195456820===e){const e=a[t++];if(3===e){const r=a[t++],s=64&r,d=s?2+3*(31&r):0,l=new Uint8Array(d);if(s){l[0]=r;for(let e=1;e<d;e++)l[e]=a[t++]}i.push({type:e,payloadType:o,pts:n,bytes:l})}}}}}else if(5===o&&s>16){const e=[];for(let n=0;n<16;n++){const i=a[t++].toString(16);e.push(1==i.length?"0"+i:i),3!==n&&5!==n&&7!==n&&9!==n||e.push("-")}const r=s-16,d=new Uint8Array(r);for(let e=0;e<r;e++)d[e]=a[t++];i.push({payloadType:o,pts:n,uuid:e.join(""),userData:oS(d),userDataBytes:d})}}}function IS(e){const t=e.byteLength,n=[];let i=1;for(;i<t-2;)0===e[i]&&0===e[i+1]&&3===e[i+2]?(n.push(i+2),i+=2):i++;if(0===n.length)return e;const a=t-n.length,r=new Uint8Array(a);let o=0;for(i=0;i<a;o++,i++)o===n[0]&&(o++,n.shift()),r[i]=e[o];return r}function _S(e,t,n){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,a,r;i=0,a=new Uint8Array,r=new Uint8Array;const o=new Uint8Array(4);return n&&n.byteLength>0&&new DataView(o.buffer).setUint32(0,n.byteLength,!1),function(e,...t){const n=t.length;let i=8,a=n;for(;a--;)i+=t[a].byteLength;const 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),a=0,i=8;a<n;a++)r.set(t[a],i),i+=t[a].byteLength;return r}([112,115,115,104],new Uint8Array([0,0,0,0]),e,r,a,o,n||new Uint8Array)}function RS(e){const t=e.getUint32(0),n=e.byteOffset,i=e.byteLength;if(i<t)return{offset:n,size:i};if(1886614376!==e.getUint32(4))return{offset:n,size:t};const a=e.getUint32(8)>>>24;if(0!==a&&1!==a)return{offset:n,size:t};const r=e.buffer,o=lS.hexDump(new Uint8Array(r,n+12,16)),s=e.getUint32(28);let d=null,l=null;if(0===a){if(t-32<s||s<22)return{offset:n,size:t};l=new Uint8Array(r,n+32,s)}else if(1===a){if(!s||i<n+32+16*s+16)return{offset:n,size:t};d=[];for(let e=0;e<s;e++)d.push(new Uint8Array(r,n+32+16*e,16))}return{version:a,systemId:o,kids:d,data:l,offset:n,size:t}}let WS={};class NS{static clearKeyUriToKeyIdMap(){WS={}}constructor(e,t,n,i=[1],a=null){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=e,this.uri=t,this.keyFormat=n,this.keyFormatVersions=i,this.iv=a,this.encrypted=!!e&&"NONE"!==e,this.isCommonEncryption=this.encrypted&&"AES-128"!==e}isSupported(){if(this.method){if("AES-128"===this.method||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case Ik:case Rk:case _k:case Dk:return-1!==["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if("AES-128"===this.method&&this.uri&&!this.iv){"number"!=typeof e&&("AES-128"!==this.method||this.iv||hk.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const t=function(e){const t=new Uint8Array(16);for(let n=12;n<16;n++)t[n]=e>>8*(15-n)&255;return t}(e);return new NS(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=Ak(this.uri);if(t)switch(this.keyFormat){case Rk:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case _k:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=_S(e,0,t);const n=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),i=String.fromCharCode.apply(null,Array.from(n)),a=i.substring(i.indexOf("<"),i.length),r=(new DOMParser).parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(r){const e=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(e){const t=Pk(e).subarray(0,16);!function(e){const t=function(e,t,n){const i=e[t];e[t]=e[n],e[n]=i};t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}(t),this.keyId=t}}break}default:{let e=t.subarray(0,16);if(16!==e.length){const t=new Uint8Array(16);t.set(e,16-e.length),e=t}this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=WS[this.uri];if(!e){const t=Object.keys(WS).length%Number.MAX_SAFE_INTEGER;e=new Uint8Array(16);new DataView(e.buffer,12,4).setUint32(0,t),WS[this.uri]=e}this.keyId=e}return this}}const OS=/\{\$([a-zA-Z0-9-_]+)\}/g;function FS(e){return OS.test(e)}function jS(e,t,n){if(null!==e.variableList||e.hasVariableRefs)for(let i=n.length;i--;){const a=n[i],r=t[a];r&&(t[a]=zS(e,r))}}function zS(e,t){if(null!==e.variableList||e.hasVariableRefs){const n=e.variableList;return t.replace(OS,(t=>{const i=t.substring(2,t.length-1),a=null==n?void 0:n[i];return void 0===a?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):a}))}return t}function $S(e,t,n){let i,a,r=e.variableList;if(r||(e.variableList=r={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(n).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${n}"`);a=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,a=t.VALUE;i in r?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):r[i]=a||""}function HS(e,t,n){const i=t.IMPORT;if(n&&i in n){let t=e.variableList;t||(e.variableList=t={}),t[i]=n[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function US(e=!0){if("undefined"==typeof self)return;return(e||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}const BS={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,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 GS(e,t,n=!0){return!e.split(",").some((e=>!XS(e,t,n)))}function XS(e,t,n=!0){var i;const a=US(n);return null!=(i=null==a?void 0:a.isTypeSupported(YS(e,t)))&&i}function YS(e,t){return`${t}/mp4;codecs="${e}"`}function VS(e){if(e){const t=e.substring(0,4);return BS.video[t]}return 2}function KS(e){return e.split(",").reduce(((e,t)=>{const n=BS.video[t];return n?(2*n+e)/(e?3:2):(BS.audio[t]+e)/(e?2:1)}),0)}const qS={};const JS=/flac|opus/i;function QS(e,t=!0){return e.replace(JS,(e=>function(e,t=!0){if(qS[e])return qS[e];const n={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[e];for(let i=0;i<n.length;i++)if(XS(n[i],"audio",t))return qS[e]=n[i],n[i];return e}(e.toLowerCase(),t)))}function ZS(e,t){return e&&"mp4a"!==e?e:t?t.split(",")[0]:t}const eM=/#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,tM=/#EXT-X-MEDIA:(.*)/g,nM=/^#EXT(?:INF|-X-TARGETDURATION):/m,iM=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),aM=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(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("|"));class rM{static findGroup(e,t){for(let n=0;n<e.length;n++){const i=e[n];if(i.id===t)return i}}static resolve(e,t){return qw.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return nM.test(e)}static parseMasterPlaylist(e,t){const n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:FS(e)},i=[];let a;for(eM.lastIndex=0;null!=(a=eM.exec(e));)if(a[1]){var r;const e=new gk(a[1]);jS(n,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const o=zS(n,a[2]),s={attrs:e,bitrate:e.decimalInteger("BANDWIDTH")||e.decimalInteger("AVERAGE-BANDWIDTH"),name:e.NAME,url:rM.resolve(o,t)},d=e.decimalResolution("RESOLUTION");d&&(s.width=d.width,s.height=d.height),dM(e.CODECS,s),null!=(r=s.unknownCodecs)&&r.length||i.push(s),n.levels.push(s)}else if(a[3]){const e=a[3],i=a[4];switch(e){case"SESSION-DATA":{const e=new gk(i);jS(n,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[t]=e);break}case"SESSION-KEY":{const e=oM(i,t,n);e.encrypted&&e.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(e)):hk.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const e=new gk(i);jS(n,e,["NAME","VALUE","QUERYPARAM"]),$S(n,e,t)}break;case"CONTENT-STEERING":{const e=new gk(i);jS(n,e,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:rM.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":n.startTimeOffset=sM(i)}}const o=i.length>0&&i.length<n.levels.length;return n.levels=o?i:n.levels,0===n.levels.length&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,n){let i;const a={},r=n.levels,o={AUDIO:r.map((e=>({id:e.attrs.AUDIO,audioCodec:e.audioCodec}))),SUBTITLES:r.map((e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec}))),"CLOSED-CAPTIONS":[]};let s=0;for(tM.lastIndex=0;null!==(i=tM.exec(e));){const e=new gk(i[1]),r=e.TYPE;if(r){const i=o[r],d=a[r]||[];a[r]=d,jS(n,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const l=e.LANGUAGE,u=e["ASSOC-LANGUAGE"],c=e.CHANNELS,h=e.CHARACTERISTICS,m=e["INSTREAM-ID"],f={attrs:e,bitrate:0,id:s++,groupId:e["GROUP-ID"]||"",name:e.NAME||l||"",type:r,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:l,url:e.URI?rM.resolve(e.URI,t):""};if(u&&(f.assocLang=u),c&&(f.channels=c),h&&(f.characteristics=h),m&&(f.instreamId=m),null!=i&&i.length){const e=rM.findGroup(i,f.groupId)||i[0];lM(f,e,"audioCodec"),lM(f,e,"textCodec")}d.push(f)}}return a}static parseLevelPlaylist(e,t,n,i,a,r){const o=new Ek(t),s=o.fragments;let d,l,u,c=null,h=0,m=0,f=0,g=0,p=null,v=new Mk(i,t),y=-1,b=!1,w=null;for(iM.lastIndex=0,o.m3u8=e,o.hasVariableRefs=FS(e);null!==(d=iM.exec(e));){b&&(b=!1,v=new Mk(i,t),v.start=f,v.sn=h,v.cc=g,v.level=n,c&&(v.initSegment=c,v.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null,w&&(v.setByteRange(w),w=null)));const e=d[1];if(e){v.duration=parseFloat(e);const t=(" "+d[2]).slice(1);v.title=t||null,v.tagList.push(t?["INF",e,t]:["INF",e])}else if(d[3]){if(nk(v.duration)){v.start=f,u&&hM(v,u,o),v.sn=h,v.level=n,v.cc=g,s.push(v);const e=(" "+d[3]).slice(1);v.relurl=zS(o,e),uM(v,p),p=v,f+=v.duration,h++,m=0,b=!0}}else if(d[4]){const e=(" "+d[4]).slice(1);p?v.setByteRange(e,p):v.setByteRange(e)}else if(d[5])v.rawProgramDateTime=(" "+d[5]).slice(1),v.tagList.push(["PROGRAM-DATE-TIME",v.rawProgramDateTime]),-1===y&&(y=s.length);else{if(d=d[0].match(aM),!d){hk.warn("No matches on slow regex match for level playlist!");continue}for(l=1;l<d.length&&void 0===d[l];l++);const e=(" "+d[l]).slice(1),a=(" "+d[l+1]).slice(1),f=d[l+2]?(" "+d[l+2]).slice(1):"";switch(e){case"PLAYLIST-TYPE":o.type=a.toUpperCase();break;case"MEDIA-SEQUENCE":h=o.startSN=parseInt(a);break;case"SKIP":{const e=new gk(a);jS(o,e,["RECENTLY-REMOVED-DATERANGES"]);const t=e.decimalInteger("SKIPPED-SEGMENTS");if(nk(t)){o.skippedSegments=t;for(let e=t;e--;)s.unshift(null);h+=t}const n=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");n&&(o.recentlyRemovedDateranges=n.split("\t"));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(a),1);break;case"VERSION":o.version=parseInt(a);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(a||f)&&v.tagList.push(f?[a,f]:[a]);break;case"DISCONTINUITY":g++,v.tagList.push(["DIS"]);break;case"GAP":v.gap=!0,v.tagList.push([e]);break;case"BITRATE":v.tagList.push([e,a]);break;case"DATERANGE":{const e=new gk(a);jS(o,e,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),jS(o,e,e.clientAttrs);const t=new vk(e,o.dateRanges[e.ID]);t.isValid||o.skippedSegments?o.dateRanges[t.id]=t:hk.warn(`Ignoring invalid DATERANGE tag: "${a}"`),v.tagList.push(["EXT-X-DATERANGE",a]);break}case"DEFINE":{const e=new gk(a);jS(o,e,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in e?HS(o,e,r):$S(o,e,t)}break;case"DISCONTINUITY-SEQUENCE":g=parseInt(a);break;case"KEY":{const e=oM(a,t,o);if(e.isSupported()){if("NONE"===e.method){u=void 0;break}u||(u={}),u[e.keyFormat]&&(u=tk({},u)),u[e.keyFormat]=e}else hk.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${a}"`);break}case"START":o.startTimeOffset=sM(a);break;case"MAP":{const e=new gk(a);if(jS(o,e,["BYTERANGE","URI"]),v.duration){const a=new Mk(i,t);cM(a,e,n,u),c=a,v.initSegment=c,c.rawProgramDateTime&&!v.rawProgramDateTime&&(v.rawProgramDateTime=c.rawProgramDateTime)}else{const t=v.byteRangeEndOffset;if(t){const e=v.byteRangeStartOffset;w=`${t-e}@${e}`}else w=null;cM(v,e,n,u),c=v,b=!0}break}case"SERVER-CONTROL":{const e=new gk(a);o.canBlockReload=e.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=e.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&e.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),o.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new gk(a);o.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=o.partList;e||(e=o.partList=[]);const n=m>0?e[e.length-1]:void 0,i=m++,r=new gk(a);jS(o,r,["BYTERANGE","URI"]);const s=new Tk(r,v,t,i,n);e.push(s),v.duration+=s.duration;break}case"PRELOAD-HINT":{const e=new gk(a);jS(o,e,["URI"]),o.preloadHint=e;break}case"RENDITION-REPORT":{const e=new gk(a);jS(o,e,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(e);break}default:hk.warn(`line parsed but not handled: ${d}`)}}}p&&!p.relurl?(s.pop(),f-=p.duration,o.partList&&(o.fragmentHint=p)):o.partList&&(uM(v,p),v.cc=g,o.fragmentHint=v,u&&hM(v,u,o));const k=s.length,S=s[0],M=s[k-1];if(f+=o.skippedSegments*o.targetduration,f>0&&k&&M){o.averagetargetduration=f/k;const e=M.sn;o.endSN="initSegment"!==e?e:0,o.live||(M.endList=!0),S&&(o.startCC=S.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(f+=o.fragmentHint.duration),o.totalduration=f,o.endCC=g,y>0&&function(e,t){let n=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=n.programDateTime-1e3*t.duration,n=t}}(s,y),o}}function oM(e,t,n){var i,a;const r=new gk(e);jS(n,r,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=null!=(i=r.METHOD)?i:"",s=r.URI,d=r.hexadecimalInteger("IV"),l=r.KEYFORMATVERSIONS,u=null!=(a=r.KEYFORMAT)?a:"identity";s&&r.IV&&!d&&hk.error(`Invalid IV: ${r.IV}`);const c=s?rM.resolve(s,t):"",h=(l||"1").split("/").map(Number).filter(Number.isFinite);return new NS(o,c,u,h,d)}function sM(e){const t=new gk(e).decimalFloatingPoint("TIME-OFFSET");return nk(t)?t:null}function dM(e,t){let n=(e||"").split(/[ ,]+/).filter((e=>e));["video","audio","text"].forEach((e=>{const i=n.filter((t=>function(e,t){const n=BS[t];return!!n&&!!n[e.slice(0,4)]}(t,e)));i.length&&(t[`${e}Codec`]=i.join(","),n=n.filter((e=>-1===i.indexOf(e))))})),t.unknownCodecs=n}function lM(e,t,n){const i=t[n];i&&(e[n]=i)}function uM(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),nk(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function cM(e,t,n,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=n,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function hM(e,t,n){e.levelkeys=t;const{encryptedFragments:i}=n;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some((e=>t[e].isCommonEncryption))||i.push(e)}var mM="manifest",fM="level",gM="audioTrack",pM="subtitleTrack",vM="main",yM="audio",bM="subtitle";function wM(e){const{type:t}=e;switch(t){case gM:return yM;case pM:return bM;default:return vM}}function kM(e,t){let n=e.url;return void 0!==n&&0!==n.indexOf("data:")||(n=t.url),n}class SM{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.LEVEL_LOADING,this.onLevelLoading,this),e.on(rk.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(rk.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.LEVEL_LOADING,this.onLevelLoading,this),e.off(rk.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(rk.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,n=t.pLoader,i=t.loader,a=new(n||i)(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:n}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:mM,url:n,deliveryDirectives:null})}onLevelLoading(e,t){const{id:n,level:i,pathwayId:a,url:r,deliveryDirectives:o}=t;this.load({id:n,level:i,pathwayId:a,responseType:"text",type:fM,url:r,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:n,groupId:i,url:a,deliveryDirectives:r}=t;this.load({id:n,groupId:i,level:null,responseType:"text",type:gM,url:a,deliveryDirectives:r})}onSubtitleTrackLoading(e,t){const{id:n,groupId:i,url:a,deliveryDirectives:r}=t;this.load({id:n,groupId:i,level:null,responseType:"text",type:pM,url:a,deliveryDirectives:r})}load(e){var t;const n=this.hls.config;let i,a=this.getInternalLoader(e);if(a){const t=a.context;if(t&&t.url===e.url&&t.level===e.level)return void hk.trace("[playlist-loader]: playlist request ongoing");hk.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),a.abort()}if(i=e.type===mM?n.manifestLoadPolicy.default:tk({},n.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),a=this.createInternalLoader(e),nk(null==(t=e.deliveryDirectives)?void 0:t.part)){let t;if(e.type===fM&&null!==e.level?t=this.hls.levels[e.level].details:e.type===gM&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===pM&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,n=t.targetduration;if(e&&n){const t=1e3*Math.max(3*e,.8*n);i=tk({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const r=i.errorRetry||i.timeoutRetry||{},o={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:r.maxNumRetry||0,retryDelay:r.retryDelayMs||0,maxRetryDelay:r.maxRetryDelayMs||0},s={onSuccess:(e,t,n,i)=>{const a=this.getInternalLoader(n);this.resetInternalLoader(n.type);const r=e.data;0===r.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),rM.isMediaPlaylist(r)?this.handleTrackOrLevelPlaylist(e,t,n,i||null,a):this.handleMasterPlaylist(e,t,n,i)):this.handleManifestParsingError(e,n,new Error("no EXTM3U delimiter"),i||null,t)},onError:(e,t,n,i)=>{this.handleNetworkError(t,n,!1,e,i)},onTimeout:(e,t,n)=>{this.handleNetworkError(t,n,!0,void 0,e)}};a.load(e,o,s)}handleMasterPlaylist(e,t,n,i){const a=this.hls,r=e.data,o=kM(e,n),s=rM.parseMasterPlaylist(r,o);if(s.playlistParsingError)return void this.handleManifestParsingError(e,n,s.playlistParsingError,i,t);const{contentSteering:d,levels:l,sessionData:u,sessionKeys:c,startTimeOffset:h,variableList:m}=s;this.variableList=m;const{AUDIO:f=[],SUBTITLES:g,"CLOSED-CAPTIONS":p}=rM.parseMasterPlaylistMedia(r,o,s);if(f.length){f.some((e=>!e.url))||!l[0].audioCodec||l[0].attrs.AUDIO||(hk.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),f.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new gk({}),bitrate:0,url:""}))}a.trigger(rk.MANIFEST_LOADED,{levels:l,audioTracks:f,subtitles:g,captions:p,contentSteering:d,url:o,stats:t,networkDetails:i,sessionData:u,sessionKeys:c,startTimeOffset:h,variableList:m})}handleTrackOrLevelPlaylist(e,t,n,i,a){const r=this.hls,{id:o,level:s,type:d}=n,l=kM(e,n),u=nk(s)?s:nk(o)?o:0,c=wM(n),h=rM.parseLevelPlaylist(e.data,l,u,c,0,this.variableList);if(d===mM){const e={attrs:new gk({}),bitrate:0,details:h,name:"",url:l};r.trigger(rk.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:l,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),n.levelDetails=h,this.handlePlaylistLoaded(h,e,t,n,i,a)}handleManifestParsingError(e,t,n,i,a){this.hls.trigger(rk.ERROR,{type:ok.NETWORK_ERROR,details:sk.MANIFEST_PARSING_ERROR,fatal:t.type===mM,url:e.url,err:n,error:n,reason:n.message,response:e,context:t,networkDetails:i,stats:a})}handleNetworkError(e,t,n=!1,i,a){let r=`A network ${n?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===fM?r+=`: ${e.level} id: ${e.id}`:e.type!==gM&&e.type!==pM||(r+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(r);hk.warn(`[playlist-loader]: ${r}`);let s=sk.UNKNOWN,d=!1;const l=this.getInternalLoader(e);switch(e.type){case mM:s=n?sk.MANIFEST_LOAD_TIMEOUT:sk.MANIFEST_LOAD_ERROR,d=!0;break;case fM:s=n?sk.LEVEL_LOAD_TIMEOUT:sk.LEVEL_LOAD_ERROR,d=!1;break;case gM:s=n?sk.AUDIO_TRACK_LOAD_TIMEOUT:sk.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case pM:s=n?sk.SUBTITLE_TRACK_LOAD_TIMEOUT:sk.SUBTITLE_LOAD_ERROR,d=!1}l&&this.resetInternalLoader(e.type);const u={type:ok.NETWORK_ERROR,details:s,fatal:d,url:e.url,loader:l,context:e,error:o,networkDetails:t,stats:a};if(i){const n=(null==t?void 0:t.url)||e.url;u.response=Qw({url:n,data:void 0},i)}this.hls.trigger(rk.ERROR,u)}handlePlaylistLoaded(e,t,n,i,a,r){const o=this.hls,{type:s,level:d,id:l,groupId:u,deliveryDirectives:c}=i,h=kM(t,i),m=wM(i),f="number"==typeof i.level&&m===vM?d:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void o.trigger(rk.ERROR,{type:ok.NETWORK_ERROR,details:sk.LEVEL_EMPTY_ERROR,fatal:!1,url:h,error:e,reason:e.message,response:t,context:i,level:f,parent:m,networkDetails:a,stats:n})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g)o.trigger(rk.ERROR,{type:ok.NETWORK_ERROR,details:sk.LEVEL_PARSING_ERROR,fatal:!1,url:h,error:g,reason:g.message,response:t,context:i,level:f,parent:m,networkDetails:a,stats:n});else switch(e.live&&r&&(r.getCacheAge&&(e.ageHeader=r.getCacheAge()||0),r.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),s){case mM:case fM:o.trigger(rk.LEVEL_LOADED,{details:e,level:f||0,id:l||0,stats:n,networkDetails:a,deliveryDirectives:c});break;case gM:o.trigger(rk.AUDIO_TRACK_LOADED,{details:e,id:l||0,groupId:u||"",stats:n,networkDetails:a,deliveryDirectives:c});break;case pM:o.trigger(rk.SUBTITLE_TRACK_LOADED,{details:e,id:l||0,groupId:u||"",stats:n,networkDetails:a,deliveryDirectives:c})}}}function MM(e,t){let n;try{n=new Event("addtrack")}catch(e){n=document.createEvent("Event"),n.initEvent("addtrack",!1,!1)}n.track=e,t.dispatchEvent(n)}function TM(e,t){const n=e.mode;if("disabled"===n&&(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(n){hk.debug(`[texttrack-utils]: ${n}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,e.addCue(n)}catch(e){hk.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===n&&(e.mode=n)}function EM(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function PM(e,t,n,i){const a=e.mode;if("disabled"===a&&(e.mode="hidden"),e.cues&&e.cues.length>0){const a=function(e,t,n){const i=[],a=function(e,t){if(t<e[0].startTime)return 0;const n=e.length-1;if(t>e[n].endTime)return-1;let i=0,a=n;for(;i<=a;){const r=Math.floor((a+i)/2);if(t<e[r].startTime)a=r-1;else{if(!(t>e[r].startTime&&i<n))return r;i=r+1}}return e[i].startTime-t<t-e[a].startTime?i:a}(e,t);if(a>-1)for(let r=a,o=e.length;r<o;r++){const a=e[r];if(a.startTime>=t&&a.endTime<=n)i.push(a);else if(a.startTime>n)return i}return i}(e.cues,t,n);for(let t=0;t<a.length;t++)i&&!i(a[t])||e.removeCue(a[t])}"disabled"===a&&(e.mode=a)}function AM(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||t.push(e[n])}return t}var xM="org.id3",CM="com.apple.quicktime.HLS",LM="https://aomedia.org/emsg/ID3";function DM(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function IM(e,t,n,i,a){let r=new e(t,n,"");try{r.value=i,a&&(r.type=a)}catch(o){r=new e(t,n,JSON.stringify(a?Qw({type:a},i):i))}return r}const _M=(()=>{const e=DM();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function RM(e,t){return e.getTime()/1e3-t}class WM{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rk.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rk.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(EM(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const n=e[t];if("metadata"===n.kind&&"id3"===n.label)return MM(n,this.media),n}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:n,enableID3MetadataCues:i}}}=this;if(!n&&!i)return;const{samples:a}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const r=DM();if(r)for(let e=0;e<a.length;e++){const t=a[e].type;if(t===LM&&!n||!i)continue;const o=eS(a[e].data);if(o){const n=a[e].pts;let i=n+a[e].duration;i>_M&&(i=_M);i-n<=0&&(i=n+.25);for(let e=0;e<o.length;e++){const a=o[e];if(!Qk(a)){this.updateId3CueEnds(n,t);const e=IM(r,n,i,a,t);e&&this.id3Track.addCue(e)}}}}}updateId3CueEnds(e,t){var n;const i=null==(n=this.id3Track)?void 0:n.cues;if(i)for(let n=i.length;n--;){const a=i[n];a.type===t&&a.startTime<e&&a.endTime===_M&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:n,type:i}){const{id3Track:a,hls:r}=this;if(!r)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:s}}=r;if(a&&(o||s)){let e;e="audio"===i?e=>e.type===xM&&s:"video"===i?e=>e.type===LM&&o:e=>e.type===xM&&s||e.type===LM&&o,PM(a,t,n,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:n,id3Track:i}=this,{dateRanges:a}=t,r=Object.keys(a);if(i){const e=Object.keys(n).filter((e=>!r.includes(e)));for(let t=e.length;t--;){const a=e[t];Object.keys(n[a].cues).forEach((e=>{i.removeCue(n[a].cues[e])})),delete n[a]}}const o=t.fragments[t.fragments.length-1];if(0===r.length||!nk(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const s=o.programDateTime/1e3-o.start,d=DM();for(let e=0;e<r.length;e++){const t=r[e],i=a[t],o=RM(i.startDate,s),c=n[t],h=(null==c?void 0:c.cues)||{};let m=(null==c?void 0:c.durationKnown)||!1,f=_M;const g=i.endDate;if(g)f=RM(g,s),m=!0;else if(i.endOnNext&&!m){const e=r.reduce(((e,t)=>{if(t!==i.id){const n=a[t];if(n.class===i.class&&n.startDate>i.startDate&&(!e||i.startDate<e.startDate))return n}return e}),null);e&&(f=RM(e.startDate,s),m=!0)}const p=Object.keys(i.attr);for(let e=0;e<p.length;e++){const n=p[e];if("ID"===(u=n)||"CLASS"===u||"START-DATE"===u||"DURATION"===u||"END-DATE"===u||"END-ON-NEXT"===u)continue;const a=h[n];if(a)m&&!c.durationKnown&&(a.endTime=f);else if(d){let e=i.attr[n];pk(n)&&(l=e,e=Uint8Array.from(l.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer);const a=IM(d,o,f,{key:n,data:e},CM);a&&(a.id=t,this.id3Track.addCue(a),h[n]=a)}}n[t]={cues:h,dateRange:i,durationKnown:m}}var l,u}}class NM{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(null===e)return null;const{holdBack:t,partHoldBack:n,targetduration:i}=e,{liveSyncDuration:a,liveSyncDurationCount:r,lowLatencyMode:o}=this.config,s=this.hls.userConfig;let d=o&&n||t;(s.liveSyncDuration||s.liveSyncDurationCount||0===d)&&(d=void 0!==a?a:r*i);const l=i;return d+Math.min(1*this.stallCount,l)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,n=this.levelDetails;if(null===e||null===t||null===n)return null;const i=n.edge,a=e-t-this.edgeStalled,r=i-n.totalduration,o=i-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(r,a),o)}get drift(){const{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const n=e.buffered.length;return(n?e.buffered.end(n-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(rk.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(rk.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(rk.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(rk.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var n;t.details===sk.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(n=this.levelDetails)&&n.live&&hk.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const n=this.computeLatency();if(null===n)return;this._latency=n;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:a}=this.config;if(!i||1===a||!t.live)return;const r=this.targetLatency;if(null===r)return;const o=n-r;if(o<Math.min(this.maxLatency,r+t.targetduration)&&o>.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,a)),n=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,n))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const OM=["NONE","TYPE-0","TYPE-1",null];const FM=["SDR","PQ","HLG"];var jM="",zM="YES",$M="v2";function HM(e){const{canSkipUntil:t,canSkipDateRanges:n,age:i}=e;return t&&i<t/2?n?$M:zM:jM}class UM{constructor(e,t,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=n}addDirectives(e){const 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}}class BM{constructor(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.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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter((e=>!!e)).map((e=>e.substring(0,4))).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(e){return GM(this._audioGroups,e)}hasSubtitleGroup(e){return GM(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t)if("audio"===e){let e=this._audioGroups;e||(e=this._audioGroups=[]),-1===e.indexOf(t)&&e.push(t)}else if("text"===e){let e=this._subtitleGroups;e||(e=this._subtitleGroups=[]),-1===e.indexOf(t)&&e.push(t)}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return null==(e=this.audioGroups)?void 0:e[0]}get textGroupId(){var e;return null==(e=this.subtitleGroups)?void 0:e[0]}addFallback(){}}function GM(e,t){return!(!t||!e)&&-1!==e.indexOf(t)}function XM(e,t){const n=t.startPTS;if(nk(n)){let i,a=0;t.sn>e.sn?(a=n-e.start,i=e):(a=e.start-n,i=t),i.duration!==a&&(i.duration=a)}else if(t.sn>e.sn){e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration}else t.start=Math.max(e.start-t.duration,0)}function YM(e,t,n,i,a,r){i-n<=0&&(hk.warn("Fragment should have a positive duration",t),i=n+t.duration,r=a+t.duration);let o=n,s=i;const d=t.startPTS,l=t.endPTS;if(nk(d)){const e=Math.abs(d-n);nk(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(n,d),n=Math.min(n,d),a=Math.min(a,t.startDTS),s=Math.min(i,l),i=Math.max(i,l),r=Math.max(r,t.endDTS)}const u=n-t.start;0!==t.start&&(t.start=n),t.duration=i-t.start,t.startPTS=n,t.maxStartPTS=o,t.startDTS=a,t.endPTS=i,t.minEndPTS=s,t.endDTS=r;const c=t.sn;if(!e||c<e.startSN||c>e.endSN)return 0;let h;const m=c-e.startSN,f=e.fragments;for(f[m]=t,h=m;h>0;h--)XM(f[h],f[h-1]);for(h=m;h<f.length-1;h++)XM(f[h],f[h+1]);return e.fragmentHint&&XM(f[f.length-1],e.fragmentHint),e.PTSKnown=e.alignedSliding=!0,u}function VM(e,t){let n=null;const i=e.fragments;for(let e=i.length-1;e>=0;e--){const t=i[e].initSegment;if(t){n=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let a,r=0;if(function(e,t,n){const i=t.skippedSegments,a=Math.max(e.startSN,t.startSN)-t.startSN,r=(e.fragmentHint?1:0)+(i?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,d=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let e=a;e<=r;e++){const a=d[o+e];let r=s[e];i&&!r&&e<i&&(r=t.fragments[e]=a),a&&r&&n(a,r)}}(e,t,((e,i)=>{e.relurl&&(r=e.cc-i.cc),nk(e.startPTS)&&nk(e.endPTS)&&(i.start=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.duration=e.endPTS-e.startPTS,i.duration&&(a=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,e.initSegment&&(i.initSegment=e.initSegment,n=e.initSegment)})),n){(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach((e=>{var t;!e||e.initSegment&&e.initSegment.relurl!==(null==(t=n)?void 0:t.relurl)||(e.initSegment=n)}))}if(t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some((e=>!e)),t.deltaUpdateFailed){hk.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=function(e,t,n){const i=tk({},e);n&&n.forEach((e=>{delete i[e]}));return Object.keys(t).forEach((e=>{const n=new vk(t[e].attr,i[e]);n.isValid?i[e]=n:hk.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)})),i}(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const o=t.fragments;if(r){hk.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e<o.length;e++)o[e].cc+=r}t.skippedSegments&&(t.startCC=t.fragments[0].cc),function(e,t,n){if(e&&t){let i=0;for(let a=0,r=e.length;a<=r;a++){const r=e[a],o=t[a+i];r&&o&&r.index===o.index&&r.fragment.sn===o.fragment.sn?n(r,o):i--}}}(e.partList,t.partList,((e,t)=>{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats})),a?YM(t,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):KM(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const s=t.advancedDateTime;if(t.advanced&&s){const e=t.edge;t.driftStart||(t.driftStartTime=s,t.driftStart=e),t.driftEndTime=s,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}function KM(e,t){const n=t.startSN+t.skippedSegments-e.startSN,i=e.fragments;n<0||n>=i.length||qM(t,i[n].start)}function qM(e,t){if(t){const n=e.fragments;for(let i=e.skippedSegments;i<n.length;i++)n[i].start+=t;e.fragmentHint&&(e.fragmentHint.start+=t)}}function JM(e,t,n){var i;return null!=e&&e.details?QM(null==(i=e.details)?void 0:i.partList,t,n):null}function QM(e,t,n){if(e)for(let i=e.length;i--;){const a=e[i];if(a.index===n&&a.fragment.sn===t)return a}return null}function ZM(e){e.forEach(((e,t)=>{const{details:n}=e;null!=n&&n.fragments&&n.fragments.forEach((e=>{e.level=t}))}))}function eT(e){switch(e.details){case sk.FRAG_LOAD_TIMEOUT:case sk.KEY_LOAD_TIMEOUT:case sk.LEVEL_LOAD_TIMEOUT:case sk.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function tT(e,t){const n=eT(t);return e.default[(n?"timeout":"error")+"Retry"]}function nT(e,t){const n="linear"===e.backoff?1:Math.pow(2,t);return Math.min(n*e.retryDelayMs,e.maxRetryDelayMs)}function iT(e){return Qw(Qw({},e),{errorRetry:null,timeoutRetry:null})}function aT(e,t,n,i){if(!e)return!1;const a=null==i?void 0:i.code,r=t<e.maxNumRetry&&(function(e){return 0===e&&!1===navigator.onLine||!!e&&(e<400||e>499)}(a)||!!n);return e.shouldRetry?e.shouldRetry(e,t,n,i,r):r}const rT=function(e,t){let n=0,i=e.length-1,a=null,r=null;for(;n<=i;){a=(n+i)/2|0,r=e[a];const o=t(r);if(o>0)n=a+1;else{if(!(o<0))return r;i=a-1}}return null};function oT(e,t,n=0,i=0,a=.005){let r=null;if(e){r=t[e.sn-t[0].sn+1]||null;const i=e.endDTS-n;i>0&&i<15e-7&&(n+=15e-7)}else 0===n&&0===t[0].start&&(r=t[0]);if(r&&((!e||e.level===r.level)&&0===sT(n,i,r)||function(e,t,n){if(t&&0===t.start&&t.level<e.level&&(t.endPTS||0)>0){const i=t.tagList.reduce(((e,t)=>("INF"===t[0]&&(e+=parseFloat(t[1])),e)),n);return e.start<=i}return!1}(r,e,Math.min(a,i))))return r;const o=rT(t,sT.bind(null,n,i));return!o||o===e&&r?r:o}function sT(e=0,t=0,n){if(n.start<=e&&n.start+n.duration>e)return 0;const i=Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-i<=e?1:n.start-i>e&&n.start?-1:0}function dT(e,t,n){const i=1e3*Math.min(t,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-i>e}var lT=0,uT=2,cT=3,hT=5,mT=0,fT=1,gT=2;class pT{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=hk.log.bind(hk,`${t}:`),this.warn=hk.warn.bind(hk,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,n){const i=null==t?void 0:t.renditionReports;if(i){let a=-1;for(let n=0;n<i.length;n++){const r=i[n];let o;try{o=new self.URL(r.URI,t.url).href}catch(e){hk.warn(`Could not construct new URL for Rendition Report: ${e}`),o=r.URI||""}if(o===e){a=n;break}o===e.substring(0,o.length)&&(a=n)}if(-1!==a){const e=i[a],r=parseInt(e["LAST-MSN"])||(null==t?void 0:t.lastPartSn);let o=parseInt(e["LAST-PART"])||(null==t?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const e=Math.min(t.age-t.partTarget,t.targetduration);o>=0&&e>t.partTarget&&(o+=1)}const s=n&&HM(n);return new UM(r,o>=0?o:void 0,s)}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,n){const{details:i,stats:a}=t,r=self.performance.now(),o=a.loading.first?Math.max(0,r-a.loading.first):0;if(i.advancedDateTime=Date.now()-o,i.live||null!=n&&n.live){if(i.reloaded(n),n&&this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),n&&i.fragments.length>0&&VM(n,i),!this.canLoad||!i.live)return;let o,s,d;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,a=i.lastPartSn,r=i.endSN,l=i.lastPartIndex,u=a===r;-1!==l?(s=u?r+1:a,d=u?e?0:l:l+1):s=r+1;const c=i.age,h=c+i.ageHeader;let m=Math.min(h-i.partTarget,1.5*i.targetduration);if(m>0){if(n&&m>n.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${n.tuneInGoal} to: ${m} with playlist age: ${i.age}`),m=0;else{const e=Math.floor(m/i.targetduration);if(s+=e,void 0!==d){d+=Math.round(m%i.targetduration/i.partTarget)}this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${c.toFixed(2)}s goal: ${m} skip sn ${e} to part ${d}`)}i.tuneInGoal=m}if(o=this.getDeliveryDirectives(i,t.deliveryDirectives,s,d),e||!u)return void this.loadPlaylist(o)}else(i.canBlockReload||i.canSkipUntil)&&(o=this.getDeliveryDirectives(i,t.deliveryDirectives,s,d));const l=this.hls.mainForwardBufferInfo,u=l?l.end-l.len:0,c=function(e,t=1/0){let n=1e3*e.targetduration;if(e.updated){const i=e.fragments,a=4;if(i.length&&n*a>t){const e=1e3*i[i.length-1].duration;e<n&&(n=e)}}else n/=2;return Math.round(n)}(i,1e3*(i.edge-u));i.updated&&r>this.requestScheduled+c&&(this.requestScheduled=a.loading.start),void 0!==s&&i.canBlockReload?this.requestScheduled=a.loading.first+c-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+c<r?this.requestScheduled=r:this.requestScheduled-r<=0&&(this.requestScheduled+=c);let h=this.requestScheduled-r;h=Math.max(0,h),this.log(`reload live playlist ${e} in ${Math.round(h)} ms`),this.timer=self.setTimeout((()=>this.loadPlaylist(o)),h)}else this.clearTimer()}getDeliveryDirectives(e,t,n,i){let a=HM(e);return null!=t&&t.skip&&e.deltaUpdateFailed&&(n=t.msn,i=t.part,a=jM),new UM(n,i,a)}checkRetry(e){const t=e.details,n=eT(e),i=e.errorAction,{action:a,retryCount:r=0,retryConfig:o}=i||{},s=!!i&&!!o&&(a===hT||!i.resolved&&a===uT);if(s){var d;if(this.requestScheduled=-1,r>=o.maxNumRetry)return!1;if(n&&null!=(d=e.context)&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${r+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=nT(o,r);this.timer=self.setTimeout((()=>this.loadPlaylist()),e),this.warn(`Retrying playlist loading ${r+1}/${o.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return s}}class vT{constructor(e,t=0,n=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=n}sample(e,t){const n=Math.pow(this.alpha_,e);this.estimate_=t*(1-n)+n*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class yT{constructor(e,t,n,i=100){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 vT(e),this.fast_=new vT(t),this.defaultTTFB_=i,this.ttfb_=new vT(e)}update(e,t){const{slow_:n,fast_:i,ttfb_:a}=this;n.halfLife!==e&&(this.slow_=new vT(e,n.getEstimate(),n.getTotalWeight())),i.halfLife!==t&&(this.fast_=new vT(t,i.getEstimate(),i.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new vT(e,a.getEstimate(),a.getTotalWeight()))}sample(e,t){const n=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/n;this.fast_.sample(n,i),this.slow_.sample(n,i)}sampleTTFB(e){const t=e/1e3,n=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(n,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}const bT={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},wT={};function kT(e,t,n,i,a,r){const o=e.audioCodec?e.audioGroups:null,s=null==r?void 0:r.audioCodec,d=null==r?void 0:r.channels,l=d?parseInt(d):s?1/0:2;let u=null;if(null!=o&&o.length)try{u=1===o.length&&o[0]?t.groups[o[0]].channels:o.reduce(((e,n)=>{if(n){const i=t.groups[n];if(!i)throw new Error(`Audio track group ${n} not found`);Object.keys(i.channels).forEach((t=>{e[t]=(e[t]||0)+i.channels[t]}))}return e}),{2:0})}catch(e){return!0}return void 0!==e.videoCodec&&(e.width>1920&&e.height>1088||e.height>1920&&e.width>1088||e.frameRate>Math.max(i,30)||"SDR"!==e.videoRange&&e.videoRange!==n||e.bitrate>Math.max(a,8e6))||!!u&&nk(l)&&Object.keys(u).some((e=>parseInt(e)>l))}function ST(e,t,n){const i=e.videoCodec,a=e.audioCodec;if(!i||!a||!n)return Promise.resolve(bT);const r={width:e.width,height:e.height,bitrate:Math.ceil(Math.max(.9*e.bitrate,e.averageBitrate)),framerate:e.frameRate||30},o=e.videoRange;"SDR"!==o&&(r.transferFunction=o.toLowerCase());const s=i.split(",").map((e=>({type:"media-source",video:Qw(Qw({},r),{},{contentType:YS(e,"video")})})));return a&&e.audioGroups&&e.audioGroups.forEach((e=>{var n;e&&(null==(n=t.groups[e])||n.tracks.forEach((t=>{if(t.groupId===e){const e=t.channels||"",n=parseFloat(e);nk(n)&&n>2&&s.push.apply(s,a.split(",").map((e=>({type:"media-source",audio:{contentType:YS(e,"audio"),channels:""+n}}))))}})))})),Promise.all(s.map((e=>{const t=function(e){const{audio:t,video:n}=e,i=n||t;if(i){const e=i.contentType.split('"')[1];if(n)return`r${n.height}x${n.width}f${Math.ceil(n.framerate)}${n.transferFunction||"sd"}_${e}_${Math.ceil(n.bitrate/1e5)}`;if(t)return`c${t.channels}${t.spatialRendering?"s":"n"}_${e}`}return""}(e);return wT[t]||(wT[t]=n.decodingInfo(e))}))).then((e=>({supported:!e.some((e=>!e.supported)),configurations:s,decodingInfoResults:e}))).catch((e=>({supported:!1,configurations:s,decodingInfoResults:[],error:e})))}function MT(e,t){let n=!1,i=[];return e&&(n="SDR"!==e,i=[e]),t&&(i=t.allowedVideoRanges||FM.slice(0),n=void 0!==t.preferHDR?t.preferHDR:function(){if("function"==typeof matchMedia){const e=matchMedia("(dynamic-range: high)"),t=matchMedia("bad query");if(e.media!==t.media)return!0===e.matches}return!1}(),i=n?i.filter((e=>"SDR"!==e)):["SDR"]),{preferHDR:n,allowedVideoRanges:i}}function TT(e,t){hk.log(`[abr] start candidates with "${e}" ignored because ${t}`)}function ET(e,t,n){if("attrs"in e){const n=t.indexOf(e);if(-1!==n)return n}for(let i=0;i<t.length;i++){if(PT(e,t[i],n))return i}return-1}function PT(e,t,n){const{groupId:i,name:a,lang:r,assocLang:o,characteristics:s,default:d}=e,l=e.forced;return(void 0===i||t.groupId===i)&&(void 0===a||t.name===a)&&(void 0===r||t.lang===r)&&(void 0===r||t.assocLang===o)&&(void 0===d||t.default===d)&&(void 0===l||t.forced===l)&&(void 0===s||function(e,t=""){const n=e.split(","),i=t.split(",");return n.length===i.length&&!n.some((e=>-1===i.indexOf(e)))}(s,t.characteristics))&&(void 0===n||n(e,t))}function AT(e,t){const{audioCodec:n,channels:i}=e;return!(void 0!==n&&(t.audioCodec||"").substring(0,4)!==n.substring(0,4)||void 0!==i&&i!==(t.channels||"2"))}function xT(e,t,n){for(let i=t;i;i--)if(n(e[i]))return i;for(let i=t+1;i<e.length;i++)if(n(e[i]))return i;return-1}class CT{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var LT="NOT_LOADED",DT="APPENDING",IT="PARTIAL",_T="OK";class RT{constructor(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=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(rk.BUFFER_APPENDED,this.onBufferAppended,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rk.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.BUFFER_APPENDED,this.onBufferAppended,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rk.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const n=this.activePartLists[t];if(n)for(let t=n.length;t--;){const i=n[t];if(!i)break;const a=i.end;if(i.start<=e&&null!==a&&e<=a)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:n}=this,i=Object.keys(n);for(let a=i.length;a--;){const r=n[i[a]];if((null==r?void 0:r.body.type)===t&&r.buffered){const t=r.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,n,i){this.timeRanges&&(this.timeRanges[e]=t);const a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((i=>{const r=this.fragments[i];if(!r)return;if(a>=r.body.sn)return;if(!r.buffered&&!r.loaded)return void(r.body.type===n&&this.removeFragment(r.body));const o=r.range[e];o&&o.time.some((e=>{const n=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return n&&this.removeFragment(r.body),n}))}))}detectPartialFragments(e){const t=this.timeRanges,{frag:n,part:i}=e;if(!t||"initSegment"===n.sn)return;const a=NT(n),r=this.fragments[a];if(!r||r.buffered&&n.gap)return;const o=!n.relurl;if(Object.keys(t).forEach((e=>{const a=n.elementaryStreams[e];if(!a)return;const s=t[e],d=o||!0===a.partial;r.range[e]=this.getBufferedTimes(n,i,d,s)})),r.loaded=null,Object.keys(r.range).length){r.buffered=!0;(r.body.endList=n.endList||r.body.endList)&&(this.endListFragments[r.body.type]=r),WT(r)||this.removeParts(n.sn-1,n.type)}else this.removeFragment(r.body)}removeParts(e,t){const n=this.activePartLists[t];n&&(this.activePartLists[t]=n.filter((t=>t.fragment.sn>=e)))}fragBuffered(e,t){const n=NT(e);let i=this.fragments[n];!i&&t&&(i=this.fragments[n]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,n,i){const a={time:[],partial:n},r=e.start,o=e.end,s=e.minEndPTS||o,d=e.maxStartPTS||r;for(let e=0;e<i.length;e++){const t=i.start(e)-this.bufferPadding,n=i.end(e)+this.bufferPadding;if(d>=t&&s<=n){a.time.push({startPTS:Math.max(r,i.start(e)),endPTS:Math.min(o,i.end(e))});break}if(r<n&&o>t){const t=Math.max(r,i.start(e)),n=Math.min(o,i.end(e));n>t&&(a.partial=!0,a.time.push({startPTS:t,endPTS:n}))}else if(o<=t)break}return a}getPartialFragment(e){let t,n,i,a=null,r=0;const{bufferPadding:o,fragments:s}=this;return Object.keys(s).forEach((d=>{const l=s[d];l&&WT(l)&&(n=l.body.start-o,i=l.body.end+o,e>=n&&e<=i&&(t=Math.min(e-n,i-e),r<=t&&(a=l.body,r=t)))})),a}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||WT(t))}getState(e){const t=NT(e),n=this.fragments[t];return n?n.buffered?WT(n)?IT:_T:DT:LT}isTimeBuffered(e,t,n){let i,a;for(let r=0;r<n.length;r++){if(i=n.start(r)-this.bufferPadding,a=n.end(r)+this.bufferPadding,e>=i&&t<=a)return!0;if(t<=i)return!1}return!1}onFragLoaded(e,t){const{frag:n,part:i}=t;if("initSegment"===n.sn||n.bitrateTest)return;const a=i?null:t,r=NT(n);this.fragments[r]={body:n,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:n,part:i,timeRanges:a}=t;if("initSegment"===n.sn)return;const r=n.type;if(i){let e=this.activePartLists[r];e||(this.activePartLists[r]=e=[]),e.push(i)}this.timeRanges=a,Object.keys(a).forEach((e=>{const t=a[e];this.detectEvictedFragments(e,t,r,i)}))}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=NT(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,n,i,a){i&&!this.hasGaps||Object.keys(this.fragments).forEach((r=>{const o=this.fragments[r];if(!o)return;const s=o.body;s.type!==n||i&&!s.gap||s.start<t&&s.end>e&&(o.buffered||a)&&this.removeFragment(s)}))}removeFragment(e){const t=NT(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const n=this.activePartLists[e.type];if(n){const t=e.sn;this.activePartLists[e.type]=n.filter((e=>e.fragment.sn!==t))}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function WT(e){var t,n,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(n=e.range.audio)?void 0:n.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function NT(e){return`${e.type}_${e.level}_${e.sn}`}const OT={length:0,start:()=>0,end:()=>0};class FT{static isBuffered(e,t){try{if(e){const n=FT.getBuffered(e);for(let e=0;e<n.length;e++)if(t>=n.start(e)&&t<=n.end(e))return!0}}catch(e){}return!1}static bufferInfo(e,t,n){try{if(e){const i=FT.getBuffered(e),a=[];let r;for(r=0;r<i.length;r++)a.push({start:i.start(r),end:i.end(r)});return this.bufferedInfo(a,t,n)}}catch(e){}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,n){t=Math.max(0,t),e.sort((function(e,t){const n=e.start-t.start;return n||t.end-e.end}));let i=[];if(n)for(let t=0;t<e.length;t++){const a=i.length;if(a){const r=i[a-1].end;e[t].start-r<n?e[t].end>r&&(i[a-1].end=e[t].end):i.push(e[t])}else i.push(e[t])}else i=e;let a,r=0,o=t,s=t;for(let e=0;e<i.length;e++){const d=i[e].start,l=i[e].end;if(t+n>=d&&t<l)o=d,s=l,r=s-t;else if(t+n<d){a=d;break}}return{len:r,start:o||0,end:s||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(e){return hk.log("failed to get media.buffered",e),OT}}}class jT{constructor(e,t,n,i=0,a=-1,r=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={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=e,this.sn=t,this.id=n,this.size=i,this.part=a,this.partial=r}}function zT(e,t){for(let i=0,a=e.length;i<a;i++){var n;if((null==(n=e[i])?void 0:n.cc)===t)return e[i]}return null}function $T(e,t){if(e){const n=e.start+t;e.start=e.startPTS=n,e.endPTS=n+e.duration}}function HT(e,t){const n=t.fragments;for(let t=0,i=n.length;t<i;t++)$T(n[t],e);t.fragmentHint&&$T(t.fragmentHint,e),t.alignedSliding=!0}function UT(e,t,n){t&&(!function(e,t,n){if(function(e,t,n){return!(!t||!(n.endCC>n.startCC||e&&e.cc<n.startCC))}(e,n,t)){const e=function(e,t){const n=e.fragments,i=t.fragments;if(!i.length||!n.length)return void hk.log("No fragments to align");const a=zT(n,i[0].cc);if(a&&(!a||a.startPTS))return a;hk.log("No frag in previous level to align on")}(n,t);e&&nk(e.start)&&(hk.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),HT(e.start,t))}}(e,n,t),!n.alignedSliding&&t&&BT(n,t),n.alignedSliding||!t||n.skippedSegments||KM(t,n))}function BT(e,t){if(!e.hasProgramDateTime||!t.hasProgramDateTime)return;const n=e.fragments,i=t.fragments;if(!n.length||!i.length)return;let a,r;const o=Math.min(t.endCC,e.endCC);t.startCC<o&&e.startCC<o&&(a=zT(i,o),r=zT(n,o)),a&&r||(a=i[Math.floor(i.length/2)],r=zT(n,a.cc)||n[Math.floor(n.length/2)]);const s=a.programDateTime,d=r.programDateTime;if(!s||!d)return;HT((d-s)/1e3-(r.start-a.start),e)}const GT=Math.pow(2,17);class XT{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const n=e.url;if(!n)return Promise.reject(new KT({type:ok.NETWORK_ERROR,details:sk.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,a=i.fLoader,r=i.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(VT(e));e.gap=!1}const d=this.loader=e.loader=a?new a(i):new r(i),l=YT(e),u=iT(i.fragLoadPolicy.default),c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:GT};e.stats=d.stats,d.load(l,c,{onSuccess:(t,n,i,a)=>{this.resetLoader(e,d);let r=t.data;i.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,i,a,r)=>{this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Qw({url:n,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:a,stats:r}))},onAbort:(t,n,i)=>{this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,n,i)=>{this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:i,stats:t}))},onProgress:(n,i,a,r)=>{t&&t({frag:e,part:null,payload:a,networkDetails:r})}})}))}loadPart(e,t,n){this.abort();const i=this.config,a=i.fLoader,r=i.loader;return new Promise(((o,s)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void s(VT(e,t));const d=this.loader=e.loader=a?new a(i):new r(i),l=YT(e,t),u=iT(i.fragLoadPolicy.default),c={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:GT};t.stats=d.stats,d.load(l,c,{onSuccess:(i,a,r,s)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const l={frag:e,part:t,payload:i.data,networkDetails:s};n(l),o(l)},onError:(n,i,a,r)=>{this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Qw({url:l.url,data:void 0},n),error:new Error(`HTTP Error ${n.code} ${n.text}`),networkDetails:a,stats:r}))},onAbort:(n,i,a)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:a,stats:n}))},onTimeout:(n,i,a)=>{this.resetLoader(e,d),s(new KT({type:ok.NETWORK_ERROR,details:sk.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${c.timeout}ms`),networkDetails:a,stats:n}))}})}))}updateStatsFromPart(e,t){const n=e.stats,i=t.stats,a=i.total;if(n.loaded+=i.loaded,a){const i=Math.round(e.duration/t.duration),r=Math.min(Math.round(n.loaded/a),i),o=(i-r)*Math.round(n.loaded/r);n.total=n.loaded+o}else n.total=Math.max(n.loaded,n.total);const r=n.loading,o=i.loading;r.start?r.first+=o.first-o.start:(r.start=o.start,r.first=o.first),r.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function YT(e,t=null){const n=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},a=n.byteRangeStartOffset,r=n.byteRangeEndOffset;if(nk(a)&&nk(r)){var o;let t=a,n=r;if("initSegment"===e.sn&&"AES-128"===(null==(o=e.decryptdata)?void 0:o.method)){const e=r-a;e%16&&(n=r+(16-e%16)),0!==a&&(i.resetIV=!0,t=a-16)}i.rangeStart=t,i.rangeEnd=n}return i}function VT(e,t){const n=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:ok.MEDIA_ERROR,details:sk.FRAG_GAP,fatal:!1,frag:e,error:n,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new KT(i)}class KT extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class qT{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class JT{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}class QT{constructor(){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()}uint8ArrayToUint32Array_(e){const t=new DataView(e),n=new Uint32Array(4);for(let e=0;e<4;e++)n[e]=t.getUint32(4*e);return n}initTable(){const e=this.sBox,t=this.invSBox,n=this.subMix,i=n[0],a=n[1],r=n[2],o=n[3],s=this.invSubMix,d=s[0],l=s[1],u=s[2],c=s[3],h=new Uint32Array(256);let m=0,f=0,g=0;for(g=0;g<256;g++)h[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){let n=f^f<<1^f<<2^f<<3^f<<4;n=n>>>8^255&n^99,e[m]=n,t[n]=m;const s=h[m],g=h[s],p=h[g];let v=257*h[n]^16843008*n;i[m]=v<<24|v>>>8,a[m]=v<<16|v>>>16,r[m]=v<<8|v>>>24,o[m]=v,v=16843009*p^65537*g^257*s^16843008*m,d[n]=v<<24|v>>>8,l[n]=v<<16|v>>>16,u[n]=v<<8|v>>>24,c[n]=v,m?(m=s^h[h[h[p^s]]],f^=h[h[f]]):m=f=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let n=!0,i=0;for(;i<t.length&&n;)n=t[i]===this.key[i],i++;if(n)return;this.key=t;const a=this.keySize=t.length;if(4!==a&&6!==a&&8!==a)throw new Error("Invalid aes key size="+a);const r=this.ksRows=4*(a+6+1);let o,s;const d=this.keySchedule=new Uint32Array(r),l=this.invKeySchedule=new Uint32Array(r),u=this.sBox,c=this.rcon,h=this.invSubMix,m=h[0],f=h[1],g=h[2],p=h[3];let v,y;for(o=0;o<r;o++)o<a?v=d[o]=t[o]:(y=v,o%a==0?(y=y<<8|y>>>24,y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[255&y],y^=c[o/a|0]<<24):a>6&&o%a==4&&(y=u[y>>>24]<<24|u[y>>>16&255]<<16|u[y>>>8&255]<<8|u[255&y]),d[o]=v=(d[o-a]^y)>>>0);for(s=0;s<r;s++)o=r-s,y=3&s?d[o]:d[o-4],l[s]=s<4||o<=4?y:m[u[y>>>24]]^f[u[y>>>16&255]]^g[u[y>>>8&255]]^p[u[255&y]],l[s]=l[s]>>>0}networkToHostOrderSwap(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24}decrypt(e,t,n){const i=this.keySize+6,a=this.invKeySchedule,r=this.invSBox,o=this.invSubMix,s=o[0],d=o[1],l=o[2],u=o[3],c=this.uint8ArrayToUint32Array_(n);let h=c[0],m=c[1],f=c[2],g=c[3];const p=new Int32Array(e),v=new Int32Array(p.length);let y,b,w,k,S,M,T,E,P,A,x,C,L,D;const I=this.networkToHostOrderSwap;for(;t<p.length;){for(P=I(p[t]),A=I(p[t+1]),x=I(p[t+2]),C=I(p[t+3]),S=P^a[0],M=C^a[1],T=x^a[2],E=A^a[3],L=4,D=1;D<i;D++)y=s[S>>>24]^d[M>>16&255]^l[T>>8&255]^u[255&E]^a[L],b=s[M>>>24]^d[T>>16&255]^l[E>>8&255]^u[255&S]^a[L+1],w=s[T>>>24]^d[E>>16&255]^l[S>>8&255]^u[255&M]^a[L+2],k=s[E>>>24]^d[S>>16&255]^l[M>>8&255]^u[255&T]^a[L+3],S=y,M=b,T=w,E=k,L+=4;y=r[S>>>24]<<24^r[M>>16&255]<<16^r[T>>8&255]<<8^r[255&E]^a[L],b=r[M>>>24]<<24^r[T>>16&255]<<16^r[E>>8&255]<<8^r[255&S]^a[L+1],w=r[T>>>24]<<24^r[E>>16&255]<<16^r[S>>8&255]<<8^r[255&M]^a[L+2],k=r[E>>>24]<<24^r[S>>16&255]<<16^r[M>>8&255]<<8^r[255&T]^a[L+3],v[t]=I(y^h),v[t+1]=I(k^m),v[t+2]=I(w^f),v[t+3]=I(b^g),h=P,m=A,f=x,g=C,t+=4}return v.buffer}}class ZT{constructor(e,{removePKCS7Padding:t=!0}={}){if(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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const e=self.crypto;e&&(this.subtle=e.subtle||e.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?function(e){const t=e.byteLength,n=t&&new DataView(e.buffer).getUint8(t-1);return n?Gk(e,0,t-n):e}(n):n}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,n){return this.useSoftware?new Promise(((i,a)=>{this.softwareDecrypt(new Uint8Array(e),t,n);const r=this.flush();r?i(r.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,n)}softwareDecrypt(e,t,n){const{currentIV:i,currentResult:a,remainderData:r}=this;this.logOnce("JS AES decrypt"),r&&(e=xS(r,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;i&&(n=i);let s=this.softwareDecrypter;s||(s=this.softwareDecrypter=new QT),s.expandKey(t);const d=a;return this.currentResult=s.decrypt(o.buffer,0,n),this.currentIV=Gk(o,-16).buffer,d||null}webCryptoDecrypt(e,t,n){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,n));this.key=t,this.fastAesKey=new JT(this.subtle,t)}return this.fastAesKey.expandKey().then((t=>{if(!this.subtle)return Promise.reject(new Error("web crypto not initialized"));this.logOnce("WebCrypto AES decrypt");return new qT(this.subtle,new Uint8Array(n)).decrypt(e.buffer,t)})).catch((i=>(hk.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,n))))}onWebCryptoError(e,t,n){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,n);const i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const n=e.length-e.length%16;return n!==e.length&&(t=Gk(e,0,n),this.remainderData=Gk(e,n)),t}logOnce(e){this.logEnabled&&(hk.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const eE=function(e){let t="";const n=e.length;for(let i=0;i<n;i++)t+=`[${e.start(i).toFixed(3)}-${e.end(i).toFixed(3)}]`;return t},tE="STOPPED",nE="IDLE",iE="KEY_LOADING",aE="FRAG_LOADING",rE="FRAG_LOADING_WAITING_RETRY",oE="WAITING_TRACK",sE="PARSING",dE="PARSED",lE="ENDED",uE="ERROR",cE="WAITING_INIT_PTS",hE="WAITING_LEVEL";class mE extends CT{constructor(e,t,n,i,a){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=tE,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=a,this.logPrefix=i,this.log=hk.log.bind(hk,`${i}:`),this.warn=hk.warn.bind(hk,`${i}:`),this.hls=e,this.fragmentLoader=new XT(e.config),this.keyLoader=n,this.fragmentTracker=t,this.config=e.config,this.decrypter=new ZT(e.config),e.on(rk.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const 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=tE}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const n=t.partList;if(null!=n&&n.length){const e=n[n.length-1];return FT.isBuffered(this.media,e.start+e.duration/2)}const i=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)}getLevelDetails(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levelLastLoaded)?void 0:e.details}onMediaAttached(e,t){const n=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),n.addEventListener("seeking",this.onvseeking),n.addEventListener("ended",this.onvended);const i=this.config;this.levels&&i.autoStartLoad&&this.state===tE&&this.startLoad(i.startPosition)}onMediaDetaching(){const e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:n,mediaBuffer:i,state:a}=this,r=n?n.currentTime:0,o=FT.bufferInfo(i||n,r,e.maxBufferHole);if(this.log(`media seeking to ${nk(r)?r.toFixed(3):r}, state: ${a}`),this.state===lE)this.resetLoadingState();else if(t){const n=e.maxFragLookUpTolerance,i=t.start-n,a=t.start+t.duration+n;if(!o.len||a<o.start||i>o.end){const e=r>a;(r<i||e)&&(e&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}n&&(this.fragmentTracker.removeFragmentsInRange(r,1/0,this.playlistType,!0),this.lastCurrentTime=r),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=r),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(rk.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=tE,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,super.onHandlerDestroyed()}loadFragment(e,t,n){this._loadFragForPlayback(e,t,n)}_loadFragForPlayback(e,t,n){this._doFragLoad(e,t,n,(t=>{if(this.fragContextChanged(e))return this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)})).then((t=>{if(!t)return;const n=this.state;this.fragContextChanged(e)?(n===aE||!this.fragCurrent&&n===sE)&&(this.fragmentTracker.removeFragment(e),this.state=nE):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(rk.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))})).catch((t=>{this.state!==tE&&this.state!==uE&&(this.warn(`Frag error: ${(null==t?void 0:t.message)||t}`),this.resetFragmentLoading(e))}))}clearTrackerIfNeeded(e){var t;const{fragmentTracker:n}=this;if(n.getState(e)===DT){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),a=Math.max(e.duration,i?i.len:this.config.maxBufferLength),r=this.backtrackFragment;(1===(r?e.sn-r.sn:0)||this.reduceMaxBufferLength(a,e.duration))&&n.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?n.removeAllFragments():n.hasParts(e.type)&&(n.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),n.getState(e)===IT&&n.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const 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)}flushMainBuffer(e,t,n=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:n};this.hls.trigger(rk.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then((t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t})).then((t=>{const{hls:n}=this,{payload:i}=t,a=e.decryptdata;if(i&&i.byteLength>0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){const r=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),a.key.buffer,a.iv.buffer).catch((t=>{throw n.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t})).then((i=>{const a=self.performance.now();return n.trigger(rk.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:r,tdecrypt:a}}),t.payload=i,this.completeInitSegmentLoad(t)}))}return this.completeInitSegmentLoad(t)})).catch((t=>{this.state!==tE&&this.state!==uE&&(this.warn(t),this.resetFragmentLoading(e))}))}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const n=e.frag.stats;this.state=nE,e.frag.data=new Uint8Array(e.payload),n.parsing.start=n.buffering.start=self.performance.now(),n.parsing.end=n.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var n,i,a,r;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===vM?"level":"track"} ${e.level} (frag:[${(null!=(n=e.startPTS)?n:NaN).toFixed(3)}-${(null!=(i=e.endPTS)?i:NaN).toFixed(3)}] > buffer:${o?eE(FT.getBuffered(o)):"(detached)"})`),"initSegment"!==e.sn){var s;if(e.type!==bM){const t=e.elementaryStreams;if(!Object.keys(t).some((e=>!!t[e])))return void(this.state=nE)}const t=null==(s=this.levels)?void 0:s[e.level];null!=t&&t.fragmentError&&(this.log(`Resetting level fragment error count of ${t.fragmentError} on frag buffered`),t.fragmentError=0)}this.state=nE,o&&(!this.loadedmetadata&&e.type==vM&&o.buffered.length&&(null==(a=this.fragCurrent)?void 0:a.sn)===(null==(r=this.fragPrevious)?void 0:r.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:n,part:i,partsLoaded:a}=e,r=!a||0===a.length||a.some((e=>!e)),o=new jT(n.level,n.sn,n.stats.chunkCount+1,0,i?i.index:-1,!r);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,n=null,i){var a;const r=null==t?void 0:t.details;if(!this.levels||!r)throw new Error(`frag load aborted, missing level${r?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(a=e.decryptdata)&&a.key?!e.encrypted&&r.encryptedFragments.length&&this.keyLoader.loadClear(e,r.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${r.startSN}-${r.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=iE,this.fragCurrent=e,o=this.keyLoader.load(e).then((e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(rk.KEY_LOADED,e),this.state===iE&&(this.state=nE),e})),this.hls.trigger(rk.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),n=Math.max(e.start,n||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const a=r.partList;if(a&&i){n>e.end&&r.fragmentHint&&(e=r.fragmentHint);const s=this.getNextPart(a,e,n);if(s>-1){const d=a[s];let l;return this.log(`Loading part sn: ${e.sn} p: ${d.index} cc: ${e.cc} of playlist [${r.startSN}-${r.endSN}] parts [0-${s}-${a.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(n.toFixed(3))}`),this.nextLoadPosition=d.start+d.duration,this.state=aE,l=o?o.then((n=>!n||this.fragContextChanged(n.frag)?null:this.doFragPartsLoad(e,d,t,i))).catch((e=>this.handleFragLoadError(e))):this.doFragPartsLoad(e,d,t,i).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(rk.FRAG_LOADING,{frag:e,part:d,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):l}if(!e.url||this.loadedEndOfParts(a,n))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${r?"of ["+r.startSN+"-"+r.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(n.toFixed(3))}`),nk(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=aE;const s=this.config.progressive;let d;return d=s&&o?o.then((t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i))).catch((e=>this.handleFragLoadError(e))):Promise.all([this.fragmentLoader.load(e,s?i:void 0),o]).then((([e])=>(!s&&e&&i&&i(e),e))).catch((e=>this.handleFragLoadError(e))),this.hls.trigger(rk.FRAG_LOADING,{frag:e,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,n,i){return new Promise(((a,r)=>{var o;const s=[],d=null==(o=n.details)?void 0:o.partList,l=t=>{this.fragmentLoader.loadPart(e,t,i).then((i=>{s[t.index]=i;const r=i.part;this.hls.trigger(rk.FRAG_LOADED,i);const o=JM(n,e.sn,t.index+1)||QM(d,e.sn,t.index+1);if(!o)return a({frag:e,part:r,partsLoaded:s});l(o)})).catch(r)};l(t)}))}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===sk.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(rk.ERROR,t)}else this.hls.trigger(rk.ERROR,{type:ok.OTHER_ERROR,details:sk.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==sE)return void(this.fragCurrent||this.state===tE||this.state===uE||(this.state=nE));const{frag:n,part:i,level:a}=t,r=self.performance.now();n.stats.parsing.end=r,i&&(i.stats.parsing.end=r),this.updateLevelTiming(n,i,a,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:n}=this,{level:i,sn:a,part:r}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${a} of level ${i}. The current chunk will not be buffered.`),null;const o=t[i],s=r>-1?JM(o,a,r):null,d=s?s.fragment:function(e,t,n){if(null==e||!e.details)return null;const i=e.details;let a=i.fragments[t-i.startSN];return a||(a=i.fragmentHint,a&&a.sn===t?a:t<i.startSN&&n&&n.sn===t?n:null)}(o,a,n);return d?(n&&n!==d&&(d.stats=n.stats),{frag:d,part:s,level:o}):null}bufferFragmentData(e,t,n,i,a){var r;if(!e||this.state!==sE)return;const{data1:o,data2:s}=e;let d=o;if(o&&s&&(d=xS(o,s)),null==(r=d)||!r.length)return;const l={type:e.type,frag:t,part:n,chunkMeta:i,parent:t.type,data:d};if(this.hls.trigger(rk.BUFFER_APPENDING,l),e.dropped&&e.independent&&!n){if(a)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!FT.isBuffered(t,t.currentTime))return void this.flushMainBuffer(0,e.start);const n=t.currentTime,i=FT.bufferInfo(t,n,0),a=e.duration,r=Math.min(2*this.config.maxFragLookUpTolerance,.25*a),o=Math.max(Math.min(e.start-r,i.end-r),n+r);e.start-o>r&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const n=this.getLoadPosition();return nk(n)?this.getFwdBufferInfoAtPos(e,n,t):null}getFwdBufferInfoAtPos(e,t,n){const{config:{maxBufferHole:i}}=this,a=FT.bufferInfo(e,t,i);if(0===a.len&&void 0!==a.nextStart){const r=this.fragmentTracker.getBufferedFrag(t,n);if(r&&a.nextStart<r.end)return FT.bufferInfo(e,t,Math.max(a.nextStart,i))}return a}getMaxBufferLength(e){const{config:t}=this;let n;return n=e?Math.max(8*t.maxBufferSize/e,t.maxBufferLength):t.maxBufferLength,Math.min(n,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const n=this.config,i=Math.max(Math.min(e-t,n.maxBufferLength),t),a=Math.max(e-3*t,n.maxMaxBufferLength/2,i);return a>=i&&(n.maxMaxBufferLength=a,this.warn(`Reduce max buffer length to ${a}s`),!0)}getAppendedFrag(e,t=vM){const n=this.fragmentTracker.getAppendedFrag(e,vM);return n&&"fragment"in n?n.fragment:n}getNextFragment(e,t){const n=t.fragments,i=n.length;if(!i)return null;const{config:a}=this,r=n[0].start;let o;if(t.live){const s=a.initialLiveManifestSize;if(i<s)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${s})`),null;(!t.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||e<r)&&(o=this.getInitialLiveFragment(t,n),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=r&&(o=n[0]);if(!o){const n=a.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,n,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const n=this.fragmentTracker.getState(e);return(n===_T||n===IT&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,n,i,a){const r=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(null===o)return o;if(e=o,r&&e&&!e.gap&&n.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,n.nextStart,i);if(null!==t&&n.len+t.len>=a)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,n){let i=-1,a=!1,r=!0;for(let o=0,s=e.length;o<s;o++){const s=e[o];if(r=r&&!s.independent,i>-1&&n<s.start)break;const d=s.loaded;d?i=-1:(a||s.independent||r)&&s.fragment===t&&(i=o),a=d}return i}loadedEndOfParts(e,t){const n=e[e.length-1];return n&&t>n.start&&n.loaded}getInitialLiveFragment(e,t){const n=this.fragPrevious;let i=null;if(n){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${n.programDateTime}`),i=function(e,t,n){if(null===t||!Array.isArray(e)||!e.length||!nk(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;n=n||0;for(let i=0;i<e.length;++i){const a=e[i];if(dT(t,n,a))return a}return null}(t,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),!i){const a=n.sn+1;if(a>=e.startSN&&a<=e.endSN){const r=t[a-e.startSN];n.cc===r.cc&&(i=r,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=function(e,t){return rT(e,(e=>e.cc<t?1:e.cc>t?-1:0))}(t,n.cc),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,n){const{config:i}=this;let{fragPrevious:a}=this,{fragments:r,endSN:o}=n;const{fragmentHint:s}=n,{maxFragLookUpTolerance:d}=i,l=n.partList,u=!!(i.lowLatencyMode&&null!=l&&l.length&&s);let c;if(u&&s&&!this.bitrateTest&&(r=r.concat(s),o=s.sn),e<t){c=oT(a,r,e,e>t-d?0:d)}else c=r[r.length-1];if(c){const e=c.sn-n.startSN,t=this.fragmentTracker.getState(c);if((t===_T||t===IT&&c.gap)&&(a=c),a&&c.sn===a.sn&&(!u||l[0].fragment.sn>c.sn)){if(a&&c.level===a.level){const t=r[e+1];c=c.sn<o&&this.fragmentTracker.getState(t)!==_T?t:null}}}return c}synchronizeToLiveEdge(e){const{config:t,media:n}=this;if(!n)return;const i=this.hls.liveSyncPosition,a=n.currentTime,r=e.fragments[0].start,o=e.edge,s=a>=r-t.maxFragLookUpTolerance&&a<=o;if(null!==i&&n.duration>i&&(a<i||!s)){const r=void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!s&&n.readyState<4||a<o-r)&&(this.loadedmetadata||(this.nextLoadPosition=i),n.readyState&&(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${i.toFixed(3)}`),n.currentTime=i))}}alignPlaylists(e,t,n){const i=e.fragments.length;if(!i)return this.warn("No fragments in live playlist"),0;const a=e.fragments[0].start,r=!t,o=e.alignedSliding&&nk(a);if(r||!o&&!a){const{fragPrevious:a}=this;UT(a,n,e);const r=e.fragments[0].start;return this.log(`Live playlist sliding: ${r.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${a?a.sn:"na"} fragments: ${i}`),r}return a}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let n=this.startPosition;if(n<t&&(n=-1),-1===n||-1===this.lastCurrentTime){const i=null!==this.startTimeOffset,a=i?this.startTimeOffset:e.startTimeOffset;null!==a&&nk(a)?(n=t+a,a<0&&(n+=e.totalduration),n=Math.min(Math.max(t,n),t+e.totalduration),this.log(`Start time offset ${a} found in ${i?"multivariant":"media"} playlist, adjust startPosition to ${n}`),this.startPosition=n):e.live?n=this.hls.liveSyncPosition||t:this.startPosition=n=0,this.lastCurrentTime=n}this.nextLoadPosition=n}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&"initSegment"!==e.sn&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){this.fragCurrent&&(this.fragContextChanged(e)||this.state===rE)||(this.state=nE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const e=this.getCurrentContext(t.chunkMeta);e&&(t.frag=e.frag)}const n=t.frag;if(!n||n.type!==e||!this.levels)return;var i;if(this.fragContextChanged(n))return void this.warn(`Frag load error must match current frag to retry ${n.url} > ${null==(i=this.fragCurrent)?void 0:i.url}`);const a=t.details===sk.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(n,!0);const r=t.errorAction,{action:o,retryCount:s=0,retryConfig:d}=r||{};if(r&&o===hT&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const i=nT(d,s);this.warn(`Fragment ${n.sn} of ${e} ${n.level} errored with ${t.details}, retrying loading ${s+1}/${d.maxNumRetry} in ${i}ms`),r.resolved=!0,this.retryDate=self.performance.now()+i,this.state=rE}else if(d&&r){if(this.resetFragmentErrors(e),!(s<d.maxNumRetry))return void hk.warn(`${t.details} reached or exceeded max retry (${s})`);a||o===cT||(r.resolved=!0)}else(null==r?void 0:r.action)===uT?this.state=hE:this.state=uE;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===sE||this.state===dE){const t=e.frag,n=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,n),a=i&&i.len>.5;a&&this.reduceMaxBufferLength(i.len,(null==t?void 0:t.duration)||10);const r=!a;return r&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${n} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),r}return!1}resetFragmentErrors(e){e===yM&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==tE&&(this.state=nE)}afterBufferFlushed(e,t,n){if(!e)return;const i=FT.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,n),this.state===lE&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=nE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,n,i){var a;const r=n.details;if(!r)return void this.warn("level.details undefined");if(!Object.keys(e.elementaryStreams).reduce(((t,a)=>{const o=e.elementaryStreams[a];if(o){const s=o.endPTS-o.startPTS;if(s<=0)return this.warn(`Could not parse fragment ${e.sn} ${a} duration reliably (${s})`),t||!1;const d=i?0:YM(r,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return this.hls.trigger(rk.LEVEL_PTS_UPDATED,{details:r,level:n,drift:d,type:a,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t}),!1)&&null===(null==(a=this.transmuxer)?void 0:a.error)){const t=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(0===n.fragmentError&&(n.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(t.message),this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${n.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=dE,this.hls.trigger(rk.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class fE{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let n;return e.length?(n=1===e.length?e[0]:function(e,t){const n=new Uint8Array(t);let i=0;for(let t=0;t<e.length;t++){const a=e[t];n.set(a,i),i+=a.length}return n}(e,t),this.reset(),n):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}function gE(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class pE{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,n,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,n){}demux(e,t){this.cachedData&&(e=xS(this.cachedData,e),this.cachedData=null);let n,i=Vk(e,0),a=i?i.length:0;const r=this._audioTrack,o=this._id3Track,s=i?Jk(i):void 0,d=e.length;for((null===this.basePTS||0===this.frameIndex&&nk(s))&&(this.basePTS=vE(s,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&i.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:xM,duration:Number.POSITIVE_INFINITY});a<d;){if(this.canParse(e,a)){const t=this.appendFrame(r,e,a);t?(this.frameIndex++,this.lastPTS=t.sample.pts,a+=t.length,n=a):a=d}else qk(e,a)?(i=Vk(e,a),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:xM,duration:Number.POSITIVE_INFINITY}),a+=i.length,n=a):a++;if(a===d&&n!==d){const t=Gk(e,n);this.cachedData?this.cachedData=xS(this.cachedData,t):this.cachedData=t}}return{audioTrack:r,videoTrack:gE(),id3Track:o,textTrack:gE()}}demuxSampleAes(e,t,n){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:gE(),id3Track:this._id3Track,textTrack:gE()}}destroy(){}}const vE=(e,t,n)=>{if(nk(e))return 90*e;return 9e4*t+(n?9e4*n.baseTime/n.timescale:0)};function yE(e,t){return 255===e[t]&&240==(246&e[t+1])}function bE(e,t){return 1&e[t+1]?7:9}function wE(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function kE(e,t){return t+1<e.length&&yE(e,t)}function SE(e,t){if(kE(e,t)){const n=bE(e,t);if(t+n>=e.length)return!1;const i=wE(e,t);if(i<=n)return!1;const a=t+i;return a===e.length||kE(e,a)}return!1}function ME(e,t,n,i,a){if(!e.samplerate){const r=function(e,t,n,i){let a,r,o,s;const d=navigator.userAgent.toLowerCase(),l=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];a=1+((192&t[n+2])>>>6);const c=(60&t[n+2])>>>2;if(!(c>u.length-1))return o=(1&t[n+2])<<2,o|=(192&t[n+3])>>>6,hk.log(`manifest codec:${i}, ADTS type:${a}, samplingIndex:${c}`),/firefox/i.test(d)?c>=6?(a=5,s=new Array(4),r=c-3):(a=2,s=new Array(2),r=c):-1!==d.indexOf("android")?(a=2,s=new Array(2),r=c):(a=5,s=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&c>=6?r=c-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(c>=6&&1===o||/vivaldi/i.test(d))||!i&&1===o)&&(a=2,s=new Array(2)),r=c)),s[0]=a<<3,s[0]|=(14&c)>>1,s[1]|=(1&c)<<7,s[1]|=o<<3,5===a&&(s[1]|=(14&r)>>1,s[2]=(1&r)<<7,s[2]|=8,s[3]=0),{config:s,samplerate:u[c],channelCount:o,codec:"mp4a.40."+a,manifestCodec:l};{const t=new Error(`invalid ADTS sampling index:${c}`);e.emit(rk.ERROR,rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_PARSING_ERROR,fatal:!0,error:t,reason:t.message})}}(t,n,i,a);if(!r)return;e.config=r.config,e.samplerate=r.samplerate,e.channelCount=r.channelCount,e.codec=r.codec,e.manifestCodec=r.manifestCodec,hk.log(`parsed codec:${e.codec}, rate:${r.samplerate}, channels:${r.channelCount}`)}}function TE(e){return 9216e4/e}function EE(e,t,n,i,a){const r=i+a*TE(e.samplerate),o=function(e,t){const n=bE(e,t);if(t+n<=e.length){const i=wE(e,t)-n;if(i>0)return{headerLength:n,frameLength:i}}}(t,n);let s;if(o){const{frameLength:i,headerLength:a}=o,d=a+i,l=Math.max(0,n+d-t.length);l?(s=new Uint8Array(d-a),s.set(t.subarray(n+a,t.length),0)):s=t.subarray(n+a,n+d);const u={unit:s,pts:r};return l||e.samples.push(u),{sample:u,length:d,missing:l}}const d=t.length-n;s=new Uint8Array(d),s.set(t.subarray(n,t.length),0);return{sample:{unit:s,pts:r},length:d,missing:-1}}let PE=null;const AE=[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],xE=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],CE=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],LE=[0,1,1,4];function DE(e,t,n,i,a){if(n+24>t.length)return;const r=IE(t,n);if(r&&n+r.frameLength<=t.length){const o=i+a*(9e4*r.samplesPerFrame/r.sampleRate),s={unit:t.subarray(n,n+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 IE(e,t){const n=e[t+1]>>3&3,i=e[t+1]>>1&3,a=e[t+2]>>4&15,r=e[t+2]>>2&3;if(1!==n&&0!==a&&15!==a&&3!==r){const o=e[t+2]>>1&1,s=e[t+3]>>6,d=1e3*AE[14*(3===n?3-i:3===i?3:4)+a-1],l=xE[3*(3===n?0:2===n?1:2)+r],u=3===s?1:2,c=CE[n][i],h=LE[i],m=8*c*h,f=Math.floor(c*d/l+o)*h;if(null===PE){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);PE=e?parseInt(e[1]):0}return!!PE&&PE<=87&&2===i&&d>=224e3&&0===s&&(e[t+3]=128|e[t+3]),{sampleRate:l,channelCount:u,frameLength:f,samplesPerFrame:m}}}function _E(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function RE(e,t){return t+1<e.length&&_E(e,t)}function WE(e,t){if(t+1<e.length&&_E(e,t)){const n=4,i=IE(e,t);let a=n;null!=i&&i.frameLength&&(a=i.frameLength);const r=t+a;return r===e.length||RE(e,r)}return!1}const NE=/\/emsg[-/]ID3/i;const OE=(e,t)=>{let n=0,i=5;t+=i;const a=new Uint32Array(1),r=new Uint32Array(1),o=new Uint8Array(1);for(;i>0;){o[0]=e[t];const s=Math.min(i,8),d=8-s;r[0]=4278190080>>>24+d<<d,a[0]=(o[0]&r[0])>>d,n=n?n<<s|a[0]:a[0],t+=1,i-=s}return n};class FE extends pE{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,n){const i=jE(e,t,n,this.basePTS,this.frameIndex);if(-1!==i){return{sample:e.samples[e.samples.length-1],length:i,missing:0}}}static probe(e){if(!e)return!1;const t=Vk(e,0);if(!t)return!1;const n=t.length;return 11===e[n]&&119===e[n+1]&&void 0!==Jk(t)&&OE(e,n)<16}}function jE(e,t,n,i,a){if(n+8>t.length)return-1;if(11!==t[n]||119!==t[n+1])return-1;const r=t[n+4]>>6;if(r>=3)return-1;const o=[48e3,44100,32e3][r],s=63&t[n+4],d=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(n+d>t.length)return-1;const l=t[n+6]>>5;let u=0;2===l?u+=2:(1&l&&1!==l&&(u+=2),4&l&&(u+=2));const c=(t[n+6]<<8|t[n+7])>>12-u&1,h=[2,1,2,3,3,4,4,5][l]+c,m=t[n+5]>>3,f=7&t[n+5],g=new Uint8Array([r<<6|m<<1|f>>2,(3&f)<<6|l<<3|c<<2|s>>4,s<<4&224]),p=i+a*(1536/o*9e4),v=t.subarray(n,n+d);return e.config=g,e.channelCount=h,e.samplerate=o,e.samples.push({unit:v,pts:p}),d}class zE{constructor(){this.VideoSample=null}createVideoSample(e,t,n,i){return{key:e,frame:!1,pts:t,dts:n,units:[],debug:i,length:0}}getLastNalUnit(e){var t;let n,i=this.VideoSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;n=e[e.length-1]}return n}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const n=t.samples,i=n.length;if(!i)return void t.dropped++;{const t=n[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&hk.log(e.pts+"/"+e.dts+":"+e.debug)}}class $E{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,n=e.byteLength-t,i=new Uint8Array(4),a=Math.min(4,t);if(0===a)throw new Error("no bytes available");i.set(e.subarray(n,n+a)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*a,this.bytesAvailable-=a}skipBits(e){let t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const n=this.word>>>32-t;if(e>32&&hk.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,t>0&&this.bitsAvailable?n<<t|this.readBits(t):n}skipLZ(){let 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()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t,n=8,i=8;for(let a=0;a<e;a++)0!==i&&(t=this.readEG(),i=(n+t+256)%256),n=0===i?n:i}readSPS(){let e,t,n,i=0,a=0,r=0,o=0;const s=this.readUByte.bind(this),d=this.readBits.bind(this),l=this.readUEG.bind(this),u=this.readBoolean.bind(this),c=this.skipBits.bind(this),h=this.skipEG.bind(this),m=this.skipUEG.bind(this),f=this.skipScalingList.bind(this);s();const g=s();if(d(5),c(3),s(),m(),100===g||110===g||122===g||244===g||44===g||83===g||86===g||118===g||128===g){const e=l();if(3===e&&c(1),m(),m(),c(1),u())for(t=3!==e?8:12,n=0;n<t;n++)u()&&f(n<6?16:64)}m();const p=l();if(0===p)l();else if(1===p)for(c(1),h(),h(),e=l(),n=0;n<e;n++)h();m(),c(1);const v=l(),y=l(),b=d(1);0===b&&c(1),c(1),u()&&(i=l(),a=l(),r=l(),o=l());let w=[1,1];if(u()&&u()){switch(s()){case 1:w=[1,1];break;case 2:w=[12,11];break;case 3:w=[10,11];break;case 4:w=[16,11];break;case 5:w=[40,33];break;case 6:w=[24,11];break;case 7:w=[20,11];break;case 8:w=[32,11];break;case 9:w=[80,33];break;case 10:w=[18,11];break;case 11:w=[15,11];break;case 12:w=[64,33];break;case 13:w=[160,99];break;case 14:w=[4,3];break;case 15:w=[3,2];break;case 16:w=[2,1];break;case 255:w=[s()<<8|s(),s()<<8|s()]}}return{width:Math.ceil(16*(v+1)-2*i-2*a),height:(2-b)*(y+1)*16-(b?2:4)*(r+o),pixelRatio:w}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class HE extends zE{parseAVCPES(e,t,n,i,a){const r=this.parseAVCNALu(e,n.data);let o,s=this.VideoSample,d=!1;n.data=null,s&&r.length&&!e.audFound&&(this.pushAccessUnit(s,e),s=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts,"")),r.forEach((i=>{var r;switch(i.type){case 1:{let t=!1;o=!0;const a=i.data;if(d&&a.length>4){const e=new $E(a).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var l;if(t)null!=(l=s)&&l.frame&&!s.key&&(this.pushAccessUnit(s,e),s=this.VideoSample=null);s||(s=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts,"")),s.frame=!0,s.key=t;break}case 5:o=!0,null!=(r=s)&&r.frame&&!s.key&&(this.pushAccessUnit(s,e),s=this.VideoSample=null),s||(s=this.VideoSample=this.createVideoSample(!0,n.pts,n.dts,"")),s.key=!0,s.frame=!0;break;case 6:o=!0,DS(i.data,1,n.pts,t.samples);break;case 7:{var u,c;o=!0,d=!0;const t=i.data,n=new $E(t).readSPS();if(!e.sps||e.width!==n.width||e.height!==n.height||(null==(u=e.pixelRatio)?void 0:u[0])!==n.pixelRatio[0]||(null==(c=e.pixelRatio)?void 0:c[1])!==n.pixelRatio[1]){e.width=n.width,e.height=n.height,e.pixelRatio=n.pixelRatio,e.sps=[t],e.duration=a;const i=t.subarray(1,4);let r="avc1.";for(let e=0;e<3;e++){let t=i[e].toString(16);t.length<2&&(t="0"+t),r+=t}e.codec=r}break}case 8:o=!0,e.pps=[i.data];break;case 9:o=!0,e.audFound=!0,s&&this.pushAccessUnit(s,e),s=this.VideoSample=this.createVideoSample(!1,n.pts,n.dts,"");break;case 12:o=!0;break;default:o=!1,s&&(s.debug+="unknown NAL "+i.type+" ")}if(s&&o){s.units.push(i)}})),i&&s&&(this.pushAccessUnit(s,e),this.VideoSample=null)}parseAVCNALu(e,t){const n=t.byteLength;let i=e.naluState||0;const a=i,r=[];let o,s,d,l=0,u=-1,c=0;for(-1===i&&(u=0,c=31&t[0],i=0,l=1);l<n;)if(o=t[l++],i)if(1!==i)if(o)if(1===o){if(s=l-i-1,u>=0){const e={data:t.subarray(u,s),type:c};r.push(e)}else{const n=this.getLastNalUnit(e.samples);n&&(a&&l<=4-a&&n.state&&(n.data=n.data.subarray(0,n.data.byteLength-a)),s>0&&(n.data=xS(n.data,t.subarray(0,s)),n.state=0))}l<n?(d=31&t[l],u=l,c=d,i=0):i=-1}else i=0;else i=3;else i=o?0:2;else i=o?0:1;if(u>=0&&i>=0){const e={data:t.subarray(u,n),type:c,state:i};r.push(e)}if(0===r.length){const n=this.getLastNalUnit(e.samples);n&&(n.data=xS(n.data,t))}return e.naluState=i,r}}class UE{constructor(e,t,n){this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new ZT(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,n){const i=e[t].unit;if(i.length<=16)return;const a=i.subarray(16,i.length-i.length%16),r=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(r).then((a=>{const r=new Uint8Array(a);i.set(r,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,n)}))}decryptAacSamples(e,t,n){for(;;t++){if(t>=e.length)return void n();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,n),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,n=new Int8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)n.set(e.subarray(t,t+16),i);return n}getAvcDecryptedUnit(e,t){const n=new Uint8Array(t);let i=0;for(let t=32;t<e.length-16;t+=160,i+=16)e.set(n.subarray(i,i+16),t);return e}decryptAvcSample(e,t,n,i,a){const r=IS(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,n+1,i)}))}decryptAvcSamples(e,t,n,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,n=0){if(t>=e.length)return void i();const a=e[t].units;for(;!(n>=a.length);n++){const r=a[n];if(!(r.data.length<=48||1!==r.type&&5!==r.type||(this.decryptAvcSample(e,t,n,i,r),this.decrypter.isSync())))return}}}}const BE=188;class GE{constructor(e,t,n){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._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=e,this.config=t,this.typeSupported=n,this.videoParser=new HE}static probe(e){const t=GE.syncOffset(e);return t>0&&hk.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),-1!==t}static syncOffset(e){const t=e.length;let n=Math.min(940,t-BE)+1,i=0;for(;i<n;){let a=!1,r=-1,o=0;for(let s=i;s<t;s+=BE){if(71!==e[s]||t-s!==BE&&71!==e[s+BE]){if(o)return-1;break}if(o++,-1===r&&(r=s,0!==r&&(n=Math.min(r+18612,e.length-BE)+1)),a||(a=0===XE(e,s)),a&&o>1&&(0===r&&o>2||s+BE>n))return r}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:hS[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,n,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=GE.createTrack("video"),this._audioTrack=GE.createTrack("audio",i),this._id3Track=GE.createTrack("id3"),this._txtTrack=GE.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=n,this._duration=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:n}=this;e&&(e.pesData=null),t&&(t.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,n=!1,i=!1){let a;n||(this.sampleAes=null);const r=this._videoTrack,o=this._audioTrack,s=this._id3Track,d=this._txtTrack;let l=r.pid,u=r.pesData,c=o.pid,h=s.pid,m=o.pesData,f=s.pesData,g=null,p=this.pmtParsed,v=this._pmtId,y=e.length;if(this.remainderData&&(y=(e=xS(this.remainderData,e)).length,this.remainderData=null),y<BE&&!i)return this.remainderData=e,{audioTrack:o,videoTrack:r,id3Track:s,textTrack:d};const b=Math.max(0,GE.syncOffset(e));y-=(y-b)%BE,y<e.byteLength&&!i&&(this.remainderData=new Uint8Array(e.buffer,y,e.buffer.byteLength-y));let w=0;for(let t=b;t<y;t+=BE)if(71===e[t]){const i=!!(64&e[t+1]),y=XE(e,t);let w;if((48&e[t+3])>>4>1){if(w=t+5+e[t+4],w===t+BE)continue}else w=t+4;switch(y){case l:i&&(u&&(a=JE(u))&&this.videoParser.parseAVCPES(r,d,a,!1,this._duration),u={data:[],size:0}),u&&(u.data.push(e.subarray(w,t+BE)),u.size+=t+BE-w);break;case c:if(i){if(m&&(a=JE(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a);break;case"ac3":this.parseAC3PES(o,a)}m={data:[],size:0}}m&&(m.data.push(e.subarray(w,t+BE)),m.size+=t+BE-w);break;case h:i&&(f&&(a=JE(f))&&this.parseID3PES(s,a),f={data:[],size:0}),f&&(f.data.push(e.subarray(w,t+BE)),f.size+=t+BE-w);break;case 0:i&&(w+=e[w]+1),v=this._pmtId=YE(e,w);break;case v:{i&&(w+=e[w]+1);const a=VE(e,w,this.typeSupported,n,this.observer);l=a.videoPid,l>0&&(r.pid=l,r.segmentCodec=a.segmentVideoCodec),c=a.audioPid,c>0&&(o.pid=c,o.segmentCodec=a.segmentAudioCodec),h=a.id3Pid,h>0&&(s.pid=h),null===g||p||(hk.warn(`MPEG-TS PMT found at ${t} after unknown PID '${g}'. Backtracking to sync byte @${b} to parse all TS packets.`),g=null,t=b-188),p=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=y}}else w++;w>0&&KE(this.observer,new Error(`Found ${w} TS packet/s that do not start with 0x47`)),r.pesData=u,o.pesData=m,s.pesData=f;const k={audioTrack:o,videoTrack:r,id3Track:s,textTrack:d};return i&&this.extractRemainingSamples(k),k}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:n,id3Track:i,textTrack:a}=e,r=n.pesData,o=t.pesData,s=i.pesData;let d;if(r&&(d=JE(r))?(this.videoParser.parseAVCPES(n,a,d,!0,this._duration),n.pesData=null):n.pesData=r,o&&(d=JE(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d)}t.pesData=null}else null!=o&&o.size&&hk.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;s&&(d=JE(s))?(this.parseID3PES(i,d),i.pesData=null):i.pesData=s}demuxSampleAes(e,t,n){const i=this.demux(e,n,!0,!this.config.progressive),a=this.sampleAes=new UE(this.observer,this.config,t);return this.decrypt(i,a)}decrypt(e,t){return new Promise((n=>{const{audioTrack:i,videoTrack:a}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,(()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,(()=>{n(e)})):n(e)})):a.samples&&t.decryptAvcSamples(a.samples,0,0,(()=>{n(e)}))}))}destroy(){this._duration=0}parseAACPES(e,t){let n=0;const i=this.aacOverFlow;let a,r,o,s=t.data;if(i){this.aacOverFlow=null;const t=i.missing,a=i.sample.unit.byteLength;if(-1===t)s=xS(i.sample.unit,s);else{const r=a-t;i.sample.unit.set(s.subarray(0,t),r),e.samples.push(i.sample),n=i.missing}}for(a=n,r=s.length;a<r-1&&!kE(s,a);a++);if(a!==n){let e;const t=a<r-1;if(e=t?`AAC PES did not start with ADTS header,offset:${a}`:"No ADTS header found in AAC PES",KE(this.observer,new Error(e),t),!t)return}if(ME(e,this.observer,s,a,this.audioCodec),void 0!==t.pts)o=t.pts;else{if(!i)return void hk.warn("[tsdemuxer]: AAC PES unknown PTS");{const t=TE(e.samplerate);o=i.sample.pts+t}}let d,l=0;for(;a<r;){if(d=EE(e,s,a,o,l),a+=d.length,d.missing){this.aacOverFlow=d;break}for(l++;a<r-1&&!kE(s,a);a++);}}parseMPEGPES(e,t){const n=t.data,i=n.length;let a=0,r=0;const o=t.pts;if(void 0!==o)for(;r<i;)if(RE(n,r)){const t=DE(e,n,r,o,a);if(!t)break;r+=t.length,a++}else r++;else hk.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(e,t){{const n=t.data,i=t.pts;if(void 0===i)return void hk.warn("[tsdemuxer]: AC3 PES unknown PTS");const a=n.length;let r,o=0,s=0;for(;s<a&&(r=jE(e,n,s,i,o++))>0;)s+=r}}parseID3PES(e,t){if(void 0===t.pts)return void hk.warn("[tsdemuxer]: ID3 PES unknown PTS");const n=tk({},t,{type:this._videoTrack?LM:xM,duration:Number.POSITIVE_INFINITY});e.samples.push(n)}}function XE(e,t){return((31&e[t+1])<<8)+e[t+2]}function YE(e,t){return(31&e[t+10])<<8|e[t+11]}function VE(e,t,n,i,a){const r={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=t+3+((15&e[t+1])<<8|e[t+2])-4;for(t+=12+((15&e[t+10])<<8|e[t+11]);t<o;){const o=XE(e,t),s=(15&e[t+3])<<8|e[t+4];switch(e[t]){case 207:if(!i){qE("ADTS AAC");break}case 15:-1===r.audioPid&&(r.audioPid=o);break;case 21:-1===r.id3Pid&&(r.id3Pid=o);break;case 219:if(!i){qE("H.264");break}case 27:-1===r.videoPid&&(r.videoPid=o,r.segmentVideoCodec="avc");break;case 3:case 4:n.mpeg||n.mp3?-1===r.audioPid&&(r.audioPid=o,r.segmentAudioCodec="mp3"):hk.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){qE("AC-3");break}case 129:n.ac3?-1===r.audioPid&&(r.audioPid=o,r.segmentAudioCodec="ac3"):hk.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===r.audioPid&&s>0){let i=t+5,a=s;for(;a>2;){if(106===e[i])!0!==n.ac3?hk.log("AC-3 audio found, not supported in this browser for now"):(r.audioPid=o,r.segmentAudioCodec="ac3");const t=e[i+1]+2;i+=t,a-=t}}break;case 194:case 135:return KE(a,new Error("Unsupported EC-3 in M2TS found")),r;case 36:return KE(a,new Error("Unsupported HEVC in M2TS found")),r}t+=s+5}return r}function KE(e,t,n){hk.warn(`parsing error: ${t.message}`),e.emit(rk.ERROR,rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_PARSING_ERROR,fatal:!1,levelRetry:n,error:t,reason:t.message})}function qE(e){hk.log(`${e} with AES-128-CBC encryption found in unencrypted stream`)}function JE(e){let t,n,i,a,r,o=0;const s=e.data;if(!e||0===e.size)return null;for(;s[0].length<19&&s.length>1;)s[0]=xS(s[0],s[1]),s.splice(1,1);t=s[0];if(1===(t[0]<<16)+(t[1]<<8)+t[2]){if(n=(t[4]<<8)+t[5],n&&n>e.size-6)return null;const d=t[7];192&d&&(a=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&d?(r=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,a-r>54e5&&(hk.warn(`${Math.round((a-r)/9e4)}s delta between PTS and DTS, align them`),a=r)):r=a),i=t[8];let l=i+9;if(e.size<=l)return null;e.size-=l;const u=new Uint8Array(e.size);for(let e=0,n=s.length;e<n;e++){t=s[e];let n=t.byteLength;if(l){if(l>n){l-=n;continue}t=t.subarray(l),n-=l,l=0}u.set(t,o),o+=n}return n&&(n-=i+3),{data:u,pts:a,dts:r,len:n}}return null}class QE{static getSilentFrame(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])}}}const ZE=Math.pow(2,32)-1;class eP{static init(){let e;for(e in eP.types={avc1:[],avcC:[],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:[]},eP.types)eP.types.hasOwnProperty(e)&&(eP.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]);eP.HDLR_TYPES={video:t,audio:n};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),a=new Uint8Array([0,0,0,0,0,0,0,0]);eP.STTS=eP.STSC=eP.STCO=a,eP.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),eP.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),eP.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),eP.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const r=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),s=new Uint8Array([0,0,0,1]);eP.FTYP=eP.box(eP.types.ftyp,r,s,r,o),eP.DINF=eP.box(eP.types.dinf,eP.box(eP.types.dref,i))}static box(e,...t){let n=8,i=t.length;const a=i;for(;i--;)n+=t[i].byteLength;const 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),i=0,n=8;i<a;i++)r.set(t[i],n),n+=t[i].byteLength;return r}static hdlr(e){return eP.box(eP.types.hdlr,eP.HDLR_TYPES[e])}static mdat(e){return eP.box(eP.types.mdat,e)}static mdhd(e,t){t*=e;const n=Math.floor(t/(ZE+1)),i=Math.floor(t%(ZE+1));return eP.box(eP.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return eP.box(eP.types.mdia,eP.mdhd(e.timescale,e.duration),eP.hdlr(e.type),eP.minf(e))}static mfhd(e){return eP.box(eP.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?eP.box(eP.types.minf,eP.box(eP.types.smhd,eP.SMHD),eP.DINF,eP.stbl(e)):eP.box(eP.types.minf,eP.box(eP.types.vmhd,eP.VMHD),eP.DINF,eP.stbl(e))}static moof(e,t,n){return eP.box(eP.types.moof,eP.mfhd(e),eP.traf(n,t))}static moov(e){let t=e.length;const n=[];for(;t--;)n[t]=eP.trak(e[t]);return eP.box.apply(null,[eP.types.moov,eP.mvhd(e[0].timescale,e[0].duration)].concat(n).concat(eP.mvex(e)))}static mvex(e){let t=e.length;const n=[];for(;t--;)n[t]=eP.trex(e[t]);return eP.box.apply(null,[eP.types.mvex,...n])}static mvhd(e,t){t*=e;const n=Math.floor(t/(ZE+1)),i=Math.floor(t%(ZE+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24,n>>16&255,n>>8&255,255&n,i>>24,i>>16&255,i>>8&255,255&i,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 eP.box(eP.types.mvhd,a)}static sdtp(e){const t=e.samples||[],n=new Uint8Array(4+t.length);let i,a;for(i=0;i<t.length;i++)a=t[i].flags,n[i+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return eP.box(eP.types.sdtp,n)}static stbl(e){return eP.box(eP.types.stbl,eP.stsd(e),eP.box(eP.types.stts,eP.STTS),eP.box(eP.types.stsc,eP.STSC),eP.box(eP.types.stsz,eP.STSZ),eP.box(eP.types.stco,eP.STCO))}static avc1(e){let t,n,i,a=[],r=[];for(t=0;t<e.sps.length;t++)n=e.sps[t],i=n.byteLength,a.push(i>>>8&255),a.push(255&i),a=a.concat(Array.prototype.slice.call(n));for(t=0;t<e.pps.length;t++)n=e.pps[t],i=n.byteLength,r.push(i>>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(n));const o=eP.box(eP.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|e.sps.length].concat(a).concat([e.pps.length]).concat(r))),s=e.width,d=e.height,l=e.pixelRatio[0],u=e.pixelRatio[1];return eP.box(eP.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,s>>8&255,255&s,d>>8&255,255&d,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]),o,eP.box(eP.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),eP.box(eP.types.pasp,new Uint8Array([l>>24,l>>16&255,l>>8&255,255&l,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0])}static mp4a(e){return eP.box(eP.types.mp4a,eP.audioStsd(e),eP.box(eP.types.esds,eP.esds(e)))}static mp3(e){return eP.box(eP.types[".mp3"],eP.audioStsd(e))}static ac3(e){return eP.box(eP.types["ac-3"],eP.audioStsd(e),eP.box(eP.types.dac3,e.config))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?eP.box(eP.types.stsd,eP.STSD,eP.mp3(e)):"ac3"===e.segmentCodec?eP.box(eP.types.stsd,eP.STSD,eP.ac3(e)):eP.box(eP.types.stsd,eP.STSD,eP.mp4a(e)):eP.box(eP.types.stsd,eP.STSD,eP.avc1(e))}static tkhd(e){const t=e.id,n=e.duration*e.timescale,i=e.width,a=e.height,r=Math.floor(n/(ZE+1)),o=Math.floor(n%(ZE+1));return eP.box(eP.types.tkhd,new Uint8Array([1,0,0,7,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,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,o>>24,o>>16&255,o>>8&255,255&o,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,i>>8&255,255&i,0,0,a>>8&255,255&a,0,0]))}static traf(e,t){const n=eP.sdtp(e),i=e.id,a=Math.floor(t/(ZE+1)),r=Math.floor(t%(ZE+1));return eP.box(eP.types.traf,eP.box(eP.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),eP.box(eP.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,r>>24,r>>16&255,r>>8&255,255&r])),eP.trun(e,n.length+16+20+8+16+8+8),n)}static trak(e){return e.duration=e.duration||4294967295,eP.box(eP.types.trak,eP.tkhd(e),eP.mdia(e))}static trex(e){const t=e.id;return eP.box(eP.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const n=e.samples||[],i=n.length,a=12+16*i,r=new Uint8Array(a);let o,s,d,l,u,c;for(t+=8+a,r.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),o=0;o<i;o++)s=n[o],d=s.duration,l=s.size,u=s.flags,c=s.cts,r.set([d>>>24&255,d>>>16&255,d>>>8&255,255&d,l>>>24&255,l>>>16&255,l>>>8&255,255&l,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,c>>>24&255,c>>>16&255,c>>>8&255,255&c],12+16*o);return eP.box(eP.types.trun,r)}static initSegment(e){eP.types||eP.init();const t=eP.moov(e);return xS(eP.FTYP,t)}}eP.types=void 0,eP.HDLR_TYPES=void 0,eP.STTS=void 0,eP.STSC=void 0,eP.STCO=void 0,eP.STSZ=void 0,eP.VMHD=void 0,eP.SMHD=void 0,eP.STSD=void 0,eP.FTYP=void 0,eP.DINF=void 0;const tP=9e4;function nP(e,t,n=1,i=!1){const a=e*t*n;return i?Math.round(a):a}function iP(e,t=!1){return nP(e,1e3,1/tP,t)}let aP,rP=null,oP=null;class sP{constructor(e,t,n,i=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=n,this.ISGenerated=!1,null===rP){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);rP=e?parseInt(e[1]):0}if(null===oP){const e=navigator.userAgent.match(/Safari\/(\d+)/i);oP=e?parseInt(e[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){hk.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){hk.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){hk.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const n=e.reduce(((e,n)=>{const i=n.pts-e;return i<-4294967296?(t=!0,dP(e,n.pts)):i>0?e:n.pts}),e[0].pts);return t&&hk.debug("PTS rollover detected"),n}remux(e,t,n,i,a,r,o,s){let d,l,u,c,h,m,f=a,g=a;const p=e.pid>-1,v=t.pid>-1,y=t.samples.length,b=e.samples.length>0,w=o&&y>0||y>1;if((!p||b)&&(!v||w)||this.ISGenerated||o){if(this.ISGenerated){var k,S,M,T;const e=this.videoTrackConfig;!e||t.width===e.width&&t.height===e.height&&(null==(k=t.pixelRatio)?void 0:k[0])===(null==(S=e.pixelRatio)?void 0:S[0])&&(null==(M=t.pixelRatio)?void 0:M[1])===(null==(T=e.pixelRatio)?void 0:T[1])||this.resetInitSegment()}else u=this.generateIS(e,t,a,r);const n=this.isVideoContiguous;let i,o=-1;if(w&&(o=function(e){for(let t=0;t<e.length;t++)if(e[t].key)return t;return-1}(t.samples),!n&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,o>0){hk.warn(`[mp4-remuxer]: Dropped ${o} out of ${y} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(o),t.dropped+=o,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else-1===o&&(hk.warn(`[mp4-remuxer]: No keyframe found out of ${y} video samples`),m=!1);if(this.ISGenerated){if(b&&w){const n=this.getVideoStartPts(t.samples),i=(dP(e.samples[0].pts,n)-n)/t.inputTimeScale;f+=Math.max(0,i),g+=Math.max(0,-i)}if(b){if(e.samplerate||(hk.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,a,r)),l=this.remuxAudio(e,f,this.isAudioContiguous,r,v||w||s===yM?g:void 0),w){const i=l?l.endPTS-l.startPTS:0;t.inputTimeScale||(hk.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,a,r)),d=this.remuxVideo(t,g,n,i)}}else w&&(d=this.remuxVideo(t,g,n,0));d&&(d.firstKeyFrame=o,d.independent=-1!==o,d.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(n.samples.length&&(h=lP(n,a,this._initPTS,this._initDTS)),i.samples.length&&(c=uP(i,a,this._initPTS))),{audio:l,video:d,initSegment:u,independent:m,text:c,id3:h}}generateIS(e,t,n,i){const a=e.samples,r=t.samples,o=this.typeSupported,s={},d=this._initPTS;let l,u,c,h=!d||i,m="audio/mp4";if(h&&(l=u=1/0),e.config&&a.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(m="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3"}s.audio={id:"audio",container:m,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&o.mpeg?new Uint8Array(0):eP.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(c=e.inputTimeScale,d&&c===d.timescale?h=!1:l=u=a[0].pts-Math.round(c*n))}if(t.sps&&t.pps&&r.length){if(t.timescale=t.inputTimeScale,s.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:eP.initSegment([t]),metadata:{width:t.width,height:t.height}},h)if(c=t.inputTimeScale,d&&c===d.timescale)h=!1;else{const e=this.getVideoStartPts(r),t=Math.round(c*n);u=Math.min(u,dP(r[0].dts,e)-t),l=Math.min(l,e-t)}this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(s).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:l,timescale:c},this._initDTS={baseTime:u,timescale:c}):l=c=void 0,{tracks:s,initPTS:l,timescale:c}}remuxVideo(e,t,n,i){const a=e.inputTimeScale,r=e.samples,o=[],s=r.length,d=this._initPTS;let l,u,c=this.nextAvcDts,h=8,m=this.videoSampleDuration,f=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,p=!1;if(!n||null===c){const e=t*a,i=r[0].pts-dP(r[0].dts,r[0].pts);rP&&null!==c&&Math.abs(e-i-c)<15e3?n=!0:c=e-i}const v=d.baseTime*a/d.timescale;for(let e=0;e<s;e++){const t=r[e];t.pts=dP(t.pts-v,c),t.dts=dP(t.dts-v,c),t.dts<r[e>0?e-1:e].dts&&(p=!0)}p&&r.sort((function(e,t){const n=e.dts-t.dts,i=e.pts-t.pts;return n||i})),l=r[0].dts,u=r[r.length-1].dts;const y=u-l,b=y?Math.round(y/(s-1)):m||e.inputTimeScale/30;if(n){const e=l-c,n=e>b,i=e<-1;if((n||i)&&(n?hk.warn(`AVC: ${iP(e,!0)} ms (${e}dts) hole between fragments detected at ${t.toFixed(3)}`):hk.warn(`AVC: ${iP(-e,!0)} ms (${e}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!i||c>=r[0].pts||rP)){l=c;const t=r[0].pts-e;if(n)r[0].dts=l,r[0].pts=t;else for(let n=0;n<r.length&&!(r[n].dts>t);n++)r[n].dts-=e,r[n].pts-=e;hk.log(`Video: Initial PTS/DTS adjusted: ${iP(t,!0)}/${iP(l,!0)}, delta: ${iP(e,!0)} ms`)}}l=Math.max(0,l);let w=0,k=0,S=l;for(let e=0;e<s;e++){const t=r[e],n=t.units,i=n.length;let a=0;for(let e=0;e<i;e++)a+=n[e].data.length;k+=a,w+=i,t.length=a,t.dts<S?(t.dts=S,S+=b/4|0||1):S=t.dts,f=Math.min(t.pts,f),g=Math.max(t.pts,g)}u=r[s-1].dts;const M=k+4*w+8;let T;try{T=new Uint8Array(M)}catch(e){return void this.observer.emit(rk.ERROR,rk.ERROR,{type:ok.MUX_ERROR,details:sk.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:M,reason:`fail allocating video mdat ${M}`})}const E=new DataView(T.buffer);E.setUint32(0,M),T.set(eP.types.mdat,4);let P=!1,A=Number.POSITIVE_INFINITY,x=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,L=Number.NEGATIVE_INFINITY;for(let e=0;e<s;e++){const t=r[e],n=t.units;let d,l=0;for(let e=0,t=n.length;e<t;e++){const t=n[e],i=t.data,a=t.data.byteLength;E.setUint32(h,a),h+=4,T.set(i,h),h+=a,l+=4+a}if(e<s-1)m=r[e+1].dts-t.dts,d=r[e+1].pts-t.pts;else{const n=this.config,o=e>0?t.dts-r[e-1].dts:b;if(d=e>0?t.pts-r[e-1].pts:b,n.stretchShortVideoTrack&&null!==this.nextAudioPts){const e=Math.floor(n.maxBufferHole*a),r=(i?f+i*a:this.nextAudioPts)-t.pts;r>e?(m=r-o,m<0?m=o:P=!0,hk.log(`[mp4-remuxer]: It is approximately ${r/90} ms to the next segment; using duration ${m/90} ms for the last video frame.`)):m=o}else m=o}const u=Math.round(t.pts-t.dts);A=Math.min(A,m),C=Math.max(C,m),x=Math.min(x,d),L=Math.max(L,d),o.push(new cP(t.key,m,l,u))}if(o.length)if(rP){if(rP<70){const e=o[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(oP&&L-x<C-A&&b/C<.025&&0===o[0].cts){hk.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let e=l;for(let t=0,n=o.length;t<n;t++){const i=e+o[t].duration,a=e+o[t].cts;if(t<n-1){const e=i+o[t+1].cts;o[t].duration=e-a}else o[t].duration=t?o[t-1].duration:b;o[t].cts=0,e=i}}m=P||!m?b:m,this.nextAvcDts=c=u+m,this.videoSampleDuration=m,this.isVideoContiguous=!0;const D={data1:eP.moof(e.sequenceNumber++,l,tk({},e,{samples:o})),data2:T,startPTS:f/a,endPTS:(g+m)/a,startDTS:l/a,endDTS:c/a,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,D}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(e,t,n,i,a){const r=e.inputTimeScale,o=r/(e.samplerate?e.samplerate:r),s=this.getSamplesPerFrame(e),d=s*o,l=this._initPTS,u="mp3"===e.segmentCodec&&this.typeSupported.mpeg,c=[],h=void 0!==a;let m=e.samples,f=u?0:8,g=this.nextAudioPts||-1;const p=t*r,v=l.baseTime*r/l.timescale;if(this.isAudioContiguous=n=n||m.length&&g>0&&(i&&Math.abs(p-g)<9e3||Math.abs(dP(m[0].pts-v,p)-g)<20*d),m.forEach((function(e){e.pts=dP(e.pts-v,p)})),!n||g<0){if(m=m.filter((e=>e.pts>=0)),!m.length)return;g=0===a?0:i&&!h?Math.max(0,p):m[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let n=0,i=g;n<m.length;n++){const a=m[n],o=a.pts,s=o-i,l=Math.abs(1e3*s/r);if(s<=-t*d&&h)0===n&&(hk.warn(`Audio frame @ ${(o/r).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*s/r)} ms.`),this.nextAudioPts=g=i=o);else if(s>=t*d&&l<1e4&&h){let t=Math.round(s/d);i=o-t*d,i<0&&(t--,i+=d),0===n&&(this.nextAudioPts=g=i),hk.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/r).toFixed(3)}s due to ${Math.round(1e3*s/r)} ms gap.`);for(let r=0;r<t;r++){const t=Math.max(i,0);let r=QE.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);r||(hk.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),r=a.unit.subarray()),m.splice(n,0,{unit:r,pts:t}),i+=d,n++}}a.pts=i,i+=d}}let y,b=null,w=null,k=0,S=m.length;for(;S--;)k+=m[S].unit.byteLength;for(let t=0,i=m.length;t<i;t++){const i=m[t],a=i.unit;let r=i.pts;if(null!==w){c[t-1].duration=Math.round((r-w)/o)}else{if(n&&"aac"===e.segmentCodec&&(r=g),b=r,!(k>0))return;k+=f;try{y=new Uint8Array(k)}catch(e){return void this.observer.emit(rk.ERROR,rk.ERROR,{type:ok.MUX_ERROR,details:sk.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:k,reason:`fail allocating audio mdat ${k}`})}if(!u){new DataView(y.buffer).setUint32(0,k),y.set(eP.types.mdat,4)}}y.set(a,f);const d=a.byteLength;f+=d,c.push(new cP(!0,s,d,0)),w=r}const M=c.length;if(!M)return;const T=c[c.length-1];this.nextAudioPts=g=w+o*T.duration;const E=u?new Uint8Array(0):eP.moof(e.sequenceNumber++,b/o,tk({},e,{samples:c}));e.samples=[];const P=b/r,A=g/r,x={data1:E,data2:y,startPTS:P,endPTS:A,startDTS:P,endDTS:A,type:"audio",hasAudio:!0,hasVideo:!1,nb:M};return this.isAudioContiguous=!0,x}remuxEmptyAudio(e,t,n,i){const a=e.inputTimeScale,r=a/(e.samplerate?e.samplerate:a),o=this.nextAudioPts,s=this._initDTS,d=9e4*s.baseTime/s.timescale,l=(null!==o?o:i.startDTS*a)+d,u=i.endDTS*a+d,c=1024*r,h=Math.ceil((u-l)/c),m=QE.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(hk.warn("[mp4-remuxer]: remux empty Audio"),!m)return void hk.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const f=[];for(let e=0;e<h;e++){const t=l+e*c;f.push({unit:m,pts:t,dts:t})}return e.samples=f,this.remuxAudio(e,t,n,!1)}}function dP(e,t){let n;if(null===t)return e;for(n=t<e?-8589934592:8589934592;Math.abs(e-t)>4294967296;)e+=n;return e}function lP(e,t,n,i){const a=e.samples.length;if(!a)return;const r=e.inputTimeScale;for(let o=0;o<a;o++){const a=e.samples[o];a.pts=dP(a.pts-n.baseTime*r/n.timescale,t*r)/r,a.dts=dP(a.dts-i.baseTime*r/i.timescale,t*r)/r}const o=e.samples;return e.samples=[],{samples:o}}function uP(e,t,n){const i=e.samples.length;if(!i)return;const a=e.inputTimeScale;for(let r=0;r<i;r++){const i=e.samples[r];i.pts=dP(i.pts-n.baseTime*a/n.timescale,t*a)/a}e.samples.sort(((e,t)=>e.pts-t.pts));const r=e.samples;return e.samples=[],{samples:r}}class cP{constructor(e,t,n,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=n,this.cts=i,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}function hP(e,t){const n=null==e?void 0:e.codec;if(n&&n.length>4)return n;if(t===bk){if("ec-3"===n||"ac-3"===n||"alac"===n)return n;if("fLaC"===n||"Opus"===n){return QS(n,!1)}const e="mp4a.40.5";return hk.info(`Parsed audio codec "${n}" or audio object type not handled. Using "${e}"`),e}return hk.warn(`Unhandled video codec "${n}"`),"hvc1"===n||"hev1"===n?"hvc1.1.6.L120.90":"av01"===n?"av01.0.04M.08":"avc1.42e01e"}try{aP=self.performance.now.bind(self.performance)}catch(e){hk.debug("Unable to use Performance API on this environment"),aP=null==Ck?void 0:Ck.Date.now}const mP=[{demux:class{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,n,i){const a=this.videoTrack=gE("video",1),r=this.audioTrack=gE("audio",1),o=this.txtTrack=gE("text",1);if(this.id3Track=gE("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const s=kS(e);if(s.video){const{id:e,timescale:t,codec:n}=s.video;a.id=e,a.timescale=o.timescale=t,a.codec=n}if(s.audio){const{id:e,timescale:t,codec:n}=s.audio;r.id=e,r.timescale=t,r.codec=n}o.id=hS.text,a.sampleDuration=0,a.duration=r.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return function(e){const t=e.byteLength;for(let n=0;n<t;){const i=gS(e,n);if(i>8&&109===e[n+4]&&111===e[n+5]&&111===e[n+6]&&102===e[n+7])return!0;n=i>1?n+i:t}return!1}(e)}demux(e,t){this.timeOffset=t;let n=e;const i=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(n=xS(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},n=bS(e,["moof"]);if(n.length<2)return t.remainder=e,t;const i=n[n.length-1];return t.valid=Gk(e,0,i.byteOffset-8),t.remainder=Gk(e,i.byteOffset-8),t}(n);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=n;const r=this.extractID3Track(i,t);return a.samples=CS(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:r,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,n=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return n.samples=CS(e,t),{videoTrack:t,audioTrack:gE(),id3Track:i,textTrack:gE()}}extractID3Track(e,t){const n=this.id3Track;if(e.samples.length){const i=bS(e.samples,["emsg"]);i&&i.forEach((e=>{const i=function(e){const t=e[0];let n="",i="",a=0,r=0,o=0,s=0,d=0,l=0;if(0===t){for(;"\0"!==mS(e.subarray(l,l+1));)n+=mS(e.subarray(l,l+1)),l+=1;for(n+=mS(e.subarray(l,l+1)),l+=1;"\0"!==mS(e.subarray(l,l+1));)i+=mS(e.subarray(l,l+1)),l+=1;i+=mS(e.subarray(l,l+1)),l+=1,a=gS(e,12),r=gS(e,16),s=gS(e,20),d=gS(e,24),l=28}else if(1===t){l+=4,a=gS(e,l),l+=4;const t=gS(e,l);l+=4;const r=gS(e,l);for(l+=4,o=2**32*t+r,ik(o)||(o=Number.MAX_SAFE_INTEGER,hk.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),s=gS(e,l),l+=4,d=gS(e,l),l+=4;"\0"!==mS(e.subarray(l,l+1));)n+=mS(e.subarray(l,l+1)),l+=1;for(n+=mS(e.subarray(l,l+1)),l+=1;"\0"!==mS(e.subarray(l,l+1));)i+=mS(e.subarray(l,l+1)),l+=1;i+=mS(e.subarray(l,l+1)),l+=1}return{schemeIdUri:n,value:i,timeScale:a,presentationTime:o,presentationTimeDelta:r,eventDuration:s,id:d,payload:e.subarray(l,e.byteLength)}}(e);if(NE.test(i.schemeIdUri)){const e=nk(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale;let a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);const r=i.payload;n.samples.push({data:r,len:r.byteLength,dts:e,pts:e,type:LM,duration:a})}}))}return n}demuxSampleAes(e,t,n){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,n,i){this.audioCodec=t,this.videoCodec=n,this.generateInitSegment(function(e,t){if(!e||!t)return e;const n=t.keyId;n&&t.isCommonEncryption&&bS(e,["moov","trak"]).forEach((e=>{const t=bS(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let i=bS(t,["enca"]);const a=i.length>0;a||(i=bS(t,["encv"])),i.forEach((e=>{bS(a?e.subarray(28):e.subarray(78),["sinf"]).forEach((e=>{const t=PS(e);if(t){const e=t.subarray(8,24);e.some((e=>0!==e))||(hk.log(`[eme] Patching keyId in 'enc${a?"a":"v"}>sinf>>tenc' box: ${lS.hexDump(e)} -> ${lS.hexDump(n)}`),t.set(n,8))}}))}))}));return e}(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:n}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const i=this.initData=kS(e);i.audio&&(t=hP(i.audio,bk)),i.video&&(n=hP(i.video,wk));const a={};i.audio&&i.video?a.audiovideo={container:"video/mp4",codec:t+","+n,initSegment:e,id:"main"}:i.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?a.video={container:"video/mp4",codec:n,initSegment:e,id:"main"}:hk.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,n,i,a,r){var o,s;let{initPTS:d,lastEndTime:l}=this;const u={audio:void 0,video:void 0,text:i,id3:n,initSegment:void 0};nk(l)||(l=this.lastEndTime=a||0);const c=t.samples;if(null==c||!c.length)return u;const h={initPTS:void 0,timescale:1};let m=this.initData;if(null!=(o=m)&&o.length||(this.generateInitSegment(c),m=this.initData),null==(s=m)||!s.length)return hk.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const f=function(e,t){let n=0,i=0,a=0;const r=bS(e,["moof","traf"]);for(let e=0;e<r.length;e++){const o=r[e],s=bS(o,["tfhd"])[0],d=t[gS(s,4)];if(!d)continue;const l=d.default,u=gS(s,0)|(null==l?void 0:l.flags);let c=null==l?void 0:l.duration;8&u&&(c=gS(s,2&u?12:8));const h=d.timescale||9e4,m=bS(o,["trun"]);for(let e=0;e<m.length;e++)n=AS(m[e]),!n&&c&&(n=c*gS(m[e],4)),d.type===wk?i+=n/h:d.type===bk&&(a+=n/h)}if(0===i&&0===a){let t=1/0,n=0,i=0;const a=bS(e,["sidx"]);for(let e=0;e<a.length;e++){const r=wS(a[e]);if(null!=r&&r.references){t=Math.min(t,r.earliestPresentationTime/r.timescale);const e=r.references.reduce(((e,t)=>e+t.info.duration||0),0);n=Math.max(n,e+r.earliestPresentationTime/r.timescale),i=n-t}}if(i&&nk(i))return i}return i||a}(c,m),g=function(e,t){return bS(t,["moof","traf"]).reduce(((t,n)=>{const i=bS(n,["tfdt"])[0],a=i[0],r=bS(n,["tfhd"]).reduce(((t,n)=>{const r=gS(n,4),o=e[r];if(o){let e=gS(i,4);if(1===a){if(e===uS)return hk.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=uS+1,e+=gS(i,8)}const n=e/(o.timescale||9e4);if(nk(n)&&(null===t||n<t))return n}return t}),null);return null!==r&&nk(r)&&(null===t||r<t)?r:t}),null)}(m,c),p=null===g?a:g;(function(e,t,n,i){if(null===e)return!0;const a=Math.max(i,1),r=t-e.baseTime/e.timescale;return Math.abs(r-n)>a}(d,p,a,f)||h.timescale!==d.timescale&&r)&&(h.initPTS=p-a,d&&1===d.timescale&&hk.warn("Adjusting initPTS by "+(h.initPTS-d.baseTime)),this.initPTS=d={baseTime:h.initPTS,timescale:1});const v=e?p-d.baseTime/d.timescale:l,y=v+f;!function(e,t,n){bS(t,["moof","traf"]).forEach((t=>{bS(t,["tfhd"]).forEach((i=>{const a=gS(i,4),r=e[a];if(!r)return;const o=r.timescale||9e4;bS(t,["tfdt"]).forEach((e=>{const t=e[0],i=n*o;if(i){let n=gS(e,4);if(0===t)n-=i,n=Math.max(n,0),yS(e,4,n);else{n*=Math.pow(2,32),n+=gS(e,8),n-=i,n=Math.max(n,0);const t=Math.floor(n/(uS+1)),a=Math.floor(n%(uS+1));yS(e,4,t),yS(e,8,a)}}}))}))}))}(m,c,d.baseTime/d.timescale),f>0?this.lastEndTime=y:(hk.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const b=!!m.audio,w=!!m.video;let k="";b&&(k+="audio"),w&&(k+="video");const S={data1:c,startPTS:v,startDTS:v,endPTS:y,endDTS:y,type:k,hasAudio:b,hasVideo:w,nb:1,dropped:0};return u.audio="audio"===S.type?S:void 0,u.video="audio"!==S.type?S:void 0,u.initSegment=h,u.id3=lP(n,a,d,d),i.samples.length&&(u.text=uP(i,a,d)),u}}},{demux:GE,remux:sP},{demux:class extends pE{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Vk(e,0);let n=(null==t?void 0:t.length)||0;if(WE(e,n))return!1;for(let t=e.length;n<t;n++)if(SE(e,n))return hk.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&yE(e,t)&&wE(e,t)<=e.length-t}(e,t)}appendFrame(e,t,n){ME(e,this.observer,t,n,e.manifestCodec);const i=EE(e,t,n,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:sP},{demux:class extends pE{resetInitSegment(e,t,n,i){super.resetInitSegment(e,t,n,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Vk(e,0);let n=(null==t?void 0:t.length)||0;if(t&&11===e[n]&&119===e[n+1]&&void 0!==Jk(t)&&OE(e,n)<=16)return!1;for(let t=e.length;n<t;n++)if(WE(e,n))return hk.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return function(e,t){return _E(e,t)&&4<=e.length-t}(e,t)}appendFrame(e,t,n){if(null!==this.basePTS)return DE(e,t,n,this.basePTS,this.frameIndex)}},remux:sP}];mP.splice(2,0,{demux:FE,remux:sP});class fP{constructor(e,t,n,i,a){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=n,this.vendor=i,this.id=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,n,i){const a=n.transmuxing;a.executeStart=aP();let r=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:s}=this;i&&(this.currentTransmuxState=i);const{contiguous:d,discontinuity:l,trackSwitch:u,accurateTimeOffset:c,timeOffset:h,initSegmentChange:m}=i||o,{audioCodec:f,videoCodec:g,defaultInitPts:p,duration:v,initSegmentData:y}=s,b=function(e,t){let n=null;e.byteLength>0&&null!=(null==t?void 0:t.key)&&null!==t.iv&&null!=t.method&&(n=t);return n}(r,t);if(b&&"AES-128"===b.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(r,b.key.buffer,b.iv.buffer).then((e=>{const t=this.push(e,null,n);return this.decryptionPromise=null,t})),this.decryptionPromise;{let t=e.softwareDecrypt(r,b.key.buffer,b.iv.buffer);if(n.part>-1&&(t=e.flush()),!t)return a.executeEnd=aP(),gP(n);r=new Uint8Array(t)}}const w=this.needsProbing(l,u);if(w){const e=this.configureTransmuxer(r);if(e)return hk.warn(`[transmuxer] ${e.message}`),this.observer.emit(rk.ERROR,rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),a.executeEnd=aP(),gP(n)}(l||u||m||w)&&this.resetInitSegment(y,f,g,v,t),(l||m||w)&&this.resetInitialTimestamp(p),d||this.resetContiguity();const k=this.transmux(r,b,h,c,n),S=this.currentTransmuxState;return S.contiguous=!0,S.discontinuity=!1,S.trackSwitch=!1,a.executeEnd=aP(),k}flush(e){const t=e.transmuxing;t.executeStart=aP();const{decrypter:n,currentTransmuxState:i,decryptionPromise:a}=this;if(a)return a.then((()=>this.flush(e)));const r=[],{timeOffset:o}=i;if(n){const t=n.flush();t&&r.push(this.push(t,null,e))}const{demuxer:s,remuxer:d}=this;if(!s||!d)return t.executeEnd=aP(),[gP(e)];const l=s.flush(o);return pP(l)?l.then((t=>(this.flushRemux(r,t,e),r))):(this.flushRemux(r,l,e),r)}flushRemux(e,t,n){const{audioTrack:i,videoTrack:a,id3Track:r,textTrack:o}=t,{accurateTimeOffset:s,timeOffset:d}=this.currentTransmuxState;hk.log(`[transmuxer.ts]: Flushed fragment ${n.sn}${n.part>-1?" p: "+n.part:""} of level ${n.level}`);const l=this.remuxer.remux(i,a,r,o,d,s,!0,this.id);e.push({remuxResult:l,chunkMeta:n}),n.transmuxing.executeEnd=aP()}resetInitialTimestamp(e){const{demuxer:t,remuxer:n}=this;t&&n&&(t.resetTimeStamp(e),n.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,n,i,a){const{demuxer:r,remuxer:o}=this;r&&o&&(r.resetInitSegment(e,t,n,i),o.resetInitSegment(e,t,n,a))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,n,i,a){let r;return r=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,n,i,a):this.transmuxUnencrypted(e,n,i,a),r}transmuxUnencrypted(e,t,n,i){const{audioTrack:a,videoTrack:r,id3Track:o,textTrack:s}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(a,r,o,s,t,n,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,n,i,a){return this.demuxer.demuxSampleAes(e,t,n).then((e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,n,i,!1,this.id),chunkMeta:a})))}configureTransmuxer(e){const{config:t,observer:n,typeSupported:i,vendor:a}=this;let r;for(let t=0,n=mP.length;t<n;t++){var o;if(null!=(o=mP[t].demux)&&o.probe(e)){r=mP[t];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const s=this.demuxer,d=this.remuxer,l=r.remux,u=r.demux;d&&d instanceof l||(this.remuxer=new l(n,t,i,a)),s&&s instanceof u||(this.demuxer=new u(n,t,i),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new ZT(this.config)),e}}const gP=e=>({remuxResult:{},chunkMeta:e});function pP(e){return"then"in e&&e.then instanceof Function}class vP{constructor(e,t,n,i,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=n,this.duration=i,this.defaultInitPts=a||null}}class yP{constructor(e,t,n,i,a,r){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=e,this.contiguous=t,this.accurateTimeOffset=n,this.trackSwitch=i,this.timeOffset=a,this.initSegmentChange=r}}var bP={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function r(e,t,i,r,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var s=new a(i,r||e,o),d=n?n+t:t;return e._events[d]?e._events[d].fn?e._events[d]=[e._events[d],s]:e._events[d].push(s):(e._events[d]=s,e._eventsCount++),e}function o(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function s(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(n=!1)),s.prototype.eventNames=function(){var e,i,a=[];if(0===this._eventsCount)return a;for(i in e=this._events)t.call(e,i)&&a.push(n?i.slice(1):i);return Object.getOwnPropertySymbols?a.concat(Object.getOwnPropertySymbols(e)):a},s.prototype.listeners=function(e){var t=n?n+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var a=0,r=i.length,o=new Array(r);a<r;a++)o[a]=i[a].fn;return o},s.prototype.listenerCount=function(e){var t=n?n+e:e,i=this._events[t];return i?i.fn?1:i.length:0},s.prototype.emit=function(e,t,i,a,r,o){var s=n?n+e:e;if(!this._events[s])return!1;var d,l,u=this._events[s],c=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),c){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,i),!0;case 4:return u.fn.call(u.context,t,i,a),!0;case 5:return u.fn.call(u.context,t,i,a,r),!0;case 6:return u.fn.call(u.context,t,i,a,r,o),!0}for(l=1,d=new Array(c-1);l<c;l++)d[l-1]=arguments[l];u.fn.apply(u.context,d)}else{var h,m=u.length;for(l=0;l<m;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),c){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,i);break;case 4:u[l].fn.call(u[l].context,t,i,a);break;default:if(!d)for(h=1,d=new Array(c-1);h<c;h++)d[h-1]=arguments[h];u[l].fn.apply(u[l].context,d)}}return!0},s.prototype.on=function(e,t,n){return r(this,e,t,n,!1)},s.prototype.once=function(e,t,n){return r(this,e,t,n,!0)},s.prototype.removeListener=function(e,t,i,a){var r=n?n+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||i&&s.context!==i||o(this,r);else{for(var d=0,l=[],u=s.length;d<u;d++)(s[d].fn!==t||a&&!s[d].once||i&&s[d].context!==i)&&l.push(s[d]);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=n?n+e:e,this._events[t]&&o(this,t)):(this._events=new i,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s}(bP);var wP=Uw(bP.exports);class kP{constructor(e,t,n,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=n,this.onFlush=i;const r=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===rk.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new wP,this.observer.on(rk.FRAG_DECRYPTED,r),this.observer.on(rk.ERROR,r);const o=US(a.preferManagedMediaSource)||{isTypeSupported:()=>!1},s={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&"undefined"!=typeof Worker){if(a.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{a.workerPath?(hk.log(`loading Web Worker ${a.workerPath} for "${t}"`),this.workerContext=function(e){const t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(a.workerPath)):(hk.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e);return{worker:new self.Worker(t),objectURL:t}}()),this.onwmsg=e=>this.onWorkerMessage(e);const{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{const n=new Error(`${e.message} (${e.filename}:${e.lineno})`);a.enableWorker=!1,hk.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(rk.ERROR,{type:ok.OTHER_ERROR,details:sk.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:n})},e.postMessage({cmd:"init",typeSupported:s,vendor:"",id:t,config:JSON.stringify(a)})}catch(e){hk.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new fP(this.observer,s,a,"",t)}return}}this.transmuxer=new fP(this.observer,s,a,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,n,i,a,r,o,s,d,l){var u,c;d.transmuxing.start=self.performance.now();const{transmuxer:h}=this,m=r?r.start:a.start,f=a.decryptdata,g=this.frag,p=!(g&&a.cc===g.cc),v=!(g&&d.level===g.level),y=g?d.sn-g.sn:-1,b=this.part?d.part-this.part.index:-1,w=0===y&&d.id>1&&d.id===(null==g?void 0:g.stats.chunkCount),k=!v&&(1===y||0===y&&(1===b||w&&b<=0)),S=self.performance.now();(v||y||0===a.stats.parsing.start)&&(a.stats.parsing.start=S),!r||!b&&k||(r.stats.parsing.start=S);const M=!(g&&(null==(u=a.initSegment)?void 0:u.url)===(null==(c=g.initSegment)?void 0:c.url)),T=new yP(p,k,s,v,m,M);if(!k||p||M){hk.log(`[transmuxer-interface, ${a.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}\n discontinuity: ${p}\n trackSwitch: ${v}\n contiguous: ${k}\n accurateTimeOffset: ${s}\n timeOffset: ${m}\n initSegmentChange: ${M}`);const e=new vP(n,i,t,o,l);this.configureTransmuxer(e)}if(this.frag=a,this.part=r,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:f,chunkMeta:d,state:T},e instanceof ArrayBuffer?[e]:[]);else if(h){const t=h.push(e,f,d,T);pP(t)?(h.async=!0,t.then((e=>{this.handleTransmuxComplete(e)})).catch((e=>{this.transmuxerError(e,d,"transmuxer-interface push error")}))):(h.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let n=t.flush(e);pP(n)||t.async?(pP(n)||(n=Promise.resolve(n)),n.then((t=>{this.handleFlushResult(t,e)})).catch((t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")}))):this.handleFlushResult(n,e)}}transmuxerError(e,t,n){this.hls&&(this.error=e,this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:n}))}handleFlushResult(e,t){e.forEach((e=>{this.handleTransmuxComplete(e)})),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(null==t||!t.event)return void hk.warn("worker message received with no "+(t?"event name":"data"));const n=this.hls;if(this.hls)switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":hk[t.data.logType]&&hk[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,n.trigger(t.event,t.data)}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function SP(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!MP(e[n].attrs,t[n].attrs))return!1;return!0}function MP(e,t,n){const i=e["STABLE-RENDITION-ID"];return i&&!n?i===t["STABLE-RENDITION-ID"]:!(n||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some((n=>e[n]!==t[n]))}function TP(e,t){return t.label.toLowerCase()===e.name.toLowerCase()&&(!t.language||t.language.toLowerCase()===(e.lang||"").toLowerCase())}class EP{constructor(e){this.buffered=void 0;const t=(t,n,i)=>{if((n>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${i})`);return e[n][t]};this.buffered={get length(){return e.length},end:n=>t("end",n,e.length),start:n=>t("start",n,e.length)}}}class PP{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,n){const i=this.queues[t];i.push(e),1!==i.length||n||this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const n=new Promise((e=>{t=e})),i={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,e),n}executeNext(e){const t=this.queues[e];if(t.length){const n=t[0];try{n.execute()}catch(t){hk.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${t}`),n.onError(t);const i=this.buffers[e];null!=i&&i.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const AP=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;function xP(e){const t=e.querySelectorAll("source");[].slice.call(t).forEach((t=>{e.removeChild(t)}))}const CP={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},LP=e=>String.fromCharCode(CP[e]||e),DP=15,IP=100,_P={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},RP={17:2,18:4,21:6,22:8,23:10,19:13,20:15},WP={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},NP={25:2,26:4,29:6,30:8,31:10,27:13,28:15},OP=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class FP{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const n="function"==typeof t?t():t;hk.log(`${this.time} [${e}] ${n}`)}}}const jP=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].toString(16));return t};class zP{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let n=0;n<t.length;n++){const i=t[n];e.hasOwnProperty(i)&&(this[i]=e[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class $P{constructor(){this.uchar=" ",this.penState=new zP}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class HP{constructor(e){this.chars=[],this.pos=0,this.currPenState=new zP,this.cueStartTime=null,this.logger=void 0;for(let e=0;e<IP;e++)this.chars.push(new $P);this.logger=e}equals(e){for(let t=0;t<IP;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<IP;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<IP;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>IP&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=IP)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e<t+1;e++)this.chars[e].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=LP(e);this.pos>=IP?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))}clearFromPos(e){let t;for(t=e;t<IP;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let n=0;n<IP;n++){const i=this.chars[n].uchar;" "!==i&&(t=!1),e.push(i)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e);this.chars[this.pos].setPenState(this.currPenState)}}class UP{constructor(e){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<DP;t++)this.rows.push(new HP(e));this.logger=e}reset(){for(let e=0;e<DP;e++)this.rows[e].clear();this.currRow=14}equals(e){let t=!0;for(let n=0;n<DP;n++)if(!this.rows[n].equals(e.rows[n])){t=!1;break}return t}copy(e){for(let t=0;t<DP;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<DP;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e);this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,(()=>"pacData = "+JSON.stringify(e)));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let e=0;e<DP;e++)this.rows[e].clear();const e=this.currRow+1-this.nrRollUpRows,n=this.lastOutputScreen;if(n){const i=n.rows[e].cueStartTime,a=this.logger.time;if(null!==i&&null!==a&&i<a)for(let i=0;i<this.nrRollUpRows;i++)this.rows[t-this.nrRollUpRows+i+1].copy(n.rows[e+i])}}this.currRow=t;const n=this.rows[this.currRow];if(null!==e.indent){const t=e.indent,i=Math.max(t-1,0);n.setCursor(e.indent),e.color=n.chars[i].penState.foreground}const i={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(e){this.logger.log(2,(()=>"bkgData = "+JSON.stringify(e))),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,(()=>this.getDisplayText()));const 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")}getDisplayText(e){e=e||!1;const t=[];let n="",i=-1;for(let n=0;n<DP;n++){const a=this.rows[n].getTextString();a&&(i=n+1,e?t.push("Row "+i+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(n=e?"["+t.join(" | ")+"]":t.join("\n")),n}getTextAndFormat(){return this.rows}}class BP{constructor(e,t,n){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new UP(n),this.nonDisplayedMemory=new UP(n),this.lastOutputScreen=new UP(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}reset(){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}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(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)}insertChars(e){for(let t=0;t<e.length;t++)this.writeScreen.insertChar(e[t]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,(()=>t+": "+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())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const 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)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const n=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[n]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const 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))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class GP{constructor(e,t,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new FP;this.channels=[null,new BP(e,t,i),new BP(e+1,n,i)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let e=0;e<t.length;e+=2){const n=127&t[e],i=127&t[e+1];let a=!1,r=null;if(0===n&&0===i)continue;this.logger.log(3,(()=>"["+jP([t[e],t[e+1]])+"] -> ("+jP([n,i])+")"));const o=this.cmdHistory;if(n>=16&&n<=31){if(YP(n,i,o)){XP(null,null,o),this.logger.log(3,(()=>"Repeated command ("+jP([n,i])+") is dropped"));continue}XP(n,i,this.cmdHistory),a=this.parseCmd(n,i),a||(a=this.parseMidrow(n,i)),a||(a=this.parsePAC(n,i)),a||(a=this.parseBackgroundAttributes(n,i))}else XP(null,null,o);if(!a&&(r=this.parseChars(n,i),r)){const e=this.currentChannel;if(e&&e>0){this.channels[e].insertChars(r)}else this.logger.log(2,"No channel found yet. TEXT-MODE?")}a||r||this.logger.log(2,(()=>"Couldn't parse cleaned data "+jP([n,i])+" orig: "+jP([t[e],t[e+1]])))}}parseCmd(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;const n=20===e||21===e||23===e?1:2,i=this.channels[n];return 20===e||21===e||28===e||29===e?32===t?i.ccRCL():33===t?i.ccBS():34===t?i.ccAOF():35===t?i.ccAON():36===t?i.ccDER():37===t?i.ccRU(2):38===t?i.ccRU(3):39===t?i.ccRU(4):40===t?i.ccFON():41===t?i.ccRDC():42===t?i.ccTR():43===t?i.ccRTD():44===t?i.ccEDM():45===t?i.ccCR():46===t?i.ccENM():47===t&&i.ccEOC():i.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let n=0;if((17===e||25===e)&&t>=32&&t<=47){if(n=17===e?1:2,n!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[n];return!!i&&(i.ccMIDROW(t),this.logger.log(3,(()=>"MIDROW ("+jP([e,t])+")")),!0)}return!1}parsePAC(e,t){let n;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127)&&!((16===e||24===e)&&t>=64&&t<=95))return!1;const i=e<=23?1:2;n=t>=64&&t<=95?1===i?_P[e]:WP[e]:1===i?RP[e]:NP[e];const a=this.channels[i];return!!a&&(a.setPAC(this.interpretPAC(n,t)),this.currentChannel=i,!0)}interpretPAC(e,t){let n;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return n=t>95?t-96:t-64,i.underline=!(1&~n),n<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((n-16)/2),i}parseChars(e,t){let n,i=null,a=null;if(e>=25?(n=2,a=e-8):(n=1,a=e),a>=17&&a<=19){let e;e=17===a?t+80:18===a?t+112:t+144,this.logger.log(2,(()=>"Special char '"+LP(e)+"' in channel "+n)),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);return i&&this.logger.log(3,(()=>"Char codes = "+jP(i).join(","))),i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47)&&!((23===e||31===e)&&t>=45&&t<=47))return!1;let n;const i={};16===e||24===e?(n=Math.floor((t-32)/2),i.background=OP[n],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const a=e<=23?1:2;return this.channels[a].setBkgData(i),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}XP(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const n=this.channels[t];n&&n.cueSplitAtTime(e)}}}function XP(e,t,n){n.a=e,n.b=t}function YP(e,t,n){return n.a===e&&n.b===t}class VP{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,n){(null===this.startTime||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var KP=function(){if(null!=Ck&&Ck.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function n(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const n=t.toLowerCase();return!!~e.indexOf(n)&&n}function i(e){return n(t,e)}function a(e,...t){let n=1;for(;n<arguments.length;n++){const t=arguments[n];for(const n in t)e[n]=t[n]}return e}function r(t,r,o){const s=this,d={enumerable:!0};s.hasBeenReset=!1;let l="",u=!1,c=t,h=r,m=o,f=null,g="",p=!0,v="auto",y="start",b=50,w="middle",k=50,S="middle";Object.defineProperty(s,"id",a({},d,{get:function(){return l},set:function(e){l=""+e}})),Object.defineProperty(s,"pauseOnExit",a({},d,{get:function(){return u},set:function(e){u=!!e}})),Object.defineProperty(s,"startTime",a({},d,{get:function(){return c},set:function(e){if("number"!=typeof e)throw new TypeError("Start time must be set to a number.");c=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"endTime",a({},d,{get:function(){return h},set:function(e){if("number"!=typeof e)throw new TypeError("End time must be set to a number.");h=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"text",a({},d,{get:function(){return m},set:function(e){m=""+e,this.hasBeenReset=!0}})),Object.defineProperty(s,"region",a({},d,{get:function(){return f},set:function(e){f=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"vertical",a({},d,{get:function(){return g},set:function(t){const i=function(t){return n(e,t)}(t);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(s,"snapToLines",a({},d,{get:function(){return p},set:function(e){p=!!e,this.hasBeenReset=!0}})),Object.defineProperty(s,"line",a({},d,{get:function(){return v},set:function(e){if("number"!=typeof e&&"auto"!==e)throw new SyntaxError("An invalid number or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(s,"lineAlign",a({},d,{get:function(){return y},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"position",a({},d,{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({},d,{get:function(){return w},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),Object.defineProperty(s,"size",a({},d,{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({},d,{get:function(){return S},set:function(e){const t=i(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}();class qP{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function JP(e){function t(e,t,n,i){return 3600*(0|e)+60*(0|t)+(0|n)+parseFloat(i||0)}const n=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?t(n[2],n[3],0,n[4]):t(n[1],n[2],n[3],n[4]):null}class QP{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,n){for(let i=0;i<n.length;++i)if(t===n[i]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const n=parseFloat(t);if(n>=0&&n<=100)return this.set(e,n),!0}return!1}}function ZP(e,t,n,i){const a=i?e.split(i):[e];for(const e in a){if("string"!=typeof a[e])continue;const i=a[e].split(n);if(2!==i.length)continue;t(i[0],i[1])}}const eA=new KP(0,0,""),tA="middle"===eA.align?"middle":"center";function nA(e,t,n){const i=e;function a(){const t=JP(e);if(null===t)throw new Error("Malformed timestamp: "+i);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'): "+i);e=e.slice(3),r(),t.endTime=a(),r(),function(e,t){const i=new QP;ZP(e,(function(e,t){let a;switch(e){case"region":for(let a=n.length-1;a>=0;a--)if(n[a].id===t){i.set(e,n[a].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":a=t.split(","),i.integer(e,a[0]),i.percent(e,a[0])&&i.set("snapToLines",!1),i.alt(e,a[0],["auto"]),2===a.length&&i.alt("lineAlign",a[1],["start",tA,"end"]);break;case"position":a=t.split(","),i.percent(e,a[0]),2===a.length&&i.alt("positionAlign",a[1],["start",tA,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",tA,"end","left","right"])}}),/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let a=i.get("line","auto");"auto"===a&&-1===eA.line&&(a=-1),t.line=a,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",tA);let r=i.get("position","auto");"auto"===r&&50===eA.position&&(r="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=r}(e,t)}function iA(e){return e.replace(/<br(?: \/)?>/gi,"\n")}class aA{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new qP,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function n(){let e=t.buffer,n=0;for(e=iA(e);n<e.length&&"\r"!==e[n]&&"\n"!==e[n];)++n;const i=e.slice(0,n);return"\r"===e[n]&&++n,"\n"===e[n]&&++n,t.buffer=e.slice(n),i}e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));try{let e="";if("INITIAL"===t.state){if(!/\r\n|\n/.test(t.buffer))return this;e=n();const i=e.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let i=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(i?i=!1:e=n(),t.state){case"HEADER":/:/.test(e)?ZP(e,(function(e,t){}),/:/):e||(t.state="ID");continue;case"NOTE":e||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){t.state="NOTE";break}if(!e)continue;if(t.cue=new KP(0,0,""),t.state="CUE",-1===e.indexOf("--\x3e")){t.cue.id=e;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{nA(e,t.cue,t.regionList)}catch(e){t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const n=-1!==e.indexOf("--\x3e");if(!e||n&&(i=!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+=e}continue;case"BADCUE":e||(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}flush(){const 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}}const rA=/\r\n|\n\r|\n|\r/g,oA=function(e,t,n=0){return e.slice(n,n+t.length)===t},sA=function(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return(t>>>0).toString()};function dA(e,t,n){return sA(e.toString())+sA(t.toString())+sA(n)}function lA(e,t,n,i,a,r,o){const s=new aA,d=oS(new Uint8Array(e)).trim().replace(rA,"\n").split("\n"),l=[],u=t?function(e,t=1){return nP(e,tP,1/t)}(t.baseTime,t.timescale):0;let c,h="00:00.000",m=0,f=0,g=!0;s.oncue=function(e){const r=n[i];let o=n.ccOffset;const s=(m-u)/9e4;if(null!=r&&r.new&&(void 0!==f?o=n.ccOffset=r.start:function(e,t,n){let i=e[t],a=e[i.prevCC];if(!a||!a.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(r=a)&&r.new;){var r;e.ccOffset+=i.start-a.start,i.new=!1,i=a,a=e[i.prevCC]}e.presentationOffset=n}(n,i,s)),s){if(!t)return void(c=new Error("Missing initPTS for VTT MPEGTS"));o=s-n.presentationOffset}const d=e.endTime-e.startTime,h=dP(9e4*(e.startTime+o-f),9e4*a)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+d,0);const g=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(g)),e.id||(e.id=dA(e.startTime,e.endTime,g)),e.endTime>0&&l.push(e)},s.onparsingerror=function(e){c=e},s.onflush=function(){c?o(c):r(l)},d.forEach((e=>{if(g){if(oA(e,"X-TIMESTAMP-MAP=")){g=!1,e.slice(16).split(",").forEach((e=>{oA(e,"LOCAL:")?h=e.slice(6):oA(e,"MPEGTS:")&&(m=parseInt(e.slice(7)))}));try{f=function(e){let t=parseInt(e.slice(-3));const n=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(nk(t)&&nk(n)&&nk(i)&&nk(a)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*n,t+=6e4*i,t+=36e5*a,t}(h)/1e3}catch(e){c=e}return}""===e&&(g=!1)}s.parse(e+"\n")})),s.flush()}const uA="stpp.ttml.im1t",cA=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,hA=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,mA={left:"start",center:"center",right:"end",start:"start",end:"end"};function fA(e,t,n,i){const a=bS(new Uint8Array(e),["mdat"]);if(0===a.length)return void i(new Error("Could not parse IMSC1 mdat"));const r=a.map((e=>oS(e))),o=function(e,t,n=1,i=!1){return nP(e,t,1/n,i)}(t.baseTime,1,t.timescale);try{r.forEach((e=>n(function(e,t){const n=(new DOMParser).parseFromString(e,"text/xml"),i=n.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");const a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(a).reduce(((e,t)=>(e[t]=i.getAttribute(`ttp:${t}`)||a[t],e)),{}),o="preserve"!==i.getAttribute("xml:space"),s=pA(gA(i,"styling","style")),d=pA(gA(i,"layout","region")),l=gA(i,"body","[begin]");return[].map.call(l,(e=>{const n=vA(e,o);if(!n||!e.hasAttribute("begin"))return null;const i=wA(e.getAttribute("begin"),r),a=wA(e.getAttribute("dur"),r);let l=wA(e.getAttribute("end"),r);if(null===i)throw bA(e);if(null===l){if(null===a)throw bA(e);l=i+a}const u=new KP(i-t,l-t,n);u.id=dA(u.startTime,u.endTime,u.text);const c=function(e,t,n){const i="http://www.w3.org/ns/ttml#styling";let a=null;const r=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;o&&n.hasOwnProperty(o)&&(a=n[o]);return r.reduce(((n,r)=>{const o=yA(t,i,r)||yA(e,i,r)||yA(a,i,r);return o&&(n[r]=o),n}),{})}(d[e.getAttribute("region")],s[e.getAttribute("style")],s),{textAlign:h}=c;if(h){const e=mA[h];e&&(u.lineAlign=e),u.align=h}return tk(u,c),u})).filter((e=>null!==e))}(e,o))))}catch(e){i(e)}}function gA(e,t,n){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(n)):[]}function pA(e){return e.reduce(((e,t)=>{const n=t.getAttribute("xml:id");return n&&(e[n]=t),e}),{})}function vA(e,t){return[].slice.call(e.childNodes).reduce(((e,n,i)=>{var a;return"br"===n.nodeName&&i?e+"\n":null!=(a=n.childNodes)&&a.length?vA(n,t):t?e+n.textContent.trim().replace(/\s+/g," "):e+n.textContent}),"")}function yA(e,t,n){return e&&e.hasAttributeNS(t,n)?e.getAttributeNS(t,n):null}function bA(e){return new Error(`Could not parse ttml timestamp ${e}`)}function wA(e,t){if(!e)return null;let n=JP(e);return null===n&&(cA.test(e)?n=function(e,t){const n=cA.exec(e),i=(0|n[4])+(0|n[5])/t.subFrameRate;return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+i/t.frameRate}(e,t):hA.test(e)&&(n=function(e,t){const n=hA.exec(e),i=Number(n[1]);switch(n[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),n}function kA(e){return e.characteristics&&/transcribes-spoken-dialog/gi.test(e.characteristics)&&/describes-music-and-sound/gi.test(e.characteristics)?"captions":"subtitles"}function SA(e,t){return!!e&&e.kind===kA(t)&&TP(t,e)}class MA{constructor(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=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(rk.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rk.BUFFER_CODECS,this.onBufferCodecs,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(rk.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rk.BUFFER_CODECS,this.onBufferCodecs,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const n=this.hls.levels[t.droppedLevel];this.isLevelAllowed(n)&&this.restrictedLevels.push({bitrate:n.bitrate,height:n.height,width:n.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const n=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,n.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&nk(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const e=this.hls.levels;if(e.length){const t=this.hls,n=this.getMaxLevel(e.length-1);n!==this.autoLevelCapping&&hk.log(`Setting autoLevelCapping to ${n}: ${e[n].height}p@${e[n].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=n,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const n=t.filter(((t,n)=>this.isLevelAllowed(t)&&n<=e));return this.clientRect=null,MA.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const n=e.getBoundingClientRect();t.width=n.width,t.height=n.height,t.width||t.height||(t.width=n.right-n.left||e.width||0,t.height=n.bottom-n.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(e){return!this.restrictedLevels.some((t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height))}static getMaxLevelByMediaSize(e,t,n){if(null==e||!e.length)return-1;let i=e.length-1;const a=Math.max(t,n);for(let t=0;t<e.length;t+=1){const n=e[t];if((n.width>=a||n.height>=a)&&(r=n,!(o=e[t+1])||r.width!==o.width||r.height!==o.height)){i=t;break}}var r,o;return i}}const TA="[eme]";class EA{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=EA.CDMCleanupPromise?[EA.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=hk.debug.bind(hk,TA),this.log=hk.log.bind(hk,TA),this.warn=hk.warn.bind(hk,TA),this.error=hk.error.bind(hk,TA),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(rk.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(rk.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(rk.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(rk.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:n}=this.config,i=t[e];if(i)return i.licenseUrl;if(e===Lk.WIDEVINE&&n)return n;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,n=t[e];if(n)return n.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,n=(e,t,n)=>!!e&&n.indexOf(e)===t,i=t.map((e=>e.audioCodec)).filter(n),a=t.map((e=>e.videoCodec)).filter(n);return i.length+a.length===0&&a.push("avc1.42e01e"),new Promise(((t,n)=>{const r=e=>{const o=e.shift();this.getMediaKeysPromise(o,i,a).then((e=>t({keySystem:o,mediaKeys:e}))).catch((t=>{e.length?r(e):n(t instanceof PA?t:new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))}))};r(e)}))}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:n}=this.config;if("function"!=typeof n){let e=`Configured requestMediaKeySystemAccess is not a function ${n}`;return null===Uk&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return n(e,t)}getMediaKeysPromise(e,t,n){const i=function(e,t,n,i){let a;switch(e){case Lk.FAIRPLAY:a=["cenc","sinf"];break;case Lk.WIDEVINE:case Lk.PLAYREADY:a=["cenc"];break;case Lk.CLEARKEY:a=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,n,i){return[{initDataTypes:e,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map((e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}))),videoCapabilities:n.map((e=>({contentType:`video/mp4; codecs="${e}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null})))}]}(a,t,n,i)}(e,t,n,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e];let r=null==a?void 0:a.keySystemAccess;if(!r){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(i)}`),r=this.requestMediaKeySystemAccess(e,i);const t=this.keySystemAccessPromises[e]={keySystemAccess:r};return r.catch((t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)})),r.then((n=>{this.log(`Access for key-system "${n.keySystem}" obtained`);const i=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=n.createMediaKeys().then((t=>(this.log(`Media-keys created for "${e}"`),i.then((n=>n?this.setMediaKeysServerCertificate(t,e,n):t))))),t.mediaKeys.catch((t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)})),t.mediaKeys}))}return r.then((()=>a.mediaKeys))}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:n}){this.log(`Creating key-system session "${t}" keyId: ${lS.hexDump(e.keyId||[])}`);const i=n.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:n,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const n=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t),a="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(n,a,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return lS.hexDump(e.keyId)}updateKeySession(e,t){var n;const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${lS.hexDump((null==(n=e.decryptdata)?void 0:n.keyId)||[])}\n } (data length: ${t?t.byteLength:t})`),i.update(t)}selectKeySystemFormat(e){const 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}getKeyFormatPromise(e){return new Promise(((t,n)=>{const i=Hk(this.config),a=e.map(Wk).filter((e=>!!e&&-1!==i.indexOf(e)));return this.getKeySystemSelectionPromise(a).then((({keySystem:e})=>{const i=$k(e);i?t(i):n(new Error(`Unable to find format for key-system "${e}"`))})).catch(n)}))}loadKey(e){const t=e.keyInfo.decryptdata,n=this.getKeyIdString(t),i=`(keyId: ${n} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${i}`);let a=this.keyIdToKeySessionPromise[n];return a||(a=this.keyIdToKeySessionPromise[n]=this.getKeySystemForKeyPromise(t).then((({keySystem:n,mediaKeys:a})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(n,a).then((()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:n,mediaKeys:a,decryptdata:t});return this.generateRequestWithPreferredKeySession(e,"cenc",t.pssh,"playlist-key")}))))),a.catch((e=>this.handleError(e)))),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof PA?this.hls.trigger(rk.ERROR,e.data):this.hls.trigger(rk.ERROR,{type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),n=this.keyIdToKeySessionPromise[t];if(!n){const t=Wk(e.keyFormat),n=t?[t]:Hk(this.config);return this.attemptKeySystemAccess(n)}return n}getKeySystemSelectionPromise(e){if(e.length||(e=Hk(this.config)),0===e.length)throw new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:n}=e,i=`"${e.type}" event: init data type: "${t}"`;if(this.debug(i),null===n)return;let a,r;if("sinf"===t&&this.config.drmSystems[Lk.FAIRPLAY]){const e=mS(new Uint8Array(n));try{const t=Pk(JSON.parse(e).sinf),n=PS(new Uint8Array(t));if(!n)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=n.subarray(8,24),r=Lk.FAIRPLAY}catch(e){return void this.warn(`${i} Failed to parse sinf: ${e}`)}}else{const e=function(e){const t=[];if(e instanceof ArrayBuffer){const n=e.byteLength;let i=0;for(;i+32<n;){const n=RS(new DataView(e,i));t.push(n),i+=n.size}}return t}(n),t=e.filter((e=>e.systemId===jk))[0];if(!t)return void(0===e.length||e.some((e=>!e.systemId))?this.warn(`${i} contains incomplete or invalid pssh data`):this.log(`ignoring ${i} for ${e.map((e=>zk(e.systemId))).join(",")} pssh data in favor of playlist keys`));if(r=zk(t.systemId),0===t.version&&t.data){const e=t.data.length-22;a=t.data.subarray(e,e+16)}}if(!r||!a)return;const o=lS.hexDump(a),{keyIdToKeySessionPromise:s,mediaKeySessions:d}=this;let l=s[o];for(let e=0;e<d.length;e++){const i=d[e],r=i.decryptdata;if(!r.keyId)continue;const u=lS.hexDump(r.keyId);if(o===u||-1!==r.uri.replace(/-/g,"").indexOf(o)){if(l=s[u],r.pssh)break;delete s[u],r.pssh=new Uint8Array(n),r.keyId=a,l=s[o]=l.then((()=>this.generateRequestWithPreferredKeySession(i,t,n,"encrypted-event-key-match")));break}}l||(l=s[o]=this.getKeySystemSelectionPromise([r]).then((({keySystem:e,mediaKeys:i})=>{var r;this.throwIfDestroyed();const s=new NS("ISO-23001-7",o,null!=(r=$k(e))?r:"");return s.pssh=new Uint8Array(n),s.keyId=a,this.attemptSetMediaKeys(e,i).then((()=>{this.throwIfDestroyed();const a=this.createMediaKeySessionContext({decryptdata:s,keySystem:e,mediaKeys:i});return this.generateRequestWithPreferredKeySession(a,t,n,"encrypted-event-no-match")}))}))),l.catch((e=>this.handleError(e)))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const n=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(n).then((()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)}));return this.setMediaKeysQueue.push(i),i.then((()=>{this.log(`Media-keys set for "${e}"`),n.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter((e=>-1===n.indexOf(e)))}))}generateRequestWithPreferredKeySession(e,t,n,i){var a,r;const o=null==(a=this.config.drmSystems)||null==(r=a[e.keySystem])?void 0:r.generateRequest;if(o)try{const i=o.call(this.hls,t,n,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,n=e.decryptdata.pssh=i.initData?new Uint8Array(i.initData):null}catch(e){var s;if(this.warn(e.message),null!=(s=this.hls)&&s.config.debug)throw e}if(null===n)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${i}": ${d} (init data type: ${t} length: ${n?n.byteLength:null})`);const l=new wP,u=e._onmessage=t=>{const n=e.mediaKeysSession;if(!n)return void l.emit("error",new Error("invalid state"));const{messageType:i,message:a}=t;this.log(`"${i}" message event for session "${n.sessionId}" message size: ${a.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,a).catch((e=>{this.handleError(e),l.emit("error",e)})):"license-release"===i?e.keySystem===Lk.FAIRPLAY&&(this.updateKeySession(e,xk("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${i}"`)},c=e._onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void l.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const n=e.keyStatus;l.emit("keyStatus",n),"expired"===n&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",u),e.mediaKeysSession.addEventListener("keystatuseschange",c);const h=new Promise(((e,t)=>{l.on("error",t),l.on("keyStatus",(n=>{n.startsWith("usable")?e():"output-restricted"===n?t(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===n?t(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${n}"`)):"expired"===n?t(new Error("key expired while generating request")):this.warn(`unhandled key status change "${n}"`)}))}));return e.mediaKeysSession.generateRequest(t,n).then((()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${d}`)})).catch((e=>{throw new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},`Error generating key-session request: ${e}`)})).then((()=>h)).catch((t=>{throw l.removeAllListeners(),this.removeSession(e),t})).then((()=>(l.removeAllListeners(),e)))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach(((t,n)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${lS.hexDump("buffer"in n?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):new Uint8Array(n))} session keyId: ${lS.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t}))}fetchServerCertificate(e){const t=this.config,n=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching server certificate for "${e}"`),new Promise(((a,r)=>{const o={responseType:"arraybuffer",url:i},s=t.certLoadPolicy.default,d={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,n,i)=>{a(e.data)},onError:(t,n,a,s)=>{r(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:Qw({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,n,a)=>{r(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,n)=>{r(new Error("aborted"))}};n.load(o,d,l)}))):Promise.resolve()}setMediaKeysServerCertificate(e,t,n){return new Promise(((i,a)=>{e.setServerCertificate(n).then((a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${null==n?void 0:n.byteLength}) on "${t}"`),i(e)})).catch((e=>{a(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))}))}))}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then((t=>this.updateKeySession(e,new Uint8Array(t)).catch((e=>{throw new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))))}unpackPlayReadyKeyMessage(e,t){const n=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!n.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const i=(new DOMParser).parseFromString(n,"application/xml"),a=i.querySelectorAll("HttpHeader");if(a.length>0){let t;for(let n=0,i=a.length;n<i;n++){var r,o;t=a[n];const i=null==(r=t.querySelector("name"))?void 0:r.textContent,s=null==(o=t.querySelector("value"))?void 0:o.textContent;i&&s&&e.setRequestHeader(i,s)}}const s=i.querySelector("Challenge"),d=null==s?void 0:s.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return xk(atob(d))}setupLicenseXHR(e,t,n,i){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then((()=>{if(!n.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,n,i)})).catch((r=>{if(!n.decryptdata)throw r;return e.open("POST",t,!0),a.call(this.hls,e,t,n,i)})).then((n=>{e.readyState||e.open("POST",t,!0);return{xhr:e,licenseChallenge:n||i}})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const n=this.config.keyLoadPolicy.default;return new Promise(((i,a)=>{const r=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${r}`);const 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;let t=o.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const n=this.config.licenseResponseCallback;if(n)try{t=n.call(this.hls,o,r,e)}catch(e){this.error(e)}i(t)}else{const s=n.errorRetry,d=s?s.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new PA({type:ok.KEY_SYSTEM_ERROR,details:sk.KEY_SYSTEM_LICENSE_REQUEST_FAILED,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{const n=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${n} attempts left`),this.requestLicense(e,t).then(i,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,r,e,t).then((({xhr:t,licenseChallenge:n})=>{e.keySystem==Lk.PLAYREADY&&(n=this.unpackPlayReadyKeyMessage(t,n)),t.send(n)}))}))}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const n=t.media;this.media=n,n.addEventListener("encrypted",this.onMediaEncrypted),n.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},NS.clearKeyUriToKeyIdMap();const n=t.length;EA.CDMCleanupPromise=Promise.all(t.map((e=>this.removeSession(e))).concat(null==e?void 0:e.setMediaKeys(null).catch((e=>{this.log(`Could not clear media keys: ${e}`)})))).then((()=>{n&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)})).catch((e=>{this.log(`Could not close sessions and clear media keys: ${e}`)}))}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce(((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e)),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:n}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),n&&n.readyState!==XMLHttpRequest.DONE&&n.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const i=this.mediaKeySessions.indexOf(e);return i>-1&&this.mediaKeySessions.splice(i,1),t.remove().catch((e=>{this.log(`Could not remove session: ${e}`)})).then((()=>t.close())).catch((e=>{this.log(`Could not close session: ${e}`)}))}}}EA.CDMCleanupPromise=void 0;class PA extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var AA,xA,CA;!function(e){e.MANIFEST="m",e.AUDIO="a",e.VIDEO="v",e.MUXED="av",e.INIT="i",e.CAPTION="c",e.TIMED_TEXT="tt",e.KEY="k",e.OTHER="o"}(AA||(AA={})),function(e){e.DASH="d",e.HLS="h",e.SMOOTH="s",e.OTHER="o"}(xA||(xA={})),function(e){e.OBJECT="CMCD-Object",e.REQUEST="CMCD-Request",e.SESSION="CMCD-Session",e.STATUS="CMCD-Status"}(CA||(CA={}));const LA={[CA.OBJECT]:["br","d","ot","tb"],[CA.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[CA.SESSION]:["cid","pr","sf","sid","st","v"],[CA.STATUS]:["bs","rtp"]};class DA{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map((e=>e instanceof DA?e:new DA(e)))),this.value=e,this.params=t}}class IA{constructor(e){this.description=void 0,this.description=e}}const _A="Dict";function RA(e,t,n,i){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 ${n}`,{cause:i});var a}const WA="Bare Item",NA="Boolean",OA="Byte Sequence",FA="Decimal",jA="Integer";const zA=/[\x00-\x1f\x7f]+/,$A="Token",HA="Key";function UA(e,t,n){return RA("serialize",e,t,n)}function BA(e){if(!1===ArrayBuffer.isView(e))throw UA(e,OA);return`:${t=e,btoa(String.fromCharCode(...t))}:`;var t}function GA(e){if(function(e){return e<-999999999999999||999999999999999<e}(e))throw UA(e,jA);return e.toString()}function XA(e,t){if(e<0)return-XA(-e,t);const n=Math.pow(10,t);if(Math.abs(e*n%1-.5)<Number.EPSILON){const t=Math.floor(e*n);return(t%2==0?t:t+1)/n}return Math.round(e*n)/n}function YA(e){const t=XA(e,3);if(Math.floor(Math.abs(t)).toString().length>12)throw UA(e,FA);const n=t.toString();return n.includes(".")?n:`${n}.0`}const VA="String";function KA(e){const t=(n=e).description||n.toString().slice(7,-1);var n;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(t))throw UA(t,$A);return t}function qA(e){switch(typeof e){case"number":if(!nk(e))throw UA(e,WA);return Number.isInteger(e)?GA(e):YA(e);case"string":return function(e){if(zA.test(e))throw UA(e,VA);return`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(e);case"symbol":return KA(e);case"boolean":return function(e){if("boolean"!=typeof e)throw UA(e,NA);return e?"?1":"?0"}(e);case"object":if(e instanceof Date)return function(e){return`@${GA(e.getTime()/1e3)}`}(e);if(e instanceof Uint8Array)return BA(e);if(e instanceof IA)return KA(e);default:throw UA(e,WA)}}function JA(e){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(e))throw UA(e,HA);return e}function QA(e){return null==e?"":Object.entries(e).map((([e,t])=>!0===t?`;${JA(e)}`:`;${JA(e)}=${qA(t)}`)).join("")}function ZA(e){return e instanceof DA?`${qA(e.value)}${QA(e.params)}`:qA(e)}function ex(e,t={whitespace:!0}){if("object"!=typeof e)throw UA(e,_A);const n=e instanceof Map?e.entries():Object.entries(e),i=null!=t&&t.whitespace?" ":"";return Array.from(n).map((([e,t])=>{t instanceof DA==!1&&(t=new DA(t));let n=JA(e);var i;return!0===t.value?n+=QA(t.params):(n+="=",Array.isArray(t.value)?n+=`(${(i=t).value.map(ZA).join(" ")})${QA(i.params)}`:n+=ZA(t)),n})).join(`,${i}`)}const tx=e=>"ot"===e||"sf"===e||"st"===e,nx=e=>"number"==typeof e?nk(e):null!=e&&""!==e&&!1!==e;const ix=e=>Math.round(e),ax=e=>100*ix(e/100),rx={br:ix,d:ix,bl:ax,dl:ax,mtp:ax,nor:(e,t)=>(null!=t&&t.baseUrl&&(e=function(e,t){const n=new URL(e),i=new URL(t);if(n.origin!==i.origin)return e;const a=n.pathname.split("/").slice(1),r=i.pathname.split("/").slice(1,-1);for(;a[0]===r[0];)a.shift(),r.shift();for(;r.length;)r.shift(),a.unshift("..");return a.join("/")}(e,t.baseUrl)),encodeURIComponent(e)),rtp:ax,tb:ix};function ox(e,t={}){return e?function(e,t){return ex(e,t)}(function(e,t){const n={};if(null==e||"object"!=typeof e)return n;const i=Object.keys(e).sort(),a=tk({},rx,null==t?void 0:t.formatters),r=null==t?void 0:t.filter;return i.forEach((i=>{if(null!=r&&r(i))return;let o=e[i];const s=a[i];s&&(o=s(o,t)),"v"===i&&1===o||"pr"==i&&1===o||nx(o)&&(tx(i)&&"string"==typeof o&&(o=new IA(o)),n[i]=o)})),n}(e,t),tk({whitespace:!1},t)):""}function sx(e,t,n){return tk(e,function(e,t={}){if(!e)return{};const n=Object.entries(e),i=Object.entries(LA).concat(Object.entries((null==t?void 0:t.customHeaderMap)||{})),a=n.reduce(((e,t)=>{var n;const[a,r]=t,o=(null==(n=i.find((e=>e[1].includes(a))))?void 0:n[0])||CA.REQUEST;return null!=e[o]||(e[o]={}),e[o][a]=r,e}),{});return Object.entries(a).reduce(((e,[n,i])=>(e[n]=ox(i,t),e)),{})}(t,n))}const dx="CMCD";const lx=/CMCD=[^&#]+/;function ux(e,t,n){const i=function(e,t={}){if(!e)return"";const n=ox(e,t);return`${dx}=${encodeURIComponent(n)}`}(t,n);if(!i)return e;if(lx.test(e))return e.replace(lx,i);const a=e.includes("?")?"&":"?";return`${e}${a}${i}`}function cx(e,t,n,i){e&&Object.keys(t).forEach((a=>{const r=e.filter((e=>e.groupId===a)).map((e=>{const r=tk({},e);return r.details=void 0,r.attrs=new gk(r.attrs),r.url=r.attrs.URI=hx(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",n),r.groupId=r.attrs["GROUP-ID"]=t[a],r.attrs["PATHWAY-ID"]=i,r}));e.push(...r)}))}function hx(e,t,n,i){const{HOST:a,PARAMS:r,[n]:o}=i;let s;t&&(s=null==o?void 0:o[t],s&&(e=s));const d=new self.URL(e);return a&&!s&&(d.host=a),r&&Object.keys(r).sort().forEach((e=>{e&&d.searchParams.set(e,r[e])})),d.href}const mx=/^age:\s*[\d.]+\s*$/im;class fx{constructor(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=e&&e.xhrSetup||null,this.stats=new yk,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const 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()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,n){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=n,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const n=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const a=this.xhrSetup;a?Promise.resolve().then((()=>{if(this.loader===n&&!this.stats.aborted)return a(n,t.url)})).catch((e=>{if(this.loader===n&&!this.stats.aborted)return n.open("GET",t.url,!0),a(n,t.url)})).then((()=>{this.loader!==n||this.stats.aborted||this.openAndSendXhr(n,t,e)})).catch((e=>{this.callbacks.onError({code:n.status,text:e.message},t,n,i)})):this.openAndSendXhr(n,t,e)}openAndSendXhr(e,t,n){e.readyState||e.open("GET",t.url,!0);const i=t.headers,{maxTimeToFirstByteMs:a,maxLoadTimeMs:r}=n.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);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),n.timeout=a&&nk(a)?a:r,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:n}=this;if(!e||!t)return;const i=t.readyState,a=this.config;if(!n.aborted&&i>=2&&(0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.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-(n.loading.first-n.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,r="text"!==t.responseType;if(i>=200&&i<300&&(r&&t.response||null!==t.responseText)){n.loading.end=Math.max(self.performance.now(),n.loading.first);const a=r?t.response:t.responseText,o="arraybuffer"===t.responseType?a.byteLength:a.length;if(n.loaded=n.total=o,n.bwEstimate=8e3*n.total/(n.loading.end-n.loading.first),!this.callbacks)return;const s=this.callbacks.onProgress;if(s&&s(n,e,a,t),!this.callbacks)return;const d={url:t.responseURL,data:a,code:i};this.callbacks.onSuccess(d,n,e,t)}else{const r=a.loadPolicy.errorRetry;aT(r,n.retry,!1,{url:e.url,data:void 0,code:i})?this.retry(r):(hk.error(`${i} while loading ${e.url}`),this.callbacks.onError({code:i,text:t.statusText},e,t,n))}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry;if(aT(e,this.stats.retry,!0))this.retry(e);else{var t;hk.warn(`timeout while loading ${null==(t=this.context)?void 0:t.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:n}=this;this.retryDelay=nT(e,n.retry),n.retry++,hk.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==t?void 0:t.url}, retrying ${n.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)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&mx.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const gx=/(\d+)-(\d+)\/(\d+)/;class px{constructor(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=e.fetchSetup||vx,this.controller=new self.AbortController,this.stats=new yk}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,n){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const a=function(e,t){const n={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(tk({},e.headers))};e.rangeEnd&&n.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return n}(e,this.controller.signal),r=n.onProgress,o="arraybuffer"===e.responseType,s=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:l}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=n,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=d&&nk(d)?d:l,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(i,e,this.response)}),t.timeout),self.fetch(this.request).then((a=>{this.response=this.loader=a;const s=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=l,this.requestTimeout=self.setTimeout((()=>{this.abortInternal(),n.onTimeout(i,e,this.response)}),l-(s-i.loading.start)),!a.ok){const{status:e,statusText:t}=a;throw new yx(t||"fetch, bad network response",e,a)}return i.loading.first=s,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=gx.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(nk(e))return e}const n=e.get("Content-Length");if(n)return parseInt(n)}(a.headers)||i.total,r&&nk(t.highWaterMark)?this.loadProgressively(a,i,e,t.highWaterMark,r):o?a.arrayBuffer():"json"===e.responseType?a.json():a.text()})).then((a=>{const o=this.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const d=a[s];d&&(i.loaded=i.total=d);const l={url:o.url,data:a,code:o.status};r&&!nk(t.highWaterMark)&&r(i,e,a,o),n.onSuccess(l,i,e,o)})).catch((t=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const a=t&&t.code||0,r=t?t.message:null;n.onError({code:a,text:r},e,t?t.details:null,i)}))}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,n,i=0,a){const r=new fE,o=e.body.getReader(),s=()=>o.read().then((o=>{if(o.done)return r.dataLength&&a(t,n,r.flush(),e),Promise.resolve(new ArrayBuffer(0));const d=o.value,l=d.length;return t.loaded+=l,l<i||r.dataLength?(r.push(d),r.dataLength>=i&&a(t,n,r.flush(),e)):a(t,n,d,e),s()})).catch((()=>Promise.reject()));return s()}}function vx(e,t){return new self.Request(e.url,t)}class yx extends Error{constructor(e,t,n){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=n}}const bx=/\s/,wx={newCue(e,t,n,i){const a=[];let r,o,s,d,l;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<i.rows.length;h++)if(r=i.rows[h],s=!0,d=0,l="",!r.isEmpty()){var c;for(let e=0;e<r.chars.length;e++)bx.test(r.chars[e].uchar)&&s?d++:(l+=r.chars[e].uchar,s=!1);r.cueStartTime=t,t===n&&(n+=1e-4),d>=16?d--:d++;const i=iA(l.trim()),m=dA(t,n,i);null!=e&&null!=(c=e.cues)&&c.getCueById(m)||(o=new u(t,n,i),o.id=m,o.line=h+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*d/32)),a.push(o))}return e&&a.length&&(a.sort(((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line)),a.forEach((t=>TM(e,t)))),a}},kx=Qw(Qw({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:fx,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:e,partCurrent:t,hls:n}=this,{autoLevelEnabled:i,media:a}=n;if(!e||!a)return;const r=performance.now(),o=t?t.stats:e.stats,s=t?t.duration:e.duration,d=r-o.loading.start,l=n.minAutoLevel;if(o.aborted||o.loaded&&o.loaded===o.total||e.level<=l)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!i||a.paused||!a.playbackRate||!a.readyState)return;const u=n.mainForwardBufferInfo;if(null===u)return;const c=this.bwEstimator.getEstimateTTFB(),h=Math.abs(a.playbackRate);if(d<=Math.max(c,s/(2*h)*1e3))return;const m=u.len/h,f=o.loading.first?o.loading.first-o.loading.start:-1,g=o.loaded&&f>-1,p=this.getBwEstimate(),v=n.levels,y=v[e.level],b=o.total||Math.max(o.loaded,Math.round(s*y.averageBitrate/8));let w=g?d-f:d;w<1&&g&&(w=Math.min(d,8*o.loaded/p));const k=g?1e3*o.loaded/w:0,S=k?(b-o.loaded)/k:8*b/p+c/1e3;if(S<=m)return;const M=k?8*k:p;let T,E=Number.POSITIVE_INFINITY;for(T=e.level-1;T>l;T--){const e=v[T].maxBitrate;if(E=this.getTimeToLoadFrag(c/1e3,M,s*e,!v[T].details),E<m)break}if(E>=S)return;if(E>10*s)return;n.nextLoadLevel=n.nextAutoLevel=T,g?this.bwEstimator.sample(d-Math.min(c,f),o.loaded):this.bwEstimator.sampleTTFB(d);const P=v[T].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>P&&this.resetEstimator(P),this.clearTimer(),hk.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${m.toFixed(3)} s\n Estimated load time for current fragment: ${S.toFixed(3)} s\n Estimated load time for down switch fragment: ${E.toFixed(3)} s\n TTFB estimate: ${0|f} ms\n Current BW estimate: ${nk(p)?0|p:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${T} @ ${0|P} bps`),n.trigger(rk.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(hk.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new yT(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.FRAG_LOADING,this.onFragLoading,this),e.on(rk.FRAG_LOADED,this.onFragLoaded,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rk.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(rk.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.FRAG_LOADING,this.onFragLoading,this),e.off(rk.FRAG_LOADED,this.onFragLoaded,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rk.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(rk.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(e,t){const n=t.frag;if(!this.ignoreFragment(n)){var i;if(!n.bitrateTest)this.fragCurrent=n,this.partCurrent=null!=(i=t.part)?i:null;this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case sk.BUFFER_ADD_CODEC_ERROR:case sk.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case sk.FRAG_LOAD_TIMEOUT:{const e=t.frag,{fragCurrent:n,partCurrent:i}=this;if(e&&n&&e.sn===n.sn&&e.level===n.level){const t=performance.now(),n=i?i.stats:e.stats,a=t-n.loading.start,r=n.loading.first?n.loading.first-n.loading.start:-1;if(n.loaded&&r>-1){const e=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(a-Math.min(e,r),n.loaded)}else this.bwEstimator.sampleTTFB(a)}break}}}getTimeToLoadFrag(e,t,n,i){return e+n/t+(i?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const n=this.hls.config,{loading:i}=t.stats,a=i.end-i.start;nk(a)&&(this.lastLevelLoadSec=a/1e3),t.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:n}){const i=n?n.stats:t.stats;if(t.type===vM&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const e=n?n.duration:t.duration,a=this.hls.levels[t.level],r=(a.loaded?a.loaded.bytes:0)+i.loaded,o=(a.loaded?a.loaded.duration:0)+e;a.loaded={bytes:r,duration:o},a.realBitrate=Math.round(8*r/o)}if(t.bitrateTest){const e={stats:i,frag:t,part:n,id:t.type};this.onFragBuffered(rk.FRAG_BUFFERED,e),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:n,part:i}=t,a=null!=i&&i.stats.loaded?i.stats:n.stats;if(a.aborted)return;if(this.ignoreFragment(n))return;const 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(),n.bitrateTest?this.bitrateTestDelay=r/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==vM||"initSegment"===e.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,n=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,a=this.findBestLevel(n,t,e,0,i,1,1);if(a>-1)return a;const r=this.hls.firstLevel,o=Math.min(Math.max(r,t),e);return hk.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${r} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,t=this.bwEstimator.canEstimate(),n=this.lastLoadedFragLevel>-1;if(!(-1===e||t&&n&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return e;const i=t&&n?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:n}=this,{maxAutoLevel:i,config:a,minAutoLevel:r}=n,o=t?t.duration:e?e.duration:0,s=this.getBwEstimate(),d=this.getStarvationDelay();let l=a.abrBandWidthFactor,u=a.abrBandWidthUpFactor;if(d){const e=this.findBestLevel(s,r,i,d,0,l,u);if(e>=0)return e}let c=o?Math.min(o,a.maxStarvationDelay):a.maxStarvationDelay;if(!d){const e=this.bitrateTestDelay;if(e){c=(o?Math.min(o,a.maxLoadingDelay):a.maxLoadingDelay)-e,hk.info(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*c)} ms`),l=u=1}}const h=this.findBestLevel(s,r,i,d,c,l,u);if(hk.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${h}`),h>-1)return h;const m=n.levels[r],f=n.levels[n.loadLevel];return(null==m?void 0:m.bitrate)<(null==f?void 0:f.bitrate)?r:n.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const n=t&&0!==t.playbackRate?Math.abs(t.playbackRate):1,i=e.mainForwardBufferInfo;return(i?i.len:0)/n}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,n,i,a,r,o){var s;const d=i+a,l=this.lastLoadedFragLevel,u=-1===l?this.hls.firstLevel:l,{fragCurrent:c,partCurrent:h}=this,{levels:m,allAudioTracks:f,loadLevel:g,config:p}=this.hls;if(1===m.length)return 0;const v=m[u],y=!(null==v||null==(s=v.details)||!s.live),b=-1===g||-1===l;let w,k="SDR",S=(null==v?void 0:v.frameRate)||0;const{audioPreference:M,videoPreference:T}=p,E=this.audioTracksByGroup||(this.audioTracksByGroup=function(e){return e.reduce(((e,t)=>{let n=e.groups[t.groupId];n||(n=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),n.tracks.push(t);const i=t.channels||"2";return n.channels[i]=(n.channels[i]||0)+1,n.hasDefault=n.hasDefault||t.default,n.hasAutoSelect=n.hasAutoSelect||t.autoselect,n.hasDefault&&(e.hasDefaultAudio=!0),n.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(f));if(b){if(-1!==this.firstSelection)return this.firstSelection;const i=this.codecTiers||(this.codecTiers=function(e,t,n,i){return e.slice(n,i+1).reduce(((e,n)=>{if(!n.codecSet)return e;const i=n.audioGroups;let a=e[n.codecSet];a||(e[n.codecSet]=a={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!i,fragmentError:0}),a.minBitrate=Math.min(a.minBitrate,n.bitrate);const r=Math.min(n.height,n.width);return a.minHeight=Math.min(a.minHeight,r),a.minFramerate=Math.min(a.minFramerate,n.frameRate),a.maxScore=Math.max(a.maxScore,n.score),a.fragmentError+=n.fragmentError,a.videoRanges[n.videoRange]=(a.videoRanges[n.videoRange]||0)+1,i&&i.forEach((e=>{if(!e)return;const n=t.groups[e];n&&(a.hasDefaultAudio=a.hasDefaultAudio||t.hasDefaultAudio?n.hasDefault:n.hasAutoSelect||!t.hasDefaultAudio&&!t.hasAutoSelectAudio,Object.keys(n.channels).forEach((e=>{a.channels[e]=(a.channels[e]||0)+n.channels[e]})))})),e}),{})}(m,E,t,n)),a=function(e,t,n,i,a){const r=Object.keys(e),o=null==i?void 0:i.channels,s=null==i?void 0:i.audioCodec,d=o&&2===parseInt(o);let l=!0,u=!1,c=1/0,h=1/0,m=1/0,f=0,g=[];const{preferHDR:p,allowedVideoRanges:v}=MT(t,a);for(let t=r.length;t--;){const n=e[r[t]];l=n.channels[2]>0,c=Math.min(c,n.minHeight),h=Math.min(h,n.minFramerate),m=Math.min(m,n.minBitrate);const i=v.filter((e=>n.videoRanges[e]>0));i.length>0&&(u=!0,g=i)}c=nk(c)?c:0,h=nk(h)?h:0;const y=Math.max(1080,c),b=Math.max(30,h);return m=nk(m)?m:n,n=Math.max(m,n),u||(t=void 0,g=[]),{codecSet:r.reduce(((t,i)=>{const a=e[i];if(i===t)return t;if(a.minBitrate>n)return TT(i,`min bitrate of ${a.minBitrate} > current estimate of ${n}`),t;if(!a.hasDefaultAudio)return TT(i,"no renditions with default or auto-select sound found"),t;if(s&&i.indexOf(s.substring(0,4))%5!=0)return TT(i,`audio codec preference "${s}" not found`),t;if(o&&!d){if(!a.channels[o])return TT(i,`no renditions with ${o} channel sound found (channels options: ${Object.keys(a.channels)})`),t}else if((!s||d)&&l&&0===a.channels[2])return TT(i,"no renditions with stereo sound found"),t;return a.minHeight>y?(TT(i,`min resolution of ${a.minHeight} > maximum of ${y}`),t):a.minFramerate>b?(TT(i,`min framerate of ${a.minFramerate} > maximum of ${b}`),t):g.some((e=>a.videoRanges[e]>0))?a.maxScore<f?(TT(i,`max score of ${a.maxScore} < selected max of ${f}`),t):t&&(KS(i)>=KS(t)||a.fragmentError>e[t].fragmentError)?t:(f=a.maxScore,i):(TT(i,`no variants with VIDEO-RANGE of ${JSON.stringify(g)} found`),t)}),void 0),videoRanges:g,preferHDR:p,minFramerate:h,minBitrate:m}}(i,k,e,M,T),{codecSet:r,videoRanges:o,minFramerate:s,minBitrate:d,preferHDR:l}=a;w=r,k=l?o[o.length-1]:o[0],S=s,e=Math.max(e,d),hk.log(`[abr] picked start tier ${JSON.stringify(a)}`)}else w=null==v?void 0:v.codecSet,k=null==v?void 0:v.videoRange;const P=h?h.duration:c?c.duration:0,A=this.bwEstimator.getEstimateTTFB()/1e3,x=[];for(let s=n;s>=t;s--){var C;const t=m[s],c=s>u;if(!t)continue;if(p.useMediaCapabilities&&!t.supportedResult&&!t.supportedPromise){const n=navigator.mediaCapabilities;"function"==typeof(null==n?void 0:n.decodingInfo)&&kT(t,E,k,S,e,M)?(t.supportedPromise=ST(t,E,n),t.supportedPromise.then((e=>{if(!this.hls)return;t.supportedResult=e;const n=this.hls.levels,i=n.indexOf(t);e.error?hk.warn(`[abr] MediaCapabilities decodingInfo error: "${e.error}" for level ${i} ${JSON.stringify(e)}`):e.supported||(hk.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${i} ${JSON.stringify(e)}`),i>-1&&n.length>1&&(hk.log(`[abr] Removing unsupported level ${i}`),this.hls.removeLevel(i)))}))):t.supportedResult=bT}if(w&&t.codecSet!==w||k&&t.videoRange!==k||c&&S>t.frameRate||!c&&S>0&&S<t.frameRate||t.supportedResult&&(null==(C=t.supportedResult.decodingInfoResults)||!C[0].smooth)){x.push(s);continue}const f=t.details,T=(h?null==f?void 0:f.partTarget:null==f?void 0:f.averagetargetduration)||P;let L;L=c?o*e:r*e;const D=P&&i>=2*P&&0===a?m[s].averageBitrate:m[s].maxBitrate,I=this.getTimeToLoadFrag(A,L,D*T,void 0===f);if(L>=D&&(s===l||0===t.loadError&&0===t.fragmentError)&&(I<=A||!nk(I)||y&&!this.bitrateTestDelay||I<d)){const e=this.forcedAutoLevel;return s===g||-1!==e&&e===g||(x.length&&hk.trace(`[abr] Skipped level(s) ${x.join(",")} of ${n} max with CODECS and VIDEO-RANGE:"${m[x[0]].codecs}" ${m[x[0]].videoRange}; not compatible with "${v.codecs}" ${k}`),hk.info(`[abr] switch candidate:${u}->${s} adjustedbw(${Math.round(L)})-bitrate=${Math.round(L-D)} ttfb:${A.toFixed(1)} avgDuration:${T.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${I.toFixed(1)} firstSelection:${b} codecSet:${w} videoRange:${k} hls.loadLevel:${g}`)),b&&(this.firstSelection=s),s}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:n}=this.hls,i=Math.min(Math.max(e,n),t);this._nextAutoLevel!==i&&(this.nextAutoLevelKey="",this._nextAutoLevel=i)}},bufferController:class{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=e=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=e=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:e,mediaSource:t}=this;this.log("Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(rk.MEDIA_ATTACHED,{media:e,mediaSource:t})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:e,_objectUrl:t}=this;e!==t&&hk.error(`Media element src was set while attaching MediaSource (${t} > ${e})`)},this.hls=e;const t="[buffer-controller]";var n;this.appendSource=(n=US(e.config.preferManagedMediaSource),"undefined"!=typeof self&&n===self.ManagedMediaSource),this.log=hk.log.bind(hk,t),this.warn=hk.warn.bind(hk,t),this.error=hk.error.bind(hk,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.BUFFER_RESET,this.onBufferReset,this),e.on(rk.BUFFER_APPENDING,this.onBufferAppending,this),e.on(rk.BUFFER_CODECS,this.onBufferCodecs,this),e.on(rk.BUFFER_EOS,this.onBufferEos,this),e.on(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rk.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(rk.FRAG_PARSED,this.onFragParsed,this),e.on(rk.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.BUFFER_RESET,this.onBufferReset,this),e.off(rk.BUFFER_APPENDING,this.onBufferAppending,this),e.off(rk.BUFFER_CODECS,this.onBufferCodecs,this),e.off(rk.BUFFER_EOS,this.onBufferEos,this),e.off(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rk.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(rk.FRAG_PARSED,this.onFragParsed,this),e.off(rk.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new PP(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let n=2;(t.audio&&!t.video||!t.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const n=this.media=t.media,i=US(this.appendSource);if(n&&i){var a;const e=this.mediaSource=new i;this.log(`created media source: ${null==(a=e.constructor)?void 0:a.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));const t=this._objectUrl=self.URL.createObjectURL(e);if(this.appendSource)try{n.removeAttribute("src");const i=self.ManagedMediaSource;n.disableRemotePlayback=n.disableRemotePlayback||i&&e instanceof i,xP(n),function(e,t){const n=self.document.createElement("source");n.type="video/mp4",n.src=t,e.appendChild(n)}(n,t),n.load()}catch(e){n.src=t}else n.src=t;n.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:n}=this;if(t){if(this.log("media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){this.warn(`onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(e.removeAttribute("src"),this.appendSource&&xP(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(rk.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach((e=>{this.resetBuffer(e)})),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{var n;if(t)this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,null!=(n=this.mediaSource)&&n.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}catch(t){this.warn(`onBufferReset ${e}`,t)}}onBufferCodecs(e,t){const n=this.getSourceBufferTypes().length,i=Object.keys(t);if(i.forEach((e=>{if(n){const n=this.tracks[e];if(n&&"function"==typeof n.buffer.changeType){var i;const{id:a,codec:r,levelCodec:o,container:s,metadata:d}=t[e],l=ZS(n.codec,n.levelCodec),u=null==l?void 0:l.replace(AP,"$1");let c=ZS(r,o);const h=null==(i=c)?void 0:i.replace(AP,"$1");if(c&&u!==h){"audio"===e.slice(0,5)&&(c=QS(c,this.appendSource));const t=`${s};codecs=${c}`;this.appendChangeType(e,t),this.log(`switching codec ${l} to ${c}`),this.tracks[e]={buffer:n.buffer,codec:r,container:s,levelCodec:o,metadata:d,id:a}}}}else this.pendingTracks[e]=t[e]})),n)return;const a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(`${a} bufferCodec event(s) expected ${i.join(",")}`),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:n}=this,i={execute:()=>{const i=this.sourceBuffer[e];i&&(this.log(`changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),n.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn(`Failed to change ${e} SourceBuffer type`,t)}};n.append(i,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:n,operationQueue:i,tracks:a}=this,{data:r,type:o,frag:s,part:d,chunkMeta:l}=t,u=l.buffering[o],c=self.performance.now();u.start=c;const h=s.stats.buffering,m=d?d.stats.buffering:null;0===h.start&&(h.start=c),m&&0===m.start&&(m.start=c);const f=a.audio;let g=!1;"audio"===o&&"audio/mpeg"===(null==f?void 0:f.container)&&(g=!this.lastMpegAudioChunk||1===l.id||this.lastMpegAudioChunk.sn!==l.sn,this.lastMpegAudioChunk=l);const p=s.start,v={execute:()=>{if(u.executeStart=self.performance.now(),g){const e=this.sourceBuffer[o];if(e){const t=p-e.timestampOffset;Math.abs(t)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${p} (delta: ${t}) sn: ${s.sn})`),e.timestampOffset=p)}}this.appendExecutor(r,o)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();u.executeEnd=u.end=e,0===h.first&&(h.first=e),m&&0===m.first&&(m.first=e);const{sourceBuffer:t}=this,n={};for(const e in t)n[e]=FT.getBuffered(t[e]);this.appendErrors[o]=0,"audio"===o||"video"===o?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(rk.BUFFER_APPENDED,{type:o,frag:s,part:d,chunkMeta:l,parent:s.type,timeRanges:n})},onError:e=>{const t={type:ok.MEDIA_ERROR,parent:s.type,details:sk.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:s,part:d,chunkMeta:l,error:e,err:e,fatal:!1};if(e.code===DOMException.QUOTA_EXCEEDED_ERR)t.details=sk.BUFFER_FULL_ERROR;else{const e=++this.appendErrors[o];t.details=sk.BUFFER_APPEND_ERROR,this.warn(`Failed ${e}/${n.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),e>=n.config.appendErrorMaxRetry&&(t.fatal=!0)}n.trigger(rk.ERROR,t)}};i.append(v,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:n}=this,i=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(rk.BUFFER_FLUSHED,{type:e})},onError:t=>{this.warn(`Failed to remove from ${e} SourceBuffer`,t)}});t.type?n.append(i(t.type),t.type):this.getSourceBufferTypes().forEach((e=>{n.append(i(e),e)}))}onFragParsed(e,t){const{frag:n,part:i}=t,a=[],r=i?i.elementaryStreams:n.elementaryStreams;r[kk]?a.push("audiovideo"):(r[bk]&&a.push("audio"),r[wk]&&a.push("video"));0===a.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${n.type} level: ${n.level} sn: ${n.sn}`),this.blockBuffers((()=>{const e=self.performance.now();n.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:n.stats;this.hls.trigger(rk.FRAG_BUFFERED,{frag:n,part:i,stats:t,id:n.type})}),a)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce(((e,n)=>{const i=this.sourceBuffer[n];return!i||t.type&&t.type!==n||(i.ending=!0,i.ended||(i.ended=!0,this.log(`${n} sourceBuffer now EOS`))),e&&!(i&&!i.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((()=>{this.getSourceBufferTypes().forEach((e=>{const t=this.sourceBuffer[e];t&&(t.ending=!1)}));const{mediaSource:e}=this;e&&"open"===e.readyState?(this.log("Calling mediaSource.endOfStream()"),e.endOfStream()):e&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)})))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:n}=this;if(!n||null===t)return;if(!this.getSourceBufferTypes().length)return;const i=e.config,a=n.currentTime,r=t.levelTargetDuration,o=t.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(nk(o)&&o>0){const e=Math.max(o,r),t=Math.floor(a/r)*r-e;this.flushBackBuffer(a,r,t)}if(nk(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){const e=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),t=Math.max(e,r),n=Math.floor(a/r)*r+t;this.flushFrontBuffer(a,r,n)}}flushBackBuffer(e,t,n){const{details:i,sourceBuffer:a}=this;this.getSourceBufferTypes().forEach((r=>{const o=a[r];if(o){const a=FT.getBuffered(o);if(a.length>0&&n>a.start(0)){if(this.hls.trigger(rk.BACK_BUFFER_REACHED,{bufferEnd:n}),null!=i&&i.live)this.hls.trigger(rk.LIVE_BACK_BUFFER_REACHED,{bufferEnd:n});else if(o.ended&&a.end(a.length-1)-e<2*t)return void this.log(`Cannot flush ${r} back buffer while SourceBuffer is in ended state`);this.hls.trigger(rk.BUFFER_FLUSHING,{startOffset:0,endOffset:n,type:r})}}}))}flushFrontBuffer(e,t,n){const{sourceBuffer:i}=this;this.getSourceBufferTypes().forEach((a=>{const r=i[a];if(r){const i=FT.getBuffered(r),o=i.length;if(o<2)return;const s=i.start(o-1),d=i.end(o-1);if(n>s||e>=s&&e<=d)return;if(r.ended&&e-d<2*t)return void this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);this.hls.trigger(rk.BUFFER_FLUSHING,{startOffset:s,endOffset:1/0,type:a})}}))}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:n,mediaSource:i}=this,a=e.fragments[0].start+e.totalduration,r=n.duration,o=nk(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(e)):(a>o&&a>r||!nk(r))&&(this.log(`Updating Media Source duration to ${a.toFixed(3)}`),i.duration=a)}updateSeekableRange(e){const t=this.mediaSource,n=e.fragments;if(n.length&&e.live&&null!=t&&t.setLiveSeekableRange){const i=Math.max(0,n[0].start),a=Math.max(i,i+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${i}-${a}.`),t.setLiveSeekableRange(i,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:n}=this,i=Object.keys(n).length;if(i&&(!e||2===i||"audiovideo"in n)){this.createSourceBuffers(n),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(rk.BUFFER_CREATED,{tracks:this.tracks}),e.forEach((e=>{t.executeNext(e)}));else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:n}=this;if(!n)throw Error("createSourceBuffers called when mediaSource was null");for(const a in e)if(!t[a]){var i;const r=e[a];if(!r)throw Error(`source buffer exists for track ${a}, however track does not`);let o=-1===(null==(i=r.levelCodec)?void 0:i.indexOf(","))?r.levelCodec:r.codec;o&&"audio"===a.slice(0,5)&&(o=QS(o,this.appendSource));const s=`${r.container};codecs=${o}`;this.log(`creating sourceBuffer(${s})`);try{const e=t[a]=n.addSourceBuffer(s),i=a;this.addBufferListener(i,"updatestart",this._onSBUpdateStart),this.addBufferListener(i,"updateend",this._onSBUpdateEnd),this.addBufferListener(i,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(i,"bufferedchange",((e,t)=>{const n=t.removedRanges;null!=n&&n.length&&this.hls.trigger(rk.BUFFER_FLUSHED,{type:a})})),this.tracks[a]={buffer:e,codec:o,container:r.container,levelCodec:r.levelCodec,metadata:r.metadata,id:r.id}}catch(e){this.error(`error while trying to add sourceBuffer: ${e.message}`),this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,sourceBufferName:a,mimeType:s})}}}get mediaSrc(){var e,t;const n=(null==(e=this.media)||null==(t=e.querySelector)?void 0:t.call(e,"source"))||this.media;return null==n?void 0:n.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if("closed"===(null==(t=this.mediaSource)?void 0:t.readyState))return void this.resetBuffer(e);const{operationQueue:n}=this;n.current(e).onComplete(),n.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var n;const i=new Error(`${e} SourceBuffer error. MediaSource readyState: ${null==(n=this.mediaSource)?void 0:n.readyState}`);this.error(`${i}`,t),this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:i,fatal:!1});const a=this.operationQueue.current(e);a&&a.onError(i)}removeExecutor(e,t,n){const{media:i,mediaSource:a,operationQueue:r,sourceBuffer:o}=this,s=o[e];if(!i||!a||!s)return this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void r.shiftAndExecuteNext(e);const d=nk(i.duration)?i.duration:1/0,l=nk(a.duration)?a.duration:1/0,u=Math.max(0,t),c=Math.min(n,d,l);c>u&&(!s.ending||s.ended)?(s.ended=!1,this.log(`Removing [${u},${c}] from the ${e} SourceBuffer`),s.remove(u,c)):r.shiftAndExecuteNext(e)}appendExecutor(e,t){const n=this.sourceBuffer[t];if(n)n.ended=!1,n.appendBuffer(e);else if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);const{operationQueue:n}=this,i=t.map((e=>n.appendBlocker(e)));Promise.all(i).then((()=>{e(),t.forEach((e=>{const t=this.sourceBuffer[e];null!=t&&t.updating||n.shiftAndExecuteNext(e)}))}))}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,n){const i=this.sourceBuffer[e];if(!i)return;const a=n.bind(this,e);this.listeners[e].push({event:t,listener:a}),i.addEventListener(t,a)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach((e=>{t.removeEventListener(e.event,e.listener)}))}},capLevelController:MA,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=hk.log.bind(hk,"[info]:"),this.warn=hk.warn.bind(hk,"[warning]:"),this.error=hk.error.bind(hk,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(rk.ERROR,this.onError,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(rk.ERROR,this.onError,this),e.off(rk.ERROR,this.onErrorOut,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(null==e?void 0:e.type)===vM?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var n,i;if(t.fatal)return;const a=this.hls,r=t.context;switch(t.details){case sk.FRAG_LOAD_ERROR:case sk.FRAG_LOAD_TIMEOUT:case sk.KEY_LOAD_ERROR:case sk.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case sk.FRAG_PARSING_ERROR:if(null!=(n=t.frag)&&n.gap)return void(t.errorAction={action:lT,flags:mT});case sk.FRAG_GAP:case sk.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=uT);case sk.LEVEL_EMPTY_ERROR:case sk.LEVEL_PARSING_ERROR:{var o,s;const e=t.parent===vM?t.level:a.loadLevel;t.details===sk.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(s=o.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case sk.LEVEL_LOAD_ERROR:case sk.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==r?void 0:r.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level)));case sk.AUDIO_TRACK_LOAD_ERROR:case sk.AUDIO_TRACK_LOAD_TIMEOUT:case sk.SUBTITLE_LOAD_ERROR:case sk.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const e=a.levels[a.loadLevel];if(e&&(r.type===gM&&e.hasAudioGroup(r.groupId)||r.type===pM&&e.hasSubtitleGroup(r.groupId)))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=uT,void(t.errorAction.flags=fT)}return;case sk.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=a.levels[a.loadLevel],n=null==e?void 0:e.attrs["HDCP-LEVEL"];n?t.errorAction={action:uT,flags:gT,hdcpLevel:n}:this.keySystemError(t)}return;case sk.BUFFER_ADD_CODEC_ERROR:case sk.REMUX_ALLOC_ERROR:case sk.BUFFER_APPEND_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:a.loadLevel));case sk.INTERNAL_EXCEPTION:case sk.BUFFER_APPENDING_ERROR:case sk.BUFFER_FULL_ERROR:case sk.LEVEL_SWITCH_ERROR:case sk.BUFFER_STALLED_ERROR:case sk.BUFFER_SEEK_OVER_HOLE:case sk.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:lT,flags:mT})}t.type===ok.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const n=tT(this.hls.config.playlistLoadPolicy,e),i=this.playlistError++;if(aT(n,i,eT(e),e.response))return{action:hT,flags:mT,retryConfig:n,retryCount:i};const a=this.getLevelSwitchAction(e,t);return n&&(a.retryConfig=n,a.retryCount=i),a}getFragRetryOrSwitchAction(e){const t=this.hls,n=this.getVariantLevelIndex(e.frag),i=t.levels[n],{fragLoadPolicy:a,keyLoadPolicy:r}=t.config,o=tT(e.details.startsWith("key")?r:a,e),s=t.levels.reduce(((e,t)=>e+t.fragmentError),0);if(i){e.details!==sk.FRAG_GAP&&i.fragmentError++;if(aT(o,s,eT(e),e.response))return{action:hT,flags:mT,retryConfig:o,retryCount:s}}const d=this.getLevelSwitchAction(e,n);return o&&(d.retryConfig=o,d.retryCount=s),d}getLevelSwitchAction(e,t){const n=this.hls;null==t&&(t=n.loadLevel);const i=this.hls.levels[t];if(i){var a,r;const t=e.details;i.loadError++,t===sk.BUFFER_APPEND_ERROR&&i.fragmentError++;let d=-1;const{levels:l,loadLevel:u,minAutoLevel:c,maxAutoLevel:h}=n;n.autoLevelEnabled||(n.loadLevel=-1);const m=null==(a=e.frag)?void 0:a.type,f=(m===yM&&t===sk.FRAG_PARSING_ERROR||"audio"===e.sourceBufferName&&(t===sk.BUFFER_ADD_CODEC_ERROR||t===sk.BUFFER_APPEND_ERROR))&&l.some((({audioCodec:e})=>i.audioCodec!==e)),g="video"===e.sourceBufferName&&(t===sk.BUFFER_ADD_CODEC_ERROR||t===sk.BUFFER_APPEND_ERROR)&&l.some((({codecSet:e,audioCodec:t})=>i.codecSet!==e&&i.audioCodec===t)),{type:p,groupId:v}=null!=(r=e.context)?r:{};for(let n=l.length;n--;){const a=(n+u)%l.length;if(a!==u&&a>=c&&a<=h&&0===l[a].loadError){var o,s;const n=l[a];if(t===sk.FRAG_GAP&&m===vM&&e.frag){const t=l[a].details;if(t){const n=oT(e.frag,t.fragments,e.frag.start);if(null!=n&&n.gap)continue}}else{if(p===gM&&n.hasAudioGroup(v)||p===pM&&n.hasSubtitleGroup(v))continue;if(m===yM&&null!=(o=i.audioGroups)&&o.some((e=>n.hasAudioGroup(e)))||m===bM&&null!=(s=i.subtitleGroups)&&s.some((e=>n.hasSubtitleGroup(e)))||f&&i.audioCodec===n.audioCodec||!f&&i.audioCodec!==n.audioCodec||g&&i.codecSet===n.codecSet)continue}d=a;break}}if(d>-1&&n.loadLevel!==d)return e.levelRetry=!0,this.playlistError=0,{action:uT,flags:mT,nextAutoLevel:d}}return{action:uT,flags:fT}}onErrorOut(e,t){var n;switch(null==(n=t.errorAction)?void 0:n.action){case lT:break;case uT:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===sk.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()}sendAlternateToPenaltyBox(e){const t=this.hls,n=e.errorAction;if(!n)return;const{flags:i,hdcpLevel:a,nextAutoLevel:r}=n;switch(i){case mT:this.switchLevel(e,r);break;case gT:a&&(t.maxHdcpLevel=OM[OM.indexOf(a)-1],n.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}n.resolved||this.switchLevel(e,r)}switchLevel(e,t){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)}},fpsController:class{constructor(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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(rk.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(rk.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const n=this.hls.config;if(n.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,n){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,a=n-this.lastDroppedFrames,r=t-this.lastDecodedFrames,o=1e3*a/e,s=this.hls;if(s.trigger(rk.FPS_DROP,{currentDropped:a,currentDecoded:r,totalDroppedFrames:n}),o>0&&a>s.config.fpsDroppedMonitoringThreshold*r){let e=s.currentLevel;hk.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===s.autoLevelCapping||s.autoLevelCapping>=e)&&(e-=1,s.trigger(rk.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:s.currentLevel}),s.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=n,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},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:Uk,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,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}}},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:wx,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:class extends mE{constructor(e,t,n){super(e,t,n,"[subtitle-stream-controller]",bM),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rk.ERROR,this.onError,this),e.on(rk.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(rk.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(rk.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(rk.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rk.ERROR,this.onError,this),e.off(rk.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(rk.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(rk.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(rk.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=nE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:n,success:i}=t;if(this.fragPrevious=n,this.state=nE,!i)return;const a=this.tracksBuffered[this.currentTrackId];if(!a)return;let r;const o=n.start;for(let e=0;e<a.length;e++)if(o>=a[e].start&&o<=a[e].end){r=a[e];break}const s=n.start+n.duration;r?r.end=s:(r={start:o,end:s},a.push(r)),this.fragmentTracker.fragBuffered(n),this.fragBufferedComplete(n,null)}onBufferFlushing(e,t){const{startOffset:n,endOffset:i}=t;if(0===n&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach((t=>{for(let n=0;n<t.length;)if(t[n].end<=e)t.shift();else{if(!(t[n].start<e))break;t[n].start=e,n++}})),this.fragmentTracker.removeFragmentsInRange(n,e,bM)}}onFragBuffered(e,t){var n;this.loadedmetadata||t.frag.type!==vM||null!=(n=this.media)&&n.buffered.length&&(this.loadedmetadata=!0)}onError(e,t){const n=t.frag;(null==n?void 0:n.type)===bM&&(t.details===sk.FRAG_GAP&&this.fragmentTracker.fragBuffered(n,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==tE&&(this.state=nE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){this.levels&&SP(this.levels,t)?this.levels=t.map((e=>new BM(e))):(this.tracksBuffered=[],this.levels=t.map((e=>{const t=new BM(e);return this.tracksBuffered[t.id]=[],t})),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,bM),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){var n;if(this.currentTrackId=t.id,null==(n=this.levels)||!n.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var n;const{currentTrackId:i,levels:a}=this,{details:r,id:o}=t;if(!a)return void this.warn(`Subtitle tracks were reset while loading level ${o}`);const s=a[o];if(o>=a.length||!s)return;this.log(`Subtitle track ${o} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(r.live||null!=(n=s.details)&&n.live){const e=this.mainDetails;if(r.deltaUpdateFailed||!e)return;const t=e.fragments[0];var l;if(s.details)d=this.alignPlaylists(r,s.details,null==(l=this.levelLastLoaded)?void 0:l.details),0===d&&t&&(d=t.start,qM(r,d));else r.hasProgramDateTime&&e.hasProgramDateTime?(BT(r,e),d=r.fragments[0].start):t&&(d=t.start,qM(r,d))}if(s.details=r,this.levelLastLoaded=s,o===i&&(this.startFragRequested||!this.mainDetails&&r.live||this.setStartPosition(this.mainDetails||r,d),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===nE)){oT(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),s.details=void 0)}}_handleFragmentLoadComplete(e){const{frag:t,payload:n}=e,i=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&n&&n.byteLength>0&&null!=i&&i.key&&i.iv&&"AES-128"===i.method){const e=performance.now();this.decrypter.decrypt(new Uint8Array(n),i.key.buffer,i.iv.buffer).catch((e=>{throw a.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((n=>{const i=performance.now();a.trigger(rk.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:e,tdecrypt:i}})})).catch((e=>{this.warn(`${e.name}: ${e.message}`),this.state=nE}))}}doTick(){if(this.media){if(this.state===nE){const{currentTrackId:e,levels:t}=this,n=null==t?void 0:t[e];if(!n||!t.length||!n.details)return;const{config:i}=this,a=this.getLoadPosition(),r=FT.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,i.maxBufferHole),{end:o,len:s}=r,d=this.getFwdBufferInfo(this.media,vM),l=n.details;if(s>this.getMaxBufferLength(null==d?void 0:d.len)+l.levelTargetDuration)return;const u=l.fragments,c=u.length,h=l.edge;let m=null;const f=this.fragPrevious;if(o<h){const e=i.maxFragLookUpTolerance,t=o>h-e?0:e;m=oT(f,u,Math.max(u[0].start,o),t),!m&&f&&f.start<u[0].start&&(m=u[0])}else m=u[c-1];if(!m)return;if(m=this.mapToInitFragWhenRequired(m),"initSegment"!==m.sn){const e=u[m.sn-l.startSN-1];e&&e.cc===m.cc&&this.fragmentTracker.getState(e)===LT&&(m=e)}this.fragmentTracker.getState(m)===LT&&this.loadFragment(m,n,o)}}else this.state=nE}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,n){this.fragCurrent=e,"initSegment"===e.sn?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,n))}get mediaBufferTimeRanges(){return new EP(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends pT{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=null;const t=AM(this.media.textTracks);for(let n=0;n<t.length;n++)if("hidden"===t[n].mode)e=t[n];else if("showing"===t[n].mode){e=t[n];break}const n=this.findTrackForTextTrack(e);this.subtitleTrack!==n&&this.setSubtitleTrack(n)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.LEVEL_LOADING,this.onLevelLoading,this),e.on(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(rk.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(rk.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.LEVEL_LOADING,this.onLevelLoading,this),e.off(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(rk.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(rk.ERROR,this.onError,this)}onMediaAttached(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))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId);AM(this.media.textTracks).forEach((e=>{EM(e)})),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:n,groupId:i,details:a}=t,r=this.tracksInGroup[n];if(!r||r.groupId!==i)return void this.warn(`Subtitle track with id:${n} and group:${i} not found in active group ${null==r?void 0:r.groupId}`);const o=r.details;r.details=t.details,this.log(`Subtitle track ${n} "${r.name}" lang:${r.lang} group:${i} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const n=t.subtitleGroups||null,i=this.groupIds;let a=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some((e=>-1===(null==i?void 0:i.indexOf(e))))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!n||-1!==n.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.subtitlePreference;if(!a&&t){this.selectDefaultTrack=!1;const n=ET(t,e);if(n>-1)a=e[n];else{const e=ET(t,this.tracks);a=this.tracks[e]}}let i=this.findTrackId(a);-1===i&&a&&(i=this.findTrackId(null));const r={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${null==n?void 0:n.join(",")}" group-id`),this.hls.trigger(rk.SUBTITLE_TRACKS_UPDATED,r),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}else this.shouldReloadPlaylist(a)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,n=this.selectDefaultTrack;for(let i=0;i<t.length;i++){const a=t[i];if((!n||a.default)&&(n||e)&&(!e||PT(a,e)))return i}if(e){for(let n=0;n<t.length;n++){const i=t[n];if(MP(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const i=t[n];if(MP(e.attrs,i.attrs,["LANGUAGE"]))return n}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let n=0;n<t.length;n++){if(TP(t[n],e))return n}}return-1}onError(e,t){!t.fatal&&t.context&&(t.context.type!==pM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||this.checkRetry(t))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const n=this.currentTrack;if(n&&PT(e,n))return n;const i=ET(e,this.tracksInGroup);if(i>-1){const e=this.tracksInGroup[i];return this.setSubtitleTrack(i),e}if(n)return null;{const n=ET(e,t);if(n>-1)return t[n]}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const n=t.id,i=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`Loading subtitle playlist for id ${n}`),this.hls.trigger(rk.SUBTITLE_TRACK_LOADING,{url:a,id:n,groupId:i,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=AM(e.textTracks),n=this.currentTrack;let i;if(n&&(i=t.filter((e=>TP(n,e)))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${n.name}" and language "${n.lang}"`)),[].slice.call(t).forEach((e=>{"disabled"!==e.mode&&e!==i&&(e.mode="disabled")})),i){const e=this.subtitleDisplay?"showing":"hidden";i.mode!==e&&(i.mode=e)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(e<-1||e>=t.length||!nk(e))return void this.warn(`Invalid subtitle track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;const n=this.currentTrack,i=t[e]||null;if(this.trackId=e,this.currentTrack=i,this.toggleTrackModes(),!i)return void this.hls.trigger(rk.SUBTITLE_TRACK_SWITCH,{id:e});const a=!!i.details&&!i.details.live;if(e===this.trackId&&i===n&&a)return;this.log(`Switching to subtitle-track ${e}`+(i?` "${i.name}" lang:${i.lang} group:${i.groupId}`:""));const{id:r,groupId:o="",name:s,type:d,url:l}=i;this.hls.trigger(rk.SUBTITLE_TRACK_SWITCH,{id:r,groupId:o,name:s,type:d,url:l});const u=this.switchParams(i.url,null==n?void 0:n.details,i.details);this.loadPlaylist(u)}},timelineController:class{constructor(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=e,this.config=e.config,this.Cues=e.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}},e.on(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(rk.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(rk.FRAG_LOADING,this.onFragLoading,this),e.on(rk.FRAG_LOADED,this.onFragLoaded,this),e.on(rk.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(rk.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(rk.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(rk.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(rk.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(rk.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(rk.FRAG_LOADING,this.onFragLoading,this),e.off(rk.FRAG_LOADED,this.onFragLoaded,this),e.off(rk.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(rk.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(rk.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(rk.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new VP(this,"textTrack1"),t=new VP(this,"textTrack2"),n=new VP(this,"textTrack3"),i=new VP(this,"textTrack4");this.cea608Parser1=new GP(1,e,t),this.cea608Parser2=new GP(3,n,i)}}addCues(e,t,n,i,a){let r=!1;for(let e=a.length;e--;){const i=a[e],u=(o=i[0],s=i[1],d=t,l=n,Math.min(s,l)-Math.max(o,d));if(u>=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],n),r=!0,u/(n-t)>.5))return}var o,s,d,l;if(r||a.push([t,n]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,t,n,i)}else{const a=this.Cues.newCue(null,t,n,i);this.hls.trigger(rk.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:t,id:n,initPTS:i,timescale:a}){const{unparsedVttFrags:r}=this;"main"===n&&(this.initPTS[t.cc]={baseTime:i,timescale:a}),r.length&&(this.unparsedVttFrags=[],r.forEach((e=>{this.onFragLoaded(rk.FRAG_LOADED,e)})))}getExistingTrack(e,t){const{media:n}=this;if(n)for(let i=0;i<n.textTracks.length;i++){const a=n.textTracks[i];if(SA(a,{name:e,lang:t,attrs:{}}))return a}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:n,media:i}=this,{label:a,languageCode:r}=t[e],o=this.getExistingTrack(a,r);if(o)n[e]=o,EM(n[e]),MM(n[e],i);else{const t=this.createTextTrack("captions",a,r);t&&(t[e]=!0,n[e]=t)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const n={_id:e,label:t.label,kind:"captions",default:!!t.media&&!!t.media.default,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(rk.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,n){const i=this.media;if(i)return i.addTextTrack(e,t,n)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach((t=>{EM(e[t]),delete e[t]})),this.nonNativeCaptionsTracks={}}onManifestLoading(){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())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;e<t.length;e++)EM(t[e])}onSubtitleTracksUpdated(e,t){const n=t.subtitleTracks||[],i=n.some((e=>e.textCodec===uA));if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(SP(this.tracks,n))return void(this.tracks=n);if(this.textTracks=[],this.tracks=n,this.config.renderTextTracksNatively){const e=this.media,t=e?AM(e.textTracks):null;if(this.tracks.forEach(((e,n)=>{let i;if(t){let n=null;for(let i=0;i<t.length;i++)if(t[i]&&SA(t[i],e)){n=t[i],t[i]=null;break}n&&(i=n)}if(i)EM(i);else{const t=kA(e);i=this.createTextTrack(t,e.name,e.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)})),null!=t&&t.length){const e=t.filter((e=>null!==e)).map((e=>e.label));e.length&&hk.warn(`Media element contains unused subtitle tracks: ${e.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const e=this.tracks.map((e=>({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e})));this.hls.trigger(rk.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach((e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const n=`textTrack${t[1]}`,i=this.captionsProperties[n];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)}))}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===vM){var n,i;const{cea608Parser1:e,cea608Parser2:a,lastSn:r}=this,{cc:o,sn:s}=t.frag,d=null!=(n=null==(i=t.part)?void 0:i.index)?n:-1;e&&a&&(s!==r+1||s===r&&d!==this.lastPartIndex+1||o!==this.lastCc)&&(e.reset(),a.reset()),this.lastCc=o,this.lastSn=s,this.lastPartIndex=d}}onFragLoaded(e,t){const{frag:n,payload:i}=t;if(n.type===bM)if(i.byteLength){const e=n.decryptdata,a="stats"in t;if(null==e||!e.encrypted||a){const e=this.tracks[n.level],a=this.vttCCs;a[n.cc]||(a[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),e&&e.textCodec===uA?this._parseIMSC1(n,i):this._parseVTTs(t)}}else this.hls.trigger(rk.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const n=this.hls;fA(t,this.initPTS[e.cc],(t=>{this._appendCues(t,e.level),n.trigger(rk.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})}),(t=>{hk.log(`Failed to parse IMSC1: ${t}`),n.trigger(rk.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})}))}_parseVTTs(e){var t;const{frag:n,payload:i}=e,{initPTS:a,unparsedVttFrags:r}=this,o=a.length-1;if(!a[n.cc]&&-1===o)return void r.push(e);const s=this.hls;lA(null!=(t=n.initSegment)&&t.data?xS(n.initSegment.data,new Uint8Array(i)):i,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,(e=>{this._appendCues(e,n.level),s.trigger(rk.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})}),(t=>{const a="Missing initPTS for VTT MPEGTS"===t.message;a?r.push(e):this._fallbackToIMSC1(n,i),hk.log(`Failed to parse VTT cue: ${t}`),a&&o>n.cc||s.trigger(rk.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:t})}))}_fallbackToIMSC1(e,t){const n=this.tracks[e.level];n.textCodec||fA(t,this.initPTS[e.cc],(()=>{n.textCodec=uA,this._parseIMSC1(e,t)}),(()=>{n.textCodec="wvtt"}))}_appendCues(e,t){const n=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||"disabled"===n.mode)return;e.forEach((e=>TM(n,e)))}else{const i=this.tracks[t];if(!i)return;const a=i.default?"default":"subtitles"+t;n.trigger(rk.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}onFragDecrypted(e,t){const{frag:n}=t;n.type===bM&&this.onFragLoaded(rk.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:n,cea608Parser2:i}=this;if(!this.enabled||!n||!i)return;const{frag:a,samples:r}=t;if(a.type!==vM||"NONE"!==this.closedCaptionsForLevel(a))for(let e=0;e<r.length;e++){const t=r[e].bytes;if(t){const a=this.extractCea608Data(t);n.addData(r[e].pts,a[0]),i.addData(r[e].pts,a[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:n,endOffsetSubtitles:i,type:a}){const{media:r}=this;if(r&&!(r.currentTime<n)){if(!a||"video"===a){const{captionsTracks:e}=this;Object.keys(e).forEach((i=>PM(e[i],t,n)))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach((n=>PM(e[n],t,i)))}}}extractCea608Data(e){const t=[[],[]],n=31&e[0];let i=2;for(let a=0;a<n;a++){const n=e[i++],a=127&e[i++],r=127&e[i++];if(0===a&&0===r)continue;if(!!(4&n)){const e=3&n;0!==e&&1!==e||(t[e].push(a),t[e].push(r))}}return t}},audioStreamController:class extends mE{constructor(e,t,n){super(e,t,n,"[audio-stream-controller]",yM),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rk.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(rk.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(rk.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(rk.ERROR,this.onError,this),e.on(rk.BUFFER_RESET,this.onBufferReset,this),e.on(rk.BUFFER_CREATED,this.onBufferCreated,this),e.on(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(rk.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(rk.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rk.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(rk.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(rk.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(rk.ERROR,this.onError,this),e.off(rk.BUFFER_RESET,this.onBufferReset,this),e.off(rk.BUFFER_CREATED,this.onBufferCreated,this),e.off(rk.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(rk.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(rk.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:n,initPTS:i,timescale:a}){if("main"===n){const e=t.cc;this.initPTS[t.cc]={baseTime:i,timescale:a},this.log(`InitPTS for cc: ${e} found from main: ${i}`),this.videoTrackCC=e,this.state===cE&&this.tick()}}startLoad(e){if(!this.levels)return this.startPosition=e,void(this.state=tE);const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),t>0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=nE):(this.loadedmetadata=!1,this.state=oE),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case nE:this.doTickIdle();break;case oE:{var e;const{levels:t,trackId:n}=this,i=null==t||null==(e=t[n])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=cE}break}case rE:{var t;const e=performance.now(),n=this.retryDate;if(!n||e>=n||null!=(t=this.media)&&t.seeking){const{levels:e,trackId:t}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==e?void 0:e[t])||null),this.state=nE}break}case cE:{const e=this.waitingData;if(e){const{frag:t,part:n,cache:i,complete:a}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=aE;const e={frag:t,part:n,payload:i.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),a&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const e=this.getLoadPosition(),n=FT.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);sT(n.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${n.end} is needed`),this.clearWaitingFragment())}}else this.state=nE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=nE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:n,trackId:i}=this,a=e.config;if(!n&&(this.startFragRequested||!a.startFragPrefetch)||null==t||!t[i])return;const r=t[i],o=r.details;if(!o||o.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(o))return void(this.state=oE);const s=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&s&&(this.bufferFlushed=!1,this.afterBufferFlushed(s,bk,yM));const d=this.getFwdBufferInfo(s,yM);if(null===d)return;const{bufferedTrack:l,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o))return e.trigger(rk.BUFFER_EOS,{type:"audio"}),void(this.state=lE);const c=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,vM),h=d.len,m=this.getMaxBufferLength(null==c?void 0:c.len),f=o.fragments,g=f[0].start;let p=this.flushing?this.getLoadPosition():d.end;if(u&&n){const e=this.getLoadPosition();l&&!MP(u.attrs,l.attrs)&&(p=e),o.PTSKnown&&e<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),n.currentTime=g+.05)}if(h>=m&&!u&&p<f[f.length-1].start)return;let v=this.getNextFragment(p,o),y=!1;if(v&&this.isLoopLoading(v,p)&&(y=!!v.gap,v=this.getNextFragmentLoopLoading(v,o,d,vM,m)),!v)return void(this.bufferFlushed=!0);const b=c&&v.start>c.end+o.targetduration;if(b||(null==c||!c.len)&&d.len){const e=this.getAppendedFrag(v.start,vM);if(null===e)return;if(y||(y=!!e.gap||!!b&&0===c.len),b&&!y||y&&d.nextStart&&d.nextStart<e.end)return}this.loadFragment(v,r,p)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map((e=>new BM(e)))}onAudioTrackSwitching(e,t){const n=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),n?this.setInterval(100):this.resetTransmuxer(),n?(this.switchingTrack=t,this.state=nE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=tE),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(rk.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var n;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);const{levels:i}=this,{details:a,id:r}=t;if(!i)return void this.warn(`Audio tracks were reset while loading level ${r}`);this.log(`Audio track ${r} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);const o=i[r];let s=0;if(a.live||null!=(n=o.details)&&n.live){this.checkLiveUpdate(a);const e=this.mainDetails;if(a.deltaUpdateFailed||!e)return;var d;if(!o.details&&a.hasProgramDateTime&&e.hasProgramDateTime)BT(a,e),s=a.fragments[0].start;else s=this.alignPlaylists(a,o.details,null==(d=this.levelLastLoaded)?void 0:d.details)}o.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,s),this.state!==oE||this.waitForCdnTuneIn(a)||(this.state=nE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:n,part:i,payload:a}=e,{config:r,trackId:o,levels:s}=this;if(!s)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const d=s[o];if(!d)return void this.warn("Audio track is undefined on fragment load progress");const l=d.details;if(!l)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(n.start);const u=r.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let c=this.transmuxer;c||(c=this.transmuxer=new kP(this.hls,yM,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[n.cc],m=null==(t=n.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,r=-1!==t,o=new jT(n.level,n.sn,n.stats.chunkCount,a.byteLength,t,r);c.push(a,m,u,"",n,i,l.totalduration,e,o,h)}else{this.log(`Unknown video PTS for cc ${n.cc}, waiting for video PTS before demuxing audio frag ${n.sn} of [${l.startSN} ,${l.endSN}],track ${o}`);const{cache:e}=this.waitingData=this.waitingData||{frag:n,part:i,cache:new fE,complete:!1};e.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=cE}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const n=t.tracks.audio;n&&(this.mediaBuffer=n.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:n,part:i}=t;if(n.type===yM)if(this.fragContextChanged(n))this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==n.sn){this.fragPrevious=n;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(rk.AUDIO_TRACK_SWITCHED,Qw({},e)))}this.fragBufferedComplete(n,i)}else if(!this.loadedmetadata&&n.type===vM){const e=this.videoBuffer||this.media;if(e){FT.getBuffered(e).length&&(this.loadedmetadata=!0)}}}onError(e,t){var n;if(t.fatal)this.state=uE;else switch(t.details){case sk.FRAG_GAP:case sk.FRAG_PARSING_ERROR:case sk.FRAG_DECRYPT_ERROR:case sk.FRAG_LOAD_ERROR:case sk.FRAG_LOAD_TIMEOUT:case sk.KEY_LOAD_ERROR:case sk.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(yM,t);break;case sk.AUDIO_TRACK_LOAD_ERROR:case sk.AUDIO_TRACK_LOAD_TIMEOUT:case sk.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==oE||(null==(n=t.context)?void 0:n.type)!==gM||(this.state=nE);break;case sk.BUFFER_APPEND_ERROR:case sk.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;if(t.details===sk.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case sk.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushing(e,{type:t}){t!==wk&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==wk){this.flushing=!1,this.bufferFlushed=!0,this.state===lE&&(this.state=nE);const e=this.mediaBuffer||this.media;e&&(this.afterBufferFlushed(e,t,yM),this.tick())}}_handleTransmuxComplete(e){var t;const n="audio",{hls:i}=this,{remuxResult:a,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o)return void this.resetWhenMissingContext(r);const{frag:s,part:d,level:l}=o,{details:u}=l,{audio:c,text:h,id3:m,initSegment:f}=a;if(!this.fragContextChanged(s)&&u){if(this.state=sE,this.switchingTrack&&c&&this.completeAudioSwitch(this.switchingTrack),null!=f&&f.tracks){const e=s.initSegment||s;this._bufferInitSegment(l,f.tracks,e,r),i.trigger(rk.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:n,tracks:f.tracks})}if(c){const{startPTS:e,endPTS:t,startDTS:n,endDTS:i}=c;d&&(d.elementaryStreams[bk]={startPTS:e,endPTS:t,startDTS:n,endDTS:i}),s.setElementaryStreamInfo(bk,e,t,n,i),this.bufferFragmentData(c,s,d,r)}if(null!=m&&null!=(t=m.samples)&&t.length){const e=tk({id:n,frag:s,details:u},m);i.trigger(rk.FRAG_PARSING_METADATA,e)}if(h){const e=tk({id:n,frag:s,details:u},h);i.trigger(rk.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(s)}_bufferInitSegment(e,t,n,i){if(this.state!==sE)return;t.video&&delete t.video;const a=t.audio;if(!a)return;a.id="audio";const 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(rk.BUFFER_CODECS,t);const o=a.initSegment;if(null!=o&&o.byteLength){const e={type:"audio",frag:n,part:null,chunkMeta:i,parent:n.type,data:o};this.hls.trigger(rk.BUFFER_APPENDING,e)}this.tickImmediate()}loadFragment(e,t,n){const i=this.fragmentTracker.getState(e);var a;if(this.fragCurrent=e,this.switchingTrack||i===LT||i===IT)if("initSegment"===e.sn)this._loadInitSegment(e,t);else if(null!=(a=t.details)&&a.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=cE;const n=this.mainDetails;n&&n.fragments[0].start!==t.details.fragments[0].start&&BT(t.details,n)}else this.startFragRequested=!0,super.loadFragment(e,t,n);else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:n}=this,i=null==n?void 0:n.attrs,a=e.attrs;t&&i&&(i.CHANNELS!==a.CHANNELS||n.name!==e.name||n.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(rk.AUDIO_TRACK_SWITCHED,Qw({},e))}},audioTrackController:class extends pT{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.LEVEL_LOADING,this.onLevelLoading,this),e.on(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(rk.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(rk.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.LEVEL_LOADING,this.onLevelLoading,this),e.off(rk.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(rk.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(rk.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:n,groupId:i,details:a}=t,r=this.tracksInGroup[n];if(!r||r.groupId!==i)return void this.warn(`Audio track with id:${n} and group:${i} not found in active group ${null==r?void 0:r.groupId}`);const o=r.details;r.details=t.details,this.log(`Audio track ${n} "${r.name}" lang:${r.lang} group:${i} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const n=t.audioGroups||null,i=this.groupIds;let a=this.currentTrack;if(!n||(null==i?void 0:i.length)!==(null==n?void 0:n.length)||null!=n&&n.some((e=>-1===(null==i?void 0:i.indexOf(e))))){this.groupIds=n,this.trackId=-1,this.currentTrack=null;const e=this.tracks.filter((e=>!n||-1!==n.indexOf(e.groupId)));if(e.length)this.selectDefaultTrack&&!e.some((e=>e.default))&&(this.selectDefaultTrack=!1),e.forEach(((e,t)=>{e.id=t}));else if(!a&&!this.tracksInGroup.length)return;this.tracksInGroup=e;const t=this.hls.config.audioPreference;if(!a&&t){const n=ET(t,e,AT);if(n>-1)a=e[n];else{const e=ET(t,this.tracks);a=this.tracks[e]}}let i=this.findTrackId(a);-1===i&&a&&(i=this.findTrackId(null));const o={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group(s): ${null==n?void 0:n.join(",")}`),this.hls.trigger(rk.AUDIO_TRACKS_UPDATED,o);const s=this.trackId;if(-1!==i&&-1===s)this.setAudioTrack(i);else if(e.length&&-1===s){var r;const t=new Error(`No audio track selected for current audio group-ID(s): ${null==(r=this.groupIds)?void 0:r.join(",")} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}else this.shouldReloadPlaylist(a)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&(t.context.type!==gM||t.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(t.context.groupId)||(this.requestScheduled=-1,this.checkRetry(t)))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const n=this.allAudioTracks;if(this.selectDefaultTrack=!1,n.length){const i=this.currentTrack;if(i&&PT(e,i,AT))return i;const a=ET(e,this.tracksInGroup,AT);if(a>-1){const e=this.tracksInGroup[a];return this.setAudioTrack(a),e}if(i){let i=t.loadLevel;-1===i&&(i=t.firstAutoLevel);const a=function(e,t,n,i,a){const r=t[i],o=t.reduce(((e,t,n)=>{const i=t.uri;return(e[i]||(e[i]=[])).push(n),e}),{})[r.uri];o.length>1&&(i=Math.max.apply(Math,o));const s=r.videoRange,d=r.frameRate,l=r.codecSet.substring(0,4),u=xT(t,i,(t=>{if(t.videoRange!==s||t.frameRate!==d||t.codecSet.substring(0,4)!==l)return!1;const i=t.audioGroups,r=n.filter((e=>!i||-1!==i.indexOf(e.groupId)));return ET(e,r,a)>-1}));return u>-1?u:xT(t,i,(t=>{const i=t.audioGroups,r=n.filter((e=>!i||-1!==i.indexOf(e.groupId)));return ET(e,r,a)>-1}))}(e,t.levels,n,i,AT);if(-1===a)return null;t.nextLoadLevel=a}if(e.channels||e.audioCodec){const t=ET(e,n);if(t>-1)return n[t]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn(`Invalid audio track id: ${e}`);this.clearTimer(),this.selectDefaultTrack=!1;const n=this.currentTrack,i=t[e],a=i.details&&!i.details.live;if(e===this.trackId&&i===n&&a)return;if(this.log(`Switching to audio-track ${e} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=e,this.currentTrack=i,this.hls.trigger(rk.AUDIO_TRACK_SWITCHING,Qw({},i)),a)return;const r=this.switchParams(i.url,null==n?void 0:n.details,i.details);this.loadPlaylist(r)}findTrackId(e){const t=this.tracksInGroup;for(let n=0;n<t.length;n++){const i=t[n];if((!this.selectDefaultTrack||i.default)&&(!e||PT(e,i,AT)))return n}if(e){const{name:n,lang:i,assocLang:a,characteristics:r,audioCodec:o,channels:s}=e;for(let e=0;e<t.length;e++){if(PT({name:n,lang:i,assocLang:a,characteristics:r,audioCodec:o,channels:s},t[e],AT))return e}for(let n=0;n<t.length;n++){const i=t[n];if(MP(e.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return n}for(let n=0;n<t.length;n++){const i=t[n];if(MP(e.attrs,i.attrs,["LANGUAGE"]))return n}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const n=t.id,i=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}this.log(`loading audio-track playlist ${n} "${t.name}" lang:${t.lang} group:${i}`),this.clearTimer(),this.hls.trigger(rk.AUDIO_TRACK_LOADING,{url:a,id:n,groupId:i,deliveryDirectives:e||null})}}},emeController:EA,cmcdController:class{constructor(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:AA.MANIFEST,su:!this.initialized})}catch(e){hk.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const t=e.frag,n=this.hls.levels[t.level],i=this.getObjectType(t),a={d:1e3*t.duration,ot:i};i!==AA.VIDEO&&i!==AA.AUDIO&&i!=AA.MUXED||(a.br=n.bitrate/1e3,a.tb=this.getTopBandwidth(i)/1e3,a.bl=this.getBufferLength(i)),this.apply(e,a)}catch(e){hk.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:n}=t;null!=n&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||function(){try{return crypto.randomUUID()}catch(e){try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch(e){let t=(new Date).getTime();const n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const n=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?n:3&n|8).toString(16)}));return n}}}(),this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.includeKeys=n.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHED,this.onMediaDetached,this),e.on(rk.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHED,this.onMediaDetached,this),e.off(rk.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var n,i;this.audioBuffer=null==(n=t.tracks.audio)?void 0:n.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:xA.HLS,sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){tk(t,this.createData());const n=t.ot===AA.INIT||t.ot===AA.VIDEO||t.ot===AA.MUXED;this.starved&&n&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering);const{includeKeys:i}=this;i&&(t=Object.keys(t).reduce(((e,n)=>(i.includes(n)&&(e[n]=t[n]),e)),{})),this.useHeaders?(e.headers||(e.headers={}),sx(e.headers,t)):e.url=ux(e.url,t)}getObjectType(e){const{type:t}=e;return"subtitle"===t?AA.TIMED_TEXT:"initSegment"===e.sn?AA.INIT:"audio"===t?AA.AUDIO:"main"===t?this.hls.audioTracks.length?AA.VIDEO:AA.MUXED:void 0}getTopBandwidth(e){let t,n=0;const i=this.hls;if(e===AA.AUDIO)t=i.audioTracks;else{const e=i.maxAutoLevel,n=e>-1?e+1:i.levels.length;t=i.levels.slice(0,n)}for(const e of t)e.bitrate>n&&(n=e.bitrate);return n>0?n:NaN}getBufferLength(e){const t=this.hls.media,n=e===AA.AUDIO?this.audioBuffer:this.videoBuffer;if(!n||!t)return NaN;return 1e3*FT.bufferInfo(n,t.currentTime,this.config.maxBufferHole).len}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,n=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new n(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,n,i){t(e),this.loader.load(e,n,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,n=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new n(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,n,i){t(e),this.loader.load(e,n,i)}}}},contentSteeringController:class{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=hk.log.bind(hk,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=1e3*this.timeToLoad-(performance.now()-this.updated);if(e>0)return void this.scheduleRefresh(this.uri,e)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter((t=>t!==e)))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:n}=t;null!==n&&(this.pathwayId=n.pathwayId,this.uri=n.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:n}=t;if((null==n?void 0:n.action)===uT&&n.flags===fT){const e=this.levels;let i=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:n,pathwayId:i,type:r}=t.context;n&&e?a=this.getPathwayForGroupId(n,r,a):i&&(a=i)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!i&&e&&(i=e.reduce(((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e)),[])),i&&i.length>1&&(this.updatePathwayPriority(i),n.resolved=this.pathwayId!==a),n.resolved||hk.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${e?e.length:e} priorities: ${JSON.stringify(i)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const n=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${n}"`),t=this.getLevelsForPathway(n),this.pathwayId=n}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter((t=>e===t.pathwayId))}updatePathwayPriority(e){let t;this.pathwayPriority=e;const n=this.penalizedPathways,i=performance.now();Object.keys(n).forEach((e=>{i-n[e]>3e5&&delete n[e]}));for(let i=0;i<e.length;i++){const a=e[i];if(a in n)continue;if(a===this.pathwayId)return;const r=this.hls.nextLoadLevel,o=this.hls.levels[r];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,ZM(t),this.hls.trigger(rk.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[r];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=r);break}}}getPathwayForGroupId(e,t,n){const i=this.getLevelsForPathway(n).concat(this.levels||[]);for(let n=0;n<i.length;n++)if(t===gM&&i[n].hasAudioGroup(e)||t===pM&&i[n].hasSubtitleGroup(e))return i[n].pathwayId;return n}clonePathways(e){const t=this.levels;if(!t)return;const n={},i={};e.forEach((e=>{const{ID:a,"BASE-ID":r,"URI-REPLACEMENT":o}=e;if(t.some((e=>e.pathwayId===a)))return;const s=this.getLevelsForPathway(r).map((e=>{const t=new gk(e.attrs);t["PATHWAY-ID"]=a;const r=t.AUDIO&&`${t.AUDIO}_clone_${a}`,s=t.SUBTITLES&&`${t.SUBTITLES}_clone_${a}`;r&&(n[t.AUDIO]=r,t.AUDIO=r),s&&(i[t.SUBTITLES]=s,t.SUBTITLES=s);const d=hx(e.uri,t["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o),l=new BM({attrs:t,audioCodec:e.audioCodec,bitrate:e.bitrate,height:e.height,name:e.name,url:d,videoCodec:e.videoCodec,width:e.width});if(e.audioGroups)for(let t=1;t<e.audioGroups.length;t++)l.addGroupId("audio",`${e.audioGroups[t]}_clone_${a}`);if(e.subtitleGroups)for(let t=1;t<e.subtitleGroups.length;t++)l.addGroupId("text",`${e.subtitleGroups[t]}_clone_${a}`);return l}));t.push(...s),cx(this.audioTracks,n,o,a),cx(this.subtitleTracks,i,o,a)}))}loadSteeringManifest(e){const t=this.hls.config,n=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new n(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const a={responseType:"json",url:i.href},r=t.steeringManifestLoadPolicy.default,o=r.errorRetry||r.timeoutRetry||{},s={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(e,t,n,a)=>{this.log(`Loaded steering manifest: "${i}"`);const r=e.data;if(1!==r.VERSION)return void this.log(`Steering VERSION ${r.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=r.TTL;const{"RELOAD-URI":o,"PATHWAY-CLONES":s,"PATHWAY-PRIORITY":d}=r;if(o)try{this.uri=new self.URL(o,i).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);const l={steeringManifest:r,url:i.toString()};this.hls.trigger(rk.STEERING_MANIFEST_LOADED,l),d&&this.updatePathwayPriority(d)},onError:(e,t,n,i)=>{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`);let a=1e3*this.timeToLoad;if(429!==e.code)this.scheduleRefresh(this.uri||t.url,a);else{const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(a=1e3*parseFloat(t))}this.log(`Steering manifest ${t.url} rate limited`)}},onTimeout:(e,t,n)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(a,s,d)}scheduleRefresh(e,t=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout((()=>{var t;const n=null==(t=this.hls)?void 0:t.media;!n||n.ended?this.scheduleRefresh(e,1e3*this.timeToLoad):this.loadSteeringManifest(e)}),t)}}});function Sx(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Sx):Object.keys(e).reduce(((t,n)=>(t[n]=Sx(e[n]),t)),{}):e}function Mx(e){const t=e.loader;if(t!==px&&t!==fx)hk.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1;else{(function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1})()&&(e.loader=px,e.progressive=!0,e.enableSoftwareAES=!0,hk.log("[config]: Progressive streaming enabled, using FetchLoader"))}}let Tx;class Ex extends pT{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.on(rk.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this),e.off(rk.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach((e=>{e.loadError=0,e.fragmentError=0})),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const n=this.hls.config.preferManagedMediaSource,i=[],a={},r={};let o=!1,s=!1,d=!1;t.levels.forEach((e=>{var t,l;const u=e.attrs;let{audioCodec:c,videoCodec:h}=e;-1!==(null==(t=c)?void 0:t.indexOf("mp4a.40.34"))&&(Tx||(Tx=/chrome|firefox/i.test(navigator.userAgent)),Tx&&(e.audioCodec=c=void 0)),c&&(e.audioCodec=c=QS(c,n)),0===(null==(l=h)?void 0:l.indexOf("avc1"))&&(h=e.videoCodec=function(e){const t=e.split(",");for(let e=0;e<t.length;e++){const n=t[e].split(".");if(n.length>2){let i=n.shift()+".";i+=parseInt(n.shift()).toString(16),i+=("000"+parseInt(n.shift()).toString(16)).slice(-4),t[e]=i}}return t.join(",")}(h));const{width:m,height:f,unknownCodecs:g}=e;if(o||(o=!(!m||!f)),s||(s=!!h),d||(d=!!c),null!=g&&g.length||c&&!GS(c,"audio",n)||h&&!GS(h,"video",n))return;const{CODECS:p,"FRAME-RATE":v,"HDCP-LEVEL":y,"PATHWAY-ID":b,RESOLUTION:w,"VIDEO-RANGE":k}=u,S=`${`${b||"."}-`}${e.bitrate}-${w}-${v}-${p}-${k}-${y}`;if(a[S])if(a[S].uri===e.url||e.attrs["PATHWAY-ID"])a[S].addGroupId("audio",u.AUDIO),a[S].addGroupId("text",u.SUBTITLES);else{const t=r[S]+=1;e.attrs["PATHWAY-ID"]=new Array(t+1).join(".");const n=new BM(e);a[S]=n,i.push(n)}else{const t=new BM(e);a[S]=t,r[S]=1,i.push(t)}})),this.filterAndSortMediaOptions(i,t,o,s,d)}filterAndSortMediaOptions(e,t,n,i,a){let r=[],o=[],s=e;if((n||i)&&a&&(s=s.filter((({videoCodec:e,videoRange:t,width:n,height:i})=>{return(!!e||!(!n||!i))&&(!!(a=t)&&FM.indexOf(a)>-1);var a}))),0===s.length)return void Promise.resolve().then((()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}}));if(t.audioTracks){const{preferManagedMediaSource:e}=this.hls.config;r=t.audioTracks.filter((t=>!t.audioCodec||GS(t.audioCodec,"audio",e))),Px(r)}t.subtitles&&(o=t.subtitles,Px(o));const d=s.slice(0);s.sort(((e,t)=>{if(e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"])return(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1;if(n&&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 FM.indexOf(e.videoRange)-FM.indexOf(t.videoRange);if(e.videoCodec!==t.videoCodec){const n=VS(e.videoCodec),i=VS(t.videoCodec);if(n!==i)return i-n}if(e.uri===t.uri&&e.codecSet!==t.codecSet){const n=KS(e.codecSet),i=KS(t.codecSet);if(n!==i)return i-n}return e.averageBitrate!==t.averageBitrate?e.averageBitrate-t.averageBitrate:0}));let l=d[0];if(this.steering&&(s=this.steering.filterParsedLevels(s),s.length!==d.length))for(let e=0;e<d.length;e++)if(d[e].pathwayId===s[0].pathwayId){l=d[e];break}this._levels=s;for(let e=0;e<s.length;e++)if(s[e]===l){var u;this._firstLevel=e;const t=l.bitrate,n=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${s.length} level(s) found, first bitrate: ${t}`),void 0===(null==(u=this.hls.userConfig)?void 0:u.abrEwmaDefaultEstimate)){const e=Math.min(t,this.hls.config.abrEwmaDefaultEstimateMax);e>n&&n===kx.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=e)}break}const c=a&&!i,h={levels:s,audioTracks:r,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:i,altAudio:!c&&r.some((e=>!!e.url))};this.hls.trigger(rk.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const n=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(rk.ERROR,{type:ok.OTHER_ERROR,details:sk.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:n,reason:n.message}),i)return;e=Math.min(e,t.length-1)}const n=this.currentLevelIndex,i=this.currentLevel,a=i?i.attrs["PATHWAY-ID"]:void 0,r=t[e],o=r.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=r,n===e&&r.details&&i&&a===o)return;this.log(`Switching to level ${e} (${r.height?r.height+"p ":""}${r.videoRange?r.videoRange+" ":""}${r.codecSet?r.codecSet+" ":""}@${r.bitrate})${o?" with Pathway "+o:""} from level ${n}${a?" with Pathway "+a:""}`);const s={level:e,attrs:r.attrs,details:r.details,bitrate:r.bitrate,averageBitrate:r.averageBitrate,maxBitrate:r.maxBitrate,realBitrate:r.realBitrate,width:r.width,height:r.height,codecSet:r.codecSet,audioCodec:r.audioCodec,videoCodec:r.videoCodec,audioGroups:r.audioGroups,subtitleGroups:r.subtitleGroups,loaded:r.loaded,loadError:r.loadError,fragmentError:r.fragmentError,name:r.name,id:r.id,uri:r.uri,url:r.url,urlId:0,audioGroupIds:r.audioGroupIds,textGroupIds:r.textGroupIds};this.hls.trigger(rk.LEVEL_SWITCHING,s);const d=r.details;if(!d||d.live){const e=this.switchParams(r.uri,null==i?void 0:i.details,d);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===fM&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(void 0!==t&&t.type===vM){const e=t.elementaryStreams;if(!Object.keys(e).some((t=>!!e[t])))return;const n=this._levels[t.level];null!=n&&n.loadError&&(this.log(`Resetting level error count of ${n.loadError} on frag buffered`),n.loadError=0)}}onLevelLoaded(e,t){var n;const{level:i,details:a}=t,r=this._levels[i];var o;if(!r)return this.warn(`Invalid level index ${i}`),void(null!=(o=t.deliveryDirectives)&&o.skip&&(a.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===r.fragmentError&&(r.loadError=0),this.playlistLoaded(i,t,r.details)):null!=(n=t.deliveryDirectives)&&n.skip&&(a.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,n=this.currentLevel;if(n&&this.shouldLoadPlaylist(n)){let i=n.uri;if(e)try{i=e.addDirectives(i)}catch(e){this.warn(`Could not construct new URL with HLS Delivery Directives: ${e}`)}const a=n.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""} with${a?" Pathway "+a:""} ${i}`),this.clearTimer(),this.hls.trigger(rk.LEVEL_LOADING,{url:i,level:t,pathwayId:n.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const n=this._levels.filter(((t,n)=>n!==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)));ZM(n),this._levels=n,this.currentLevelIndex>-1&&null!=(t=this.currentLevel)&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(rk.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:n}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(rk.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:n}))}}function Px(e){const t={};e.forEach((e=>{const n=e.groupId||"";e.id=t[n]=t[n]||0,t[n]++}))}class Ax{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const n in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[n].loader;if(i){var t;if(e&&e!==(null==(t=i.context)?void 0:t.frag.type))return;i.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=sk.KEY_LOAD_ERROR,n,i,a){return new KT({type:ok.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:n,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:n,cc:i}=e;for(let e=0;e<t.length;e++){const a=t[e];if(i<=a.cc&&("initSegment"===n||"initSegment"===a.sn||n<a.sn)){this.emeController.selectKeySystemFormat(a).then((e=>{a.setKeyFormat(e)}));break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then((t=>this.loadInternal(e,t))):this.loadInternal(e)}loadInternal(e,t){var n,i;t&&e.setKeyFormat(t);const a=e.decryptdata;if(!a){const n=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,sk.KEY_LOAD_ERROR,n))}const r=a.uri;if(!r)return Promise.reject(this.createKeyLoadError(e,sk.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${r}"`)));let o=this.keyUriToKeyInfo[r];if(null!=(n=o)&&n.decryptdata.key)return a.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});var s;if(null!=(i=o)&&i.keyLoadPromise)switch(null==(s=o.mediaKeySessionContext)?void 0:s.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then((t=>(a.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o})))}switch(o=this.keyUriToKeyInfo[r]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===a.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,sk.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}loadKeyEME(e,t){const n={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(n);if(t)return(e.keyLoadPromise=t.then((t=>(e.mediaKeySessionContext=t,n)))).catch((t=>{throw e.keyLoadPromise=null,t}))}return Promise.resolve(n)}loadKeyHTTP(e,t){const n=this.config,i=new(0,n.loader)(n);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise(((a,r)=>{const o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},s=n.keyLoadPolicy.default,d={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},l={onSuccess:(e,t,n,i)=>{const{frag:o,keyInfo:s,url:d}=n;if(!o.decryptdata||s!==this.keyUriToKeyInfo[d])return r(this.createKeyLoadError(o,sk.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));s.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,s.loader=null,a({frag:o,keyInfo:s})},onError:(e,n,i,a)=>{this.resetLoader(n),r(this.createKeyLoadError(t,sk.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Qw({url:o.url,data:void 0},e)))},onTimeout:(e,n,i)=>{this.resetLoader(n),r(this.createKeyLoadError(t,sk.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,n,i)=>{this.resetLoader(n),r(this.createKeyLoadError(t,sk.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(o,d,l)}))}resetLoader(e){const{frag:t,keyInfo:n,url:i}=e,a=n.loader;t.keyLoader===a&&(t.keyLoader=null,n.loader=null),delete this.keyUriToKeyInfo[i],a&&a.destroy()}}function xx(){return self.SourceBuffer||self.WebKitSourceBuffer}function Cx(){if(!US())return!1;const e=xx();return!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove}class Lx{constructor(e,t,n,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=n,this.hls=i}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:n,media:i,stalled:a}=this;if(null===i)return;const{currentTime:r,seeking:o}=i,s=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,r!==e){if(this.moved=!0,o||(this.nudgeRetry=0),null!==a){if(this.stallReported){const e=self.performance.now()-a;hk.warn(`playback not stuck anymore @${r}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||s)return void(this.stalled=null);if(i.paused&&!o||i.ended||0===i.playbackRate||!FT.getBuffered(i).length)return void(this.nudgeRetry=0);const l=FT.bufferInfo(i,r,0),u=l.nextStart||0;if(o){const e=l.len>2,n=!u||t&&t.start<=r||u-r>2&&!this.fragmentTracker.getPartialFragment(r);if(e||n)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var c;if(!(l.len>0)&&!u)return;const e=Math.max(u,l.start||0)-r,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,n=(null==t||null==(c=t.details)?void 0:c.live)?2*t.details.targetduration:2,a=this.fragmentTracker.getPartialFragment(r);if(e>0&&(e<=n||a))return void(i.paused||this._trySkipBufferHole(a))}const h=self.performance.now();if(null===a)return void(this.stalled=h);const m=h-a;if(!o&&m>=250&&(this._reportStall(l),!this.media))return;const f=FT.bufferInfo(i,r,n.maxBufferHole);this._tryFixBufferStall(f,m)}_tryFixBufferStall(e,t){const{config:n,fragmentTracker:i,media:a}=this;if(null===a)return;const r=a.currentTime,o=i.getPartialFragment(r);if(o){if(this._trySkipBufferHole(o)||!this.media)return}(e.len>n.maxBufferHole||e.nextStart&&e.nextStart-r<n.maxBufferHole)&&t>1e3*n.highBufferWatchdogPeriod&&(hk.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:n,stallReported:i}=this;if(!i&&n){this.stallReported=!0;const i=new Error(`Playback stalling at @${n.currentTime} due to low buffer (${JSON.stringify(e)})`);hk.warn(i.message),t.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:n,media:i}=this;if(null===i)return 0;const a=i.currentTime,r=FT.bufferInfo(i,a,0),o=a<r.start?r.start:r.nextStart;if(o){const s=r.len<=t.maxBufferHole,d=r.len>0&&r.len<1&&i.readyState<3,l=o-a;if(l>0&&(s||d)){if(l>t.maxBufferHole){const{fragmentTracker:t}=this;let n=!1;if(0===a){const e=t.getAppendedFrag(0,vM);e&&o<e.end&&(n=!0)}if(!n){const n=e||t.getAppendedFrag(a,vM);if(n){let e=!1,i=n.end;for(;i<o;){const n=t.getPartialFragment(i);if(!n){e=!0;break}i+=n.duration}if(e)return 0}}}const r=Math.max(o+.05,a+.1);if(hk.warn(`skipping hole, adjusting currentTime from ${a} to ${r}`),this.moved=!0,this.stalled=null,i.currentTime=r,e&&!e.gap){const t=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${r}`);n.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:t,reason:t.message,frag:e})}return r}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:n,nudgeRetry:i}=this;if(null===n)return;const a=n.currentTime;if(this.nudgeRetry++,i<e.nudgeMaxRetry){const r=a+(i+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${a} to ${r}`);hk.warn(o.message),n.currentTime=r,t.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const n=new Error(`Playhead still not moving while enough data buffered @${a} after ${e.nudgeMaxRetry} nudges`);hk.error(n.message),t.trigger(rk.ERROR,{type:ok.MEDIA_ERROR,details:sk.BUFFER_STALLED_ERROR,error:n,fatal:!0})}}}class Dx extends mE{constructor(e,t,n){super(e,t,n,"[stream-controller]",vM),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.on(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.on(rk.LEVEL_LOADING,this.onLevelLoading,this),e.on(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.on(rk.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(rk.ERROR,this.onError,this),e.on(rk.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(rk.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(rk.BUFFER_CREATED,this.onBufferCreated,this),e.on(rk.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(rk.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(rk.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(rk.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(rk.MANIFEST_LOADING,this.onManifestLoading,this),e.off(rk.MANIFEST_PARSED,this.onManifestParsed,this),e.off(rk.LEVEL_LOADED,this.onLevelLoaded,this),e.off(rk.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(rk.ERROR,this.onError,this),e.off(rk.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(rk.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(rk.BUFFER_CREATED,this.onBufferCreated,this),e.off(rk.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(rk.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(rk.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:n}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let e=n.startLevel;-1===e&&(n.config.testBandwidth&&this.levels.length>1?(e=0,this.bitrateTest=!0):e=n.firstAutoLevel),n.nextLoadLevel=e,this.level=n.loadLevel,this.loadedmetadata=!1}t>0&&-1===e&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=nE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=tE}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case hE:{const{levels:e,level:t}=this,n=null==e?void 0:e[t],i=null==n?void 0:n.details;if(i&&(!i.live||this.levelLastLoaded===n)){if(this.waitForCdnTuneIn(i))break;this.state=nE;break}if(this.hls.nextLoadLevel!==this.level){this.state=nE;break}break}case rE:{var e;const t=self.performance.now(),n=this.retryDate;if(!n||t>=n||null!=(e=this.media)&&e.seeking){const{levels:e,level:t}=this,n=null==e?void 0:e[t];this.resetStartWhenNotLoaded(n||null),this.state=nE}}}this.state===nE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:n,media:i}=this;if(null===t||!i&&(this.startFragRequested||!e.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const a=e.nextLoadLevel;if(null==n||!n[a])return;const r=n[a],o=this.getMainFwdBufferInfo();if(null===o)return;const s=this.getLevelDetails();if(s&&this._streamEnded(o,s)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(rk.BUFFER_EOS,e),void(this.state=lE)}e.loadLevel!==a&&-1===e.manualLevel&&this.log(`Adapting to level ${a} from level ${this.level}`),this.level=e.nextLoadLevel=a;const d=r.details;if(!d||this.state===hE||d.live&&this.levelLastLoaded!==r)return this.level=a,void(this.state=hE);const l=o.len,u=this.getMaxBufferLength(r.maxBitrate);if(l>=u)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const c=this.backtrackFragment?this.backtrackFragment.start:o.end;let h=this.getNextFragment(c,d);if(this.couldBacktrack&&!this.fragPrevious&&h&&"initSegment"!==h.sn&&this.fragmentTracker.getState(h)!==_T){var m;const e=(null!=(m=this.backtrackFragment)?m:h).sn-d.startSN,t=d.fragments[e-1];t&&h.cc===t.cc&&(h=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(h&&this.isLoopLoading(h,c)){if(!h.gap){const e=this.audioOnly&&!this.altAudio?bk:wk,t=(e===wk?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,vM)}h=this.getNextFragmentLoopLoading(h,d,o,vM,u)}h&&(!h.initSegment||h.initSegment.data||this.bitrateTest||(h=h.initSegment),this.loadFragment(h,r,c))}loadFragment(e,t,n){const i=this.fragmentTracker.getState(e);this.fragCurrent=e,i===LT||i===IT?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,n)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,vM)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let n;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const a=this.getLevelDetails();if(null!=a&&a.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*a.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;n=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else n=0;const r=this.getBufferedFrag(t.currentTime+n);if(r){const e=this.followingBufferedFrag(r);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,n=e.duration,i=Math.max(r.end,t+Math.min(Math.max(n-this.config.maxFragLookUpTolerance,n*(this.couldBacktrack?.5:.125)),n*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case iE:case aE:case rE:case sE:case dE:this.state=nE}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const n=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),n.addEventListener("playing",this.onvplaying),n.addEventListener("seeked",this.onvseeked),this.gapController=new Lx(this.config,n,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;nk(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const n=this.getMainFwdBufferInfo();null!==n&&0!==n.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${n?n.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(rk.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let n=!1,i=!1;t.levels.forEach((e=>{const t=e.audioCodec;t&&(n=n||-1!==t.indexOf("mp4a.40.2"),i=i||-1!==t.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&i&&!function(){var e;const t=xx();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.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}onLevelLoading(e,t){const{levels:n}=this;if(!n||this.state!==nE)return;const i=n[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=hE)}onLevelLoaded(e,t){var n;const{levels:i}=this,a=t.level,r=t.details,o=r.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${a}`);this.log(`Level ${a} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""}, cc [${r.startCC}, ${r.endCC}] duration:${o}`);const s=i[a],d=this.fragCurrent;!d||this.state!==aE&&this.state!==rE||d.level!==t.level&&d.loader&&this.abortCurrentFrag();let l=0;if(r.live||null!=(n=s.details)&&n.live){var u;if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;l=this.alignPlaylists(r,s.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(s.details=r,this.levelLastLoaded=s,this.hls.trigger(rk.LEVEL_UPDATED,{details:r,level:a}),this.state===hE){if(this.waitForCdnTuneIn(r))return;this.state=nE}this.startFragRequested?r.live&&this.synchronizeToLiveEdge(r):this.setStartPosition(r,l),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:n,part:i,payload:a}=e,{levels:r}=this;if(!r)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${n.sn} of level ${n.level} will not be buffered`);const o=r[n.level],s=o.details;if(!s)return this.warn(`Dropping fragment ${n.sn} of level ${n.level} after level details were reset`),void this.fragmentTracker.removeFragment(n);const d=o.videoCodec,l=s.PTSKnown||!s.live,u=null==(t=n.initSegment)?void 0:t.data,c=this._getAudioCodec(o),h=this.transmuxer=this.transmuxer||new kP(this.hls,vM,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=i?i.index:-1,f=-1!==m,g=new jT(n.level,n.sn,n.stats.chunkCount,a.byteLength,m,f),p=this.initPTS[n.cc];h.push(a,u,c,d,n,i,s.totalduration,l,g,p)}onAudioTrackSwitching(e,t){const n=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const e=this.hls;n&&(e.trigger(rk.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(rk.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const n=t.id,i=!!this.hls.audioTracks[n].url;if(i){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=i,this.tick()}onBufferCreated(e,t){const n=t.tracks;let i,a,r=!1;for(const e in n){const t=n[e];if("main"===t.id){if(a=e,i=t,"video"===e){const t=n[e];t&&(this.videoBuffer=t.buffer)}}else r=!0}r&&i?(this.log(`Alternate track found, use ${a}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:n,part:i}=t;if(n&&n.type!==vM)return;if(this.fragContextChanged(n))return this.warn(`Fragment ${n.sn}${i?" p: "+i.index:""} of level ${n.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===dE&&(this.state=nE));const a=i?i.stats:n.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),"initSegment"!==n.sn&&(this.fragPrevious=n),this.fragBufferedComplete(n,i)}onError(e,t){var n;if(t.fatal)this.state=uE;else switch(t.details){case sk.FRAG_GAP:case sk.FRAG_PARSING_ERROR:case sk.FRAG_DECRYPT_ERROR:case sk.FRAG_LOAD_ERROR:case sk.FRAG_LOAD_TIMEOUT:case sk.KEY_LOAD_ERROR:case sk.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(vM,t);break;case sk.LEVEL_LOAD_ERROR:case sk.LEVEL_LOAD_TIMEOUT:case sk.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==hE||(null==(n=t.context)?void 0:n.type)!==fM||(this.state=nE);break;case sk.BUFFER_APPEND_ERROR:case sk.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;if(t.details===sk.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case sk.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!FT.getBuffered(e).length){const e=this.state!==nE?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=nE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==bk||this.audioOnly&&!this.altAudio){const e=(t===wk?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,vM),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let n=this.startPosition;if(n>=0&&t<n){if(e.seeking)return void this.log(`could not seek to ${n}, already seeking at ${t}`);const i=FT.getBuffered(e),a=(i.length?i.start(0):0)-n;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),n+=a,this.startPosition=n),this.log(`seek to target start position ${n} from current time ${t}`),e.currentTime=n}}_getAudioCodec(e){let 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}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then((n=>{const{hls:i}=this;if(!n||this.fragContextChanged(e))return;t.fragmentError=0,this.state=nE,this.startFragRequested=!1,this.bitrateTest=!1;const a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),i.trigger(rk.FRAG_LOADED,n),e.bitrateTest=!1}))}_handleTransmuxComplete(e){var t;const n="main",{hls:i}=this,{remuxResult:a,chunkMeta:r}=e,o=this.getCurrentContext(r);if(!o)return void this.resetWhenMissingContext(r);const{frag:s,part:d,level:l}=o,{video:u,text:c,id3:h,initSegment:m}=a,{details:f}=l,g=this.altAudio?void 0:a.audio;if(this.fragContextChanged(s))this.fragmentTracker.removeFragment(s);else{if(this.state=sE,m){if(null!=m&&m.tracks){const e=s.initSegment||s;this._bufferInitSegment(l,m.tracks,e,r),i.trigger(rk.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:n,tracks:m.tracks})}const e=m.initPTS,t=m.timescale;nk(e)&&(this.initPTS[s.cc]={baseTime:e,timescale:t},i.trigger(rk.INIT_PTS_FOUND,{frag:s,id:n,initPTS:e,timescale:t}))}if(u&&f&&"initSegment"!==s.sn){const e=f.fragments[s.sn-1-f.startSN],t=s.sn===f.startSN,n=!e||s.cc>e.cc;if(!1!==a.independent){const{startPTS:e,endPTS:i,startDTS:a,endDTS:o}=u;if(d)d.elementaryStreams[u.type]={startPTS:e,endPTS:i,startDTS:a,endDTS:o};else if(u.firstKeyFrame&&u.independent&&1===r.id&&!n&&(this.couldBacktrack=!0),u.dropped&&u.independent){const a=this.getMainFwdBufferInfo(),r=(a?a.end:this.getLoadPosition())+this.config.maxBufferHole,d=u.firstKeyFramePTS?u.firstKeyFramePTS:e;if(!t&&r<d-this.config.maxBufferHole&&!n)return void this.backtrack(s);n&&(s.gap=!0),s.setElementaryStreamInfo(u.type,s.start,i,s.start,o,!0)}else t&&e>2&&(s.gap=!0);s.setElementaryStreamInfo(u.type,e,i,a,o),this.backtrackFragment&&(this.backtrackFragment=s),this.bufferFragmentData(u,s,d,r,t||n)}else{if(!t&&!n)return void this.backtrack(s);s.gap=!0}}if(g){const{startPTS:e,endPTS:t,startDTS:n,endDTS:i}=g;d&&(d.elementaryStreams[bk]={startPTS:e,endPTS:t,startDTS:n,endDTS:i}),s.setElementaryStreamInfo(bk,e,t,n,i),this.bufferFragmentData(g,s,d,r)}if(f&&null!=h&&null!=(t=h.samples)&&t.length){const e={id:n,frag:s,details:f,samples:h.samples};i.trigger(rk.FRAG_PARSING_METADATA,e)}if(f&&c){const e={id:n,frag:s,details:f,samples:c.samples};i.trigger(rk.FRAG_PARSING_USERDATA,e)}}}_bufferInitSegment(e,t,n,i){if(this.state!==sE)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:a,video:r,audiovideo:o}=t;if(a){let t=e.audioCodec;const n=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){t&&(t=-1!==t.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const e=a.metadata;e&&"channelCount"in e&&1!==(e.channelCount||1)&&-1===n.indexOf("firefox")&&(t="mp4a.40.5")}t&&-1!==t.indexOf("mp4a.40.5")&&-1!==n.indexOf("android")&&"audio/mpeg"!==a.container&&(t="mp4a.40.2",this.log(`Android: force audio codec to ${t}`)),e.audioCodec&&e.audioCodec!==t&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${t}"`),a.levelCodec=t,a.id="main",this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${t||""}/${e.audioCodec||""}/${a.codec}]`)}r&&(r.levelCodec=e.videoCodec,r.id="main",this.log(`Init video buffer, container:${r.container}, codecs[level/parsed]=[${e.videoCodec||""}/${r.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(rk.BUFFER_CODECS,t),Object.keys(t).forEach((e=>{const a=t[e].initSegment;null!=a&&a.byteLength&&this.hls.trigger(rk.BUFFER_APPENDING,{type:e,data:a,frag:n,part:null,chunkMeta:i,parent:n.type})})),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,vM)}backtrack(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=nE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const n=e.currentTime;if(FT.isBuffered(e,n)?t=this.getAppendedFrag(n):FT.isBuffered(e,n+.1)&&(t=this.getAppendedFrag(n+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,n=t.level;e&&t.sn===e.sn&&e.level===n||(this.fragPlaying=t,this.hls.trigger(rk.FRAG_CHANGED,{frag:t}),e&&e.level===n||this.hls.trigger(rk.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,n=this.currentFrag;if(n&&nk(t)&&nk(n.programDateTime)){const e=n.programDateTime+1e3*(t-n.start);return new Date(e)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Ix{static get version(){return"1.5.15"}static isMSESupported(){return Cx()}static isSupported(){return function(){if(!Cx())return!1;const e=US();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(YS(t,"video"))))||["mp4a.40.2","fLaC"].some((t=>e.isTypeSupported(YS(t,"audio")))))}()}static getMediaSource(){return US()}static get Events(){return rk}static get ErrorTypes(){return ok}static get ErrorDetails(){return sk}static get DefaultConfig(){return Ix.defaultConfig?Ix.defaultConfig:kx}static set DefaultConfig(e){Ix.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new wP,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,function(e,t){if("object"==typeof console&&!0===e||"object"==typeof e){ck(e,"debug","log","info","warn","error");try{uk.log(`Debug logs enabled for "${t}" in hls.js version 1.5.15`)}catch(e){uk=lk}}else uk=lk}(e.debug||!1,"Hls instance");const t=this.config=function(e,t){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"');const n=Sx(e),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((e=>{const a=`${"level"===e?"playlist":e}LoadPolicy`,r=void 0===t[a],o=[];i.forEach((i=>{const s=`${e}Loading${i}`,d=t[s];if(void 0!==d&&r){o.push(s);const e=n[a].default;switch(t[a]={default:e},i){case"TimeOut":e.maxLoadTimeMs=d,e.maxTimeToFirstByteMs=d;break;case"MaxRetry":e.errorRetry.maxNumRetry=d,e.timeoutRetry.maxNumRetry=d;break;case"RetryDelay":e.errorRetry.retryDelayMs=d,e.timeoutRetry.retryDelayMs=d;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=d,e.timeoutRetry.maxRetryDelayMs=d}}})),o.length&&hk.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(t[a])}`)})),Qw(Qw({},n),t)}(Ix.DefaultConfig,e);this.userConfig=e,t.progressive&&Mx(t);const{abrController:n,bufferController:i,capLevelController:a,errorController:r,fpsController:o}=t,s=new r(this),d=this.abrController=new n(this),l=this.bufferController=new i(this),u=this.capLevelController=new a(this),c=new o(this),h=new SM(this),m=new WM(this),f=t.contentSteeringController,g=f?new f(this):null,p=this.levelController=new Ex(this,g),v=new RT(this),y=new Ax(this.config),b=this.streamController=new Dx(this,v,y);u.setStreamController(b),c.setStreamController(b);const w=[h,p,b];g&&w.splice(1,0,g),this.networkControllers=w;const k=[d,l,u,c,m,v];this.audioTrackController=this.createController(t.audioTrackController,w);const S=t.audioStreamController;S&&w.push(new S(this,v,y)),this.subtitleTrackController=this.createController(t.subtitleTrackController,w);const M=t.subtitleStreamController;M&&w.push(new M(this,v,y)),this.createController(t.timelineController,k),y.emeController=this.emeController=this.createController(t.emeController,k),this.cmcdController=this.createController(t.cmcdController,k),this.latencyController=this.createController(NM,k),this.coreComponents=k,w.push(s);const T=s.onErrorOut;"function"==typeof T&&this.on(rk.ERROR,T,s)}createController(e,t){if(e){const n=new e(this);return t&&t.push(n),n}return null}on(e,t,n=this){this._emitter.on(e,t,n)}once(e,t,n=this){this._emitter.once(e,t,n)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,n=this,i){this._emitter.off(e,t,n,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,n){return this._emitter.emit(e,t,n)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){if(hk.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),!this.triggeringException){this.triggeringException=!0;const n=e===rk.ERROR;this.trigger(rk.ERROR,{type:ok.OTHER_ERROR,details:sk.INTERNAL_EXCEPTION,fatal:n,event:e,error:t}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){hk.log("destroy"),this.trigger(rk.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;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){hk.log("attachMedia"),this._media=e,this.trigger(rk.MEDIA_ATTACHING,{media:e})}detachMedia(){hk.log("detachMedia"),this.trigger(rk.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,n=this.url,i=this.url=qw.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,hk.log(`loadSource:${i}`),t&&n&&(n!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(rk.MANIFEST_LOADING,{url:e})}startLoad(e=-1){hk.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach((t=>{t.startLoad(e)}))}stopLoad(){hk.log("stopLoad"),this.started=!1,this.networkControllers.forEach((e=>{e.stopLoad()}))}resumeBuffering(){this.started&&this.networkControllers.forEach((e=>{"fragmentLoader"in e&&e.startLoad(-1)}))}pauseBuffering(){this.networkControllers.forEach((e=>{"fragmentLoader"in e&&e.stopLoad()}))}swapAudioCodec(){hk.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){hk.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){hk.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){hk.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){hk.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){hk.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return-1===e&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){hk.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(hk.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){(function(e){return OM.indexOf(e)>-1})(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const n=e.length;for(let i=0;i<n;i++)if(e[i].maxBitrate>=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:n}=this;let i;if(i=-1===t&&null!=e&&e.length?e.length-1:t,n)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=n)return t}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return null==(t=this.audioTrackController)?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return null==(t=this.subtitleTrackController)||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Ix.defaultConfig=void 0;let _x=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1,this.bgVideo=!1}styles(){const{url:t,imageCropping:n,alignment:i,rightMargin:a,spacing:r}=this.component,o="fit"===n,s=this.getRootNode().host.tagName.toLowerCase();this.bgVideo=s.includes("background");const d=o?"":e.unsafeCSS(` position: ${this.bgVideo?"fixed":"relative"};\n right: 0;\n top: 0;\n min-width: 100%;\n `);return e.unsafeCSS(`\n :host {\n box-sizing: border-box;\n display: flex;\n transition: all 0.3s;\n background-image: url(${t});\n background-size: ${o?"contain":"cover"};\n background-position: ${i||""} center;\n background-repeat: no-repeat;\n ${zs(this.component,this.scaleFactor)};\n margin-right: ${a||r||0}px;\n ${Gs(this.component,this.scaleFactor)}\n ${this.component.hidden?"display:none":""}\n ${d}\n }\n\n #nami-video {\n ${zs(this.component,this.scaleFactor)};\n object-fit: ${o?"contain":"cover"};\n }\n `)}loadMediaSrc(e){const{url:t}=this.component;if(t&&!t.includes(ke)&&e.src!==t)if(!t.includes("m3u8")||e.canPlayType("application/vnd.apple.mpegurl"))e.src=t;else if(Ix.isSupported()){const n=new Ix;n.loadSource(t),n.attachMedia(e)}}updated(){Object.keys(this.component).forEach((e=>{this.component[e]=ed(this.component[e])}));const{id:e,title:t,autoplayVideo:n,mute:i,loopVideo:a,controlsType:r,fallbackImage:o}=this.component,s=this.shadowRoot?.getElementById("nami-video");s&&(s.autoplay=n??!1,s.loop=a??!1,s.muted=!!n||(i??!1),s.controls="none"!==r,s.poster=o??"",s.playsInline=n??this.bgVideo,this.loadMediaSrc(s),Rd.instance=new Rd(s,t,e))}render(){const{focusedBorderColor:t,focusedFillColor:n,fillColor:i}=this.component;return!t&&od(i,n)||(this.tabIndex=0),e.html`<video id="nami-video" preload="auto"></video>`}};o([fs({type:Object})],_x.prototype,"component",void 0),o([fs({type:Boolean})],_x.prototype,"inFocusedState",void 0),o([fs({type:Number})],_x.prototype,"scaleFactor",void 0),_x=o([Uo("nami-video")],_x);let Rx=class extends gs{constructor(){super(),this.inFocusedState=!1,this.height=0,this.scaleFactor=1,this._handleClick=()=>{Do.setOpenHeaderIds(this.component.id||"",this.component.sku),this.height=this.shadowRoot?.getElementById("collapse")?.scrollHeight||0,this.shadowRoot?.getElementById("collapse")?.classList.toggle("hidden")},this.addEventListener("click",this._handleClick,!1)}styles(){const{component:t,inFocusedState:n,height:i,scaleFactor:a}=this,{direction:r,hidden:o}=this.component,s="vertical"===r?"margin-top":"margin-left",d=e.unsafeCSS(Is(t,n));return e.unsafeCSS(`\n :host {\n display: ${o?"none":"flex"};\n ${d};\n ${_s(this.component)}\n ${Gs(t,a,n)}\n ${Rs(t)} \n cursor: pointer;\n }\n :host > :not(:first-child) {\n ${s}: ${t.spacing||0}px;\n }\n #collapse.hidden{\n max-height: 0;\n opacity: 0;\n }\n #collapse {\n ${zs(t,a)}\n max-height: ${i}px;\n opacity: 1;\n transition: all linear 0.5s;\n }\n `)}render(){const{components:t,collapseHeader:n,open:i,id:a,focusedBorderColor:r,focusedFillColor:o,fillColor:s}=this.component;!r&&od(s,o)||(this.tabIndex=0);const d=t.map((e=>sd(e,this.scaleFactor,this.inFocusedState)));return e.html`${sd(n,this.scaleFactor,this.inFocusedState)}
|
|
61
|
-
<div id="collapse" class="${i===a?"hidden":""}">${d}</div>`}};o([fs({type:Object})],Rx.prototype,"component",void 0),o([fs({type:Boolean})],Rx.prototype,"inFocusedState",void 0),o([fs({type:Number})],Rx.prototype,"height",void 0),o([fs({type:Number})],Rx.prototype,"scaleFactor",void 0),Rx=o([Uo("nami-collapse-container")],Rx);let Wx=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1,this.mouseDown=!1,this.startDragging=e=>{e.preventDefault(),this.mouseDown=!0,this.startX=e.pageX-this.offsetLeft},this.stopDragging=()=>{this.mouseDown=!1},this.move=e=>{e.preventDefault(),this.mouseDown&&(this.scrollLeft=this.scrollLeft-(e.pageX-this.offsetLeft-this.startX))}}connectedCallback(){super.connectedCallback(),this.addEventListener("mousemove",this.move,!1),this.addEventListener("mousedown",this.startDragging,!1),this.addEventListener("mouseup",this.stopDragging,!1),this.addEventListener("mouseleave",this.stopDragging,!1)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousemove",this.move,!1),this.removeEventListener("mousedown",this.startDragging,!1),this.removeEventListener("mouseup",this.stopDragging,!1),this.removeEventListener("mouseleave",this.stopDragging,!1)}styles(){const t="vertical"===this.component.direction,n=t?"margin-top":"margin-left",i=e.unsafeCSS(Is(this.component,this.inFocusedState));return e.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-gap: ${this.component.spacing}px;\n grid-auto-flow: ${t?"row":"column"};\n overflow: auto;\n place-items: center;\n ${i}\n ${function(e,t,n=1){return`\n transition: all 0.3s;\n ${Ws(e)}\n ${Ns(e,n)}\n ${Os(e)}\n ${Fs(e,n,t)}\n ${zs(e,n)}\n ${$s(e)}\n ${Hs(e)}\n `}(this.component,this.inFocusedState)}\n width: auto !important;\n align-self: baseline;\n cursor: grab;\n }\n :host > :not(:first-child) {\n ${n}: ${this.component.spacing||0}px;\n }\n `)}render(){const{focusedBorderColor:e,focusedFillColor:t,fillColor:n}=this.component;!e&&od(n,t)||(this.tabIndex=0);const i=function(e){if(!e.loopSource)return[];const t=JSON.parse(e.loopSource)?.map((t=>(e.loopSourceConditions?.every((e=>td(e,t))),Js(e.components,Js({block:t},{block:t})))))??[];return t.filter((e=>null!=e))}(this.component);return i.map((e=>e.map((e=>sd(e,this.scaleFactor,this.inFocusedState)))))}};function Nx(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Ox(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach((n=>{void 0===e[n]?e[n]=t[n]:Nx(t[n])&&Nx(e[n])&&Object.keys(t[n]).length>0&&Ox(e[n],t[n])}))}o([fs({type:Object})],Wx.prototype,"component",void 0),o([fs({type:Boolean})],Wx.prototype,"inFocusedState",void 0),o([fs({type:Number})],Wx.prototype,"scaleFactor",void 0),Wx=o([Uo("nami-responsive-grid")],Wx);const Fx={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 jx(){const e="undefined"!=typeof document?document:{};return Ox(e,Fx),e}const zx={document:Fx,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 $x(){const e="undefined"!=typeof window?window:{};return Ox(e,zx),e}function Hx(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Ux(){return Date.now()}function Bx(e,t){void 0===t&&(t="x");const n=$x();let i,a,r;const o=function(e){const t=$x();let n;return t.getComputedStyle&&(n=t.getComputedStyle(e,null)),!n&&e.currentStyle&&(n=e.currentStyle),n||(n=e.style),n}(e);return n.WebKitCSSMatrix?(a=o.transform||o.webkitTransform,a.split(",").length>6&&(a=a.split(", ").map((e=>e.replace(",","."))).join(", ")),r=new n.WebKitCSSMatrix("none"===a?"":a)):(r=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=r.toString().split(",")),"x"===t&&(a=n.WebKitCSSMatrix?r.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(a=n.WebKitCSSMatrix?r.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),a||0}function Gx(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Xx(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let i=1;i<arguments.length;i+=1){const a=i<0||arguments.length<=i?void 0:arguments[i];if(null!=a&&(n=a,!("undefined"!=typeof window&&void 0!==window.HTMLElement?n instanceof HTMLElement:n&&(1===n.nodeType||11===n.nodeType)))){const n=Object.keys(Object(a)).filter((e=>t.indexOf(e)<0));for(let t=0,i=n.length;t<i;t+=1){const i=n[t],r=Object.getOwnPropertyDescriptor(a,i);void 0!==r&&r.enumerable&&(Gx(e[i])&&Gx(a[i])?a[i].__swiper__?e[i]=a[i]:Xx(e[i],a[i]):!Gx(e[i])&&Gx(a[i])?(e[i]={},a[i].__swiper__?e[i]=a[i]:Xx(e[i],a[i])):e[i]=a[i])}}}var n;return e}function Yx(e,t,n){e.style.setProperty(t,n)}function Vx(e){let{swiper:t,targetPosition:n,side:i}=e;const a=$x(),r=-t.translate;let o,s=null;const d=t.params.speed;t.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(t.cssModeFrameID);const l=n>r?"next":"prev",u=(e,t)=>"next"===l&&e>=t||"prev"===l&&e<=t,c=()=>{o=(new Date).getTime(),null===s&&(s=o);const e=Math.max(Math.min((o-s)/d,1),0),l=.5-Math.cos(e*Math.PI)/2;let h=r+l*(n-r);if(u(h,n)&&(h=n),t.wrapperEl.scrollTo({[i]:h}),u(h,n))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout((()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})})),void a.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=a.requestAnimationFrame(c)};c()}function Kx(e,t){void 0===t&&(t="");const n=[...e.children];return e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter((e=>e.matches(t))):n}function qx(e){try{return void console.warn(e)}catch(e){}}function Jx(e,t){void 0===t&&(t=[]);const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter((e=>!!e.trim()))}(t)),n}function Qx(e,t){return $x().getComputedStyle(e,null).getPropertyValue(t)}function Zx(e){let t,n=e;if(n){for(t=0;null!==(n=n.previousSibling);)1===n.nodeType&&(t+=1);return t}}function eC(e,t){const n=[];let i=e.parentElement;for(;i;)t?i.matches(t)&&n.push(i):n.push(i),i=i.parentElement;return n}function tC(e,t,n){const i=$x();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function nC(e){return(Array.isArray(e)?e:[e]).filter((e=>!!e))}let iC,aC,rC;function oC(){return iC||(iC=function(){const e=$x(),t=jx();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),iC}function sC(e){return void 0===e&&(e={}),aC||(aC=function(e){let{userAgent:t}=void 0===e?{}:e;const n=oC(),i=$x(),a=i.navigator.platform,r=t||i.navigator.userAgent,o={ios:!1,android:!1},s=i.screen.width,d=i.screen.height,l=r.match(/(Android);?[\s\/]+([\d.]+)?/);let u=r.match(/(iPad).*OS\s([\d_]+)/);const c=r.match(/(iPod)(.*OS\s([\d_]+))?/),h=!u&&r.match(/(iPhone\sOS|iOS)\s([\d_]+)/),m="Win32"===a;let f="MacIntel"===a;return!u&&f&&n.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${s}x${d}`)>=0&&(u=r.match(/(Version)\/([\d.]+)/),u||(u=[0,1,"13_0_0"]),f=!1),l&&!m&&(o.os="android",o.android=!0),(u||h||c)&&(o.os="ios",o.ios=!0),o}(e)),aC}function dC(){return rC||(rC=function(){const e=$x(),t=sC();let n=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map((e=>Number(e)));n=e<16||16===e&&i<2}}const a=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),r=i();return{isSafari:n||r,needPerspectiveFix:n,need3dFix:r||a&&t.ios,isWebView:a}}()),rC}var lC={on(e,t,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const a=n?"unshift":"push";return e.split(" ").forEach((e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][a](t)})),i},once(e,t,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function a(){i.off(e,a),a.__emitterProxy&&delete a.__emitterProxy;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];t.apply(i,r)}return a.__emitterProxy=t,i.on(e,a,n)},onAny(e,t){const n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof e)return n;const i=t?"unshift":"push";return n.eventsAnyListeners.indexOf(e)<0&&n.eventsAnyListeners[i](e),n},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const n=t.eventsAnyListeners.indexOf(e);return n>=0&&t.eventsAnyListeners.splice(n,1),t},off(e,t){const n=this;return!n.eventsListeners||n.destroyed?n:n.eventsListeners?(e.split(" ").forEach((e=>{void 0===t?n.eventsListeners[e]=[]:n.eventsListeners[e]&&n.eventsListeners[e].forEach(((i,a)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&n.eventsListeners[e].splice(a,1)}))})),n):n},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,n,i;for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];"string"==typeof r[0]||Array.isArray(r[0])?(t=r[0],n=r.slice(1,r.length),i=e):(t=r[0].events,n=r[0].data,i=r[0].context||e),n.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach((t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach((e=>{e.apply(i,[t,...n])})),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach((e=>{e.apply(i,n)}))})),e}};const uC=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};const cC=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};const hC=(e,t)=>{if(!e||e.destroyed||!e.params)return;const n=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(n){let t=n.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(n.shadowRoot?t=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame((()=>{n.shadowRoot&&(t=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())}))),t&&t.remove()}},mC=(e,t)=>{if(!e.slides[t])return;const n=e.slides[t].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},fC=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const n=e.slides.length;if(!n||!t||t<0)return;t=Math.min(t,n);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const n=a,r=[n-t];return r.push(...Array.from({length:t}).map(((e,t)=>n+i+t))),void e.slides.forEach(((t,n)=>{r.includes(t.column)&&mC(e,n)}))}const r=a+i-1;if(e.params.rewind||e.params.loop)for(let i=a-t;i<=r+t;i+=1){const t=(i%n+n)%n;(t<a||t>r)&&mC(e,t)}else for(let i=Math.max(a-t,0);i<=Math.min(r+t,n-1);i+=1)i!==a&&(i>r||i<a)&&mC(e,i)};var gC={updateSize:function(){const e=this;let t,n;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,n=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===n&&e.isVertical()||(t=t-parseInt(Qx(i,"padding-left")||0,10)-parseInt(Qx(i,"padding-right")||0,10),n=n-parseInt(Qx(i,"padding-top")||0,10)-parseInt(Qx(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(n)&&(n=0),Object.assign(e,{width:t,height:n,size:e.isHorizontal()?t:n}))},updateSlides:function(){const e=this;function t(t,n){return parseFloat(t.getPropertyValue(e.getDirectionLabel(n))||0)}const n=e.params,{wrapperEl:i,slidesEl:a,size:r,rtlTranslate:o,wrongRTL:s}=e,d=e.virtual&&n.virtual.enabled,l=d?e.virtual.slides.length:e.slides.length,u=Kx(a,`.${e.params.slideClass}, swiper-slide`),c=d?e.virtual.slides.length:u.length;let h=[];const m=[],f=[];let g=n.slidesOffsetBefore;"function"==typeof g&&(g=n.slidesOffsetBefore.call(e));let p=n.slidesOffsetAfter;"function"==typeof p&&(p=n.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=n.spaceBetween,w=-g,k=0,S=0;if(void 0===r)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*r:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,u.forEach((e=>{o?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""})),n.centeredSlides&&n.cssMode&&(Yx(i,"--swiper-centered-offset-before",""),Yx(i,"--swiper-centered-offset-after",""));const M=n.grid&&n.grid.rows>1&&e.grid;let T;M?e.grid.initSlides(u):e.grid&&e.grid.unsetSlides();const E="auto"===n.slidesPerView&&n.breakpoints&&Object.keys(n.breakpoints).filter((e=>void 0!==n.breakpoints[e].slidesPerView)).length>0;for(let i=0;i<c;i+=1){let a;if(T=0,u[i]&&(a=u[i]),M&&e.grid.updateSlide(i,a,u),!u[i]||"none"!==Qx(a,"display")){if("auto"===n.slidesPerView){E&&(u[i].style[e.getDirectionLabel("width")]="");const r=getComputedStyle(a),o=a.style.transform,s=a.style.webkitTransform;if(o&&(a.style.transform="none"),s&&(a.style.webkitTransform="none"),n.roundLengths)T=e.isHorizontal()?tC(a,"width"):tC(a,"height");else{const e=t(r,"width"),n=t(r,"padding-left"),i=t(r,"padding-right"),o=t(r,"margin-left"),s=t(r,"margin-right"),d=r.getPropertyValue("box-sizing");if(d&&"border-box"===d)T=e+o+s;else{const{clientWidth:t,offsetWidth:r}=a;T=e+n+i+o+s+(r-t)}}o&&(a.style.transform=o),s&&(a.style.webkitTransform=s),n.roundLengths&&(T=Math.floor(T))}else T=(r-(n.slidesPerView-1)*b)/n.slidesPerView,n.roundLengths&&(T=Math.floor(T)),u[i]&&(u[i].style[e.getDirectionLabel("width")]=`${T}px`);u[i]&&(u[i].swiperSlideSize=T),f.push(T),n.centeredSlides?(w=w+T/2+k/2+b,0===k&&0!==i&&(w=w-r/2-b),0===i&&(w=w-r/2-b),Math.abs(w)<.001&&(w=0),n.roundLengths&&(w=Math.floor(w)),S%n.slidesPerGroup==0&&h.push(w),m.push(w)):(n.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup==0&&h.push(w),m.push(w),w=w+T+b),e.virtualSize+=T+b,k=T,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,r)+p,o&&s&&("slide"===n.effect||"coverflow"===n.effect)&&(i.style.width=`${e.virtualSize+b}px`),n.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),M&&e.grid.updateWrapperSize(T,h),!n.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let a=h[i];n.roundLengths&&(a=Math.floor(a)),h[i]<=e.virtualSize-r&&t.push(a)}h=t,Math.floor(e.virtualSize-r)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-r)}if(d&&n.loop){const t=f[0]+b;if(n.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/n.slidesPerGroup),a=t*n.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+a)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===n.slidesPerGroup&&h.push(h[h.length-1]+t),m.push(m[m.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&o?"marginLeft":e.getDirectionLabel("marginRight");u.filter(((e,t)=>!(n.cssMode&&!n.loop)||t!==u.length-1)).forEach((e=>{e.style[t]=`${b}px`}))}if(n.centeredSlides&&n.centeredSlidesBounds){let e=0;f.forEach((t=>{e+=t+(b||0)})),e-=b;const t=e>r?e-r:0;h=h.map((e=>e<=0?-g:e>t?t+p:e))}if(n.centerInsufficientSlides){let e=0;f.forEach((t=>{e+=t+(b||0)})),e-=b;const t=(n.slidesOffsetBefore||0)+(n.slidesOffsetAfter||0);if(e+t<r){const n=(r-e-t)/2;h.forEach(((e,t)=>{h[t]=e-n})),m.forEach(((e,t)=>{m[t]=e+n}))}}if(Object.assign(e,{slides:u,snapGrid:h,slidesGrid:m,slidesSizesGrid:f}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){Yx(i,"--swiper-centered-offset-before",-h[0]+"px"),Yx(i,"--swiper-centered-offset-after",e.size/2-f[f.length-1]/2+"px");const t=-e.snapGrid[0],n=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map((e=>e+t)),e.slidesGrid=e.slidesGrid.map((e=>e+n))}if(c!==l&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),m.length!==y&&e.emit("slidesGridLengthChange"),n.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(d||n.cssMode||"slide"!==n.effect&&"fade"!==n.effect)){const t=`${n.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);c<=n.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,n=[],i=t.virtual&&t.params.virtual.enabled;let a,r=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const o=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach((e=>{n.push(e)}));else for(a=0;a<Math.ceil(t.params.slidesPerView);a+=1){const e=t.activeIndex+a;if(e>t.slides.length&&!i)break;n.push(o(e))}else n.push(o(t.activeIndex));for(a=0;a<n.length;a+=1)if(void 0!==n[a]){const e=n[a].offsetHeight;r=e>r?e:r}(r||0===r)&&(t.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,n=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-n-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,n=t.params,{slides:i,rtlTranslate:a,snapGrid:r}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let s=n.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(let e=0;e<i.length;e+=1){const d=i[e];let l=d.swiperSlideOffset;n.cssMode&&n.centeredSlides&&(l-=i[0].swiperSlideOffset);const u=(o+(n.centeredSlides?t.minTranslate():0)-l)/(d.swiperSlideSize+s),c=(o-r[0]+(n.centeredSlides?t.minTranslate():0)-l)/(d.swiperSlideSize+s),h=-(o-l),m=h+t.slidesSizesGrid[e],f=h>=0&&h<=t.size-t.slidesSizesGrid[e],g=h>=0&&h<t.size-1||m>1&&m<=t.size||h<=0&&m>=t.size;g&&(t.visibleSlides.push(d),t.visibleSlidesIndexes.push(e)),uC(d,g,n.slideVisibleClass),uC(d,f,n.slideFullyVisibleClass),d.progress=a?-u:u,d.originalProgress=a?-c:c}},updateProgress:function(e){const t=this;if(void 0===e){const n=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*n||0}const n=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:a,isBeginning:r,isEnd:o,progressLoop:s}=t;const d=r,l=o;if(0===i)a=0,r=!0,o=!0;else{a=(e-t.minTranslate())/i;const n=Math.abs(e-t.minTranslate())<1,s=Math.abs(e-t.maxTranslate())<1;r=n||a<=0,o=s||a>=1,n&&(a=0),s&&(a=1)}if(n.loop){const n=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),a=t.slidesGrid[n],r=t.slidesGrid[i],o=t.slidesGrid[t.slidesGrid.length-1],d=Math.abs(e);s=d>=a?(d-a)/o:(d+o-r)/o,s>1&&(s-=1)}Object.assign(t,{progress:a,progressLoop:s,isBeginning:r,isEnd:o}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),r&&!d&&t.emit("reachBeginning toEdge"),o&&!l&&t.emit("reachEnd toEdge"),(d&&!r||l&&!o)&&t.emit("fromEdge"),t.emit("progress",a)},updateSlidesClasses:function(){const e=this,{slides:t,params:n,slidesEl:i,activeIndex:a}=e,r=e.virtual&&n.virtual.enabled,o=e.grid&&n.grid&&n.grid.rows>1,s=e=>Kx(i,`.${n.slideClass}${e}, swiper-slide${e}`)[0];let d,l,u;if(r)if(n.loop){let t=a-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),d=s(`[data-swiper-slide-index="${t}"]`)}else d=s(`[data-swiper-slide-index="${a}"]`);else o?(d=t.filter((e=>e.column===a))[0],u=t.filter((e=>e.column===a+1))[0],l=t.filter((e=>e.column===a-1))[0]):d=t[a];d&&(o||(u=function(e,t){const n=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&n.push(i):n.push(i),e=i}return n}(d,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!u&&(u=t[0]),l=function(e,t){const n=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&n.push(i):n.push(i),e=i}return n}(d,`.${n.slideClass}, swiper-slide`)[0],n.loop&&0===!l&&(l=t[t.length-1]))),t.forEach((e=>{cC(e,e===d,n.slideActiveClass),cC(e,e===u,n.slideNextClass),cC(e,e===l,n.slidePrevClass)})),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,n=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:a,activeIndex:r,realIndex:o,snapIndex:s}=t;let d,l=e;const u=e=>{let n=e-t.virtual.slidesBefore;return n<0&&(n=t.virtual.slides.length+n),n>=t.virtual.slides.length&&(n-=t.virtual.slides.length),n};if(void 0===l&&(l=function(e){const{slidesGrid:t,params:n}=e,i=e.rtlTranslate?e.translate:-e.translate;let a;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?a=e:i>=t[e]&&i<t[e+1]&&(a=e+1):i>=t[e]&&(a=e);return n.normalizeSlideIndex&&(a<0||void 0===a)&&(a=0),a}(t)),i.indexOf(n)>=0)d=i.indexOf(n);else{const e=Math.min(a.slidesPerGroupSkip,l);d=e+Math.floor((l-e)/a.slidesPerGroup)}if(d>=i.length&&(d=i.length-1),l===r&&!t.params.loop)return void(d!==s&&(t.snapIndex=d,t.emit("snapIndexChange")));if(l===r&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=u(l));const c=t.grid&&a.grid&&a.grid.rows>1;let h;if(t.virtual&&a.virtual.enabled&&a.loop)h=u(l);else if(c){const e=t.slides.filter((e=>e.column===l))[0];let n=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(n)&&(n=Math.max(t.slides.indexOf(e),0)),h=Math.floor(n/a.grid.rows)}else if(t.slides[l]){const e=t.slides[l].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):l}else h=l;Object.assign(t,{previousSnapIndex:s,snapIndex:d,previousRealIndex:o,realIndex:h,previousIndex:r,activeIndex:l}),t.initialized&&fC(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(o!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const n=this,i=n.params;let a=e.closest(`.${i.slideClass}, swiper-slide`);!a&&n.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach((e=>{!a&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(a=e)}));let r,o=!1;if(a)for(let e=0;e<n.slides.length;e+=1)if(n.slides[e]===a){o=!0,r=e;break}if(!a||!o)return n.clickedSlide=void 0,void(n.clickedIndex=void 0);n.clickedSlide=a,n.virtual&&n.params.virtual.enabled?n.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):n.clickedIndex=r,i.slideToClickedSlide&&void 0!==n.clickedIndex&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}};var pC={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:n,translate:i,wrapperEl:a}=this;if(t.virtualTranslate)return n?-i:i;if(t.cssMode)return i;let r=Bx(a,e);return r+=this.cssOverflowAdjustment(),n&&(r=-r),r||0},setTranslate:function(e,t){const n=this,{rtlTranslate:i,params:a,wrapperEl:r,progress:o}=n;let s,d=0,l=0;n.isHorizontal()?d=i?-e:e:l=e,a.roundLengths&&(d=Math.floor(d),l=Math.floor(l)),n.previousTranslate=n.translate,n.translate=n.isHorizontal()?d:l,a.cssMode?r[n.isHorizontal()?"scrollLeft":"scrollTop"]=n.isHorizontal()?-d:-l:a.virtualTranslate||(n.isHorizontal()?d-=n.cssOverflowAdjustment():l-=n.cssOverflowAdjustment(),r.style.transform=`translate3d(${d}px, ${l}px, 0px)`);const u=n.maxTranslate()-n.minTranslate();s=0===u?0:(e-n.minTranslate())/u,s!==o&&n.updateProgress(e),n.emit("setTranslate",n.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,n,i,a){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===n&&(n=!0),void 0===i&&(i=!0);const r=this,{params:o,wrapperEl:s}=r;if(r.animating&&o.preventInteractionOnTransition)return!1;const d=r.minTranslate(),l=r.maxTranslate();let u;if(u=i&&e>d?d:i&&e<l?l:e,r.updateProgress(u),o.cssMode){const e=r.isHorizontal();if(0===t)s[e?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return Vx({swiper:r,targetPosition:-u,side:e?"left":"top"}),!0;s.scrollTo({[e?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),n&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),n&&(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,n&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function vC(e){let{swiper:t,runCallbacks:n,direction:i,step:a}=e;const{activeIndex:r,previousIndex:o}=t;let s=i;if(s||(s=r>o?"next":r<o?"prev":"reset"),t.emit(`transition${a}`),n&&r!==o){if("reset"===s)return void t.emit(`slideResetTransition${a}`);t.emit(`slideChangeTransition${a}`),"next"===s?t.emit(`slideNextTransition${a}`):t.emit(`slidePrevTransition${a}`)}}var yC={slideTo:function(e,t,n,i,a){void 0===e&&(e=0),void 0===n&&(n=!0),"string"==typeof e&&(e=parseInt(e,10));const r=this;let o=e;o<0&&(o=0);const{params:s,snapGrid:d,slidesGrid:l,previousIndex:u,activeIndex:c,rtlTranslate:h,wrapperEl:m,enabled:f}=r;if(!f&&!i&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);const g=Math.min(r.params.slidesPerGroupSkip,o);let p=g+Math.floor((o-g)/r.params.slidesPerGroup);p>=d.length&&(p=d.length-1);const v=-d[p];if(s.normalizeSlideIndex)for(let e=0;e<l.length;e+=1){const t=-Math.floor(100*v),n=Math.floor(100*l[e]),i=Math.floor(100*l[e+1]);void 0!==l[e+1]?t>=n&&t<i-(i-n)/2?o=e:t>=n&&t<i&&(o=e+1):t>=n&&(o=e)}if(r.initialized&&o!==c){if(!r.allowSlideNext&&(h?v>r.translate&&v>r.minTranslate():v<r.translate&&v<r.minTranslate()))return!1;if(!r.allowSlidePrev&&v>r.translate&&v>r.maxTranslate()&&(c||0)!==o)return!1}let y;o!==(u||0)&&n&&r.emit("beforeSlideChangeStart"),r.updateProgress(v),y=o>c?"next":o<c?"prev":"reset";const b=r.virtual&&r.params.virtual.enabled;if(!(b&&a)&&(h&&-v===r.translate||!h&&v===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(v),"reset"!==y&&(r.transitionStart(n,y),r.transitionEnd(n,y)),!1;if(s.cssMode){const e=r.isHorizontal(),n=h?v:-v;if(0===t)b&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),b&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame((()=>{m[e?"scrollLeft":"scrollTop"]=n}))):m[e?"scrollLeft":"scrollTop"]=n,b&&requestAnimationFrame((()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1}));else{if(!r.support.smoothScroll)return Vx({swiper:r,targetPosition:n,side:e?"left":"top"}),!0;m.scrollTo({[e?"left":"top"]:n,behavior:"smooth"})}return!0}return r.setTransition(t),r.setTranslate(v),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,i),r.transitionStart(n,y),0===t?r.transitionEnd(n,y):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(n,y))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,n,i){if(void 0===e&&(e=0),void 0===n&&(n=!0),"string"==typeof e){e=parseInt(e,10)}const a=this;if(a.destroyed)return;void 0===t&&(t=a.params.speed);const r=a.grid&&a.params.grid&&a.params.grid.rows>1;let o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{let e;if(r){const t=o*a.params.grid.rows;e=a.slides.filter((e=>1*e.getAttribute("data-swiper-slide-index")===t))[0].column}else e=a.getSlideIndexByData(o);const t=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,{centeredSlides:n}=a.params;let s=a.params.slidesPerView;"auto"===s?s=a.slidesPerViewDynamic():(s=Math.ceil(parseFloat(a.params.slidesPerView,10)),n&&s%2==0&&(s+=1));let d=t-e<s;if(n&&(d=d||e<Math.ceil(s/2)),i&&n&&"auto"!==a.params.slidesPerView&&!r&&(d=!1),d){const i=n?e<a.activeIndex?"prev":"next":e-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?a.realIndex:void 0})}if(r){const e=o*a.params.grid.rows;o=a.slides.filter((t=>1*t.getAttribute("data-swiper-slide-index")===e))[0].column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame((()=>{a.slideTo(o,t,n,i)})),a},slideNext:function(e,t,n){void 0===t&&(t=!0);const i=this,{enabled:a,params:r,animating:o}=i;if(!a||i.destroyed)return i;void 0===e&&(e=i.params.speed);let s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(i.slidesPerViewDynamic("current",!0),1));const d=i.activeIndex<r.slidesPerGroupSkip?1:s,l=i.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&r.cssMode)return requestAnimationFrame((()=>{i.slideTo(i.activeIndex+d,e,t,n)})),!0}return r.rewind&&i.isEnd?i.slideTo(0,e,t,n):i.slideTo(i.activeIndex+d,e,t,n)},slidePrev:function(e,t,n){void 0===t&&(t=!0);const i=this,{params:a,snapGrid:r,slidesGrid:o,rtlTranslate:s,enabled:d,animating:l}=i;if(!d||i.destroyed)return i;void 0===e&&(e=i.params.speed);const u=i.virtual&&a.virtual.enabled;if(a.loop){if(l&&!u&&a.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function c(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=c(s?i.translate:-i.translate),m=r.map((e=>c(e)));let f=r[m.indexOf(h)-1];if(void 0===f&&a.cssMode){let e;r.forEach(((t,n)=>{h>=t&&(e=n)})),void 0!==e&&(f=r[e>0?e-1:e])}let g=0;if(void 0!==f&&(g=o.indexOf(f),g<0&&(g=i.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-i.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&i.isBeginning){const a=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(a,e,t,n)}return a.loop&&0===i.activeIndex&&a.cssMode?(requestAnimationFrame((()=>{i.slideTo(g,e,t,n)})),!0):i.slideTo(g,e,t,n)},slideReset:function(e,t,n){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,n)},slideToClosest:function(e,t,n,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const a=this;if(a.destroyed)return;void 0===e&&(e=a.params.speed);let r=a.activeIndex;const o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),d=a.rtlTranslate?a.translate:-a.translate;if(d>=a.snapGrid[s]){const e=a.snapGrid[s];d-e>(a.snapGrid[s+1]-e)*i&&(r+=a.params.slidesPerGroup)}else{const e=a.snapGrid[s-1];d-e<=(a.snapGrid[s]-e)*i&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,n)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:n}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let a,r=e.clickedIndex;const o=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;a=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?r<e.loopedSlides-i/2||r>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),r=e.getSlideIndex(Kx(n,`${o}[data-swiper-slide-index="${a}"]`)[0]),Hx((()=>{e.slideTo(r)}))):e.slideTo(r):r>e.slides.length-i?(e.loopFix(),r=e.getSlideIndex(Kx(n,`${o}[data-swiper-slide-index="${a}"]`)[0]),Hx((()=>{e.slideTo(r)}))):e.slideTo(r)}else e.slideTo(r)}};var bC={loopCreate:function(e){const t=this,{params:n,slidesEl:i}=t;if(!n.loop||t.virtual&&t.params.virtual.enabled)return;const a=()=>{Kx(i,`.${n.slideClass}, swiper-slide`).forEach(((e,t)=>{e.setAttribute("data-swiper-slide-index",t)}))},r=t.grid&&n.grid&&n.grid.rows>1,o=n.slidesPerGroup*(r?n.grid.rows:1),s=t.slides.length%o!=0,d=r&&t.slides.length%n.grid.rows!=0,l=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Jx("swiper-slide",[n.slideBlankClass]):Jx("div",[n.slideClass,n.slideBlankClass]);t.slidesEl.append(e)}};if(s){if(n.loopAddBlankSlides){l(o-t.slides.length%o),t.recalcSlides(),t.updateSlides()}else qx("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)");a()}else if(d){if(n.loopAddBlankSlides){l(n.grid.rows-t.slides.length%n.grid.rows),t.recalcSlides(),t.updateSlides()}else qx("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)");a()}else a();t.loopFix({slideRealIndex:e,direction:n.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:n=!0,direction:i,setTranslate:a,activeSlideIndex:r,byController:o,byMousewheel:s}=void 0===e?{}:e;const d=this;if(!d.params.loop)return;d.emit("beforeLoopFix");const{slides:l,allowSlidePrev:u,allowSlideNext:c,slidesEl:h,params:m}=d,{centeredSlides:f}=m;if(d.allowSlidePrev=!0,d.allowSlideNext=!0,d.virtual&&m.virtual.enabled)return n&&(m.centeredSlides||0!==d.snapIndex?m.centeredSlides&&d.snapIndex<m.slidesPerView?d.slideTo(d.virtual.slides.length+d.snapIndex,0,!1,!0):d.snapIndex===d.snapGrid.length-1&&d.slideTo(d.virtual.slidesBefore,0,!1,!0):d.slideTo(d.virtual.slides.length,0,!1,!0)),d.allowSlidePrev=u,d.allowSlideNext=c,void d.emit("loopFix");let g=m.slidesPerView;"auto"===g?g=d.slidesPerViewDynamic():(g=Math.ceil(parseFloat(m.slidesPerView,10)),f&&g%2==0&&(g+=1));const p=m.slidesPerGroupAuto?g:m.slidesPerGroup;let v=p;v%p!=0&&(v+=p-v%p),v+=m.loopAdditionalSlides,d.loopedSlides=v;const y=d.grid&&m.grid&&m.grid.rows>1;l.length<g+v?qx("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===m.grid.fill&&qx("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],w=[];let k=d.activeIndex;void 0===r?r=d.getSlideIndex(l.filter((e=>e.classList.contains(m.slideActiveClass)))[0]):k=r;const S="next"===i||!i,M="prev"===i||!i;let T=0,E=0;const P=y?Math.ceil(l.length/m.grid.rows):l.length,A=(y?l[r].column:r)+(f&&void 0===a?-g/2+.5:0);if(A<v){T=Math.max(v-A,p);for(let e=0;e<v-A;e+=1){const t=e-Math.floor(e/P)*P;if(y){const e=P-t-1;for(let t=l.length-1;t>=0;t-=1)l[t].column===e&&b.push(t)}else b.push(P-t-1)}}else if(A+g>P-v){E=Math.max(A-(P-2*v),p);for(let e=0;e<E;e+=1){const t=e-Math.floor(e/P)*P;y?l.forEach(((e,n)=>{e.column===t&&w.push(n)})):w.push(t)}}if(d.__preventObserver__=!0,requestAnimationFrame((()=>{d.__preventObserver__=!1})),M&&b.forEach((e=>{l[e].swiperLoopMoveDOM=!0,h.prepend(l[e]),l[e].swiperLoopMoveDOM=!1})),S&&w.forEach((e=>{l[e].swiperLoopMoveDOM=!0,h.append(l[e]),l[e].swiperLoopMoveDOM=!1})),d.recalcSlides(),"auto"===m.slidesPerView?d.updateSlides():y&&(b.length>0&&M||w.length>0&&S)&&d.slides.forEach(((e,t)=>{d.grid.updateSlide(t,e,d.slides)})),m.watchSlidesProgress&&d.updateSlidesOffset(),n)if(b.length>0&&M){if(void 0===t){const e=d.slidesGrid[k],t=d.slidesGrid[k+T]-e;s?d.setTranslate(d.translate-t):(d.slideTo(k+Math.ceil(T),0,!1,!0),a&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-t,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-t))}else if(a){const e=y?b.length/m.grid.rows:b.length;d.slideTo(d.activeIndex+e,0,!1,!0),d.touchEventsData.currentTranslate=d.translate}}else if(w.length>0&&S)if(void 0===t){const e=d.slidesGrid[k],t=d.slidesGrid[k-E]-e;s?d.setTranslate(d.translate-t):(d.slideTo(k-E,0,!1,!0),a&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-t,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-t))}else{const e=y?w.length/m.grid.rows:w.length;d.slideTo(d.activeIndex-e,0,!1,!0)}if(d.allowSlidePrev=u,d.allowSlideNext=c,d.controller&&d.controller.control&&!o){const e={slideRealIndex:t,direction:i,setTranslate:a,activeSlideIndex:r,byController:!0};Array.isArray(d.controller.control)?d.controller.control.forEach((t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===m.slidesPerView&&n})})):d.controller.control instanceof d.constructor&&d.controller.control.params.loop&&d.controller.control.loopFix({...e,slideTo:d.controller.control.params.slidesPerView===m.slidesPerView&&n})}d.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:n}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach((e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e})),e.slides.forEach((e=>{e.removeAttribute("data-swiper-slide-index")})),i.forEach((e=>{n.append(e)})),e.recalcSlides(),e.slideTo(e.realIndex,0)}};var wC={setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const n="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),n.style.cursor="move",n.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame((()=>{t.__preventObserver__=!1}))},unsetGrabCursor:function(){const 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 kC(e,t,n){const i=$x(),{params:a}=e,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(n<=o||n>=i.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function SC(e){const t=this,n=jx();let i=e;i.originalEvent&&(i=i.originalEvent);const a=t.touchEventsData;if("pointerdown"===i.type){if(null!==a.pointerId&&a.pointerId!==i.pointerId)return;a.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(a.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void kC(t,i,i.targetTouches[0].pageX);const{params:r,touches:o,enabled:s}=t;if(!s)return;if(!r.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&r.preventInteractionOnTransition)return;!t.animating&&r.cssMode&&r.loop&&t.loopFix();let d=i.target;if("wrapper"===r.touchEventsTarget&&!function(e,t){const n=t.contains(e);if(!n&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return n}(d,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(a.isTouched&&a.isMoved)return;const l=!!r.noSwipingClass&&""!==r.noSwipingClass,u=i.composedPath?i.composedPath():i.path;l&&i.target&&i.target.shadowRoot&&u&&(d=u[0]);const c=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(r.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(n){if(!n||n===jx()||n===$x())return null;n.assignedSlot&&(n=n.assignedSlot);const i=n.closest(e);return i||n.getRootNode?i||t(n.getRootNode().host):null}(t)}(c,d):d.closest(c)))return void(t.allowClick=!0);if(r.swipeHandler&&!d.closest(r.swipeHandler))return;o.currentX=i.pageX,o.currentY=i.pageY;const m=o.currentX,f=o.currentY;if(!kC(t,i,m))return;Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=m,o.startY=f,a.touchStartTime=Ux(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);let g=!0;d.matches(a.focusableElements)&&(g=!1,"SELECT"===d.nodeName&&(a.isTouched=!1)),n.activeElement&&n.activeElement.matches(a.focusableElements)&&n.activeElement!==d&&n.activeElement.blur();const p=g&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!p||d.isContentEditable||i.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function MC(e){const t=jx(),n=this,i=n.touchEventsData,{params:a,touches:r,rtlTranslate:o,enabled:s}=n;if(!s)return;if(!a.simulateTouch&&"mouse"===e.pointerType)return;let d,l=e;if(l.originalEvent&&(l=l.originalEvent),"pointermove"===l.type){if(null!==i.touchId)return;if(l.pointerId!==i.pointerId)return}if("touchmove"===l.type){if(d=[...l.changedTouches].filter((e=>e.identifier===i.touchId))[0],!d||d.identifier!==i.touchId)return}else d=l;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&n.emit("touchMoveOpposite",l));const u=d.pageX,c=d.pageY;if(l.preventedByNestedSwiper)return r.startX=u,void(r.startY=c);if(!n.allowTouchMove)return l.target.matches(i.focusableElements)||(n.allowClick=!1),void(i.isTouched&&(Object.assign(r,{startX:u,startY:c,currentX:u,currentY:c}),i.touchStartTime=Ux()));if(a.touchReleaseOnEdges&&!a.loop)if(n.isVertical()){if(c<r.startY&&n.translate<=n.maxTranslate()||c>r.startY&&n.translate>=n.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(u<r.startX&&n.translate<=n.maxTranslate()||u>r.startX&&n.translate>=n.minTranslate())return;if(t.activeElement&&l.target===t.activeElement&&l.target.matches(i.focusableElements))return i.isMoved=!0,void(n.allowClick=!1);i.allowTouchCallbacks&&n.emit("touchMove",l),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=u,r.currentY=c;const h=r.currentX-r.startX,m=r.currentY-r.startY;if(n.params.threshold&&Math.sqrt(h**2+m**2)<n.params.threshold)return;if(void 0===i.isScrolling){let e;n.isHorizontal()&&r.currentY===r.startY||n.isVertical()&&r.currentX===r.startX?i.isScrolling=!1:h*h+m*m>=25&&(e=180*Math.atan2(Math.abs(m),Math.abs(h))/Math.PI,i.isScrolling=n.isHorizontal()?e>a.touchAngle:90-e>a.touchAngle)}if(i.isScrolling&&n.emit("touchMoveOpposite",l),void 0===i.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===l.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;n.allowClick=!1,!a.cssMode&&l.cancelable&&l.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&l.stopPropagation();let f=n.isHorizontal()?h:m,g=n.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),g=Math.abs(g)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,g=-g);const p=n.touchesDirection;n.swipeDirection=f>0?"prev":"next",n.touchesDirection=g>0?"prev":"next";const v=n.params.loop&&!a.cssMode,y="next"===n.touchesDirection&&n.allowSlideNext||"prev"===n.touchesDirection&&n.allowSlidePrev;if(!i.isMoved){if(v&&y&&n.loopFix({direction:n.swipeDirection}),i.startTranslate=n.getTranslate(),n.setTransition(0),n.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});n.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!a.grabCursor||!0!==n.allowSlideNext&&!0!==n.allowSlidePrev||n.setGrabCursor(!0),n.emit("sliderFirstMove",l)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&p!==n.touchesDirection&&v&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:u,startY:c,currentX:u,currentY:c,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);n.emit("sliderMove",l),i.isMoved=!0,i.currentTranslate=f+i.startTranslate;let b=!0,w=a.resistanceRatio;if(a.touchReleaseOnEdges&&(w=0),f>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(a.centeredSlides?n.minTranslate()-n.slidesSizesGrid[n.activeIndex+1]-("auto"!==a.slidesPerView&&n.slides.length-a.slidesPerView>=2?n.slidesSizesGrid[n.activeIndex+1]+n.params.spaceBetween:0)-n.params.spaceBetween:n.minTranslate())&&n.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>n.minTranslate()&&(b=!1,a.resistance&&(i.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+i.startTranslate+f)**w))):f<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(a.centeredSlides?n.maxTranslate()+n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween+("auto"!==a.slidesPerView&&n.slides.length-a.slidesPerView>=2?n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween:0):n.maxTranslate())&&n.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:n.slides.length-("auto"===a.slidesPerView?n.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),i.currentTranslate<n.maxTranslate()&&(b=!1,a.resistance&&(i.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-i.startTranslate-f)**w))),b&&(l.preventedByNestedSwiper=!0),!n.allowSlideNext&&"next"===n.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!n.allowSlidePrev&&"prev"===n.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),n.allowSlidePrev||n.allowSlideNext||(i.currentTranslate=i.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,i.currentTranslate=i.startTranslate,void(r.diff=n.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&n.freeMode||a.watchSlidesProgress)&&(n.updateActiveIndex(),n.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&n.freeMode&&n.freeMode.onTouchMove(),n.updateProgress(i.currentTranslate),n.setTranslate(i.currentTranslate))}function TC(e){const t=this,n=t.touchEventsData;let i,a=e;a.originalEvent&&(a=a.originalEvent);if("touchend"===a.type||"touchcancel"===a.type){if(i=[...a.changedTouches].filter((e=>e.identifier===n.touchId))[0],!i||i.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;i=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)){if(!(["pointercancel","contextmenu"].includes(a.type)&&(t.browser.isSafari||t.browser.isWebView)))return}n.pointerId=null,n.touchId=null;const{params:r,touches:o,rtlTranslate:s,slidesGrid:d,enabled:l}=t;if(!l)return;if(!r.simulateTouch&&"mouse"===a.pointerType)return;if(n.allowTouchCallbacks&&t.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&t.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const u=Ux(),c=u-n.touchStartTime;if(t.allowClick){const e=a.path||a.composedPath&&a.composedPath();t.updateClickedSlide(e&&e[0]||a.target,e),t.emit("tap click",a),c<300&&u-n.lastClickTime<300&&t.emit("doubleTap doubleClick",a)}if(n.lastClickTime=Ux(),Hx((()=>{t.destroyed||(t.allowClick=!0)})),!n.isTouched||!n.isMoved||!t.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);let h;if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,h=r.followFinger?s?t.translate:-t.translate:-n.currentTranslate,r.cssMode)return;if(r.freeMode&&r.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const m=h>=-t.maxTranslate()&&!t.params.loop;let f=0,g=t.slidesSizesGrid[0];for(let e=0;e<d.length;e+=e<r.slidesPerGroupSkip?1:r.slidesPerGroup){const t=e<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==d[e+t]?(m||h>=d[e]&&h<d[e+t])&&(f=e,g=d[e+t]-d[e]):(m||h>=d[e])&&(f=e,g=d[d.length-1]-d[d.length-2])}let p=null,v=null;r.rewind&&(t.isBeginning?v=r.virtual&&r.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(p=0));const y=(h-d[f])/g,b=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(c>r.longSwipesMs){if(!r.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=r.longSwipesRatio?t.slideTo(r.rewind&&t.isEnd?p:f+b):t.slideTo(f)),"prev"===t.swipeDirection&&(y>1-r.longSwipesRatio?t.slideTo(f+b):null!==v&&y<0&&Math.abs(y)>r.longSwipesRatio?t.slideTo(v):t.slideTo(f))}else{if(!r.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(a.target===t.navigation.nextEl||a.target===t.navigation.prevEl)?a.target===t.navigation.nextEl?t.slideTo(f+b):t.slideTo(f):("next"===t.swipeDirection&&t.slideTo(null!==p?p:f+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:f))}}function EC(){const e=this,{params:t,el:n}=e;if(n&&0===n.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:a,snapGrid:r}=e,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const s=o&&t.loop;!("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):e.slideTo(e.slides.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=i,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}function PC(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function AC(){const e=this,{wrapperEl:t,rtlTranslate:n,enabled:i}=e;if(!i)return;let a;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const r=e.maxTranslate()-e.minTranslate();a=0===r?0:(e.translate-e.minTranslate())/r,a!==e.progress&&e.updateProgress(n?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function xC(e){const t=this;hC(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function CC(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const LC=(e,t)=>{const n=jx(),{params:i,el:a,wrapperEl:r,device:o}=e,s=!!i.nested,d="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(n[d]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[d]("touchstart",e.onTouchStart,{passive:!1}),a[d]("pointerdown",e.onTouchStart,{passive:!1}),n[d]("touchmove",e.onTouchMove,{passive:!1,capture:s}),n[d]("pointermove",e.onTouchMove,{passive:!1,capture:s}),n[d]("touchend",e.onTouchEnd,{passive:!0}),n[d]("pointerup",e.onTouchEnd,{passive:!0}),n[d]("pointercancel",e.onTouchEnd,{passive:!0}),n[d]("touchcancel",e.onTouchEnd,{passive:!0}),n[d]("pointerout",e.onTouchEnd,{passive:!0}),n[d]("pointerleave",e.onTouchEnd,{passive:!0}),n[d]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&a[d]("click",e.onClick,!0),i.cssMode&&r[d]("scroll",e.onScroll),i.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",EC,!0):e[l]("observerUpdate",EC,!0),a[d]("load",e.onLoad,{capture:!0}))};const DC=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var IC={setBreakpoint:function(){const e=this,{realIndex:t,initialized:n,params:i,el:a}=e,r=i.breakpoints;if(!r||r&&0===Object.keys(r).length)return;const o=e.getBreakpoint(r,e.params.breakpointsBase,e.el);if(!o||e.currentBreakpoint===o)return;const s=(o in r?r[o]:void 0)||e.originalParams,d=DC(e,i),l=DC(e,s),u=e.params.grabCursor,c=s.grabCursor,h=i.enabled;d&&!l?(a.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!d&&l&&(a.classList.add(`${i.containerModifierClass}grid`),(s.grid.fill&&"column"===s.grid.fill||!s.grid.fill&&"column"===i.grid.fill)&&a.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),u&&!c?e.unsetGrabCursor():!u&&c&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach((t=>{if(void 0===s[t])return;const n=i[t]&&i[t].enabled,a=s[t]&&s[t].enabled;n&&!a&&e[t].disable(),!n&&a&&e[t].enable()}));const m=s.direction&&s.direction!==i.direction,f=i.loop&&(s.slidesPerView!==i.slidesPerView||m),g=i.loop;m&&n&&e.changeDirection(),Xx(e.params,s);const p=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!p?e.disable():!h&&p&&e.enable(),e.currentBreakpoint=o,e.emit("_beforeBreakpoint",s),n&&(f?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!g&&v?(e.loopCreate(t),e.updateSlides()):g&&!v&&e.loopDestroy()),e.emit("breakpoint",s)},getBreakpoint:function(e,t,n){if(void 0===t&&(t="window"),!e||"container"===t&&!n)return;let i=!1;const a=$x(),r="window"===t?a.innerHeight:n.clientHeight,o=Object.keys(e).map((e=>{if("string"==typeof e&&0===e.indexOf("@")){const 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(let e=0;e<o.length;e+=1){const{point:r,value:s}=o[e];"window"===t?a.matchMedia(`(min-width: ${s}px)`).matches&&(i=r):s<=n.clientWidth&&(i=r)}return i||"max"}};var _C={addClasses:function(){const e=this,{classNames:t,params:n,rtl:i,el:a,device:r}=e,o=function(e,t){const n=[];return e.forEach((e=>{"object"==typeof e?Object.keys(e).forEach((i=>{e[i]&&n.push(t+i)})):"string"==typeof e&&n.push(t+e)})),n}(["initialized",n.direction,{"free-mode":e.params.freeMode&&n.freeMode.enabled},{autoheight:n.autoHeight},{rtl:i},{grid:n.grid&&n.grid.rows>1},{"grid-column":n.grid&&n.grid.rows>1&&"column"===n.grid.fill},{android:r.android},{ios:r.ios},{"css-mode":n.cssMode},{centered:n.cssMode&&n.centeredSlides},{"watch-progress":n.watchSlidesProgress}],n.containerModifierClass);t.push(...o),a.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}};var RC={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,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 WC(e,t){return function(n){void 0===n&&(n={});const i=Object.keys(n)[0],a=n[i];"object"==typeof a&&null!==a?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in a?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Xx(t,n)):Xx(t,n)):Xx(t,n)}}const NC={eventsEmitter:lC,update:gC,translate:pC,transition:{setTransition:function(e,t){const n=this;n.params.cssMode||(n.wrapperEl.style.transitionDuration=`${e}ms`,n.wrapperEl.style.transitionDelay=0===e?"0ms":""),n.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const n=this,{params:i}=n;i.cssMode||(i.autoHeight&&n.updateAutoHeight(),vC({swiper:n,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const n=this,{params:i}=n;n.animating=!1,i.cssMode||(n.setTransition(0),vC({swiper:n,runCallbacks:e,direction:t,step:"End"}))}},slide:yC,loop:bC,grabCursor:wC,events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=SC.bind(e),e.onTouchMove=MC.bind(e),e.onTouchEnd=TC.bind(e),e.onDocumentTouchStart=CC.bind(e),t.cssMode&&(e.onScroll=AC.bind(e)),e.onClick=PC.bind(e),e.onLoad=xC.bind(e),LC(e,"on")},detachEvents:function(){LC(this,"off")}},breakpoints:IC,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:n}=e,{slidesOffsetBefore:i}=n;if(i){const t=e.slides.length-1,n=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>n}else e.isLocked=1===e.snapGrid.length;!0===n.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===n.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:_C},OC={};class FC{constructor(){let e,t;for(var n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];1===i.length&&i[0].constructor&&"Object"===Object.prototype.toString.call(i[0]).slice(8,-1)?t=i[0]:[e,t]=i,t||(t={}),t=Xx({},t),e&&!t.el&&(t.el=e);const r=jx();if(t.el&&"string"==typeof t.el&&r.querySelectorAll(t.el).length>1){const e=[];return r.querySelectorAll(t.el).forEach((n=>{const i=Xx({},t,{el:n});e.push(new FC(i))})),e}const o=this;o.__swiper__=!0,o.support=oC(),o.device=sC({userAgent:t.userAgent}),o.browser=dC(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],t.modules&&Array.isArray(t.modules)&&o.modules.push(...t.modules);const s={};o.modules.forEach((e=>{e({params:t,swiper:o,extendParams:WC(t,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})}));const d=Xx({},RC,s);return o.params=Xx({},d,OC,t),o.originalParams=Xx({},o.params),o.passedParams=Xx({},t),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:e,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}getDirectionLabel(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]}getSlideIndex(e){const{slidesEl:t,params:n}=this,i=Zx(Kx(t,`.${n.slideClass}, swiper-slide`)[0]);return Zx(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter((t=>1*t.getAttribute("data-swiper-slide-index")===e))[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=Kx(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const n=this;e=Math.min(Math.max(e,0),1);const i=n.minTranslate(),a=(n.maxTranslate()-i)*e+i;n.translateTo(a,void 0===t?0:t),n.updateActiveIndex(),n.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter((t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass)));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter((e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass))).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach((n=>{const i=e.getSlideClasses(n);t.push({slideEl:n,classNames:i}),e.emit("_slideClass",n,i)})),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:n,slides:i,slidesGrid:a,slidesSizesGrid:r,size:o,activeIndex:s}=this;let d=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){let e,t=i[s]?Math.ceil(i[s].swiperSlideSize):0;for(let n=s+1;n<i.length;n+=1)i[n]&&!e&&(t+=Math.ceil(i[n].swiperSlideSize),d+=1,t>o&&(e=!0));for(let n=s-1;n>=0;n-=1)i[n]&&!e&&(t+=i[n].swiperSlideSize,d+=1,t>o&&(e=!0))}else if("current"===e)for(let e=s+1;e<i.length;e+=1){(t?a[e]+r[e]-a[s]<o:a[e]-a[s]<o)&&(d+=1)}else for(let e=s-1;e>=0;e-=1){a[s]-a[e]<o&&(d+=1)}return d}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:n}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,n=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(n),e.updateActiveIndex(),e.updateSlidesClasses()}let a;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach((t=>{t.complete&&hC(e,t)})),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)i(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){const t=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;a=e.slideTo(t.length-1,0,!1,!0)}else a=e.slideTo(e.activeIndex,0,!1,!0);a||i()}n.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const n=this,i=n.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(n.el.classList.remove(`${n.params.containerModifierClass}${i}`),n.el.classList.add(`${n.params.containerModifierClass}${e}`),n.emitContainerClasses(),n.params.direction=e,n.slides.forEach((t=>{"vertical"===e?t.style.width="":t.style.height=""})),n.emit("changeDirection"),t&&n.update()),n}changeLanguageDirection(e){const 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())}mount(e){const t=this;if(t.mounted)return!0;let n=e||t.params.el;if("string"==typeof n&&(n=document.querySelector(n)),!n)return!1;n.swiper=t,n.parentNode&&n.parentNode.host&&n.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let a=(()=>{if(n&&n.shadowRoot&&n.shadowRoot.querySelector){return n.shadowRoot.querySelector(i())}return Kx(n,i())[0]})();return!a&&t.params.createElements&&(a=Jx("div",t.params.wrapperClass),n.append(a),Kx(n,`.${t.params.slideClass}`).forEach((e=>{a.append(e)}))),Object.assign(t,{el:n,wrapperEl:a,slidesEl:t.isElement&&!n.parentNode.host.slideSlots?n.parentNode.host:a,hostEl:t.isElement?n.parentNode.host:n,mounted:!0,rtl:"rtl"===n.dir.toLowerCase()||"rtl"===Qx(n,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===n.dir.toLowerCase()||"rtl"===Qx(n,"direction")),wrongRTL:"-webkit-box"===Qx(a,"display")}),!0}init(e){const 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(),t.attachEvents();const n=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&n.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),n.forEach((e=>{e.complete?hC(t,e):e.addEventListener("load",(e=>{hC(t,e.target)}))})),fC(t),t.initialized=!0,fC(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const n=this,{params:i,el:a,wrapperEl:r,slides:o}=n;return void 0===n.params||n.destroyed||(n.emit("beforeDestroy"),n.initialized=!1,n.detachEvents(),i.loop&&n.loopDestroy(),t&&(n.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach((e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")}))),n.emit("destroy"),Object.keys(n.eventsListeners).forEach((e=>{n.off(e)})),!1!==e&&(n.el&&"string"!=typeof n.el&&(n.el.swiper=null),function(e){const t=e;Object.keys(t).forEach((e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}}))}(n)),n.destroyed=!0),null}static extendDefaults(e){Xx(OC,e)}static get extendedDefaults(){return OC}static get defaults(){return RC}static installModule(e){FC.prototype.__modules__||(FC.prototype.__modules__=[]);const t=FC.prototype.__modules__;"function"==typeof e&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach((e=>FC.installModule(e))),FC):(FC.installModule(e),FC)}}function jC(e){return void 0===e&&(e=""),`.${e.trim().replace(/([\.:!+\/])/g,"\\$1").replace(/ /g,".")}`}function zC(e){let{swiper:t,extendParams:n,on:i,emit:a}=e;const r="swiper-pagination";let o;n({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`}}),t.pagination={el:null,bullets:[]};let s=0;function d(){return!t.params.pagination.el||!t.pagination.el||Array.isArray(t.pagination.el)&&0===t.pagination.el.length}function l(e,n){const{bulletActiveClass:i}=t.params.pagination;e&&(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&(e.classList.add(`${i}-${n}`),(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&e.classList.add(`${i}-${n}-${n}`))}function u(e){const n=e.target.closest(jC(t.params.pagination.bulletClass));if(!n)return;e.preventDefault();const i=Zx(n)*t.params.slidesPerGroup;if(t.params.loop){if(t.realIndex===i)return;const e=(a=t.realIndex,r=i,o=t.slides.length,(r%=o)==1+(a%=o)?"next":r===a-1?"previous":void 0);"next"===e?t.slideNext():"previous"===e?t.slidePrev():t.slideToLoop(i)}else t.slideTo(i);var a,r,o}function c(){const e=t.rtl,n=t.params.pagination;if(d())return;let i,r,u=t.pagination.el;u=nC(u);const c=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.slides.length,h=t.params.loop?Math.ceil(c/t.params.slidesPerGroup):t.snapGrid.length;if(t.params.loop?(r=t.previousRealIndex||0,i=t.params.slidesPerGroup>1?Math.floor(t.realIndex/t.params.slidesPerGroup):t.realIndex):void 0!==t.snapIndex?(i=t.snapIndex,r=t.previousSnapIndex):(r=t.previousIndex||0,i=t.activeIndex||0),"bullets"===n.type&&t.pagination.bullets&&t.pagination.bullets.length>0){const a=t.pagination.bullets;let d,c,h;if(n.dynamicBullets&&(o=tC(a[0],t.isHorizontal()?"width":"height"),u.forEach((e=>{e.style[t.isHorizontal()?"width":"height"]=o*(n.dynamicMainBullets+4)+"px"})),n.dynamicMainBullets>1&&void 0!==r&&(s+=i-(r||0),s>n.dynamicMainBullets-1?s=n.dynamicMainBullets-1:s<0&&(s=0)),d=Math.max(i-s,0),c=d+(Math.min(a.length,n.dynamicMainBullets)-1),h=(c+d)/2),a.forEach((e=>{const t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map((e=>`${n.bulletActiveClass}${e}`))].map((e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e)).flat();e.classList.remove(...t)})),u.length>1)a.forEach((e=>{const a=Zx(e);a===i?e.classList.add(...n.bulletActiveClass.split(" ")):t.isElement&&e.setAttribute("part","bullet"),n.dynamicBullets&&(a>=d&&a<=c&&e.classList.add(...`${n.bulletActiveClass}-main`.split(" ")),a===d&&l(e,"prev"),a===c&&l(e,"next"))}));else{const e=a[i];if(e&&e.classList.add(...n.bulletActiveClass.split(" ")),t.isElement&&a.forEach(((e,t)=>{e.setAttribute("part",t===i?"bullet-active":"bullet")})),n.dynamicBullets){const e=a[d],t=a[c];for(let e=d;e<=c;e+=1)a[e]&&a[e].classList.add(...`${n.bulletActiveClass}-main`.split(" "));l(e,"prev"),l(t,"next")}}if(n.dynamicBullets){const i=Math.min(a.length,n.dynamicMainBullets+4),r=(o*i-o)/2-h*o,s=e?"right":"left";a.forEach((e=>{e.style[t.isHorizontal()?s:"top"]=`${r}px`}))}}u.forEach(((e,r)=>{if("fraction"===n.type&&(e.querySelectorAll(jC(n.currentClass)).forEach((e=>{e.textContent=n.formatFractionCurrent(i+1)})),e.querySelectorAll(jC(n.totalClass)).forEach((e=>{e.textContent=n.formatFractionTotal(h)}))),"progressbar"===n.type){let a;a=n.progressbarOpposite?t.isHorizontal()?"vertical":"horizontal":t.isHorizontal()?"horizontal":"vertical";const r=(i+1)/h;let o=1,s=1;"horizontal"===a?o=r:s=r,e.querySelectorAll(jC(n.progressbarFillClass)).forEach((e=>{e.style.transform=`translate3d(0,0,0) scaleX(${o}) scaleY(${s})`,e.style.transitionDuration=`${t.params.speed}ms`}))}"custom"===n.type&&n.renderCustom?(e.innerHTML=n.renderCustom(t,i+1,h),0===r&&a("paginationRender",e)):(0===r&&a("paginationRender",e),a("paginationUpdate",e)),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](n.lockClass)}))}function h(){const e=t.params.pagination;if(d())return;const n=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.grid&&t.params.grid.rows>1?t.slides.length/Math.ceil(t.params.grid.rows):t.slides.length;let i=t.pagination.el;i=nC(i);let r="";if("bullets"===e.type){let i=t.params.loop?Math.ceil(n/t.params.slidesPerGroup):t.snapGrid.length;t.params.freeMode&&t.params.freeMode.enabled&&i>n&&(i=n);for(let n=0;n<i;n+=1)e.renderBullet?r+=e.renderBullet.call(t,n,e.bulletClass):r+=`<${e.bulletElement} ${t.isElement?'part="bullet"':""} class="${e.bulletClass}"></${e.bulletElement}>`}"fraction"===e.type&&(r=e.renderFraction?e.renderFraction.call(t,e.currentClass,e.totalClass):`<span class="${e.currentClass}"></span> / <span class="${e.totalClass}"></span>`),"progressbar"===e.type&&(r=e.renderProgressbar?e.renderProgressbar.call(t,e.progressbarFillClass):`<span class="${e.progressbarFillClass}"></span>`),t.pagination.bullets=[],i.forEach((n=>{"custom"!==e.type&&(n.innerHTML=r||""),"bullets"===e.type&&t.pagination.bullets.push(...n.querySelectorAll(jC(e.bulletClass)))})),"custom"!==e.type&&a("paginationRender",i[0])}function m(){t.params.pagination=function(e,t,n,i){return e.params.createElements&&Object.keys(i).forEach((a=>{if(!n[a]&&!0===n.auto){let r=Kx(e.el,`.${i[a]}`)[0];r||(r=Jx("div",i[a]),r.className=i[a],e.el.append(r)),n[a]=r,t[a]=r}})),n}(t,t.originalParams.pagination,t.params.pagination,{el:"swiper-pagination"});const e=t.params.pagination;if(!e.el)return;let n;"string"==typeof e.el&&t.isElement&&(n=t.el.querySelector(e.el)),n||"string"!=typeof e.el||(n=[...document.querySelectorAll(e.el)]),n||(n=e.el),n&&0!==n.length&&(t.params.uniqueNavElements&&"string"==typeof e.el&&Array.isArray(n)&&n.length>1&&(n=[...t.el.querySelectorAll(e.el)],n.length>1&&(n=n.filter((e=>eC(e,".swiper")[0]===t.el))[0])),Array.isArray(n)&&1===n.length&&(n=n[0]),Object.assign(t.pagination,{el:n}),n=nC(n),n.forEach((n=>{"bullets"===e.type&&e.clickable&&n.classList.add(...(e.clickableClass||"").split(" ")),n.classList.add(e.modifierClass+e.type),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass),"bullets"===e.type&&e.dynamicBullets&&(n.classList.add(`${e.modifierClass}${e.type}-dynamic`),s=0,e.dynamicMainBullets<1&&(e.dynamicMainBullets=1)),"progressbar"===e.type&&e.progressbarOpposite&&n.classList.add(e.progressbarOppositeClass),e.clickable&&n.addEventListener("click",u),t.enabled||n.classList.add(e.lockClass)})))}function f(){const e=t.params.pagination;if(d())return;let n=t.pagination.el;n&&(n=nC(n),n.forEach((n=>{n.classList.remove(e.hiddenClass),n.classList.remove(e.modifierClass+e.type),n.classList.remove(t.isHorizontal()?e.horizontalClass:e.verticalClass),e.clickable&&(n.classList.remove(...(e.clickableClass||"").split(" ")),n.removeEventListener("click",u))}))),t.pagination.bullets&&t.pagination.bullets.forEach((t=>t.classList.remove(...e.bulletActiveClass.split(" "))))}i("changeDirection",(()=>{if(!t.pagination||!t.pagination.el)return;const e=t.params.pagination;let{el:n}=t.pagination;n=nC(n),n.forEach((n=>{n.classList.remove(e.horizontalClass,e.verticalClass),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass)}))})),i("init",(()=>{!1===t.params.pagination.enabled?g():(m(),h(),c())})),i("activeIndexChange",(()=>{void 0===t.snapIndex&&c()})),i("snapIndexChange",(()=>{c()})),i("snapGridLengthChange",(()=>{h(),c()})),i("destroy",(()=>{f()})),i("enable disable",(()=>{let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList[t.enabled?"remove":"add"](t.params.pagination.lockClass))))})),i("lock unlock",(()=>{c()})),i("click",((e,n)=>{const i=n.target,r=nC(t.pagination.el);if(t.params.pagination.el&&t.params.pagination.hideOnClick&&r&&r.length>0&&!i.classList.contains(t.params.pagination.bulletClass)){if(t.navigation&&(t.navigation.nextEl&&i===t.navigation.nextEl||t.navigation.prevEl&&i===t.navigation.prevEl))return;const e=r[0].classList.contains(t.params.pagination.hiddenClass);a(!0===e?"paginationShow":"paginationHide"),r.forEach((e=>e.classList.toggle(t.params.pagination.hiddenClass)))}}));const g=()=>{t.el.classList.add(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList.add(t.params.pagination.paginationDisabledClass)))),f()};Object.assign(t.pagination,{enable:()=>{t.el.classList.remove(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList.remove(t.params.pagination.paginationDisabledClass)))),m(),h(),c()},disable:g,render:h,update:c,init:m,destroy:f})}function $C(e){let t,n,{swiper:i,extendParams:a,on:r,emit:o,params:s}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},a({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let d,l,u,c,h,m,f,g,p=s&&s.autoplay?s.autoplay.delay:3e3,v=s&&s.autoplay?s.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),g||e.detail&&e.detail.bySwiperTouchMove||E())}const w=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?l=!0:l&&(v=d,l=!1);const e=i.autoplay.paused?d:y+v-(new Date).getTime();i.autoplay.timeLeft=e,o("autoplayTimeLeft",e,e/p),n=requestAnimationFrame((()=>{w()}))},k=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(n),w();let a=void 0===e?i.params.autoplay.delay:e;p=i.params.autoplay.delay,v=i.params.autoplay.delay;const r=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter((e=>e.classList.contains("swiper-slide-active")))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(r)&&r>0&&void 0===e&&(a=r,p=r,v=r),d=a;const s=i.params.speed,l=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(s,!0,!0),o("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,s,!0,!0),o("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(s,!0,!0),o("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,s,!0,!0),o("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame((()=>{k()}))))};return a>0?(clearTimeout(t),t=setTimeout((()=>{l()}),a)):requestAnimationFrame((()=>{l()})),a},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,k(),o("autoplayStart")},M=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(n),o("autoplayStop")},T=(e,n)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(f=!0);const a=()=>{o("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):E()};if(i.autoplay.paused=!0,n)return m&&(d=i.params.autoplay.delay),m=!1,void a();const r=d||i.params.autoplay.delay;d=r-((new Date).getTime()-y),i.isEnd&&d<0&&!i.params.loop||(d<0&&(d=0),a())},E=()=>{i.isEnd&&d<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),f?(f=!1,k(d)):k(),i.autoplay.paused=!1,o("autoplayResume"))},P=()=>{if(i.destroyed||!i.autoplay.running)return;const e=jx();"hidden"===e.visibilityState&&(f=!0,T(!0)),"visible"===e.visibilityState&&E()},A=e=>{"mouse"===e.pointerType&&(f=!0,g=!0,i.animating||i.autoplay.paused||T(!0))},x=e=>{"mouse"===e.pointerType&&(g=!1,i.autoplay.paused&&E())};r("init",(()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",A),i.el.addEventListener("pointerleave",x)),jx().addEventListener("visibilitychange",P),S())})),r("destroy",(()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",A),i.el.removeEventListener("pointerleave",x)),jx().removeEventListener("visibilitychange",P),i.autoplay.running&&M()})),r("_freeModeStaticRelease",(()=>{(c||f)&&E()})),r("_freeModeNoMomentumRelease",(()=>{i.params.autoplay.disableOnInteraction?M():T(!0,!0)})),r("beforeTransitionStart",((e,t,n)=>{!i.destroyed&&i.autoplay.running&&(n||!i.params.autoplay.disableOnInteraction?T(!0,!0):M())})),r("sliderFirstMove",(()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?M():(u=!0,c=!1,f=!1,h=setTimeout((()=>{f=!0,c=!0,T(!0)}),200)))})),r("touchEnd",(()=>{if(!i.destroyed&&i.autoplay.running&&u){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return c=!1,void(u=!1);c&&i.params.cssMode&&E(),c=!1,u=!1}})),r("slideChange",(()=>{!i.destroyed&&i.autoplay.running&&(m=!0)})),Object.assign(i.autoplay,{start:S,stop:M,pause:T,resume:E})}Object.keys(NC).forEach((e=>{Object.keys(NC[e]).forEach((t=>{FC.prototype[t]=NC[e][t]}))})),FC.use([function(e){let{swiper:t,on:n,emit:i}=e;const a=$x();let r=null,o=null;const s=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},d=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};n("init",(()=>{t.params.resizeObserver&&void 0!==a.ResizeObserver?t&&!t.destroyed&&t.initialized&&(r=new ResizeObserver((e=>{o=a.requestAnimationFrame((()=>{const{width:n,height:i}=t;let a=n,r=i;e.forEach((e=>{let{contentBoxSize:n,contentRect:i,target:o}=e;o&&o!==t.el||(a=i?i.width:(n[0]||n).inlineSize,r=i?i.height:(n[0]||n).blockSize)})),a===n&&r===i||s()}))})),r.observe(t.el)):(a.addEventListener("resize",s),a.addEventListener("orientationchange",d))})),n("destroy",(()=>{o&&a.cancelAnimationFrame(o),r&&r.unobserve&&t.el&&(r.unobserve(t.el),r=null),a.removeEventListener("resize",s),a.removeEventListener("orientationchange",d)}))},function(e){let{swiper:t,extendParams:n,on:i,emit:a}=e;const r=[],o=$x(),s=function(e,n){void 0===n&&(n={});const i=new(o.MutationObserver||o.WebkitMutationObserver)((e=>{if(t.__preventObserver__)return;if(1===e.length)return void a("observerUpdate",e[0]);const n=function(){a("observerUpdate",e[0])};o.requestAnimationFrame?o.requestAnimationFrame(n):o.setTimeout(n,0)}));i.observe(e,{attributes:void 0===n.attributes||n.attributes,childList:t.isElement||(void 0===n.childList||n).childList,characterData:void 0===n.characterData||n.characterData}),r.push(i)};n({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",(()=>{if(t.params.observer){if(t.params.observeParents){const e=eC(t.hostEl);for(let t=0;t<e.length;t+=1)s(e[t])}s(t.hostEl,{childList:t.params.observeSlideChildren}),s(t.wrapperEl,{attributes:!1})}})),i("destroy",(()=>{r.forEach((e=>{e.disconnect()})),r.splice(0,r.length)}))}]);let HC=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1,this.updateSpacing=e=>{this.slideSpacing=e.detail.spacing,this.swiperInstance.params.spaceBetween=this.slideSpacing,this.swiperInstance.update()}}connectedCallback(){super.connectedCallback(),window.addEventListener("child-spacing",this.updateSpacing,!1)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("child-spacing",this.updateSpacing,!1)}styles(){const{scaleFactor:t,inFocusedState:n,component:i}=this;return e.unsafeCSS(`\n :host {\n display: ${i.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Rs(i)} \n ${Xs(i.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${i.zIndex??1};\n top: 0px;\n transition: all 0.3s;\n ${Ns(i,t)}\n ${function(e,t){return`\n padding-right: ${(e.nextSlidePadding??0)*t}px !important;\n padding-left: ${(e.previousSlidePadding??0)*t}px !important;\n `}(i,t)}\n ${_s(i)}\n ${Gs(i,t,n)}\n ${Is(i,n)}\n }\n .swiper-container {\n ${zs(i,t)};\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n background: ${i.indicatorColor} !important;\n opacity: 1 !important;\n }\n .swiper-pagination-bullet-active {\n background: ${i.activeIndicatorColor} !important;\n }\n `)}updated(){FC.use([zC,$C]);const{autoplay:e,autoplaySeconds:t,showIndicators:n,slideSpacing:i,nextSlidePadding:a,previousSlidePadding:r}=this.component,o=this.shadowRoot?.querySelector(".swiper-container"),s=this.shadowRoot?.querySelector(".swiper-pagination");o&&!this.swiperInstance&&(this.swiperInstance=new FC(o,{initialSlide:0,slidesPerView:1,loop:e,spaceBetween:a??r??i??this.slideSpacing??0,autoplay:!!e&&{delay:1e3*t,disableOnInteraction:!1},pagination:!(null!=n&&!n)&&{el:s,clickable:!0}}))}render(){const t=function(e){if(!e.loopSource)return[];const{slides:t,selectedProducts:n}=Do.state,i="string"==typeof e.loopSource?e.loopSource:"",a=So(Do.productDetails,Do.state.selectedPaywall?.sku_menus||[],i);let r=[];return t&&(r=""!=i?t[i].carouselName:e.loopSource??[]),r.map((t=>{const i=a.find((e=>e.id==n[t.productGroupId]));return Js(e.components,Js({slide:t},{sku:{...To(i?.product_details,t,a)}}))}))??[]}(this.component),{focusedBorderColor:n,focusedFillColor:i,fillColor:a}=this.component;return!n&&od(a,i)||(this.tabIndex=0),e.html`
|
|
61
|
+
<div id="collapse" class="${i===a?"hidden":""}">${d}</div>`}};o([fs({type:Object})],Rx.prototype,"component",void 0),o([fs({type:Boolean})],Rx.prototype,"inFocusedState",void 0),o([fs({type:Number})],Rx.prototype,"height",void 0),o([fs({type:Number})],Rx.prototype,"scaleFactor",void 0),Rx=o([Uo("nami-collapse-container")],Rx);let Wx=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1,this.mouseDown=!1,this.startDragging=e=>{e.preventDefault(),this.mouseDown=!0,this.startX=e.pageX-this.offsetLeft},this.stopDragging=()=>{this.mouseDown=!1},this.move=e=>{e.preventDefault(),this.mouseDown&&(this.scrollLeft=this.scrollLeft-(e.pageX-this.offsetLeft-this.startX))}}connectedCallback(){super.connectedCallback(),this.addEventListener("mousemove",this.move,!1),this.addEventListener("mousedown",this.startDragging,!1),this.addEventListener("mouseup",this.stopDragging,!1),this.addEventListener("mouseleave",this.stopDragging,!1)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("mousemove",this.move,!1),this.removeEventListener("mousedown",this.startDragging,!1),this.removeEventListener("mouseup",this.stopDragging,!1),this.removeEventListener("mouseleave",this.stopDragging,!1)}styles(){const t="vertical"===this.component.direction,n=t?"margin-top":"margin-left",i=e.unsafeCSS(Is(this.component,this.inFocusedState));return e.unsafeCSS(`\n :host {\n display: ${this.component.hidden?"none":"grid"};\n grid-gap: ${this.component.spacing}px;\n grid-auto-flow: ${t?"row":"column"};\n overflow: auto;\n place-items: center;\n ${i}\n ${function(e,t,n=1){return`\n transition: all 0.3s;\n ${Ws(e)}\n ${Ns(e,n)}\n ${Os(e)}\n ${Fs(e,n,t)}\n ${zs(e,n)}\n ${$s(e)}\n ${Hs(e)}\n `}(this.component,this.inFocusedState)}\n width: auto !important;\n align-self: baseline;\n cursor: grab;\n }\n :host > :not(:first-child) {\n ${n}: ${this.component.spacing||0}px;\n }\n `)}render(){const{focusedBorderColor:e,focusedFillColor:t,fillColor:n}=this.component;!e&&od(n,t)||(this.tabIndex=0);const i=function(e){if(!e.loopSource)return[];const t=JSON.parse(e.loopSource)?.map((t=>(e.loopSourceConditions?.every((e=>td(e,t))),Js(e.components,Js({block:t},{block:t})))))??[];return t.filter((e=>null!=e))}(this.component);return i.map((e=>e.map((e=>sd(e,this.scaleFactor,this.inFocusedState)))))}};function Nx(e){return null!==e&&"object"==typeof e&&"constructor"in e&&e.constructor===Object}function Ox(e,t){void 0===e&&(e={}),void 0===t&&(t={}),Object.keys(t).forEach((n=>{void 0===e[n]?e[n]=t[n]:Nx(t[n])&&Nx(e[n])&&Object.keys(t[n]).length>0&&Ox(e[n],t[n])}))}o([fs({type:Object})],Wx.prototype,"component",void 0),o([fs({type:Boolean})],Wx.prototype,"inFocusedState",void 0),o([fs({type:Number})],Wx.prototype,"scaleFactor",void 0),Wx=o([Uo("nami-responsive-grid")],Wx);const Fx={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 jx(){const e="undefined"!=typeof document?document:{};return Ox(e,Fx),e}const zx={document:Fx,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 $x(){const e="undefined"!=typeof window?window:{};return Ox(e,zx),e}function Hx(e,t){return void 0===t&&(t=0),setTimeout(e,t)}function Ux(){return Date.now()}function Bx(e,t){void 0===t&&(t="x");const n=$x();let i,a,r;const o=function(e){const t=$x();let n;return t.getComputedStyle&&(n=t.getComputedStyle(e,null)),!n&&e.currentStyle&&(n=e.currentStyle),n||(n=e.style),n}(e);return n.WebKitCSSMatrix?(a=o.transform||o.webkitTransform,a.split(",").length>6&&(a=a.split(", ").map((e=>e.replace(",","."))).join(", ")),r=new n.WebKitCSSMatrix("none"===a?"":a)):(r=o.MozTransform||o.OTransform||o.MsTransform||o.msTransform||o.transform||o.getPropertyValue("transform").replace("translate(","matrix(1, 0, 0, 1,"),i=r.toString().split(",")),"x"===t&&(a=n.WebKitCSSMatrix?r.m41:16===i.length?parseFloat(i[12]):parseFloat(i[4])),"y"===t&&(a=n.WebKitCSSMatrix?r.m42:16===i.length?parseFloat(i[13]):parseFloat(i[5])),a||0}function Gx(e){return"object"==typeof e&&null!==e&&e.constructor&&"Object"===Object.prototype.toString.call(e).slice(8,-1)}function Xx(){const e=Object(arguments.length<=0?void 0:arguments[0]),t=["__proto__","constructor","prototype"];for(let i=1;i<arguments.length;i+=1){const a=i<0||arguments.length<=i?void 0:arguments[i];if(null!=a&&(n=a,!("undefined"!=typeof window&&void 0!==window.HTMLElement?n instanceof HTMLElement:n&&(1===n.nodeType||11===n.nodeType)))){const n=Object.keys(Object(a)).filter((e=>t.indexOf(e)<0));for(let t=0,i=n.length;t<i;t+=1){const i=n[t],r=Object.getOwnPropertyDescriptor(a,i);void 0!==r&&r.enumerable&&(Gx(e[i])&&Gx(a[i])?a[i].__swiper__?e[i]=a[i]:Xx(e[i],a[i]):!Gx(e[i])&&Gx(a[i])?(e[i]={},a[i].__swiper__?e[i]=a[i]:Xx(e[i],a[i])):e[i]=a[i])}}}var n;return e}function Yx(e,t,n){e.style.setProperty(t,n)}function Vx(e){let{swiper:t,targetPosition:n,side:i}=e;const a=$x(),r=-t.translate;let o,s=null;const d=t.params.speed;t.wrapperEl.style.scrollSnapType="none",a.cancelAnimationFrame(t.cssModeFrameID);const l=n>r?"next":"prev",u=(e,t)=>"next"===l&&e>=t||"prev"===l&&e<=t,c=()=>{o=(new Date).getTime(),null===s&&(s=o);const e=Math.max(Math.min((o-s)/d,1),0),l=.5-Math.cos(e*Math.PI)/2;let h=r+l*(n-r);if(u(h,n)&&(h=n),t.wrapperEl.scrollTo({[i]:h}),u(h,n))return t.wrapperEl.style.overflow="hidden",t.wrapperEl.style.scrollSnapType="",setTimeout((()=>{t.wrapperEl.style.overflow="",t.wrapperEl.scrollTo({[i]:h})})),void a.cancelAnimationFrame(t.cssModeFrameID);t.cssModeFrameID=a.requestAnimationFrame(c)};c()}function Kx(e,t){void 0===t&&(t="");const n=[...e.children];return e instanceof HTMLSlotElement&&n.push(...e.assignedElements()),t?n.filter((e=>e.matches(t))):n}function qx(e){try{return void console.warn(e)}catch(e){}}function Jx(e,t){void 0===t&&(t=[]);const n=document.createElement(e);return n.classList.add(...Array.isArray(t)?t:function(e){return void 0===e&&(e=""),e.trim().split(" ").filter((e=>!!e.trim()))}(t)),n}function Qx(e,t){return $x().getComputedStyle(e,null).getPropertyValue(t)}function Zx(e){let t,n=e;if(n){for(t=0;null!==(n=n.previousSibling);)1===n.nodeType&&(t+=1);return t}}function eC(e,t){const n=[];let i=e.parentElement;for(;i;)t?i.matches(t)&&n.push(i):n.push(i),i=i.parentElement;return n}function tC(e,t,n){const i=$x();return e["width"===t?"offsetWidth":"offsetHeight"]+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-right":"margin-top"))+parseFloat(i.getComputedStyle(e,null).getPropertyValue("width"===t?"margin-left":"margin-bottom"))}function nC(e){return(Array.isArray(e)?e:[e]).filter((e=>!!e))}let iC,aC,rC;function oC(){return iC||(iC=function(){const e=$x(),t=jx();return{smoothScroll:t.documentElement&&t.documentElement.style&&"scrollBehavior"in t.documentElement.style,touch:!!("ontouchstart"in e||e.DocumentTouch&&t instanceof e.DocumentTouch)}}()),iC}function sC(e){return void 0===e&&(e={}),aC||(aC=function(e){let{userAgent:t}=void 0===e?{}:e;const n=oC(),i=$x(),a=i.navigator.platform,r=t||i.navigator.userAgent,o={ios:!1,android:!1},s=i.screen.width,d=i.screen.height,l=r.match(/(Android);?[\s\/]+([\d.]+)?/);let u=r.match(/(iPad).*OS\s([\d_]+)/);const c=r.match(/(iPod)(.*OS\s([\d_]+))?/),h=!u&&r.match(/(iPhone\sOS|iOS)\s([\d_]+)/),m="Win32"===a;let f="MacIntel"===a;return!u&&f&&n.touch&&["1024x1366","1366x1024","834x1194","1194x834","834x1112","1112x834","768x1024","1024x768","820x1180","1180x820","810x1080","1080x810"].indexOf(`${s}x${d}`)>=0&&(u=r.match(/(Version)\/([\d.]+)/),u||(u=[0,1,"13_0_0"]),f=!1),l&&!m&&(o.os="android",o.android=!0),(u||h||c)&&(o.os="ios",o.ios=!0),o}(e)),aC}function dC(){return rC||(rC=function(){const e=$x(),t=sC();let n=!1;function i(){const t=e.navigator.userAgent.toLowerCase();return t.indexOf("safari")>=0&&t.indexOf("chrome")<0&&t.indexOf("android")<0}if(i()){const t=String(e.navigator.userAgent);if(t.includes("Version/")){const[e,i]=t.split("Version/")[1].split(" ")[0].split(".").map((e=>Number(e)));n=e<16||16===e&&i<2}}const a=/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/i.test(e.navigator.userAgent),r=i();return{isSafari:n||r,needPerspectiveFix:n,need3dFix:r||a&&t.ios,isWebView:a}}()),rC}var lC={on(e,t,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;const a=n?"unshift":"push";return e.split(" ").forEach((e=>{i.eventsListeners[e]||(i.eventsListeners[e]=[]),i.eventsListeners[e][a](t)})),i},once(e,t,n){const i=this;if(!i.eventsListeners||i.destroyed)return i;if("function"!=typeof t)return i;function a(){i.off(e,a),a.__emitterProxy&&delete a.__emitterProxy;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];t.apply(i,r)}return a.__emitterProxy=t,i.on(e,a,n)},onAny(e,t){const n=this;if(!n.eventsListeners||n.destroyed)return n;if("function"!=typeof e)return n;const i=t?"unshift":"push";return n.eventsAnyListeners.indexOf(e)<0&&n.eventsAnyListeners[i](e),n},offAny(e){const t=this;if(!t.eventsListeners||t.destroyed)return t;if(!t.eventsAnyListeners)return t;const n=t.eventsAnyListeners.indexOf(e);return n>=0&&t.eventsAnyListeners.splice(n,1),t},off(e,t){const n=this;return!n.eventsListeners||n.destroyed?n:n.eventsListeners?(e.split(" ").forEach((e=>{void 0===t?n.eventsListeners[e]=[]:n.eventsListeners[e]&&n.eventsListeners[e].forEach(((i,a)=>{(i===t||i.__emitterProxy&&i.__emitterProxy===t)&&n.eventsListeners[e].splice(a,1)}))})),n):n},emit(){const e=this;if(!e.eventsListeners||e.destroyed)return e;if(!e.eventsListeners)return e;let t,n,i;for(var a=arguments.length,r=new Array(a),o=0;o<a;o++)r[o]=arguments[o];"string"==typeof r[0]||Array.isArray(r[0])?(t=r[0],n=r.slice(1,r.length),i=e):(t=r[0].events,n=r[0].data,i=r[0].context||e),n.unshift(i);return(Array.isArray(t)?t:t.split(" ")).forEach((t=>{e.eventsAnyListeners&&e.eventsAnyListeners.length&&e.eventsAnyListeners.forEach((e=>{e.apply(i,[t,...n])})),e.eventsListeners&&e.eventsListeners[t]&&e.eventsListeners[t].forEach((e=>{e.apply(i,n)}))})),e}};const uC=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};const cC=(e,t,n)=>{t&&!e.classList.contains(n)?e.classList.add(n):!t&&e.classList.contains(n)&&e.classList.remove(n)};const hC=(e,t)=>{if(!e||e.destroyed||!e.params)return;const n=t.closest(e.isElement?"swiper-slide":`.${e.params.slideClass}`);if(n){let t=n.querySelector(`.${e.params.lazyPreloaderClass}`);!t&&e.isElement&&(n.shadowRoot?t=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`):requestAnimationFrame((()=>{n.shadowRoot&&(t=n.shadowRoot.querySelector(`.${e.params.lazyPreloaderClass}`),t&&t.remove())}))),t&&t.remove()}},mC=(e,t)=>{if(!e.slides[t])return;const n=e.slides[t].querySelector('[loading="lazy"]');n&&n.removeAttribute("loading")},fC=e=>{if(!e||e.destroyed||!e.params)return;let t=e.params.lazyPreloadPrevNext;const n=e.slides.length;if(!n||!t||t<0)return;t=Math.min(t,n);const i="auto"===e.params.slidesPerView?e.slidesPerViewDynamic():Math.ceil(e.params.slidesPerView),a=e.activeIndex;if(e.params.grid&&e.params.grid.rows>1){const n=a,r=[n-t];return r.push(...Array.from({length:t}).map(((e,t)=>n+i+t))),void e.slides.forEach(((t,n)=>{r.includes(t.column)&&mC(e,n)}))}const r=a+i-1;if(e.params.rewind||e.params.loop)for(let i=a-t;i<=r+t;i+=1){const t=(i%n+n)%n;(t<a||t>r)&&mC(e,t)}else for(let i=Math.max(a-t,0);i<=Math.min(r+t,n-1);i+=1)i!==a&&(i>r||i<a)&&mC(e,i)};var gC={updateSize:function(){const e=this;let t,n;const i=e.el;t=void 0!==e.params.width&&null!==e.params.width?e.params.width:i.clientWidth,n=void 0!==e.params.height&&null!==e.params.height?e.params.height:i.clientHeight,0===t&&e.isHorizontal()||0===n&&e.isVertical()||(t=t-parseInt(Qx(i,"padding-left")||0,10)-parseInt(Qx(i,"padding-right")||0,10),n=n-parseInt(Qx(i,"padding-top")||0,10)-parseInt(Qx(i,"padding-bottom")||0,10),Number.isNaN(t)&&(t=0),Number.isNaN(n)&&(n=0),Object.assign(e,{width:t,height:n,size:e.isHorizontal()?t:n}))},updateSlides:function(){const e=this;function t(t,n){return parseFloat(t.getPropertyValue(e.getDirectionLabel(n))||0)}const n=e.params,{wrapperEl:i,slidesEl:a,size:r,rtlTranslate:o,wrongRTL:s}=e,d=e.virtual&&n.virtual.enabled,l=d?e.virtual.slides.length:e.slides.length,u=Kx(a,`.${e.params.slideClass}, swiper-slide`),c=d?e.virtual.slides.length:u.length;let h=[];const m=[],f=[];let g=n.slidesOffsetBefore;"function"==typeof g&&(g=n.slidesOffsetBefore.call(e));let p=n.slidesOffsetAfter;"function"==typeof p&&(p=n.slidesOffsetAfter.call(e));const v=e.snapGrid.length,y=e.slidesGrid.length;let b=n.spaceBetween,w=-g,k=0,S=0;if(void 0===r)return;"string"==typeof b&&b.indexOf("%")>=0?b=parseFloat(b.replace("%",""))/100*r:"string"==typeof b&&(b=parseFloat(b)),e.virtualSize=-b,u.forEach((e=>{o?e.style.marginLeft="":e.style.marginRight="",e.style.marginBottom="",e.style.marginTop=""})),n.centeredSlides&&n.cssMode&&(Yx(i,"--swiper-centered-offset-before",""),Yx(i,"--swiper-centered-offset-after",""));const M=n.grid&&n.grid.rows>1&&e.grid;let T;M?e.grid.initSlides(u):e.grid&&e.grid.unsetSlides();const E="auto"===n.slidesPerView&&n.breakpoints&&Object.keys(n.breakpoints).filter((e=>void 0!==n.breakpoints[e].slidesPerView)).length>0;for(let i=0;i<c;i+=1){let a;if(T=0,u[i]&&(a=u[i]),M&&e.grid.updateSlide(i,a,u),!u[i]||"none"!==Qx(a,"display")){if("auto"===n.slidesPerView){E&&(u[i].style[e.getDirectionLabel("width")]="");const r=getComputedStyle(a),o=a.style.transform,s=a.style.webkitTransform;if(o&&(a.style.transform="none"),s&&(a.style.webkitTransform="none"),n.roundLengths)T=e.isHorizontal()?tC(a,"width"):tC(a,"height");else{const e=t(r,"width"),n=t(r,"padding-left"),i=t(r,"padding-right"),o=t(r,"margin-left"),s=t(r,"margin-right"),d=r.getPropertyValue("box-sizing");if(d&&"border-box"===d)T=e+o+s;else{const{clientWidth:t,offsetWidth:r}=a;T=e+n+i+o+s+(r-t)}}o&&(a.style.transform=o),s&&(a.style.webkitTransform=s),n.roundLengths&&(T=Math.floor(T))}else T=(r-(n.slidesPerView-1)*b)/n.slidesPerView,n.roundLengths&&(T=Math.floor(T)),u[i]&&(u[i].style[e.getDirectionLabel("width")]=`${T}px`);u[i]&&(u[i].swiperSlideSize=T),f.push(T),n.centeredSlides?(w=w+T/2+k/2+b,0===k&&0!==i&&(w=w-r/2-b),0===i&&(w=w-r/2-b),Math.abs(w)<.001&&(w=0),n.roundLengths&&(w=Math.floor(w)),S%n.slidesPerGroup==0&&h.push(w),m.push(w)):(n.roundLengths&&(w=Math.floor(w)),(S-Math.min(e.params.slidesPerGroupSkip,S))%e.params.slidesPerGroup==0&&h.push(w),m.push(w),w=w+T+b),e.virtualSize+=T+b,k=T,S+=1}}if(e.virtualSize=Math.max(e.virtualSize,r)+p,o&&s&&("slide"===n.effect||"coverflow"===n.effect)&&(i.style.width=`${e.virtualSize+b}px`),n.setWrapperSize&&(i.style[e.getDirectionLabel("width")]=`${e.virtualSize+b}px`),M&&e.grid.updateWrapperSize(T,h),!n.centeredSlides){const t=[];for(let i=0;i<h.length;i+=1){let a=h[i];n.roundLengths&&(a=Math.floor(a)),h[i]<=e.virtualSize-r&&t.push(a)}h=t,Math.floor(e.virtualSize-r)-Math.floor(h[h.length-1])>1&&h.push(e.virtualSize-r)}if(d&&n.loop){const t=f[0]+b;if(n.slidesPerGroup>1){const i=Math.ceil((e.virtual.slidesBefore+e.virtual.slidesAfter)/n.slidesPerGroup),a=t*n.slidesPerGroup;for(let e=0;e<i;e+=1)h.push(h[h.length-1]+a)}for(let i=0;i<e.virtual.slidesBefore+e.virtual.slidesAfter;i+=1)1===n.slidesPerGroup&&h.push(h[h.length-1]+t),m.push(m[m.length-1]+t),e.virtualSize+=t}if(0===h.length&&(h=[0]),0!==b){const t=e.isHorizontal()&&o?"marginLeft":e.getDirectionLabel("marginRight");u.filter(((e,t)=>!(n.cssMode&&!n.loop)||t!==u.length-1)).forEach((e=>{e.style[t]=`${b}px`}))}if(n.centeredSlides&&n.centeredSlidesBounds){let e=0;f.forEach((t=>{e+=t+(b||0)})),e-=b;const t=e>r?e-r:0;h=h.map((e=>e<=0?-g:e>t?t+p:e))}if(n.centerInsufficientSlides){let e=0;f.forEach((t=>{e+=t+(b||0)})),e-=b;const t=(n.slidesOffsetBefore||0)+(n.slidesOffsetAfter||0);if(e+t<r){const n=(r-e-t)/2;h.forEach(((e,t)=>{h[t]=e-n})),m.forEach(((e,t)=>{m[t]=e+n}))}}if(Object.assign(e,{slides:u,snapGrid:h,slidesGrid:m,slidesSizesGrid:f}),n.centeredSlides&&n.cssMode&&!n.centeredSlidesBounds){Yx(i,"--swiper-centered-offset-before",-h[0]+"px"),Yx(i,"--swiper-centered-offset-after",e.size/2-f[f.length-1]/2+"px");const t=-e.snapGrid[0],n=-e.slidesGrid[0];e.snapGrid=e.snapGrid.map((e=>e+t)),e.slidesGrid=e.slidesGrid.map((e=>e+n))}if(c!==l&&e.emit("slidesLengthChange"),h.length!==v&&(e.params.watchOverflow&&e.checkOverflow(),e.emit("snapGridLengthChange")),m.length!==y&&e.emit("slidesGridLengthChange"),n.watchSlidesProgress&&e.updateSlidesOffset(),e.emit("slidesUpdated"),!(d||n.cssMode||"slide"!==n.effect&&"fade"!==n.effect)){const t=`${n.containerModifierClass}backface-hidden`,i=e.el.classList.contains(t);c<=n.maxBackfaceHiddenSlides?i||e.el.classList.add(t):i&&e.el.classList.remove(t)}},updateAutoHeight:function(e){const t=this,n=[],i=t.virtual&&t.params.virtual.enabled;let a,r=0;"number"==typeof e?t.setTransition(e):!0===e&&t.setTransition(t.params.speed);const o=e=>i?t.slides[t.getSlideIndexByData(e)]:t.slides[e];if("auto"!==t.params.slidesPerView&&t.params.slidesPerView>1)if(t.params.centeredSlides)(t.visibleSlides||[]).forEach((e=>{n.push(e)}));else for(a=0;a<Math.ceil(t.params.slidesPerView);a+=1){const e=t.activeIndex+a;if(e>t.slides.length&&!i)break;n.push(o(e))}else n.push(o(t.activeIndex));for(a=0;a<n.length;a+=1)if(void 0!==n[a]){const e=n[a].offsetHeight;r=e>r?e:r}(r||0===r)&&(t.wrapperEl.style.height=`${r}px`)},updateSlidesOffset:function(){const e=this,t=e.slides,n=e.isElement?e.isHorizontal()?e.wrapperEl.offsetLeft:e.wrapperEl.offsetTop:0;for(let i=0;i<t.length;i+=1)t[i].swiperSlideOffset=(e.isHorizontal()?t[i].offsetLeft:t[i].offsetTop)-n-e.cssOverflowAdjustment()},updateSlidesProgress:function(e){void 0===e&&(e=this&&this.translate||0);const t=this,n=t.params,{slides:i,rtlTranslate:a,snapGrid:r}=t;if(0===i.length)return;void 0===i[0].swiperSlideOffset&&t.updateSlidesOffset();let o=-e;a&&(o=e),t.visibleSlidesIndexes=[],t.visibleSlides=[];let s=n.spaceBetween;"string"==typeof s&&s.indexOf("%")>=0?s=parseFloat(s.replace("%",""))/100*t.size:"string"==typeof s&&(s=parseFloat(s));for(let e=0;e<i.length;e+=1){const d=i[e];let l=d.swiperSlideOffset;n.cssMode&&n.centeredSlides&&(l-=i[0].swiperSlideOffset);const u=(o+(n.centeredSlides?t.minTranslate():0)-l)/(d.swiperSlideSize+s),c=(o-r[0]+(n.centeredSlides?t.minTranslate():0)-l)/(d.swiperSlideSize+s),h=-(o-l),m=h+t.slidesSizesGrid[e],f=h>=0&&h<=t.size-t.slidesSizesGrid[e],g=h>=0&&h<t.size-1||m>1&&m<=t.size||h<=0&&m>=t.size;g&&(t.visibleSlides.push(d),t.visibleSlidesIndexes.push(e)),uC(d,g,n.slideVisibleClass),uC(d,f,n.slideFullyVisibleClass),d.progress=a?-u:u,d.originalProgress=a?-c:c}},updateProgress:function(e){const t=this;if(void 0===e){const n=t.rtlTranslate?-1:1;e=t&&t.translate&&t.translate*n||0}const n=t.params,i=t.maxTranslate()-t.minTranslate();let{progress:a,isBeginning:r,isEnd:o,progressLoop:s}=t;const d=r,l=o;if(0===i)a=0,r=!0,o=!0;else{a=(e-t.minTranslate())/i;const n=Math.abs(e-t.minTranslate())<1,s=Math.abs(e-t.maxTranslate())<1;r=n||a<=0,o=s||a>=1,n&&(a=0),s&&(a=1)}if(n.loop){const n=t.getSlideIndexByData(0),i=t.getSlideIndexByData(t.slides.length-1),a=t.slidesGrid[n],r=t.slidesGrid[i],o=t.slidesGrid[t.slidesGrid.length-1],d=Math.abs(e);s=d>=a?(d-a)/o:(d+o-r)/o,s>1&&(s-=1)}Object.assign(t,{progress:a,progressLoop:s,isBeginning:r,isEnd:o}),(n.watchSlidesProgress||n.centeredSlides&&n.autoHeight)&&t.updateSlidesProgress(e),r&&!d&&t.emit("reachBeginning toEdge"),o&&!l&&t.emit("reachEnd toEdge"),(d&&!r||l&&!o)&&t.emit("fromEdge"),t.emit("progress",a)},updateSlidesClasses:function(){const e=this,{slides:t,params:n,slidesEl:i,activeIndex:a}=e,r=e.virtual&&n.virtual.enabled,o=e.grid&&n.grid&&n.grid.rows>1,s=e=>Kx(i,`.${n.slideClass}${e}, swiper-slide${e}`)[0];let d,l,u;if(r)if(n.loop){let t=a-e.virtual.slidesBefore;t<0&&(t=e.virtual.slides.length+t),t>=e.virtual.slides.length&&(t-=e.virtual.slides.length),d=s(`[data-swiper-slide-index="${t}"]`)}else d=s(`[data-swiper-slide-index="${a}"]`);else o?(d=t.filter((e=>e.column===a))[0],u=t.filter((e=>e.column===a+1))[0],l=t.filter((e=>e.column===a-1))[0]):d=t[a];d&&(o||(u=function(e,t){const n=[];for(;e.nextElementSibling;){const i=e.nextElementSibling;t?i.matches(t)&&n.push(i):n.push(i),e=i}return n}(d,`.${n.slideClass}, swiper-slide`)[0],n.loop&&!u&&(u=t[0]),l=function(e,t){const n=[];for(;e.previousElementSibling;){const i=e.previousElementSibling;t?i.matches(t)&&n.push(i):n.push(i),e=i}return n}(d,`.${n.slideClass}, swiper-slide`)[0],n.loop&&0===!l&&(l=t[t.length-1]))),t.forEach((e=>{cC(e,e===d,n.slideActiveClass),cC(e,e===u,n.slideNextClass),cC(e,e===l,n.slidePrevClass)})),e.emitSlidesClasses()},updateActiveIndex:function(e){const t=this,n=t.rtlTranslate?t.translate:-t.translate,{snapGrid:i,params:a,activeIndex:r,realIndex:o,snapIndex:s}=t;let d,l=e;const u=e=>{let n=e-t.virtual.slidesBefore;return n<0&&(n=t.virtual.slides.length+n),n>=t.virtual.slides.length&&(n-=t.virtual.slides.length),n};if(void 0===l&&(l=function(e){const{slidesGrid:t,params:n}=e,i=e.rtlTranslate?e.translate:-e.translate;let a;for(let e=0;e<t.length;e+=1)void 0!==t[e+1]?i>=t[e]&&i<t[e+1]-(t[e+1]-t[e])/2?a=e:i>=t[e]&&i<t[e+1]&&(a=e+1):i>=t[e]&&(a=e);return n.normalizeSlideIndex&&(a<0||void 0===a)&&(a=0),a}(t)),i.indexOf(n)>=0)d=i.indexOf(n);else{const e=Math.min(a.slidesPerGroupSkip,l);d=e+Math.floor((l-e)/a.slidesPerGroup)}if(d>=i.length&&(d=i.length-1),l===r&&!t.params.loop)return void(d!==s&&(t.snapIndex=d,t.emit("snapIndexChange")));if(l===r&&t.params.loop&&t.virtual&&t.params.virtual.enabled)return void(t.realIndex=u(l));const c=t.grid&&a.grid&&a.grid.rows>1;let h;if(t.virtual&&a.virtual.enabled&&a.loop)h=u(l);else if(c){const e=t.slides.filter((e=>e.column===l))[0];let n=parseInt(e.getAttribute("data-swiper-slide-index"),10);Number.isNaN(n)&&(n=Math.max(t.slides.indexOf(e),0)),h=Math.floor(n/a.grid.rows)}else if(t.slides[l]){const e=t.slides[l].getAttribute("data-swiper-slide-index");h=e?parseInt(e,10):l}else h=l;Object.assign(t,{previousSnapIndex:s,snapIndex:d,previousRealIndex:o,realIndex:h,previousIndex:r,activeIndex:l}),t.initialized&&fC(t),t.emit("activeIndexChange"),t.emit("snapIndexChange"),(t.initialized||t.params.runCallbacksOnInit)&&(o!==h&&t.emit("realIndexChange"),t.emit("slideChange"))},updateClickedSlide:function(e,t){const n=this,i=n.params;let a=e.closest(`.${i.slideClass}, swiper-slide`);!a&&n.isElement&&t&&t.length>1&&t.includes(e)&&[...t.slice(t.indexOf(e)+1,t.length)].forEach((e=>{!a&&e.matches&&e.matches(`.${i.slideClass}, swiper-slide`)&&(a=e)}));let r,o=!1;if(a)for(let e=0;e<n.slides.length;e+=1)if(n.slides[e]===a){o=!0,r=e;break}if(!a||!o)return n.clickedSlide=void 0,void(n.clickedIndex=void 0);n.clickedSlide=a,n.virtual&&n.params.virtual.enabled?n.clickedIndex=parseInt(a.getAttribute("data-swiper-slide-index"),10):n.clickedIndex=r,i.slideToClickedSlide&&void 0!==n.clickedIndex&&n.clickedIndex!==n.activeIndex&&n.slideToClickedSlide()}};var pC={getTranslate:function(e){void 0===e&&(e=this.isHorizontal()?"x":"y");const{params:t,rtlTranslate:n,translate:i,wrapperEl:a}=this;if(t.virtualTranslate)return n?-i:i;if(t.cssMode)return i;let r=Bx(a,e);return r+=this.cssOverflowAdjustment(),n&&(r=-r),r||0},setTranslate:function(e,t){const n=this,{rtlTranslate:i,params:a,wrapperEl:r,progress:o}=n;let s,d=0,l=0;n.isHorizontal()?d=i?-e:e:l=e,a.roundLengths&&(d=Math.floor(d),l=Math.floor(l)),n.previousTranslate=n.translate,n.translate=n.isHorizontal()?d:l,a.cssMode?r[n.isHorizontal()?"scrollLeft":"scrollTop"]=n.isHorizontal()?-d:-l:a.virtualTranslate||(n.isHorizontal()?d-=n.cssOverflowAdjustment():l-=n.cssOverflowAdjustment(),r.style.transform=`translate3d(${d}px, ${l}px, 0px)`);const u=n.maxTranslate()-n.minTranslate();s=0===u?0:(e-n.minTranslate())/u,s!==o&&n.updateProgress(e),n.emit("setTranslate",n.translate,t)},minTranslate:function(){return-this.snapGrid[0]},maxTranslate:function(){return-this.snapGrid[this.snapGrid.length-1]},translateTo:function(e,t,n,i,a){void 0===e&&(e=0),void 0===t&&(t=this.params.speed),void 0===n&&(n=!0),void 0===i&&(i=!0);const r=this,{params:o,wrapperEl:s}=r;if(r.animating&&o.preventInteractionOnTransition)return!1;const d=r.minTranslate(),l=r.maxTranslate();let u;if(u=i&&e>d?d:i&&e<l?l:e,r.updateProgress(u),o.cssMode){const e=r.isHorizontal();if(0===t)s[e?"scrollLeft":"scrollTop"]=-u;else{if(!r.support.smoothScroll)return Vx({swiper:r,targetPosition:-u,side:e?"left":"top"}),!0;s.scrollTo({[e?"left":"top"]:-u,behavior:"smooth"})}return!0}return 0===t?(r.setTransition(0),r.setTranslate(u),n&&(r.emit("beforeTransitionStart",t,a),r.emit("transitionEnd"))):(r.setTransition(t),r.setTranslate(u),n&&(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,n&&r.emit("transitionEnd"))}),r.wrapperEl.addEventListener("transitionend",r.onTranslateToWrapperTransitionEnd))),!0}};function vC(e){let{swiper:t,runCallbacks:n,direction:i,step:a}=e;const{activeIndex:r,previousIndex:o}=t;let s=i;if(s||(s=r>o?"next":r<o?"prev":"reset"),t.emit(`transition${a}`),n&&r!==o){if("reset"===s)return void t.emit(`slideResetTransition${a}`);t.emit(`slideChangeTransition${a}`),"next"===s?t.emit(`slideNextTransition${a}`):t.emit(`slidePrevTransition${a}`)}}var yC={slideTo:function(e,t,n,i,a){void 0===e&&(e=0),void 0===n&&(n=!0),"string"==typeof e&&(e=parseInt(e,10));const r=this;let o=e;o<0&&(o=0);const{params:s,snapGrid:d,slidesGrid:l,previousIndex:u,activeIndex:c,rtlTranslate:h,wrapperEl:m,enabled:f}=r;if(!f&&!i&&!a||r.destroyed||r.animating&&s.preventInteractionOnTransition)return!1;void 0===t&&(t=r.params.speed);const g=Math.min(r.params.slidesPerGroupSkip,o);let p=g+Math.floor((o-g)/r.params.slidesPerGroup);p>=d.length&&(p=d.length-1);const v=-d[p];if(s.normalizeSlideIndex)for(let e=0;e<l.length;e+=1){const t=-Math.floor(100*v),n=Math.floor(100*l[e]),i=Math.floor(100*l[e+1]);void 0!==l[e+1]?t>=n&&t<i-(i-n)/2?o=e:t>=n&&t<i&&(o=e+1):t>=n&&(o=e)}if(r.initialized&&o!==c){if(!r.allowSlideNext&&(h?v>r.translate&&v>r.minTranslate():v<r.translate&&v<r.minTranslate()))return!1;if(!r.allowSlidePrev&&v>r.translate&&v>r.maxTranslate()&&(c||0)!==o)return!1}let y;o!==(u||0)&&n&&r.emit("beforeSlideChangeStart"),r.updateProgress(v),y=o>c?"next":o<c?"prev":"reset";const b=r.virtual&&r.params.virtual.enabled;if(!(b&&a)&&(h&&-v===r.translate||!h&&v===r.translate))return r.updateActiveIndex(o),s.autoHeight&&r.updateAutoHeight(),r.updateSlidesClasses(),"slide"!==s.effect&&r.setTranslate(v),"reset"!==y&&(r.transitionStart(n,y),r.transitionEnd(n,y)),!1;if(s.cssMode){const e=r.isHorizontal(),n=h?v:-v;if(0===t)b&&(r.wrapperEl.style.scrollSnapType="none",r._immediateVirtual=!0),b&&!r._cssModeVirtualInitialSet&&r.params.initialSlide>0?(r._cssModeVirtualInitialSet=!0,requestAnimationFrame((()=>{m[e?"scrollLeft":"scrollTop"]=n}))):m[e?"scrollLeft":"scrollTop"]=n,b&&requestAnimationFrame((()=>{r.wrapperEl.style.scrollSnapType="",r._immediateVirtual=!1}));else{if(!r.support.smoothScroll)return Vx({swiper:r,targetPosition:n,side:e?"left":"top"}),!0;m.scrollTo({[e?"left":"top"]:n,behavior:"smooth"})}return!0}return r.setTransition(t),r.setTranslate(v),r.updateActiveIndex(o),r.updateSlidesClasses(),r.emit("beforeTransitionStart",t,i),r.transitionStart(n,y),0===t?r.transitionEnd(n,y):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(n,y))}),r.wrapperEl.addEventListener("transitionend",r.onSlideToWrapperTransitionEnd)),!0},slideToLoop:function(e,t,n,i){if(void 0===e&&(e=0),void 0===n&&(n=!0),"string"==typeof e){e=parseInt(e,10)}const a=this;if(a.destroyed)return;void 0===t&&(t=a.params.speed);const r=a.grid&&a.params.grid&&a.params.grid.rows>1;let o=e;if(a.params.loop)if(a.virtual&&a.params.virtual.enabled)o+=a.virtual.slidesBefore;else{let e;if(r){const t=o*a.params.grid.rows;e=a.slides.filter((e=>1*e.getAttribute("data-swiper-slide-index")===t))[0].column}else e=a.getSlideIndexByData(o);const t=r?Math.ceil(a.slides.length/a.params.grid.rows):a.slides.length,{centeredSlides:n}=a.params;let s=a.params.slidesPerView;"auto"===s?s=a.slidesPerViewDynamic():(s=Math.ceil(parseFloat(a.params.slidesPerView,10)),n&&s%2==0&&(s+=1));let d=t-e<s;if(n&&(d=d||e<Math.ceil(s/2)),i&&n&&"auto"!==a.params.slidesPerView&&!r&&(d=!1),d){const i=n?e<a.activeIndex?"prev":"next":e-a.activeIndex-1<a.params.slidesPerView?"next":"prev";a.loopFix({direction:i,slideTo:!0,activeSlideIndex:"next"===i?e+1:e-t+1,slideRealIndex:"next"===i?a.realIndex:void 0})}if(r){const e=o*a.params.grid.rows;o=a.slides.filter((t=>1*t.getAttribute("data-swiper-slide-index")===e))[0].column}else o=a.getSlideIndexByData(o)}return requestAnimationFrame((()=>{a.slideTo(o,t,n,i)})),a},slideNext:function(e,t,n){void 0===t&&(t=!0);const i=this,{enabled:a,params:r,animating:o}=i;if(!a||i.destroyed)return i;void 0===e&&(e=i.params.speed);let s=r.slidesPerGroup;"auto"===r.slidesPerView&&1===r.slidesPerGroup&&r.slidesPerGroupAuto&&(s=Math.max(i.slidesPerViewDynamic("current",!0),1));const d=i.activeIndex<r.slidesPerGroupSkip?1:s,l=i.virtual&&r.virtual.enabled;if(r.loop){if(o&&!l&&r.loopPreventsSliding)return!1;if(i.loopFix({direction:"next"}),i._clientLeft=i.wrapperEl.clientLeft,i.activeIndex===i.slides.length-1&&r.cssMode)return requestAnimationFrame((()=>{i.slideTo(i.activeIndex+d,e,t,n)})),!0}return r.rewind&&i.isEnd?i.slideTo(0,e,t,n):i.slideTo(i.activeIndex+d,e,t,n)},slidePrev:function(e,t,n){void 0===t&&(t=!0);const i=this,{params:a,snapGrid:r,slidesGrid:o,rtlTranslate:s,enabled:d,animating:l}=i;if(!d||i.destroyed)return i;void 0===e&&(e=i.params.speed);const u=i.virtual&&a.virtual.enabled;if(a.loop){if(l&&!u&&a.loopPreventsSliding)return!1;i.loopFix({direction:"prev"}),i._clientLeft=i.wrapperEl.clientLeft}function c(e){return e<0?-Math.floor(Math.abs(e)):Math.floor(e)}const h=c(s?i.translate:-i.translate),m=r.map((e=>c(e)));let f=r[m.indexOf(h)-1];if(void 0===f&&a.cssMode){let e;r.forEach(((t,n)=>{h>=t&&(e=n)})),void 0!==e&&(f=r[e>0?e-1:e])}let g=0;if(void 0!==f&&(g=o.indexOf(f),g<0&&(g=i.activeIndex-1),"auto"===a.slidesPerView&&1===a.slidesPerGroup&&a.slidesPerGroupAuto&&(g=g-i.slidesPerViewDynamic("previous",!0)+1,g=Math.max(g,0))),a.rewind&&i.isBeginning){const a=i.params.virtual&&i.params.virtual.enabled&&i.virtual?i.virtual.slides.length-1:i.slides.length-1;return i.slideTo(a,e,t,n)}return a.loop&&0===i.activeIndex&&a.cssMode?(requestAnimationFrame((()=>{i.slideTo(g,e,t,n)})),!0):i.slideTo(g,e,t,n)},slideReset:function(e,t,n){void 0===t&&(t=!0);const i=this;if(!i.destroyed)return void 0===e&&(e=i.params.speed),i.slideTo(i.activeIndex,e,t,n)},slideToClosest:function(e,t,n,i){void 0===t&&(t=!0),void 0===i&&(i=.5);const a=this;if(a.destroyed)return;void 0===e&&(e=a.params.speed);let r=a.activeIndex;const o=Math.min(a.params.slidesPerGroupSkip,r),s=o+Math.floor((r-o)/a.params.slidesPerGroup),d=a.rtlTranslate?a.translate:-a.translate;if(d>=a.snapGrid[s]){const e=a.snapGrid[s];d-e>(a.snapGrid[s+1]-e)*i&&(r+=a.params.slidesPerGroup)}else{const e=a.snapGrid[s-1];d-e<=(a.snapGrid[s]-e)*i&&(r-=a.params.slidesPerGroup)}return r=Math.max(r,0),r=Math.min(r,a.slidesGrid.length-1),a.slideTo(r,e,t,n)},slideToClickedSlide:function(){const e=this;if(e.destroyed)return;const{params:t,slidesEl:n}=e,i="auto"===t.slidesPerView?e.slidesPerViewDynamic():t.slidesPerView;let a,r=e.clickedIndex;const o=e.isElement?"swiper-slide":`.${t.slideClass}`;if(t.loop){if(e.animating)return;a=parseInt(e.clickedSlide.getAttribute("data-swiper-slide-index"),10),t.centeredSlides?r<e.loopedSlides-i/2||r>e.slides.length-e.loopedSlides+i/2?(e.loopFix(),r=e.getSlideIndex(Kx(n,`${o}[data-swiper-slide-index="${a}"]`)[0]),Hx((()=>{e.slideTo(r)}))):e.slideTo(r):r>e.slides.length-i?(e.loopFix(),r=e.getSlideIndex(Kx(n,`${o}[data-swiper-slide-index="${a}"]`)[0]),Hx((()=>{e.slideTo(r)}))):e.slideTo(r)}else e.slideTo(r)}};var bC={loopCreate:function(e){const t=this,{params:n,slidesEl:i}=t;if(!n.loop||t.virtual&&t.params.virtual.enabled)return;const a=()=>{Kx(i,`.${n.slideClass}, swiper-slide`).forEach(((e,t)=>{e.setAttribute("data-swiper-slide-index",t)}))},r=t.grid&&n.grid&&n.grid.rows>1,o=n.slidesPerGroup*(r?n.grid.rows:1),s=t.slides.length%o!=0,d=r&&t.slides.length%n.grid.rows!=0,l=e=>{for(let i=0;i<e;i+=1){const e=t.isElement?Jx("swiper-slide",[n.slideBlankClass]):Jx("div",[n.slideClass,n.slideBlankClass]);t.slidesEl.append(e)}};if(s){if(n.loopAddBlankSlides){l(o-t.slides.length%o),t.recalcSlides(),t.updateSlides()}else qx("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)");a()}else if(d){if(n.loopAddBlankSlides){l(n.grid.rows-t.slides.length%n.grid.rows),t.recalcSlides(),t.updateSlides()}else qx("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)");a()}else a();t.loopFix({slideRealIndex:e,direction:n.centeredSlides?void 0:"next"})},loopFix:function(e){let{slideRealIndex:t,slideTo:n=!0,direction:i,setTranslate:a,activeSlideIndex:r,byController:o,byMousewheel:s}=void 0===e?{}:e;const d=this;if(!d.params.loop)return;d.emit("beforeLoopFix");const{slides:l,allowSlidePrev:u,allowSlideNext:c,slidesEl:h,params:m}=d,{centeredSlides:f}=m;if(d.allowSlidePrev=!0,d.allowSlideNext=!0,d.virtual&&m.virtual.enabled)return n&&(m.centeredSlides||0!==d.snapIndex?m.centeredSlides&&d.snapIndex<m.slidesPerView?d.slideTo(d.virtual.slides.length+d.snapIndex,0,!1,!0):d.snapIndex===d.snapGrid.length-1&&d.slideTo(d.virtual.slidesBefore,0,!1,!0):d.slideTo(d.virtual.slides.length,0,!1,!0)),d.allowSlidePrev=u,d.allowSlideNext=c,void d.emit("loopFix");let g=m.slidesPerView;"auto"===g?g=d.slidesPerViewDynamic():(g=Math.ceil(parseFloat(m.slidesPerView,10)),f&&g%2==0&&(g+=1));const p=m.slidesPerGroupAuto?g:m.slidesPerGroup;let v=p;v%p!=0&&(v+=p-v%p),v+=m.loopAdditionalSlides,d.loopedSlides=v;const y=d.grid&&m.grid&&m.grid.rows>1;l.length<g+v?qx("Swiper Loop Warning: The number of slides is not enough for loop mode, it will be disabled and not function properly. You need to add more slides (or make duplicates) or lower the values of slidesPerView and slidesPerGroup parameters"):y&&"row"===m.grid.fill&&qx("Swiper Loop Warning: Loop mode is not compatible with grid.fill = `row`");const b=[],w=[];let k=d.activeIndex;void 0===r?r=d.getSlideIndex(l.filter((e=>e.classList.contains(m.slideActiveClass)))[0]):k=r;const S="next"===i||!i,M="prev"===i||!i;let T=0,E=0;const P=y?Math.ceil(l.length/m.grid.rows):l.length,A=(y?l[r].column:r)+(f&&void 0===a?-g/2+.5:0);if(A<v){T=Math.max(v-A,p);for(let e=0;e<v-A;e+=1){const t=e-Math.floor(e/P)*P;if(y){const e=P-t-1;for(let t=l.length-1;t>=0;t-=1)l[t].column===e&&b.push(t)}else b.push(P-t-1)}}else if(A+g>P-v){E=Math.max(A-(P-2*v),p);for(let e=0;e<E;e+=1){const t=e-Math.floor(e/P)*P;y?l.forEach(((e,n)=>{e.column===t&&w.push(n)})):w.push(t)}}if(d.__preventObserver__=!0,requestAnimationFrame((()=>{d.__preventObserver__=!1})),M&&b.forEach((e=>{l[e].swiperLoopMoveDOM=!0,h.prepend(l[e]),l[e].swiperLoopMoveDOM=!1})),S&&w.forEach((e=>{l[e].swiperLoopMoveDOM=!0,h.append(l[e]),l[e].swiperLoopMoveDOM=!1})),d.recalcSlides(),"auto"===m.slidesPerView?d.updateSlides():y&&(b.length>0&&M||w.length>0&&S)&&d.slides.forEach(((e,t)=>{d.grid.updateSlide(t,e,d.slides)})),m.watchSlidesProgress&&d.updateSlidesOffset(),n)if(b.length>0&&M){if(void 0===t){const e=d.slidesGrid[k],t=d.slidesGrid[k+T]-e;s?d.setTranslate(d.translate-t):(d.slideTo(k+Math.ceil(T),0,!1,!0),a&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-t,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-t))}else if(a){const e=y?b.length/m.grid.rows:b.length;d.slideTo(d.activeIndex+e,0,!1,!0),d.touchEventsData.currentTranslate=d.translate}}else if(w.length>0&&S)if(void 0===t){const e=d.slidesGrid[k],t=d.slidesGrid[k-E]-e;s?d.setTranslate(d.translate-t):(d.slideTo(k-E,0,!1,!0),a&&(d.touchEventsData.startTranslate=d.touchEventsData.startTranslate-t,d.touchEventsData.currentTranslate=d.touchEventsData.currentTranslate-t))}else{const e=y?w.length/m.grid.rows:w.length;d.slideTo(d.activeIndex-e,0,!1,!0)}if(d.allowSlidePrev=u,d.allowSlideNext=c,d.controller&&d.controller.control&&!o){const e={slideRealIndex:t,direction:i,setTranslate:a,activeSlideIndex:r,byController:!0};Array.isArray(d.controller.control)?d.controller.control.forEach((t=>{!t.destroyed&&t.params.loop&&t.loopFix({...e,slideTo:t.params.slidesPerView===m.slidesPerView&&n})})):d.controller.control instanceof d.constructor&&d.controller.control.params.loop&&d.controller.control.loopFix({...e,slideTo:d.controller.control.params.slidesPerView===m.slidesPerView&&n})}d.emit("loopFix")},loopDestroy:function(){const e=this,{params:t,slidesEl:n}=e;if(!t.loop||e.virtual&&e.params.virtual.enabled)return;e.recalcSlides();const i=[];e.slides.forEach((e=>{const t=void 0===e.swiperSlideIndex?1*e.getAttribute("data-swiper-slide-index"):e.swiperSlideIndex;i[t]=e})),e.slides.forEach((e=>{e.removeAttribute("data-swiper-slide-index")})),i.forEach((e=>{n.append(e)})),e.recalcSlides(),e.slideTo(e.realIndex,0)}};var wC={setGrabCursor:function(e){const t=this;if(!t.params.simulateTouch||t.params.watchOverflow&&t.isLocked||t.params.cssMode)return;const n="container"===t.params.touchEventsTarget?t.el:t.wrapperEl;t.isElement&&(t.__preventObserver__=!0),n.style.cursor="move",n.style.cursor=e?"grabbing":"grab",t.isElement&&requestAnimationFrame((()=>{t.__preventObserver__=!1}))},unsetGrabCursor:function(){const 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 kC(e,t,n){const i=$x(),{params:a}=e,r=a.edgeSwipeDetection,o=a.edgeSwipeThreshold;return!r||!(n<=o||n>=i.innerWidth-o)||"prevent"===r&&(t.preventDefault(),!0)}function SC(e){const t=this,n=jx();let i=e;i.originalEvent&&(i=i.originalEvent);const a=t.touchEventsData;if("pointerdown"===i.type){if(null!==a.pointerId&&a.pointerId!==i.pointerId)return;a.pointerId=i.pointerId}else"touchstart"===i.type&&1===i.targetTouches.length&&(a.touchId=i.targetTouches[0].identifier);if("touchstart"===i.type)return void kC(t,i,i.targetTouches[0].pageX);const{params:r,touches:o,enabled:s}=t;if(!s)return;if(!r.simulateTouch&&"mouse"===i.pointerType)return;if(t.animating&&r.preventInteractionOnTransition)return;!t.animating&&r.cssMode&&r.loop&&t.loopFix();let d=i.target;if("wrapper"===r.touchEventsTarget&&!function(e,t){const n=t.contains(e);if(!n&&t instanceof HTMLSlotElement)return[...t.assignedElements()].includes(e);return n}(d,t.wrapperEl))return;if("which"in i&&3===i.which)return;if("button"in i&&i.button>0)return;if(a.isTouched&&a.isMoved)return;const l=!!r.noSwipingClass&&""!==r.noSwipingClass,u=i.composedPath?i.composedPath():i.path;l&&i.target&&i.target.shadowRoot&&u&&(d=u[0]);const c=r.noSwipingSelector?r.noSwipingSelector:`.${r.noSwipingClass}`,h=!(!i.target||!i.target.shadowRoot);if(r.noSwiping&&(h?function(e,t){return void 0===t&&(t=this),function t(n){if(!n||n===jx()||n===$x())return null;n.assignedSlot&&(n=n.assignedSlot);const i=n.closest(e);return i||n.getRootNode?i||t(n.getRootNode().host):null}(t)}(c,d):d.closest(c)))return void(t.allowClick=!0);if(r.swipeHandler&&!d.closest(r.swipeHandler))return;o.currentX=i.pageX,o.currentY=i.pageY;const m=o.currentX,f=o.currentY;if(!kC(t,i,m))return;Object.assign(a,{isTouched:!0,isMoved:!1,allowTouchCallbacks:!0,isScrolling:void 0,startMoving:void 0}),o.startX=m,o.startY=f,a.touchStartTime=Ux(),t.allowClick=!0,t.updateSize(),t.swipeDirection=void 0,r.threshold>0&&(a.allowThresholdMove=!1);let g=!0;d.matches(a.focusableElements)&&(g=!1,"SELECT"===d.nodeName&&(a.isTouched=!1)),n.activeElement&&n.activeElement.matches(a.focusableElements)&&n.activeElement!==d&&n.activeElement.blur();const p=g&&t.allowTouchMove&&r.touchStartPreventDefault;!r.touchStartForcePreventDefault&&!p||d.isContentEditable||i.preventDefault(),r.freeMode&&r.freeMode.enabled&&t.freeMode&&t.animating&&!r.cssMode&&t.freeMode.onTouchStart(),t.emit("touchStart",i)}function MC(e){const t=jx(),n=this,i=n.touchEventsData,{params:a,touches:r,rtlTranslate:o,enabled:s}=n;if(!s)return;if(!a.simulateTouch&&"mouse"===e.pointerType)return;let d,l=e;if(l.originalEvent&&(l=l.originalEvent),"pointermove"===l.type){if(null!==i.touchId)return;if(l.pointerId!==i.pointerId)return}if("touchmove"===l.type){if(d=[...l.changedTouches].filter((e=>e.identifier===i.touchId))[0],!d||d.identifier!==i.touchId)return}else d=l;if(!i.isTouched)return void(i.startMoving&&i.isScrolling&&n.emit("touchMoveOpposite",l));const u=d.pageX,c=d.pageY;if(l.preventedByNestedSwiper)return r.startX=u,void(r.startY=c);if(!n.allowTouchMove)return l.target.matches(i.focusableElements)||(n.allowClick=!1),void(i.isTouched&&(Object.assign(r,{startX:u,startY:c,currentX:u,currentY:c}),i.touchStartTime=Ux()));if(a.touchReleaseOnEdges&&!a.loop)if(n.isVertical()){if(c<r.startY&&n.translate<=n.maxTranslate()||c>r.startY&&n.translate>=n.minTranslate())return i.isTouched=!1,void(i.isMoved=!1)}else if(u<r.startX&&n.translate<=n.maxTranslate()||u>r.startX&&n.translate>=n.minTranslate())return;if(t.activeElement&&l.target===t.activeElement&&l.target.matches(i.focusableElements))return i.isMoved=!0,void(n.allowClick=!1);i.allowTouchCallbacks&&n.emit("touchMove",l),r.previousX=r.currentX,r.previousY=r.currentY,r.currentX=u,r.currentY=c;const h=r.currentX-r.startX,m=r.currentY-r.startY;if(n.params.threshold&&Math.sqrt(h**2+m**2)<n.params.threshold)return;if(void 0===i.isScrolling){let e;n.isHorizontal()&&r.currentY===r.startY||n.isVertical()&&r.currentX===r.startX?i.isScrolling=!1:h*h+m*m>=25&&(e=180*Math.atan2(Math.abs(m),Math.abs(h))/Math.PI,i.isScrolling=n.isHorizontal()?e>a.touchAngle:90-e>a.touchAngle)}if(i.isScrolling&&n.emit("touchMoveOpposite",l),void 0===i.startMoving&&(r.currentX===r.startX&&r.currentY===r.startY||(i.startMoving=!0)),i.isScrolling||"touchmove"===l.type&&i.preventTouchMoveFromPointerMove)return void(i.isTouched=!1);if(!i.startMoving)return;n.allowClick=!1,!a.cssMode&&l.cancelable&&l.preventDefault(),a.touchMoveStopPropagation&&!a.nested&&l.stopPropagation();let f=n.isHorizontal()?h:m,g=n.isHorizontal()?r.currentX-r.previousX:r.currentY-r.previousY;a.oneWayMovement&&(f=Math.abs(f)*(o?1:-1),g=Math.abs(g)*(o?1:-1)),r.diff=f,f*=a.touchRatio,o&&(f=-f,g=-g);const p=n.touchesDirection;n.swipeDirection=f>0?"prev":"next",n.touchesDirection=g>0?"prev":"next";const v=n.params.loop&&!a.cssMode,y="next"===n.touchesDirection&&n.allowSlideNext||"prev"===n.touchesDirection&&n.allowSlidePrev;if(!i.isMoved){if(v&&y&&n.loopFix({direction:n.swipeDirection}),i.startTranslate=n.getTranslate(),n.setTransition(0),n.animating){const e=new window.CustomEvent("transitionend",{bubbles:!0,cancelable:!0,detail:{bySwiperTouchMove:!0}});n.wrapperEl.dispatchEvent(e)}i.allowMomentumBounce=!1,!a.grabCursor||!0!==n.allowSlideNext&&!0!==n.allowSlidePrev||n.setGrabCursor(!0),n.emit("sliderFirstMove",l)}if((new Date).getTime(),i.isMoved&&i.allowThresholdMove&&p!==n.touchesDirection&&v&&y&&Math.abs(f)>=1)return Object.assign(r,{startX:u,startY:c,currentX:u,currentY:c,startTranslate:i.currentTranslate}),i.loopSwapReset=!0,void(i.startTranslate=i.currentTranslate);n.emit("sliderMove",l),i.isMoved=!0,i.currentTranslate=f+i.startTranslate;let b=!0,w=a.resistanceRatio;if(a.touchReleaseOnEdges&&(w=0),f>0?(v&&y&&i.allowThresholdMove&&i.currentTranslate>(a.centeredSlides?n.minTranslate()-n.slidesSizesGrid[n.activeIndex+1]-("auto"!==a.slidesPerView&&n.slides.length-a.slidesPerView>=2?n.slidesSizesGrid[n.activeIndex+1]+n.params.spaceBetween:0)-n.params.spaceBetween:n.minTranslate())&&n.loopFix({direction:"prev",setTranslate:!0,activeSlideIndex:0}),i.currentTranslate>n.minTranslate()&&(b=!1,a.resistance&&(i.currentTranslate=n.minTranslate()-1+(-n.minTranslate()+i.startTranslate+f)**w))):f<0&&(v&&y&&i.allowThresholdMove&&i.currentTranslate<(a.centeredSlides?n.maxTranslate()+n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween+("auto"!==a.slidesPerView&&n.slides.length-a.slidesPerView>=2?n.slidesSizesGrid[n.slidesSizesGrid.length-1]+n.params.spaceBetween:0):n.maxTranslate())&&n.loopFix({direction:"next",setTranslate:!0,activeSlideIndex:n.slides.length-("auto"===a.slidesPerView?n.slidesPerViewDynamic():Math.ceil(parseFloat(a.slidesPerView,10)))}),i.currentTranslate<n.maxTranslate()&&(b=!1,a.resistance&&(i.currentTranslate=n.maxTranslate()+1-(n.maxTranslate()-i.startTranslate-f)**w))),b&&(l.preventedByNestedSwiper=!0),!n.allowSlideNext&&"next"===n.swipeDirection&&i.currentTranslate<i.startTranslate&&(i.currentTranslate=i.startTranslate),!n.allowSlidePrev&&"prev"===n.swipeDirection&&i.currentTranslate>i.startTranslate&&(i.currentTranslate=i.startTranslate),n.allowSlidePrev||n.allowSlideNext||(i.currentTranslate=i.startTranslate),a.threshold>0){if(!(Math.abs(f)>a.threshold||i.allowThresholdMove))return void(i.currentTranslate=i.startTranslate);if(!i.allowThresholdMove)return i.allowThresholdMove=!0,r.startX=r.currentX,r.startY=r.currentY,i.currentTranslate=i.startTranslate,void(r.diff=n.isHorizontal()?r.currentX-r.startX:r.currentY-r.startY)}a.followFinger&&!a.cssMode&&((a.freeMode&&a.freeMode.enabled&&n.freeMode||a.watchSlidesProgress)&&(n.updateActiveIndex(),n.updateSlidesClasses()),a.freeMode&&a.freeMode.enabled&&n.freeMode&&n.freeMode.onTouchMove(),n.updateProgress(i.currentTranslate),n.setTranslate(i.currentTranslate))}function TC(e){const t=this,n=t.touchEventsData;let i,a=e;a.originalEvent&&(a=a.originalEvent);if("touchend"===a.type||"touchcancel"===a.type){if(i=[...a.changedTouches].filter((e=>e.identifier===n.touchId))[0],!i||i.identifier!==n.touchId)return}else{if(null!==n.touchId)return;if(a.pointerId!==n.pointerId)return;i=a}if(["pointercancel","pointerout","pointerleave","contextmenu"].includes(a.type)){if(!(["pointercancel","contextmenu"].includes(a.type)&&(t.browser.isSafari||t.browser.isWebView)))return}n.pointerId=null,n.touchId=null;const{params:r,touches:o,rtlTranslate:s,slidesGrid:d,enabled:l}=t;if(!l)return;if(!r.simulateTouch&&"mouse"===a.pointerType)return;if(n.allowTouchCallbacks&&t.emit("touchEnd",a),n.allowTouchCallbacks=!1,!n.isTouched)return n.isMoved&&r.grabCursor&&t.setGrabCursor(!1),n.isMoved=!1,void(n.startMoving=!1);r.grabCursor&&n.isMoved&&n.isTouched&&(!0===t.allowSlideNext||!0===t.allowSlidePrev)&&t.setGrabCursor(!1);const u=Ux(),c=u-n.touchStartTime;if(t.allowClick){const e=a.path||a.composedPath&&a.composedPath();t.updateClickedSlide(e&&e[0]||a.target,e),t.emit("tap click",a),c<300&&u-n.lastClickTime<300&&t.emit("doubleTap doubleClick",a)}if(n.lastClickTime=Ux(),Hx((()=>{t.destroyed||(t.allowClick=!0)})),!n.isTouched||!n.isMoved||!t.swipeDirection||0===o.diff&&!n.loopSwapReset||n.currentTranslate===n.startTranslate&&!n.loopSwapReset)return n.isTouched=!1,n.isMoved=!1,void(n.startMoving=!1);let h;if(n.isTouched=!1,n.isMoved=!1,n.startMoving=!1,h=r.followFinger?s?t.translate:-t.translate:-n.currentTranslate,r.cssMode)return;if(r.freeMode&&r.freeMode.enabled)return void t.freeMode.onTouchEnd({currentPos:h});const m=h>=-t.maxTranslate()&&!t.params.loop;let f=0,g=t.slidesSizesGrid[0];for(let e=0;e<d.length;e+=e<r.slidesPerGroupSkip?1:r.slidesPerGroup){const t=e<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;void 0!==d[e+t]?(m||h>=d[e]&&h<d[e+t])&&(f=e,g=d[e+t]-d[e]):(m||h>=d[e])&&(f=e,g=d[d.length-1]-d[d.length-2])}let p=null,v=null;r.rewind&&(t.isBeginning?v=r.virtual&&r.virtual.enabled&&t.virtual?t.virtual.slides.length-1:t.slides.length-1:t.isEnd&&(p=0));const y=(h-d[f])/g,b=f<r.slidesPerGroupSkip-1?1:r.slidesPerGroup;if(c>r.longSwipesMs){if(!r.longSwipes)return void t.slideTo(t.activeIndex);"next"===t.swipeDirection&&(y>=r.longSwipesRatio?t.slideTo(r.rewind&&t.isEnd?p:f+b):t.slideTo(f)),"prev"===t.swipeDirection&&(y>1-r.longSwipesRatio?t.slideTo(f+b):null!==v&&y<0&&Math.abs(y)>r.longSwipesRatio?t.slideTo(v):t.slideTo(f))}else{if(!r.shortSwipes)return void t.slideTo(t.activeIndex);t.navigation&&(a.target===t.navigation.nextEl||a.target===t.navigation.prevEl)?a.target===t.navigation.nextEl?t.slideTo(f+b):t.slideTo(f):("next"===t.swipeDirection&&t.slideTo(null!==p?p:f+b),"prev"===t.swipeDirection&&t.slideTo(null!==v?v:f))}}function EC(){const e=this,{params:t,el:n}=e;if(n&&0===n.offsetWidth)return;t.breakpoints&&e.setBreakpoint();const{allowSlideNext:i,allowSlidePrev:a,snapGrid:r}=e,o=e.virtual&&e.params.virtual.enabled;e.allowSlideNext=!0,e.allowSlidePrev=!0,e.updateSize(),e.updateSlides(),e.updateSlidesClasses();const s=o&&t.loop;!("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):e.slideTo(e.slides.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=i,e.params.watchOverflow&&r!==e.snapGrid&&e.checkOverflow()}function PC(e){const t=this;t.enabled&&(t.allowClick||(t.params.preventClicks&&e.preventDefault(),t.params.preventClicksPropagation&&t.animating&&(e.stopPropagation(),e.stopImmediatePropagation())))}function AC(){const e=this,{wrapperEl:t,rtlTranslate:n,enabled:i}=e;if(!i)return;let a;e.previousTranslate=e.translate,e.isHorizontal()?e.translate=-t.scrollLeft:e.translate=-t.scrollTop,0===e.translate&&(e.translate=0),e.updateActiveIndex(),e.updateSlidesClasses();const r=e.maxTranslate()-e.minTranslate();a=0===r?0:(e.translate-e.minTranslate())/r,a!==e.progress&&e.updateProgress(n?-e.translate:e.translate),e.emit("setTranslate",e.translate,!1)}function xC(e){const t=this;hC(t,e.target),t.params.cssMode||"auto"!==t.params.slidesPerView&&!t.params.autoHeight||t.update()}function CC(){const e=this;e.documentTouchHandlerProceeded||(e.documentTouchHandlerProceeded=!0,e.params.touchReleaseOnEdges&&(e.el.style.touchAction="auto"))}const LC=(e,t)=>{const n=jx(),{params:i,el:a,wrapperEl:r,device:o}=e,s=!!i.nested,d="on"===t?"addEventListener":"removeEventListener",l=t;a&&"string"!=typeof a&&(n[d]("touchstart",e.onDocumentTouchStart,{passive:!1,capture:s}),a[d]("touchstart",e.onTouchStart,{passive:!1}),a[d]("pointerdown",e.onTouchStart,{passive:!1}),n[d]("touchmove",e.onTouchMove,{passive:!1,capture:s}),n[d]("pointermove",e.onTouchMove,{passive:!1,capture:s}),n[d]("touchend",e.onTouchEnd,{passive:!0}),n[d]("pointerup",e.onTouchEnd,{passive:!0}),n[d]("pointercancel",e.onTouchEnd,{passive:!0}),n[d]("touchcancel",e.onTouchEnd,{passive:!0}),n[d]("pointerout",e.onTouchEnd,{passive:!0}),n[d]("pointerleave",e.onTouchEnd,{passive:!0}),n[d]("contextmenu",e.onTouchEnd,{passive:!0}),(i.preventClicks||i.preventClicksPropagation)&&a[d]("click",e.onClick,!0),i.cssMode&&r[d]("scroll",e.onScroll),i.updateOnWindowResize?e[l](o.ios||o.android?"resize orientationchange observerUpdate":"resize observerUpdate",EC,!0):e[l]("observerUpdate",EC,!0),a[d]("load",e.onLoad,{capture:!0}))};const DC=(e,t)=>e.grid&&t.grid&&t.grid.rows>1;var IC={setBreakpoint:function(){const e=this,{realIndex:t,initialized:n,params:i,el:a}=e,r=i.breakpoints;if(!r||r&&0===Object.keys(r).length)return;const o=e.getBreakpoint(r,e.params.breakpointsBase,e.el);if(!o||e.currentBreakpoint===o)return;const s=(o in r?r[o]:void 0)||e.originalParams,d=DC(e,i),l=DC(e,s),u=e.params.grabCursor,c=s.grabCursor,h=i.enabled;d&&!l?(a.classList.remove(`${i.containerModifierClass}grid`,`${i.containerModifierClass}grid-column`),e.emitContainerClasses()):!d&&l&&(a.classList.add(`${i.containerModifierClass}grid`),(s.grid.fill&&"column"===s.grid.fill||!s.grid.fill&&"column"===i.grid.fill)&&a.classList.add(`${i.containerModifierClass}grid-column`),e.emitContainerClasses()),u&&!c?e.unsetGrabCursor():!u&&c&&e.setGrabCursor(),["navigation","pagination","scrollbar"].forEach((t=>{if(void 0===s[t])return;const n=i[t]&&i[t].enabled,a=s[t]&&s[t].enabled;n&&!a&&e[t].disable(),!n&&a&&e[t].enable()}));const m=s.direction&&s.direction!==i.direction,f=i.loop&&(s.slidesPerView!==i.slidesPerView||m),g=i.loop;m&&n&&e.changeDirection(),Xx(e.params,s);const p=e.params.enabled,v=e.params.loop;Object.assign(e,{allowTouchMove:e.params.allowTouchMove,allowSlideNext:e.params.allowSlideNext,allowSlidePrev:e.params.allowSlidePrev}),h&&!p?e.disable():!h&&p&&e.enable(),e.currentBreakpoint=o,e.emit("_beforeBreakpoint",s),n&&(f?(e.loopDestroy(),e.loopCreate(t),e.updateSlides()):!g&&v?(e.loopCreate(t),e.updateSlides()):g&&!v&&e.loopDestroy()),e.emit("breakpoint",s)},getBreakpoint:function(e,t,n){if(void 0===t&&(t="window"),!e||"container"===t&&!n)return;let i=!1;const a=$x(),r="window"===t?a.innerHeight:n.clientHeight,o=Object.keys(e).map((e=>{if("string"==typeof e&&0===e.indexOf("@")){const 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(let e=0;e<o.length;e+=1){const{point:r,value:s}=o[e];"window"===t?a.matchMedia(`(min-width: ${s}px)`).matches&&(i=r):s<=n.clientWidth&&(i=r)}return i||"max"}};var _C={addClasses:function(){const e=this,{classNames:t,params:n,rtl:i,el:a,device:r}=e,o=function(e,t){const n=[];return e.forEach((e=>{"object"==typeof e?Object.keys(e).forEach((i=>{e[i]&&n.push(t+i)})):"string"==typeof e&&n.push(t+e)})),n}(["initialized",n.direction,{"free-mode":e.params.freeMode&&n.freeMode.enabled},{autoheight:n.autoHeight},{rtl:i},{grid:n.grid&&n.grid.rows>1},{"grid-column":n.grid&&n.grid.rows>1&&"column"===n.grid.fill},{android:r.android},{ios:r.ios},{"css-mode":n.cssMode},{centered:n.cssMode&&n.centeredSlides},{"watch-progress":n.watchSlidesProgress}],n.containerModifierClass);t.push(...o),a.classList.add(...t),e.emitContainerClasses()},removeClasses:function(){const{el:e,classNames:t}=this;e&&"string"!=typeof e&&(e.classList.remove(...t),this.emitContainerClasses())}};var RC={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,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 WC(e,t){return function(n){void 0===n&&(n={});const i=Object.keys(n)[0],a=n[i];"object"==typeof a&&null!==a?(!0===e[i]&&(e[i]={enabled:!0}),"navigation"===i&&e[i]&&e[i].enabled&&!e[i].prevEl&&!e[i].nextEl&&(e[i].auto=!0),["pagination","scrollbar"].indexOf(i)>=0&&e[i]&&e[i].enabled&&!e[i].el&&(e[i].auto=!0),i in e&&"enabled"in a?("object"!=typeof e[i]||"enabled"in e[i]||(e[i].enabled=!0),e[i]||(e[i]={enabled:!1}),Xx(t,n)):Xx(t,n)):Xx(t,n)}}const NC={eventsEmitter:lC,update:gC,translate:pC,transition:{setTransition:function(e,t){const n=this;n.params.cssMode||(n.wrapperEl.style.transitionDuration=`${e}ms`,n.wrapperEl.style.transitionDelay=0===e?"0ms":""),n.emit("setTransition",e,t)},transitionStart:function(e,t){void 0===e&&(e=!0);const n=this,{params:i}=n;i.cssMode||(i.autoHeight&&n.updateAutoHeight(),vC({swiper:n,runCallbacks:e,direction:t,step:"Start"}))},transitionEnd:function(e,t){void 0===e&&(e=!0);const n=this,{params:i}=n;n.animating=!1,i.cssMode||(n.setTransition(0),vC({swiper:n,runCallbacks:e,direction:t,step:"End"}))}},slide:yC,loop:bC,grabCursor:wC,events:{attachEvents:function(){const e=this,{params:t}=e;e.onTouchStart=SC.bind(e),e.onTouchMove=MC.bind(e),e.onTouchEnd=TC.bind(e),e.onDocumentTouchStart=CC.bind(e),t.cssMode&&(e.onScroll=AC.bind(e)),e.onClick=PC.bind(e),e.onLoad=xC.bind(e),LC(e,"on")},detachEvents:function(){LC(this,"off")}},breakpoints:IC,checkOverflow:{checkOverflow:function(){const e=this,{isLocked:t,params:n}=e,{slidesOffsetBefore:i}=n;if(i){const t=e.slides.length-1,n=e.slidesGrid[t]+e.slidesSizesGrid[t]+2*i;e.isLocked=e.size>n}else e.isLocked=1===e.snapGrid.length;!0===n.allowSlideNext&&(e.allowSlideNext=!e.isLocked),!0===n.allowSlidePrev&&(e.allowSlidePrev=!e.isLocked),t&&t!==e.isLocked&&(e.isEnd=!1),t!==e.isLocked&&e.emit(e.isLocked?"lock":"unlock")}},classes:_C},OC={};class FC{constructor(){let e,t;for(var n=arguments.length,i=new Array(n),a=0;a<n;a++)i[a]=arguments[a];1===i.length&&i[0].constructor&&"Object"===Object.prototype.toString.call(i[0]).slice(8,-1)?t=i[0]:[e,t]=i,t||(t={}),t=Xx({},t),e&&!t.el&&(t.el=e);const r=jx();if(t.el&&"string"==typeof t.el&&r.querySelectorAll(t.el).length>1){const e=[];return r.querySelectorAll(t.el).forEach((n=>{const i=Xx({},t,{el:n});e.push(new FC(i))})),e}const o=this;o.__swiper__=!0,o.support=oC(),o.device=sC({userAgent:t.userAgent}),o.browser=dC(),o.eventsListeners={},o.eventsAnyListeners=[],o.modules=[...o.__modules__],t.modules&&Array.isArray(t.modules)&&o.modules.push(...t.modules);const s={};o.modules.forEach((e=>{e({params:t,swiper:o,extendParams:WC(t,s),on:o.on.bind(o),once:o.once.bind(o),off:o.off.bind(o),emit:o.emit.bind(o)})}));const d=Xx({},RC,s);return o.params=Xx({},d,OC,t),o.originalParams=Xx({},o.params),o.passedParams=Xx({},t),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:e,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}getDirectionLabel(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]}getSlideIndex(e){const{slidesEl:t,params:n}=this,i=Zx(Kx(t,`.${n.slideClass}, swiper-slide`)[0]);return Zx(e)-i}getSlideIndexByData(e){return this.getSlideIndex(this.slides.filter((t=>1*t.getAttribute("data-swiper-slide-index")===e))[0])}recalcSlides(){const{slidesEl:e,params:t}=this;this.slides=Kx(e,`.${t.slideClass}, swiper-slide`)}enable(){const e=this;e.enabled||(e.enabled=!0,e.params.grabCursor&&e.setGrabCursor(),e.emit("enable"))}disable(){const e=this;e.enabled&&(e.enabled=!1,e.params.grabCursor&&e.unsetGrabCursor(),e.emit("disable"))}setProgress(e,t){const n=this;e=Math.min(Math.max(e,0),1);const i=n.minTranslate(),a=(n.maxTranslate()-i)*e+i;n.translateTo(a,void 0===t?0:t),n.updateActiveIndex(),n.updateSlidesClasses()}emitContainerClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=e.el.className.split(" ").filter((t=>0===t.indexOf("swiper")||0===t.indexOf(e.params.containerModifierClass)));e.emit("_containerClasses",t.join(" "))}getSlideClasses(e){const t=this;return t.destroyed?"":e.className.split(" ").filter((e=>0===e.indexOf("swiper-slide")||0===e.indexOf(t.params.slideClass))).join(" ")}emitSlidesClasses(){const e=this;if(!e.params._emitClasses||!e.el)return;const t=[];e.slides.forEach((n=>{const i=e.getSlideClasses(n);t.push({slideEl:n,classNames:i}),e.emit("_slideClass",n,i)})),e.emit("_slideClasses",t)}slidesPerViewDynamic(e,t){void 0===e&&(e="current"),void 0===t&&(t=!1);const{params:n,slides:i,slidesGrid:a,slidesSizesGrid:r,size:o,activeIndex:s}=this;let d=1;if("number"==typeof n.slidesPerView)return n.slidesPerView;if(n.centeredSlides){let e,t=i[s]?Math.ceil(i[s].swiperSlideSize):0;for(let n=s+1;n<i.length;n+=1)i[n]&&!e&&(t+=Math.ceil(i[n].swiperSlideSize),d+=1,t>o&&(e=!0));for(let n=s-1;n>=0;n-=1)i[n]&&!e&&(t+=i[n].swiperSlideSize,d+=1,t>o&&(e=!0))}else if("current"===e)for(let e=s+1;e<i.length;e+=1){(t?a[e]+r[e]-a[s]<o:a[e]-a[s]<o)&&(d+=1)}else for(let e=s-1;e>=0;e-=1){a[s]-a[e]<o&&(d+=1)}return d}update(){const e=this;if(!e||e.destroyed)return;const{snapGrid:t,params:n}=e;function i(){const t=e.rtlTranslate?-1*e.translate:e.translate,n=Math.min(Math.max(t,e.maxTranslate()),e.minTranslate());e.setTranslate(n),e.updateActiveIndex(),e.updateSlidesClasses()}let a;if(n.breakpoints&&e.setBreakpoint(),[...e.el.querySelectorAll('[loading="lazy"]')].forEach((t=>{t.complete&&hC(e,t)})),e.updateSize(),e.updateSlides(),e.updateProgress(),e.updateSlidesClasses(),n.freeMode&&n.freeMode.enabled&&!n.cssMode)i(),n.autoHeight&&e.updateAutoHeight();else{if(("auto"===n.slidesPerView||n.slidesPerView>1)&&e.isEnd&&!n.centeredSlides){const t=e.virtual&&n.virtual.enabled?e.virtual.slides:e.slides;a=e.slideTo(t.length-1,0,!1,!0)}else a=e.slideTo(e.activeIndex,0,!1,!0);a||i()}n.watchOverflow&&t!==e.snapGrid&&e.checkOverflow(),e.emit("update")}changeDirection(e,t){void 0===t&&(t=!0);const n=this,i=n.params.direction;return e||(e="horizontal"===i?"vertical":"horizontal"),e===i||"horizontal"!==e&&"vertical"!==e||(n.el.classList.remove(`${n.params.containerModifierClass}${i}`),n.el.classList.add(`${n.params.containerModifierClass}${e}`),n.emitContainerClasses(),n.params.direction=e,n.slides.forEach((t=>{"vertical"===e?t.style.width="":t.style.height=""})),n.emit("changeDirection"),t&&n.update()),n}changeLanguageDirection(e){const 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())}mount(e){const t=this;if(t.mounted)return!0;let n=e||t.params.el;if("string"==typeof n&&(n=document.querySelector(n)),!n)return!1;n.swiper=t,n.parentNode&&n.parentNode.host&&n.parentNode.host.nodeName===t.params.swiperElementNodeName.toUpperCase()&&(t.isElement=!0);const i=()=>`.${(t.params.wrapperClass||"").trim().split(" ").join(".")}`;let a=(()=>{if(n&&n.shadowRoot&&n.shadowRoot.querySelector){return n.shadowRoot.querySelector(i())}return Kx(n,i())[0]})();return!a&&t.params.createElements&&(a=Jx("div",t.params.wrapperClass),n.append(a),Kx(n,`.${t.params.slideClass}`).forEach((e=>{a.append(e)}))),Object.assign(t,{el:n,wrapperEl:a,slidesEl:t.isElement&&!n.parentNode.host.slideSlots?n.parentNode.host:a,hostEl:t.isElement?n.parentNode.host:n,mounted:!0,rtl:"rtl"===n.dir.toLowerCase()||"rtl"===Qx(n,"direction"),rtlTranslate:"horizontal"===t.params.direction&&("rtl"===n.dir.toLowerCase()||"rtl"===Qx(n,"direction")),wrongRTL:"-webkit-box"===Qx(a,"display")}),!0}init(e){const 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(),t.attachEvents();const n=[...t.el.querySelectorAll('[loading="lazy"]')];return t.isElement&&n.push(...t.hostEl.querySelectorAll('[loading="lazy"]')),n.forEach((e=>{e.complete?hC(t,e):e.addEventListener("load",(e=>{hC(t,e.target)}))})),fC(t),t.initialized=!0,fC(t),t.emit("init"),t.emit("afterInit"),t}destroy(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0);const n=this,{params:i,el:a,wrapperEl:r,slides:o}=n;return void 0===n.params||n.destroyed||(n.emit("beforeDestroy"),n.initialized=!1,n.detachEvents(),i.loop&&n.loopDestroy(),t&&(n.removeClasses(),a&&"string"!=typeof a&&a.removeAttribute("style"),r&&r.removeAttribute("style"),o&&o.length&&o.forEach((e=>{e.classList.remove(i.slideVisibleClass,i.slideFullyVisibleClass,i.slideActiveClass,i.slideNextClass,i.slidePrevClass),e.removeAttribute("style"),e.removeAttribute("data-swiper-slide-index")}))),n.emit("destroy"),Object.keys(n.eventsListeners).forEach((e=>{n.off(e)})),!1!==e&&(n.el&&"string"!=typeof n.el&&(n.el.swiper=null),function(e){const t=e;Object.keys(t).forEach((e=>{try{t[e]=null}catch(e){}try{delete t[e]}catch(e){}}))}(n)),n.destroyed=!0),null}static extendDefaults(e){Xx(OC,e)}static get extendedDefaults(){return OC}static get defaults(){return RC}static installModule(e){FC.prototype.__modules__||(FC.prototype.__modules__=[]);const t=FC.prototype.__modules__;"function"==typeof e&&t.indexOf(e)<0&&t.push(e)}static use(e){return Array.isArray(e)?(e.forEach((e=>FC.installModule(e))),FC):(FC.installModule(e),FC)}}function jC(e){return void 0===e&&(e=""),`.${e.trim().replace(/([\.:!+\/])/g,"\\$1").replace(/ /g,".")}`}function zC(e){let{swiper:t,extendParams:n,on:i,emit:a}=e;const r="swiper-pagination";let o;n({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`}}),t.pagination={el:null,bullets:[]};let s=0;function d(){return!t.params.pagination.el||!t.pagination.el||Array.isArray(t.pagination.el)&&0===t.pagination.el.length}function l(e,n){const{bulletActiveClass:i}=t.params.pagination;e&&(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&(e.classList.add(`${i}-${n}`),(e=e[("prev"===n?"previous":"next")+"ElementSibling"])&&e.classList.add(`${i}-${n}-${n}`))}function u(e){const n=e.target.closest(jC(t.params.pagination.bulletClass));if(!n)return;e.preventDefault();const i=Zx(n)*t.params.slidesPerGroup;if(t.params.loop){if(t.realIndex===i)return;const e=(a=t.realIndex,r=i,o=t.slides.length,(r%=o)==1+(a%=o)?"next":r===a-1?"previous":void 0);"next"===e?t.slideNext():"previous"===e?t.slidePrev():t.slideToLoop(i)}else t.slideTo(i);var a,r,o}function c(){const e=t.rtl,n=t.params.pagination;if(d())return;let i,r,u=t.pagination.el;u=nC(u);const c=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.slides.length,h=t.params.loop?Math.ceil(c/t.params.slidesPerGroup):t.snapGrid.length;if(t.params.loop?(r=t.previousRealIndex||0,i=t.params.slidesPerGroup>1?Math.floor(t.realIndex/t.params.slidesPerGroup):t.realIndex):void 0!==t.snapIndex?(i=t.snapIndex,r=t.previousSnapIndex):(r=t.previousIndex||0,i=t.activeIndex||0),"bullets"===n.type&&t.pagination.bullets&&t.pagination.bullets.length>0){const a=t.pagination.bullets;let d,c,h;if(n.dynamicBullets&&(o=tC(a[0],t.isHorizontal()?"width":"height"),u.forEach((e=>{e.style[t.isHorizontal()?"width":"height"]=o*(n.dynamicMainBullets+4)+"px"})),n.dynamicMainBullets>1&&void 0!==r&&(s+=i-(r||0),s>n.dynamicMainBullets-1?s=n.dynamicMainBullets-1:s<0&&(s=0)),d=Math.max(i-s,0),c=d+(Math.min(a.length,n.dynamicMainBullets)-1),h=(c+d)/2),a.forEach((e=>{const t=[...["","-next","-next-next","-prev","-prev-prev","-main"].map((e=>`${n.bulletActiveClass}${e}`))].map((e=>"string"==typeof e&&e.includes(" ")?e.split(" "):e)).flat();e.classList.remove(...t)})),u.length>1)a.forEach((e=>{const a=Zx(e);a===i?e.classList.add(...n.bulletActiveClass.split(" ")):t.isElement&&e.setAttribute("part","bullet"),n.dynamicBullets&&(a>=d&&a<=c&&e.classList.add(...`${n.bulletActiveClass}-main`.split(" ")),a===d&&l(e,"prev"),a===c&&l(e,"next"))}));else{const e=a[i];if(e&&e.classList.add(...n.bulletActiveClass.split(" ")),t.isElement&&a.forEach(((e,t)=>{e.setAttribute("part",t===i?"bullet-active":"bullet")})),n.dynamicBullets){const e=a[d],t=a[c];for(let e=d;e<=c;e+=1)a[e]&&a[e].classList.add(...`${n.bulletActiveClass}-main`.split(" "));l(e,"prev"),l(t,"next")}}if(n.dynamicBullets){const i=Math.min(a.length,n.dynamicMainBullets+4),r=(o*i-o)/2-h*o,s=e?"right":"left";a.forEach((e=>{e.style[t.isHorizontal()?s:"top"]=`${r}px`}))}}u.forEach(((e,r)=>{if("fraction"===n.type&&(e.querySelectorAll(jC(n.currentClass)).forEach((e=>{e.textContent=n.formatFractionCurrent(i+1)})),e.querySelectorAll(jC(n.totalClass)).forEach((e=>{e.textContent=n.formatFractionTotal(h)}))),"progressbar"===n.type){let a;a=n.progressbarOpposite?t.isHorizontal()?"vertical":"horizontal":t.isHorizontal()?"horizontal":"vertical";const r=(i+1)/h;let o=1,s=1;"horizontal"===a?o=r:s=r,e.querySelectorAll(jC(n.progressbarFillClass)).forEach((e=>{e.style.transform=`translate3d(0,0,0) scaleX(${o}) scaleY(${s})`,e.style.transitionDuration=`${t.params.speed}ms`}))}"custom"===n.type&&n.renderCustom?(e.innerHTML=n.renderCustom(t,i+1,h),0===r&&a("paginationRender",e)):(0===r&&a("paginationRender",e),a("paginationUpdate",e)),t.params.watchOverflow&&t.enabled&&e.classList[t.isLocked?"add":"remove"](n.lockClass)}))}function h(){const e=t.params.pagination;if(d())return;const n=t.virtual&&t.params.virtual.enabled?t.virtual.slides.length:t.grid&&t.params.grid.rows>1?t.slides.length/Math.ceil(t.params.grid.rows):t.slides.length;let i=t.pagination.el;i=nC(i);let r="";if("bullets"===e.type){let i=t.params.loop?Math.ceil(n/t.params.slidesPerGroup):t.snapGrid.length;t.params.freeMode&&t.params.freeMode.enabled&&i>n&&(i=n);for(let n=0;n<i;n+=1)e.renderBullet?r+=e.renderBullet.call(t,n,e.bulletClass):r+=`<${e.bulletElement} ${t.isElement?'part="bullet"':""} class="${e.bulletClass}"></${e.bulletElement}>`}"fraction"===e.type&&(r=e.renderFraction?e.renderFraction.call(t,e.currentClass,e.totalClass):`<span class="${e.currentClass}"></span> / <span class="${e.totalClass}"></span>`),"progressbar"===e.type&&(r=e.renderProgressbar?e.renderProgressbar.call(t,e.progressbarFillClass):`<span class="${e.progressbarFillClass}"></span>`),t.pagination.bullets=[],i.forEach((n=>{"custom"!==e.type&&(n.innerHTML=r||""),"bullets"===e.type&&t.pagination.bullets.push(...n.querySelectorAll(jC(e.bulletClass)))})),"custom"!==e.type&&a("paginationRender",i[0])}function m(){t.params.pagination=function(e,t,n,i){return e.params.createElements&&Object.keys(i).forEach((a=>{if(!n[a]&&!0===n.auto){let r=Kx(e.el,`.${i[a]}`)[0];r||(r=Jx("div",i[a]),r.className=i[a],e.el.append(r)),n[a]=r,t[a]=r}})),n}(t,t.originalParams.pagination,t.params.pagination,{el:"swiper-pagination"});const e=t.params.pagination;if(!e.el)return;let n;"string"==typeof e.el&&t.isElement&&(n=t.el.querySelector(e.el)),n||"string"!=typeof e.el||(n=[...document.querySelectorAll(e.el)]),n||(n=e.el),n&&0!==n.length&&(t.params.uniqueNavElements&&"string"==typeof e.el&&Array.isArray(n)&&n.length>1&&(n=[...t.el.querySelectorAll(e.el)],n.length>1&&(n=n.filter((e=>eC(e,".swiper")[0]===t.el))[0])),Array.isArray(n)&&1===n.length&&(n=n[0]),Object.assign(t.pagination,{el:n}),n=nC(n),n.forEach((n=>{"bullets"===e.type&&e.clickable&&n.classList.add(...(e.clickableClass||"").split(" ")),n.classList.add(e.modifierClass+e.type),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass),"bullets"===e.type&&e.dynamicBullets&&(n.classList.add(`${e.modifierClass}${e.type}-dynamic`),s=0,e.dynamicMainBullets<1&&(e.dynamicMainBullets=1)),"progressbar"===e.type&&e.progressbarOpposite&&n.classList.add(e.progressbarOppositeClass),e.clickable&&n.addEventListener("click",u),t.enabled||n.classList.add(e.lockClass)})))}function f(){const e=t.params.pagination;if(d())return;let n=t.pagination.el;n&&(n=nC(n),n.forEach((n=>{n.classList.remove(e.hiddenClass),n.classList.remove(e.modifierClass+e.type),n.classList.remove(t.isHorizontal()?e.horizontalClass:e.verticalClass),e.clickable&&(n.classList.remove(...(e.clickableClass||"").split(" ")),n.removeEventListener("click",u))}))),t.pagination.bullets&&t.pagination.bullets.forEach((t=>t.classList.remove(...e.bulletActiveClass.split(" "))))}i("changeDirection",(()=>{if(!t.pagination||!t.pagination.el)return;const e=t.params.pagination;let{el:n}=t.pagination;n=nC(n),n.forEach((n=>{n.classList.remove(e.horizontalClass,e.verticalClass),n.classList.add(t.isHorizontal()?e.horizontalClass:e.verticalClass)}))})),i("init",(()=>{!1===t.params.pagination.enabled?g():(m(),h(),c())})),i("activeIndexChange",(()=>{void 0===t.snapIndex&&c()})),i("snapIndexChange",(()=>{c()})),i("snapGridLengthChange",(()=>{h(),c()})),i("destroy",(()=>{f()})),i("enable disable",(()=>{let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList[t.enabled?"remove":"add"](t.params.pagination.lockClass))))})),i("lock unlock",(()=>{c()})),i("click",((e,n)=>{const i=n.target,r=nC(t.pagination.el);if(t.params.pagination.el&&t.params.pagination.hideOnClick&&r&&r.length>0&&!i.classList.contains(t.params.pagination.bulletClass)){if(t.navigation&&(t.navigation.nextEl&&i===t.navigation.nextEl||t.navigation.prevEl&&i===t.navigation.prevEl))return;const e=r[0].classList.contains(t.params.pagination.hiddenClass);a(!0===e?"paginationShow":"paginationHide"),r.forEach((e=>e.classList.toggle(t.params.pagination.hiddenClass)))}}));const g=()=>{t.el.classList.add(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList.add(t.params.pagination.paginationDisabledClass)))),f()};Object.assign(t.pagination,{enable:()=>{t.el.classList.remove(t.params.pagination.paginationDisabledClass);let{el:e}=t.pagination;e&&(e=nC(e),e.forEach((e=>e.classList.remove(t.params.pagination.paginationDisabledClass)))),m(),h(),c()},disable:g,render:h,update:c,init:m,destroy:f})}function $C(e){let t,n,{swiper:i,extendParams:a,on:r,emit:o,params:s}=e;i.autoplay={running:!1,paused:!1,timeLeft:0},a({autoplay:{enabled:!1,delay:3e3,waitForTransition:!0,disableOnInteraction:!1,stopOnLastSlide:!1,reverseDirection:!1,pauseOnMouseEnter:!1}});let d,l,u,c,h,m,f,g,p=s&&s.autoplay?s.autoplay.delay:3e3,v=s&&s.autoplay?s.autoplay.delay:3e3,y=(new Date).getTime();function b(e){i&&!i.destroyed&&i.wrapperEl&&e.target===i.wrapperEl&&(i.wrapperEl.removeEventListener("transitionend",b),g||e.detail&&e.detail.bySwiperTouchMove||E())}const w=()=>{if(i.destroyed||!i.autoplay.running)return;i.autoplay.paused?l=!0:l&&(v=d,l=!1);const e=i.autoplay.paused?d:y+v-(new Date).getTime();i.autoplay.timeLeft=e,o("autoplayTimeLeft",e,e/p),n=requestAnimationFrame((()=>{w()}))},k=e=>{if(i.destroyed||!i.autoplay.running)return;cancelAnimationFrame(n),w();let a=void 0===e?i.params.autoplay.delay:e;p=i.params.autoplay.delay,v=i.params.autoplay.delay;const r=(()=>{let e;if(e=i.virtual&&i.params.virtual.enabled?i.slides.filter((e=>e.classList.contains("swiper-slide-active")))[0]:i.slides[i.activeIndex],!e)return;return parseInt(e.getAttribute("data-swiper-autoplay"),10)})();!Number.isNaN(r)&&r>0&&void 0===e&&(a=r,p=r,v=r),d=a;const s=i.params.speed,l=()=>{i&&!i.destroyed&&(i.params.autoplay.reverseDirection?!i.isBeginning||i.params.loop||i.params.rewind?(i.slidePrev(s,!0,!0),o("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(i.slides.length-1,s,!0,!0),o("autoplay")):!i.isEnd||i.params.loop||i.params.rewind?(i.slideNext(s,!0,!0),o("autoplay")):i.params.autoplay.stopOnLastSlide||(i.slideTo(0,s,!0,!0),o("autoplay")),i.params.cssMode&&(y=(new Date).getTime(),requestAnimationFrame((()=>{k()}))))};return a>0?(clearTimeout(t),t=setTimeout((()=>{l()}),a)):requestAnimationFrame((()=>{l()})),a},S=()=>{y=(new Date).getTime(),i.autoplay.running=!0,k(),o("autoplayStart")},M=()=>{i.autoplay.running=!1,clearTimeout(t),cancelAnimationFrame(n),o("autoplayStop")},T=(e,n)=>{if(i.destroyed||!i.autoplay.running)return;clearTimeout(t),e||(f=!0);const a=()=>{o("autoplayPause"),i.params.autoplay.waitForTransition?i.wrapperEl.addEventListener("transitionend",b):E()};if(i.autoplay.paused=!0,n)return m&&(d=i.params.autoplay.delay),m=!1,void a();const r=d||i.params.autoplay.delay;d=r-((new Date).getTime()-y),i.isEnd&&d<0&&!i.params.loop||(d<0&&(d=0),a())},E=()=>{i.isEnd&&d<0&&!i.params.loop||i.destroyed||!i.autoplay.running||(y=(new Date).getTime(),f?(f=!1,k(d)):k(),i.autoplay.paused=!1,o("autoplayResume"))},P=()=>{if(i.destroyed||!i.autoplay.running)return;const e=jx();"hidden"===e.visibilityState&&(f=!0,T(!0)),"visible"===e.visibilityState&&E()},A=e=>{"mouse"===e.pointerType&&(f=!0,g=!0,i.animating||i.autoplay.paused||T(!0))},x=e=>{"mouse"===e.pointerType&&(g=!1,i.autoplay.paused&&E())};r("init",(()=>{i.params.autoplay.enabled&&(i.params.autoplay.pauseOnMouseEnter&&(i.el.addEventListener("pointerenter",A),i.el.addEventListener("pointerleave",x)),jx().addEventListener("visibilitychange",P),S())})),r("destroy",(()=>{i.el&&"string"!=typeof i.el&&(i.el.removeEventListener("pointerenter",A),i.el.removeEventListener("pointerleave",x)),jx().removeEventListener("visibilitychange",P),i.autoplay.running&&M()})),r("_freeModeStaticRelease",(()=>{(c||f)&&E()})),r("_freeModeNoMomentumRelease",(()=>{i.params.autoplay.disableOnInteraction?M():T(!0,!0)})),r("beforeTransitionStart",((e,t,n)=>{!i.destroyed&&i.autoplay.running&&(n||!i.params.autoplay.disableOnInteraction?T(!0,!0):M())})),r("sliderFirstMove",(()=>{!i.destroyed&&i.autoplay.running&&(i.params.autoplay.disableOnInteraction?M():(u=!0,c=!1,f=!1,h=setTimeout((()=>{f=!0,c=!0,T(!0)}),200)))})),r("touchEnd",(()=>{if(!i.destroyed&&i.autoplay.running&&u){if(clearTimeout(h),clearTimeout(t),i.params.autoplay.disableOnInteraction)return c=!1,void(u=!1);c&&i.params.cssMode&&E(),c=!1,u=!1}})),r("slideChange",(()=>{!i.destroyed&&i.autoplay.running&&(m=!0)})),Object.assign(i.autoplay,{start:S,stop:M,pause:T,resume:E})}Object.keys(NC).forEach((e=>{Object.keys(NC[e]).forEach((t=>{FC.prototype[t]=NC[e][t]}))})),FC.use([function(e){let{swiper:t,on:n,emit:i}=e;const a=$x();let r=null,o=null;const s=()=>{t&&!t.destroyed&&t.initialized&&(i("beforeResize"),i("resize"))},d=()=>{t&&!t.destroyed&&t.initialized&&i("orientationchange")};n("init",(()=>{t.params.resizeObserver&&void 0!==a.ResizeObserver?t&&!t.destroyed&&t.initialized&&(r=new ResizeObserver((e=>{o=a.requestAnimationFrame((()=>{const{width:n,height:i}=t;let a=n,r=i;e.forEach((e=>{let{contentBoxSize:n,contentRect:i,target:o}=e;o&&o!==t.el||(a=i?i.width:(n[0]||n).inlineSize,r=i?i.height:(n[0]||n).blockSize)})),a===n&&r===i||s()}))})),r.observe(t.el)):(a.addEventListener("resize",s),a.addEventListener("orientationchange",d))})),n("destroy",(()=>{o&&a.cancelAnimationFrame(o),r&&r.unobserve&&t.el&&(r.unobserve(t.el),r=null),a.removeEventListener("resize",s),a.removeEventListener("orientationchange",d)}))},function(e){let{swiper:t,extendParams:n,on:i,emit:a}=e;const r=[],o=$x(),s=function(e,n){void 0===n&&(n={});const i=new(o.MutationObserver||o.WebkitMutationObserver)((e=>{if(t.__preventObserver__)return;if(1===e.length)return void a("observerUpdate",e[0]);const n=function(){a("observerUpdate",e[0])};o.requestAnimationFrame?o.requestAnimationFrame(n):o.setTimeout(n,0)}));i.observe(e,{attributes:void 0===n.attributes||n.attributes,childList:t.isElement||(void 0===n.childList||n).childList,characterData:void 0===n.characterData||n.characterData}),r.push(i)};n({observer:!1,observeParents:!1,observeSlideChildren:!1}),i("init",(()=>{if(t.params.observer){if(t.params.observeParents){const e=eC(t.hostEl);for(let t=0;t<e.length;t+=1)s(e[t])}s(t.hostEl,{childList:t.params.observeSlideChildren}),s(t.wrapperEl,{attributes:!1})}})),i("destroy",(()=>{r.forEach((e=>{e.disconnect()})),r.splice(0,r.length)}))}]);let HC=class extends gs{constructor(){super(...arguments),this.inFocusedState=!1,this.scaleFactor=1,this.updateSpacing=e=>{this.slideSpacing=e.detail.spacing,this.swiperInstance.params.spaceBetween=this.slideSpacing,this.swiperInstance.update()}}connectedCallback(){super.connectedCallback(),window.addEventListener("child-spacing",this.updateSpacing,!1)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("child-spacing",this.updateSpacing,!1)}styles(){const{scaleFactor:t,inFocusedState:n,component:i}=this;return e.unsafeCSS(`\n :host {\n display: ${i.hidden?"none":"flex"};\n flex-direction: column !important;\n ${Rs(i)} \n ${Xs(i.position)} \n width: 100%;\n bottom: -1px;\n background-repeat: no-repeat;\n background-size: cover;\n background-position: center;\n z-index: ${i.zIndex??1};\n top: 0px;\n transition: all 0.3s;\n ${Ns(i,t)}\n ${function(e,t){return`\n padding-right: ${(e.nextSlidePadding??0)*t}px !important;\n padding-left: ${(e.previousSlidePadding??0)*t}px !important;\n `}(i,t)}\n ${_s(i)}\n ${Gs(i,t,n)}\n ${Is(i,n)}\n }\n .swiper-container {\n ${zs(i,t)};\n }\n .swiper-pagination{\n position: relative;\n padding: 8px;\n }\n .swiper-pagination-bullet {\n background: ${i.indicatorColor} !important;\n opacity: 1 !important;\n }\n .swiper-pagination-bullet-active {\n background: ${i.activeIndicatorColor} !important;\n }\n `)}updated(){FC.use([zC,$C]);const{autoplay:e,autoplaySeconds:t,showIndicators:n,slideSpacing:i,nextSlidePadding:a,previousSlidePadding:r}=this.component,o=this.shadowRoot?.querySelector(".swiper-container"),s=this.shadowRoot?.querySelector(".swiper-pagination");o&&!this.swiperInstance&&(this.swiperInstance=new FC(o,{initialSlide:0,slidesPerView:1,loop:e,spaceBetween:a??r??i??this.slideSpacing??0,autoplay:!!e&&{delay:1e3*t,disableOnInteraction:!1},pagination:!(null!=n&&!n)&&{el:s,clickable:!0}}))}render(){const t=function(e){if(!e.loopSource)return[];const{slides:t,selectedProducts:n}=Do.state,i="string"==typeof e.loopSource?e.loopSource:"",a=So(Do.productDetails,Do.state.selectedPaywall?.sku_menus||[],i);let r=[];return t&&(r=""!=i?t[i].carouselName:e.loopSource??[]),r.map((t=>{const i=a.find((e=>e.id==n[t.productGroupId]));return Js(e.components,Js({slide:t},{sku:{...To(i?.product_details,t,a)}}))||[]}))??[]}(this.component),{focusedBorderColor:n,focusedFillColor:i,fillColor:a}=this.component;return!n&&od(a,i)||(this.tabIndex=0),e.html`
|
|
62
62
|
<link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css"/>
|
|
63
63
|
<div class="swiper-container">
|
|
64
64
|
<div class="swiper-wrapper">
|