@vouchfor/embeds 0.0.0-experiment.01cbe51 → 0.0.0-experiment.03bde95

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,115 +1,123 @@
1
- var Nk=Object.defineProperty;var Uk=(Ke,jr,Rr)=>jr in Ke?Nk(Ke,jr,{enumerable:!0,configurable:!0,writable:!0,value:Rr}):Ke[jr]=Rr;var Jp=(Ke,jr,Rr)=>(Uk(Ke,typeof jr!="symbol"?jr+"":jr,Rr),Rr);var embeds=function(Ke){var $f;"use strict";function jr(n,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}/**
1
+ var e3=Object.defineProperty;var i3=(Ge,Yr,_r)=>Yr in Ge?e3(Ge,Yr,{enumerable:!0,configurable:!0,writable:!0,value:_r}):Ge[Yr]=_r;var c2=(Ge,Yr,_r)=>(i3(Ge,typeof Yr!="symbol"?Yr+"":Yr,_r),_r);var embeds=function(Ge){var Kf;"use strict";function Yr(n,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}/**
2
2
  * @license
3
3
  * Copyright 2019 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
5
- */const Rr=globalThis,tl=Rr.ShadowRoot&&(Rr.ShadyCSS===void 0||Rr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ih=Symbol(),Dh=new WeakMap;let r2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Ih)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(tl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Dh.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Dh.set(e,t))}return t}toString(){return this.cssText}};const s2=n=>new r2(typeof n=="string"?n:n+"",void 0,Ih),n2=(n,t)=>{if(tl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Rr.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},xh=tl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return s2(e)})(n):n;/**
5
+ */const _r=globalThis,nl=_r.ShadowRoot&&(_r.ShadyCSS===void 0||_r.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Uh=Symbol(),Bh=new WeakMap;let f2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Uh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(nl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Bh.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Bh.set(e,t))}return t}toString(){return this.cssText}};const p2=n=>new f2(typeof n=="string"?n:n+"",void 0,Uh),g2=(n,t)=>{if(nl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=_r.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},Gh=nl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return p2(e)})(n):n;/**
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:a2,defineProperty:o2,getOwnPropertyDescriptor:l2,getOwnPropertyNames:c2,getOwnPropertySymbols:h2,getPrototypeOf:d2}=Object,cs=globalThis,Ph=cs.trustedTypes,u2=Ph?Ph.emptyScript:"",el=cs.reactiveElementPolyfillSupport,Nn=(n,t)=>n,Fa={toAttribute(n,t){switch(t){case Boolean:n=n?u2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},il=(n,t)=>!a2(n,t),Oh={attribute:!0,type:String,converter:Fa,reflect:!1,hasChanged:il};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),cs.litPropertyMetadata??(cs.litPropertyMetadata=new WeakMap);let Un=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Oh){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&o2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=l2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Oh}static _$Ei(){if(this.hasOwnProperty(Nn("elementProperties")))return;const t=d2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Nn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Nn("properties"))){const e=this.properties,i=[...c2(e),...h2(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(xh(s))}else t!==void 0&&e.push(xh(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return n2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Fa).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Fa;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??il)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}};Un.elementStyles=[],Un.shadowRootOptions={mode:"open"},Un[Nn("elementProperties")]=new Map,Un[Nn("finalized")]=new Map,el==null||el({ReactiveElement:Un}),(cs.reactiveElementVersions??(cs.reactiveElementVersions=[])).push("2.0.2");/**
9
+ */const{is:m2,defineProperty:v2,getOwnPropertyDescriptor:y2,getOwnPropertyNames:b2,getOwnPropertySymbols:A2,getPrototypeOf:E2}=Object,ds=globalThis,Vh=ds.trustedTypes,k2=Vh?Vh.emptyScript:"",al=ds.reactiveElementPolyfillSupport,jn=(n,t)=>n,Ha={toAttribute(n,t){switch(t){case Boolean:n=n?k2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},ol=(n,t)=>!m2(n,t),Hh={attribute:!0,type:String,converter:Ha,reflect:!1,hasChanged:ol};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ds.litPropertyMetadata??(ds.litPropertyMetadata=new WeakMap);let Kn=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Hh){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&v2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=y2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Hh}static _$Ei(){if(this.hasOwnProperty(jn("elementProperties")))return;const t=E2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(jn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(jn("properties"))){const e=this.properties,i=[...b2(e),...A2(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Gh(s))}else t!==void 0&&e.push(Gh(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return g2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Ha).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Ha;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??ol)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}};Kn.elementStyles=[],Kn.shadowRootOptions={mode:"open"},Kn[jn("elementProperties")]=new Map,Kn[jn("finalized")]=new Map,al==null||al({ReactiveElement:Kn}),(ds.reactiveElementVersions??(ds.reactiveElementVersions=[])).push("2.0.2");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const Bn=globalThis,Na=Bn.trustedTypes,Mh=Na?Na.createPolicy("lit-html",{createHTML:n=>n}):void 0,rl="$lit$",zr=`lit$${(Math.random()+"").slice(9)}$`,sl="?"+zr,f2=`<${sl}>`,$s=document,Ua=()=>$s.createComment(""),Gn=n=>n===null||typeof n!="object"&&typeof n!="function",$h=Array.isArray,Fh=n=>$h(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",nl=`[
14
- \f\r]`,Hn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Nh=/-->/g,Uh=/>/g,Fs=RegExp(`>|${nl}(?:([^\\s"'>=/]+)(${nl}*=${nl}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),Bh=/'/g,Gh=/"/g,Hh=/^(?:script|style|textarea|title)$/i,Ns=Symbol.for("lit-noChange"),Xe=Symbol.for("lit-nothing"),Vh=new WeakMap,Us=$s.createTreeWalker($s,129);function Wh(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Mh!==void 0?Mh.createHTML(t):t}const Kh=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=Hn;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,A=0;for(;A<f.length&&(c.lastIndex=A,g=c.exec(f),g!==null);)A=c.lastIndex,c===Hn?g[1]==="!--"?c=Nh:g[1]!==void 0?c=Uh:g[2]!==void 0?(Hh.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Fs):g[3]!==void 0&&(c=Fs):c===Fs?g[0]===">"?(c=s??Hn,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Fs:g[3]==='"'?Gh:Bh):c===Gh||c===Bh?c=Fs:c===Nh||c===Uh?c=Hn:(c=Fs,s=void 0);const T=c===Fs&&n[d+1].startsWith("/>")?" ":"";o+=c===Hn?f+f2:v>=0?(i.push(p),f.slice(0,v)+rl+f.slice(v)+zr+T):f+zr+(v===-2?d:T)}return[Wh(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};let al=class t2{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=Kh(t,e);if(this.el=t2.createElement(p,i),Us.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=Us.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(rl)){const A=g[c++],T=s.getAttribute(v).split(zr),E=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:E[2],strings:T,ctor:E[1]==="."?zh:E[1]==="?"?Yh:E[1]==="@"?Zh:Vn}),s.removeAttribute(v)}else v.startsWith(zr)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(Hh.test(s.tagName)){const v=s.textContent.split(zr),A=v.length-1;if(A>0){s.textContent=Na?Na.emptyScript:"";for(let T=0;T<A;T++)s.append(v[T],Ua()),Us.nextNode(),f.push({type:2,index:++o});s.append(v[A],Ua())}}}else if(s.nodeType===8)if(s.data===sl)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(zr,v+1))!==-1;)f.push({type:7,index:o}),v+=zr.length-1}o++}}static createElement(t,e){const i=$s.createElement("template");return i.innerHTML=t,i}};function Bs(n,t,e=n,i){var c,d;if(t===Ns)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=Gn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=Bs(n,s._$AS(n,t.values),s,i)),t}let jh=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??$s).importNode(e,!0);Us.currentNode=s;let o=Us.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new ol(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new Xh(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Us.nextNode(),c++)}return Us.currentNode=$s,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},ol=class e2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Xe,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Bs(this,t,e),Gn(t)?t===Xe||t==null||t===""?(this._$AH!==Xe&&this._$AR(),this._$AH=Xe):t!==this._$AH&&t!==Ns&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Fh(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==Xe&&Gn(this._$AH)?this._$AA.nextSibling.data=t:this.$($s.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=al.createElement(Wh(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new jh(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=Vh.get(t.strings);return e===void 0&&Vh.set(t.strings,e=new al(t)),e}T(t){$h(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new e2(this.k(Ua()),this.k(Ua()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Vn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=Xe,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Xe}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=Bs(this,t,e,0),c=!Gn(t)||t!==this._$AH&&t!==Ns,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=Bs(this,d[i+f],e,f),p===Ns&&(p=this._$AH[f]),c||(c=!Gn(p)||p!==this._$AH[f]),p===Xe?t=Xe:t!==Xe&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===Xe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},zh=class extends Vn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===Xe?void 0:t}},Yh=class extends Vn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==Xe)}},Zh=class extends Vn{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=Bs(this,t,e,0)??Xe)===Ns)return;const i=this._$AH,s=t===Xe&&i!==Xe||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==Xe&&(i===Xe||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Xh=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Bs(this,t)}};const p2={j:rl,P:zr,A:sl,C:1,M:Kh,L:jh,R:Fh,V:Bs,D:ol,I:Vn,H:Yh,N:Zh,U:zh,B:Xh},ll=Bn.litHtmlPolyfillSupport;ll==null||ll(al,ol),(Bn.litHtmlVersions??(Bn.litHtmlVersions=[])).push("3.1.0");/**
13
+ */const Yn=globalThis,Wa=Yn.trustedTypes,Wh=Wa?Wa.createPolicy("lit-html",{createHTML:n=>n}):void 0,ll="$lit$",zr=`lit$${(Math.random()+"").slice(9)}$`,cl="?"+zr,T2=`<${cl}>`,Gs=document,ja=()=>Gs.createComment(""),zn=n=>n===null||typeof n!="object"&&typeof n!="function",jh=Array.isArray,Kh=n=>jh(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",hl=`[
14
+ \f\r]`,Zn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Yh=/-->/g,zh=/>/g,Vs=RegExp(`>|${hl}(?:([^\\s"'>=/]+)(${hl}*=${hl}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Zh=/'/g,Xh=/"/g,qh=/^(?:script|style|textarea|title)$/i,us=Symbol.for("lit-noChange"),Qe=Symbol.for("lit-nothing"),Qh=new WeakMap,Hs=Gs.createTreeWalker(Gs,129);function Jh(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Wh!==void 0?Wh.createHTML(t):t}const td=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=Zn;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,b=0;for(;b<f.length&&(c.lastIndex=b,g=c.exec(f),g!==null);)b=c.lastIndex,c===Zn?g[1]==="!--"?c=Yh:g[1]!==void 0?c=zh:g[2]!==void 0?(qh.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Vs):g[3]!==void 0&&(c=Vs):c===Vs?g[0]===">"?(c=s??Zn,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Vs:g[3]==='"'?Xh:Zh):c===Xh||c===Zh?c=Vs:c===Yh||c===zh?c=Zn:(c=Vs,s=void 0);const E=c===Vs&&n[d+1].startsWith("/>")?" ":"";o+=c===Zn?f+T2:v>=0?(i.push(p),f.slice(0,v)+ll+f.slice(v)+zr+E):f+zr+(v===-2?d:E)}return[Jh(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};let dl=class h2{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=td(t,e);if(this.el=h2.createElement(p,i),Hs.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=Hs.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(ll)){const b=g[c++],E=s.getAttribute(v).split(zr),k=/([.?@])?(.*)/.exec(b);f.push({type:1,index:o,name:k[2],strings:E,ctor:k[1]==="."?id:k[1]==="?"?rd:k[1]==="@"?sd:Xn}),s.removeAttribute(v)}else v.startsWith(zr)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(qh.test(s.tagName)){const v=s.textContent.split(zr),b=v.length-1;if(b>0){s.textContent=Wa?Wa.emptyScript:"";for(let E=0;E<b;E++)s.append(v[E],ja()),Hs.nextNode(),f.push({type:2,index:++o});s.append(v[b],ja())}}}else if(s.nodeType===8)if(s.data===cl)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(zr,v+1))!==-1;)f.push({type:7,index:o}),v+=zr.length-1}o++}}static createElement(t,e){const i=Gs.createElement("template");return i.innerHTML=t,i}};function Ws(n,t,e=n,i){var c,d;if(t===us)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=zn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=Ws(n,s._$AS(n,t.values),s,i)),t}let ed=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Gs).importNode(e,!0);Hs.currentNode=s;let o=Hs.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new ul(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new nd(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Hs.nextNode(),c++)}return Hs.currentNode=Gs,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},ul=class d2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=Qe,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Ws(this,t,e),zn(t)?t===Qe||t==null||t===""?(this._$AH!==Qe&&this._$AR(),this._$AH=Qe):t!==this._$AH&&t!==us&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Kh(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==Qe&&zn(this._$AH)?this._$AA.nextSibling.data=t:this.$(Gs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=dl.createElement(Jh(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new ed(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=Qh.get(t.strings);return e===void 0&&Qh.set(t.strings,e=new dl(t)),e}T(t){jh(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new d2(this.k(ja()),this.k(ja()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Xn=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=Qe,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Qe}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=Ws(this,t,e,0),c=!zn(t)||t!==this._$AH&&t!==us,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=Ws(this,d[i+f],e,f),p===us&&(p=this._$AH[f]),c||(c=!zn(p)||p!==this._$AH[f]),p===Qe?t=Qe:t!==Qe&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===Qe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},id=class extends Xn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===Qe?void 0:t}},rd=class extends Xn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==Qe)}},sd=class extends Xn{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=Ws(this,t,e,0)??Qe)===us)return;const i=this._$AH,s=t===Qe&&i!==Qe||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==Qe&&(i===Qe||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},nd=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){Ws(this,t)}};const w2={j:ll,P:zr,A:cl,C:1,M:td,L:ed,R:Kh,V:Ws,D:ul,I:Xn,H:rd,N:sd,U:id,B:nd},fl=Yn.litHtmlPolyfillSupport;fl==null||fl(dl,ul),(Yn.litHtmlVersions??(Yn.litHtmlVersions=[])).push("3.1.0");/**
16
16
  * @license
17
17
  * Copyright 2019 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */const Ba=globalThis,cl=Ba.ShadowRoot&&(Ba.ShadyCSS===void 0||Ba.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,hl=Symbol(),qh=new WeakMap;let Qh=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==hl)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(cl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=qh.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&qh.set(e,t))}return t}toString(){return this.cssText}};const Wn=n=>new Qh(typeof n=="string"?n:n+"",void 0,hl),Ii=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,o)=>i+(c=>{if(c._$cssResult$===!0)return c.cssText;if(typeof c=="number")return c;throw Error("Value passed to 'css' function must be a 'css' function result: "+c+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[o+1],n[0]);return new Qh(e,n,hl)},g2=(n,t)=>{if(cl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ba.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},Jh=cl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Wn(e)})(n):n;/**
19
+ */const Ka=globalThis,pl=Ka.ShadowRoot&&(Ka.ShadyCSS===void 0||Ka.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,gl=Symbol(),ad=new WeakMap;let od=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==gl)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(pl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ad.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ad.set(e,t))}return t}toString(){return this.cssText}};const qn=n=>new od(typeof n=="string"?n:n+"",void 0,gl),ki=(n,...t)=>{const e=n.length===1?n[0]:t.reduce((i,s,o)=>i+(c=>{if(c._$cssResult$===!0)return c.cssText;if(typeof c=="number")return c;throw Error("Value passed to 'css' function must be a 'css' function result: "+c+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[o+1],n[0]);return new od(e,n,gl)},S2=(n,t)=>{if(pl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ka.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},ld=pl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return qn(e)})(n):n;/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const{is:m2,defineProperty:v2,getOwnPropertyDescriptor:y2,getOwnPropertyNames:b2,getOwnPropertySymbols:A2,getPrototypeOf:E2}=Object,hs=globalThis,td=hs.trustedTypes,T2=td?td.emptyScript:"",dl=hs.reactiveElementPolyfillSupport,Kn=(n,t)=>n,ul={toAttribute(n,t){switch(t){case Boolean:n=n?T2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},ed=(n,t)=>!m2(n,t),id={attribute:!0,type:String,converter:ul,reflect:!1,hasChanged:ed};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),hs.litPropertyMetadata??(hs.litPropertyMetadata=new WeakMap);let hn=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=id){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&v2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=y2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??id}static _$Ei(){if(this.hasOwnProperty(Kn("elementProperties")))return;const t=E2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Kn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Kn("properties"))){const e=this.properties,i=[...b2(e),...A2(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Jh(s))}else t!==void 0&&e.push(Jh(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return g2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:ul).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:ul;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??ed)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}};hn.elementStyles=[],hn.shadowRootOptions={mode:"open"},hn[Kn("elementProperties")]=new Map,hn[Kn("finalized")]=new Map,dl==null||dl({ReactiveElement:hn}),(hs.reactiveElementVersions??(hs.reactiveElementVersions=[])).push("2.0.2");/**
23
+ */const{is:R2,defineProperty:L2,getOwnPropertyDescriptor:_2,getOwnPropertyNames:C2,getOwnPropertySymbols:I2,getPrototypeOf:D2}=Object,fs=globalThis,cd=fs.trustedTypes,x2=cd?cd.emptyScript:"",ml=fs.reactiveElementPolyfillSupport,Qn=(n,t)=>n,vl={toAttribute(n,t){switch(t){case Boolean:n=n?x2:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},hd=(n,t)=>!R2(n,t),dd={attribute:!0,type:String,converter:vl,reflect:!1,hasChanged:hd};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),fs.litPropertyMetadata??(fs.litPropertyMetadata=new WeakMap);let mn=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=dd){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&L2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=_2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??dd}static _$Ei(){if(this.hasOwnProperty(Qn("elementProperties")))return;const t=D2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Qn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Qn("properties"))){const e=this.properties,i=[...C2(e),...I2(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(ld(s))}else t!==void 0&&e.push(ld(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$ES(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$E_??(this._$E_=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$E_)==null||e.delete(t)}_$ES(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$E_)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:vl).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:vl;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??hd)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$E_)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}};mn.elementStyles=[],mn.shadowRootOptions={mode:"open"},mn[Qn("elementProperties")]=new Map,mn[Qn("finalized")]=new Map,ml==null||ml({ReactiveElement:mn}),(fs.reactiveElementVersions??(fs.reactiveElementVersions=[])).push("2.0.2");/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */const jn=globalThis,Ga=jn.trustedTypes,rd=Ga?Ga.createPolicy("lit-html",{createHTML:n=>n}):void 0,sd="$lit$",ds=`lit$${(Math.random()+"").slice(9)}$`,nd="?"+ds,k2=`<${nd}>`,Gs=document,zn=()=>Gs.createComment(""),Yn=n=>n===null||typeof n!="object"&&typeof n!="function",ad=Array.isArray,w2=n=>ad(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",fl=`[
28
- \f\r]`,Zn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,od=/-->/g,ld=/>/g,Hs=RegExp(`>|${fl}(?:([^\\s"'>=/]+)(${fl}*=${fl}*(?:[^
29
- \f\r"'\`<>=]|("|')|))|$)`,"g"),cd=/'/g,hd=/"/g,dd=/^(?:script|style|textarea|title)$/i,S2=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),ne=S2(1),us=Symbol.for("lit-noChange"),hi=Symbol.for("lit-nothing"),ud=new WeakMap,Vs=Gs.createTreeWalker(Gs,129);function fd(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return rd!==void 0?rd.createHTML(t):t}const L2=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=Zn;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,A=0;for(;A<f.length&&(c.lastIndex=A,g=c.exec(f),g!==null);)A=c.lastIndex,c===Zn?g[1]==="!--"?c=od:g[1]!==void 0?c=ld:g[2]!==void 0?(dd.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Hs):g[3]!==void 0&&(c=Hs):c===Hs?g[0]===">"?(c=s??Zn,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Hs:g[3]==='"'?hd:cd):c===hd||c===cd?c=Hs:c===od||c===ld?c=Zn:(c=Hs,s=void 0);const T=c===Hs&&n[d+1].startsWith("/>")?" ":"";o+=c===Zn?f+k2:v>=0?(i.push(p),f.slice(0,v)+sd+f.slice(v)+ds+T):f+ds+(v===-2?d:T)}return[fd(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};class Xn{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=L2(t,e);if(this.el=Xn.createElement(p,i),Vs.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=Vs.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(sd)){const A=g[c++],T=s.getAttribute(v).split(ds),E=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:E[2],strings:T,ctor:E[1]==="."?_2:E[1]==="?"?C2:E[1]==="@"?I2:Ha}),s.removeAttribute(v)}else v.startsWith(ds)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(dd.test(s.tagName)){const v=s.textContent.split(ds),A=v.length-1;if(A>0){s.textContent=Ga?Ga.emptyScript:"";for(let T=0;T<A;T++)s.append(v[T],zn()),Vs.nextNode(),f.push({type:2,index:++o});s.append(v[A],zn())}}}else if(s.nodeType===8)if(s.data===nd)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(ds,v+1))!==-1;)f.push({type:7,index:o}),v+=ds.length-1}o++}}static createElement(t,e){const i=Gs.createElement("template");return i.innerHTML=t,i}}function dn(n,t,e=n,i){var c,d;if(t===us)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=Yn(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=dn(n,s._$AS(n,t.values),s,i)),t}let R2=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??Gs).importNode(e,!0);Vs.currentNode=s;let o=Vs.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new pl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new D2(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Vs.nextNode(),c++)}return Vs.currentNode=Gs,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},pl=class i2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=hi,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=dn(this,t,e),Yn(t)?t===hi||t==null||t===""?(this._$AH!==hi&&this._$AR(),this._$AH=hi):t!==this._$AH&&t!==us&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):w2(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==hi&&Yn(this._$AH)?this._$AA.nextSibling.data=t:this.$(Gs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Xn.createElement(fd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new R2(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=ud.get(t.strings);return e===void 0&&ud.set(t.strings,e=new Xn(t)),e}T(t){ad(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new i2(this.k(zn()),this.k(zn()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class Ha{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=hi,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=hi}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=dn(this,t,e,0),c=!Yn(t)||t!==this._$AH&&t!==us,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=dn(this,d[i+f],e,f),p===us&&(p=this._$AH[f]),c||(c=!Yn(p)||p!==this._$AH[f]),p===hi?t=hi:t!==hi&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===hi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class _2 extends Ha{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===hi?void 0:t}}let C2=class extends Ha{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==hi)}};class I2 extends Ha{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=dn(this,t,e,0)??hi)===us)return;const i=this._$AH,s=t===hi&&i!==hi||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==hi&&(i===hi||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}let D2=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){dn(this,t)}};const gl=jn.litHtmlPolyfillSupport;gl==null||gl(Xn,pl),(jn.litHtmlVersions??(jn.litHtmlVersions=[])).push("3.1.0");const x2=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new pl(t.insertBefore(zn(),o),o,void 0,e??{})}return s._$AI(n),s};/**
27
+ */const Jn=globalThis,Ya=Jn.trustedTypes,ud=Ya?Ya.createPolicy("lit-html",{createHTML:n=>n}):void 0,fd="$lit$",ps=`lit$${(Math.random()+"").slice(9)}$`,pd="?"+ps,P2=`<${pd}>`,js=document,ta=()=>js.createComment(""),ea=n=>n===null||typeof n!="object"&&typeof n!="function",gd=Array.isArray,O2=n=>gd(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",yl=`[
28
+ \f\r]`,ia=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,md=/-->/g,vd=/>/g,Ks=RegExp(`>|${yl}(?:([^\\s"'>=/]+)(${yl}*=${yl}*(?:[^
29
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),yd=/'/g,bd=/"/g,Ad=/^(?:script|style|textarea|title)$/i,M2=n=>(t,...e)=>({_$litType$:n,strings:t,values:e}),ie=M2(1),gs=Symbol.for("lit-noChange"),di=Symbol.for("lit-nothing"),Ed=new WeakMap,Ys=js.createTreeWalker(js,129);function kd(n,t){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return ud!==void 0?ud.createHTML(t):t}const $2=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":"",c=ia;for(let d=0;d<e;d++){const f=n[d];let p,g,v=-1,b=0;for(;b<f.length&&(c.lastIndex=b,g=c.exec(f),g!==null);)b=c.lastIndex,c===ia?g[1]==="!--"?c=md:g[1]!==void 0?c=vd:g[2]!==void 0?(Ad.test(g[2])&&(s=RegExp("</"+g[2],"g")),c=Ks):g[3]!==void 0&&(c=Ks):c===Ks?g[0]===">"?(c=s??ia,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?Ks:g[3]==='"'?bd:yd):c===bd||c===yd?c=Ks:c===md||c===vd?c=ia:(c=Ks,s=void 0);const E=c===Ks&&n[d+1].startsWith("/>")?" ":"";o+=c===ia?f+P2:v>=0?(i.push(p),f.slice(0,v)+fd+f.slice(v)+ps+E):f+ps+(v===-2?d:E)}return[kd(n,o+(n[e]||"<?>")+(t===2?"</svg>":"")),i]};class ra{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=$2(t,e);if(this.el=ra.createElement(p,i),Ys.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(s=Ys.nextNode())!==null&&f.length<d;){if(s.nodeType===1){if(s.hasAttributes())for(const v of s.getAttributeNames())if(v.endsWith(fd)){const b=g[c++],E=s.getAttribute(v).split(ps),k=/([.?@])?(.*)/.exec(b);f.push({type:1,index:o,name:k[2],strings:E,ctor:k[1]==="."?N2:k[1]==="?"?U2:k[1]==="@"?B2:za}),s.removeAttribute(v)}else v.startsWith(ps)&&(f.push({type:6,index:o}),s.removeAttribute(v));if(Ad.test(s.tagName)){const v=s.textContent.split(ps),b=v.length-1;if(b>0){s.textContent=Ya?Ya.emptyScript:"";for(let E=0;E<b;E++)s.append(v[E],ta()),Ys.nextNode(),f.push({type:2,index:++o});s.append(v[b],ta())}}}else if(s.nodeType===8)if(s.data===pd)f.push({type:2,index:o});else{let v=-1;for(;(v=s.data.indexOf(ps,v+1))!==-1;)f.push({type:7,index:o}),v+=ps.length-1}o++}}static createElement(t,e){const i=js.createElement("template");return i.innerHTML=t,i}}function vn(n,t,e=n,i){var c,d;if(t===gs)return t;let s=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=ea(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((d=s==null?void 0:s._$AO)==null||d.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=vn(n,s._$AS(n,t.values),s,i)),t}let F2=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??js).importNode(e,!0);Ys.currentNode=s;let o=Ys.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new bl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new G2(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Ys.nextNode(),c++)}return Ys.currentNode=js,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},bl=class u2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=di,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=vn(this,t,e),ea(t)?t===di||t==null||t===""?(this._$AH!==di&&this._$AR(),this._$AH=di):t!==this._$AH&&t!==gs&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):O2(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==di&&ea(this._$AH)?this._$AA.nextSibling.data=t:this.$(js.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=ra.createElement(kd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const c=new F2(s,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=Ed.get(t.strings);return e===void 0&&Ed.set(t.strings,e=new ra(t)),e}T(t){gd(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new u2(this.k(ta()),this.k(ta()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}};class za{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=di,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=di}_$AI(t,e=this,i,s){const o=this.strings;let c=!1;if(o===void 0)t=vn(this,t,e,0),c=!ea(t)||t!==this._$AH&&t!==gs,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=vn(this,d[i+f],e,f),p===gs&&(p=this._$AH[f]),c||(c=!ea(p)||p!==this._$AH[f]),p===di?t=di:t!==di&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!s&&this.O(t)}O(t){t===di?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class N2 extends za{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===di?void 0:t}}let U2=class extends za{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==di)}};class B2 extends za{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=vn(this,t,e,0)??di)===gs)return;const i=this._$AH,s=t===di&&i!==di||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==di&&(i===di||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}let G2=class{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){vn(this,t)}};const Al=Jn.litHtmlPolyfillSupport;Al==null||Al(ra,bl),(Jn.litHtmlVersions??(Jn.litHtmlVersions=[])).push("3.1.0");const V2=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new bl(t.insertBefore(ta(),o),o,void 0,e??{})}return s._$AI(n),s};/**
30
30
  * @license
31
31
  * Copyright 2017 Google LLC
32
32
  * SPDX-License-Identifier: BSD-3-Clause
33
- */let un=class extends hn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=x2(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return us}};un._$litElement$=!0,un.finalized=!0,($f=globalThis.litElementHydrateSupport)==null||$f.call(globalThis,{LitElement:un});const ml=globalThis.litElementPolyfillSupport;ml==null||ml({LitElement:un}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
33
+ */let yn=class extends mn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=V2(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return gs}};yn._$litElement$=!0,yn.finalized=!0,(Kf=globalThis.litElementHydrateSupport)==null||Kf.call(globalThis,{LitElement:yn});const El=globalThis.litElementPolyfillSupport;El==null||El({LitElement:yn}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
34
34
  * @license
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
- */const P2=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};/**
37
+ */const H2=n=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(n,t)}):customElements.define(n,t)};/**
38
38
  * @license
39
39
  * Copyright 2017 Google LLC
40
40
  * SPDX-License-Identifier: BSD-3-Clause
41
- */const O2={attribute:!0,type:String,converter:Fa,reflect:!1,hasChanged:il},M2=(n=O2,t,e)=>{const{kind:i,metadata:s}=e;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(e.name,n),i==="accessor"){const{name:c}=e;return{set(d){const f=t.get.call(this);t.set.call(this,d),this.requestUpdate(c,f,n)},init(d){return d!==void 0&&this.C(c,void 0,n),d}}}if(i==="setter"){const{name:c}=e;return function(d){const f=this[c];t.call(this,d),this.requestUpdate(c,f,n)}}throw Error("Unsupported decorator location: "+i)};function Mt(n){return(t,e)=>typeof e=="object"?M2(n,t,e):((i,s,o)=>{const c=s.hasOwnProperty(o);return s.constructor.createProperty(o,c?{...i,wrapped:!0}:i),c?Object.getOwnPropertyDescriptor(s,o):void 0})(n,t,e)}/**
41
+ */const W2={attribute:!0,type:String,converter:Ha,reflect:!1,hasChanged:ol},j2=(n=W2,t,e)=>{const{kind:i,metadata:s}=e;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(e.name,n),i==="accessor"){const{name:c}=e;return{set(d){const f=t.get.call(this);t.set.call(this,d),this.requestUpdate(c,f,n)},init(d){return d!==void 0&&this.C(c,void 0,n),d}}}if(i==="setter"){const{name:c}=e;return function(d){const f=this[c];t.call(this,d),this.requestUpdate(c,f,n)}}throw Error("Unsupported decorator location: "+i)};function It(n){return(t,e)=>typeof e=="object"?j2(n,t,e):((i,s,o)=>{const c=s.hasOwnProperty(o);return s.constructor.createProperty(o,c?{...i,wrapped:!0}:i),c?Object.getOwnPropertyDescriptor(s,o):void 0})(n,t,e)}/**
42
42
  * @license
43
43
  * Copyright 2017 Google LLC
44
44
  * SPDX-License-Identifier: BSD-3-Clause
45
- */function Di(n){return Mt({...n,state:!0,attribute:!1})}/**
45
+ */function Ti(n){return It({...n,state:!0,attribute:!1})}/**
46
46
  * @license
47
47
  * Copyright 2018 Google LLC
48
48
  * SPDX-License-Identifier: BSD-3-Clause
49
- */const Ws=n=>n??Xe;/**
49
+ */const zs=n=>n??Qe;/**
50
50
  * @license
51
51
  * Copyright 2020 Google LLC
52
52
  * SPDX-License-Identifier: BSD-3-Clause
53
- */const{D:$2}=p2,F2=n=>n.strings===void 0,pd=()=>document.createComment(""),qn=(n,t,e)=>{var o;const i=n._$AA.parentNode,s=t===void 0?n._$AB:t._$AA;if(e===void 0){const c=i.insertBefore(pd(),s),d=i.insertBefore(pd(),s);e=new $2(c,d,n,n.options)}else{const c=e._$AB.nextSibling,d=e._$AM,f=d!==n;if(f){let p;(o=e._$AQ)==null||o.call(e,n),e._$AM=n,e._$AP!==void 0&&(p=n._$AU)!==d._$AU&&e._$AP(p)}if(c!==s||f){let p=e._$AA;for(;p!==c;){const g=p.nextSibling;i.insertBefore(p,s),p=g}}}return e},Ks=(n,t,e=n)=>(n._$AI(t,e),n),N2={},U2=(n,t=N2)=>n._$AH=t,B2=n=>n._$AH,vl=n=>{var i;(i=n._$AP)==null||i.call(n,!1,!0);let t=n._$AA;const e=n._$AB.nextSibling;for(;t!==e;){const s=t.nextSibling;t.remove(),t=s}};/**
53
+ */const{D:K2}=w2,Y2=n=>n.strings===void 0,Td=()=>document.createComment(""),sa=(n,t,e)=>{var o;const i=n._$AA.parentNode,s=t===void 0?n._$AB:t._$AA;if(e===void 0){const c=i.insertBefore(Td(),s),d=i.insertBefore(Td(),s);e=new K2(c,d,n,n.options)}else{const c=e._$AB.nextSibling,d=e._$AM,f=d!==n;if(f){let p;(o=e._$AQ)==null||o.call(e,n),e._$AM=n,e._$AP!==void 0&&(p=n._$AU)!==d._$AU&&e._$AP(p)}if(c!==s||f){let p=e._$AA;for(;p!==c;){const g=p.nextSibling;i.insertBefore(p,s),p=g}}}return e},Zs=(n,t,e=n)=>(n._$AI(t,e),n),z2={},Z2=(n,t=z2)=>n._$AH=t,X2=n=>n._$AH,kl=n=>{var i;(i=n._$AP)==null||i.call(n,!1,!0);let t=n._$AA;const e=n._$AB.nextSibling;for(;t!==e;){const s=t.nextSibling;t.remove(),t=s}};/**
54
54
  * @license
55
55
  * Copyright 2017 Google LLC
56
56
  * SPDX-License-Identifier: BSD-3-Clause
57
- */const Qn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Jn=n=>(...t)=>({_$litDirective$:n,values:t});let Va=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
57
+ */const bn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},An=n=>(...t)=>({_$litDirective$:n,values:t});let na=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};/**
58
58
  * @license
59
59
  * Copyright 2017 Google LLC
60
60
  * SPDX-License-Identifier: BSD-3-Clause
61
- */const ta=(n,t)=>{var i;const e=n._$AN;if(e===void 0)return!1;for(const s of e)(i=s._$AO)==null||i.call(s,t,!1),ta(s,t);return!0},Wa=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},gd=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),V2(t)}};function G2(n){this._$AN!==void 0?(Wa(this),this._$AM=n,gd(this)):this._$AM=n}function H2(n,t=!1,e=0){const i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(t)if(Array.isArray(i))for(let o=e;o<i.length;o++)ta(i[o],!1),Wa(i[o]);else i!=null&&(ta(i,!1),Wa(i));else ta(this,n)}const V2=n=>{n.type==Qn.CHILD&&(n._$AP??(n._$AP=H2),n._$AQ??(n._$AQ=G2))};let md=class extends Va{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),gd(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,s;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)==null||i.call(this):(s=this.disconnected)==null||s.call(this)),e&&(ta(this,t),Wa(this))}setValue(t){if(F2(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};/**
61
+ */const aa=(n,t)=>{var i;const e=n._$AN;if(e===void 0)return!1;for(const s of e)(i=s._$AO)==null||i.call(s,t,!1),aa(s,t);return!0},Za=n=>{let t,e;do{if((t=n._$AM)===void 0)break;e=t._$AN,e.delete(n),n=t}while((e==null?void 0:e.size)===0)},wd=n=>{for(let t;t=n._$AM;n=t){let e=t._$AN;if(e===void 0)t._$AN=e=new Set;else if(e.has(n))break;e.add(n),J2(t)}};function q2(n){this._$AN!==void 0?(Za(this),this._$AM=n,wd(this)):this._$AM=n}function Q2(n,t=!1,e=0){const i=this._$AH,s=this._$AN;if(s!==void 0&&s.size!==0)if(t)if(Array.isArray(i))for(let o=e;o<i.length;o++)aa(i[o],!1),Za(i[o]);else i!=null&&(aa(i,!1),Za(i));else aa(this,n)}const J2=n=>{n.type==bn.CHILD&&(n._$AP??(n._$AP=Q2),n._$AQ??(n._$AQ=q2))};let Sd=class extends na{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),wd(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,s;t!==this.isConnected&&(this.isConnected=t,t?(i=this.reconnected)==null||i.call(this):(s=this.disconnected)==null||s.call(this)),e&&(aa(this,t),Za(this))}setValue(t){if(Y2(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}};/**
62
62
  * @license
63
63
  * Copyright 2020 Google LLC
64
64
  * SPDX-License-Identifier: BSD-3-Clause
65
- */const rr=()=>new W2;let W2=class{};const yl=new WeakMap,sr=Jn(class extends md{render(n){return Xe}update(n,[t]){var i;const e=t!==this.G;return e&&this.G!==void 0&&this.ot(void 0),(e||this.rt!==this.lt)&&(this.G=t,this.ct=(i=n.options)==null?void 0:i.host,this.ot(this.lt=n.element)),Xe}ot(n){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=yl.get(t);e===void 0&&(e=new WeakMap,yl.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ct,n)}else this.G.value=n}get rt(){var n,t;return typeof this.G=="function"?(n=yl.get(this.ct??globalThis))==null?void 0:n.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function K2(n,t,e){function i(s){e.dispatchEvent(new CustomEvent(s.type,s))}return t.addEventListener(n,i),()=>{t.removeEventListener(n,i)}}class j2{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=rr(),this.host=t,this._events=e,t.addController(this)}register(){return sr(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(K2(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
65
+ */const wi=()=>new tg;let tg=class{};const Tl=new WeakMap,Si=An(class extends Sd{render(n){return Qe}update(n,[t]){var i;const e=t!==this.G;return e&&this.G!==void 0&&this.ot(void 0),(e||this.rt!==this.lt)&&(this.G=t,this.ct=(i=n.options)==null?void 0:i.host,this.ot(this.lt=n.element)),Qe}ot(n){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=Tl.get(t);e===void 0&&(e=new WeakMap,Tl.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,n),n!==void 0&&this.G.call(this.ct,n)}else this.G.value=n}get rt(){var n,t;return typeof this.G=="function"?(n=Tl.get(this.ct??globalThis))==null?void 0:n.get(this.G):(t=this.G)==null?void 0:t.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function eg(n,t,e){function i(s){e.dispatchEvent(new CustomEvent(s.type,s))}return t.addEventListener(n,i),()=>{t.removeEventListener(n,i)}}class ig{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=wi(),this.host=t,this._events=e,t.addController(this)}register(){return Si(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(eg(t,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(t=>{t()}),this._cleanup=[]}}/**
66
66
  * @license
67
67
  * Copyright 2019 Google LLC
68
68
  * SPDX-License-Identifier: BSD-3-Clause
69
- */const Ka=globalThis,bl=Ka.ShadowRoot&&(Ka.ShadyCSS===void 0||Ka.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,vd=Symbol(),yd=new WeakMap;let z2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==vd)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(bl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=yd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&yd.set(e,t))}return t}toString(){return this.cssText}};const Y2=n=>new z2(typeof n=="string"?n:n+"",void 0,vd),Z2=(n,t)=>{if(bl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Ka.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},bd=bl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Y2(e)})(n):n;/**
69
+ */const Xa=globalThis,wl=Xa.ShadowRoot&&(Xa.ShadyCSS===void 0||Xa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Rd=Symbol(),Ld=new WeakMap;let rg=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Rd)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(wl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Ld.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Ld.set(e,t))}return t}toString(){return this.cssText}};const sg=n=>new rg(typeof n=="string"?n:n+"",void 0,Rd),ng=(n,t)=>{if(wl)n.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),s=Xa.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=e.cssText,n.appendChild(i)}},_d=wl?n=>n:n=>n instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return sg(e)})(n):n;/**
70
70
  * @license
71
71
  * Copyright 2017 Google LLC
72
72
  * SPDX-License-Identifier: BSD-3-Clause
73
- */const{is:X2,defineProperty:q2,getOwnPropertyDescriptor:Q2,getOwnPropertyNames:J2,getOwnPropertySymbols:tg,getPrototypeOf:eg}=Object,fs=globalThis,Ad=fs.trustedTypes,ig=Ad?Ad.emptyScript:"",Al=fs.reactiveElementPolyfillSupport,ea=(n,t)=>n,El={toAttribute(n,t){switch(t){case Boolean:n=n?ig:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Tl=(n,t)=>!X2(n,t),Ed={attribute:!0,type:String,converter:El,reflect:!1,hasChanged:Tl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),fs.litPropertyMetadata??(fs.litPropertyMetadata=new WeakMap);class ia extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ed){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&q2(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=Q2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ed}static _$Ei(){if(this.hasOwnProperty(ea("elementProperties")))return;const t=eg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ea("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ea("properties"))){const e=this.properties,i=[...J2(e),...tg(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(bd(s))}else t!==void 0&&e.push(bd(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$ES??(this._$ES=[])).push(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$ES)==null||e.splice(this._$ES.indexOf(t)>>>0,1)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Z2(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:El).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:El;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Tl)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}}ia.elementStyles=[],ia.shadowRootOptions={mode:"open"},ia[ea("elementProperties")]=new Map,ia[ea("finalized")]=new Map,Al==null||Al({ReactiveElement:ia}),(fs.reactiveElementVersions??(fs.reactiveElementVersions=[])).push("2.0.0");/**
73
+ */const{is:ag,defineProperty:og,getOwnPropertyDescriptor:lg,getOwnPropertyNames:cg,getOwnPropertySymbols:hg,getPrototypeOf:dg}=Object,ms=globalThis,Cd=ms.trustedTypes,ug=Cd?Cd.emptyScript:"",Sl=ms.reactiveElementPolyfillSupport,oa=(n,t)=>n,Rl={toAttribute(n,t){switch(t){case Boolean:n=n?ug:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},Ll=(n,t)=>!ag(n,t),Id={attribute:!0,type:String,converter:Rl,reflect:!1,hasChanged:Ll};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),ms.litPropertyMetadata??(ms.litPropertyMetadata=new WeakMap);class la extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Id){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&og(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=lg(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return s==null?void 0:s.call(this)},set(c){const d=s==null?void 0:s.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Id}static _$Ei(){if(this.hasOwnProperty(oa("elementProperties")))return;const t=dg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(oa("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(oa("properties"))){const e=this.properties,i=[...cg(e),...hg(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(_d(s))}else t!==void 0&&e.push(_d(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$Eg=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$ES??(this._$ES=[])).push(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$ES)==null||e.splice(this._$ES.indexOf(t)>>>0,1)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ng(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$ES)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Rl).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(s):this.setAttribute(s,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const c=i.getPropertyOptions(s),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Rl;this._$Em=s,this[s]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,s=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Ll)(s?o:this[t],e))return;this.C(t,e,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[o,c]of this._$Ep)this[o]=c;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,c]of s)c.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.C(o,this[o],c)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$ES)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$ET()}catch(s){throw t=!1,this._$ET(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EO(e,this[e]))),this._$ET()}updated(t){}firstUpdated(t){}}la.elementStyles=[],la.shadowRootOptions={mode:"open"},la[oa("elementProperties")]=new Map,la[oa("finalized")]=new Map,Sl==null||Sl({ReactiveElement:la}),(ms.reactiveElementVersions??(ms.reactiveElementVersions=[])).push("2.0.0");/**
74
74
  * @license
75
75
  * Copyright 2017 Google LLC
76
76
  * SPDX-License-Identifier: BSD-3-Clause
77
- */const rg=Symbol();class Td{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??sg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===rg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const sg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!Tl(e,t[i])),kd="https://d2rxhdlm2q91uk.cloudfront.net",ng="https://d1ix11aj5kfygl.cloudfront.net",ag="https://d157jlwnudd93d.cloudfront.net",wd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",og="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",lg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",cg="http://localhost:6060/v2",hg="https://embed-dev.vouchfor.com/v2",dg="https://embed-staging.vouchfor.com/v2",ug="https://embed.vouchfor.com/v2";function ja(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:kd,publicApiUrl:wd,embedApiUrl:cg};if(n==="dev")return{videoUrl:kd,publicApiUrl:wd,embedApiUrl:hg};if(n==="staging")return{videoUrl:ng,publicApiUrl:og,embedApiUrl:dg};if(n==="prod")return{videoUrl:ag,publicApiUrl:lg,embedApiUrl:ug}}class fg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{const{embedApiUrl:o}=ja(e),c=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i]]}).then(d=>(this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:s})),d.json()));return fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),c},this.getTemplate=async(e,i,s)=>{const{embedApiUrl:o}=ja(e),c=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i]]}).then(d=>d.json());return fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),c},this.host=t,new Td(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),t.vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,A]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);t.vouch=v,t.template=A??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}let za;const pg=new Uint8Array(16);function gg(){if(!za&&(za=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!za))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return za(pg)}const yi=[];for(let n=0;n<256;++n)yi.push((n+256).toString(16).slice(1));function mg(n,t=0){return yi[n[t+0]]+yi[n[t+1]]+yi[n[t+2]]+yi[n[t+3]]+"-"+yi[n[t+4]]+yi[n[t+5]]+"-"+yi[n[t+6]]+yi[n[t+7]]+"-"+yi[n[t+8]]+yi[n[t+9]]+"-"+yi[n[t+10]]+yi[n[t+11]]+yi[n[t+12]]+yi[n[t+13]]+yi[n[t+14]]+yi[n[t+15]]}const Sd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ra(n,t,e){if(Sd.randomUUID&&!t&&!n)return Sd.randomUUID();n=n||{};const i=n.random||(n.rng||gg)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return mg(i)}const vg=2e3;class yg{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamedTime={},this._streamedPrevTimestamp={},this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=ja(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...s}},this._sendTrackingEvent=(e,i)=>{const{publicApiUrl:s}=ja(this.host.env),{client:o,tab:c,request:d,visitor:f}=this._getUids();navigator.sendBeacon(`${s}/api/events`,JSON.stringify({event:e,payload:i,context:{"x-uid-client":o,"x-uid-tab":c,"x-uid-request":d,"x-uid-visitor":f,"x-reporting-metadata":this._getReportingMetadata()}}))},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{const e=this._findVouchId();e&&(this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{vouchId:e,streamStart:this.host.currentTime}),this._hasPlayed=!0))},this._handleVideoPlay=({detail:{id:e,node:i}})=>{const s=this._findVouchId();s&&(this._answersViewed[e]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{vouchId:s,answerId:e}),this._answersViewed[e]=!0),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=Date.now())},this._handleVideoTimeUpdate=({detail:{id:e,node:i}})=>{var c,d;const s=this._findVouchId();if(!s)return;const o=Date.now();!this.host.paused&&e===((d=(c=this.host.scene)==null?void 0:c.video)==null?void 0:d.id)&&o-this._streamedPrevTimestamp[e]>vg&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),this._streamedTime[e]=i.currentTime,this._streamedPrevTimestamp[e]=o)},this._handleVideoPause=({detail:{id:e,node:i}})=>{const s=this._findVouchId();s&&(this._sendTrackingEvent("VIDEO_STREAMED",{vouchId:s,answerId:e,streamStart:this._streamedTime[e],streamEnd:i.currentTime}),delete this._streamedTime[e],delete this._streamedPrevTimestamp[e])},this.host=t,t.addController(this)}_findVouchId(){if(this.host.data)return"uuid"in this.host.data?this.host.data.uuid:this.host.data.id}_getUids(){var o,c,d,f,p,g,v,A,T,E,w,R;if(typeof window>"u")return{client:null,tab:null,request:ra()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(ra()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||ra(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||ra(),s=ra();return t!==this._visitorId&&(this._visitorId=t,(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(E=(T=window.localStorage)==null?void 0:T.setItem)==null||E.call(T,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(R=(w=window.sessionStorage)==null?void 0:w.setItem)==null||R.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const bg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Ag(s,o)&&i||Object.defineProperty(n,e,o)},Ag=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Eg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},Tg=(n,t)=>`/* Wrapped ${n}*/
78
- ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Sg=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=Tg.bind(null,i,t.toString());Object.defineProperty(s,"name",wg),Object.defineProperty(n,"toString",{...kg,value:s})};function Lg(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))bg(n,t,s,e);return Eg(n,t),Sg(n,t,i),n}const Rg=new WeakMap;function sa(n,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...o){const c=t(o);if(i.has(c))return i.get(c);const d=(async()=>{try{if(e&&await e.has(c))return await e.get(c);const p=await n.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return Lg(s,n,{ignoreNonConfigurable:!0}),Rg.set(s,e),s}var Ya=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function kl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var wl={exports:{}};(function(n,t){(function(e,i){i(t)})(Ya,function(e){function i($){var U,q,gt=new Error($);return U=gt,q=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(U,q):U.__proto__=q,gt}function s($,U,q){var gt=U.slice(0,q).split(/\n/),Et=gt.length,Pt=gt[Et-1].length+1;throw i($+=" at line "+Et+" col "+Pt+`:
79
-
80
- `+U.split(/\n/)[Et-1]+`
81
- `+Array(Pt).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,c=!1;try{c=new Function("return (async function(){}).constructor")()}catch($){if(!($ instanceof SyntaxError))throw $}function d($,U){return Object.prototype.hasOwnProperty.call($,U)}function f($,U,q){for(var gt in U)d(U,gt)&&(U[gt]==null||typeof U[gt]!="object"||gt!=="storage"&&gt!=="prefixes"||q?$[gt]=U[gt]:$[gt]=f({},U[gt]));return $}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,T=/[.*+\-?^${}()|[\]\\]/g;function E($){return T.test($)?$.replace(T,"\\$&"):$}function w($,U){U.rmWhitespace&&($=$.replace(/[\r\n]+/g,`
82
- `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,A.lastIndex=0;var q=U.prefixes,gt=[q.h,q.b,q.i,q.r,q.c,q.e].reduce(function(pe,Wt){return pe&&Wt?pe+"|"+E(Wt):Wt?E(Wt):pe},""),Et=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+E(U.tags[1])+")","g"),Pt=new RegExp("([^]*?)"+E(U.tags[0])+"(-|_)?\\s*("+gt+")?\\s*","g"),Ut=0,Ot=!1;function ae(pe,Wt){var de,ie={f:[]},Ce=0,Bt="c";function Ze(Qe){var Wi=$.slice(Ut,Qe),$e=Wi.trim();if(Bt==="f")$e==="safe"?ie.raw=!0:U.async&&p.test($e)?($e=$e.replace(p,""),ie.f.push([$e,"",!0])):ie.f.push([$e,""]);else if(Bt==="fp")ie.f[ie.f.length-1][1]+=$e;else if(Bt==="err"){if($e){var Si=Wi.search(/\S/);s("invalid syntax",$,Ut+Si)}}else ie[Bt]=$e;Ut=Qe+1}for(Wt==="h"||Wt==="b"||Wt==="c"?Bt="n":Wt==="r"&&(ie.raw=!0,Wt="i"),Et.lastIndex=Ut;(de=Et.exec($))!==null;){var ri=de[1],xi=de[2],Er=de[3],ke=de[4],oi=de[5],ve=de.index;if(ri)ri==="("?(Ce===0&&(Bt==="n"?(Ze(ve),Bt="p"):Bt==="f"&&(Ze(ve),Bt="fp")),Ce++):ri===")"?--Ce===0&&Bt!=="c"&&(Ze(ve),Bt="err"):Ce===0&&ri==="|"?(Ze(ve),Bt="f"):ri==="=>"&&(Ze(ve),Ut+=1,Bt="res");else if(xi)if(xi==="/*"){var qe=$.indexOf("*/",Et.lastIndex);qe===-1&&s("unclosed comment",$,de.index),Et.lastIndex=qe+2}else xi==="'"?(v.lastIndex=de.index,v.exec($)?Et.lastIndex=v.lastIndex:s("unclosed string",$,de.index)):xi==='"'?(A.lastIndex=de.index,A.exec($)?Et.lastIndex=A.lastIndex:s("unclosed string",$,de.index)):xi==="`"&&(g.lastIndex=de.index,g.exec($)?Et.lastIndex=g.lastIndex:s("unclosed string",$,de.index));else if(Er)return Ze(ve),Ut=ve+de[0].length,Pt.lastIndex=Ut,Ot=oi,ke&&Wt==="h"&&(Wt="s"),ie.t=Wt,ie}return s("unclosed tag",$,pe),ie}var oe=function pe(Wt,de){Wt.b=[],Wt.d=[];var ie,Ce=!1,Bt=[];function Ze(Si,es){Si&&(Si=function(li,Tr,Es,Ts){var Ji,ct;return typeof Tr.autoTrim=="string"?Ji=ct=Tr.autoTrim:Array.isArray(Tr.autoTrim)&&(Ji=Tr.autoTrim[1],ct=Tr.autoTrim[0]),(Es||Es===!1)&&(Ji=Es),(Ts||Ts===!1)&&(ct=Ts),Ji==="slurp"&&ct==="slurp"?li.trim():(Ji==="_"||Ji==="slurp"?li=String.prototype.trimLeft?li.trimLeft():li.replace(/^[\s\uFEFF\xA0]+/,""):Ji!=="-"&&Ji!=="nl"||(li=li.replace(/^(?:\n|\r|\r\n)/,"")),ct==="_"||ct==="slurp"?li=String.prototype.trimRight?li.trimRight():li.replace(/[\s\uFEFF\xA0]+$/,""):ct!=="-"&&ct!=="nl"||(li=li.replace(/(?:\n|\r|\r\n)$/,"")),li)}(Si,U,Ot,es))&&(Si=Si.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Bt.push(Si))}for(;(ie=Pt.exec($))!==null;){var ri,xi=ie[1],Er=ie[2],ke=ie[3]||"";for(var oi in q)if(q[oi]===ke){ri=oi;break}Ze(xi,Er),Ut=ie.index+ie[0].length,ri||s("unrecognized tag type: "+ke,$,Ut);var ve=ae(ie.index,ri),qe=ve.t;if(qe==="h"){var Qe=ve.n||"";U.async&&p.test(Qe)&&(ve.a=!0,ve.n=Qe.replace(p,"")),ve=pe(ve),Bt.push(ve)}else if(qe==="c"){if(Wt.n===ve.n)return Ce?(Ce.d=Bt,Wt.b.push(Ce)):Wt.d=Bt,Wt;s("Helper start and end don't match",$,ie.index+ie[0].length)}else if(qe==="b"){Ce?(Ce.d=Bt,Wt.b.push(Ce)):Wt.d=Bt;var Wi=ve.n||"";U.async&&p.test(Wi)&&(ve.a=!0,ve.n=Wi.replace(p,"")),Ce=ve,Bt=[]}else if(qe==="s"){var $e=ve.n||"";U.async&&p.test($e)&&(ve.a=!0,ve.n=$e.replace(p,"")),Bt.push(ve)}else Bt.push(ve)}if(!de)throw i('unclosed helper "'+Wt.n+'"');return Ze($.slice(Ut,$.length),!1),Wt.d=Bt,Wt}({f:[]},!0);if(U.plugins)for(var he=0;he<U.plugins.length;he++){var Te=U.plugins[he];Te.processAST&&(oe.d=Te.processAST(oe.d,U))}return oe.d}function R($,U){var q=w($,U),gt="var tR='';"+(U.useWith?"with("+U.varName+"||{}){":"")+F(q,U)+"if(cb){cb(null,tR)} return tR"+(U.useWith?"}":"");if(U.plugins)for(var Et=0;Et<U.plugins.length;Et++){var Pt=U.plugins[Et];Pt.processFnString&&(gt=Pt.processFnString(gt,U))}return gt}function x($,U){for(var q=0;q<U.length;q++){var gt=U[q][0],Et=U[q][1];$=(U[q][2]?"await ":"")+"c.l('F','"+gt+"')("+$,Et&&($+=","+Et),$+=")"}return $}function M($,U,q,gt,Et,Pt){var Ut="{exec:"+(Et?"async ":"")+_(q,U,$)+",params:["+gt+"]";return Pt&&(Ut+=",name:'"+Pt+"'"),Et&&(Ut+=",async:true"),Ut+="}"}function G($,U){for(var q="[",gt=0;gt<$.length;gt++){var Et=$[gt];q+=M(U,Et.res||"",Et.d,Et.p||"",Et.a,Et.n),gt<$.length&&(q+=",")}return q+="]"}function _($,U,q){return"function("+U+"){var tR='';"+F($,q)+"return tR}"}function F($,U){for(var q=0,gt=$.length,Et="";q<gt;q++){var Pt=$[q];if(typeof Pt=="string")Et+="tR+='"+Pt+"';";else{var Ut=Pt.t,Ot=Pt.c||"",ae=Pt.f,oe=Pt.n||"",he=Pt.p||"",Te=Pt.res||"",pe=Pt.b,Wt=!!Pt.a;if(Ut==="i"){U.defaultFilter&&(Ot="c.l('F','"+U.defaultFilter+"')("+Ot+")");var de=x(Ot,ae);!Pt.raw&&U.autoEscape&&(de="c.l('F','e')("+de+")"),Et+="tR+="+de+";"}else if(Ut==="h")if(U.storage.nativeHelpers.get(oe))Et+=U.storage.nativeHelpers.get(oe)(Pt,U);else{var ie=(Wt?"await ":"")+"c.l('H','"+oe+"')("+M(U,Te,Pt.d,he,Wt);ie+=pe?","+G(pe,U):",[]",Et+="tR+="+x(ie+=",c)",ae)+";"}else Ut==="s"?Et+="tR+="+x((Wt?"await ":"")+"c.l('H','"+oe+"')({params:["+he+"]},[],c)",ae)+";":Ut==="e"&&(Et+=Ot+`
83
- `)}}return Et}var H=function(){function $(U){this.cache=U}return $.prototype.define=function(U,q){this.cache[U]=q},$.prototype.get=function(U){return this.cache[U]},$.prototype.remove=function(U){delete this.cache[U]},$.prototype.reset=function(){this.cache={}},$.prototype.load=function(U){f(this.cache,U,!0)},$}();function j($,U,q,gt){if(U&&U.length>0)throw i((gt?"Native":"")+"Helper '"+$+"' doesn't accept blocks");if(q&&q.length>0)throw i((gt?"Native":"")+"Helper '"+$+"' doesn't accept filters")}var nt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ot($){return nt[$]}var tt=new H({}),kt=new H({each:function($,U){var q="",gt=$.params[0];if(j("each",U,!1),$.async)return new Promise(function(Pt){(function Ut(Ot,ae,oe,he,Te){oe(Ot[ae],ae).then(function(pe){he+=pe,ae===Ot.length-1?Te(he):Ut(Ot,ae+1,oe,he,Te)})})(gt,0,$.exec,q,Pt)});for(var Et=0;Et<gt.length;Et++)q+=$.exec(gt[Et],Et);return q},foreach:function($,U){var q=$.params[0];if(j("foreach",U,!1),$.async)return new Promise(function(Pt){(function Ut(Ot,ae,oe,he,Te,pe){he(ae[oe],Ot[ae[oe]]).then(function(Wt){Te+=Wt,oe===ae.length-1?pe(Te):Ut(Ot,ae,oe+1,he,Te,pe)})})(q,Object.keys(q),0,$.exec,"",Pt)});var gt="";for(var Et in q)d(q,Et)&&(gt+=$.exec(Et,q[Et]));return gt},include:function($,U,q){j("include",U,!1);var gt=q.storage.templates.get($.params[0]);if(!gt)throw i('Could not fetch template "'+$.params[0]+'"');return gt($.params[1],q)},extends:function($,U,q){var gt=$.params[1]||{};gt.content=$.exec();for(var Et=0;Et<U.length;Et++){var Pt=U[Et];gt[Pt.name]=Pt.exec()}var Ut=q.storage.templates.get($.params[0]);if(!Ut)throw i('Could not fetch template "'+$.params[0]+'"');return Ut(gt,q)},useScope:function($,U){return j("useScope",U,!1),$.exec($.params[0])}}),vt=new H({if:function($,U){j("if",!1,$.f,!0);var q="if("+$.p+"){"+F($.d,U)+"}";if($.b)for(var gt=0;gt<$.b.length;gt++){var Et=$.b[gt];Et.n==="else"?q+="else{"+F(Et.d,U)+"}":Et.n==="elif"&&(q+="else if("+Et.p+"){"+F(Et.d,U)+"}")}return q},try:function($,U){if(j("try",!1,$.f,!0),!$.b||$.b.length!==1||$.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var q="try{"+F($.d,U)+"}",gt=$.b[0];return q+="catch"+(gt.res?"("+gt.res+")":"")+"{"+F(gt.d,U)+"}"},block:function($,U){return j("block",$.b,$.f,!0),"if(!"+U.varName+"["+$.p+"]){tR+=("+_($.d,"",U)+")()}else{tR+="+U.varName+"["+$.p+"]}"}}),$t=new H({e:function($){var U=String($);return/[&<>"']/.test(U)?U.replace(/[&<>"']/g,ot):U}}),jt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function($,U){if($==="H"){var q=this.storage.helpers.get(U);if(q)return q;throw i("Can't find helper '"+U+"'")}if($==="F"){var gt=this.storage.filters.get(U);if(gt)return gt;throw i("Can't find filter '"+U+"'")}},async:!1,storage:{helpers:kt,nativeHelpers:vt,filters:$t,templates:tt},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function V($,U){var q={};return f(q,jt),U&&f(q,U),$&&f(q,$),q.l.bind(q),q}function rt($,U){var q=V(U||{}),gt=Function;if(q.async){if(!c)throw i("This environment doesn't support async/await");gt=c}try{return new gt(q.varName,"c","cb",R($,q))}catch(Et){throw Et instanceof SyntaxError?i(`Bad template syntax
84
-
85
- `+Et.message+`
86
- `+Array(Et.message.length+1).join("=")+`
87
- `+R($,q)):Et}}function Lt($,U){var q;return U.cache&&U.name&&U.storage.templates.get(U.name)?U.storage.templates.get(U.name):(q=typeof $=="function"?$:rt($,U),U.cache&&U.name&&U.storage.templates.define(U.name,q),q)}jt.l.bind(jt),e.compile=rt,e.compileScope=F,e.compileScopeIntoFunction=_,e.compileToString=R,e.defaultConfig=jt,e.filters=$t,e.getConfig=V,e.helpers=kt,e.nativeHelpers=vt,e.parse=w,e.render=function($,U,q,gt){var Et=V(q||{});if(!Et.async)return Lt($,Et)(U,Et);if(!gt){if(typeof o=="function")return new o(function(Pt,Ut){try{Pt(Lt($,Et)(U,Et))}catch(Ot){Ut(Ot)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{Lt($,Et)(U,Et,gt)}catch(Pt){return gt(Pt)}},e.templates=tt,Object.defineProperty(e,"__esModule",{value:!0})})})(wl,wl.exports);var js=wl.exports,Sl={exports:{}};(function(n,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ya<"u"&&Ya,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(c){var d=typeof o<"u"&&o||typeof self<"u"&&self||typeof d<"u"&&d,f={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function p(V){return V&&DataView.prototype.isPrototypeOf(V)}if(f.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(V){return V&&g.indexOf(Object.prototype.toString.call(V))>-1};function A(V){if(typeof V!="string"&&(V=String(V)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(V)||V==="")throw new TypeError('Invalid character in header field name: "'+V+'"');return V.toLowerCase()}function T(V){return typeof V!="string"&&(V=String(V)),V}function E(V){var rt={next:function(){var Lt=V.shift();return{done:Lt===void 0,value:Lt}}};return f.iterable&&(rt[Symbol.iterator]=function(){return rt}),rt}function w(V){this.map={},V instanceof w?V.forEach(function(rt,Lt){this.append(Lt,rt)},this):Array.isArray(V)?V.forEach(function(rt){this.append(rt[0],rt[1])},this):V&&Object.getOwnPropertyNames(V).forEach(function(rt){this.append(rt,V[rt])},this)}w.prototype.append=function(V,rt){V=A(V),rt=T(rt);var Lt=this.map[V];this.map[V]=Lt?Lt+", "+rt:rt},w.prototype.delete=function(V){delete this.map[A(V)]},w.prototype.get=function(V){return V=A(V),this.has(V)?this.map[V]:null},w.prototype.has=function(V){return this.map.hasOwnProperty(A(V))},w.prototype.set=function(V,rt){this.map[A(V)]=T(rt)},w.prototype.forEach=function(V,rt){for(var Lt in this.map)this.map.hasOwnProperty(Lt)&&V.call(rt,this.map[Lt],Lt,this)},w.prototype.keys=function(){var V=[];return this.forEach(function(rt,Lt){V.push(Lt)}),E(V)},w.prototype.values=function(){var V=[];return this.forEach(function(rt){V.push(rt)}),E(V)},w.prototype.entries=function(){var V=[];return this.forEach(function(rt,Lt){V.push([Lt,rt])}),E(V)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function R(V){if(V.bodyUsed)return Promise.reject(new TypeError("Already read"));V.bodyUsed=!0}function x(V){return new Promise(function(rt,Lt){V.onload=function(){rt(V.result)},V.onerror=function(){Lt(V.error)}})}function M(V){var rt=new FileReader,Lt=x(rt);return rt.readAsArrayBuffer(V),Lt}function G(V){var rt=new FileReader,Lt=x(rt);return rt.readAsText(V),Lt}function _(V){for(var rt=new Uint8Array(V),Lt=new Array(rt.length),$=0;$<rt.length;$++)Lt[$]=String.fromCharCode(rt[$]);return Lt.join("")}function F(V){if(V.slice)return V.slice(0);var rt=new Uint8Array(V.byteLength);return rt.set(new Uint8Array(V)),rt.buffer}function H(){return this.bodyUsed=!1,this._initBody=function(V){this.bodyUsed=this.bodyUsed,this._bodyInit=V,V?typeof V=="string"?this._bodyText=V:f.blob&&Blob.prototype.isPrototypeOf(V)?this._bodyBlob=V:f.formData&&FormData.prototype.isPrototypeOf(V)?this._bodyFormData=V:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)?this._bodyText=V.toString():f.arrayBuffer&&f.blob&&p(V)?(this._bodyArrayBuffer=F(V.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(V)||v(V))?this._bodyArrayBuffer=F(V):this._bodyText=V=Object.prototype.toString.call(V):this._bodyText="",this.headers.get("content-type")||(typeof V=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var V=R(this);if(V)return V;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var V=R(this);return V||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var V=R(this);if(V)return V;if(this._bodyBlob)return G(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(_(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(tt)}),this.json=function(){return this.text().then(JSON.parse)},this}var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function nt(V){var rt=V.toUpperCase();return j.indexOf(rt)>-1?rt:V}function ot(V,rt){if(!(this instanceof ot))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');rt=rt||{};var Lt=rt.body;if(V instanceof ot){if(V.bodyUsed)throw new TypeError("Already read");this.url=V.url,this.credentials=V.credentials,rt.headers||(this.headers=new w(V.headers)),this.method=V.method,this.mode=V.mode,this.signal=V.signal,!Lt&&V._bodyInit!=null&&(Lt=V._bodyInit,V.bodyUsed=!0)}else this.url=String(V);if(this.credentials=rt.credentials||this.credentials||"same-origin",(rt.headers||!this.headers)&&(this.headers=new w(rt.headers)),this.method=nt(rt.method||this.method||"GET"),this.mode=rt.mode||this.mode||null,this.signal=rt.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&Lt)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(Lt),(this.method==="GET"||this.method==="HEAD")&&(rt.cache==="no-store"||rt.cache==="no-cache")){var $=/([?&])_=[^&]*/;if($.test(this.url))this.url=this.url.replace($,"$1_="+new Date().getTime());else{var U=/\?/;this.url+=(U.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}ot.prototype.clone=function(){return new ot(this,{body:this._bodyInit})};function tt(V){var rt=new FormData;return V.trim().split("&").forEach(function(Lt){if(Lt){var $=Lt.split("="),U=$.shift().replace(/\+/g," "),q=$.join("=").replace(/\+/g," ");rt.append(decodeURIComponent(U),decodeURIComponent(q))}}),rt}function kt(V){var rt=new w,Lt=V.replace(/\r?\n[\t ]+/g," ");return Lt.split("\r").map(function($){return $.indexOf(`
88
- `)===0?$.substr(1,$.length):$}).forEach(function($){var U=$.split(":"),q=U.shift().trim();if(q){var gt=U.join(":").trim();rt.append(q,gt)}}),rt}H.call(ot.prototype);function vt(V,rt){if(!(this instanceof vt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');rt||(rt={}),this.type="default",this.status=rt.status===void 0?200:rt.status,this.ok=this.status>=200&&this.status<300,this.statusText=rt.statusText===void 0?"":""+rt.statusText,this.headers=new w(rt.headers),this.url=rt.url||"",this._initBody(V)}H.call(vt.prototype),vt.prototype.clone=function(){return new vt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},vt.error=function(){var V=new vt(null,{status:0,statusText:""});return V.type="error",V};var $t=[301,302,303,307,308];vt.redirect=function(V,rt){if($t.indexOf(rt)===-1)throw new RangeError("Invalid status code");return new vt(null,{status:rt,headers:{location:V}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(rt,Lt){this.message=rt,this.name=Lt;var $=Error(rt);this.stack=$.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function jt(V,rt){return new Promise(function(Lt,$){var U=new ot(V,rt);if(U.signal&&U.signal.aborted)return $(new c.DOMException("Aborted","AbortError"));var q=new XMLHttpRequest;function gt(){q.abort()}q.onload=function(){var Pt={status:q.status,statusText:q.statusText,headers:kt(q.getAllResponseHeaders()||"")};Pt.url="responseURL"in q?q.responseURL:Pt.headers.get("X-Request-URL");var Ut="response"in q?q.response:q.responseText;setTimeout(function(){Lt(new vt(Ut,Pt))},0)},q.onerror=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},q.ontimeout=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},q.onabort=function(){setTimeout(function(){$(new c.DOMException("Aborted","AbortError"))},0)};function Et(Pt){try{return Pt===""&&d.location.href?d.location.href:Pt}catch{return Pt}}q.open(U.method,Et(U.url),!0),U.credentials==="include"?q.withCredentials=!0:U.credentials==="omit"&&(q.withCredentials=!1),"responseType"in q&&(f.blob?q.responseType="blob":f.arrayBuffer&&U.headers.get("Content-Type")&&U.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(q.responseType="arraybuffer")),rt&&typeof rt.headers=="object"&&!(rt.headers instanceof w)?Object.getOwnPropertyNames(rt.headers).forEach(function(Pt){q.setRequestHeader(Pt,T(rt.headers[Pt]))}):U.headers.forEach(function(Pt,Ut){q.setRequestHeader(Ut,Pt)}),U.signal&&(U.signal.addEventListener("abort",gt),q.onreadystatechange=function(){q.readyState===4&&U.signal.removeEventListener("abort",gt)}),q.send(typeof U._bodyInit>"u"?null:U._bodyInit)})}return jt.polyfill=!0,d.fetch||(d.fetch=jt,d.Headers=w,d.Request=ot,d.Response=vt),c.Headers=w,c.Request=ot,c.Response=vt,c.fetch=jt,c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=e.fetch?e:i;t=s.fetch,t.default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,n.exports=t})(Sl,Sl.exports);var _g=Sl.exports;const Cg=kl(_g);function Ig({canvas:n,scenes:t,currentTime:e}){if(t&&n){const i=t.scenes.filter(({start:o,duration:c})=>e>=o&&e<=o+c);if(i.length<=0)return;const s=n.getContext("2d");if(s){const o=t.transitionDuration,c=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));s.globalCompositeOperation="lighter",s.clearRect(0,0,n.width,n.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{s.globalAlpha=1,g.width=g.height=0,g.width=n.width,g.height=n.height;const v=g.getContext("2d");if(v){const A=d+f,T=d===0,E=A===c;p({currentTime:e,canvas:g,context:v}),!T&&e>=d&&e<=d+o/2?s.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!E&&e>=A-o/2&&e<=A&&(s.globalAlpha=Math.max(0,Math.min(1,(A-e)/(o/2)))),s.drawImage(g,0,0,n.width,n.height)}})}}}function Dg(n){if(typeof n=="string"){const[t,e]=n.split(":");return Math.min(parseFloat(t),parseFloat(e))}return n}function xg(n){if(typeof n=="string"){const[t,e]=n.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return n}function fn({resolution:n,aspectRatio:t}){const e=Dg(n),i=xg(t),s=i>=1,o=Math.min(s?e*i:e/i,e),c=Math.max(s?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:s?o:c,width:s?c:o}}function Pg({format:n,resolution:t,aspectRatio:e,videoResolution:i,videoAspectRatio:s}){const{height:o,width:c}=fn({resolution:t,aspectRatio:e}),{height:d,width:f}=fn({resolution:i,aspectRatio:s}),p=e>s;let g=1;if(n==="letterbox"||n==="letterbox-video")g=p?o/d:c/f;else if(n==="squarebox"){const w=Math.min(o,c);g=f>=d?w/d:w/f}else(n==="crop"||n==="crop-top")&&(g=p?c/f:o/d);const v=c/g,A=o/g,T=(f-v)/2;let E=(d-A)/2;return n==="crop-top"&&(E=Math.min(0,E)),{sx:T,sy:E,sWidth:v,sHeight:A,scale:g}}function Za({source:n,sx:t,sy:e,sw:i,sh:s,dx:o,dy:c,dw:d,dh:f}){const p=(n==null?void 0:n.naturalWidth)??(n==null?void 0:n.videoWidth)??(n==null?void 0:n.width),g=(n==null?void 0:n.naturalHeight)??(n==null?void 0:n.videoHeight)??(n==null?void 0:n.height);t=t??0,e=e??0,i=i??p,s=s??g,i<0&&(t+=i,i=Math.abs(i)),s<0&&(e+=s,s=Math.abs(s)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(c+=f,f=Math.abs(f));const v=Math.max(t,0),A=Math.min(t+i,p),T=Math.max(e,0),E=Math.min(e+s,g),w=d/i,R=f/s;return[n,v,T,A-v,E-T,t<0?o-t*w:o,e<0?c-e*R:c,(A-v)*w,(E-T)*R]}function Ld({context:n,source:t,format:e="letterbox",videoResolution:i,videoAspectRatio:s,posX:o,posY:c,width:d,height:f,offscreenCanvas:p}){const{sx:g,sy:v,sWidth:A,sHeight:T,scale:E}=Pg({resolution:Math.min(d,f),aspectRatio:d/f,format:e,videoResolution:i,videoAspectRatio:s}),w=p&&typeof n.filter<"u";if(e==="letterbox"||e==="squarebox"||e==="letterbox-video"&&!w){if(g<0){const _=Math.abs(g)*E;n.fillStyle="black",n.beginPath(),n.rect(o,c,_,f),n.rect(o+d-_,c,_,f),n.fill(),n.closePath()}if(v<0){const _=Math.abs(v)*E;n.fillStyle="black",n.beginPath(),n.rect(o,c,d,_),n.rect(o,c+f-_,d,_),n.fill(),n.closePath()}}if(e==="letterbox-video"&&w){const{width:_,height:F}=fn({resolution:i,aspectRatio:s});p.width=_,p.height=F;const H=p.getContext("2d",{alpha:!1});if(H==null||H.drawImage(t,0,0,_,F),H){n.save(),n.globalCompositeOperation="destination-out",n.fillRect(o,c,d,f);const j=Za({source:p,sx:g,sy:v,sw:A,sh:T,dx:o,dy:c,dw:d,dh:f});n.globalCompositeOperation="source-over",n.drawImage(...j),H.save();const nt=1.3,ot=-(_*nt-_)/2,tt=-(F*nt-F)/2;if(H.filter="blur(40px) brightness(20%)",H.translate(ot,tt),H.scale(nt,nt),H.drawImage(p,0,0,_,F),H.restore(),n.globalCompositeOperation="destination-over",g<0){const kt=d/s,vt=f/kt,$t=Za({source:p,sy:(1-vt)*F/2,sh:vt*F,dx:o,dy:c,dw:d,dh:f});n.drawImage(...$t)}if(v<0){const kt=f*s,vt=d/kt,$t=Za({source:p,sx:(1-vt)*_/2,sw:vt*_,dx:o,dy:c,dw:d,dh:f});n.drawImage(...$t)}n.restore()}}else{const _=Za({source:t,sx:g,sy:v,sw:A,sh:T,dx:o,dy:c,dw:d,dh:f});n.drawImage(..._)}const R=g*-1*E,x=v*-1*E,M=d-R*2,G=f-x*2;return{dx:R,dy:x,dw:M,dh:G}}const Og=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Mg=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function Rd(n){if(!n)return[];const t=n.match(Og);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
77
+ */const fg=Symbol();class _l{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??pg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===fg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const pg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!Ll(e,t[i]));let qa;const gg=new Uint8Array(16);function mg(){if(!qa&&(qa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!qa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return qa(gg)}const yi=[];for(let n=0;n<256;++n)yi.push((n+256).toString(16).slice(1));function vg(n,t=0){return yi[n[t+0]]+yi[n[t+1]]+yi[n[t+2]]+yi[n[t+3]]+"-"+yi[n[t+4]]+yi[n[t+5]]+"-"+yi[n[t+6]]+yi[n[t+7]]+"-"+yi[n[t+8]]+yi[n[t+9]]+"-"+yi[n[t+10]]+yi[n[t+11]]+yi[n[t+12]]+yi[n[t+13]]+yi[n[t+14]]+yi[n[t+15]]}const Dd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Xs(n,t,e){if(Dd.randomUUID&&!t&&!n)return Dd.randomUUID();n=n||{};const i=n.random||(n.rng||mg)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return vg(i)}const xd="https://d2rxhdlm2q91uk.cloudfront.net",yg="https://d1ix11aj5kfygl.cloudfront.net",bg="https://d157jlwnudd93d.cloudfront.net",Pd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Ag="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",Eg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",kg="http://localhost:6060/v2",Tg="https://embed-dev.vouchfor.com/v2",wg="https://embed-staging.vouchfor.com/v2",Sg="https://embed.vouchfor.com/v2";function Qa(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:xd,publicApiUrl:Pd,embedApiUrl:kg};if(n==="dev")return{videoUrl:xd,publicApiUrl:Pd,embedApiUrl:Tg};if(n==="staging")return{videoUrl:yg,publicApiUrl:Ag,embedApiUrl:wg};if(n==="prod")return{videoUrl:bg,publicApiUrl:Eg,embedApiUrl:Sg}}class Rg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=Qa(e),c=Xs(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:f==null?void 0:f.id})),((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=Qa(e),c=Xs(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new _l(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),t.vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);t.vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const Lg={name:"@vouchfor/embeds",version:"0.0.0-experiment.03bde95",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"experiment",access:"public"},scripts:{build:"rm -rf dist && tsc && vite build --mode iife && vite build --mode es","build:deps":"yarn --cwd ../media-player build","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"true"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"0.0.0-experiment.03bde95",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1","lint-staged":"^14.0.1",lit:"^3.1.0",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}},Od=1;class _g{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=Qa(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,...s}},this._sendTrackingEvent=(e,i)=>{const s=this._findVouchId(i);if(!s||this.host.disableTracking)return;const{publicApiUrl:o}=Qa(this.host.env),{client:c,tab:d,request:f,visitor:p}=this._getUids();navigator.sendBeacon(`${o}/api/v2/events`,JSON.stringify({event:e,payload:{...i,vouchId:s},context:{"x-uid-client":c,"x-uid-tab":d,"x-uid-request":f,"x-uid-visitor":p,"x-reporting-metadata":this._getReportingMetadata(),"x-embeds-version":Lg.version}}))},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+Od&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0),this._streamStartTime[i]||(this._streamStartTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var o,c;!this.host.paused&&e===((c=(o=this.host.scene)==null?void 0:o.video)==null?void 0:c.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:s},this._streamLatestTime[i]=s.currentTime)},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+Od&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this.host.pause()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}_findVouchId(t){return t&&"vouchId"in t?t.vouchId:this.host.vouch?this.host.vouch.id:null}_getUids(){var o,c,d,f,p,g,v,b,E,k,w,L;if(typeof window>"u")return{client:null,tab:null,request:Xs()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(Xs()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||Xs(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||Xs(),s=Xs();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(k=(E=window.localStorage)==null?void 0:E.setItem)==null||k.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(L=(w=window.sessionStorage)==null?void 0:w.setItem)==null||L.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this._streamEnded(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}const Cg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Ig(s,o)&&i||Object.defineProperty(n,e,o)},Ig=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Dg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},xg=(n,t)=>`/* Wrapped ${n}*/
78
+ ${t}`,Pg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Og=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Mg=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=xg.bind(null,i,t.toString());Object.defineProperty(s,"name",Og),Object.defineProperty(n,"toString",{...Pg,value:s})};function $g(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))Cg(n,t,s,e);return Dg(n,t),Mg(n,t,i),n}const Fg=new WeakMap;function vs(n,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...o){const c=t(o);if(i.has(c))return i.get(c);const d=(async()=>{try{if(e&&await e.has(c))return await e.get(c);const p=await n.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return $g(s,n,{ignoreNonConfigurable:!0}),Fg.set(s,e),s}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Cl(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Il={exports:{}};(function(n,t){(function(e,i){i(t)})(Ja,function(e){function i($){var U,Z,mt=new Error($);return U=mt,Z=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(U,Z):U.__proto__=Z,mt}function s($,U,Z){var mt=U.slice(0,Z).split(/\n/),bt=mt.length,Dt=mt[bt-1].length+1;throw i($+=" at line "+bt+" col "+Dt+`:
79
+
80
+ `+U.split(/\n/)[bt-1]+`
81
+ `+Array(Dt).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,c=!1;try{c=new Function("return (async function(){}).constructor")()}catch($){if(!($ instanceof SyntaxError))throw $}function d($,U){return Object.prototype.hasOwnProperty.call($,U)}function f($,U,Z){for(var mt in U)d(U,mt)&&(U[mt]==null||typeof U[mt]!="object"||mt!=="storage"&&mt!=="prefixes"||Z?$[mt]=U[mt]:$[mt]=f({},U[mt]));return $}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,b=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function k($){return E.test($)?$.replace(E,"\\$&"):$}function w($,U){U.rmWhitespace&&($=$.replace(/[\r\n]+/g,`
82
+ `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,b.lastIndex=0;var Z=U.prefixes,mt=[Z.h,Z.b,Z.i,Z.r,Z.c,Z.e].reduce(function(me,Wt){return me&&Wt?me+"|"+k(Wt):Wt?k(Wt):me},""),bt=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+k(U.tags[1])+")","g"),Dt=new RegExp("([^]*?)"+k(U.tags[0])+"(-|_)?\\s*("+mt+")?\\s*","g"),Ut=0,Qt=!1;function fe(me,Wt){var oe,se={f:[]},Te=0,Mt="c";function Me(ti){var Zi=$.slice(Ut,ti),Fe=Zi.trim();if(Mt==="f")Fe==="safe"?se.raw=!0:U.async&&p.test(Fe)?(Fe=Fe.replace(p,""),se.f.push([Fe,"",!0])):se.f.push([Fe,""]);else if(Mt==="fp")se.f[se.f.length-1][1]+=Fe;else if(Mt==="err"){if(Fe){var Ci=Zi.search(/\S/);s("invalid syntax",$,Ut+Ci)}}else se[Mt]=Fe;Ut=ti+1}for(Wt==="h"||Wt==="b"||Wt==="c"?Mt="n":Wt==="r"&&(se.raw=!0,Wt="i"),bt.lastIndex=Ut;(oe=bt.exec($))!==null;){var qe=oe[1],Mi=oe[2],kr=oe[3],we=oe[4],li=oe[5],ve=oe.index;if(qe)qe==="("?(Te===0&&(Mt==="n"?(Me(ve),Mt="p"):Mt==="f"&&(Me(ve),Mt="fp")),Te++):qe===")"?--Te===0&&Mt!=="c"&&(Me(ve),Mt="err"):Te===0&&qe==="|"?(Me(ve),Mt="f"):qe==="=>"&&(Me(ve),Ut+=1,Mt="res");else if(Mi)if(Mi==="/*"){var Je=$.indexOf("*/",bt.lastIndex);Je===-1&&s("unclosed comment",$,oe.index),bt.lastIndex=Je+2}else Mi==="'"?(v.lastIndex=oe.index,v.exec($)?bt.lastIndex=v.lastIndex:s("unclosed string",$,oe.index)):Mi==='"'?(b.lastIndex=oe.index,b.exec($)?bt.lastIndex=b.lastIndex:s("unclosed string",$,oe.index)):Mi==="`"&&(g.lastIndex=oe.index,g.exec($)?bt.lastIndex=g.lastIndex:s("unclosed string",$,oe.index));else if(kr)return Me(ve),Ut=ve+oe[0].length,Dt.lastIndex=Ut,Qt=li,we&&Wt==="h"&&(Wt="s"),se.t=Wt,se}return s("unclosed tag",$,me),se}var re=function me(Wt,oe){Wt.b=[],Wt.d=[];var se,Te=!1,Mt=[];function Me(Ci,rs){Ci&&(Ci=function(ci,Tr,Rs,Ls){var ir,ct;return typeof Tr.autoTrim=="string"?ir=ct=Tr.autoTrim:Array.isArray(Tr.autoTrim)&&(ir=Tr.autoTrim[1],ct=Tr.autoTrim[0]),(Rs||Rs===!1)&&(ir=Rs),(Ls||Ls===!1)&&(ct=Ls),ir==="slurp"&&ct==="slurp"?ci.trim():(ir==="_"||ir==="slurp"?ci=String.prototype.trimLeft?ci.trimLeft():ci.replace(/^[\s\uFEFF\xA0]+/,""):ir!=="-"&&ir!=="nl"||(ci=ci.replace(/^(?:\n|\r|\r\n)/,"")),ct==="_"||ct==="slurp"?ci=String.prototype.trimRight?ci.trimRight():ci.replace(/[\s\uFEFF\xA0]+$/,""):ct!=="-"&&ct!=="nl"||(ci=ci.replace(/(?:\n|\r|\r\n)$/,"")),ci)}(Ci,U,Qt,rs))&&(Ci=Ci.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Mt.push(Ci))}for(;(se=Dt.exec($))!==null;){var qe,Mi=se[1],kr=se[2],we=se[3]||"";for(var li in Z)if(Z[li]===we){qe=li;break}Me(Mi,kr),Ut=se.index+se[0].length,qe||s("unrecognized tag type: "+we,$,Ut);var ve=fe(se.index,qe),Je=ve.t;if(Je==="h"){var ti=ve.n||"";U.async&&p.test(ti)&&(ve.a=!0,ve.n=ti.replace(p,"")),ve=me(ve),Mt.push(ve)}else if(Je==="c"){if(Wt.n===ve.n)return Te?(Te.d=Mt,Wt.b.push(Te)):Wt.d=Mt,Wt;s("Helper start and end don't match",$,se.index+se[0].length)}else if(Je==="b"){Te?(Te.d=Mt,Wt.b.push(Te)):Wt.d=Mt;var Zi=ve.n||"";U.async&&p.test(Zi)&&(ve.a=!0,ve.n=Zi.replace(p,"")),Te=ve,Mt=[]}else if(Je==="s"){var Fe=ve.n||"";U.async&&p.test(Fe)&&(ve.a=!0,ve.n=Fe.replace(p,"")),Mt.push(ve)}else Mt.push(ve)}if(!oe)throw i('unclosed helper "'+Wt.n+'"');return Me($.slice(Ut,$.length),!1),Wt.d=Mt,Wt}({f:[]},!0);if(U.plugins)for(var Ht=0;Ht<U.plugins.length;Ht++){var Oe=U.plugins[Ht];Oe.processAST&&(re.d=Oe.processAST(re.d,U))}return re.d}function L($,U){var Z=w($,U),mt="var tR='';"+(U.useWith?"with("+U.varName+"||{}){":"")+F(Z,U)+"if(cb){cb(null,tR)} return tR"+(U.useWith?"}":"");if(U.plugins)for(var bt=0;bt<U.plugins.length;bt++){var Dt=U.plugins[bt];Dt.processFnString&&(mt=Dt.processFnString(mt,U))}return mt}function x($,U){for(var Z=0;Z<U.length;Z++){var mt=U[Z][0],bt=U[Z][1];$=(U[Z][2]?"await ":"")+"c.l('F','"+mt+"')("+$,bt&&($+=","+bt),$+=")"}return $}function M($,U,Z,mt,bt,Dt){var Ut="{exec:"+(bt?"async ":"")+D(Z,U,$)+",params:["+mt+"]";return Dt&&(Ut+=",name:'"+Dt+"'"),bt&&(Ut+=",async:true"),Ut+="}"}function N($,U){for(var Z="[",mt=0;mt<$.length;mt++){var bt=$[mt];Z+=M(U,bt.res||"",bt.d,bt.p||"",bt.a,bt.n),mt<$.length&&(Z+=",")}return Z+="]"}function D($,U,Z){return"function("+U+"){var tR='';"+F($,Z)+"return tR}"}function F($,U){for(var Z=0,mt=$.length,bt="";Z<mt;Z++){var Dt=$[Z];if(typeof Dt=="string")bt+="tR+='"+Dt+"';";else{var Ut=Dt.t,Qt=Dt.c||"",fe=Dt.f,re=Dt.n||"",Ht=Dt.p||"",Oe=Dt.res||"",me=Dt.b,Wt=!!Dt.a;if(Ut==="i"){U.defaultFilter&&(Qt="c.l('F','"+U.defaultFilter+"')("+Qt+")");var oe=x(Qt,fe);!Dt.raw&&U.autoEscape&&(oe="c.l('F','e')("+oe+")"),bt+="tR+="+oe+";"}else if(Ut==="h")if(U.storage.nativeHelpers.get(re))bt+=U.storage.nativeHelpers.get(re)(Dt,U);else{var se=(Wt?"await ":"")+"c.l('H','"+re+"')("+M(U,Oe,Dt.d,Ht,Wt);se+=me?","+N(me,U):",[]",bt+="tR+="+x(se+=",c)",fe)+";"}else Ut==="s"?bt+="tR+="+x((Wt?"await ":"")+"c.l('H','"+re+"')({params:["+Ht+"]},[],c)",fe)+";":Ut==="e"&&(bt+=Qt+`
83
+ `)}}return bt}var H=function(){function $(U){this.cache=U}return $.prototype.define=function(U,Z){this.cache[U]=Z},$.prototype.get=function(U){return this.cache[U]},$.prototype.remove=function(U){delete this.cache[U]},$.prototype.reset=function(){this.cache={}},$.prototype.load=function(U){f(this.cache,U,!0)},$}();function j($,U,Z,mt){if(U&&U.length>0)throw i((mt?"Native":"")+"Helper '"+$+"' doesn't accept blocks");if(Z&&Z.length>0)throw i((mt?"Native":"")+"Helper '"+$+"' doesn't accept filters")}var st={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function at($){return st[$]}var Q=new H({}),kt=new H({each:function($,U){var Z="",mt=$.params[0];if(j("each",U,!1),$.async)return new Promise(function(Dt){(function Ut(Qt,fe,re,Ht,Oe){re(Qt[fe],fe).then(function(me){Ht+=me,fe===Qt.length-1?Oe(Ht):Ut(Qt,fe+1,re,Ht,Oe)})})(mt,0,$.exec,Z,Dt)});for(var bt=0;bt<mt.length;bt++)Z+=$.exec(mt[bt],bt);return Z},foreach:function($,U){var Z=$.params[0];if(j("foreach",U,!1),$.async)return new Promise(function(Dt){(function Ut(Qt,fe,re,Ht,Oe,me){Ht(fe[re],Qt[fe[re]]).then(function(Wt){Oe+=Wt,re===fe.length-1?me(Oe):Ut(Qt,fe,re+1,Ht,Oe,me)})})(Z,Object.keys(Z),0,$.exec,"",Dt)});var mt="";for(var bt in Z)d(Z,bt)&&(mt+=$.exec(bt,Z[bt]));return mt},include:function($,U,Z){j("include",U,!1);var mt=Z.storage.templates.get($.params[0]);if(!mt)throw i('Could not fetch template "'+$.params[0]+'"');return mt($.params[1],Z)},extends:function($,U,Z){var mt=$.params[1]||{};mt.content=$.exec();for(var bt=0;bt<U.length;bt++){var Dt=U[bt];mt[Dt.name]=Dt.exec()}var Ut=Z.storage.templates.get($.params[0]);if(!Ut)throw i('Could not fetch template "'+$.params[0]+'"');return Ut(mt,Z)},useScope:function($,U){return j("useScope",U,!1),$.exec($.params[0])}}),gt=new H({if:function($,U){j("if",!1,$.f,!0);var Z="if("+$.p+"){"+F($.d,U)+"}";if($.b)for(var mt=0;mt<$.b.length;mt++){var bt=$.b[mt];bt.n==="else"?Z+="else{"+F(bt.d,U)+"}":bt.n==="elif"&&(Z+="else if("+bt.p+"){"+F(bt.d,U)+"}")}return Z},try:function($,U){if(j("try",!1,$.f,!0),!$.b||$.b.length!==1||$.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var Z="try{"+F($.d,U)+"}",mt=$.b[0];return Z+="catch"+(mt.res?"("+mt.res+")":"")+"{"+F(mt.d,U)+"}"},block:function($,U){return j("block",$.b,$.f,!0),"if(!"+U.varName+"["+$.p+"]){tR+=("+D($.d,"",U)+")()}else{tR+="+U.varName+"["+$.p+"]}"}}),Ft=new H({e:function($){var U=String($);return/[&<>"']/.test(U)?U.replace(/[&<>"']/g,at):U}}),Kt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function($,U){if($==="H"){var Z=this.storage.helpers.get(U);if(Z)return Z;throw i("Can't find helper '"+U+"'")}if($==="F"){var mt=this.storage.filters.get(U);if(mt)return mt;throw i("Can't find filter '"+U+"'")}},async:!1,storage:{helpers:kt,nativeHelpers:gt,filters:Ft,templates:Q},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function V($,U){var Z={};return f(Z,Kt),U&&f(Z,U),$&&f(Z,$),Z.l.bind(Z),Z}function J($,U){var Z=V(U||{}),mt=Function;if(Z.async){if(!c)throw i("This environment doesn't support async/await");mt=c}try{return new mt(Z.varName,"c","cb",L($,Z))}catch(bt){throw bt instanceof SyntaxError?i(`Bad template syntax
84
+
85
+ `+bt.message+`
86
+ `+Array(bt.message.length+1).join("=")+`
87
+ `+L($,Z)):bt}}function St($,U){var Z;return U.cache&&U.name&&U.storage.templates.get(U.name)?U.storage.templates.get(U.name):(Z=typeof $=="function"?$:J($,U),U.cache&&U.name&&U.storage.templates.define(U.name,Z),Z)}Kt.l.bind(Kt),e.compile=J,e.compileScope=F,e.compileScopeIntoFunction=D,e.compileToString=L,e.defaultConfig=Kt,e.filters=Ft,e.getConfig=V,e.helpers=kt,e.nativeHelpers=gt,e.parse=w,e.render=function($,U,Z,mt){var bt=V(Z||{});if(!bt.async)return St($,bt)(U,bt);if(!mt){if(typeof o=="function")return new o(function(Dt,Ut){try{Dt(St($,bt)(U,bt))}catch(Qt){Ut(Qt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{St($,bt)(U,bt,mt)}catch(Dt){return mt(Dt)}},e.templates=Q,Object.defineProperty(e,"__esModule",{value:!0})})})(Il,Il.exports);var qs=Il.exports,Dl={exports:{}};(function(n,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof Ja<"u"&&Ja,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(c){var d=typeof o<"u"&&o||typeof self<"u"&&self||typeof d<"u"&&d,f={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function p(V){return V&&DataView.prototype.isPrototypeOf(V)}if(f.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(V){return V&&g.indexOf(Object.prototype.toString.call(V))>-1};function b(V){if(typeof V!="string"&&(V=String(V)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(V)||V==="")throw new TypeError('Invalid character in header field name: "'+V+'"');return V.toLowerCase()}function E(V){return typeof V!="string"&&(V=String(V)),V}function k(V){var J={next:function(){var St=V.shift();return{done:St===void 0,value:St}}};return f.iterable&&(J[Symbol.iterator]=function(){return J}),J}function w(V){this.map={},V instanceof w?V.forEach(function(J,St){this.append(St,J)},this):Array.isArray(V)?V.forEach(function(J){this.append(J[0],J[1])},this):V&&Object.getOwnPropertyNames(V).forEach(function(J){this.append(J,V[J])},this)}w.prototype.append=function(V,J){V=b(V),J=E(J);var St=this.map[V];this.map[V]=St?St+", "+J:J},w.prototype.delete=function(V){delete this.map[b(V)]},w.prototype.get=function(V){return V=b(V),this.has(V)?this.map[V]:null},w.prototype.has=function(V){return this.map.hasOwnProperty(b(V))},w.prototype.set=function(V,J){this.map[b(V)]=E(J)},w.prototype.forEach=function(V,J){for(var St in this.map)this.map.hasOwnProperty(St)&&V.call(J,this.map[St],St,this)},w.prototype.keys=function(){var V=[];return this.forEach(function(J,St){V.push(St)}),k(V)},w.prototype.values=function(){var V=[];return this.forEach(function(J){V.push(J)}),k(V)},w.prototype.entries=function(){var V=[];return this.forEach(function(J,St){V.push([St,J])}),k(V)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function L(V){if(V.bodyUsed)return Promise.reject(new TypeError("Already read"));V.bodyUsed=!0}function x(V){return new Promise(function(J,St){V.onload=function(){J(V.result)},V.onerror=function(){St(V.error)}})}function M(V){var J=new FileReader,St=x(J);return J.readAsArrayBuffer(V),St}function N(V){var J=new FileReader,St=x(J);return J.readAsText(V),St}function D(V){for(var J=new Uint8Array(V),St=new Array(J.length),$=0;$<J.length;$++)St[$]=String.fromCharCode(J[$]);return St.join("")}function F(V){if(V.slice)return V.slice(0);var J=new Uint8Array(V.byteLength);return J.set(new Uint8Array(V)),J.buffer}function H(){return this.bodyUsed=!1,this._initBody=function(V){this.bodyUsed=this.bodyUsed,this._bodyInit=V,V?typeof V=="string"?this._bodyText=V:f.blob&&Blob.prototype.isPrototypeOf(V)?this._bodyBlob=V:f.formData&&FormData.prototype.isPrototypeOf(V)?this._bodyFormData=V:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)?this._bodyText=V.toString():f.arrayBuffer&&f.blob&&p(V)?(this._bodyArrayBuffer=F(V.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(V)||v(V))?this._bodyArrayBuffer=F(V):this._bodyText=V=Object.prototype.toString.call(V):this._bodyText="",this.headers.get("content-type")||(typeof V=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var V=L(this);if(V)return V;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var V=L(this);return V||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(M)}),this.text=function(){var V=L(this);if(V)return V;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(D(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(Q)}),this.json=function(){return this.text().then(JSON.parse)},this}var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function st(V){var J=V.toUpperCase();return j.indexOf(J)>-1?J:V}function at(V,J){if(!(this instanceof at))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J=J||{};var St=J.body;if(V instanceof at){if(V.bodyUsed)throw new TypeError("Already read");this.url=V.url,this.credentials=V.credentials,J.headers||(this.headers=new w(V.headers)),this.method=V.method,this.mode=V.mode,this.signal=V.signal,!St&&V._bodyInit!=null&&(St=V._bodyInit,V.bodyUsed=!0)}else this.url=String(V);if(this.credentials=J.credentials||this.credentials||"same-origin",(J.headers||!this.headers)&&(this.headers=new w(J.headers)),this.method=st(J.method||this.method||"GET"),this.mode=J.mode||this.mode||null,this.signal=J.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&St)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(St),(this.method==="GET"||this.method==="HEAD")&&(J.cache==="no-store"||J.cache==="no-cache")){var $=/([?&])_=[^&]*/;if($.test(this.url))this.url=this.url.replace($,"$1_="+new Date().getTime());else{var U=/\?/;this.url+=(U.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}at.prototype.clone=function(){return new at(this,{body:this._bodyInit})};function Q(V){var J=new FormData;return V.trim().split("&").forEach(function(St){if(St){var $=St.split("="),U=$.shift().replace(/\+/g," "),Z=$.join("=").replace(/\+/g," ");J.append(decodeURIComponent(U),decodeURIComponent(Z))}}),J}function kt(V){var J=new w,St=V.replace(/\r?\n[\t ]+/g," ");return St.split("\r").map(function($){return $.indexOf(`
88
+ `)===0?$.substr(1,$.length):$}).forEach(function($){var U=$.split(":"),Z=U.shift().trim();if(Z){var mt=U.join(":").trim();J.append(Z,mt)}}),J}H.call(at.prototype);function gt(V,J){if(!(this instanceof gt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J||(J={}),this.type="default",this.status=J.status===void 0?200:J.status,this.ok=this.status>=200&&this.status<300,this.statusText=J.statusText===void 0?"":""+J.statusText,this.headers=new w(J.headers),this.url=J.url||"",this._initBody(V)}H.call(gt.prototype),gt.prototype.clone=function(){return new gt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},gt.error=function(){var V=new gt(null,{status:0,statusText:""});return V.type="error",V};var Ft=[301,302,303,307,308];gt.redirect=function(V,J){if(Ft.indexOf(J)===-1)throw new RangeError("Invalid status code");return new gt(null,{status:J,headers:{location:V}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(J,St){this.message=J,this.name=St;var $=Error(J);this.stack=$.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Kt(V,J){return new Promise(function(St,$){var U=new at(V,J);if(U.signal&&U.signal.aborted)return $(new c.DOMException("Aborted","AbortError"));var Z=new XMLHttpRequest;function mt(){Z.abort()}Z.onload=function(){var Dt={status:Z.status,statusText:Z.statusText,headers:kt(Z.getAllResponseHeaders()||"")};Dt.url="responseURL"in Z?Z.responseURL:Dt.headers.get("X-Request-URL");var Ut="response"in Z?Z.response:Z.responseText;setTimeout(function(){St(new gt(Ut,Dt))},0)},Z.onerror=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},Z.ontimeout=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},Z.onabort=function(){setTimeout(function(){$(new c.DOMException("Aborted","AbortError"))},0)};function bt(Dt){try{return Dt===""&&d.location.href?d.location.href:Dt}catch{return Dt}}Z.open(U.method,bt(U.url),!0),U.credentials==="include"?Z.withCredentials=!0:U.credentials==="omit"&&(Z.withCredentials=!1),"responseType"in Z&&(f.blob?Z.responseType="blob":f.arrayBuffer&&U.headers.get("Content-Type")&&U.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(Z.responseType="arraybuffer")),J&&typeof J.headers=="object"&&!(J.headers instanceof w)?Object.getOwnPropertyNames(J.headers).forEach(function(Dt){Z.setRequestHeader(Dt,E(J.headers[Dt]))}):U.headers.forEach(function(Dt,Ut){Z.setRequestHeader(Ut,Dt)}),U.signal&&(U.signal.addEventListener("abort",mt),Z.onreadystatechange=function(){Z.readyState===4&&U.signal.removeEventListener("abort",mt)}),Z.send(typeof U._bodyInit>"u"?null:U._bodyInit)})}return Kt.polyfill=!0,d.fetch||(d.fetch=Kt,d.Headers=w,d.Request=at,d.Response=gt),c.Headers=w,c.Request=at,c.Response=gt,c.fetch=Kt,c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=e.fetch?e:i;t=s.fetch,t.default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,n.exports=t})(Dl,Dl.exports);var Ng=Dl.exports;const Ug=Cl(Ng);function xl({canvas:n,scenes:t,currentTime:e}){if(t&&n){const i=t.scenes.filter(({start:o,duration:c})=>e>=o&&e<=o+c);if(i.length<=0)return;const s=n.getContext("2d");if(s){const o=t.transitionDuration,c=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));s.globalCompositeOperation="lighter",s.clearRect(0,0,n.width,n.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{s.globalAlpha=1,g.width=g.height=0,g.width=n.width,g.height=n.height;const v=g.getContext("2d");if(v){const b=d+f,E=d===0,k=b===c;p({currentTime:e,canvas:g,context:v}),!E&&e>=d&&e<=d+o/2?s.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!k&&e>=b-o/2&&e<=b&&(s.globalAlpha=Math.max(0,Math.min(1,(b-e)/(o/2)))),s.drawImage(g,0,0,n.width,n.height)}})}}}function Bg(n){if(typeof n=="string"){const[t,e]=n.split(":");return Math.min(parseFloat(t),parseFloat(e))}return n}function Gg(n){if(typeof n=="string"){const[t,e]=n.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return n}function Pl({resolution:n,aspectRatio:t}){const e=Bg(n),i=Gg(t),s=i>=1,o=Math.min(s?e*i:e/i,e),c=Math.max(s?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:s?o:c,width:s?c:o}}function Vg({format:n,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:s}){const{width:o,height:c}=Pl({resolution:t,aspectRatio:e}),d=i/s,f=e>d;let p=1;if(n==="letterbox"||n==="letterbox-video")p=f?c/s:o/i;else if(n==="squarebox"){const k=Math.min(c,o);p=i>=s?k/s:k/i}else n==="crop"&&(p=f?o/i:c/s);const g=o/p,v=c/p,b=(i-g)/2,E=(s-v)/2;return{sx:b,sy:E,sWidth:g,sHeight:v,scale:p}}function ca({source:n,sx:t,sy:e,sw:i,sh:s,dx:o,dy:c,dw:d,dh:f}){const p=(n==null?void 0:n.naturalWidth)??(n==null?void 0:n.videoWidth)??(n==null?void 0:n.width),g=(n==null?void 0:n.naturalHeight)??(n==null?void 0:n.videoHeight)??(n==null?void 0:n.height);t=t??0,e=e??0,i=i??p,s=s??g,i<0&&(t+=i,i=Math.abs(i)),s<0&&(e+=s,s=Math.abs(s)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(c+=f,f=Math.abs(f));const v=Math.max(t,0),b=Math.min(t+i,p),E=Math.max(e,0),k=Math.min(e+s,g),w=d/i,L=f/s;return[n,v,E,b-v,k-E,t<0?o-t*w:o,e<0?c-e*L:c,(b-v)*w,(k-E)*L]}function Md({context:n,source:t,crop:e,format:i="letterbox",posX:s,posY:o,drawAreaWidth:c,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:b,y:E,width:k,height:w}=e??{},L=f*(b??0),x=p*(E??0),M=f*Math.min(1-(b??0),k??1),N=p*Math.min(1-(E??0),w??1),D=g.getContext("2d");if(D){g.width=M,g.height=N;const J=ca({source:t,sx:L,sy:x,sw:M,sh:N,dx:0,dy:0,dw:M,dh:N});D.drawImage(...J)}const F=M/N,{sx:H,sy:j,sWidth:st,sHeight:at,scale:Q}=Vg({resolution:Math.min(c,d),aspectRatio:c/d,format:i,sourceWidth:M,sourceHeight:N}),kt=g&&typeof n.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!kt){if(H<0){const J=Math.abs(H)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,J,d),n.rect(s+c-J,o,J,d),n.fill(),n.closePath()}if(j<0){const J=Math.abs(j)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,c,J),n.rect(s,o+d-J,c,J),n.fill(),n.closePath()}}if(i==="letterbox-video"&&kt){const J=v.getContext("2d");if(J){v.width=M,v.height=N,n.save(),n.globalCompositeOperation="destination-out",n.fillRect(s,o,c,d);const St=ca({source:g,sx:H,sy:j,sw:st,sh:at,dx:s,dy:o,dw:c,dh:d});n.globalCompositeOperation="source-over",n.drawImage(...St),J.save();const $=1.2,U=-(M*$-M)/2,Z=-(N*$-N)/2,mt=Math.min(M/20,N/20);if(J.filter=`blur(${mt}px) brightness(20%)`,J.translate(U,Z),J.scale($,$),J.drawImage(g,0,0,M,N),J.restore(),n.globalCompositeOperation="destination-over",H<0){const bt=c/F,Dt=d/bt,Ut=ca({source:v,sy:(1-Dt)*N/2,sh:Dt*N,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}if(j<0){const bt=d*F,Dt=c/bt,Ut=ca({source:v,sx:(1-Dt)*M/2,sw:Dt*M,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}n.restore()}}else{const J=ca({source:g,sx:H,sy:j,sw:st,sh:at,dx:s,dy:o,dw:c,dh:d});n.drawImage(...J)}const gt=H*-1*Q,Ft=j*-1*Q,Kt=c-gt*2,V=d-Ft*2;return{dx:gt,dy:Ft,dw:Kt,dh:V}}const Hg=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Wg=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function $d(n){if(!n)return[];const t=n.match(Hg);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
89
89
  `,`
90
90
  `).split(`
91
- `),[o,c]=i.match(Mg)||[];return{start:o,end:c,text:s}}):[]}function Xa(n){const[t,e,i]=n.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function $g({canvas:n,dx:t,dy:e,dw:i,dh:s,relativeTime:o,vttCaptions:c}){if(c){const d=Rd(c).find(({start:f,end:p})=>f&&p&&o>=Xa(f)&&o<Xa(p));if(d){const f=n.getContext("2d");if(f){const p=Math.min(i,s);let g=[""];const v=i*.9,A=p*.05;f.font=`${A}px Roobert, Dejavu Sans, sans-serif`,f.textBaseline="middle",d.text.split(" ").forEach(T=>{const E=g.length-1,w=f.measureText(g[E]).width,R=f.measureText(` ${T}`).width;w+R<v?g[E]=`${g[E]} ${T}`:g=[...g,T]}),g.forEach((T,E)=>{const w=T.trim(),R=f.measureText(w),x=t+(i-R.width)/2,M=e+(s*.85-(A+p*.04)*(g.length-1-E)),G=A*.8,_=A/1.5,F=t+(i-R.width-_)/2,H=M-G,j=R.width+_,nt=G*2,ot=f.globalAlpha;f.save(),f.globalAlpha=.8*ot,f.fillStyle="#000000",f.beginPath(),f.roundRect(F,H,j,nt,p*.01),f.fill(),f.closePath(),f.globalAlpha=ot,f.fillStyle="#FFFFFF",f.fillText(w,x,M),f.restore()})}}}}function Fg(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Re={},Ll={},ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.default=ee.Wrap=ee.Unit=ee.PrintOptions=ee.PositionType=ee.Overflow=ee.NodeType=ee.MeasureMode=ee.LogLevel=ee.Justify=ee.Gutter=ee.FlexDirection=ee.ExperimentalFeature=ee.Errata=ee.Edge=ee.Display=ee.Direction=ee.Dimension=ee.Align=void 0;let Yr=function(n){return n[n.Auto=0]="Auto",n[n.FlexStart=1]="FlexStart",n[n.Center=2]="Center",n[n.FlexEnd=3]="FlexEnd",n[n.Stretch=4]="Stretch",n[n.Baseline=5]="Baseline",n[n.SpaceBetween=6]="SpaceBetween",n[n.SpaceAround=7]="SpaceAround",n}({});ee.Align=Yr;let Rl=function(n){return n[n.Width=0]="Width",n[n.Height=1]="Height",n}({});ee.Dimension=Rl;let qa=function(n){return n[n.Inherit=0]="Inherit",n[n.LTR=1]="LTR",n[n.RTL=2]="RTL",n}({});ee.Direction=qa;let _l=function(n){return n[n.Flex=0]="Flex",n[n.None=1]="None",n}({});ee.Display=_l;let _r=function(n){return n[n.Left=0]="Left",n[n.Top=1]="Top",n[n.Right=2]="Right",n[n.Bottom=3]="Bottom",n[n.Start=4]="Start",n[n.End=5]="End",n[n.Horizontal=6]="Horizontal",n[n.Vertical=7]="Vertical",n[n.All=8]="All",n}({});ee.Edge=_r;let na=function(n){return n[n.None=0]="None",n[n.StretchFlexBasis=1]="StretchFlexBasis",n[n.All=2147483647]="All",n[n.Classic=2147483646]="Classic",n}({});ee.Errata=na;let Qa=function(n){return n[n.WebFlexBasis=0]="WebFlexBasis",n[n.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",n[n.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",n}({});ee.ExperimentalFeature=Qa;let aa=function(n){return n[n.Column=0]="Column",n[n.ColumnReverse=1]="ColumnReverse",n[n.Row=2]="Row",n[n.RowReverse=3]="RowReverse",n}({});ee.FlexDirection=aa;let Ja=function(n){return n[n.Column=0]="Column",n[n.Row=1]="Row",n[n.All=2]="All",n}({});ee.Gutter=Ja;let zs=function(n){return n[n.FlexStart=0]="FlexStart",n[n.Center=1]="Center",n[n.FlexEnd=2]="FlexEnd",n[n.SpaceBetween=3]="SpaceBetween",n[n.SpaceAround=4]="SpaceAround",n[n.SpaceEvenly=5]="SpaceEvenly",n}({});ee.Justify=zs;let Ys=function(n){return n[n.Error=0]="Error",n[n.Warn=1]="Warn",n[n.Info=2]="Info",n[n.Debug=3]="Debug",n[n.Verbose=4]="Verbose",n[n.Fatal=5]="Fatal",n}({});ee.LogLevel=Ys;let to=function(n){return n[n.Undefined=0]="Undefined",n[n.Exactly=1]="Exactly",n[n.AtMost=2]="AtMost",n}({});ee.MeasureMode=to;let Cl=function(n){return n[n.Default=0]="Default",n[n.Text=1]="Text",n}({});ee.NodeType=Cl;let eo=function(n){return n[n.Visible=0]="Visible",n[n.Hidden=1]="Hidden",n[n.Scroll=2]="Scroll",n}({});ee.Overflow=eo;let io=function(n){return n[n.Static=0]="Static",n[n.Relative=1]="Relative",n[n.Absolute=2]="Absolute",n}({});ee.PositionType=io;let ro=function(n){return n[n.Layout=1]="Layout",n[n.Style=2]="Style",n[n.Children=4]="Children",n}({});ee.PrintOptions=ro;let oa=function(n){return n[n.Undefined=0]="Undefined",n[n.Point=1]="Point",n[n.Percent=2]="Percent",n[n.Auto=3]="Auto",n}({});ee.Unit=oa;let so=function(n){return n[n.NoWrap=0]="NoWrap",n[n.Wrap=1]="Wrap",n[n.WrapReverse=2]="WrapReverse",n}({});ee.Wrap=so;var Ng={ALIGN_AUTO:Yr.Auto,ALIGN_FLEX_START:Yr.FlexStart,ALIGN_CENTER:Yr.Center,ALIGN_FLEX_END:Yr.FlexEnd,ALIGN_STRETCH:Yr.Stretch,ALIGN_BASELINE:Yr.Baseline,ALIGN_SPACE_BETWEEN:Yr.SpaceBetween,ALIGN_SPACE_AROUND:Yr.SpaceAround,DIMENSION_WIDTH:Rl.Width,DIMENSION_HEIGHT:Rl.Height,DIRECTION_INHERIT:qa.Inherit,DIRECTION_LTR:qa.LTR,DIRECTION_RTL:qa.RTL,DISPLAY_FLEX:_l.Flex,DISPLAY_NONE:_l.None,EDGE_LEFT:_r.Left,EDGE_TOP:_r.Top,EDGE_RIGHT:_r.Right,EDGE_BOTTOM:_r.Bottom,EDGE_START:_r.Start,EDGE_END:_r.End,EDGE_HORIZONTAL:_r.Horizontal,EDGE_VERTICAL:_r.Vertical,EDGE_ALL:_r.All,ERRATA_NONE:na.None,ERRATA_STRETCH_FLEX_BASIS:na.StretchFlexBasis,ERRATA_ALL:na.All,ERRATA_CLASSIC:na.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:Qa.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:Qa.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:Qa.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:aa.Column,FLEX_DIRECTION_COLUMN_REVERSE:aa.ColumnReverse,FLEX_DIRECTION_ROW:aa.Row,FLEX_DIRECTION_ROW_REVERSE:aa.RowReverse,GUTTER_COLUMN:Ja.Column,GUTTER_ROW:Ja.Row,GUTTER_ALL:Ja.All,JUSTIFY_FLEX_START:zs.FlexStart,JUSTIFY_CENTER:zs.Center,JUSTIFY_FLEX_END:zs.FlexEnd,JUSTIFY_SPACE_BETWEEN:zs.SpaceBetween,JUSTIFY_SPACE_AROUND:zs.SpaceAround,JUSTIFY_SPACE_EVENLY:zs.SpaceEvenly,LOG_LEVEL_ERROR:Ys.Error,LOG_LEVEL_WARN:Ys.Warn,LOG_LEVEL_INFO:Ys.Info,LOG_LEVEL_DEBUG:Ys.Debug,LOG_LEVEL_VERBOSE:Ys.Verbose,LOG_LEVEL_FATAL:Ys.Fatal,MEASURE_MODE_UNDEFINED:to.Undefined,MEASURE_MODE_EXACTLY:to.Exactly,MEASURE_MODE_AT_MOST:to.AtMost,NODE_TYPE_DEFAULT:Cl.Default,NODE_TYPE_TEXT:Cl.Text,OVERFLOW_VISIBLE:eo.Visible,OVERFLOW_HIDDEN:eo.Hidden,OVERFLOW_SCROLL:eo.Scroll,POSITION_TYPE_STATIC:io.Static,POSITION_TYPE_RELATIVE:io.Relative,POSITION_TYPE_ABSOLUTE:io.Absolute,PRINT_OPTIONS_LAYOUT:ro.Layout,PRINT_OPTIONS_STYLE:ro.Style,PRINT_OPTIONS_CHILDREN:ro.Children,UNIT_UNDEFINED:oa.Undefined,UNIT_POINT:oa.Point,UNIT_PERCENT:oa.Percent,UNIT_AUTO:oa.Auto,WRAP_NO_WRAP:so.NoWrap,WRAP_WRAP:so.Wrap,WRAP_WRAP_REVERSE:so.WrapReverse};ee.default=Ng,Object.defineProperty(Ll,"__esModule",{value:!0}),Ll.default=Bg;var ps=Ug(ee);function _d(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(_d=function(i){return i?e:t})(n)}function Ug(n,t){if(!t&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var e=_d(t);if(e&&e.has(n))return e.get(n);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in n)if(o!=="default"&&Object.prototype.hasOwnProperty.call(n,o)){var c=s?Object.getOwnPropertyDescriptor(n,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=n[o]}return i.default=n,e&&e.set(n,i),i}function Bg(n){function t(s,o,c){const d=s[o];s[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return c.call(this,d,...p)}}for(const s of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[ps.Unit.Point]:n.Node.prototype[s],[ps.Unit.Percent]:n.Node.prototype[`${s}Percent`],[ps.Unit.Auto]:n.Node.prototype[`${s}Auto`]};t(n.Node.prototype,s,function(c){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,A;if(g==="auto")v=ps.Unit.Auto,A=void 0;else if(typeof g=="object")v=g.unit,A=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?ps.Unit.Percent:ps.Unit.Point,A=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(A))throw new Error(`Invalid value ${g} for ${s}`);if(!o[v])throw new Error(`Failed to execute "${s}": Unsupported unit '${g}'`);return A!==void 0?o[v].call(this,...f,A):o[v].call(this,...f)})}function e(s){return n.MeasureCallback.implement({measure:function(){const{width:o,height:c}=s(...arguments);return{width:o??NaN,height:c??NaN}}})}t(n.Node.prototype,"setMeasureFunc",function(s,o){return o?s.call(this,e(o)):this.unsetMeasureFunc()});function i(s){return n.DirtiedCallback.implement({dirtied:s})}return t(n.Node.prototype,"setDirtiedFunc",function(s,o){s.call(this,i(o))}),t(n.Config.prototype,"free",function(){n.Config.destroy(this)}),t(n.Node,"create",(s,o)=>o?n.Node.createWithConfig(o):n.Node.createDefault()),t(n.Node.prototype,"free",function(){n.Node.destroy(this)}),t(n.Node.prototype,"freeRecursive",function(){for(let s=0,o=this.getChildCount();s<o;++s)this.getChild(0).freeRecursive();this.free()}),t(n.Node.prototype,"calculateLayout",function(s){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:ps.Direction.LTR;return s.call(this,o,c,d)}),{Config:n.Config,Node:n.Node,...ps.default}}var Cd={exports:{}};(function(n,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(s){s=s||{};var o;o||(o=typeof s<"u"?s:{});var c,d;o.ready=new Promise(function(C,I){c=C,d=I});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),i&&(p=i),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var A;o.wasmBinary&&(A=o.wasmBinary),o.noExitRuntime;function T(){this.buffer=new ArrayBuffer(V/65536*65536)}function E(){}function w(C){this.exports=function(I){function N(Je){return Je.set=function(le,tr){this[le]=tr},Je.get=function(le){return this[le]},Je}for(var B,et=new Uint8Array(123),mt=25;mt>=0;--mt)et[48+mt]=52+mt,et[65+mt]=mt,et[97+mt]=26+mt;et[43]=62,et[47]=63;function lt(Je,le,tr){for(var Pi,ft,Fr=0,l=le,bt=tr.length,In=le+(bt*3>>2)-(tr[bt-2]=="=")-(tr[bt-1]=="=");Fr<bt;Fr+=4)Pi=et[tr.charCodeAt(Fr+1)],ft=et[tr.charCodeAt(Fr+2)],Je[l++]=et[tr.charCodeAt(Fr)]<<2|Pi>>4,l<In&&(Je[l++]=Pi<<4|ft>>2),l<In&&(Je[l++]=ft<<6|et[tr.charCodeAt(Fr+3)])}function St(Je){lt(B,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(B,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(B,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(B,4432,"xwAAAMgAAADJ"),lt(B,4452,"xwAAAMoAAADLAAAArBs="),lt(B,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(B,4552,"zAAAAM0AAADO"),lt(B,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(B,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(B,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(B,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(B,5179,"DA=="),lt(B,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(B,5237,"EA=="),lt(B,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(B,5295,"Eg=="),lt(B,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(B,5362,"GgAAABoaGgAAAAAAAAk="),lt(B,5411,"FA=="),lt(B,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(B,5469,"Fg=="),lt(B,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(B,5556,"1Q=="),lt(B,5596,"//////////8="),lt(B,5664,"8B8BAAAAAAAF"),lt(B,5684,"0A=="),lt(B,5708,"0QAAANIAAADUGw=="),lt(B,5732,"Ag=="),lt(B,5748,"//////////8="),lt(B,5816,"BQ=="),lt(B,5828,"0w=="),lt(B,5852,"0QAAANQAAADoGwAAAAQ="),lt(B,5876,"AQ=="),lt(B,5892,"/////wo="),lt(B,5960,"1g==")}var _t=new ArrayBuffer(16),Ct=new Int32Array(_t),Nt=new Float32Array(_t),zt=new Float64Array(_t);function Jt(Je){return Ct[Je]}function It(Je,le){Ct[Je]=le}function Ae(){return zt[0]}function pi(Je){zt[0]=Je}function ue(){throw new Error("abort")}function Ki(Je){Nt[2]=Je}function Gt(){return Nt[2]}function Wo(Je){var le=Je.a,tr=le.a,Pi=tr.buffer;tr.grow=Fk;var ft=new Int8Array(Pi),Fr=new Int16Array(Pi),l=new Int32Array(Pi),bt=new Uint8Array(Pi),In=new Uint16Array(Pi),Vf=new Uint32Array(Pi),D=new Float32Array(Pi),Fe=new Float64Array(Pi),Ne=Math.imul,m=Math.fround,Be=Math.abs,gr=Math.clz32,PA=Math.min,OA=Math.max,Yt=NaN,Wf=1/0,wt=le.b,Ei=le.c,ss=le.d,ns=le.e,Ls=le.f,Dn=le.g,Ca=le.h,Ko=le.i,oh=le.j,lh=le.k,ch=le.l,Kf=le.m,jf=le.n,zf=le.o,Yf=le.p,Zf=le.q,MA=le.r,$A=le.s,FA=le.t,NA=le.u,UA=le.v,BA=le.w,GA=le.x,HA=le.y,VA=le.z,WA=le.A,KA=le.B,jA=le.C,zA=le.D,At=73712,Oi=0;function Xf(r,a,h,u,y,b,k,S,P,K,Q,dt,X,J){var O=0,W=m(0),z=0,Z=m(0),st=0,at=m(0),pt=0,yt=m(0),Rt=0,xt=0,Ft=m(0),Vt=0,Xt=0,re=m(0),me=m(0),Le=m(0),xe=m(0),Pe=0,Ue=m(0),He=m(0),ti=0,ei=0,vi=m(0),_i=0,zi=0,Ci=0,Fi=0,Yi=m(0),Zi=0,Sr=0,Lr=0,Hr=0,Vr=m(0),Wr=0,Kr=0,as=0,os=0,ls=m(0),Is=0,Ds=0,xs=0,Ps=m(0),Os=0,Ms=m(0),xa=0,Pa=m(0),Oa=m(0),Ma=m(0),$a=0,Jo=m(0),wh=0,Sh=m(0),Lh=m(0),Rh=m(0),_h=m(0),Ch=0,jp=0,zp=0,Yp=0,Zp=0,Xp=0,qp=0,Qp=0,Ve=0,We=m(0),Fn=m(0);O=At-384|0,At=O;t:{r:{i:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(z=(P?0:4)+Q|0,l[z>>2]=l[z>>2]+1,z=l[r+24>>2]&3,wh=(u|0)<=1?1:u,Fi=z||wh,ft[r+300|0]=bt[r+300|0]&252|Fi&3,z=r+252|0,u=((Fi|0)!=1)<<3,Is=(Fi|0)==2?3:2,at=fe(r,Is,k),D[z+u>>2]=at,st=z,z=((Fi|0)==1)<<3,me=we(r,Is,k),D[st+z>>2]=me,yt=fe(r,0,k),D[r+256>>2]=yt,xe=we(r,0,k),D[r+264>>2]=xe,st=r+268|0,Ve=st+u|0,We=ge(r,Is),D[Ve>>2]=We,Ve=z+st|0,We=Se(r,Is),D[Ve>>2]=We,W=ge(r,0),D[r+272>>2]=W,Ue=Se(r,0),D[r+280>>2]=Ue,st=u,u=r+284|0,Ve=st+u|0,We=Ie(r,Is,k),D[Ve>>2]=We,Ve=u+z|0,We=De(r,Is,k),D[Ve>>2]=We,Z=Ie(r,0,k),D[r+288>>2]=Z,Ft=De(r,0,k),D[r+296>>2]=Ft,at=m(at+me),me=m(yt+xe),u=l[r+8>>2],u){yt=m(m(m(D[r+284>>2]+D[r+292>>2])+D[r+268>>2])+D[r+276>>2]),h=m(b?h-me:Yt),W=m(m(Z+Ft)+W),Z=m(y?a-at:Yt),a=Z;e:{if(a!=a)break e;if(a=m(Z-yt),a!=a){a=m(0);break e}a=ce(a,m(0))}at=m(W+Ue),W=h;e:{if(h!=h)break e;if(W=m(h-at),W!=W){W=m(0);break e}W=ce(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Ge(r,2,Z,k),u=a!=a,W=m(m(Ie(r,2,k)+ge(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}D[r+516>>2]=a,a=Ge(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,k)+ge(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}D[r+520>>2]=a;break t}e:{if(bt[r+4|0]&16){Dt[u|0](O+24|0,r,a,y,W,b,0);break e}Dt[u|0](O+24|0,r,a,y,W,b)}l[Q+20>>2]=l[Q+20>>2]+1,u=(J<<2)+Q|0,l[u+24>>2]=l[u+24>>2]+1,a=m(yt+D[O+24>>2]),a=Ge(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(Ie(r,2,k)+ge(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}D[r+516>>2]=a,a=m(at+D[O+28>>2]),a=Ge(r,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,k)+ge(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}D[r+520>>2]=a;break t}if(u=l[r+556>>2],J=l[r+560>>2],(u|0)==(J|0)){me=m(h-me),a=Ge(r,2,y&-3?m(a-at):m(m(m(D[r+284>>2]+D[r+292>>2])+D[r+268>>2])+D[r+276>>2]),k),u=a!=a,h=m(m(Ie(r,2,k)+ge(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}D[r+516>>2]=a,a=Ge(r,0,b&-3?me:m(m(m(Z+Ft)+W)+Ue),S),u=a!=a,h=m(m(Ie(r,0,k)+ge(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}D[r+520>>2]=a;break t}e:{if(P||(W=m(a-at),Z=m(h-me),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(Z<=m(0))|(b|0)!=2)&Z==Z)&((y|0)!=1|(b|0)!=1)))break e;a=Ge(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ie(r,2,k)+ge(r,2))+m(De(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}D[r+516>>2]=a,a=Ge(r,0,Z!=Z||(b|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(Ie(r,0,k)+ge(r,0))+m(De(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}D[r+520>>2]=a;break t}for(ti=J-u|0,Hr=ti>>2;z=l[u>>2],l[z+552>>2]!=(r|0)&&(st=l[r+568>>2],z=hp(l[st>>2],bt[st+8|0],z,r,Rt,0),l[u>>2]=z,l[z+552>>2]=r),Rt=Rt+1|0,u=u+4|0,(J|0)!=(u|0););ft[r+300|0]=bt[r+300|0]&251,Rt=3,_i=l[r+24>>2],u=_i>>>2&3;e:{s:{n:{if((Fi|0)==2){J=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Rt=2;break e}if(Rt=2,J=0,u>>>0>1)break s}J=Rt}Rt=u}Sh=m(a-at),Vr=m(m(Ie(r,Rt,k)+ge(r,Rt))+m(De(r,Rt,k)+Se(r,Rt))),Ue=m(Ie(r,J,k)+ge(r,J)),Yi=m(Ue+m(De(r,J,k)+Se(r,J))),Zi=Rt>>>0>1,yt=ep(r,0,Sh,Zi?Vr:Yi,k),Lh=m(h-me),He=ep(r,1,Lh,Zi?Yi:Vr,S),xe=Zi?He:yt,me=Zi?yt:He,Wr=l[r+560>>2],z=l[r+556>>2],zi=Zi?y:b;e:{if((zi|0)!=1)break e;if((z|0)==(Wr|0))break i;for(u=z;;){st=l[u>>2];s:{if(!Ap(st))break s;if(Xt=0,pt)break e;n:{a:{if(!l[st+552>>2]){W=m(0);break a}if(h=D[st+32>>2],h!=h&&(W=m(0),h=D[st+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Be(W))<m(9999999747378752e-20))break e}if(a=Mn(st),a!=a){pt=st;break s}if(pt=st,m(Be(a))<m(9999999747378752e-20))break e}if(Xt=pt,u=u+4|0,(Wr|0)==(u|0))break}}if((z|0)==(Wr|0))break i;for(xa=(Fi|0)<=1?1:Fi,Ds=yt!=yt,Kr=Ds|(y|0)!=1,as=He==He,xs=yt==yt,W=m(0);;){Vt=l[z>>2],tp(Vt),st=l[Vt+24>>2];e:{if(st&4194304){if(sp(Vt,0),u=bt[Vt+4|0],st=u|1,ft[Vt+4|0]=st,!(u&4))break e;ft[Vt+4|0]=st&251;break e}if(P&&(u=st&3,dp(Vt,u||xa,me,xe,yt),st=l[Vt+24>>2]),(st&196608)==131072)break e;s:{if((Vt|0)==(Xt|0)){l[Xt+308>>2]=0,l[Xt+304>>2]=X,h=m(0);break s}os=l[r+24>>2],u=os>>>2&3;n:{a:{if((Fi|0)!=2)break a;pt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}pt=2;break n}pt=u}Sr=pt>>>0>1,at=Sr?yt:He,h=m(0),a=D[Vt+40>>2];n:{a:{xt=l[Vt+40>>2];o:{if((xt|0)==2139156720)break o;if((xt|0)==2140081935)break a;u=4336;l:{if((xt|0)!=2141891242){if(a==a)break l;u=4344}h=D[u>>2];c:{h:switch(xt=l[u+4>>2],xt|0){case 0:case 3:break h;default:break c}if(a=m(Yt),!(D[Vt+28>>2]>m(0)))break n;xt=ft[l[Vt+568>>2]+8|0]&1,u=xt?2143289344:0,xt=xt?3:1,h=(It(2,u),Gt())}switch(a=m(Yt),xt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(It(2,(xt&-1073741825)+536870912|0),Gt()),!(xt&1073741824))break a}a=m(m(at*h)*m(.009999999776482582));break n}a=h}h=D[Vt+572>>2],xt=0;n:{a:switch(Pe=l[Vt+576>>2],Pe|0){case 0:case 3:break n;default:break a}if(Z=D[Vt+572>>2],!((Pe|0)!=1|Z!=Z)){if(h<m(0))break n;xt=1;break n}if(xt=1,(Pe|0)!=2|Z!=Z||(xt=0,h<m(0)))break n;xt=xs}Z=D[Vt+580>>2],u=0;n:{a:switch(ei=l[Vt+584>>2],ei|0){case 0:case 3:break n;default:break a}if(Ft=D[Vt+580>>2],!((ei|0)!=1|Ft!=Ft)){if(Z<m(0))break n;u=1;break n}if(u=1,(ei|0)!=2|Ft!=Ft||(u=0,Z<m(0)))break n;u=as}n:{a:{if(!(a!=a|at!=at)){if(h=D[Vt+308>>2],(!(ft[l[Vt+568>>2]+12|0]&1)|l[Vt+304>>2]==(X|0))&h==h)break n;if(h=m(m(Ie(Vt,pt,yt)+ge(Vt,pt))+m(De(Vt,pt,yt)+Se(Vt,pt))),!(h<=a)&a<h)break a;h=a;break a}if(xt&Sr){Z=m(m(Ie(Vt,2,yt)+ge(Vt,2))+m(De(Vt,2,yt)+Se(Vt,2))),a=m(Yt);o:switch(Pe-1|0){case 1:h=m(m(yt*h)*m(.009999999776482582));case 0:if(a=h,Z<=a)break a;break;default:break o}if(!(a==a|Z==Z)){h=a;break a}if(a<Z){h=Z;break a}h=a!=a?Z:a;break a}if(!(Sr|u^1)){a=m(m(Ie(Vt,0,yt)+ge(Vt,0))+m(De(Vt,0,yt)+Se(Vt,0))),h=m(Yt);o:switch(ei-1|0){case 1:Z=m(m(He*Z)*m(.009999999776482582));case 0:if(h=Z,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(l[O+360>>2]=2143289344,l[O+24>>2]=2143289344,Ci=0,l[O+356>>2]=0,l[O+352>>2]=0,Ft=m(fe(Vt,2,yt)+we(Vt,2,yt)),re=fe(Vt,0,yt),Le=we(Vt,0,yt),at=m(Yt),Lr=0,a=m(Yt),xt){o:{l:switch(Pe-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(yt*h)*m(.009999999776482582))}l[O+356>>2]=1,a=m(Ft+a),D[O+24>>2]=a,Lr=1}if(re=m(re+Le),u){h=m(Yt);o:{l:switch(ei-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(He*Z)*m(.009999999776482582))}l[O+352>>2]=1,at=m(re+h),D[O+360>>2]=at,Ci=1}Pe=(os&3145728)==2097152,ei=pt>>>0<2;o:{l:{c:{if(!(Pe&ei)){if(Pe|Ds)break l;if(a!=a)break c;break l}if(Ds|a==a)break o}Lr=2,l[O+356>>2]=2,D[O+24>>2]=yt,a=yt}l:{if(!Pe||ei){if(Pe|He!=He)break o;if(at!=at)break l;break o}if(at==at|He!=He)break o}Ci=2,l[O+352>>2]=2,D[O+360>>2]=He,at=He}h=D[Vt+224>>2],Pe=h!=h;o:{if(Pe)break o;l:{if(!(Sr|(Lr|0)!=1)){l[O+352>>2]=1,D[O+360>>2]=re+m(m(a-Ft)/h);break l}if(ei|(Ci|0)!=1)break o;l[O+356>>2]=1,D[O+24>>2]=m(m(at-re)*h)+Ft}Ci=1,Lr=1}st=st>>>13&7,st=st||os>>>10&7;o:{if((st|0)==5|(Lr|0)==1|(Sr|(xt|Kr))|(st|0)!=4||(l[O+356>>2]=1,D[O+24>>2]=yt,Pe))break o;Ci=1,l[O+352>>2]=1,D[O+360>>2]=m(yt-Ft)/h}o:{if(ei|(b|0)!=1|He!=He|u|(st|0)!=4|(Ci|0)==1||(l[O+352>>2]=1,D[O+360>>2]=He,Pe))break o;l[O+356>>2]=1,D[O+24>>2]=m(He-re)*h}if(xn(Vt,2,yt,yt,O+356|0,O+24|0),xn(Vt,0,He,yt,O+352|0,O+360|0),an(Vt,D[O+24>>2],D[O+360>>2],Fi,l[O+356>>2],l[O+352>>2],yt,He,0,5,K,Q,dt,X),a=D[(Vt+(l[(pt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Vt,pt,yt)+ge(Vt,pt))+m(De(Vt,pt,yt)+Se(Vt,pt))),!(u|h!=h)){h=ce(a,h);break a}h=u?h:a}D[Vt+308>>2]=h}l[Vt+304>>2]=X}W=m(W+m(h+m(fe(Vt,Rt,yt)+we(Vt,Rt,yt))))}if(z=z+4|0,(Wr|0)==(z|0))break}break r}l[O>>2]=3072,er(r,O),ji(),ue()}l[O+16>>2]=3154,er(r,O+16|0),ji(),ue()}W=m(0)}a=m(W+m(0)),Pa=Zi?S:k,Ps=Zi?k:S,ti>>>0>=5&&(a=m(m(jo(r,Rt,xe)*m(Hr-1>>>0))+a)),u=a>me,Wr=_i&786432,as=(zi|0)==2&&Wr&&u?1:zi,Vt=Zi?b:y,Sr=(Vt|0)==1,jp=Sr&(P^1),Zi=Rt>>>0<2,zp=Vt&-3,Ds=r+208|0,b=J<<2,ei=b+4288|0,Yp=Sr&!Wr,Zp=(Vt|0)!=1|P,z=Rt<<2,Lr=z+4288|0,xs=z+4320|0,os=xe==xe,Xp=os<<1,Pe=b+4320|0,qp=!zi|!u,xa=O+52|0,Rh=jo(r,J,xe),st=0,u=0,Ci=0;r:{for(;;){zi=u,$i(O+24|0,0,44),u=l[r+560>>2],b=l[r+556>>2];i:{if((u|0)==(b|0))break i;if(u=u-b|0,(u|0)<0)break r;if(z=Da(O+360|0,u>>2,0,xa),u=l[O+44>>2],b=l[O+48>>2]-u|0,b=Rs(l[O+364>>2]-b|0,u,b),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=b,pt=l[O+368>>2],xt=l[O+372>>2],b=l[O+48>>2],l[O+368>>2]=b,Xt=l[O+52>>2],l[O+48>>2]=pt,l[O+52>>2]=xt,l[O+372>>2]=Xt,l[z>>2]=u,(u|0)!=(b|0)&&(l[O+368>>2]=b+((u-b|0)+3&-4)),!u)break i;gi(u)}Xt=l[r+24>>2],u=Xt>>>2&3;i:{e:{if(b=Xt&3,((b||wh)|0)!=2)break e;pt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}pt=2;break i}pt=u}W=jo(r,pt,yt),z=st,xt=l[r+560>>2],b=l[r+556>>2];i:{if(z>>>0>=xt-b>>2>>>0)break i;for(Xt=Xt&786432,h=m(0);;){if(xt-b>>2>>>0<=z>>>0)break r;if(u=l[(z<<2)+b>>2],ti=l[u+24>>2],!(ti&4194304|(ti&196608)==131072)){if(l[u+548>>2]=zi,a=fe(u,pt,yt),Z=we(u,pt,yt),b=l[O+24>>2],at=(z|0)==(st|0)?m(0):W,a=m(a+Z),Z=D[u+308>>2],Ft=Ge(u,pt,Z,Ps),!(!b||!(m(at+m(a+m(h+Ft)))>me)|!Xt))break i;if(l[O+24>>2]=b+1,at=m(at+m(a+Ft)),D[O+28>>2]=at+D[O+28>>2],Ap(u)){e:{if(!l[u+552>>2]){a=m(0);break e}if(a=D[u+32>>2],a==a)break e;a=D[u+28>>2],a=a>m(0)?a:m(0)}D[O+32>>2]=a+D[O+32>>2],Ve=O,We=m(D[O+36>>2]-m(Mn(u)*Z)),D[Ve+36>>2]=We}b=l[O+48>>2];e:{if((b|0)!=l[O+52>>2]){l[b>>2]=u,l[O+48>>2]=b+4;break e}if(b=b-l[O+44>>2]|0,ti=b>>2,xt=ti+1|0,xt>>>0>=1073741824)break r;if(_i=b>>1,xt=Da(O+360|0,b>>>0>=2147483644?1073741823:xt>>>0<_i>>>0?_i:xt,ti,xa),l[l[O+368>>2]>>2]=u,l[O+368>>2]=l[O+368>>2]+4,u=l[O+44>>2],b=l[O+48>>2]-u|0,b=Rs(l[O+364>>2]-b|0,u,b),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=b,ti=l[O+368>>2],_i=l[O+372>>2],b=l[O+48>>2],l[O+368>>2]=b,Kr=l[O+52>>2],l[O+48>>2]=ti,l[O+52>>2]=_i,l[O+372>>2]=Kr,l[xt>>2]=u,(u|0)!=(b|0)&&(l[O+368>>2]=b+((u-b|0)+3&-4)),!u)break e;gi(u)}b=l[r+556>>2],xt=l[r+560>>2],h=m(h+at)}if(z=z+1|0,!(z>>>0<xt-b>>2>>>0))break}}Le=D[O+32>>2],!(Le>m(0))|!(Le<m(1))||(l[O+32>>2]=1065353216,Le=m(1)),vi=D[O+36>>2],!(vi>m(0))|!(vi<m(1))||(l[O+36>>2]=1065353216,vi=m(1)),l[O+40>>2]=z,Ft=D[O+28>>2],pt=l[O+24>>2],Ci&&gi(Ci),Z=D[O+56>>2],ti=l[O+48>>2],Ci=l[O+44>>2];i:{e:{s:{n:{if((as|0)==1)break n;h=m(0),a=D[Ds>>2];a:{o:{u=l[Ds>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(a==a)break c;b=4344}switch(h=D[b>>2],a=m(Yt),l[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=D[r+216>>2];a:{o:{u=l[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=D[b>>2],W=m(Yt),l[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),at=D[r+212>>2];a:{o:{u=l[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(at==at)break c;b=4344}switch(h=D[b>>2],at=m(Yt),l[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}at=m(m(h*S)*m(.009999999776482582));break a}at=h}h=m(0),re=D[r+220>>2];a:{o:{u=l[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;b=4336;c:{if((u|0)!=2141891242){if(re==re)break c;b=4344}switch(h=D[b>>2],re=m(Yt),l[b+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break o}re=m(m(h*S)*m(.009999999776482582));break a}re=h}if(u=Rt>>>0>1,h=m((u?a:at)-Vr),h==h&h>Ft||(h=m((u?W:re)-Vr),h==h&h<Ft))break s;if(ft[l[r+568>>2]+16|0]&1)break n;if(h=Ft,!l[r+552>>2]|Le==m(0))break e;a=D[r+32>>2];a:{o:{if(a==a){h=a;break o}if(h=D[r+28>>2],!(h>m(0)))break a}if(h!=h){h=me;break e}a=D[r+32>>2]}if(a!=a&&(h=Ft,a=D[r+28>>2],!(a>m(0)))||(h=me,a!=m(0)))break e;h=Ft;break e}h=me}if(h!=h)break e;Z=m(h-Ft);break i}if(!(Ft<m(0)))break i;Z=m(-Ft)}if(me=h,!jp){i:{if((ti|0)==(Ci|0)){at=m(0);break i}for(re=m(0),b=Ci;;){u=l[b>>2],Ft=D[u+308>>2],h=Ge(u,Rt,Ft,Ps);e:{if(Z<m(0)){if(a=m(h*m(-Mn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/vi)*a)+h),a=Ge(u,Rt,W,me),xt=a!=a,at=m(m(Ie(u,Rt,yt)+ge(u,Rt))+m(De(u,Rt,yt)+Se(u,Rt)));s:{if(!(xt|at!=at)){a=ce(a,at);break s}a=xt?at:a}if(W!=W|a!=a|a==W)break e;re=m(re+m(a-h)),vi=m(m(Mn(u)*Ft)+vi);break e}if(!(Z>m(0))|!l[u+552>>2]||(W=D[u+32>>2],W!=W&&(W=D[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;at=m(m(m(Z/Le)*W)+h),a=Ge(u,Rt,at,me),xt=a!=a,Ft=m(m(Ie(u,Rt,yt)+ge(u,Rt))+m(De(u,Rt,yt)+Se(u,Rt)));s:{if(!(xt|Ft!=Ft)){a=ce(a,Ft);break s}a=xt?Ft:a}if(at!=at|a!=a|a==at)break e;Le=m(Le-W),re=m(re+m(a-h))}if(b=b+4|0,(ti|0)==(b|0))break}for(re=m(Z-re),Oa=m(re/vi),Ma=m(re/Le),$a=Sr&(qp|!(bt[r+26|0]&12)),Kr=!$a,_i=l[Pe>>2],at=m(0),xt=Ci;;){u=l[xt>>2],Ft=Ge(u,Rt,D[u+308>>2],Ps);e:{s:{if(re<m(0)){if(W=Ft,a=m(W*m(-Mn(u))),a==m(0))break e;a=vi==m(0)?m(Ft+a):m(m(Oa*a)+Ft);break s}if(W=Ft,!(re>m(0))|!l[u+552>>2]||(a=D[u+32>>2],a!=a&&(a=D[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Ma*a)+Ft)}if(a=Ge(u,Rt,a,me),b=a!=a,h=m(m(Ie(u,Rt,yt)+ge(u,Rt))+m(De(u,Rt,yt)+Se(u,Rt))),!(b|h!=h)){W=ce(a,h);break e}W=b?h:a}a=fe(u,Rt,yt),h=we(u,Rt,yt),Le=fe(u,J,yt),Jo=we(u,J,yt),h=m(a+h),_h=m(W+h),D[O+352>>2]=_h,l[O+344>>2]=1,Le=m(Le+Jo),a=D[u+224>>2];e:{if(a==a){l[O+348>>2]=1,h=m(_h-h),D[O+356>>2]=Le+m(Zi?h*a:h/a);break e}s:{if(Os=xe!=xe,Os)break s;Xt=(_i<<3)+u|0,a=D[Xt+572>>2];n:{a:{o:{l:switch(b=l[Xt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=D[Xt+572>>2],(b|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!$a)break s;break n}if(Kr|(!(a<m(0))|((b|0)!=2|h!=h)))break s}if(b=l[u+24>>2]>>>13&7,b||(b=l[r+24>>2]>>>10&7),(b|0)!=4||(ln(O+24|0,u,J),l[O+28>>2]==3)||(on(O+360|0,u,J),l[O+364>>2]==3))break s;l[O+348>>2]=1,D[O+356>>2]=xe;break e}Xt=(_i<<3)+u|0,h=D[Xt+572>>2];s:{n:{a:{o:{l:switch(b=l[Xt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=D[Xt+572>>2],!((b|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((b|0)!=2|a!=a)break a;if(Os)break o;if(!(h<m(0)))break n}l[O+348>>2]=Xp,D[O+356>>2]=xe;break e}a=m(Yt);a:switch(b-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(xe*h)*m(.009999999776482582))}a=m(Le+a),D[O+356>>2]=a,l[O+348>>2]=(Sr|(b|0)!=2)&a==a}xn(u,Rt,me,yt,O+344|0,O+352|0),xn(u,J,xe,yt,O+348|0,O+356|0),Xt=(_i<<3)+u|0,a=D[Xt+572>>2];e:{s:{n:{a:switch(b=l[Xt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=D[Xt+572>>2],!((b|0)!=1|h!=h)){if(a<m(0))break n;break s}if((b|0)!=2|h!=h)break s;if(a<m(0))break n;if(Xt=0,os)break e}if(Xt=0,b=l[u+24>>2]>>>13&7,b||(b=l[r+24>>2]>>>10&7),(b|0)!=4||(ln(O+24|0,u,J),l[O+28>>2]==3))break e;on(O+360|0,u,J),Xt=l[O+364>>2]!=3;break e}Xt=0}a=D[O+352>>2],h=D[O+356>>2],b=Rt>>>0>1,Le=b?a:h,a=b?h:a,Os=l[O+344>>2],Ch=l[O+348>>2],Qp=b?Os:Ch,Os=b?Ch:Os,b=(Xt^1)&P,an(u,Le,a,bt[r+300|0]&3,Qp,Os,yt,He,b,b?4:7,K,Q,dt,X),at=m(at+m(W-Ft)),b=bt[r+300|0];e:{s:{if(b&4){Xt=b&251;break s}if(Xt=b&251,b=0,!(bt[u+300|0]&4))break e}b=4}if(ft[r+300|0]=b|Xt,xt=xt+4|0,(ti|0)==(xt|0))break}}Z=m(Z-at)}u=bt[r+300|0],ft[r+300|0]=u&251|(Z<m(0)?4:u&4),re=m(Ie(r,Rt,k)+ge(r,Rt)),Oa=m(De(r,Rt,k)+Se(r,Rt)),Ft=jo(r,Rt,k);i:{if(!(!(Z>m(0))|(as|0)!=2)){at=m(0),h=m(0);e:{s:{u=Ds+(l[xs>>2]<<2)|0,a=D[u>>2],u=l[u>>2],b=(u|0)==2139156720;n:{if(!b){if(xt=(u|0)==2140081935,xt)break s;if(Xt=(u|0)==2141891242,Xt|a!=a)break i;if(xt)break s;if(Xt)break i;if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break n}h=m(m(Ps*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(b)break n;if((u|0)==2140081935)break s;b=4336;a:{if((u|0)!=2141891242){if(a==a)break a;b=4344}switch(h=D[b>>2],W=m(Yt),l[b+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(It(2,(u&-1073741825)+536870912|0),Gt()),!(u&1073741824))break s}W=m(m(Ps*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-re)-Oa)-m(me-Z)),a!=a)break i;at=ce(a,m(0));break i}at=Z}Xt=z>>>0<=st>>>0;i:{if(!Xt){for(ti=l[r+556>>2],u=l[r+560>>2]-ti>>2,_i=u>>>0<st>>>0?st:u,xt=0,u=st;;){if((u|0)==(_i|0))break r;if(b=l[ti+(u<<2)>>2],(l[b+24>>2]&196608)!=131072&&(Kr=O+24|0,ln(Kr,b,Rt),$a=l[O+28>>2],on(Kr,b,Rt),xt=((($a|0)==3)+xt|0)+(l[O+28>>2]==3)|0),u=u+1|0,(z|0)==(u|0))break}if(Le=m(0),h=Ft,xt)break i}Le=m(0),xt=0,h=Ft;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:Le=m(at*m(.5));break i;case 1:Le=at;break i;case 2:if(pt>>>0<2)break i;h=m(Ft+m((We=m(0),Fn=ce(at,m(0)),Ve=at!=at,(Ve?We:Fn)/m(pt-1>>>0))));break i;case 4:Le=m(at/m(pt+1>>>0)),h=m(Ft+Le);break i;case 3:break e;default:break i}Le=m(m(at*m(.5))/m(pt>>>0)),h=m(m(Le+Le)+Ft)}if(a=m(re+Le),Z=m(0),ti=fp(r),Xt)h=m(0);else{for(_i=z-1|0,Ma=m(at/m(xt|0)),re=m(0),W=m(0),u=st;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=u>>>0)break r;b=l[b+(u<<2)>>2],pt=b+228|0,Mi(O+24|0,pt,320),h=m(h-((u|0)==(_i|0)?Ft:m(0))),xt=l[b+24>>2];i:{if(xt&4194304)break i;e:{if((xt&196608)==131072){if(!ir(b,Rt))break e;if(!P)break i;at=_s(b,Rt,me),vi=ge(r,Rt),Jo=fe(b,Rt,yt),D[pt+(l[Lr>>2]<<2)>>2]=Jo+m(at+vi);break i}if(ln(O+360|0,b,Rt),a=m(a+(l[O+364>>2]==3?Ma:m(-0))),P&&(xt=pt,pt=l[Lr>>2]<<2,D[xt+pt>>2]=a+D[pt+(O+24|0)>>2]),on(O+360|0,b,Rt),a=m(a+(l[O+364>>2]==3?Ma:m(-0))),!Zp){a=m(a+m(m(h+m(fe(b,Rt,yt)+we(b,Rt,yt)))+D[O+104>>2])),Z=xe;break i}if(pt=b+516|0,a=m(a+m(h+m(D[pt+(l[xs>>2]<<2)>>2]+m(fe(b,Rt,yt)+we(b,Rt,yt))))),ti){at=zo(b),vi=fe(b,0,yt),at=m(at+vi),vi=m(m(D[b+520>>2]+m(fe(b,0,yt)+we(b,0,yt)))-at),b=re!=re;s:{if(!(b|at!=at)){re=ce(re,at);break s}re=b?at:re}if(b=W!=W,!(b|vi!=vi)){W=ce(W,vi);break i}W=b?vi:W;break i}if(at=m(D[pt+(l[Pe>>2]<<2)>>2]+m(fe(b,J,yt)+we(b,J,yt))),b=Z!=Z,!(at!=at|b)){Z=ce(Z,at);break i}Z=b?at:Z;break i}if(!P)break i;b=l[Lr>>2]<<2,at=D[b+(O+24|0)>>2],Ve=b+pt|0,We=m(Le+m(at+ge(r,Rt))),D[Ve>>2]=We}if(u=u+1|0,(z|0)==(u|0))break}h=m(W+re)}if(Z=ti?h:Z,at=xe,!zp){h=Ge(r,J,m(Yi+Z),Pa),u=h!=h,W=m(m(Ie(r,J,k)+ge(r,J))+m(De(r,J,k)+Se(r,J)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}at=m(h-Yi)}h=Ge(r,J,m(Yi+(Yp?xe:Z)),Pa),u=h!=h,W=m(m(Ie(r,J,k)+ge(r,J))+m(De(r,J,k)+Se(r,J)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}if(W=m(h-Yi),!(Xt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=st>>>0)break r;pt=l[u+(st<<2)>>2],u=l[pt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!ir(pt,J)){b=l[ei>>2];break e}if(h=_s(pt,J,xe),Z=ge(r,J),Ft=fe(pt,J,yt),b=l[ei>>2],h=m(Ft+m(h+Z)),D[(pt+(b<<2)|0)+228>>2]=h,h==h)break i}Ve=pt+(b<<2)|0,We=m(ge(r,J)+fe(pt,J,yt)),D[Ve+228>>2]=We;break i}b=u>>>13&7,b||(b=l[r+24>>2]>>>10&7);e:{s:{if((b|0)==5){b=l[r+24>>2]&8?5:1;break s}if((b|0)!=4||(ln(O+24|0,pt,J),b=4,l[O+28>>2]==3)||(on(O+360|0,pt,J),l[O+364>>2]==3))break s;b=pt+(l[Pe>>2]<<3)|0,Z=D[b+572>>2];n:{a:switch(u=l[b+576>>2],u|0){case 0:case 3:break n;default:break a}if(Ft=D[b+572>>2],!((u|0)!=1|Ft!=Ft)){if(h=Ue,Z<m(0))break n;break e}if(h=Ue,os&!(Z<m(0))|((u|0)!=2|Ft!=Ft))break e}Z=D[(pt+(l[xs>>2]<<2)|0)+516>>2],h=W,Ft=D[pt+224>>2],Ft==Ft&&(h=m(m(fe(pt,J,yt)+we(pt,J,yt))+m(Zi?Z*Ft:Z/Ft))),D[O+360>>2]=h,Ve=O,We=m(Z+m(fe(pt,Rt,yt)+we(pt,Rt,yt))),D[Ve+24>>2]=We,l[O+356>>2]=1,l[O+352>>2]=1,xn(pt,Rt,me,yt,O+356|0,O+24|0),xn(pt,J,xe,yt,O+352|0,O+360|0),Z=D[O+360>>2],Ft=D[O+24>>2],u=Rt>>>0>1,h=u?Z:Ft,Z=u?Ft:Z,u=(Wr|0)!=0&(l[r+24>>2]&896)!=512,an(pt,Z,h,Fi,!(u&Zi|Z!=Z),(!u|Zi)&h==h,yt,He,1,2,K,Q,dt,X),h=Ue;break e}h=D[(pt+(l[Pe>>2]<<2)|0)+516>>2],Z=fe(pt,J,yt),Ft=we(pt,J,yt),ln(O+24|0,pt,J),Z=m(at-m(h+m(Z+Ft)));s:{if(l[O+28>>2]!=3||(on(O+360|0,pt,J),l[O+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(Ue+(We=m(0),Fn=ce(h,m(0)),Ve=h!=h,Ve?We:Fn));break e}if(on(O+24|0,pt,J),h=Ue,l[O+28>>2]==3)break e;if(ln(O+24|0,pt,J),l[O+28>>2]==3){h=m(Ue+(We=m(0),Fn=ce(Z,m(0)),Ve=Z!=Z,Ve?We:Fn));break e}s:switch(b-1|0){case 1:h=m(Ue+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(Ue+Z)}u=pt+(l[ei>>2]<<2)|0,D[u+228>>2]=h+m(ls+D[u+228>>2])}if(st=st+1|0,(st|0)==(z|0))break}h=m((zi?Rh:m(0))+W),u=Ms!=Ms,a=m(Oa+a);i:{if(!(u|a!=a)){Ms=ce(Ms,a);break i}Ms=u?a:Ms}if(ls=m(ls+h),u=zi+1|0,st=z,!(Hr>>>0>z>>>0))break}i:{if(!P||!Wr&&!fp(r))break i;re=m(0);e:{s:{if(xe!=xe)break s;a=m(xe-ls);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:Ue=m(Ue+m(a*m(.5)));break s;case 2:if(!(xe>ls))break s;re=m(a/m(u>>>0));break s;case 5:if(xe>ls){if(Ue=m(Ue+m(a/m(u<<1>>>0))),u>>>0<2)break s;re=m(a/m(u>>>0));break e}Ue=m(Ue+m(a*m(.5)));break s;case 4:if(!(xe>ls)|u>>>0<2)break s;re=m(a/m(zi>>>0));break e;case 1:break n;default:break s}Ue=m(Ue+a)}if(!u)break i}for(xt=0,u=0,b=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),z=u,Hr>>>0>u>>>0){e:{for(;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=z>>>0)break r;st=l[b+(z<<2)>>2],pt=l[st+24>>2];s:{if(pt&4194304|(pt&196608)==131072)break s;if(b=z,l[st+548>>2]!=(xt|0))break e;a=D[(st+(l[Pe>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(fe(st,J,yt)+we(st,J,yt))),!(b|a!=a)){h=ce(h,a);break n}h=b?a:h}if(b=pt>>>13&7,b||(b=l[r+24>>2]>>>10&7),!(bt[r+24|0]&8)|(b|0)!=5)break s;a=zo(st),at=fe(st,0,yt),a=m(a+at),at=m(m(D[st+520>>2]+m(fe(st,0,yt)+we(st,0,yt)))-a),b=h!=h,st=W!=W;n:{if(!(st|a!=a)){W=ce(W,a);break n}W=st?a:W}st=Z!=Z;n:{if(!(st|at!=at)){Z=ce(Z,at);break n}Z=st?at:Z}if(a=m(W+Z),!(b|a!=a)){h=ce(h,a);break s}h=b?a:h}if(z=z+1|0,(Hr|0)==(z|0))break}b=Hr}a=h}if(at=m(Ue+(xt?Rh:m(0))),h=m(re+a),Ue=m(at+h),u>>>0<b>>>0)for(Ft=m(at+W);;){if(z=l[r+556>>2],l[r+560>>2]-z>>2>>>0<=u>>>0)break r;st=l[z+(u<<2)>>2],z=l[st+24>>2];e:{if(z&4194304|(z&196608)==131072)break e;z=z>>>13&7,z||(z=l[r+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(bt[r+24|0]&8)break s;case 0:a=fe(st,J,yt),D[(st+(l[ei>>2]<<2)|0)+228>>2]=at+a;break e;case 2:a=we(st,J,yt),z=st+228|0,D[z+(l[ei>>2]<<2)>>2]=m(Ue-a)-D[(z+(l[Pe>>2]<<2)|0)+288>>2];break e;case 1:z=st+228|0,D[z+(l[ei>>2]<<2)>>2]=at+m(m(h-D[(z+(l[Pe>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=fe(st,J,yt),D[(st+(l[ei>>2]<<2)|0)+228>>2]=at+a,pt=st+(l[Pe>>2]<<3)|0,a=D[pt+572>>2];n:{a:switch(z=l[pt+576>>2],z|0){case 0:case 3:break n;default:break a}if(W=D[pt+572>>2],!((z|0)!=1|W!=W)){if(a<m(0))break n;break e}if(os&!(a<m(0))|((z|0)!=2|W!=W))break e}n:{if(Rt>>>0>=2){Z=h,a=D[st+516>>2],W=m(a+m(fe(st,Rt,yt)+we(st,Rt,yt)));break n}Z=m(D[st+520>>2]+m(fe(st,J,yt)+we(st,J,yt))),a=D[st+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Be(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=D[st+520>>2],z=a!=a,!(z|Z!=Z)){if(!(m(Be(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(z)break e}an(st,W,Z,Fi,1,1,yt,He,1,3,K,Q,dt,X);break e}Ve=st,We=m(m(Ft-zo(st))+_s(st,0,xe)),D[Ve+232>>2]=We}if(u=u+1|0,(b|0)==(u|0))break}if(z=(xt|0)!=(zi|0),xt=xt+1|0,u=b,!z)break}}pt=r+516|0,a=Ge(r,2,Sh,k),u=a!=a,h=m(m(Ie(r,2,k)+ge(r,2))+m(De(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}D[pt>>2]=a,a=Ge(r,0,Lh,S),u=a!=a,h=m(m(Ie(r,0,k)+ge(r,0))+m(De(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}D[r+520>>2]=a;i:{e:{s:{if(as&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(as|0)!=2))break s;if(a=Ge(r,Rt,Ms,Ps),u=a!=a,h=m(m(Ie(r,Rt,k)+ge(r,Rt))+m(De(r,Rt,k)+Se(r,Rt))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if((as|0)!=2|(u|0)!=2)break i;h=m(Vr+me),u=h!=h,a=Ge(r,Rt,Ms,Ps);s:{if(!(u|a!=a)){a=yh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Vr!=Vr)){a=ce(a,Vr);break e}a=u?Vr:a}D[pt+(l[xs>>2]<<2)>>2]=a}i:{e:{s:{if(Vt&&(b=(Vt|0)!=2,u=l[r+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Ge(r,J,m(Yi+ls),Pa),u=a!=a,h=m(m(Ie(r,J,k)+ge(r,J))+m(De(r,J,k)+Se(r,J))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break i;h=m(Yi+xe),u=h!=h,a=Ge(r,J,m(Yi+ls),Pa);s:{if(!(u|a!=a)){a=yh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Yi!=Yi)){a=ce(a,Yi);break e}a=u?Yi:a}D[pt+(l[Pe>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(b=Hr>>>0<=1?1:Hr,P=l[r+556>>2],st=l[r+560>>2]-P>>2,u=0;z=0,z=u>>>0<st>>>0?l[P+(u<<2)>>2]:z,(l[z+24>>2]&196608)!=131072&&(z=z+228|0,xt=z+(l[ei>>2]<<2)|0,Xt=l[Pe>>2]<<2,D[xt>>2]=m(D[Xt+pt>>2]-D[xt>>2])-D[(z+Xt|0)+288>>2]),u=u+1|0,(b|0)!=(u|0););if(b=l[r+556>>2],P=l[r+560>>2],(b|0)!=(P|0))for(xt=((Rt>>>0>1?as:y)|0)!=0;;){y=l[b>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=yt,me=He,bt[l[r+568>>2]+12|0]&2&&(me=D[r+520>>2],W=D[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Fi|0)==2){st=0,z=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}z=2;break s}if(st=0,u>>>0<=1)break n;z=u;break s}z=u,st=Is}S=m(fe(y,2,W)+we(y,2,W)),k=fe(y,0,W),Z=we(y,0,W),a=D[y+572>>2];s:{n:{a:switch(u=l[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=D[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(Yt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(Yt),!ir(y,2)||!Xo(y,2))break s;if(a=Ge(y,2,m(m(D[r+516>>2]-m(ge(r,2)+Se(r,2)))-m(_s(y,2,W)+Ia(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+ge(y,2))+m(De(y,2,W)+Se(y,2))),!(u|h!=h)){h=ce(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{Xt=h!=h,k=D[y+580>>2];f:{d:{p:switch(u=l[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=D[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(me!=me|k<m(0))break d;break v}a=m(Yt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(me*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(ir(y,0)&&Xo(y,0))break d;if(a=m(Yt),h==h)break h;break a}if(a=Ge(y,0,m(m(D[r+520>>2]-m(ge(r,0)+Se(r,0)))-m(_s(y,0,me)+Ia(y,0,me))),me),u=a!=a,k=m(m(Ie(y,0,W)+ge(y,0))+m(De(y,0,W)+Se(y,0))),!(u|k!=k)){a=ce(a,k);break f}a=u?k:a}if((Xt|0)==(a!=a|0)||(at=D[y+224>>2],at!=at))break l;if(h!=h){h=m(m(m(a-Z)*at)+S);break l}if(a==a)break l;break c}if(at=D[y+224>>2],at!=at)break o}a=m(Z+m(m(h-S)/at))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Xt=W>m(0),zi=u&xt&z>>>0<2,h=zi&&Xt?W:h,u=u^1,an(y,h,a,Fi,zi&&Xt?2:u,a==a,h,a,0,6,K,Q,dt,X),h=m(D[y+516>>2]+$p(y,2,W)),a=m(D[y+520>>2]+$p(y,0,W))}an(y,h,a,Fi,1,1,h,a,1,1,K,Q,dt,X);s:{n:{a:{if(!Xo(y,z)||ir(y,z))break a;u=l[(z<<2)+4320>>2]<<2,a=z>>>0<2?me:W,a=m(m(m(m(D[u+pt>>2]-D[(u+y|0)+516>>2])-Se(r,z))-we(y,z,a))-Ia(y,z,a));break n}if(!(ir(y,z)|(l[r+24>>2]&112)!=16)){u=l[(z<<2)+4320>>2]<<2,a=m(m(D[u+pt>>2]-D[(u+y|0)+516>>2])*m(.5));break n}if(!(ir(y,z)|(l[r+24>>2]&112)!=32)){u=l[(z<<2)+4320>>2]<<2,a=m(D[u+pt>>2]-D[(u+y|0)+516>>2]);break n}if(!(bt[l[r+568>>2]+12|0]&2)||!ir(y,z))break s;a=D[pt+(l[(z<<2)+4320>>2]<<2)>>2],a=m(m(_s(y,z,a)+ge(r,z))+fe(y,z,a))}D[(y+(l[(z<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!Xo(y,st)||ir(y,st))break n;u=l[(st<<2)+4320>>2]<<2,a=z>>>0<2?W:me,a=m(m(m(m(D[u+pt>>2]-D[(u+y|0)+516>>2])-Se(r,st))-we(y,st,a))-Ia(y,st,a));break s}n:{if(ir(y,st)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(st<<2)+4320>>2]<<2,a=m(m(D[u+pt>>2]-D[(u+y|0)+516>>2])*m(.5));break s}n:{if(ir(y,st))break n;z=l[y+24>>2]>>>13&7,u=l[r+24>>2],z=z||u>>>10&7;a:{if((z|0)==5){if((u&786432)==524288)break a;break n}if(((z|0)==3|0)==((u&786432)==524288|0))break n}u=l[(st<<2)+4320>>2]<<2,a=m(D[u+pt>>2]-D[(u+y|0)+516>>2]);break s}if(!(bt[l[r+568>>2]+12|0]&2)||!ir(y,st))break e;a=D[pt+(l[(st<<2)+4320>>2]<<2)>>2],a=m(m(_s(y,st,a)+ge(r,st))+fe(y,st,a))}D[(y+(l[(st<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((J|Rt)&1))break i;for(b=J&1,P=Rt&1,K=Hr>>>0<=1?1:Hr,Q=(J<<2)+4304|0,dt=(Rt<<2)+4304|0,X=l[r+556>>2],J=l[r+560>>2]-X>>2,r=0;;){if((r|0)==(J|0))break r;u=l[X+(r<<2)>>2];e:{if(bt[u+26|0]&64||(P&&(y=u+228|0,z=l[xs>>2]<<2,D[y+(l[dt>>2]<<2)>>2]=m(D[z+pt>>2]-D[(y+z|0)+288>>2])-D[y+(l[Lr>>2]<<2)>>2]),!b))break e;u=u+228|0,y=l[Pe>>2]<<2,D[u+(l[Q>>2]<<2)>>2]=m(D[y+pt>>2]-D[(u+y|0)+288>>2])-D[u+(l[ei>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Ci)break t;gi(Ci);break t}Ls(),ue()}At=O+384|0}function qf(){var r=0,a=0;Dn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7032,2922,6,4368,4392,19,r|0,1),Dn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ht(4),l[r>>2]=24,wt(7036,2359,2,4400,4408,25,r|0,0),ss(7032,1398,2,4412,4420,26,27),ss(7032,3027,3,4500,4512,28,29),Dn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7056,3293,2,4520,4408,32,r|0,1),Dn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ht(4),l[r>>2]=37,wt(7059,2359,2,4528,4408,38,r|0,0),ss(7056,1398,2,4536,4420,39,40),ss(7056,3027,3,4500,4512,28,41),Dn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),Yf(7062,1,4584,4352,44,45),ss(7062,2915,1,4584,4352,44,45),ss(7062,1129,2,4588,4408,46,47),r=ht(8),l[r+4>>2]=0,l[r>>2]=48,wt(7062,3234,4,4608,4624,49,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=50,wt(7062,1981,3,4632,4644,51,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=52,wt(7062,1952,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=54,wt(7062,3389,3,4672,4664,55,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=56,wt(7062,1800,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=57,wt(7062,3264,3,4684,4512,58,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=59,wt(7062,1926,2,4696,4420,60,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=61,wt(7062,3399,2,4704,4420,62,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=63,wt(7062,1785,2,4696,4420,60,r|0,0),ch(7065,1271,4712,64,4357,65),$n(1732,0),$n(1612,8),$n(2145,16),$n(2455,24),$n(2561,32),$n(1618,40),lh(7065),ch(7035,2898,4712,66,4357,67),Rp(2561,0),Rp(1618,8),lh(7035),ch(7066,2909,4712,68,4357,69),r=ht(4),l[r>>2]=8,a=ht(4),l[a>>2]=8,Ko(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ht(4),l[r>>2]=0,a=ht(4),l[a>>2]=0,Ko(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),lh(7066),Dn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),Yf(7067,1,4724,4352,76,77),ss(7067,1593,1,4724,4352,76,77),ss(7067,2851,2,4728,4420,78,79),ss(7067,1129,2,4736,4408,80,81),r=ht(8),l[r+4>>2]=0,l[r>>2]=82,wt(7067,1753,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=84,wt(7067,3005,3,4744,4664,85,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=86,wt(7067,2930,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=88,wt(7067,2335,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=90,wt(7067,1485,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=91,wt(7067,1356,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=92,wt(7067,1818,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=93,wt(7067,2872,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=94,wt(7067,2379,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=95,wt(7067,2164,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=96,wt(7067,1320,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=97,wt(7067,2413,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=98,wt(7067,1504,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=99,wt(7067,2236,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=100,wt(7067,1220,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=101,wt(7067,1137,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=102,wt(7067,1159,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=104,wt(7067,1846,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=105,wt(7067,1465,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=106,wt(7067,2219,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=107,wt(7067,1196,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=108,wt(7067,2501,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=109,wt(7067,2591,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=110,wt(7067,1540,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=111,wt(7067,2250,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=112,wt(7067,1651,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=113,wt(7067,1428,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=114,wt(7067,2205,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=115,wt(7067,2609,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=116,wt(7067,1556,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=117,wt(7067,1671,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=118,wt(7067,1445,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=119,wt(7067,2567,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=120,wt(7067,1521,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=121,wt(7067,1625,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=122,wt(7067,1408,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=123,wt(7067,2305,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=124,wt(7067,2093,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=125,wt(7067,2719,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=126,wt(7067,1575,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=127,wt(7067,2188,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=128,wt(7067,2946,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=130,wt(7067,2347,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=132,wt(7067,1372,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=133,wt(7067,1832,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=134,wt(7067,2885,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=135,wt(7067,2396,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=136,wt(7067,2176,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=137,wt(7067,1338,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=138,wt(7067,2423,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=139,wt(7067,1859,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=141,wt(7067,1208,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=143,wt(7067,2515,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=144,wt(7067,2600,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=145,wt(7067,1661,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=146,wt(7067,2621,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=147,wt(7067,1684,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=148,wt(7067,2579,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=149,wt(7067,1638,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=150,wt(7067,2320,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=151,wt(7067,2103,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=153,wt(7067,1232,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=154,wt(7067,1148,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=155,wt(7067,2730,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=156,wt(7067,2195,3,4860,4872,157,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=158,wt(7067,3034,4,4880,4624,159,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=160,wt(7067,3055,3,4896,4664,161,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=162,wt(7067,1293,2,4908,4420,163,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=164,wt(7067,1388,2,4916,4420,165,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=166,wt(7067,3046,3,4924,4512,167,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=168,wt(7067,2962,2,4936,4420,169,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=170,wt(7067,2982,3,4944,4664,171,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=172,wt(7067,3357,3,4956,4664,173,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=174,wt(7067,3355,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=175,wt(7067,3374,3,4968,4664,176,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=177,wt(7067,3372,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=178,wt(7067,1119,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=179,wt(7067,1111,2,4980,4420,180,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=181,wt(7067,1244,5,4992,5012,182,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=183,wt(7067,1737,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=184,wt(7067,1715,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=185,wt(7067,2149,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=186,wt(7067,2462,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=187,wt(7067,2633,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=188,wt(7067,1697,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=189,wt(7067,1260,2,5020,4420,190,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=191,wt(7067,2433,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=192,wt(7067,2113,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=193,wt(7067,2741,3,4840,4852,152,r|0,0)}function YA(r,a,h,u,y,b){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,b=b|0;var k=0,S=0,P=0,K=0,Q=0,dt=0,X=0,J=0,O=0,W=0,z=0,Z=0,st=0,at=0,pt=0,yt=0,Rt=0,xt=0,Ft=0;X=At-560|0,At=X,l[X+44>>2]=0,pi(+a),k=Jt(1)|0,Jt(0)|0;t:{if((k|0)<0){st=1,xt=1177,a=-a,pi(+a),k=Jt(1)|0,Jt(0)|0;break t}if(y&2048){st=1,xt=1180;break t}st=y&1,xt=st?1183:1178,Ft=!st}t:{if((k&2146435072)==2146435072){k=st+3|0,mi(r,32,h,k,y&-65537),ci(r,xt,st),u=b&32,ci(r,a!=a?u?2451:3459:u?2868:3463,3),mi(r,32,h,k,y^8192),J=(h|0)<(k|0)?k:h;break t}pt=X+16|0;r:{i:{e:{if(a=mp(a,X+44|0),a=a+a,a!=0){if(k=l[X+44>>2],l[X+44>>2]=k-1,yt=b|32,(yt|0)!=97)break e;break r}if(yt=b|32,(yt|0)==97)break r;Q=l[X+44>>2],dt=(u|0)<0?6:u;break i}Q=k-29|0,l[X+44>>2]=Q,a=a*268435456,dt=(u|0)<0?6:u}for(z=(X+48|0)+((Q|0)>=0?288:0)|0,S=z;a<4294967296&a>=0?u=~~a>>>0:u=0,l[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((Q|0)<=0){u=Q,k=S,P=z;break i}for(P=z,u=Q;;){O=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],Rt=u,u=O&31,(O&63)>>>0>=32?(J=K<<u,u=0):(J=(1<<u)-1&K>>>32-u,u=K<<u),Rt=Rt+u|0,K=J+W|0,u=rp(Rt,u>>>0>Rt>>>0?K+1|0:K,1e9),K=vh(u,Oi,-1e9,0)+Rt|0,l[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,l[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!l[S>>2]););if(u=l[X+44>>2]-O|0,l[X+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(at=((dt+25>>>0)/9|0)+1|0,W=(yt|0)==102;;){u=0-u|0,J=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(O=1e9>>>J|0,K=-1<<J^-1,u=0,S=P;Rt=u,u=l[S>>2],l[S>>2]=Rt+(u>>>J|0),u=Ne(O,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=l[P>>2],!u)break i;l[k>>2]=u,k=k+4|0}if(u=J+l[X+44>>2]|0,l[X+44>>2]=u,P=(!S<<2)+P|0,S=W?z:P,k=k-S>>2>(at|0)?S+(at<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=Ne(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=Ne(S,10),K>>>0>=S>>>0;);}if(S=(dt-((yt|0)!=102?u:0)|0)-((yt|0)==103&(dt|0)!=0)|0,(S|0)<(Ne(k-z>>2,9)-9|0)){if(O=S+9216|0,K=(O|0)/9|0,Q=((((Q|0)<0?4:292)+X|0)+(K<<2)|0)-4048|0,S=10,J=O+Ne(K,-9)|0,(J|0)<=7)for(;S=Ne(S,10),J=J+1|0,(J|0)!=8;);O=l[Q>>2],at=(O>>>0)/(S>>>0)|0,W=Ne(at,S),K=Q+4|0;i:{if((O|0)==(W|0)&(K|0)==(k|0))break i;O=O-W|0;e:{if(!(at&1)&&(a=9007199254740992,!(ft[Q-4|0]&1)|((S|0)!=1e9|P>>>0>=Q>>>0)))break e;a=9007199254740994}if(Z=(k|0)==(K|0)?1:1.5,K=S>>>1|0,Z=K>>>0>O>>>0?.5:(K|0)==(O|0)?Z:1.5,bt[xt|0]!=45|Ft||(Z=-Z,a=-a),l[Q>>2]=W,a+Z==a)break i;if(u=S+W|0,l[Q>>2]=u,u>>>0>=1e9)for(;l[Q>>2]=0,Q=Q-4|0,Q>>>0<P>>>0&&(P=P-4|0,l[P>>2]=0),u=l[Q>>2]+1|0,l[Q>>2]=u,u>>>0>999999999;);if(u=Ne(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=Ne(S,10),K>>>0>=S>>>0;);}S=Q+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,O=k>>>0<=P>>>0,!O&&(k=K-4|0,!l[k>>2]););i:{if((yt|0)!=103){Q=y&8;break i}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,Q=y&8,Q)break i;k=-9;e:{if(O||(Q=l[K-4>>2],!Q)||(J=10,k=0,(Q>>>0)%10|0))break e;for(;S=k,k=k+1|0,J=Ne(J,10),!((Q>>>0)%(J>>>0)|0););k=S^-1}if(S=Ne(K-z>>2,9),(b&-33)==70){Q=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break i}Q=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(J=-1,O=Q|dt,((O?2147483645:2147483646)|0)<(dt|0))break t;W=(((O|0)!=0)+dt|0)+1|0,S=b&-33;i:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break i}if(k=u>>31,k=Pn((k^u)-k|0,0,pt),(pt-k|0)<=1)for(;k=k-1|0,ft[k|0]=48,(pt-k|0)<2;);if(at=k-2|0,ft[at|0]=b,ft[k-1|0]=(u|0)<0?45:43,k=pt-at|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(st^2147483647))break t;W=u+st|0,mi(r,32,h,W,y),ci(r,xt,st),mi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(b=X+16|0,u=b|8,Q=b|9,S=P>>>0>z>>>0?z:P,P=S;;){k=Pn(l[P>>2],0,Q);n:{if((S|0)!=(P|0)){if(X+16>>>0>=k>>>0)break n;for(;k=k-1|0,ft[k|0]=48,X+16>>>0<k>>>0;);break n}if((k|0)!=(Q|0))break n;ft[X+24|0]=48,k=u}if(ci(r,k,Q-k|0),P=P+4|0,!(z>>>0>=P>>>0))break}if(O&&ci(r,4275,1),(dt|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Pn(l[P>>2],0,Q),k>>>0>X+16>>>0)for(;k=k-1|0,ft[k|0]=48,X+16>>>0<k>>>0;);if(ci(r,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(z=P>>>0<K>>>0?K:P+4|0,b=X+16|0,u=b|8,K=b|9,S=P;;){k=Pn(l[S>>2],0,K),(K|0)==(k|0)&&(ft[X+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(X+16>>>0>=k>>>0)break a;for(;k=k-1|0,ft[k|0]=48,X+16>>>0<k>>>0;);break a}if(ci(r,k,1),k=k+1|0,!(Q|dt))break a;ci(r,4275,1)}if(b=K-k|0,ci(r,k,(b|0)>(dt|0)?dt:b),dt=dt-b|0,S=S+4|0,z>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}mi(r,48,dt+18|0,18,0),ci(r,at,pt-at|0);break i}k=dt}mi(r,48,k+9|0,9,0)}mi(r,32,h,W,y^8192),J=(h|0)<(W|0)?W:h;break t}Q=(b<<26>>31&9)+xt|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(bt[Q|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(z=st|2,P=b&32,S=l[X+44>>2],k=S>>31,k=Pn((k^S)-k|0,0,pt),(pt|0)==(k|0)&&(ft[X+15|0]=48,k=X+15|0),dt=k-2|0,ft[dt|0]=b+15,ft[k-1|0]=(S|0)<0?45:43,k=y&8,S=X+16|0;b=S,Be(a)<2147483648?K=~~a:K=-2147483648,ft[S|0]=P|bt[K+5504|0],a=(a-+(K|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(X+16|0)|0)!=1||(ft[b+1|0]=46,S=b+2|0),a!=0;);if(J=-1,k=pt-dt|0,b=k+z|0,(2147483645-b|0)<(u|0))break t;r:{i:{if(!u||(P=S-(X+16|0)|0,(P-2|0)>=(u|0)))break i;u=u+2|0;break r}P=S-(X+16|0)|0,u=P}b=u+b|0,mi(r,32,h,b,y),ci(r,Q,z),mi(r,48,h,b,y^65536),ci(r,X+16|0,P),mi(r,48,u-P|0,0,0),ci(r,dt,k),mi(r,32,h,b,y^8192),J=(h|0)<(b|0)?b:h}return At=X+560|0,J|0}function Qf(r,a,h,u,y,b,k){var S=0,P=0,K=0,Q=0,dt=0,X=0,J=0,O=0,W=0,z=0,Z=0,st=0,at=0,pt=0,yt=0,Rt=0,xt=0,Ft=0,Vt=0,Xt=0;K=At-80|0,At=K,l[K+76>>2]=a,Ft=K+55|0,at=K+56|0;t:{r:{i:{e:{s:for(;;){if(Q=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=Q,P=bt[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(bt[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=bt[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-Q|0,xt=W^2147483647,(S|0)>(xt|0))break e;if(r&&ci(r,Q,S),S)continue s;l[K+76>>2]=a,S=a+1|0,Z=-1,P=ft[a+1|0],!Qo(P)|bt[a+2|0]!=36||(Z=P-48|0,pt=1,S=a+3|0),l[K+76>>2]=S,O=0,P=ft[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,l[K+76>>2]=dt,O=a|O,P=ft[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=ft[dt+1|0];h:{if(!(!Qo(a)|bt[dt+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,pt=1,z=l[((ft[dt+1|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(P=dt+1|0,!r){l[K+76>>2]=P,pt=0,z=0;break c}a=l[h>>2],l[h>>2]=a+4,pt=0,z=l[a>>2]}if(l[K+76>>2]=P,(z|0)>=0)break c;z=0-z|0,O=O|8192;break c}if(z=Ep(K+76|0),(z|0)<0)break e;P=l[K+76>>2]}S=0,J=-1;c:{if(bt[P|0]!=46){a=P,st=0;break c}if(bt[P+1|0]==42){a=ft[P+2|0];h:{if(!(!Qo(a)|bt[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,J=l[((ft[P+2|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(a=P+2|0,J=0,!r)break h;P=l[h>>2],l[h>>2]=P+4,J=l[P>>2]}l[K+76>>2]=a,st=(J^-1)>>>31|0;break c}l[K+76>>2]=P+1,J=Ep(K+76|0),a=l[K+76>>2],st=1}for(;;){if(X=S,dt=28,yt=a,S=ft[a|0],S-123>>>0<4294967238)break i;if(a=yt+1|0,S=bt[(S+Ne(X,58)|0)+4975|0],!(S-1>>>0<8))break}l[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((Z|0)>=0){l[(Z<<2)+y>>2]=S,S=(Z<<3)+u|0,P=l[S+4>>2],l[K+64>>2]=l[S>>2],l[K+68>>2]=P;break h}if(!r)break n;op(K- -64|0,S,h,k);break c}if((Z|0)>=0)break i}if(S=0,!r)continue s}P=O&-65537,O=O&8192?P:O,Z=0,Rt=1167,dt=at;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=ft[yt|0],S=X&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break A;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break E}E:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break E}if((S|0)==83)break v;break a}P=l[K+64>>2],X=l[K+68>>2],S=1167;break g}S=0;A:switch(X&255){case 0:l[l[K+64>>2]>>2]=W;continue s;case 1:l[l[K+64>>2]>>2]=W;continue s;case 2:Q=l[K+64>>2],l[Q>>2]=W,l[Q+4>>2]=W>>31;continue s;case 3:Fr[l[K+64>>2]>>1]=W;continue s;case 4:ft[l[K+64>>2]]=W;continue s;case 6:l[l[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}Q=l[K+64>>2],l[Q>>2]=W,l[Q+4>>2]=W>>31;continue s}J=J>>>0<=8?8:J,O=O|8,S=120}if(Q=at,P=l[K+64>>2],X=l[K+68>>2],P|X)for(Vt=S&32;Q=Q-1|0,ft[Q|0]=Vt|bt[(P&15)+5504|0],Xt=!X&P>>>0>15|(X|0)!=0,yt=X,X=X>>>4|0,P=(yt&15)<<28|P>>>4,!!Xt;);if(!(O&8)|!(l[K+64>>2]|l[K+68>>2]))break u;Rt=(S>>>4|0)+1167|0,Z=2;break u}if(S=at,Q=l[K+68>>2],X=Q,P=l[K+64>>2],Q|P)for(;S=S-1|0,ft[S|0]=P&7|48,yt=!X&P>>>0>7|(X|0)!=0,Q=X,X=Q>>>3|0,P=(Q&7)<<29|P>>>3,!!yt;);if(Q=S,!(O&8))break u;S=at-Q|0,J=(S|0)<(J|0)?J:S+1|0;break u}if(P=l[K+64>>2],S=l[K+68>>2],X=S,(S|0)<0){Q=0-(X+((P|0)!=0)|0)|0,X=Q,P=0-P|0,l[K+64>>2]=P,l[K+68>>2]=Q,Z=1,S=1167;break g}if(O&2048){Z=1,S=1168;break g}Z=O&1,S=Z?1169:1167}Rt=S,Q=Pn(P,X,at)}if((J|0)<0&&st)break e;if(O=st?O&-65537:O,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|J)){Q=at,J=0;break a}S=!(S|P)+(at-Q|0)|0,J=(S|0)<(J|0)?J:S;break a}O=0,st=J>>>0>=2147483647?2147483647:J,X=st,dt=(X|0)!=0;y:{u:{S=l[K+64>>2],Q=S||4277,S=Q;g:{b:{m:{if(!(S&3)|!X)break m;for(;;){if(O=bt[S|0],!O)break b;if(X=X-1|0,dt=(X|0)!=0,S=S+1|0,!(S&3))break m;if(!X)break}}if(!dt)break u;m:{if(!(!bt[S|0]|X>>>0<4))for(;;){if(dt=l[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,X=X-4|0,!(X>>>0>3))break}if(!X)break u}dt=0;break g}dt=1}for(;;){if(!dt){O=bt[S|0],dt=1;continue}if(!O)break y;if(S=S+1|0,X=X-1|0,!X)break u;dt=0}}S=0}if(S=S?S-Q|0:st,dt=S+Q|0,(J|0)>=0){O=P,J=S;break a}if(O=P,J=S,bt[dt|0])break e;break a}if(J){P=l[K+64>>2];break d}S=0,mi(r,32,z,0,O);break f}l[K+12>>2]=0,l[K+8>>2]=l[K+64>>2],P=K+8|0,l[K+64>>2]=P,J=-1}S=0;d:{for(;;){if(Q=l[P>>2],!Q)break d;if(Q=Lp(K+4|0,Q),dt=(Q|0)<0,!(dt|Q>>>0>J-S>>>0)){if(P=P+4|0,S=S+Q|0,J>>>0>S>>>0)continue;break d}break}if(dt)break r}if(dt=61,(S|0)<0)break i;if(mi(r,32,z,S,O),!S){S=0;break f}for(dt=0,P=l[K+64>>2];;){if(Q=l[P>>2],!Q||(Q=Lp(K+4|0,Q),dt=Q+dt|0,dt>>>0>S>>>0))break f;if(ci(r,K+4|0,Q),P=P+4|0,!(S>>>0>dt>>>0))break}}mi(r,32,z,S,O^8192),S=(S|0)<(z|0)?z:S;continue s}if((J|0)<0&&st)break e;if(dt=61,S=Dt[b|0](r,Fe[K+64>>3],z,J,O,S)|0,(S|0)>=0)continue s;break i}ft[K+55|0]=l[K+64>>2],J=1,Q=Ft,O=P;break a}P=bt[S+1|0],S=S+1|0}if(r)break t;if(!pt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(op((S<<3)+u|0,r,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(l[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break i}if(X=dt-Q|0,J=(J|0)>(X|0)?J:X,(J|0)>(Z^2147483647))break e;if(dt=61,P=J+Z|0,S=(P|0)<(z|0)?z:P,(xt|0)<(S|0))break i;mi(r,32,S,P,O),ci(r,Rt,Z),mi(r,48,S,P,O^65536),mi(r,48,J,X,0),ci(r,Q,X),mi(r,32,S,P,O^8192);continue}break}W=0;break t}dt=61}l[1781]=dt}W=-1}return At=K+80|0,W}function ZA(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),b=m(0),k=0,S=m(0),P=0,K=m(0),Q=0,dt=m(0),X=0;X=At+-64|0,At=X,k=l[r>>2],$i(X+8|0,0,56),l[1755]=l[1755]+1,tp(k),S=m(a),b=D[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=D[k+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|b<m(0))break r;break e}y=m(Yt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=b;break i}y=m(m(b*S)*m(.009999999776482582))}dt=m(y+m(fe(k,2,S)+we(k,2,S))),Q=1;break t}y=m(0),b=D[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;Q=4336;n:{if((r|0)!=2141891242){if(b==b)break n;Q=4344}switch(y=D[Q>>2],l[Q+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(b==b)break s;P=4344}switch(y=D[P>>2],dt=m(Yt),Q=2,l[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break r}dt=m(m(y*S)*m(.009999999776482582)),Q=2;break t}Q=S==S,dt=S;break t}Q=2,dt=y}K=m(h),b=D[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=D[k+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=b,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|b<m(0))break r;break e}y=m(Yt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=b;break i}y=m(m(b*K)*m(.009999999776482582))}b=m(y+m(fe(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),b=D[k+220>>2];r:{i:{r=l[k+220>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;P=4336;n:{if((r|0)!=2141891242){if(b==b)break n;P=4344}switch(y=D[P>>2],l[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break e}y=m(m(y*K)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(b==b)break s;P=4344}switch(y=D[P>>2],b=m(Yt),r=2,l[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break r}b=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,b=K;break t}r=2,b=y}an(k,dt,b,u,Q,r,S,K,1,0,l[k+568>>2],X+8|0,0,l[1755])&&(dp(k,bt[k+300|0]&3,S,K,S),lp(k,+D[l[k+568>>2]+20>>2],0,0)),At=X- -64|0}function XA(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,b=0,k=m(0),S=0,P=0,K=0,Q=m(0);t:{P=l[a>>2],a=l[r>>2];r:{if((l[P+24>>2]^l[a+24>>2])&8388607)break r;Q=D[P+40>>2],y=l[P+40>>2],u=D[a+40>>2];i:{e:{if(h=l[a+40>>2],(h|0)!=2139156720){if(k=m(Yt),r=3,(h|0)==2141891242)break i;if((h|0)!=2140081935)break e;k=m(0),r=1;break i}r=2;break i}if(r=0,u!=u)break i;k=(It(2,(h&-1073741825)+536870912|0),Gt()),r=h&1073741824?2:1}i:{e:{if((y|0)!=2139156720){if(u=m(Yt),h=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break e;u=m(0),h=1;break i}u=m(0),h=2;break i}if(h=0,Q!=Q)break i;u=(It(2,(y&-1073741825)+536870912|0),Gt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Be(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,b=P+44|0,l[h>>2]!=l[b>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[b+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,b=P+80|0,l[h>>2]!=l[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[b+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,b=P+116|0,l[h>>2]!=l[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[b+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,b=P+152|0,l[h>>2]!=l[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[b+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,b=P+188|0,l[h>>2]!=l[b>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,l[S+h>>2]!=l[b+S>>2])break}if(y>>>0<2)break r}for(S=P+200|0,K=a+200|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],b=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],b=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],b=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(b|0))continue}break}if((h|0)!=(b|0)||(k=D[P+28>>2],r=k!=k,u=D[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=D[a+32>>2],k=D[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=D[P+36>>2],r=k!=k,u=D[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=D[a+224>>2],u!=u&&(r=1,k=D[P+224>>2],k!=k)||(k=u,u=D[P+224>>2],k==u|u!=u&r))break t}for(Mi(a+24|0,P+24|0,204);;){if(r=bt[a+4|0],r&4)break t;if(ft[a+4|0]=r|4,r=l[a+20>>2],r&&Dt[r|0](a),l[a+308>>2]=2143289344,a=l[a+552>>2],!a)break}}}function qA(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,Q=0,dt=0,X=0,J=0,O=0,W=0,z=0,Z=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,O=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],X=r,k=At-32|0,At=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=l[a+8>>2],a=h;t:{if((y|0)==(r|0)&a>>>0<a>>>0|r>>>0>y>>>0){if(r=h,h=X<<4|r>>>28,a=r<<4|u>>>28,r=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){r=r+1073741824|0,a=a+1|0,r=a?r:r+1|0;break t}if(r=r+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,r=a>>>0<u>>>0?r+1|0:r;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){r=h,h=X<<4|r>>>28,a=r<<4|u>>>28,r=h&524287|2146959360;break t}if(a=0,r=2146435072,S>>>0>1140785151||(r=0,J=S>>>16|0,J>>>0<15249))break t;a=P,r=u,y=X&65535|65536,S=y,dt=h,b=h,K=J-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,b=0):(r=(1<<a)-1&h>>>32-a|r<<a,b=h<<a),y=r,a=0,r=0;break r}if(!K)break r;Q=b,b=K&31,(K&63)>>>0>=32?(h=Q<<b,b=0):(h=(1<<b)-1&Q>>>32-b|y<<b,b=Q<<b),y=h,W=b,Q=a,h=64-K|0,b=h&31,(h&63)>>>0>=32?(h=0,a=r>>>b|0):(h=r>>>b|0,a=((1<<b)-1&r)<<32-b|Q>>>b),b=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=Q<<a,a=0):(h=(1<<a)-1&Q>>>32-a|r<<a,a=Q<<a),r=h}l[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=b,l[k+28>>2]=y,a=15361-J|0;r:{if(a&64){u=dt,a=a+-64|0,r=a&31,(a&63)>>>0>=32?(h=0,P=S>>>r|0):(h=S>>>r|0,P=((1<<r)-1&S)<<32-r|u>>>r),u=h,dt=0,S=0;break r}if(!a)break r;y=dt,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,b=0):(r=(1<<h)-1&y>>>32-h|S<<h,b=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=b|y,u=r|h,y=dt,h=a&31,(a&63)>>>0>=32?(r=0,dt=S>>>h|0):(r=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=dt,l[k+12>>2]=S,a=l[k+8>>2],r=l[k+12>>2]<<4|a>>>28,a=a<<4,h=l[k>>2],S=l[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(l[k+16>>2]|l[k+24>>2]|(l[k+20>>2]|l[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,r=a?r:r+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,r=h>>>0>a>>>0?r+1|0:r}At=k+32|0,It(0,a|0),It(1,X&-2147483648|r),z=O,Z=+Ae(),Fe[z>>3]=Z}function an(r,a,h,u,y,b,k,S,P,K,Q,dt,X,J){var O=m(0),W=0,z=0,Z=0,st=0,at=m(0),pt=0,yt=0,Rt=m(0);t:{if(!(l[r+312>>2]!=(J|0)&&bt[r+4|0]&4)&&(st=0,l[r+316>>2]==(u|0)))break t;l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+320>>2]=0,st=1}pt=X+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(at=fe(r,2,k),Rt=we(r,2,k),O=m(fe(r,0,k)+we(r,0,k)),X=r+524|0,at=m(at+Rt),ip(y,a,b,h,l[r+532>>2],D[X>>2],l[r+536>>2],D[r+528>>2],D[r+540>>2],D[r+544>>2],at,O,Q))break i;if(z=l[r+320>>2],!z)break e;for(W=r+324|0;;){if(X=W+Ne(Z,24)|0,ip(y,a,b,h,l[X+8>>2],D[X>>2],l[X+12>>2],D[X+4>>2],D[X+16>>2],D[X+20>>2],at,O,Q))break i;if(Z=Z+1|0,(z|0)==(Z|0))break}break e}if(!P){if(yt=l[r+320>>2],!yt)break e;for(z=r+324|0;;){W=Ne(Z,24),X=W+z|0,O=D[X>>2];s:{n:{if(!(O!=O|a!=a)){if(m(Be(m(O-a)))<m(9999999747378752e-20))break n;break s}if(O==O|a==a)break s}W=z+W|0,O=D[W+4>>2];n:{if(!(O!=O|h!=h)){if(m(Be(m(O-h)))<m(9999999747378752e-20))break n;break s}if(O==O|h==h)break s}if(l[W+8>>2]!=(y|0))break s;if(l[W+12>>2]==(b|0))break i}if(Z=Z+1|0,(yt|0)==(Z|0))break}break e}X=r+524|0,O=D[X>>2];s:{if(!(O!=O|a!=a)){if(m(Be(m(O-a)))<m(9999999747378752e-20))break s;break e}if(O==O|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(b|0)?X:0,O=D[r+528>>2],X=O!=O,z=h!=h;s:{if(X|z){X=X&z;break s}X=m(Be(m(O-h)))<m(9999999747378752e-20)}X=X?W:0;break i}Xf(r,a,h,u,y,b,k,S,P,Q,dt,pt,J,K),l[r+316>>2]=u;break r}if(!(!X|st)){D[r+516>>2]=D[X+16>>2],D[r+520>>2]=D[X+20>>2],u=(P?12:16)+dt|0,l[u>>2]=l[u>>2]+1;break t}if(Xf(r,a,h,u,y,b,k,S,P,Q,dt,pt,J,K),l[r+316>>2]=u,X)break t}X=l[r+320>>2],u=X+1|0,u>>>0>Vf[dt+8>>2]&&(l[dt+8>>2]=u),(X|0)==8&&(l[r+320>>2]=0,X=0),P?u=r+524|0:(l[r+320>>2]=X+1,u=(Ne(X,24)+r|0)+324|0),l[u+12>>2]=b,l[u+8>>2]=y,D[u+4>>2]=h,D[u>>2]=a,D[u+16>>2]=D[r+516>>2],D[u+20>>2]=D[r+520>>2],X=0}t:{if(!P||(u=l[r+520>>2],l[r+244>>2]=l[r+516>>2],l[r+248>>2]=u,u=bt[r+4|0],y=u|1,ft[r+4|0]=y,!(u&4)))break t;ft[r+4|0]=y&251}return l[r+312>>2]=J,!X|st}function hh(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,Q=0,dt=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=l[1751],b=a,y=l[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=gr(r),k=((r>>>29-u^4)-(u<<2)|0)+110|0,r>>>0<=4095)break i;u=((r>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;i:{if(a|u){h=u-1|0,P=h+1|0,b=h,h=a-1|0,b=(h|0)!=-1?P:b,u=gr(u^b),u=(u|0)==32?gr(a^h)+32|0:u,h=63-u|0,Oi=0-(u>>>0>63)|0;break i}Oi=0,h=64}b=h,h=b&31,(b&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=b+k|0,h=k<<4,a=l[h+5976>>2],b=h+5968|0;i:{if((a|0)!=(b|0)){if(y=fh(a,S,r),y)break t;y=l[a+4>>2],l[y+8>>2]=l[a+8>>2],l[l[a+8>>2]+4>>2]=y,l[a+8>>2]=b,y=h+5972|0,l[a+4>>2]=l[y>>2],l[y>>2]=a,l[l[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=l[1751],b=k&63,a=b,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=b&31,b>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),Q=h,y=a,b=0-k&63,h=b,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=b&31,b>>>0>=32?(b=0,a=a>>>h|0):(b=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|Q,Oi=y|b,l[1750]=l[1750]&a,l[1751]=Oi&K,a=P^1}if(!(a|u))break}b=l[1751],y=l[1750]}i:{if(y|b){u=gr(b),h=63-((u|0)==32?gr(y)+32|0:u)|0,a=h<<4,u=l[a+5976>>2];e:{if(!b&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=fh(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(uh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=fh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!uh(r+48|0))break r}if(y=0,S-1&S)break t;if(!(r>>>0<=4294967239))break}break t}y=0}return y|0}function QA(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0,Q=0,dt=0,X=0;S=At-80|0,At=S,r=l[r>>2];t:{r:{if(P=l[a>>2],!l[P+552>>2]){if(l[r+8>>2])break r;a=l[r+556>>2],k=a+(h<<2)|0,u=l[r+560>>2],y=r+564|0,b=l[y>>2];i:{if(u>>>0<b>>>0){if((u|0)==(k|0)){l[k>>2]=P,l[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;l[h>>2]=l[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);l[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Rs(u-(a&-4)|0,k,a)),l[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=b-a|0,b=a>>1,y=Da(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<b>>>0?b:u,h,y),h=l[y+8>>2];e:{if((h|0)!=l[y+12>>2])break e;if(a=l[y+4>>2],u=l[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,b=a,a=h-a|0,h=Rs(K,b,a)+a|0,l[y+8>>2]=h,l[y+4>>2]=u+l[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,b=Da(S+56|0,a,a>>>2|0,l[y+16>>2]),u=l[b+8>>2],a=l[y+4>>2],h=l[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=l[y+8>>2],u=l[y+4>>2]}if(K=l[y>>2],l[y>>2]=l[b>>2],l[b>>2]=K,l[y+4>>2]=l[b+4>>2],l[b+4>>2]=u,l[y+8>>2]=h,l[b+8>>2]=a,Q=l[y+12>>2],l[y+12>>2]=l[b+12>>2],l[b+12>>2]=Q,(a|0)!=(u|0)&&(l[b+8>>2]=((u-a|0)+3&-4)+a),!K)break e;gi(K),h=l[y+8>>2]}if(l[h>>2]=P,l[y+8>>2]=l[y+8>>2]+4,a=l[r+556>>2],h=k-a|0,dt=y,X=Rs(l[y+4>>2]-h|0,a,h),l[dt+4>>2]=X,u=l[r+560>>2]-k|0,k=Rs(l[y+8>>2],k,u),a=l[r+556>>2],l[r+556>>2]=l[y+4>>2],l[y+4>>2]=a,h=l[r+560>>2],l[r+560>>2]=u+k,l[y+8>>2]=h,u=l[r+564>>2],l[r+564>>2]=l[y+12>>2],l[y>>2]=a,l[y+12>>2]=u,(a|0)!=(h|0)&&(l[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;gi(a)}for(l[P+552>>2]=r;a=bt[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););At=S+80|0;return}l[S+16>>2]=4075,er(r,S+16|0),ji(),ue()}l[S>>2]=4208,er(r,S),ji(),ue()}Ls(),ue()}function Jf(r,a){var h=0,u=0;for(l[r>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r+24>>2]=0,l[r+36>>2]=2143289344,l[r+40>>2]=2141891242,l[r+28>>2]=2143289344,l[r+32>>2]=2143289344,ft[r+4|0]=bt[r+4|0]&128,u=$i(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=$i(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=$i(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=$i(r+152|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,l[r+196>>2]=0,u=r+188|0,l[u>>2]=0,l[u+4>>2]=0;l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(l[r+24>>2]=4224,l[r+224>>2]=2143289344,l[r+216>>2]=2143289344,l[r+220>>2]=2143289344,l[r+208>>2]=2143289344,l[r+212>>2]=2143289344,l[r+200>>2]=2141891242,l[r+204>>2]=2141891242,$i(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,$i(r+252|0,0,49),l[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return l[r+548>>2]=0,l[r+552>>2]=0,l[r+516>>2]=2143289344,l[r+520>>2]=2143289344,l[r+572>>2]=2143289344,l[r+576>>2]=0,l[r+568>>2]=a,l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+556>>2]=0,l[r+560>>2]=0,l[r+564>>2]=0,l[r+580>>2]=2143289344,l[r+584>>2]=0,xp((a|0)!=0,2760),ft[r+4|0]=bt[r+4|0]|1,ft[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function Ge(r,a,h,u){var y=m(0),b=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){b=D[r+212>>2],a=l[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(b==b)break o;k=4344}switch(y=D[k>>2],b=m(Yt),l[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break n}b=m(m(y*u)*m(.009999999776482582));break s}b=D[r+208>>2];a:{o:{a=l[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(b==b)break c;k=4344}switch(y=D[k>>2],b=m(Yt),l[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break o}b=m(m(y*u)*m(.009999999776482582));break a}b=y}y=m(0),S=D[r+216>>2],r=l[r+216>>2];a:{if((r|0)==2139156720)break a;if((r|0)==2140081935)break i;a=4336;o:{if((r|0)!=2141891242){if(S==S)break o;a=4344}switch(y=D[a>>2],l[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}b=y}y=m(0),S=D[r+220>>2],r=l[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;a=4336;n:{if((r|0)!=2141891242){if(S==S)break n;a=4344}switch(y=D[a>>2],l[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break r}if(h>y)break t}if(!(b>=m(0)))return h;y=h<b?b:h}return y}function tp(r){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,K=0,Q=0,dt=0,X=0,J=0,O=0;for(k=At-16|0,l[k+8>>2]=0,l[k+12>>2]=1,Q=r+200|0,dt=r+572|0,X=r+208|0,J=r+216|0,r=0;;){O=r,K=l[(k+8|0)+(r<<2)>>2],S=K<<2,r=J+S|0,u=D[r>>2];t:{r:{i:{e:{s:{n:{if(a=l[r>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;r=S+X|0,y=D[r>>2],h=l[r>>2];a:{o:{if((h|0)!=2139156720){if(b=m(Yt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;b=m(0),r=1;break a}b=m(0),r=2;break a}if(r=0,y!=y)break a;b=(It(2,(h&-1073741825)+536870912|0),Gt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(Yt),r=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),r=1;break a}y=m(0),r=2;break a}if(r=0,u!=u)break a;y=(It(2,(a&-1073741825)+536870912|0),Gt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&b!=b|m(Be(m(y-b)))<m(9999999747378752e-20)))break n;if(r=0,P)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(r=0,a=S+Q|0,u=D[a>>2],a=l[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}r=2143289344,a=0;break t}r=2143289344,a=3;break t}a=1}if(h=(K<<3)+dt|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(O&1))break}}function Mi(r,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return HA(r|0,a|0,h|0),r;y=r+h|0;t:{if(!((r^a)&3)){r:{if(!(r&3)){h=r;break r}if(!h){h=r;break r}for(h=r;;){if(ft[h|0]=bt[a|0],a=a+1|0,h=h+1|0,!(h&3))break r;if(!(h>>>0<y>>>0))break}}u=y&-4;r:{if(u>>>0<64||(b=u+-64|0,b>>>0<h>>>0))break r;for(;l[h>>2]=l[a>>2],l[h+4>>2]=l[a+4>>2],l[h+8>>2]=l[a+8>>2],l[h+12>>2]=l[a+12>>2],l[h+16>>2]=l[a+16>>2],l[h+20>>2]=l[a+20>>2],l[h+24>>2]=l[a+24>>2],l[h+28>>2]=l[a+28>>2],l[h+32>>2]=l[a+32>>2],l[h+36>>2]=l[a+36>>2],l[h+40>>2]=l[a+40>>2],l[h+44>>2]=l[a+44>>2],l[h+48>>2]=l[a+48>>2],l[h+52>>2]=l[a+52>>2],l[h+56>>2]=l[a+56>>2],l[h+60>>2]=l[a+60>>2],a=a- -64|0,h=h- -64|0,b>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;l[h>>2]=l[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=r;break t}if(u=y-4|0,u>>>0<r>>>0){h=r;break t}for(h=r;ft[h|0]=bt[a|0],ft[h+1|0]=bt[a+1|0],ft[h+2|0]=bt[a+2|0],ft[h+3|0]=bt[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;ft[h|0]=bt[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function ep(r,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),K=0,Q=0,dt=m(0),X=m(0),J=0;if(S=m(h-u),Q=S!=S,!Q){h=m(0),k=(a<<2)+r|0,b=D[k+208>>2];t:{r:{k=l[k+208>>2];i:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break r;K=4336;s:{if((k|0)!=2141891242){if(b==b)break s;K=4344}switch(h=D[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(It(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;break t}P=m(h-u)}h=m(0),r=(a<<2)+r|0,b=D[r+216>>2];t:{r:{a=l[r+216>>2];i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break r;r=4336;s:{if((a|0)!=2141891242){if(b==b)break s;r=4344}switch(h=D[r>>2],b=m(34028234663852886e22),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(dt=S,X=yh(S,b),J=b!=b|Q,J?dt:X),r=h!=h,!(r|P!=P))return ce(h,P);S=r?P:h}return S}function ip(r,a,h,u,y,b,k,S,P,K,Q,dt,X){var J=m(0),O=m(0),W=0,z=0,Z=m(0),st=m(0),at=m(0),pt=0,yt=0;if(P<m(0)|K<m(0))r=0;else{Z=b,st=a,at=u,O=S;t:{if(!X||(J=D[X+20>>2],O=S,J==m(0)))break t;pt=+J,st=Br(+a,pt,0,0),at=Br(+u,pt,0,0),Z=Br(+b,pt,0,0),O=Br(+S,pt,0,0)}J=O,X=0;t:{if((r|0)!=(y|0))break t;if(yt=Z!=Z,X=st!=st,yt|X){X=X&yt;break t}X=m(Be(m(Z-st)))<m(9999999747378752e-20)}yt=X;t:{if((h|0)!=(k|0))break t;if(W=J!=J,X=at!=at,W|X){W=X&W;break t}W=m(Be(m(J-at)))<m(9999999747378752e-20)}z=1,X=1;t:{if(yt)break t;a=m(a-Q);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(a>=P))break r;break t}if(X=0,!(a<b)|(r|(y|0)!=2|(a!=a|b!=b|P!=P))||(X=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){X=r&y;break t}X=m(Be(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(z=0,!(a<S)|(r|(k|0)!=2|(a!=a|S!=S|K!=K))||(z=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){z=r&h;break t}z=m(Be(m(a-K)))<m(9999999747378752e-20)}r=X&z}return r}function dh(r){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(pi(+r),b=Jt(1)|0,u=Jt(0)|0,y=b>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=b<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?r*0:r;t:{if(!y){if(y=0,h=u<<12,a=b<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|b<<h,u=u<<h);break t}a=b&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=b&-2147483648,k=a+-1048576|y<<20,S=h,b=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=b>>>h|0):(a=b>>>h|0,u=((1<<h)-1&b)<<32-h|S>>>h),h=(y|0)>0,It(0,(h?S:u)|0),It(1,(h?k:a)|P),+Ae()}function uh(r){var a=0,h=0,u=0,y=0,b=0;u=l[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>Kp()<<16>>>0&&!(GA(h|0)|0))break r;l[1416]=h;break t}l[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,l[h+12>>2]=16,l[h>>2]=16,r=l[1748],r?b=l[r+8>>2]:b=0;t:{r:{if((b|0)==(u|0)){if(y=u-(l[u-4>>2]&-2)|0,b=l[y-4>>2],l[r+8>>2]=a,r=y-(b&-2)|0,a=-16,!(ft[(r+l[r>>2]|0)-4|0]&1))break r;a=l[r+4>>2],l[a+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=a,h=h-r|0,l[r>>2]=h;break t}l[u+12>>2]=16,l[u>>2]=16,l[u+8>>2]=a,l[u+4>>2]=r,l[1748]=u,a=16}r=a+u|0,h=h-r|0,l[r>>2]=h}l[((h&-4)+r|0)-4>>2]=h|1,a=l[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=gr(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,l[r+4>>2]=a+5968,a=a+5976|0,l[r+8>>2]=l[a>>2],l[a>>2]=r,l[l[r+8>>2]+4>>2]=r,a=l[1750],y=l[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,b=0):(b=1<<r,h=b-1&1>>>32-r),l[1750]=b|a,l[1751]=h|y}return(u|0)!=-1}function rp(r,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,K=0,Q=0,dt=0;t:{r:{i:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}r=(r>>>0)/(h>>>0)|0,Oi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;b=(gr(h)+33|0)-gr(a)|0,k=0-b|0;break e}r=(a>>>0)/0|0,Oi=0;break t}if(u=32-gr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;b=h?31-gr(h-1^h)|0:32,h=b&31,(b&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Oi=u;break t}b=u+1|0,k=63-u|0}if(u=b&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|r>>>y),k=k&63,y=k&31,k>>>0>=32?(a=r<<y,r=0):(a=(1<<y)-1&r>>>32-y|a<<y,r=r<<y),b)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,K=h&y,S=u-K|0,u=P-(u>>>0<K>>>0)|0,a=a<<1|r>>>31,r=Q|r<<1,Q=y&1,b=b-1|0,!!b;);Oi=a<<1|r>>>31,r=Q|r<<1;break t}r=0,a=0}Oi=a}return r}function jo(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=l[r+188>>2],u=D[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+196>>2],u=D[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break i;break r}if(a=l[r+192>>2],u=D[r+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=D[r+196>>2],a=l[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break i;if(u!=u)break r}u=m(0);i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(It(2,a),Gt()),u==u)break s;r=4344}switch(u=D[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function sp(r,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=At-320|0,At=h,u=$i(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,$i(h+24|0,0,49),l[h+80>>2]=2143289344,b=h+288|0,y=h+96|0;h=y,l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,y=h+24|0,(b|0)!=(y|0););if(l[u+312>>2]=-1082130432,l[u+316>>2]=-1082130432,l[u+304>>2]=0,l[u+308>>2]=0,l[u+296>>2]=-1082130432,l[u+300>>2]=-1082130432,l[u+288>>2]=2143289344,l[u+292>>2]=2143289344,Mi(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,ft[r+4|0]=bt[r+4|0]|1,y=l[r+556>>2],k=l[r+560>>2],(y|0)!=(k|0))for(;h=l[y>>2],l[h+552>>2]!=(r|0)&&(b=l[r+568>>2],h=hp(l[b>>2],bt[b+8|0],h,r,S,a),l[y>>2]=h,l[h+552>>2]=r,h=l[y>>2]),sp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););At=u+320|0}function fh(r,a,h){var u=0,y=0,b=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=l[r>>2],y+h>>>0<=(a+r|0)-4>>>0){b=l[r+4>>2],l[b+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=b,(u|0)!=(y|0)&&(y=y-u|0,b=r-(l[r-4>>2]&-2)|0,u=y+l[b>>2]|0,l[b>>2]=u,l[(b+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,l[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,l[u>>2]=a,l[(u+(a&-4)|0)-4>>2]=a|1,y=l[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(b=gr(y),a=((y>>>29-b^4)-(b<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-b^2)-(b<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,l[u+4>>2]=y+5968,y=y+5976|0,l[u+8>>2]=l[y>>2],l[y>>2]=u,l[l[u+8>>2]+4>>2]=u,y=l[1750],b=l[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),l[1750]=u|y,l[1751]=a|b,a=h+8|0,l[r>>2]=a,l[((a&-4)+r|0)-4>>2]=a;break t}l[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function JA(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0;y=At-320|0,At=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!gp(r,u)))break t;if((r|0)==(a|0)){for(h=$i(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,$i(a+24|0,0,49),l[a+80>>2]=2143289344,b=a+288|0,a=a+96|0;l[a+16>>2]=-1082130432,l[a+20>>2]=-1082130432,l[a+8>>2]=0,l[a+12>>2]=0,l[a>>2]=-1082130432,l[a+4>>2]=-1082130432,a=a+24|0,(b|0)!=(a|0););l[h+312>>2]=-1082130432,l[h+316>>2]=-1082130432,l[h+304>>2]=0,l[h+308>>2]=0,l[h+296>>2]=-1082130432,l[h+300>>2]=-1082130432,l[h+288>>2]=2143289344,l[h+292>>2]=2143289344,Mi(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}At=y+320|0}function np(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(r){if(k=At-32|0,At=k,a=l[r>>2],u=l[a+552>>2],u&&(gp(u,a),l[a+552>>2]=0),u=l[a+556>>2],h=l[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;l[l[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););l[a+560>>2]=u,h=a+564|0;t:{if(l[h>>2]==(u|0)||(h=Da(k+8|0,0,0,h),y=l[a+556>>2],b=l[a+560>>2]-y|0,u=l[h+4>>2]-b|0,b=Rs(u,y,b),y=l[a+556>>2],l[a+556>>2]=b,l[h+4>>2]=y,b=l[a+560>>2],l[a+560>>2]=l[h+8>>2],l[h+8>>2]=b,S=l[a+564>>2],l[a+564>>2]=l[h+12>>2],l[h>>2]=y,l[h+12>>2]=S,(y|0)!=(b|0)&&(l[h+8>>2]=b+((y-b|0)+3&-4)),!y))break t;gi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,gi(u)),gi(a),a=l[r+8>>2],l[r+8>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a),a=l[r+4>>2],l[r+4>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a),At=k+32|0,gi(r)}}function tE(r){r=r|0;var a=0,h=0,u=0;u=At-624|0,At=u,a=l[r+4>>2],l[r+4>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a),a=l[r+8>>2],l[r+8>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a);t:{if(r=l[r>>2],l[r+560>>2]==l[r+556>>2]){if(l[r+552>>2])break t;a=Jf(u+32|0,l[r+568>>2]),h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h,h=l[a+20>>2],l[r+16>>2]=l[a+16>>2],l[r+20>>2]=h,h=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=h,Mi(r+24|0,a+24|0,204),Mi(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,gi(h)),l[r+556>>2]=l[a+556>>2],l[r+560>>2]=l[a+560>>2],l[r+564>>2]=l[a+564>>2],l[r+584>>2]=l[a+584>>2],h=l[a+580>>2],l[r+576>>2]=l[a+576>>2],l[r+580>>2]=h,h=l[a+572>>2],l[r+568>>2]=l[a+568>>2],l[r+572>>2]=h,At=u+624|0;return}l[u+16>>2]=3301,er(r,u+16|0),ji(),ue()}l[u>>2]=2047,er(r,u),ji(),ue()}function ap(){zA(7084,3067),jA(7085,2480,1,1,0),ns(7086,2140,1,-128,127),ns(7087,2133,1,-128,127),ns(7088,2131,1,0,255),ns(7089,1287,2,-32768,32767),ns(7090,1278,2,0,65535),ns(7091,1316,4,-2147483648,2147483647),ns(7092,1307,4,0,-1),ns(7093,2659,4,-2147483648,2147483647),ns(7094,2650,4,0,-1),Fp(7095,1777,-2147483648,2147483647),Fp(7096,1776,0,-1),jf(7097,1770,4),jf(7098,3015,8),zf(7099,2677),zf(7100,3904),oh(7101,4,2664),oh(7102,2,2689),oh(7103,4,2704),KA(7104,2485),Ei(7105,0,3835),Ei(7106,0,3937),Ei(7107,1,3865),Ei(7108,2,3467),Ei(7109,3,3498),Ei(7110,4,3538),Ei(7111,5,3567),Ei(7112,4,3974),Ei(7113,5,4004),Ei(7106,0,3669),Ei(7107,1,3636),Ei(7108,2,3735),Ei(7109,3,3701),Ei(7110,4,3802),Ei(7111,5,3768),Ei(7114,6,3605),Ei(7115,7,4043)}function Rs(r,a,h){var u=0,y=0;t:{if((r|0)==(a|0))break t;if(y=r+h|0,a-y>>>0<=0-(h<<1)>>>0)return Mi(r,a,h);u=(r^a)&3;r:{i:{if(r>>>0<a>>>0){if(u){u=r;break r}if(!(r&3)){u=r;break i}for(u=r;;){if(!h)break t;if(ft[u|0]=bt[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break i}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+r|0,ft[u|0]=bt[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,l[h+r>>2]=l[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,ft[h+r|0]=bt[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;ft[u|0]=bt[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function op(r,a,h,u){t:switch(a-9|0){case 0:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2];return;case 6:a=l[h>>2],l[h>>2]=a+4,a=Fr[a>>1],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 7:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=In[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=ft[a|0],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 9:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=bt[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Fe[r>>3]=Fe[a>>3];return;case 17:Dt[u|0](r,h);default:return;case 1:case 4:case 14:a=l[h>>2],l[h>>2]=a+4,a=l[a>>2],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2],l[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=l[h>>2]+7&-8,l[h>>2]=a+8,h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h}function lp(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0,Q=0,dt=0,X=0,J=m(0),O=m(0),W=m(0),z=0,Z=m(0);t:{if(a==0||(J=D[r+248>>2],O=D[r+244>>2],W=D[r+232>>2],P=+D[r+228>>2],y=bt[r+4|0]&8,b=y>>>3|0,z=r,Z=Br(P,a,0,b),D[z+228>>2]=Z,K=+W,z=r,Z=Br(K,a,0,b),D[z+232>>2]=Z,Q=+O,k=dh(Q*a),b=k==k&Be(k)<1e-4,S=!(b|k!=k?b:Be(k+-1)<1e-4),dt=+J,k=dh(dt*a),b=k==k&Be(k)<1e-4,X=!(b|k!=k?b:Be(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,z=r,Z=m(Br(h+Q,a,y&S,y&!S)-Br(h,a,0,y)),D[z+244>>2]=Z,u=K+u,z=r,Z=m(Br(u+dt,a,y&X,y&!X)-Br(u,a,0,y)),D[z+248>>2]=Z,y=l[r+560>>2],S=l[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=l[r+556>>2],l[r+560>>2]-y>>2>>>0>b>>>0?y=l[y+(b<<2)>>2]:y=0,lp(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function $i(r,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(ft[r|0]=a,u=r+h|0,ft[u-1|0]=a,h>>>0<3)||(ft[r+2|0]=a,ft[r+1|0]=a,ft[u-3|0]=a,ft[u-2|0]=a,h>>>0<7)||(ft[r+3|0]=a,ft[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=Ne(a&255,16843009),l[y>>2]=a,u=h-u&-4,h=u+y|0,l[h-4>>2]=a,u>>>0<9)||(l[y+8>>2]=a,l[y+4>>2]=a,l[h-8>>2]=a,l[h-12>>2]=a,u>>>0<25)||(l[y+24>>2]=a,l[y+20>>2]=a,l[y+16>>2]=a,l[y+12>>2]=a,l[h-16>>2]=a,l[h-20>>2]=a,l[h-24>>2]=a,l[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=vh(a,0,1,1),b=Oi,a=y+k|0;l[a+24>>2]=u,l[a+28>>2]=b,l[a+16>>2]=u,l[a+20>>2]=b,l[a+8>>2]=u,l[a+12>>2]=b,l[a>>2]=u,l[a+4>>2]=b,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function gi(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;if(r){a=r-4|0,y=l[a>>2],h=y,u=a,b=l[r-8>>2],r=b&-2,(r|0)!=(b|0)&&(u=a-r|0,h=l[u+4>>2],l[h+8>>2]=l[u+8>>2],l[l[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=l[r>>2],(a|0)!=l[(r+a|0)-4>>2]&&(y=l[r+4>>2],l[y+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=y,h=a+h|0),l[u>>2]=h,l[((h&-4)+u|0)-4>>2]=h|1,a=l[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=gr(a),r=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;r=((a>>>30-h^2)-(h<<1)|0)+71|0,r=r>>>0>=63?63:r}a=r<<4,l[u+4>>2]=a+5968,a=a+5976|0,l[u+8>>2]=l[a>>2],l[a>>2]=u,l[l[u+8>>2]+4>>2]=u,a=l[1750],h=l[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),l[1750]=y|a,l[1751]=r|h}}function eE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0,P=0,K=0;u=At-32|0,At=u,y=l[r+28>>2],l[u+16>>2]=y,b=l[r+20>>2],l[u+28>>2]=h,l[u+24>>2]=a,a=b-y|0,l[u+20>>2]=a,b=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!Mp(VA(l[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=l[u+12>>2],(k|0)==(b|0))break e;if((k|0)>=0)break i;break r}if((b|0)!=-1)break r}a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],r=h;break t}S=l[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,l[y>>2]=S+l[y>>2],a=(K?12:4)+a|0,l[a>>2]=l[a>>2]-S,b=b-k|0,P=P-K|0,a=y;continue}break}if(l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r>>2]=l[r>>2]|32,r=0,(P|0)==2)break t;r=h-l[a+4>>2]|0}return At=u+32|0,r|0}function iE(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;h=At-96|0,At=h,l[h>>2]=r,u=At-16|0,At=u,l[u+12>>2]=h,r=At-144|0,At=r,r=Mi(r,5520,144),b=h+16|0,a=b,l[r+44>>2]=a,l[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,l[r+48>>2]=y,a=a+y|0,l[r+28>>2]=a,l[r+16>>2]=a,cp(r,2202,h,0,0),y&&(a=l[r+20>>2],ft[a-((a|0)==l[r+16>>2])|0]=0),At=r+144|0,At=u+16|0,r=b;t:{if(r&3)for(;;){if(!bt[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=l[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!bt[r|0];);}return r=(r-b|0)+1|0,a=hh(r),a?r=Mi(a,b,r):r=0,At=h+96|0,r|0}function cp(r,a,h,u,y){var b=0,k=0,S=0,P=0;b=At-208|0,At=b,l[b+204>>2]=h,h=b+160|0,$i(h,0,40),l[b+200>>2]=l[b+204>>2];t:{if((Qf(0,a,b+200|0,b+80|0,h,u,y)|0)<0){y=-1;break t}P=l[r+76>>2]>=0,k=l[r>>2],l[r+72>>2]<=0&&(l[r>>2]=k&-33);r:{i:{e:{if(!l[r+48>>2]){l[r+48>>2]=80,l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,S=l[r+44>>2],l[r+44>>2]=b;break e}if(l[r+16>>2])break i}if(h=-1,Tp(r))break r}h=Qf(r,a,b+200|0,b+80|0,b+160|0,u,y)}if(S&&(Dt[l[r+36>>2]](r,0,0)|0,l[r+48>>2]=0,l[r+44>>2]=S,l[r+28>>2]=0,a=l[r+20>>2],l[r+16>>2]=0,l[r+20>>2]=0,h=a?h:-1),a=r,r=l[r>>2],l[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return At=b+208|0,y}function zo(r){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),K=0;b=At-16|0,At=b,a=l[r+12>>2];t:{if(a){P=D[r+520>>2],h=D[r+516>>2];r:{if(bt[r+4|0]&32){h=m(Dt[a|0](r,h,P,0));break r}h=m(Dt[a|0](r,h,P))}if(h==h)break t;l[b>>2]=3409,er(r,b),ji(),ue()}r:{i:{if(k=l[r+556>>2],a=l[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=l[(S<<2)+k>>2],!l[y+548>>2]){if(a=l[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=l[r+24>>2]>>>10&7),bt[y+4|0]&2|(bt[r+24|0]&8?(a|0)==5:0))break i;u=u||y}if(S=S+1|0,(K|0)!=(S|0))continue}break}if(u)break r}h=D[r+520>>2];break t}u=y}h=m(zo(u)+D[u+232>>2])}return At=b+16|0,h}function xn(r,a,h,u,y,b){var k=0,S=m(0),P=0,K=m(0);k=(l[(a<<2)+4320>>2]<<2)+r|0,S=D[k+216>>2];t:{r:{k=l[k+216>>2];i:{if((k|0)==2139156720)break i;if((k|0)==2140081935)break r;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(K=D[P>>2],S=m(Yt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(It(2,(k&-1073741825)+536870912|0),Gt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(fe(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=D[b>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;l[y>>2]=2}D[b>>2]=u}}function Ie(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=l[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Nr(r,4,b,2140081935);break t}a=Ur(r,b,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(It(2,a),Gt()),u==u)break s;r=4344}switch(u=D[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function De(r,a,h){var u=m(0),y=m(0),b=0,k=m(0);r=r+116|0,b=l[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Nr(r,5,b,2140081935);break t}a=Ur(r,b,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(It(2,a),Gt()),u==u)break s;r=4344}switch(u=D[r>>2],y=m(Yt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function hp(r,a,h,u,y,b){var k=0;t:{r:{if(r){i:{if(a&4){b=Dt[r|0](h,u,y,b)|0;break i}b=Dt[r|0](h,u,y)|0}if(b)break r}if(b=ht(588),a=Mi(b,h,552),l[a+564>>2]=0,l[a+556>>2]=0,l[a+560>>2]=0,y=l[h+556>>2],u=l[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ht(k),l[a+556>>2]=r,l[a+564>>2]=r+k;l[r>>2]=l[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););l[a+560>>2]=r}r=l[h+572>>2],l[a+568>>2]=l[h+568>>2],l[a+572>>2]=r,l[a+584>>2]=l[h+584>>2],r=l[h+580>>2],l[a+576>>2]=l[h+576>>2],l[a+580>>2]=r,l[a+552>>2]=0}return b}Ls(),ue()}function er(r,a){var h=0,u=0,y=0;y=At-16|0,At=y,l[y+12>>2]=a;t:{r:{if(!r){a=l[y+12>>2];break r}if(a=l[y+12>>2],h=l[r+568>>2],!h)break r;if(u=l[h+4>>2],bt[h+8|0]&8){Dt[u|0](h,r,5,0,4284,a)|0;break t}Dt[u|0](h,r,5,4284,a)|0;break t}r:{if(!bt[7016]){h=ht(28),l[h+20>>2]=1065353216,l[h+24>>2]=0,l[h+12>>2]=0,l[h+16>>2]=0,l[h>>2]=0,ft[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,ft[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(bt[h+8|0]&8))break r;Dt[u|0](h,r,5,0,4284,a)|0;break t}Dt[u|0](h,r,5,4284,a)|0}At=y+16|0}function Ia(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=l[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Nr(r,5,y,2140081935);break r}a=Ur(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(It(2,a),Gt()),u==u)break e;r=4344}switch(u=D[r>>2],b=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function _s(r,a,h){var u=m(0),y=0,b=m(0);r=r+80|0,y=l[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Nr(r,4,y,2140081935);break r}a=Ur(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(It(2,a),Gt()),u==u)break e;r=4344}switch(u=D[r>>2],b=m(Yt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(It(2,(a&-1073741825)+536870912|0),Gt()),!(a&1073741824))break t}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Nr(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=D[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+r|0,y=D[a>>2],a=l[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=l[r+24>>2],y=D[r+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=D[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function rE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=At-16|0,At=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=At-16|0,At=u,l[u+12>>2]=h;t:{if(r)break t;if(bt[7016]){r=l[1753];break t}r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,ft[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(bt[r+8|0]&8){Dt[y|0](r,0,5,0,4284,h)|0;break t}Dt[y|0](r,0,5,4284,h)|0}At=u+16|0,ji(),ue()}D[r+20>>2]=a==m(0)?m(0):a,At=h+16|0}function dp(r,a,h,u,y){var b=0,k=0,S=m(0),P=0;b=2,k=l[r+24>>2]>>>2&3;t:{r:{i:{if(!(!l[r+552>>2]|(a|0)!=2)){a=0,b=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}b=2;break t}if(a=0,k>>>0>1)break r}a=b}b=k}h=Dp(r,b,h),u=Dp(r,a,u),S=fe(r,b,y),k=r+228|0,P=b<<2,D[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,b,y),D[k+(l[P+4304>>2]<<2)>>2]=h+S,h=fe(r,a,y),b=a<<2,D[k+(l[b+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),D[k+(l[b+4304>>2]<<2)>>2]=u+h}function sE(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0,P=0;k=At-48|0,At=k,P=l[a+8>>2];t:{if(ft[7052]&1){a=l[1762];break t}a=Kf(5,4480)|0,ft[7052]=1,l[1762]=a}l[k+40>>2]=b,D[k+32>>2]=y,l[k+24>>2]=u,D[k+16>>2]=h,S=+FA(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=l[k+12>>2],b=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=b,b=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=b,$A(u|0),At=k+48|0}function nE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=At-32|0,At=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){b=(y|15)+1|0,k=ht(b),l[u+16>>2]=b|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,b=y+k|0;break r}if(ft[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Mi(k,a+4|0,y)}return ft[b|0]=0,l[u>>2]=h,Dt[r|0](u+24|0,u+8|0,u),MA(l[u+24>>2]),r=l[u+24>>2],Ca(r|0),Ca(l[u>>2]),ft[u+19|0]<0&&gi(l[u+8>>2]),At=u+32|0,r|0}Ls(),ue()}function ci(r,a,h){var u=0,y=0,b=0;if(!(bt[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Tp(a))break r;r=l[a+16>>2]}if(b=l[a+20>>2],r-b>>>0<h>>>0){Dt[l[a+36>>2]](a,u,h)|0;break t}i:{if(l[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,bt[u+r|0]==10)break}if(Dt[l[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,b=l[a+20>>2]}Mi(b,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function ph(r,a,h){var u=0,y=0,b=0;u=At-16|0,At=u,y=r+24|0,Dt[a|0](u+8|0,y),b=l[u+12>>2];t:{if((l[l[u+8>>2]>>2]&7<<b)>>b==(h|0))break t;for(Dt[a|0](u+8|0,y),a=l[u+8>>2],y=a,b=l[a>>2],a=l[u+12>>2],l[y>>2]=b&(7<<a^-1)|(h&7)<<a;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}At=u+16|0}function Ur(r,a,h){var u=m(0);a=(a<<2)+r|0,u=D[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+28>>2],u=D[r+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=D[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function we(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Nr(r,5,y,2140081935);break t}r=Ur(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(It(2,r),Gt()),u!=u)return m(Yt);if(u=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function fe(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Nr(r,4,y,2140081935);break t}r=Ur(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(It(2,r),Gt()),u!=u)return m(Yt);if(u=(It(2,(r&-1073741825)+536870912|0),Gt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function aE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0,S=0;return y=l[r+84>>2],b=l[y>>2],u=l[y+4>>2],S=l[r+28>>2],k=l[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Mi(b,S,k),b=k+l[y>>2]|0,l[y>>2]=b,u=l[y+4>>2]-k|0,l[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Mi(b,a,u),b=u+l[y>>2]|0,l[y>>2]=b,l[y+4>>2]=l[y+4>>2]-u),ft[b|0]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,h|0}function Se(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Nr(r,5,u,2140081935);break t}r=Ur(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(It(2,r),Gt()),h!=h))break r;h=(It(2,(r&-1073741825)+536870912|0),Gt());break t}h=m(Yt)}return ce(h,m(0))}function ge(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Nr(r,4,u,2140081935);break t}r=Ur(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(It(2,r),Gt()),h!=h))break r;h=(It(2,(r&-1073741825)+536870912|0),Gt());break t}h=m(Yt)}return ce(h,m(0))}function oE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=l[a>>2]+(h<<2)|0,b=D[a+116>>2];t:{r:{if(a=l[a+116>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(It(2,(a&-1073741825)+536870912|0),+Gt())}Fe[r+8>>3]=y,l[r>>2]=u}function lE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=l[a>>2]+(h<<2)|0,b=D[a+80>>2];t:{r:{if(a=l[a+80>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(It(2,(a&-1073741825)+536870912|0),+Gt())}Fe[r+8>>3]=y,l[r>>2]=u}function cE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=m(0);u=2,a=l[a>>2]+(h<<2)|0,b=D[a+44>>2];t:{r:{if(a=l[a+44>>2],(a|0)!=2139156720){if(y=Yt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(b!=b){u=0;break t}u=a&1073741824?2:1,y=(It(2,(a&-1073741825)+536870912|0),+Gt())}Fe[r+8>>3]=y,l[r>>2]=u}function Br(r,a,h,u){var y=0,b=0,k=0;r=r*a,y=dh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Be(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Be(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;b=0;r:{if(k||(b=1,y>.5))break r;b=Be(y+-.5)<1e-4?1:0}r=r+b}return r!=r|a!=a?m(Yt):m(r/a)}function up(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;l[r>>2]=2143289344,l[r+4>>2]=3;return}l[r>>2]=0,l[r+4>>2]=1;return}l[r>>2]=0,l[r+4>>2]=2;return}if(h=(It(2,a),Gt()),h!=h){l[r>>2]=2143289344,l[r+4>>2]=0;return}l[r+4>>2]=a&1073741824?2:1,l[r>>2]=(a&-1073741825)+536870912}function fp(r){var a=0,h=0,u=0;h=l[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=l[r+560>>2],h=l[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=l[l[h+(r<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(r=r+1|0,(u|0)==(r|0))break}}return a}function hE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+220>>2];t:{r:{if(a=l[a+220>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function dE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+200>>2];t:{r:{if(a=l[a+200>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function uE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+204>>2];t:{r:{if(a=l[a+204>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function fE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+208>>2];t:{r:{if(a=l[a+208>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function pE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+212>>2];t:{r:{if(a=l[a+212>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function gE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=D[a+216>>2];t:{r:{if(a=l[a+216>>2],(a|0)!=2139156720){if(u=Yt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),+Gt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function mE(r,a){r=r|0,a=a|0;var h=0;if(h=At-16|0,At=h,r=l[r>>2],(a|0)<6){At=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(bt[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(bt[r+300|0]&3)==2)break t;a=r+260|0;break t;default:break r}a=(r+(a<<2)|0)+252|0}return+D[a>>2]}l[h>>2]=1872,er(r,h),ji(),ue()}function vE(r,a){r=r|0,a=a|0;var h=0;if(h=At-16|0,At=h,r=l[r>>2],(a|0)<6){At=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(bt[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(bt[r+300|0]&3)==2)break t;a=r+276|0;break t;default:break r}a=(r+(a<<2)|0)+268|0}return+D[a>>2]}l[h>>2]=1872,er(r,h),ji(),ue()}function yE(r,a){r=r|0,a=a|0;var h=0;if(h=At-16|0,At=h,r=l[r>>2],(a|0)<6){At=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(bt[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(bt[r+300|0]&3)==2)break t;a=r+292|0;break t;default:break r}a=(r+(a<<2)|0)+284|0}return+D[a>>2]}l[h>>2]=1872,er(r,h),ji(),ue()}function bE(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(Yt),a=l[a>>2],y=D[a+40>>2],a=l[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(It(2,(a&-1073741825)+536870912|0),Gt()),h=a&1073741824?2:1}l[r>>2]=h,Fe[r+8>>3]=u}function Gr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Be(r))==m(Wf)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(It(2,(Ki(r),Jt(2)&-2147483648|1602224127)),Gt()),a=(Ki(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),Jt(2)-536870912|1073741824)}return a}function mr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Be(r))==m(Wf)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(It(2,(Ki(r),Jt(2)&-2147483648|1610612735)),Gt()),a=(Ki(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),Jt(2)-536870912|0)}return a}function AE(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=l[r>>2]+(a<<2)|0,u=D[r+188>>2];t:{r:{if(r=l[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(Yt),(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return m((It(2,(r&-1073741825)+536870912|0),Gt()))}h=m(0)}return m(h)}function EE(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0,S=0;return k=At-16|0,At=k,S=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(S=l[S+l[a>>2]>>2]),Dt[S|0](k,a,h,u,y,b),r=ht(16),a=l[k+12>>2],l[r+8>>2]=l[k+8>>2],l[r+12>>2]=a,a=l[k+4>>2],l[r>>2]=l[k>>2],l[r+4>>2]=a,At=k+16|0,r|0}function pp(r,a){t:{if(a){a=Op(l[a>>2]);break t}r:{if(bt[7016]){a=l[1753];break r}a=ht(28),l[a+20>>2]=1065353216,l[a+24>>2]=0,l[a+12>>2]=0,l[a+16>>2]=0,l[a>>2]=0,ft[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,ft[7016]=1,l[1752]=l[1752]+1}a=Op(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function TE(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+152>>2],u=mr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function kE(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+188>>2],u=mr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function wE(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=l[r>>2]+(a<<2)|0,u=D[r+152>>2];t:{r:{if(r=l[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=Yt,(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return It(2,(r&-1073741825)+536870912|0),+Gt()}h=0}return+h}function SE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>20&3)==(a|0))break t;for(l[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Pn(r,a,h){var u=0,y=0,b=0;t:{if(!a){u=r;break t}for(;u=rp(r,a,10),y=Oi,r=vh(u,y,246,0)+r|0,h=h-1|0,ft[h|0]=r|48,b=a>>>0>9,r=u,a=y,!!b;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,ft[h|0]=Ne(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function LE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>22&1)==(a|0))break t;for(l[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function RE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>18&3)==(a|0))break t;for(l[r+24>>2]=h&-786433|a<<18&786432;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function _E(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>16&3)==(a|0))break t;for(l[r+24>>2]=h&-196609|a<<16&196608;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function CE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=D[r+224>>2],u==y|u!=u&y!=y)break t;for(D[r+224>>2]=u;;){if(h=bt[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Dt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function IE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=D[r+28>>2],u==y|u!=u&y!=y)break t;for(D[r+28>>2]=u;;){if(h=bt[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Dt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function DE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=D[r+32>>2],u==y|u!=u&y!=y)break t;for(D[r+32>>2]=u;;){if(h=bt[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Dt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function xE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=D[r+36>>2],u==y|u!=u&y!=y)break t;for(D[r+36>>2]=u;;){if(h=bt[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Dt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function PE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>4&7)==(a|0))break t;for(l[r+24>>2]=h&-113|a<<4&112;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function OE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>2&3)==(a|0))break t;for(l[r+24>>2]=h&-13|a<<2&12;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function ME(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=bt[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(ft[r+4|0]=h&253|(a?2:0);;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function $E(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=At-16|0,At=u,y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Dt[y|0](u,a,h),r=ht(16),a=l[u+12>>2],l[r+8>>2]=l[u+8>>2],l[r+12>>2]=a,a=l[u+4>>2],l[r>>2]=l[u>>2],l[r+4>>2]=a,At=u+16|0,r|0}function gp(r,a){var h=0,u=0;t:{r:{if(h=l[r+556>>2],u=l[r+560>>2],(h|0)==(u|0))break r;for(;;){if(l[h>>2]==(a|0))break r;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Rs(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function FE(r){r=r|0;var a=0,h=0;if(h=At-16|0,At=h,r=l[r>>2],l[r+8>>2]){for(;a=bt[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););At=h+16|0;return}l[h>>2]=1024,er(r,h),ji(),ue()}function mp(r,a){var h=0,u=0,y=0;if(pi(+r),u=Jt(1)|0,y=Jt(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=mp(r*18446744073709552e3,a),h=l[a>>2]+-64|0),l[a>>2]=h,r;l[a>>2]=h-1022,It(0,y|0),It(1,u&-2146435073|1071644672),r=+Ae()}return r}function NE(r,a){r=r|0,a=a|0;var h=0,u=0;return h=At-16|0,At=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](h,a),r=ht(16),a=l[h+12>>2],l[r+8>>2]=l[h+8>>2],l[r+12>>2]=a,a=l[h+4>>2],l[r>>2]=l[h>>2],l[r+4>>2]=a,At=h+16|0,r|0}function Yo(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(l[((a<<2)+u|0)+184>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Zo(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(l[((a<<2)+u|0)+192>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function On(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(l[((a<<2)+u|0)+176>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function gh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,l[h+16>>2]==(a|0))break t;for(u=Dt[9](h)|0,y=a,l[u+16>>2]=y;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function vp(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(l[((a<<2)+u|0)+92>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function mh(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(l[((a<<2)+u|0)+20>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function yp(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(l[((a<<2)+u|0)+56>>2]=h;;){if(a=bt[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Dt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function UE(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,l[a+5972>>2]=h,l[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);uh(48),l[1756]=16,l[1757]=0,qf(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,ap(),l[1770]=l[1768],l[1768]=7076}function ir(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Nr(r,4,h,2143289344);break t}r=Ur(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(It(2,r),Gt()),r=u==u),r}function Xo(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Nr(r,5,h,2143289344);break t}r=Ur(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(It(2,r),Gt()),r=u==u),r}function vh(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,b=r>>>16|0,K=Ne(y,b),k=h&65535,S=r&65535,P=Ne(k,S),b=(P>>>16|0)+Ne(b,k)|0,y=(b&65535)+Ne(y,S)|0,Oi=(Ne(a,h)+K|0)+Ne(r,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function bp(r,a){var h=0,u=0,y=0;u=At-16|0,At=u,h=bt[r+4|0],y=h&-17,ft[r+4|0]=y;t:{if(a){if(l[r+560>>2]!=l[r+556>>2])break t;h=y|8}else h=h&231;l[r+8>>2]=a,ft[r+4|0]=h,At=u+16|0;return}l[u>>2]=4128,er(r,u),ji(),ue()}function Ap(r){var a=0,h=m(0);a=0;t:{if((l[r+24>>2]&196608)==131072)break t;r:{if(!l[r+552>>2]||(h=D[r+32>>2],h!=h&&(h=D[r+28>>2],!(h>m(0)))))break r;if(a=1,h!=m(0))break t}a=Mn(r)!=m(0)}return a}function mi(r,a,h,u,y){var b=0;if(b=At-256|0,At=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,$i(b,a&255,h?u:256),!h)for(;ci(r,b,256),u=u-256|0,u>>>0>255;);ci(r,b,u)}At=b+256|0}function on(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=D[u>>2],u=l[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}up(r,u)}function ln(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=l[a+60>>2],y=D[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}up(r,u)}function Mn(r){var a=m(0),h=m(0);if(!l[r+552>>2])return m(0);a=D[r+36>>2];t:{if(a==a||(a=m(1),ft[l[r+568>>2]+8|0]&1)||(a=m(0),h=D[r+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function Ep(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=ft[u|0],Qo(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ne(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Da(r,a,h,u){var y=0;l[r+12>>2]=0,l[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return l[r>>2]=y,h=(h<<2)+y|0,l[r+8>>2]=h,l[r+12>>2]=(a<<2)+y,l[r+4>>2]=h,r}kh(),ue()}function Tp(r){var a=0;return a=l[r+72>>2],l[r+72>>2]=a-1|a,a=l[r>>2],a&8?(l[r>>2]=a|32,-1):(l[r+4>>2]=0,l[r+8>>2]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],0)}function BE(r,a,h,u,y,b){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),b=b|0;var k=0;k=At-16|0,At=k,a=l[l[a>>2]+4>>2],Dt[l[l[a>>2]+8>>2]](k,a,h,u,y,b),D[r>>2]=Fe[k>>3],D[r+4>>2]=Fe[k+8>>3],At=k+16|0}function GE(){var r=0,a=0;return a=ht(4),r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function HE(r,a){r=r|0,a=a|0,a=l[a>>2],Fe[r>>3]=D[a+228>>2],Fe[r+8>>3]=D[a+236>>2],Fe[r+16>>3]=D[a+232>>2],Fe[r+24>>3]=D[a+240>>2],Fe[r+32>>3]=D[a+244>>2],Fe[r+40>>3]=D[a+248>>2]}function VE(r,a){r=r|0,a=a|0;var h=0,u=0;return h=At-48|0,At=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](h,a),r=Mi(ht(48),h,48),At=h+48|0,r|0}function WE(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=At-16|0,At=y,r=Mp(UA(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),At=y+16|0,Oi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function KE(r,a){r=r|0,a=a|0;var h=0,u=0;h=l[r>>2],r=l[h+556>>2];t:{if(l[h+560>>2]-r>>2>>>0<=a>>>0||(r=l[r+(a<<2)>>2],!r))break t;u=l[r>>2]}return u|0}function jE(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=l[r>>2],h?a=a|l[r+12>>2]:a=l[r+12>>2]&(a^-1),l[r+12>>2]=a;return}Ls(),ue()}function zE(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var b=0;b=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(b=l[b+l[a>>2]>>2]),Dt[b|0](a,h,u,y)}function YE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),m(m(Dt[u|0](a,h)))}function kp(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Dt[y|0](a,h,u)}function wp(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](a,h)|0}function ZE(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Dt[y|0](a,h,u)}function XE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),+Dt[u|0](a,h)}function ht(r){var a=0;r=r||1;t:{for(;;){if(a=hh(r),a)break t;if(a=l[2042],a){Dt[a|0]();continue}break}Ls(),ue()}return a}function qE(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](a,h)}function Cs(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](a,h)}function cn(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Dt[h|0](a)|0}function yh(r,a){return Ki(r),(Jt(2)&2147483647)>>>0<=2139095040?(Ki(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(PA(r,a))):a}function ce(r,a){return Ki(r),(Jt(2)&2147483647)>>>0<=2139095040?(Ki(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(OA(r,a))):a}function Sp(r,a){r=r|0,a=a|0;var h=0;return h=At-16|0,At=h,l[h+8>>2]=a,r=Dt[r|0](h+8|0)|0,Ca(l[h+8>>2]),At=h+16|0,r|0}function QE(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Dt[u|0](a,h)}function JE(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?Up(5816,u,y)|0:Up(5672,u,y)|0}function Lp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}ft[r|0]=a,r=1}return r}function tT(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),+Dt[h|0](a)}function Rp(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Ko(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function $n(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Ko(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function bh(r,a){var h=0;t:{if(ft[7044]&1){h=l[1760];break t}h=Kf(1,4464)|0,ft[7044]=1,l[1760]=h}NA(h|0,r|0,a|0,0)}function eT(r,a){r=r|0,a=a|0;var h=0;h=l[r+8>>2],l[r+8>>2]=a,h&&Dt[l[l[h>>2]+4>>2]](h),l[l[r>>2]+20>>2]=15}function iT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Zf((ft[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function rT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=Zf((ft[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function _p(r,a){r=r|0,a=a|0;var h=0;h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Dt[h|0](a)}function sT(r){r=r|0;var a=m(0);return r=l[r>>2],a=D[r+36>>2],a!=a&&(a=ft[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function nT(r,a){r=r|0,a=a|0;var h=0;h=l[r+4>>2],l[r+4>>2]=a,h&&Dt[l[l[h>>2]+4>>2]](h),bp(l[r>>2],14)}function aT(r){r=r|0;var a=0;a=l[r+8>>2],l[r+8>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a),l[l[r>>2]+20>>2]=0}function oT(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function lT(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function cT(){var r=0;if(r=l[1768],r)for(;Dt[l[r>>2]](),r=l[r+4>>2],!!r;);}function hT(r){r=r|0;var a=0;a=l[r+4>>2],l[r+4>>2]=0,a&&Dt[l[l[a>>2]+4>>2]](a),bp(l[r>>2],0)}function Cp(r){return r=r|0,l[r>>2]=4572,bt[r+4|0]&&bh(l[r+8>>2],1759),Ca(l[r+8>>2]),r|0}function Ip(r){return r=r|0,l[r>>2]=4452,bt[r+4|0]&&bh(l[r+8>>2],1759),Ca(l[r+8>>2]),r|0}function dT(){var r=0;return r=ht(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function Dp(r,a,h){return ir(r,a)?_s(r,a,h):(h=Ia(r,a,h),h==h&&(h=m(-h)),h)}function xp(r,a){var h=0;h=At-16|0,At=h,r||(l[h>>2]=a,er(0,h),ji(),ue()),At=h+16|0}function Pp(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&gi(a),l[1752]=l[1752]-1,gi(r))}function uT(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Ls(),ue()),l[l[r>>2]+12>>2]>>>a&1}function fT(r,a,h,u,y){return r=r|0,a=a|0,h=h|0,u=u|0,y=y|0,Dt[r|0](a,h,u,y)|0}function pT(){var r=0;return r=ht(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function gT(r){r=r|0;var a=m(0);return a=D[l[r>>2]+224>>2],+(a!=a?m(Yt):a)}function mT(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function vT(r){r=r|0;var a=m(0);return a=D[l[r>>2]+32>>2],+(a==a?a:m(0))}function Op(r){var a=0;return a=Jf(ht(588),r),xp((r|0)!=0,2808),a}function yT(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function bT(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function AT(r,a){r=r|0,a=a|0,r=l[r>>2],ft[r+8|0]=bt[r+8|0]&254|a}function ET(r){r=r|0,r=l[l[r>>2]+8>>2],Dt[l[l[r>>2]+8>>2]](r)}function TT(r,a,h){r=r|0,a=a|0,h=+h,mh(l[r>>2],a,mr(m(h)))}function kT(r,a,h){r=r|0,a=a|0,h=+h,mh(l[r>>2],a,Gr(m(h)))}function wT(r,a,h,u){return Oi=0,0}function ST(r,a,h){r=r|0,a=a|0,h=+h,vp(l[r>>2],a,mr(m(h)))}function LT(r,a,h){r=r|0,a=a|0,h=+h,vp(l[r>>2],a,Gr(m(h)))}function RT(r,a,h){r=r|0,a=a|0,h=+h,yp(l[r>>2],a,mr(m(h)))}function _T(r,a,h){r=r|0,a=a|0,h=+h,yp(l[r>>2],a,Gr(m(h)))}function CT(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function IT(r,a){r=r|0,a=a|0,mh(l[r>>2],a,2141891242)}function Ah(r,a,h){r=r|0,a=a|0,h=+h,Fe[l[r>>2]+a>>3]=h}function DT(r){return r=r|0,(bt[l[r>>2]+4|0]&2)>>>1|0}function xT(r){return r=r|0,(bt[l[r>>2]+4|0]&4)>>>2|0}function PT(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function OT(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function MT(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function $T(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function Eh(r,a){return r=r|0,a=a|0,+Fe[l[r>>2]+a>>3]}function FT(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function NT(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function UT(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function BT(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function GT(r,a){r=r|0,a=+a,On(l[r>>2],0,mr(m(a)))}function HT(r,a){r=r|0,a=+a,On(l[r>>2],0,Gr(m(a)))}function VT(r,a){r=r|0,a=+a,On(l[r>>2],1,mr(m(a)))}function WT(r,a){r=r|0,a=+a,On(l[r>>2],1,Gr(m(a)))}function KT(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function jT(r,a){r=r|0,a=+a,Yo(l[r>>2],0,mr(m(a)))}function zT(r,a){r=r|0,a=+a,Yo(l[r>>2],0,Gr(m(a)))}function YT(r,a){r=r|0,a=+a,Yo(l[r>>2],1,mr(m(a)))}function ZT(r,a){r=r|0,a=+a,Yo(l[r>>2],1,Gr(m(a)))}function XT(r,a){r=r|0,a=+a,Zo(l[r>>2],0,mr(m(a)))}function qT(r,a){r=r|0,a=+a,Zo(l[r>>2],1,mr(m(a)))}function QT(r,a){r=r|0,a=+a,Zo(l[r>>2],1,Gr(m(a)))}function JT(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function tk(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function ek(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function qo(r){r=r|0,r&&Dt[l[l[r>>2]+4>>2]](r)}function ik(r,a){r=r|0,a=+a,Zo(l[r>>2],0,Gr(m(a)))}function Mp(r){return r?(l[1781]=r,-1):0}function rk(r,a){r=r|0,a=+a,gh(l[r>>2],mr(m(a)))}function sk(r,a){r=r|0,a=+a,gh(l[r>>2],Gr(m(a)))}function $p(r,a,h){return m(fe(r,a,h)+we(r,a,h))}function nk(r,a){return r=r|0,a=a|0,Dt[r|0](a)|0}function Fp(r,a,h,u){BA(r|0,a|0,8,0,h|0,-1,u|0)}function ak(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function ok(r){return r=r|0,l[l[r>>2]+16>>2]&1}function lk(r){return r=r|0,In[l[r>>2]+26>>1]&3}function ck(r){r=r|0,On(l[r>>2],0,2141891242)}function hk(r){r=r|0,On(l[r>>2],1,2141891242)}function dk(r){return r=r|0,+D[l[r>>2]+228>>2]}function uk(r){return r=r|0,+D[l[r>>2]+236>>2]}function fk(r){return r=r|0,+D[l[r>>2]+232>>2]}function pk(r){return r=r|0,+D[l[r>>2]+240>>2]}function gk(r){return r=r|0,+D[l[r>>2]+244>>2]}function mk(r){return r=r|0,+D[l[r>>2]+248>>2]}function vk(r){return r=r|0,WA(l[r+60>>2])|0}function yk(r){return r=r|0,l[l[r>>2]+16>>2]}function bk(r){return r=r|0,ft[l[r>>2]+8|0]&1}function Ak(r,a){r=r|0,a=a|0,ph(l[r>>2],5,a)}function Ek(r,a){r=r|0,a=a|0,ph(l[r>>2],6,a)}function Tk(r,a){r=r|0,a=a|0,ph(l[r>>2],7,a)}function kk(r){r=r|0,gh(l[r>>2],2141891242)}function Np(r,a){r=r|0,a=a|0,Dt[l[r>>2]](a)}function wk(r){return r=r|0,pp(ht(12),r)|0}function Sk(r){r=r|0,bh(l[r+8>>2],3293)}function Up(r,a,h){return cp(r,a,h,2,3)}function Bp(r){return r=r|0,Dt[r|0]()|0}function Gp(r,a){r=r|0,a=a|0,Dt[r|0](a)}function Lk(){return $i(ht(48),0,48)|0}function ji(){Dt[l[1490]](),kh(),ue()}function Rk(){return pp(ht(12),0)|0}function Th(r){r=r|0,r&&gi(r)}function Qo(r){return r-48>>>0<10}function _k(r){return 7032}function Ck(r){return 7036}function Ik(r){return 7056}function Dk(r){return 7059}function xk(r){return 7062}function Pk(r){return 7067}function wr(r){return r=r|0,r|0}function Hp(r){r=r|0,ft[r+4|0]=1}function Ok(r){r=r|0,gi(Cp(r))}function Mk(r){r=r|0,gi(Ip(r))}function $k(r){return 0}function Vp(r){ue()}function Wp(){kh(),ue()}function kh(){Ls(),ue()}B=bt,St();var Dt=N([null,JE,YA,qA,wr,KT,PT,OT,wr,wr,wr,wr,wr,wr,BE,ET,qf,_k,qo,EE,Ck,wr,wr,qo,Hp,Np,Sp,oT,nE,iT,Ik,qo,_p,Dk,wr,wr,qo,Hp,Np,Sp,lT,rT,xk,Pp,Bp,GE,Gp,Pp,jE,kp,rE,qE,yT,Cs,ak,Cs,AT,uT,wp,ok,cn,yk,cn,bk,Lk,Th,dT,Th,pT,Th,Eh,Ah,BT,CT,Pk,np,Bp,Rk,nk,wk,Gp,np,tE,_p,XA,Cs,_E,Cs,RT,ZE,_T,Ak,Ek,Tk,OE,RE,PE,TT,kT,IT,SE,LE,IE,QE,rk,sk,kk,DE,xE,GT,HT,ck,VT,WT,hk,jT,zT,YT,ZT,XT,ik,qT,QT,CE,TE,ST,LT,kE,lk,cn,lE,$E,JT,MT,$T,tk,FT,ek,cE,bE,NE,vT,tT,sT,dE,uE,fE,pE,gE,hE,gT,wE,XE,NT,UT,oE,AE,YE,QA,kp,JA,Cs,bT,cn,mT,cn,KE,wp,DT,cn,ME,Cs,nT,Cs,hT,eT,Cs,aT,FE,xT,cn,ZA,zE,dk,uk,fk,pk,gk,mk,HE,VE,mE,vE,yE,Eh,Ah,Eh,Ah,ap,Ip,Mk,sE,Vp,Wp,Cp,Ok,Sk,Vp,vk,eE,WE,$k,wT,aE,Wp]);function Kp(){return Pi.byteLength/65536|0}function Fk(r){r=r|0;var a=Kp()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ne(h,65536)),y=new Int8Array(u);y.set(ft),ft=new Int8Array(u),Fr=new Int16Array(u),l=new Int32Array(u),bt=new Uint8Array(u),In=new Uint16Array(u),Vf=new Uint32Array(u),D=new Float32Array(u),Fe=new Float64Array(u),Pi=u,tr.buffer=Pi,B=bt}return a}return{E:UE,F:iE,G:cT,H:hh,I:Dt,J:gi,K:fT}}return Wo(I)}(C)}var R=Error,x={};A=[],typeof x!="object"&&Pt("no native wasm support detected");var M,G=!1;function _(C,I,N){N=I+N;for(var B="";!(I>=N);){var et=C[I++];if(!et)break;if(et&128){var mt=C[I++]&63;if((et&224)==192)B+=String.fromCharCode((et&31)<<6|mt);else{var lt=C[I++]&63;et=(et&240)==224?(et&15)<<12|mt<<6|lt:(et&7)<<18|mt<<12|lt<<6|C[I++]&63,65536>et?B+=String.fromCharCode(et):(et-=65536,B+=String.fromCharCode(55296|et>>10,56320|et&1023))}}else B+=String.fromCharCode(et)}return B}var F,H,j,nt,ot,tt,kt,vt,$t;function jt(C){F=C,o.HEAP8=H=new Int8Array(C),o.HEAP16=nt=new Int16Array(C),o.HEAP32=tt=new Int32Array(C),o.HEAPU8=j=new Uint8Array(C),o.HEAPU16=ot=new Uint16Array(C),o.HEAPU32=kt=new Uint32Array(C),o.HEAPF32=vt=new Float32Array(C),o.HEAPF64=$t=new Float64Array(C)}var V=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new T,M&&(F=M.buffer),V=F.byteLength,jt(F);var rt,Lt=[],$=[],U=[];function q(){var C=o.preRun.shift();Lt.unshift(C)}var gt=0,Et=null;function Pt(C){throw o.onAbort&&o.onAbort(C),C="Aborted("+C+")",v(C),G=!0,C=new R(C+". Build with -sASSERTIONS for more info."),d(C),C}function Ut(C){return C.startsWith("data:application/octet-stream;base64,")}var Ot;if(Ot="<<< WASM_BINARY_FILE >>>",!Ut(Ot)){var ae=Ot;Ot=o.locateFile?o.locateFile(ae,p):p+ae}function oe(C){var I=Ot;try{try{if(I==Ot&&A)new Uint8Array(A);else{if(Ut(I)){try{var N=IA(I.slice(37)),B=new Uint8Array(N.length);for(I=0;I<N.length;++I)B[I]=N.charCodeAt(I);var et=B}catch{throw Error("Converting base64 string to bytes failed.")}var mt=et}else mt=void 0;if(!mt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(_t){Pt(_t)}var lt=new E,St=new w(C)}catch(_t){throw C=_t.toString(),v("failed to compile wasm module: "+C),(C.includes("imported Memory")||C.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),_t}return[St,lt]}function he(C){for(;0<C.length;)C.shift()(o)}function Te(C){if(C===void 0)return"_unknown";C=C.replace(/[^a-zA-Z0-9_]/g,"$");var I=C.charCodeAt(0);return 48<=I&&57>=I?"_"+C:C}function pe(C,I){return C=Te(C),function(){return I.apply(this,arguments)}}var Wt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],de=[];function ie(C){var I=Error,N=pe(C,function(B){this.name=C,this.message=B,B=Error(B).stack,B!==void 0&&(this.stack=this.toString()+`
92
- `+B.replace(/^Error(:[^\n]*)?\n/,""))});return N.prototype=Object.create(I.prototype),N.prototype.constructor=N,N.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},N}var Ce=void 0;function Bt(C){throw new Ce(C)}var Ze=C=>(C||Bt("Cannot use deleted val. handle = "+C),Wt[C].value),ri=C=>{switch(C){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var I=de.length?de.pop():Wt.length;return Wt[I]={fa:1,value:C},I}},xi=void 0,Er=void 0;function ke(C){for(var I="";j[C];)I+=Er[j[C++]];return I}var oi=[];function ve(){for(;oi.length;){var C=oi.pop();C.L.Z=!1,C.delete()}}var qe=void 0,Qe={};function Wi(C,I){for(I===void 0&&Bt("ptr should not be undefined");C.P;)I=C.aa(I),C=C.P;return I}var $e={};function Si(C){C=xA(C);var I=ke(C);return Ss(C),I}function es(C,I){var N=$e[C];return N===void 0&&Bt(I+" has unknown type "+Si(C)),N}function li(){}var Tr=!1;function Es(C){--C.count.value,C.count.value===0&&(C.S?C.T.V(C.S):C.O.M.V(C.N))}function Ts(C,I,N){return I===N?C:N.P===void 0?null:(C=Ts(C,I,N.P),C===null?null:N.ma(C))}var Ji={};function ct(C,I){return I=Wi(C,I),Qe[I]}var Ht=void 0;function Zt(C){throw new Ht(C)}function ye(C,I){return I.O&&I.N||Zt("makeClassHandle requires ptr and ptrType"),!!I.T!=!!I.S&&Zt("Both smartPtrType and smartPtr must be specified"),I.count={value:1},se(Object.create(C,{L:{value:I}}))}function se(C){return typeof FinalizationRegistry>"u"?(se=I=>I,C):(Tr=new FinalizationRegistry(I=>{Es(I.L)}),se=I=>{var N=I.L;return N.S&&Tr.register(I,{L:N},I),I},li=I=>{Tr.unregister(I)},se(C))}var si={};function Li(C){for(;C.length;){var I=C.pop();C.pop()(I)}}function dr(C){return this.fromWireType(tt[C>>2])}var is={},ur={};function fr(C,I,N){function B(St){St=N(St),St.length!==C.length&&Zt("Mismatched type converter count");for(var _t=0;_t<C.length;++_t)Ri(C[_t],St[_t])}C.forEach(function(St){ur[St]=I});var et=Array(I.length),mt=[],lt=0;I.forEach((St,_t)=>{$e.hasOwnProperty(St)?et[_t]=$e[St]:(mt.push(St),is.hasOwnProperty(St)||(is[St]=[]),is[St].push(()=>{et[_t]=$e[St],++lt,lt===mt.length&&B(et)}))}),mt.length===0&&B(et)}function ks(C){switch(C){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+C)}}function Ri(C,I,N={}){if(!("argPackAdvance"in I))throw new TypeError("registerType registeredInstance requires argPackAdvance");var B=I.name;if(C||Bt('type "'+B+'" must have a positive integer typeid pointer'),$e.hasOwnProperty(C)){if(N.ta)return;Bt("Cannot register type '"+B+"' twice")}$e[C]=I,delete ur[C],is.hasOwnProperty(C)&&(I=is[C],delete is[C],I.forEach(et=>et()))}function _a(C){Bt(C.L.O.M.name+" instance already deleted")}function pr(){}function ws(C,I,N){if(C[I].R===void 0){var B=C[I];C[I]=function(){return C[I].R.hasOwnProperty(arguments.length)||Bt("Function '"+N+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+C[I].R+")!"),C[I].R[arguments.length].apply(this,arguments)},C[I].R=[],C[I].R[B.Y]=B}}function dA(C,I){o.hasOwnProperty(C)?(Bt("Cannot register public name '"+C+"' twice"),ws(o,C,C),o.hasOwnProperty(void 0)&&Bt("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[C].R[void 0]=I):o[C]=I}function uA(C,I,N,B,et,mt,lt,St){this.name=C,this.constructor=I,this.W=N,this.V=B,this.P=et,this.oa=mt,this.aa=lt,this.ma=St,this.ia=[]}function ih(C,I,N){for(;I!==N;)I.aa||Bt("Expected null or instance of "+N.name+", got an instance of "+I.name),C=I.aa(C),I=I.P;return C}function fA(C,I){return I===null?(this.da&&Bt("null is not a valid "+this.name),0):(I.L||Bt('Cannot pass "'+ah(I)+'" as a '+this.name),I.L.N||Bt("Cannot pass deleted object as a pointer of type "+this.name),ih(I.L.N,I.L.O.M,this.M))}function pA(C,I){if(I===null){if(this.da&&Bt("null is not a valid "+this.name),this.ca){var N=this.ea();return C!==null&&C.push(this.V,N),N}return 0}if(I.L||Bt('Cannot pass "'+ah(I)+'" as a '+this.name),I.L.N||Bt("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&I.L.O.ba&&Bt("Cannot convert argument of type "+(I.L.T?I.L.T.name:I.L.O.name)+" to parameter type "+this.name),N=ih(I.L.N,I.L.O.M,this.M),this.ca)switch(I.L.S===void 0&&Bt("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:I.L.T===this?N=I.L.S:Bt("Cannot convert argument of type "+(I.L.T?I.L.T.name:I.L.O.name)+" to parameter type "+this.name);break;case 1:N=I.L.S;break;case 2:if(I.L.T===this)N=I.L.S;else{var B=I.clone();N=this.wa(N,ri(function(){B.delete()})),C!==null&&C.push(this.V,N)}break;default:Bt("Unsupporting sharing policy")}return N}function gA(C,I){return I===null?(this.da&&Bt("null is not a valid "+this.name),0):(I.L||Bt('Cannot pass "'+ah(I)+'" as a '+this.name),I.L.N||Bt("Cannot pass deleted object as a pointer of type "+this.name),I.L.O.ba&&Bt("Cannot convert argument of type "+I.L.O.name+" to parameter type "+this.name),ih(I.L.N,I.L.O.M,this.M))}function rs(C,I,N,B){this.name=C,this.M=I,this.da=N,this.ba=B,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,I.P!==void 0?this.toWireType=pA:(this.toWireType=B?fA:gA,this.U=null)}function mA(C,I){o.hasOwnProperty(C)||Zt("Replacing nonexistant public symbol"),o[C]=I,o[C].Y=void 0}function vA(C,I){var N=[];return function(){if(N.length=0,Object.assign(N,arguments),C.includes("j")){var B=o["dynCall_"+C];B=N&&N.length?B.apply(null,[I].concat(N)):B.call(null,I)}else B=rt.get(I).apply(null,N);return B}}function kr(C,I){C=ke(C);var N=C.includes("j")?vA(C,I):rt.get(I);return typeof N!="function"&&Bt("unknown function pointer with signature "+C+": "+I),N}var Ff=void 0;function Bo(C,I){function N(mt){et[mt]||$e[mt]||(ur[mt]?ur[mt].forEach(N):(B.push(mt),et[mt]=!0))}var B=[],et={};throw I.forEach(N),new Ff(C+": "+B.map(Si).join([", "]))}function rh(C,I,N,B,et){var mt=I.length;2>mt&&Bt("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=I[1]!==null&&N!==null,St=!1;for(N=1;N<I.length;++N)if(I[N]!==null&&I[N].U===void 0){St=!0;break}var _t=I[0].name!=="void",Ct=mt-2,Nt=Array(Ct),zt=[],Jt=[];return function(){if(arguments.length!==Ct&&Bt("function "+C+" called with "+arguments.length+" arguments, expected "+Ct+" args!"),Jt.length=0,zt.length=lt?2:1,zt[0]=et,lt){var It=I[1].toWireType(Jt,this);zt[1]=It}for(var Ae=0;Ae<Ct;++Ae)Nt[Ae]=I[Ae+2].toWireType(Jt,arguments[Ae]),zt.push(Nt[Ae]);if(Ae=B.apply(null,zt),St)Li(Jt);else for(var pi=lt?1:2;pi<I.length;pi++){var ue=pi===1?It:Nt[pi-2];I[pi].U!==null&&I[pi].U(ue)}return It=_t?I[0].fromWireType(Ae):void 0,It}}function sh(C,I){for(var N=[],B=0;B<C;B++)N.push(kt[I+4*B>>2]);return N}function nh(C){4<C&&--Wt[C].fa===0&&(Wt[C]=void 0,de.push(C))}function ah(C){if(C===null)return"null";var I=typeof C;return I==="object"||I==="array"||I==="function"?C.toString():""+C}function yA(C,I){switch(I){case 2:return function(N){return this.fromWireType(vt[N>>2])};case 3:return function(N){return this.fromWireType($t[N>>3])};default:throw new TypeError("Unknown float type: "+C)}}function bA(C,I,N){switch(I){case 0:return N?function(B){return H[B]}:function(B){return j[B]};case 1:return N?function(B){return nt[B>>1]}:function(B){return ot[B>>1]};case 2:return N?function(B){return tt[B>>2]}:function(B){return kt[B>>2]};default:throw new TypeError("Unknown integer type: "+C)}}function AA(C,I){for(var N="",B=0;!(B>=I/2);++B){var et=nt[C+2*B>>1];if(et==0)break;N+=String.fromCharCode(et)}return N}function EA(C,I,N){if(N===void 0&&(N=2147483647),2>N)return 0;N-=2;var B=I;N=N<2*C.length?N/2:C.length;for(var et=0;et<N;++et)nt[I>>1]=C.charCodeAt(et),I+=2;return nt[I>>1]=0,I-B}function TA(C){return 2*C.length}function kA(C,I){for(var N=0,B="";!(N>=I/4);){var et=tt[C+4*N>>2];if(et==0)break;++N,65536<=et?(et-=65536,B+=String.fromCharCode(55296|et>>10,56320|et&1023)):B+=String.fromCharCode(et)}return B}function wA(C,I,N){if(N===void 0&&(N=2147483647),4>N)return 0;var B=I;N=B+N-4;for(var et=0;et<C.length;++et){var mt=C.charCodeAt(et);if(55296<=mt&&57343>=mt){var lt=C.charCodeAt(++et);mt=65536+((mt&1023)<<10)|lt&1023}if(tt[I>>2]=mt,I+=4,I+4>N)break}return tt[I>>2]=0,I-B}function SA(C){for(var I=0,N=0;N<C.length;++N){var B=C.charCodeAt(N);55296<=B&&57343>=B&&++N,I+=4}return I}var LA={};function Nf(C){var I=LA[C];return I===void 0?ke(C):I}var Go=[];function RA(C){var I=Go.length;return Go.push(C),I}function _A(C,I){for(var N=Array(C),B=0;B<C;++B)N[B]=es(kt[I+4*B>>2],"parameter "+B);return N}var Uf=[],CA=[null,[],[]];Ce=o.BindingError=ie("BindingError"),o.count_emval_handles=function(){for(var C=0,I=5;I<Wt.length;++I)Wt[I]!==void 0&&++C;return C},o.get_first_emval=function(){for(var C=5;C<Wt.length;++C)if(Wt[C]!==void 0)return Wt[C];return null},xi=o.PureVirtualError=ie("PureVirtualError");for(var Bf=Array(256),Ho=0;256>Ho;++Ho)Bf[Ho]=String.fromCharCode(Ho);Er=Bf,o.getInheritedInstanceCount=function(){return Object.keys(Qe).length},o.getLiveInheritedInstances=function(){var C=[],I;for(I in Qe)Qe.hasOwnProperty(I)&&C.push(Qe[I]);return C},o.flushPendingDeletes=ve,o.setDelayFunction=function(C){qe=C,oi.length&&qe&&qe(ve)},Ht=o.InternalError=ie("InternalError"),pr.prototype.isAliasOf=function(C){if(!(this instanceof pr&&C instanceof pr))return!1;var I=this.L.O.M,N=this.L.N,B=C.L.O.M;for(C=C.L.N;I.P;)N=I.aa(N),I=I.P;for(;B.P;)C=B.aa(C),B=B.P;return I===B&&N===C},pr.prototype.clone=function(){if(this.L.N||_a(this),this.L.$)return this.L.count.value+=1,this;var C=se,I=Object,N=I.create,B=Object.getPrototypeOf(this),et=this.L;return C=C(N.call(I,B,{L:{value:{count:et.count,Z:et.Z,$:et.$,N:et.N,O:et.O,S:et.S,T:et.T}}})),C.L.count.value+=1,C.L.Z=!1,C},pr.prototype.delete=function(){this.L.N||_a(this),this.L.Z&&!this.L.$&&Bt("Object already scheduled for deletion"),li(this),Es(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},pr.prototype.isDeleted=function(){return!this.L.N},pr.prototype.deleteLater=function(){return this.L.N||_a(this),this.L.Z&&!this.L.$&&Bt("Object already scheduled for deletion"),oi.push(this),oi.length===1&&qe&&qe(ve),this.L.Z=!0,this},rs.prototype.pa=function(C){return this.ja&&(C=this.ja(C)),C},rs.prototype.ga=function(C){this.V&&this.V(C)},rs.prototype.argPackAdvance=8,rs.prototype.readValueFromPointer=dr,rs.prototype.deleteObject=function(C){C!==null&&C.delete()},rs.prototype.fromWireType=function(C){function I(){return this.ca?ye(this.M.W,{O:this.va,N,T:this,S:C}):ye(this.M.W,{O:this,N:C})}var N=this.pa(C);if(!N)return this.ga(C),null;var B=ct(this.M,N);if(B!==void 0)return B.L.count.value===0?(B.L.N=N,B.L.S=C,B.clone()):(B=B.clone(),this.ga(C),B);if(B=this.M.oa(N),B=Ji[B],!B)return I.call(this);B=this.ba?B.ka:B.pointerType;var et=Ts(N,this.M,B.M);return et===null?I.call(this):this.ca?ye(B.M.W,{O:B,N:et,T:this,S:C}):ye(B.M.W,{O:B,N:et})},Ff=o.UnboundTypeError=ie("UnboundTypeError");var IA=typeof atob=="function"?atob:function(C){var I="",N=0;C=C.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(C.charAt(N++)),et="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(C.charAt(N++)),mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(C.charAt(N++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(C.charAt(N++));B=B<<2|et>>4,et=(et&15)<<4|mt>>2;var St=(mt&3)<<6|lt;I+=String.fromCharCode(B),mt!==64&&(I+=String.fromCharCode(et)),lt!==64&&(I+=String.fromCharCode(St))}while(N<C.length);return I},DA={q:function(C,I,N){C=ke(C),I=es(I,"wrapper"),N=Ze(N);var B=[].slice,et=I.M,mt=et.W,lt=et.P.W,St=et.P.constructor;C=pe(C,function(){et.P.ia.forEach((function(Ct){if(this[Ct]===lt[Ct])throw new xi("Pure virtual function "+Ct+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:mt}),this.__construct.apply(this,B.call(arguments))}),mt.__construct=function(){this===mt&&Bt("Pass correct 'this' to __construct");var Ct=St.implement.apply(void 0,[this].concat(B.call(arguments)));li(Ct);var Nt=Ct.L;Ct.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),se(this),Ct=Nt.N,Ct=Wi(et,Ct),Qe.hasOwnProperty(Ct)?Bt("Tried to register registered instance: "+Ct):Qe[Ct]=this},mt.__destruct=function(){this===mt&&Bt("Pass correct 'this' to __destruct"),li(this);var Ct=this.L.N;Ct=Wi(et,Ct),Qe.hasOwnProperty(Ct)?delete Qe[Ct]:Bt("Tried to unregister unregistered instance: "+Ct)},C.prototype=Object.create(mt);for(var _t in N)C.prototype[_t]=N[_t];return ri(C)},k:function(C){var I=si[C];delete si[C];var N=I.ea,B=I.V,et=I.ha,mt=et.map(lt=>lt.sa).concat(et.map(lt=>lt.ya));fr([C],mt,lt=>{var St={};return et.forEach((_t,Ct)=>{var Nt=lt[Ct],zt=_t.qa,Jt=_t.ra,It=lt[Ct+et.length],Ae=_t.xa,pi=_t.za;St[_t.na]={read:ue=>Nt.fromWireType(zt(Jt,ue)),write:(ue,Ki)=>{var Gt=[];Ae(pi,ue,It.toWireType(Gt,Ki)),Li(Gt)}}}),[{name:I.name,fromWireType:function(_t){var Ct={},Nt;for(Nt in St)Ct[Nt]=St[Nt].read(_t);return B(_t),Ct},toWireType:function(_t,Ct){for(var Nt in St)if(!(Nt in Ct))throw new TypeError('Missing field: "'+Nt+'"');var zt=N();for(Nt in St)St[Nt].write(zt,Ct[Nt]);return _t!==null&&_t.push(B,zt),zt},argPackAdvance:8,readValueFromPointer:dr,U:B}]})},w:function(){},C:function(C,I,N,B,et){var mt=ks(N);I=ke(I),Ri(C,{name:I,fromWireType:function(lt){return!!lt},toWireType:function(lt,St){return St?B:et},argPackAdvance:8,readValueFromPointer:function(lt){if(N===1)var St=H;else if(N===2)St=nt;else if(N===4)St=tt;else throw new TypeError("Unknown boolean type size: "+I);return this.fromWireType(St[lt>>mt])},U:null})},g:function(C,I,N,B,et,mt,lt,St,_t,Ct,Nt,zt,Jt){Nt=ke(Nt),mt=kr(et,mt),St&&(St=kr(lt,St)),Ct&&(Ct=kr(_t,Ct)),Jt=kr(zt,Jt);var It=Te(Nt);dA(It,function(){Bo("Cannot construct "+Nt+" due to unbound types",[B])}),fr([C,I,N],B?[B]:[],function(Ae){if(Ae=Ae[0],B)var pi=Ae.M,ue=pi.W;else ue=pr.prototype;Ae=pe(It,function(){if(Object.getPrototypeOf(this)!==Ki)throw new Ce("Use 'new' to construct "+Nt);if(Gt.X===void 0)throw new Ce(Nt+" has no accessible constructor");var Je=Gt.X[arguments.length];if(Je===void 0)throw new Ce("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Gt.X).toString()+") parameters instead!");return Je.apply(this,arguments)});var Ki=Object.create(ue,{constructor:{value:Ae}});Ae.prototype=Ki;var Gt=new uA(Nt,Ae,Ki,Jt,pi,mt,St,Ct);pi=new rs(Nt,Gt,!0,!1),ue=new rs(Nt+"*",Gt,!1,!1);var Wo=new rs(Nt+" const*",Gt,!1,!0);return Ji[C]={pointerType:ue,ka:Wo},mA(It,Ae),[pi,ue,Wo]})},d:function(C,I,N,B,et,mt,lt){var St=sh(N,B);I=ke(I),mt=kr(et,mt),fr([],[C],function(_t){function Ct(){Bo("Cannot call "+Nt+" due to unbound types",St)}_t=_t[0];var Nt=_t.name+"."+I;I.startsWith("@@")&&(I=Symbol[I.substring(2)]);var zt=_t.M.constructor;return zt[I]===void 0?(Ct.Y=N-1,zt[I]=Ct):(ws(zt,I,Nt),zt[I].R[N-1]=Ct),fr([],St,function(Jt){return Jt=rh(Nt,[Jt[0],null].concat(Jt.slice(1)),null,mt,lt),zt[I].R===void 0?(Jt.Y=N-1,zt[I]=Jt):zt[I].R[N-1]=Jt,[]}),[]})},p:function(C,I,N,B,et,mt){0<I||Pt();var lt=sh(I,N);et=kr(B,et),fr([],[C],function(St){St=St[0];var _t="constructor "+St.name;if(St.M.X===void 0&&(St.M.X=[]),St.M.X[I-1]!==void 0)throw new Ce("Cannot register multiple constructors with identical number of parameters ("+(I-1)+") for class '"+St.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return St.M.X[I-1]=()=>{Bo("Cannot construct "+St.name+" due to unbound types",lt)},fr([],lt,function(Ct){return Ct.splice(1,0,null),St.M.X[I-1]=rh(_t,Ct,null,et,mt),[]}),[]})},b:function(C,I,N,B,et,mt,lt,St){var _t=sh(N,B);I=ke(I),mt=kr(et,mt),fr([],[C],function(Ct){function Nt(){Bo("Cannot call "+zt+" due to unbound types",_t)}Ct=Ct[0];var zt=Ct.name+"."+I;I.startsWith("@@")&&(I=Symbol[I.substring(2)]),St&&Ct.M.ia.push(I);var Jt=Ct.M.W,It=Jt[I];return It===void 0||It.R===void 0&&It.className!==Ct.name&&It.Y===N-2?(Nt.Y=N-2,Nt.className=Ct.name,Jt[I]=Nt):(ws(Jt,I,zt),Jt[I].R[N-2]=Nt),fr([],_t,function(Ae){return Ae=rh(zt,Ae,Ct,mt,lt),Jt[I].R===void 0?(Ae.Y=N-2,Jt[I]=Ae):Jt[I].R[N-2]=Ae,[]}),[]})},B:function(C,I){I=ke(I),Ri(C,{name:I,fromWireType:function(N){var B=Ze(N);return nh(N),B},toWireType:function(N,B){return ri(B)},argPackAdvance:8,readValueFromPointer:dr,U:null})},n:function(C,I,N){N=ks(N),I=ke(I),Ri(C,{name:I,fromWireType:function(B){return B},toWireType:function(B,et){return et},argPackAdvance:8,readValueFromPointer:yA(I,N),U:null})},e:function(C,I,N,B,et){I=ke(I),et===-1&&(et=4294967295),et=ks(N);var mt=St=>St;if(B===0){var lt=32-8*N;mt=St=>St<<lt>>>lt}N=I.includes("unsigned")?function(St,_t){return _t>>>0}:function(St,_t){return _t},Ri(C,{name:I,fromWireType:mt,toWireType:N,argPackAdvance:8,readValueFromPointer:bA(I,et,B!==0),U:null})},c:function(C,I,N){function B(mt){mt>>=2;var lt=kt;return new et(F,lt[mt+1],lt[mt])}var et=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][I];N=ke(N),Ri(C,{name:N,fromWireType:B,argPackAdvance:8,readValueFromPointer:B},{ta:!0})},o:function(C,I){I=ke(I);var N=I==="std::string";Ri(C,{name:I,fromWireType:function(B){var et=kt[B>>2],mt=B+4;if(N)for(var lt=mt,St=0;St<=et;++St){var _t=mt+St;if(St==et||j[_t]==0){if(lt=lt?_(j,lt,_t-lt):"",Ct===void 0)var Ct=lt;else Ct+=String.fromCharCode(0),Ct+=lt;lt=_t+1}}else{for(Ct=Array(et),St=0;St<et;++St)Ct[St]=String.fromCharCode(j[mt+St]);Ct=Ct.join("")}return Ss(B),Ct},toWireType:function(B,et){et instanceof ArrayBuffer&&(et=new Uint8Array(et));var mt,lt=typeof et=="string";if(lt||et instanceof Uint8Array||et instanceof Uint8ClampedArray||et instanceof Int8Array||Bt("Cannot pass non-string to std::string"),N&&lt){var St=0;for(mt=0;mt<et.length;++mt){var _t=et.charCodeAt(mt);127>=_t?St++:2047>=_t?St+=2:55296<=_t&&57343>=_t?(St+=4,++mt):St+=3}mt=St}else mt=et.length;if(St=Gf(4+mt+1),_t=St+4,kt[St>>2]=mt,N&&lt){if(lt=_t,_t=mt+1,mt=j,0<_t){_t=lt+_t-1;for(var Ct=0;Ct<et.length;++Ct){var Nt=et.charCodeAt(Ct);if(55296<=Nt&&57343>=Nt){var zt=et.charCodeAt(++Ct);Nt=65536+((Nt&1023)<<10)|zt&1023}if(127>=Nt){if(lt>=_t)break;mt[lt++]=Nt}else{if(2047>=Nt){if(lt+1>=_t)break;mt[lt++]=192|Nt>>6}else{if(65535>=Nt){if(lt+2>=_t)break;mt[lt++]=224|Nt>>12}else{if(lt+3>=_t)break;mt[lt++]=240|Nt>>18,mt[lt++]=128|Nt>>12&63}mt[lt++]=128|Nt>>6&63}mt[lt++]=128|Nt&63}}mt[lt]=0}}else if(lt)for(lt=0;lt<mt;++lt)Ct=et.charCodeAt(lt),255<Ct&&(Ss(_t),Bt("String has UTF-16 code units that do not fit in 8 bits")),j[_t+lt]=Ct;else for(lt=0;lt<mt;++lt)j[_t+lt]=et[lt];return B!==null&&B.push(Ss,St),St},argPackAdvance:8,readValueFromPointer:dr,U:function(B){Ss(B)}})},j:function(C,I,N){if(N=ke(N),I===2)var B=AA,et=EA,mt=TA,lt=()=>ot,St=1;else I===4&&(B=kA,et=wA,mt=SA,lt=()=>kt,St=2);Ri(C,{name:N,fromWireType:function(_t){for(var Ct=kt[_t>>2],Nt=lt(),zt,Jt=_t+4,It=0;It<=Ct;++It){var Ae=_t+4+It*I;(It==Ct||Nt[Ae>>St]==0)&&(Jt=B(Jt,Ae-Jt),zt===void 0?zt=Jt:(zt+=String.fromCharCode(0),zt+=Jt),Jt=Ae+I)}return Ss(_t),zt},toWireType:function(_t,Ct){typeof Ct!="string"&&Bt("Cannot pass non-string to C++ string type "+N);var Nt=mt(Ct),zt=Gf(4+Nt+I);return kt[zt>>2]=Nt>>St,et(Ct,zt+4,Nt+I),_t!==null&&_t.push(Ss,zt),zt},argPackAdvance:8,readValueFromPointer:dr,U:function(_t){Ss(_t)}})},l:function(C,I,N,B,et,mt){si[C]={name:ke(I),ea:kr(N,B),V:kr(et,mt),ha:[]}},i:function(C,I,N,B,et,mt,lt,St,_t,Ct){si[C].ha.push({na:ke(I),sa:N,qa:kr(B,et),ra:mt,ya:lt,xa:kr(St,_t),za:Ct})},D:function(C,I){I=ke(I),Ri(C,{ua:!0,name:I,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(C,I,N,B,et){C=Go[C],I=Ze(I),N=Nf(N);var mt=[];return kt[B>>2]=ri(mt),C(I,N,mt,et)},u:function(C,I,N,B){C=Go[C],I=Ze(I),N=Nf(N),C(I,N,null,B)},h:nh,m:function(C,I){var N=_A(C,I),B=N[0];I=B.name+"_$"+N.slice(1).map(function(lt){return lt.name}).join("_")+"$";var et=Uf[I];if(et!==void 0)return et;var mt=Array(C-1);return et=RA((lt,St,_t,Ct)=>{for(var Nt=0,zt=0;zt<C-1;++zt)mt[zt]=N[zt+1].readValueFromPointer(Ct+Nt),Nt+=N[zt+1].argPackAdvance;for(lt=lt[St].apply(lt,mt),zt=0;zt<C-1;++zt)N[zt+1].la&&N[zt+1].la(mt[zt]);if(!B.ua)return B.toWireType(_t,lt)}),Uf[I]=et},r:function(C){4<C&&(Wt[C].fa+=1)},s:function(C){var I=Ze(C);Li(I),nh(C)},f:function(){Pt("")},y:function(C,I,N){j.copyWithin(C,I,I+N)},x:function(C){var I=j.length;if(C>>>=0,2147483648<C)return!1;for(var N=1;4>=N;N*=2){var B=I*(1+.2/N);B=Math.min(B,C+100663296);var et=Math;B=Math.max(C,B),et=et.min.call(et,2147483648,B+(65536-B%65536)%65536);t:{try{M.grow(et-F.byteLength+65535>>>16),jt(M.buffer);var mt=1;break t}catch{}mt=void 0}if(mt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(C,I,N,B){for(var et=0,mt=0;mt<N;mt++){var lt=kt[I>>2],St=kt[I+4>>2];I+=8;for(var _t=0;_t<St;_t++){var Ct=j[lt+_t],Nt=CA[C];Ct===0||Ct===10?((C===1?g:v)(_(Nt,0)),Nt.length=0):Nt.push(Ct)}et+=St}return kt[B>>2]=et,0},a:M},Cn=function(){function C(N){o.asm=N.exports,rt=o.asm.I,$.unshift(o.asm.E),gt--,o.monitorRunDependencies&&o.monitorRunDependencies(gt),gt==0&&Et&&(N=Et,Et=null,N())}var I={a:DA};if(gt++,o.monitorRunDependencies&&o.monitorRunDependencies(gt),o.instantiateWasm)try{return o.instantiateWasm(I,C)}catch(N){v("Module.instantiateWasm callback failed with error: "+N),d(N)}return I=oe(I),C(I[0]),o.asm}();o.___wasm_call_ctors=Cn.E;var xA=o.___getTypeName=Cn.F;o.__embind_initialize_bindings=Cn.G;var Gf=o._malloc=Cn.H,Ss=o._free=Cn.J;o.dynCall_jiji=Cn.K;var Vo;Et=function C(){Vo||Hf(),Vo||(Et=C)};function Hf(){function C(){if(!Vo&&(Vo=!0,o.calledRun=!0,!G)){if(he($),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var I=o.postRun.shift();U.unshift(I)}he(U)}}if(!(0<gt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)q();he(Lt),0<gt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),C()},1)):C())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return Hf(),s}})();n.exports=e})(Cd);var Gg=Cd.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var e=s(Ll),i=ee;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in n&&n[d]===i[d]||Object.defineProperty(n,d,{enumerable:!0,get:function(){return i[d]}})});function s(d){return d&&d.__esModule?d:{default:d}}const o=Gg;var c=(0,e.default)(o());n.default=c})(Re);const Id=Fg(Re),Zr=1.8;function Dd(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:(n.top??0)*t,right:(n.right??0)*t,bottom:(n.bottom??0)*t,left:(n.left??0)*t}}function Hg(n,t=1){return typeof n=="number"?{topLeft:n*t,topRight:n*t,bottomRight:n*t,bottomLeft:n*t}:{topLeft:((n==null?void 0:n.topLeft)??0)*t,topRight:((n==null?void 0:n.topRight)??0)*t,bottomRight:((n==null?void 0:n.bottomRight)??0)*t,bottomLeft:((n==null?void 0:n.bottomLeft)??0)*t}}function xd(n,{layout:t,scale:e=1}){const{x:i,y:s,w:o,h:c,flex:d,gap:f,margin:p,padding:g,direction:v="column",align:A="start",justify:T="start"}=t,E={row:Re.FlexDirection.Row,column:Re.FlexDirection.Column,"row-reverse":Re.FlexDirection.RowReverse,"column-reverse":Re.FlexDirection.ColumnReverse};n.setFlexDirection(E[v]);const w={start:Re.Align.FlexStart,end:Re.Align.FlexEnd,center:Re.Align.Center,stretch:Re.Align.Stretch};n.setAlignItems(w[A]);const R={start:Re.Justify.FlexStart,end:Re.Justify.FlexEnd,center:Re.Justify.Center,"space-between":Re.Justify.SpaceBetween,"space-around":Re.Justify.SpaceAround,"space-evenly":Re.Justify.SpaceEvenly};if(n.setJustifyContent(R[T]),(i||s)&&(n.setPositionType(Re.PositionType.Absolute),n.setPosition(Re.Edge.Left,i??0),n.setPosition(Re.Edge.Top,s??0)),p){const{top:x,right:M,bottom:G,left:_}=Dd(p,e);n.setMargin(Re.Edge.Top,x),n.setMargin(Re.Edge.Right,M),n.setMargin(Re.Edge.Bottom,G),n.setMargin(Re.Edge.Left,_)}if(g){const{top:x,right:M,bottom:G,left:_}=Dd(g,e);n.setPadding(Re.Edge.Top,x),n.setPadding(Re.Edge.Right,M),n.setPadding(Re.Edge.Bottom,G),n.setPadding(Re.Edge.Left,_)}d&&n.setFlex(d),n.setGap(Re.Gutter.All,(f??0)*e),o&&n.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?n.setHeight(0):n.setHeight(typeof c=="number"?c*e:c))}function Pd({canvas:n,offscreenCanvas:t,debug:e=!1,scale:i=1,position:s=[]}){s.forEach(({x:o,y:c,width:d,height:f,childNodes:p,element:g})=>{const v=n.getContext("2d",{alpha:!1});if(v){const{radius:A,draw:T}=g;if(T){if(v.save(),A){const{topLeft:E,topRight:w,bottomRight:R,bottomLeft:x}=Hg(A,i);v.beginPath(),v.moveTo(o+Math.min(f/Zr,E),c),v.lineTo(o+d-Math.min(f/Zr,w),c),v.quadraticCurveTo(o+d,c,o+d,c+Math.min(f/Zr,w)),v.lineTo(o+d,c+f-Math.min(f/Zr,R)),v.quadraticCurveTo(o+d,c+f,o+d-Math.min(f/Zr,R),c+f),v.lineTo(o+Math.min(f/Zr,x),c+f),v.quadraticCurveTo(o,c+f,o,c+f-Math.min(f/Zr,x)),v.lineTo(o,c+Math.min(f/Zr,E)),v.quadraticCurveTo(o,c,o+Math.min(f/Zr,E),c),v.closePath(),e&&(v.strokeStyle="blue",v.stroke()),v.clip()}T({scale:i,canvas:n,context:v,offscreenCanvas:t,dx:o,dy:c,dw:d,dh:f}),e&&(v.strokeStyle="red",v.strokeRect(o,c,d,f)),v.restore()}}Pd({canvas:n,offscreenCanvas:t,debug:e,scale:i,position:p})})}function Od(n,t,e){const i=t.map((s,o)=>{const c=Id.Node.create(),{radius:d,elements:f=[],draw:p,...g}=s;return xd(c,{layout:g,scale:e}),n.insertChild(c,o),{node:c,element:s,childNodes:Od(c,f,e)}});return n.calculateLayout(),i}function Md(n,t,e=0,i=0){const{top:s,left:o}=n.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:A}=c.getComputedLayout(),T=e+g,E=i+p;return{x:o+T,y:s+E,width:v,height:A,element:d,childNodes:Md(n,f,T,E)}})}function $d(n,t){n.forEach(({node:e,element:i,childNodes:s})=>{const{h:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=o(c,t);e.setHeight(typeof d=="number"?d*t:d)}$d(s,t)})}function Vg({canvas:n,origin:t,elements:e,...i}){const s={x:0,y:0,w:n.width,h:n.height,...t},o=Id.Node.create();xd(o,{layout:s}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=Od(o,e,f);$d(p,f),o.calculateLayout();const g=Md(o,p);return Pd({...i,scale:f,canvas:n,position:g})}function no({context:n,node:t,maxW:e=1/0}){const i=(t.value??"").split(" ");return i.slice(1).reduce((s,o)=>{const c=`${s[s.length-1].text} ${o}`.trim(),d=n.measureText(c);return d.width>e?s=[...s,{text:o,metrics:n.measureText(o)}]:s[s.length-1]={text:c,metrics:d},s},[{text:i[0],metrics:n.measureText(i[0])}])}function Fd(n){const{visible:t=!0,node:e}=n,i=[...(e==null?void 0:e.elements)??[],...(n==null?void 0:n.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>Fd(s)):!1}function Nd({canvas:n,debug:t=!1,elements:e=[],currentTime:i,relativeTime:s}){return e.map(o=>{var c,d,f,p,g,v,A,T;const{node:E}=o,w=n.getContext("2d");if(w&&Fd(o)){let R=o.w,x=o.h;if((E==null?void 0:E.type)==="text"&&E.value){w.save();const M=/(?<value>\d+\.?\d*)(?=px)/,G=parseFloat(((d=(c=E.font.match(M))==null?void 0:c.groups)==null?void 0:d.value)??"0");E.wrap?x=(_,F)=>{var H,j;const nt=parseFloat(((j=(H=E.font.match(M))==null?void 0:H.groups)==null?void 0:j.value)??"0")*F;return w.font=E.font.replace(M,nt.toString()),no({context:w,node:E,maxW:_}).length*G}:(w.font=E.font,R=w.measureText(E.value).width,x=G),w.restore()}if((E==null?void 0:E.type)==="image"&&E.image&&E.size){const M=((f=E.image)==null?void 0:f.naturalWidth)??((p=E.image)==null?void 0:p.width),G=((g=E.image)==null?void 0:g.naturalHeight)??((v=E.image)==null?void 0:v.height),_=M/G,F=(A=E.size)==null?void 0:A.w,H=(T=E.size)==null?void 0:T.h;R=F??(_>=1?H:(H??0)*_),x=H??(_<1?F:(F??0)*_)}return{...o,w:R,h:x,elements:Nd({canvas:n,debug:t,elements:o.elements,currentTime:i,relativeTime:s}),draw:({canvas:M,offscreenCanvas:G,context:_,dx:F,dy:H,dw:j,dh:nt,scale:ot})=>{var tt,kt,vt,$t,jt,V,rt,Lt,$,U,q;if(E){const{type:gt,from:Et=0,to:Pt=1/0}=E;if(s>=Et&&s<=Pt){if(_.save(),s&&Pt-.3333333333333333<=s&&(_.globalAlpha=1-(.16666666666666666-(Pt-s))/.16666666666666666),gt==="box"&&(_.fillStyle=E.background,_.fillRect(F,H,j,nt)),gt==="text"&&E.value){const Ut=/(?<value>\d+\.?\d*)(?=px)/;let Ot=0;const ae=parseFloat(((kt=(tt=E.font.match(Ut))==null?void 0:tt.groups)==null?void 0:kt.value)??"0")*ot;if(E.fill){const{minSize:oe,maxSize:he}=E.fill;Ot=oe*ot,_.font=E.font.replace(Ut,Ot.toString());const Te=10*ot;let pe=0,Wt=no({context:_,node:E,maxW:j});for(;Ot+Te<he*ot&&(Wt.length+1)*(Ot+Te)<nt;)if(Ot+=Te,_.font=E.font.replace(Ut,Ot.toString()),Wt=no({context:_,node:E,maxW:j}),pe=Wt.reduce((de,ie)=>(ie.metrics.width>de&&(de=ie.metrics.width),de),0),pe>j){Ot-=Te;break}}else Ot=ae;_.font=E.font.replace(Ut,Ot.toString()),_.textBaseline="top",_.fillStyle=E.color,E.wrap?no({context:_,node:E,maxW:j}).forEach((oe,he)=>{_.fillText(oe.text,F,H+Ot*he)}):_.fillText(E.value,F,H)}if(gt==="image"&&E.image&&_.drawImage(E.image,F,H,j,nt),gt==="video"&&((vt=E.video)!=null&&vt.node||($t=E.video)!=null&&$t.getSource)){const Ut=E.format??"letterbox",Ot=((V=(jt=E.video)==null?void 0:jt.getSource)==null?void 0:V.call(jt,s))??E.video.node,ae=(Ot==null?void 0:Ot.videoWidth)??(Ot==null?void 0:Ot.naturalWidth)??(Ot==null?void 0:Ot.width),oe=(Ot==null?void 0:Ot.videoHeight)??(Ot==null?void 0:Ot.naturalHeight)??(Ot==null?void 0:Ot.height);if(ae&&oe){const{resolution:Te,aspectRatio:pe}=fn({resolution:Math.min(ae,oe),aspectRatio:ae/oe}),{dx:Wt,dy:de,dw:ie,dh:Ce}=Ld({offscreenCanvas:G,context:_,source:Ot,format:Ut,videoResolution:Te,videoAspectRatio:pe,posX:F,posY:H,width:j,height:nt});E.elements&&Il({debug:t,canvas:M,offscreenCanvas:G,currentTime:i,relativeTime:s,origin:{x:Math.max(F,F+Wt),y:Math.max(H,H+de),w:Math.min(j,ie),h:Math.min(nt,Ce)},elements:E.elements})}const he=1/3;if(E.poster&&i>=0&&i<=he){_.save(),_.globalAlpha=1-i/he;const Te=((rt=E.poster)==null?void 0:rt.naturalWidth)??((Lt=E.poster)==null?void 0:Lt.width),pe=(($=E.poster)==null?void 0:$.naturalHeight)??((U=E.poster)==null?void 0:U.height);if(Te&&pe){const{resolution:Wt,aspectRatio:de}=fn({resolution:Math.min(Te,pe),aspectRatio:Te/pe}),{dx:ie,dy:Ce,dw:Bt,dh:Ze}=Ld({offscreenCanvas:G,context:_,source:E.poster,format:Ut,videoResolution:Wt,videoAspectRatio:de,posX:F,posY:H,width:j,height:nt});E.elements&&Il({debug:t,canvas:M,offscreenCanvas:G,currentTime:i,relativeTime:s,origin:{x:Math.max(F,F+ie),y:Math.max(H,H+Ce),w:Math.min(j,Bt),h:Math.min(nt,Ze)},elements:E.elements})}_.restore()}}if(gt==="gradient"&&E.value){const Ut=_.createLinearGradient(F+j,H,F+j,H+nt);(q=E.value)==null||q.forEach(Ot=>{Ut.addColorStop(Ot.percent,Ot.color)}),_.fillStyle=Ut,_.fillRect(F,H,j,nt)}_.restore()}}}}}}).filter(Boolean)}function Il({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s,...o}){return Vg({...o,canvas:n,elements:Nd({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s})})}const Wg={id:"default",name:"None",template:{id:"basic",name:"Basic",layouts:[{name:"basic",tree:`[
91
+ `),[o,c]=i.match(Wg)||[];return{start:o,end:c,text:s}}):[]}function to(n){const[t,e,i]=n.split(":");return i?parseInt(t)*60*60+parseInt(e)*60+parseFloat(i):parseInt(t)*60+parseInt(e)}function jg({canvas:n,dx:t,dy:e,dw:i,dh:s,relativeTime:o,vttCaptions:c}){if(c){const d=$d(c).find(({start:f,end:p})=>f&&p&&o>=to(f)&&o<to(p));if(d){const f=n.getContext("2d");if(f){const p=Math.min(i,s);let g=[""];const v=i*.9,b=p*.05;f.font=`400 ${b}px Roobert Captions, Dejavu Sans, sans-serif`,f.textBaseline="middle",d.text.split(" ").forEach(E=>{const k=g.length-1,w=f.measureText(g[k]).width,L=f.measureText(` ${E}`).width;w+L<v?g[k]=`${g[k]} ${E}`:g=[...g,E]}),g.forEach((E,k)=>{const w=E.trim(),L=f.measureText(w),x=t+(i-L.width)/2,M=e+(s*.85-(b+p*.04)*(g.length-1-k)),N=b*.8,D=b/1.5,F=t+(i-L.width-D)/2,H=M-N,j=L.width+D,st=N*2,at=f.globalAlpha;f.save(),f.globalAlpha=.8*at,f.fillStyle="#000000",f.beginPath(),f.roundRect(F,H,j,st,p*.01),f.fill(),f.closePath(),f.globalAlpha=at,f.fillStyle="#FFFFFF",f.fillText(w,x,M),f.restore()})}}}}function Kg(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ee={},Ol={},ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.default=ne.Wrap=ne.Unit=ne.PrintOptions=ne.PositionType=ne.Overflow=ne.NodeType=ne.MeasureMode=ne.LogLevel=ne.Justify=ne.Gutter=ne.FlexDirection=ne.ExperimentalFeature=ne.Errata=ne.Edge=ne.Display=ne.Direction=ne.Dimension=ne.Align=void 0;let Zr=function(n){return n[n.Auto=0]="Auto",n[n.FlexStart=1]="FlexStart",n[n.Center=2]="Center",n[n.FlexEnd=3]="FlexEnd",n[n.Stretch=4]="Stretch",n[n.Baseline=5]="Baseline",n[n.SpaceBetween=6]="SpaceBetween",n[n.SpaceAround=7]="SpaceAround",n}({});ne.Align=Zr;let Ml=function(n){return n[n.Width=0]="Width",n[n.Height=1]="Height",n}({});ne.Dimension=Ml;let eo=function(n){return n[n.Inherit=0]="Inherit",n[n.LTR=1]="LTR",n[n.RTL=2]="RTL",n}({});ne.Direction=eo;let $l=function(n){return n[n.Flex=0]="Flex",n[n.None=1]="None",n}({});ne.Display=$l;let Cr=function(n){return n[n.Left=0]="Left",n[n.Top=1]="Top",n[n.Right=2]="Right",n[n.Bottom=3]="Bottom",n[n.Start=4]="Start",n[n.End=5]="End",n[n.Horizontal=6]="Horizontal",n[n.Vertical=7]="Vertical",n[n.All=8]="All",n}({});ne.Edge=Cr;let ha=function(n){return n[n.None=0]="None",n[n.StretchFlexBasis=1]="StretchFlexBasis",n[n.All=2147483647]="All",n[n.Classic=2147483646]="Classic",n}({});ne.Errata=ha;let io=function(n){return n[n.WebFlexBasis=0]="WebFlexBasis",n[n.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",n[n.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",n}({});ne.ExperimentalFeature=io;let da=function(n){return n[n.Column=0]="Column",n[n.ColumnReverse=1]="ColumnReverse",n[n.Row=2]="Row",n[n.RowReverse=3]="RowReverse",n}({});ne.FlexDirection=da;let ro=function(n){return n[n.Column=0]="Column",n[n.Row=1]="Row",n[n.All=2]="All",n}({});ne.Gutter=ro;let Qs=function(n){return n[n.FlexStart=0]="FlexStart",n[n.Center=1]="Center",n[n.FlexEnd=2]="FlexEnd",n[n.SpaceBetween=3]="SpaceBetween",n[n.SpaceAround=4]="SpaceAround",n[n.SpaceEvenly=5]="SpaceEvenly",n}({});ne.Justify=Qs;let Js=function(n){return n[n.Error=0]="Error",n[n.Warn=1]="Warn",n[n.Info=2]="Info",n[n.Debug=3]="Debug",n[n.Verbose=4]="Verbose",n[n.Fatal=5]="Fatal",n}({});ne.LogLevel=Js;let so=function(n){return n[n.Undefined=0]="Undefined",n[n.Exactly=1]="Exactly",n[n.AtMost=2]="AtMost",n}({});ne.MeasureMode=so;let Fl=function(n){return n[n.Default=0]="Default",n[n.Text=1]="Text",n}({});ne.NodeType=Fl;let no=function(n){return n[n.Visible=0]="Visible",n[n.Hidden=1]="Hidden",n[n.Scroll=2]="Scroll",n}({});ne.Overflow=no;let ao=function(n){return n[n.Static=0]="Static",n[n.Relative=1]="Relative",n[n.Absolute=2]="Absolute",n}({});ne.PositionType=ao;let oo=function(n){return n[n.Layout=1]="Layout",n[n.Style=2]="Style",n[n.Children=4]="Children",n}({});ne.PrintOptions=oo;let ua=function(n){return n[n.Undefined=0]="Undefined",n[n.Point=1]="Point",n[n.Percent=2]="Percent",n[n.Auto=3]="Auto",n}({});ne.Unit=ua;let lo=function(n){return n[n.NoWrap=0]="NoWrap",n[n.Wrap=1]="Wrap",n[n.WrapReverse=2]="WrapReverse",n}({});ne.Wrap=lo;var Yg={ALIGN_AUTO:Zr.Auto,ALIGN_FLEX_START:Zr.FlexStart,ALIGN_CENTER:Zr.Center,ALIGN_FLEX_END:Zr.FlexEnd,ALIGN_STRETCH:Zr.Stretch,ALIGN_BASELINE:Zr.Baseline,ALIGN_SPACE_BETWEEN:Zr.SpaceBetween,ALIGN_SPACE_AROUND:Zr.SpaceAround,DIMENSION_WIDTH:Ml.Width,DIMENSION_HEIGHT:Ml.Height,DIRECTION_INHERIT:eo.Inherit,DIRECTION_LTR:eo.LTR,DIRECTION_RTL:eo.RTL,DISPLAY_FLEX:$l.Flex,DISPLAY_NONE:$l.None,EDGE_LEFT:Cr.Left,EDGE_TOP:Cr.Top,EDGE_RIGHT:Cr.Right,EDGE_BOTTOM:Cr.Bottom,EDGE_START:Cr.Start,EDGE_END:Cr.End,EDGE_HORIZONTAL:Cr.Horizontal,EDGE_VERTICAL:Cr.Vertical,EDGE_ALL:Cr.All,ERRATA_NONE:ha.None,ERRATA_STRETCH_FLEX_BASIS:ha.StretchFlexBasis,ERRATA_ALL:ha.All,ERRATA_CLASSIC:ha.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:io.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:io.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:io.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:da.Column,FLEX_DIRECTION_COLUMN_REVERSE:da.ColumnReverse,FLEX_DIRECTION_ROW:da.Row,FLEX_DIRECTION_ROW_REVERSE:da.RowReverse,GUTTER_COLUMN:ro.Column,GUTTER_ROW:ro.Row,GUTTER_ALL:ro.All,JUSTIFY_FLEX_START:Qs.FlexStart,JUSTIFY_CENTER:Qs.Center,JUSTIFY_FLEX_END:Qs.FlexEnd,JUSTIFY_SPACE_BETWEEN:Qs.SpaceBetween,JUSTIFY_SPACE_AROUND:Qs.SpaceAround,JUSTIFY_SPACE_EVENLY:Qs.SpaceEvenly,LOG_LEVEL_ERROR:Js.Error,LOG_LEVEL_WARN:Js.Warn,LOG_LEVEL_INFO:Js.Info,LOG_LEVEL_DEBUG:Js.Debug,LOG_LEVEL_VERBOSE:Js.Verbose,LOG_LEVEL_FATAL:Js.Fatal,MEASURE_MODE_UNDEFINED:so.Undefined,MEASURE_MODE_EXACTLY:so.Exactly,MEASURE_MODE_AT_MOST:so.AtMost,NODE_TYPE_DEFAULT:Fl.Default,NODE_TYPE_TEXT:Fl.Text,OVERFLOW_VISIBLE:no.Visible,OVERFLOW_HIDDEN:no.Hidden,OVERFLOW_SCROLL:no.Scroll,POSITION_TYPE_STATIC:ao.Static,POSITION_TYPE_RELATIVE:ao.Relative,POSITION_TYPE_ABSOLUTE:ao.Absolute,PRINT_OPTIONS_LAYOUT:oo.Layout,PRINT_OPTIONS_STYLE:oo.Style,PRINT_OPTIONS_CHILDREN:oo.Children,UNIT_UNDEFINED:ua.Undefined,UNIT_POINT:ua.Point,UNIT_PERCENT:ua.Percent,UNIT_AUTO:ua.Auto,WRAP_NO_WRAP:lo.NoWrap,WRAP_WRAP:lo.Wrap,WRAP_WRAP_REVERSE:lo.WrapReverse};ne.default=Yg,Object.defineProperty(Ol,"__esModule",{value:!0}),Ol.default=Zg;var ys=zg(ne);function Fd(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Fd=function(i){return i?e:t})(n)}function zg(n,t){if(!t&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var e=Fd(t);if(e&&e.has(n))return e.get(n);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in n)if(o!=="default"&&Object.prototype.hasOwnProperty.call(n,o)){var c=s?Object.getOwnPropertyDescriptor(n,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=n[o]}return i.default=n,e&&e.set(n,i),i}function Zg(n){function t(s,o,c){const d=s[o];s[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return c.call(this,d,...p)}}for(const s of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[ys.Unit.Point]:n.Node.prototype[s],[ys.Unit.Percent]:n.Node.prototype[`${s}Percent`],[ys.Unit.Auto]:n.Node.prototype[`${s}Auto`]};t(n.Node.prototype,s,function(c){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,b;if(g==="auto")v=ys.Unit.Auto,b=void 0;else if(typeof g=="object")v=g.unit,b=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?ys.Unit.Percent:ys.Unit.Point,b=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(b))throw new Error(`Invalid value ${g} for ${s}`);if(!o[v])throw new Error(`Failed to execute "${s}": Unsupported unit '${g}'`);return b!==void 0?o[v].call(this,...f,b):o[v].call(this,...f)})}function e(s){return n.MeasureCallback.implement({measure:function(){const{width:o,height:c}=s(...arguments);return{width:o??NaN,height:c??NaN}}})}t(n.Node.prototype,"setMeasureFunc",function(s,o){return o?s.call(this,e(o)):this.unsetMeasureFunc()});function i(s){return n.DirtiedCallback.implement({dirtied:s})}return t(n.Node.prototype,"setDirtiedFunc",function(s,o){s.call(this,i(o))}),t(n.Config.prototype,"free",function(){n.Config.destroy(this)}),t(n.Node,"create",(s,o)=>o?n.Node.createWithConfig(o):n.Node.createDefault()),t(n.Node.prototype,"free",function(){n.Node.destroy(this)}),t(n.Node.prototype,"freeRecursive",function(){for(let s=0,o=this.getChildCount();s<o;++s)this.getChild(0).freeRecursive();this.free()}),t(n.Node.prototype,"calculateLayout",function(s){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:ys.Direction.LTR;return s.call(this,o,c,d)}),{Config:n.Config,Node:n.Node,...ys.default}}var Nd={exports:{}};(function(n,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(s){s=s||{};var o;o||(o=typeof s<"u"?s:{});var c,d;o.ready=new Promise(function(_,C){c=_,d=C});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),i&&(p=i),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var b;o.wasmBinary&&(b=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(V/65536*65536)}function k(){}function w(_){this.exports=function(C){function B(ei){return ei.set=function(ce,rr){this[ce]=rr},ei.get=function(ce){return this[ce]},ei}for(var G,it=new Uint8Array(123),vt=25;vt>=0;--vt)it[48+vt]=52+vt,it[65+vt]=vt,it[97+vt]=26+vt;it[43]=62,it[47]=63;function lt(ei,ce,rr){for(var $i,ft,Nr=0,l=ce,At=rr.length,Fn=ce+(At*3>>2)-(rr[At-2]=="=")-(rr[At-1]=="=");Nr<At;Nr+=4)$i=it[rr.charCodeAt(Nr+1)],ft=it[rr.charCodeAt(Nr+2)],ei[l++]=it[rr.charCodeAt(Nr)]<<2|$i>>4,l<Fn&&(ei[l++]=$i<<4|ft>>2),l<Fn&&(ei[l++]=ft<<6|it[rr.charCodeAt(Nr+3)])}function Rt(ei){lt(G,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(G,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(G,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(G,4432,"xwAAAMgAAADJ"),lt(G,4452,"xwAAAMoAAADLAAAArBs="),lt(G,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(G,4552,"zAAAAM0AAADO"),lt(G,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(G,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(G,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(G,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(G,5179,"DA=="),lt(G,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(G,5237,"EA=="),lt(G,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(G,5295,"Eg=="),lt(G,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(G,5362,"GgAAABoaGgAAAAAAAAk="),lt(G,5411,"FA=="),lt(G,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(G,5469,"Fg=="),lt(G,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(G,5556,"1Q=="),lt(G,5596,"//////////8="),lt(G,5664,"8B8BAAAAAAAF"),lt(G,5684,"0A=="),lt(G,5708,"0QAAANIAAADUGw=="),lt(G,5732,"Ag=="),lt(G,5748,"//////////8="),lt(G,5816,"BQ=="),lt(G,5828,"0w=="),lt(G,5852,"0QAAANQAAADoGwAAAAQ="),lt(G,5876,"AQ=="),lt(G,5892,"/////wo="),lt(G,5960,"1g==")}var _t=new ArrayBuffer(16),Ct=new Int32Array(_t),Nt=new Float32Array(_t),Yt=new Float64Array(_t);function te(ei){return Ct[ei]}function xt(ei,ce){Ct[ei]=ce}function Ae(){return Yt[0]}function pi(ei){Yt[0]=ei}function de(){throw new Error("abort")}function Xi(ei){Nt[2]=ei}function Bt(){return Nt[2]}function Zo(ei){var ce=ei.a,rr=ce.a,$i=rr.buffer;rr.grow=t3;var ft=new Int8Array($i),Nr=new Int16Array($i),l=new Int32Array($i),At=new Uint8Array($i),Fn=new Uint16Array($i),Jf=new Uint32Array($i),I=new Float32Array($i),Ne=new Float64Array($i),Ue=Math.imul,m=Math.fround,Ve=Math.abs,mr=Math.clz32,XA=Math.min,qA=Math.max,zt=NaN,tp=1/0,wt=ce.b,Ei=ce.c,as=ce.d,os=ce.e,Ds=ce.f,Nn=ce.g,Ma=ce.h,Xo=ce.i,mh=ce.j,vh=ce.k,yh=ce.l,ep=ce.m,ip=ce.n,rp=ce.o,sp=ce.p,np=ce.q,QA=ce.r,JA=ce.s,tE=ce.t,eE=ce.u,iE=ce.v,rE=ce.w,sE=ce.x,nE=ce.y,aE=ce.z,oE=ce.A,lE=ce.B,cE=ce.C,hE=ce.D,Et=73712,Fi=0;function ap(r,a,h,u,y,A,T,S,P,K,tt,dt,q,et){var O=0,W=m(0),Y=0,X=m(0),nt=0,ot=m(0),pt=0,yt=m(0),Lt=0,Ot=0,$t=m(0),Vt=0,Xt=0,ae=m(0),ge=m(0),_e=m(0),xe=m(0),Pe=0,Be=m(0),We=m(0),ii=0,ri=0,vi=m(0),xi=0,Qi=0,Pi=0,Bi=0,Ji=m(0),tr=0,Rr=0,Lr=0,Hr=0,Wr=m(0),jr=0,Kr=0,ls=0,cs=0,hs=m(0),Ms=0,$s=0,Fs=0,Ns=m(0),Us=0,Bs=m(0),Na=0,Ua=m(0),Ba=m(0),Ga=m(0),Va=0,sl=m(0),Ph=0,Oh=m(0),Mh=m(0),$h=m(0),Fh=m(0),Nh=0,i2=0,r2=0,s2=0,n2=0,a2=0,o2=0,l2=0,je=0,Ke=m(0),Wn=m(0);O=Et-384|0,Et=O;t:{r:{i:{if(!(y&&a!=a)){if(!(A&&h!=h)){if(Y=(P?0:4)+tt|0,l[Y>>2]=l[Y>>2]+1,Y=l[r+24>>2]&3,Ph=(u|0)<=1?1:u,Bi=Y||Ph,ft[r+300|0]=At[r+300|0]&252|Bi&3,Y=r+252|0,u=((Bi|0)!=1)<<3,Ms=(Bi|0)==2?3:2,ot=ue(r,Ms,T),I[Y+u>>2]=ot,nt=Y,Y=((Bi|0)==1)<<3,ge=Se(r,Ms,T),I[nt+Y>>2]=ge,yt=ue(r,0,T),I[r+256>>2]=yt,xe=Se(r,0,T),I[r+264>>2]=xe,nt=r+268|0,je=nt+u|0,Ke=pe(r,Ms),I[je>>2]=Ke,je=Y+nt|0,Ke=Re(r,Ms),I[je>>2]=Ke,W=pe(r,0),I[r+272>>2]=W,Be=Re(r,0),I[r+280>>2]=Be,nt=u,u=r+284|0,je=nt+u|0,Ke=Ie(r,Ms,T),I[je>>2]=Ke,je=u+Y|0,Ke=De(r,Ms,T),I[je>>2]=Ke,X=Ie(r,0,T),I[r+288>>2]=X,$t=De(r,0,T),I[r+296>>2]=$t,ot=m(ot+ge),ge=m(yt+xe),u=l[r+8>>2],u){yt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(A?h-ge:zt),W=m(m(X+$t)+W),X=m(y?a-ot:zt),a=X;e:{if(a!=a)break e;if(a=m(X-yt),a!=a){a=m(0);break e}a=he(a,m(0))}ot=m(W+Be),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=he(W,m(0))}if(!((y|0)!=1|(A|0)!=1)){a=He(r,2,X,T),u=a!=a,W=m(m(Ie(r,2,T)+pe(r,2))+m(De(r,2,T)+Re(r,2)));e:{if(!(u|W!=W)){a=he(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=He(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,T)+pe(r,0))+m(De(r,0,T)+Re(r,0)));e:{if(!(u|h!=h)){a=he(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(At[r+4|0]&16){Pt[u|0](O+24|0,r,a,y,W,A,0);break e}Pt[u|0](O+24|0,r,a,y,W,A)}l[tt+20>>2]=l[tt+20>>2]+1,u=(et<<2)+tt|0,l[u+24>>2]=l[u+24>>2]+1,a=m(yt+I[O+24>>2]),a=He(r,2,y?(y|0)==2?a:X:a,T),u=a!=a,W=m(m(Ie(r,2,T)+pe(r,2))+m(De(r,2,T)+Re(r,2)));e:{if(!(u|W!=W)){a=he(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(ot+I[O+28>>2]),a=He(r,0,A?(A|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,T)+pe(r,0))+m(De(r,0,T)+Re(r,0)));e:{if(!(u|h!=h)){a=he(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=l[r+556>>2],et=l[r+560>>2],(u|0)==(et|0)){ge=m(h-ge),a=He(r,2,y&-3?m(a-ot):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),T),u=a!=a,h=m(m(Ie(r,2,T)+pe(r,2))+m(De(r,2,T)+Re(r,2)));e:{if(!(u|h!=h)){a=he(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=He(r,0,A&-3?ge:m(m(m(X+$t)+W)+Be),S),u=a!=a,h=m(m(Ie(r,0,T)+pe(r,0))+m(De(r,0,T)+Re(r,0)));e:{if(!(u|h!=h)){a=he(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-ot),X=m(h-ge),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(X<=m(0))|(A|0)!=2)&X==X)&((y|0)!=1|(A|0)!=1)))break e;a=He(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,T),u=a!=a,h=m(m(Ie(r,2,T)+pe(r,2))+m(De(r,2,T)+Re(r,2)));s:{if(!(u|h!=h)){a=he(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=He(r,0,X!=X||(A|0)==2&&X<m(0)?m(0):X,S),u=a!=a,h=m(m(Ie(r,0,T)+pe(r,0))+m(De(r,0,T)+Re(r,0)));s:{if(!(u|h!=h)){a=he(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(ii=et-u|0,Hr=ii>>2;Y=l[u>>2],l[Y+552>>2]!=(r|0)&&(nt=l[r+568>>2],Y=Ap(l[nt>>2],At[nt+8|0],Y,r,Lt,0),l[u>>2]=Y,l[Y+552>>2]=r),Lt=Lt+1|0,u=u+4|0,(et|0)!=(u|0););ft[r+300|0]=At[r+300|0]&251,Lt=3,xi=l[r+24>>2],u=xi>>>2&3;e:{s:{n:{if((Bi|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}Lt=2;break e}if(Lt=2,et=0,u>>>0>1)break s}et=Lt}Lt=u}Oh=m(a-ot),Wr=m(m(Ie(r,Lt,T)+pe(r,Lt))+m(De(r,Lt,T)+Re(r,Lt))),Be=m(Ie(r,et,T)+pe(r,et)),Ji=m(Be+m(De(r,et,T)+Re(r,et))),tr=Lt>>>0>1,yt=dp(r,0,Oh,tr?Wr:Ji,T),Mh=m(h-ge),We=dp(r,1,Mh,tr?Ji:Wr,S),xe=tr?We:yt,ge=tr?yt:We,jr=l[r+560>>2],Y=l[r+556>>2],Qi=tr?y:A;e:{if((Qi|0)!=1)break e;if((Y|0)==(jr|0))break i;for(u=Y;;){nt=l[u>>2];s:{if(!Ip(nt))break s;if(Xt=0,pt)break e;n:{a:{if(!l[nt+552>>2]){W=m(0);break a}if(h=I[nt+32>>2],h!=h&&(W=m(0),h=I[nt+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ve(W))<m(9999999747378752e-20))break e}if(a=Vn(nt),a!=a){pt=nt;break s}if(pt=nt,m(Ve(a))<m(9999999747378752e-20))break e}if(Xt=pt,u=u+4|0,(jr|0)==(u|0))break}}if((Y|0)==(jr|0))break i;for(Na=(Bi|0)<=1?1:Bi,$s=yt!=yt,Kr=$s|(y|0)!=1,ls=We==We,Fs=yt==yt,W=m(0);;){Vt=l[Y>>2],hp(Vt),nt=l[Vt+24>>2];e:{if(nt&4194304){if(pp(Vt,0),u=At[Vt+4|0],nt=u|1,ft[Vt+4|0]=nt,!(u&4))break e;ft[Vt+4|0]=nt&251;break e}if(P&&(u=nt&3,Ep(Vt,u||Na,ge,xe,yt),nt=l[Vt+24>>2]),(nt&196608)==131072)break e;s:{if((Vt|0)==(Xt|0)){l[Xt+308>>2]=0,l[Xt+304>>2]=q,h=m(0);break s}cs=l[r+24>>2],u=cs>>>2&3;n:{a:{if((Bi|0)!=2)break a;pt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}pt=2;break n}pt=u}Rr=pt>>>0>1,ot=Rr?yt:We,h=m(0),a=I[Vt+40>>2];n:{a:{Ot=l[Vt+40>>2];o:{if((Ot|0)==2139156720)break o;if((Ot|0)==2140081935)break a;u=4336;l:{if((Ot|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Ot=l[u+4>>2],Ot|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Vt+28>>2]>m(0)))break n;Ot=ft[l[Vt+568>>2]+8|0]&1,u=Ot?2143289344:0,Ot=Ot?3:1,h=(xt(2,u),Bt())}switch(a=m(zt),Ot-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(xt(2,(Ot&-1073741825)+536870912|0),Bt()),!(Ot&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Vt+572>>2],Ot=0;n:{a:switch(Pe=l[Vt+576>>2],Pe|0){case 0:case 3:break n;default:break a}if(X=I[Vt+572>>2],!((Pe|0)!=1|X!=X)){if(h<m(0))break n;Ot=1;break n}if(Ot=1,(Pe|0)!=2|X!=X||(Ot=0,h<m(0)))break n;Ot=Fs}X=I[Vt+580>>2],u=0;n:{a:switch(ri=l[Vt+584>>2],ri|0){case 0:case 3:break n;default:break a}if($t=I[Vt+580>>2],!((ri|0)!=1|$t!=$t)){if(X<m(0))break n;u=1;break n}if(u=1,(ri|0)!=2|$t!=$t||(u=0,X<m(0)))break n;u=ls}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Vt+308>>2],(!(ft[l[Vt+568>>2]+12|0]&1)|l[Vt+304>>2]==(q|0))&h==h)break n;if(h=m(m(Ie(Vt,pt,yt)+pe(Vt,pt))+m(De(Vt,pt,yt)+Re(Vt,pt))),!(h<=a)&a<h)break a;h=a;break a}if(Ot&Rr){X=m(m(Ie(Vt,2,yt)+pe(Vt,2))+m(De(Vt,2,yt)+Re(Vt,2))),a=m(zt);o:switch(Pe-1|0){case 1:h=m(m(yt*h)*m(.009999999776482582));case 0:if(a=h,X<=a)break a;break;default:break o}if(!(a==a|X==X)){h=a;break a}if(a<X){h=X;break a}h=a!=a?X:a;break a}if(!(Rr|u^1)){a=m(m(Ie(Vt,0,yt)+pe(Vt,0))+m(De(Vt,0,yt)+Re(Vt,0))),h=m(zt);o:switch(ri-1|0){case 1:X=m(m(We*X)*m(.009999999776482582));case 0:if(h=X,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(l[O+360>>2]=2143289344,l[O+24>>2]=2143289344,Pi=0,l[O+356>>2]=0,l[O+352>>2]=0,$t=m(ue(Vt,2,yt)+Se(Vt,2,yt)),ae=ue(Vt,0,yt),_e=Se(Vt,0,yt),ot=m(zt),Lr=0,a=m(zt),Ot){o:{l:switch(Pe-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(yt*h)*m(.009999999776482582))}l[O+356>>2]=1,a=m($t+a),I[O+24>>2]=a,Lr=1}if(ae=m(ae+_e),u){h=m(zt);o:{l:switch(ri-1|0){case 0:h=X;break o;case 1:break l;default:break o}h=m(m(We*X)*m(.009999999776482582))}l[O+352>>2]=1,ot=m(ae+h),I[O+360>>2]=ot,Pi=1}Pe=(cs&3145728)==2097152,ri=pt>>>0<2;o:{l:{c:{if(!(Pe&ri)){if(Pe|$s)break l;if(a!=a)break c;break l}if($s|a==a)break o}Lr=2,l[O+356>>2]=2,I[O+24>>2]=yt,a=yt}l:{if(!Pe||ri){if(Pe|We!=We)break o;if(ot!=ot)break l;break o}if(ot==ot|We!=We)break o}Pi=2,l[O+352>>2]=2,I[O+360>>2]=We,ot=We}h=I[Vt+224>>2],Pe=h!=h;o:{if(Pe)break o;l:{if(!(Rr|(Lr|0)!=1)){l[O+352>>2]=1,I[O+360>>2]=ae+m(m(a-$t)/h);break l}if(ri|(Pi|0)!=1)break o;l[O+356>>2]=1,I[O+24>>2]=m(m(ot-ae)*h)+$t}Pi=1,Lr=1}nt=nt>>>13&7,nt=nt||cs>>>10&7;o:{if((nt|0)==5|(Lr|0)==1|(Rr|(Ot|Kr))|(nt|0)!=4||(l[O+356>>2]=1,I[O+24>>2]=yt,Pe))break o;Pi=1,l[O+352>>2]=1,I[O+360>>2]=m(yt-$t)/h}o:{if(ri|(A|0)!=1|We!=We|u|(nt|0)!=4|(Pi|0)==1||(l[O+352>>2]=1,I[O+360>>2]=We,Pe))break o;l[O+356>>2]=1,I[O+24>>2]=m(We-ae)*h}if(Un(Vt,2,yt,yt,O+356|0,O+24|0),Un(Vt,0,We,yt,O+352|0,O+360|0),un(Vt,I[O+24>>2],I[O+360>>2],Bi,l[O+356>>2],l[O+352>>2],yt,We,0,5,K,tt,dt,q),a=I[(Vt+(l[(pt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Vt,pt,yt)+pe(Vt,pt))+m(De(Vt,pt,yt)+Re(Vt,pt))),!(u|h!=h)){h=he(a,h);break a}h=u?h:a}I[Vt+308>>2]=h}l[Vt+304>>2]=q}W=m(W+m(h+m(ue(Vt,Lt,yt)+Se(Vt,Lt,yt))))}if(Y=Y+4|0,(jr|0)==(Y|0))break}break r}l[O>>2]=3072,sr(r,O),qi(),de()}l[O+16>>2]=3154,sr(r,O+16|0),qi(),de()}W=m(0)}a=m(W+m(0)),Ua=tr?S:T,Ns=tr?T:S,ii>>>0>=5&&(a=m(m(qo(r,Lt,xe)*m(Hr-1>>>0))+a)),u=a>ge,jr=xi&786432,ls=(Qi|0)==2&&jr&&u?1:Qi,Vt=tr?A:y,Rr=(Vt|0)==1,i2=Rr&(P^1),tr=Lt>>>0<2,r2=Vt&-3,$s=r+208|0,A=et<<2,ri=A+4288|0,s2=Rr&!jr,n2=(Vt|0)!=1|P,Y=Lt<<2,Lr=Y+4288|0,Fs=Y+4320|0,cs=xe==xe,a2=cs<<1,Pe=A+4320|0,o2=!Qi|!u,Na=O+52|0,$h=qo(r,et,xe),nt=0,u=0,Pi=0;r:{for(;;){Qi=u,Ui(O+24|0,0,44),u=l[r+560>>2],A=l[r+556>>2];i:{if((u|0)==(A|0))break i;if(u=u-A|0,(u|0)<0)break r;if(Y=Fa(O+360|0,u>>2,0,Na),u=l[O+44>>2],A=l[O+48>>2]-u|0,A=xs(l[O+364>>2]-A|0,u,A),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=A,pt=l[O+368>>2],Ot=l[O+372>>2],A=l[O+48>>2],l[O+368>>2]=A,Xt=l[O+52>>2],l[O+48>>2]=pt,l[O+52>>2]=Ot,l[O+372>>2]=Xt,l[Y>>2]=u,(u|0)!=(A|0)&&(l[O+368>>2]=A+((u-A|0)+3&-4)),!u)break i;gi(u)}Xt=l[r+24>>2],u=Xt>>>2&3;i:{e:{if(A=Xt&3,((A||Ph)|0)!=2)break e;pt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}pt=2;break i}pt=u}W=qo(r,pt,yt),Y=nt,Ot=l[r+560>>2],A=l[r+556>>2];i:{if(Y>>>0>=Ot-A>>2>>>0)break i;for(Xt=Xt&786432,h=m(0);;){if(Ot-A>>2>>>0<=Y>>>0)break r;if(u=l[(Y<<2)+A>>2],ii=l[u+24>>2],!(ii&4194304|(ii&196608)==131072)){if(l[u+548>>2]=Qi,a=ue(u,pt,yt),X=Se(u,pt,yt),A=l[O+24>>2],ot=(Y|0)==(nt|0)?m(0):W,a=m(a+X),X=I[u+308>>2],$t=He(u,pt,X,Ns),!(!A||!(m(ot+m(a+m(h+$t)))>ge)|!Xt))break i;if(l[O+24>>2]=A+1,ot=m(ot+m(a+$t)),I[O+28>>2]=ot+I[O+28>>2],Ip(u)){e:{if(!l[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[O+32>>2]=a+I[O+32>>2],je=O,Ke=m(I[O+36>>2]-m(Vn(u)*X)),I[je+36>>2]=Ke}A=l[O+48>>2];e:{if((A|0)!=l[O+52>>2]){l[A>>2]=u,l[O+48>>2]=A+4;break e}if(A=A-l[O+44>>2]|0,ii=A>>2,Ot=ii+1|0,Ot>>>0>=1073741824)break r;if(xi=A>>1,Ot=Fa(O+360|0,A>>>0>=2147483644?1073741823:Ot>>>0<xi>>>0?xi:Ot,ii,Na),l[l[O+368>>2]>>2]=u,l[O+368>>2]=l[O+368>>2]+4,u=l[O+44>>2],A=l[O+48>>2]-u|0,A=xs(l[O+364>>2]-A|0,u,A),u=l[O+44>>2],l[O+364>>2]=u,l[O+44>>2]=A,ii=l[O+368>>2],xi=l[O+372>>2],A=l[O+48>>2],l[O+368>>2]=A,Kr=l[O+52>>2],l[O+48>>2]=ii,l[O+52>>2]=xi,l[O+372>>2]=Kr,l[Ot>>2]=u,(u|0)!=(A|0)&&(l[O+368>>2]=A+((u-A|0)+3&-4)),!u)break e;gi(u)}A=l[r+556>>2],Ot=l[r+560>>2],h=m(h+ot)}if(Y=Y+1|0,!(Y>>>0<Ot-A>>2>>>0))break}}_e=I[O+32>>2],!(_e>m(0))|!(_e<m(1))||(l[O+32>>2]=1065353216,_e=m(1)),vi=I[O+36>>2],!(vi>m(0))|!(vi<m(1))||(l[O+36>>2]=1065353216,vi=m(1)),l[O+40>>2]=Y,$t=I[O+28>>2],pt=l[O+24>>2],Pi&&gi(Pi),X=I[O+56>>2],ii=l[O+48>>2],Pi=l[O+44>>2];i:{e:{s:{n:{if((ls|0)==1)break n;h=m(0),a=I[$s>>2];a:{o:{u=l[$s>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(a==a)break c;A=4344}switch(h=I[A>>2],a=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}a=m(m(h*T)*m(.009999999776482582));break a}a=h}h=m(0),W=I[r+216>>2];a:{o:{u=l[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(W==W)break c;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}W=m(m(h*T)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[r+212>>2];a:{o:{u=l[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;A=4344}switch(h=I[A>>2],ot=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),ae=I[r+220>>2];a:{o:{u=l[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ae==ae)break c;A=4344}switch(h=I[A>>2],ae=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ae=m(m(h*S)*m(.009999999776482582));break a}ae=h}if(u=Lt>>>0>1,h=m((u?a:ot)-Wr),h==h&h>$t||(h=m((u?W:ae)-Wr),h==h&h<$t))break s;if(ft[l[r+568>>2]+16|0]&1)break n;if(h=$t,!l[r+552>>2]|_e==m(0))break e;a=I[r+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[r+28>>2],!(h>m(0)))break a}if(h!=h){h=ge;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=ge,a!=m(0)))break e;h=$t;break e}h=ge}if(h!=h)break e;X=m(h-$t);break i}if(!($t<m(0)))break i;X=m(-$t)}if(ge=h,!i2){i:{if((ii|0)==(Pi|0)){ot=m(0);break i}for(ae=m(0),A=Pi;;){u=l[A>>2],$t=I[u+308>>2],h=He(u,Lt,$t,Ns);e:{if(X<m(0)){if(a=m(h*m(-Vn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(X/vi)*a)+h),a=He(u,Lt,W,ge),Ot=a!=a,ot=m(m(Ie(u,Lt,yt)+pe(u,Lt))+m(De(u,Lt,yt)+Re(u,Lt)));s:{if(!(Ot|ot!=ot)){a=he(a,ot);break s}a=Ot?ot:a}if(W!=W|a!=a|a==W)break e;ae=m(ae+m(a-h)),vi=m(m(Vn(u)*$t)+vi);break e}if(!(X>m(0))|!l[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(X/_e)*W)+h),a=He(u,Lt,ot,ge),Ot=a!=a,$t=m(m(Ie(u,Lt,yt)+pe(u,Lt))+m(De(u,Lt,yt)+Re(u,Lt)));s:{if(!(Ot|$t!=$t)){a=he(a,$t);break s}a=Ot?$t:a}if(ot!=ot|a!=a|a==ot)break e;_e=m(_e-W),ae=m(ae+m(a-h))}if(A=A+4|0,(ii|0)==(A|0))break}for(ae=m(X-ae),Ba=m(ae/vi),Ga=m(ae/_e),Va=Rr&(o2|!(At[r+26|0]&12)),Kr=!Va,xi=l[Pe>>2],ot=m(0),Ot=Pi;;){u=l[Ot>>2],$t=He(u,Lt,I[u+308>>2],Ns);e:{s:{if(ae<m(0)){if(W=$t,a=m(W*m(-Vn(u))),a==m(0))break e;a=vi==m(0)?m($t+a):m(m(Ba*a)+$t);break s}if(W=$t,!(ae>m(0))|!l[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Ga*a)+$t)}if(a=He(u,Lt,a,ge),A=a!=a,h=m(m(Ie(u,Lt,yt)+pe(u,Lt))+m(De(u,Lt,yt)+Re(u,Lt))),!(A|h!=h)){W=he(a,h);break e}W=A?h:a}a=ue(u,Lt,yt),h=Se(u,Lt,yt),_e=ue(u,et,yt),sl=Se(u,et,yt),h=m(a+h),Fh=m(W+h),I[O+352>>2]=Fh,l[O+344>>2]=1,_e=m(_e+sl),a=I[u+224>>2];e:{if(a==a){l[O+348>>2]=1,h=m(Fh-h),I[O+356>>2]=_e+m(tr?h*a:h/a);break e}s:{if(Us=xe!=xe,Us)break s;Xt=(xi<<3)+u|0,a=I[Xt+572>>2];n:{a:{o:{l:switch(A=l[Xt+576>>2],A|0){case 0:case 3:break o;default:break l}if(h=I[Xt+572>>2],(A|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!Va)break s;break n}if(Kr|(!(a<m(0))|((A|0)!=2|h!=h)))break s}if(A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(O+24|0,u,et),l[O+28>>2]==3)||(fn(O+360|0,u,et),l[O+364>>2]==3))break s;l[O+348>>2]=1,I[O+356>>2]=xe;break e}Xt=(xi<<3)+u|0,h=I[Xt+572>>2];s:{n:{a:{o:{l:switch(A=l[Xt+576>>2],A|0){case 0:case 3:break o;default:break l}if(a=I[Xt+572>>2],!((A|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((A|0)!=2|a!=a)break a;if(Us)break o;if(!(h<m(0)))break n}l[O+348>>2]=a2,I[O+356>>2]=xe;break e}a=m(zt);a:switch(A-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(xe*h)*m(.009999999776482582))}a=m(_e+a),I[O+356>>2]=a,l[O+348>>2]=(Rr|(A|0)!=2)&a==a}Un(u,Lt,ge,yt,O+344|0,O+352|0),Un(u,et,xe,yt,O+348|0,O+356|0),Xt=(xi<<3)+u|0,a=I[Xt+572>>2];e:{s:{n:{a:switch(A=l[Xt+576>>2],A|0){case 0:case 3:break n;default:break a}if(h=I[Xt+572>>2],!((A|0)!=1|h!=h)){if(a<m(0))break n;break s}if((A|0)!=2|h!=h)break s;if(a<m(0))break n;if(Xt=0,cs)break e}if(Xt=0,A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(O+24|0,u,et),l[O+28>>2]==3))break e;fn(O+360|0,u,et),Xt=l[O+364>>2]!=3;break e}Xt=0}a=I[O+352>>2],h=I[O+356>>2],A=Lt>>>0>1,_e=A?a:h,a=A?h:a,Us=l[O+344>>2],Nh=l[O+348>>2],l2=A?Us:Nh,Us=A?Nh:Us,A=(Xt^1)&P,un(u,_e,a,At[r+300|0]&3,l2,Us,yt,We,A,A?4:7,K,tt,dt,q),ot=m(ot+m(W-$t)),A=At[r+300|0];e:{s:{if(A&4){Xt=A&251;break s}if(Xt=A&251,A=0,!(At[u+300|0]&4))break e}A=4}if(ft[r+300|0]=A|Xt,Ot=Ot+4|0,(ii|0)==(Ot|0))break}}X=m(X-ot)}u=At[r+300|0],ft[r+300|0]=u&251|(X<m(0)?4:u&4),ae=m(Ie(r,Lt,T)+pe(r,Lt)),Ba=m(De(r,Lt,T)+Re(r,Lt)),$t=qo(r,Lt,T);i:{if(!(!(X>m(0))|(ls|0)!=2)){ot=m(0),h=m(0);e:{s:{u=$s+(l[Fs>>2]<<2)|0,a=I[u>>2],u=l[u>>2],A=(u|0)==2139156720;n:{if(!A){if(Ot=(u|0)==2140081935,Ot)break s;if(Xt=(u|0)==2141891242,Xt|a!=a)break i;if(Ot)break s;if(Xt)break i;if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Ns*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(A)break n;if((u|0)==2140081935)break s;A=4336;a:{if((u|0)!=2141891242){if(a==a)break a;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break s}W=m(m(Ns*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-ae)-Ba)-m(ge-X)),a!=a)break i;ot=he(a,m(0));break i}ot=X}Xt=Y>>>0<=nt>>>0;i:{if(!Xt){for(ii=l[r+556>>2],u=l[r+560>>2]-ii>>2,xi=u>>>0<nt>>>0?nt:u,Ot=0,u=nt;;){if((u|0)==(xi|0))break r;if(A=l[ii+(u<<2)>>2],(l[A+24>>2]&196608)!=131072&&(Kr=O+24|0,pn(Kr,A,Lt),Va=l[O+28>>2],fn(Kr,A,Lt),Ot=(((Va|0)==3)+Ot|0)+(l[O+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(_e=m(0),h=$t,Ot)break i}_e=m(0),Ot=0,h=$t;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:_e=m(ot*m(.5));break i;case 1:_e=ot;break i;case 2:if(pt>>>0<2)break i;h=m($t+m((Ke=m(0),Wn=he(ot,m(0)),je=ot!=ot,(je?Ke:Wn)/m(pt-1>>>0))));break i;case 4:_e=m(ot/m(pt+1>>>0)),h=m($t+_e);break i;case 3:break e;default:break i}_e=m(m(ot*m(.5))/m(pt>>>0)),h=m(m(_e+_e)+$t)}if(a=m(ae+_e),X=m(0),ii=Tp(r),Xt)h=m(0);else{for(xi=Y-1|0,Ga=m(ot/m(Ot|0)),ae=m(0),W=m(0),u=nt;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=u>>>0)break r;A=l[A+(u<<2)>>2],pt=A+228|0,Ni(O+24|0,pt,320),h=m(h-((u|0)==(xi|0)?$t:m(0))),Ot=l[A+24>>2];i:{if(Ot&4194304)break i;e:{if((Ot&196608)==131072){if(!nr(A,Lt))break e;if(!P)break i;ot=Ps(A,Lt,ge),vi=pe(r,Lt),sl=ue(A,Lt,yt),I[pt+(l[Lr>>2]<<2)>>2]=sl+m(ot+vi);break i}if(pn(O+360|0,A,Lt),a=m(a+(l[O+364>>2]==3?Ga:m(-0))),P&&(Ot=pt,pt=l[Lr>>2]<<2,I[Ot+pt>>2]=a+I[pt+(O+24|0)>>2]),fn(O+360|0,A,Lt),a=m(a+(l[O+364>>2]==3?Ga:m(-0))),!n2){a=m(a+m(m(h+m(ue(A,Lt,yt)+Se(A,Lt,yt)))+I[O+104>>2])),X=xe;break i}if(pt=A+516|0,a=m(a+m(h+m(I[pt+(l[Fs>>2]<<2)>>2]+m(ue(A,Lt,yt)+Se(A,Lt,yt))))),ii){ot=Qo(A),vi=ue(A,0,yt),ot=m(ot+vi),vi=m(m(I[A+520>>2]+m(ue(A,0,yt)+Se(A,0,yt)))-ot),A=ae!=ae;s:{if(!(A|ot!=ot)){ae=he(ae,ot);break s}ae=A?ot:ae}if(A=W!=W,!(A|vi!=vi)){W=he(W,vi);break i}W=A?vi:W;break i}if(ot=m(I[pt+(l[Pe>>2]<<2)>>2]+m(ue(A,et,yt)+Se(A,et,yt))),A=X!=X,!(ot!=ot|A)){X=he(X,ot);break i}X=A?ot:X;break i}if(!P)break i;A=l[Lr>>2]<<2,ot=I[A+(O+24|0)>>2],je=A+pt|0,Ke=m(_e+m(ot+pe(r,Lt))),I[je>>2]=Ke}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+ae)}if(X=ii?h:X,ot=xe,!r2){h=He(r,et,m(Ji+X),Ua),u=h!=h,W=m(m(Ie(r,et,T)+pe(r,et))+m(De(r,et,T)+Re(r,et)));i:{if(!(u|W!=W)){h=he(h,W);break i}h=u?W:h}ot=m(h-Ji)}h=He(r,et,m(Ji+(s2?xe:X)),Ua),u=h!=h,W=m(m(Ie(r,et,T)+pe(r,et))+m(De(r,et,T)+Re(r,et)));i:{if(!(u|W!=W)){h=he(h,W);break i}h=u?W:h}if(W=m(h-Ji),!(Xt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=nt>>>0)break r;pt=l[u+(nt<<2)>>2],u=l[pt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!nr(pt,et)){A=l[ri>>2];break e}if(h=Ps(pt,et,xe),X=pe(r,et),$t=ue(pt,et,yt),A=l[ri>>2],h=m($t+m(h+X)),I[(pt+(A<<2)|0)+228>>2]=h,h==h)break i}je=pt+(A<<2)|0,Ke=m(pe(r,et)+ue(pt,et,yt)),I[je+228>>2]=Ke;break i}A=u>>>13&7,A||(A=l[r+24>>2]>>>10&7);e:{s:{if((A|0)==5){A=l[r+24>>2]&8?5:1;break s}if((A|0)!=4||(pn(O+24|0,pt,et),A=4,l[O+28>>2]==3)||(fn(O+360|0,pt,et),l[O+364>>2]==3))break s;A=pt+(l[Pe>>2]<<3)|0,X=I[A+572>>2];n:{a:switch(u=l[A+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[A+572>>2],!((u|0)!=1|$t!=$t)){if(h=Be,X<m(0))break n;break e}if(h=Be,cs&!(X<m(0))|((u|0)!=2|$t!=$t))break e}X=I[(pt+(l[Fs>>2]<<2)|0)+516>>2],h=W,$t=I[pt+224>>2],$t==$t&&(h=m(m(ue(pt,et,yt)+Se(pt,et,yt))+m(tr?X*$t:X/$t))),I[O+360>>2]=h,je=O,Ke=m(X+m(ue(pt,Lt,yt)+Se(pt,Lt,yt))),I[je+24>>2]=Ke,l[O+356>>2]=1,l[O+352>>2]=1,Un(pt,Lt,ge,yt,O+356|0,O+24|0),Un(pt,et,xe,yt,O+352|0,O+360|0),X=I[O+360>>2],$t=I[O+24>>2],u=Lt>>>0>1,h=u?X:$t,X=u?$t:X,u=(jr|0)!=0&(l[r+24>>2]&896)!=512,un(pt,X,h,Bi,!(u&tr|X!=X),(!u|tr)&h==h,yt,We,1,2,K,tt,dt,q),h=Be;break e}h=I[(pt+(l[Pe>>2]<<2)|0)+516>>2],X=ue(pt,et,yt),$t=Se(pt,et,yt),pn(O+24|0,pt,et),X=m(ot-m(h+m(X+$t)));s:{if(l[O+28>>2]!=3||(fn(O+360|0,pt,et),l[O+364>>2]!=3))break s;h=m(X*m(.5)),h=m(Be+(Ke=m(0),Wn=he(h,m(0)),je=h!=h,je?Ke:Wn));break e}if(fn(O+24|0,pt,et),h=Be,l[O+28>>2]==3)break e;if(pn(O+24|0,pt,et),l[O+28>>2]==3){h=m(Be+(Ke=m(0),Wn=he(X,m(0)),je=X!=X,je?Ke:Wn));break e}s:switch(A-1|0){case 1:h=m(Be+m(X*m(.5)));break e;case 0:break e;default:break s}h=m(Be+X)}u=pt+(l[ri>>2]<<2)|0,I[u+228>>2]=h+m(hs+I[u+228>>2])}if(nt=nt+1|0,(nt|0)==(Y|0))break}h=m((Qi?$h:m(0))+W),u=Bs!=Bs,a=m(Ba+a);i:{if(!(u|a!=a)){Bs=he(Bs,a);break i}Bs=u?a:Bs}if(hs=m(hs+h),u=Qi+1|0,nt=Y,!(Hr>>>0>Y>>>0))break}i:{if(!P||!jr&&!Tp(r))break i;ae=m(0);e:{s:{if(xe!=xe)break s;a=m(xe-hs);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:Be=m(Be+m(a*m(.5)));break s;case 2:if(!(xe>hs))break s;ae=m(a/m(u>>>0));break s;case 5:if(xe>hs){if(Be=m(Be+m(a/m(u<<1>>>0))),u>>>0<2)break s;ae=m(a/m(u>>>0));break e}Be=m(Be+m(a*m(.5)));break s;case 4:if(!(xe>hs)|u>>>0<2)break s;ae=m(a/m(Qi>>>0));break e;case 1:break n;default:break s}Be=m(Be+a)}if(!u)break i}for(Ot=0,u=0,A=0;;){if(X=m(0),h=m(0),a=m(0),W=m(0),Y=u,Hr>>>0>u>>>0){e:{for(;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=Y>>>0)break r;nt=l[A+(Y<<2)>>2],pt=l[nt+24>>2];s:{if(pt&4194304|(pt&196608)==131072)break s;if(A=Y,l[nt+548>>2]!=(Ot|0))break e;a=I[(nt+(l[Pe>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(A=h!=h,a=m(a+m(ue(nt,et,yt)+Se(nt,et,yt))),!(A|a!=a)){h=he(h,a);break n}h=A?a:h}if(A=pt>>>13&7,A||(A=l[r+24>>2]>>>10&7),!(At[r+24|0]&8)|(A|0)!=5)break s;a=Qo(nt),ot=ue(nt,0,yt),a=m(a+ot),ot=m(m(I[nt+520>>2]+m(ue(nt,0,yt)+Se(nt,0,yt)))-a),A=h!=h,nt=W!=W;n:{if(!(nt|a!=a)){W=he(W,a);break n}W=nt?a:W}nt=X!=X;n:{if(!(nt|ot!=ot)){X=he(X,ot);break n}X=nt?ot:X}if(a=m(W+X),!(A|a!=a)){h=he(h,a);break s}h=A?a:h}if(Y=Y+1|0,(Hr|0)==(Y|0))break}A=Hr}a=h}if(ot=m(Be+(Ot?$h:m(0))),h=m(ae+a),Be=m(ot+h),u>>>0<A>>>0)for($t=m(ot+W);;){if(Y=l[r+556>>2],l[r+560>>2]-Y>>2>>>0<=u>>>0)break r;nt=l[Y+(u<<2)>>2],Y=l[nt+24>>2];e:{if(Y&4194304|(Y&196608)==131072)break e;Y=Y>>>13&7,Y||(Y=l[r+24>>2]>>>10&7);s:{n:switch(Y-1|0){case 4:if(At[r+24|0]&8)break s;case 0:a=ue(nt,et,yt),I[(nt+(l[ri>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=Se(nt,et,yt),Y=nt+228|0,I[Y+(l[ri>>2]<<2)>>2]=m(Be-a)-I[(Y+(l[Pe>>2]<<2)|0)+288>>2];break e;case 1:Y=nt+228|0,I[Y+(l[ri>>2]<<2)>>2]=ot+m(m(h-I[(Y+(l[Pe>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=ue(nt,et,yt),I[(nt+(l[ri>>2]<<2)|0)+228>>2]=ot+a,pt=nt+(l[Pe>>2]<<3)|0,a=I[pt+572>>2];n:{a:switch(Y=l[pt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[pt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(cs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(Lt>>>0>=2){X=h,a=I[nt+516>>2],W=m(a+m(ue(nt,Lt,yt)+Se(nt,Lt,yt)));break n}X=m(I[nt+520>>2]+m(ue(nt,et,yt)+Se(nt,et,yt))),a=I[nt+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ve(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[nt+520>>2],Y=a!=a,!(Y|X!=X)){if(!(m(Ve(m(X-a)))<m(9999999747378752e-20)))break n;break e}if(X==X)break n;if(Y)break e}un(nt,W,X,Bi,1,1,yt,We,1,3,K,tt,dt,q);break e}je=nt,Ke=m(m($t-Qo(nt))+Ps(nt,0,xe)),I[je+232>>2]=Ke}if(u=u+1|0,(A|0)==(u|0))break}if(Y=(Ot|0)!=(Qi|0),Ot=Ot+1|0,u=A,!Y)break}}pt=r+516|0,a=He(r,2,Oh,T),u=a!=a,h=m(m(Ie(r,2,T)+pe(r,2))+m(De(r,2,T)+Re(r,2)));i:{if(!(u|h!=h)){a=he(a,h);break i}a=u?h:a}I[pt>>2]=a,a=He(r,0,Mh,S),u=a!=a,h=m(m(Ie(r,0,T)+pe(r,0))+m(De(r,0,T)+Re(r,0)));i:{if(!(u|h!=h)){a=he(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(ls&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(ls|0)!=2))break s;if(a=He(r,Lt,Bs,Ns),u=a!=a,h=m(m(Ie(r,Lt,T)+pe(r,Lt))+m(De(r,Lt,T)+Re(r,Lt))),!(u|h!=h)){a=he(a,h);break e}a=u?h:a;break e}if((ls|0)!=2|(u|0)!=2)break i;h=m(Wr+ge),u=h!=h,a=He(r,Lt,Bs,Ns);s:{if(!(u|a!=a)){a=Lh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Wr!=Wr)){a=he(a,Wr);break e}a=u?Wr:a}I[pt+(l[Fs>>2]<<2)>>2]=a}i:{e:{s:{if(Vt&&(A=(Vt|0)!=2,u=l[r+24>>2]>>>20&3,A|(u|0)==2))break s;if(a=He(r,et,m(Ji+hs),Ua),u=a!=a,h=m(m(Ie(r,et,T)+pe(r,et))+m(De(r,et,T)+Re(r,et))),!(u|h!=h)){a=he(a,h);break e}a=u?h:a;break e}if(A|(u|0)!=2)break i;h=m(Ji+xe),u=h!=h,a=He(r,et,m(Ji+hs),Ua);s:{if(!(u|a!=a)){a=Lh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Ji!=Ji)){a=he(a,Ji);break e}a=u?Ji:a}I[pt+(l[Pe>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(A=Hr>>>0<=1?1:Hr,P=l[r+556>>2],nt=l[r+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<nt>>>0?l[P+(u<<2)>>2]:Y,(l[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Ot=Y+(l[ri>>2]<<2)|0,Xt=l[Pe>>2]<<2,I[Ot>>2]=m(I[Xt+pt>>2]-I[Ot>>2])-I[(Y+Xt|0)+288>>2]),u=u+1|0,(A|0)!=(u|0););if(A=l[r+556>>2],P=l[r+560>>2],(A|0)!=(P|0))for(Ot=((Lt>>>0>1?ls:y)|0)!=0;;){y=l[A>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=yt,ge=We,At[l[r+568>>2]+12|0]&2&&(ge=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Bi|0)==2){nt=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(nt=0,u>>>0<=1)break n;Y=u;break s}Y=u,nt=Ms}S=m(ue(y,2,W)+Se(y,2,W)),T=ue(y,0,W),X=Se(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=l[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(zt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(zt),!nr(y,2)||!el(y,2))break s;if(a=He(y,2,m(m(I[r+516>>2]-m(pe(r,2)+Re(r,2)))-m(Ps(y,2,W)+$a(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+pe(y,2))+m(De(y,2,W)+Re(y,2))),!(u|h!=h)){h=he(a,h);break s}h=u?h:a}X=m(T+X);s:{n:{a:{o:{l:{c:{h:{Xt=h!=h,T=I[y+580>>2];f:{d:{p:switch(u=l[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=T,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(ge!=ge|T<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=T;break p}a=m(m(ge*T)*m(.009999999776482582))}a=m(X+a);break f}d:{if(nr(y,0)&&el(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=He(y,0,m(m(I[r+520>>2]-m(pe(r,0)+Re(r,0)))-m(Ps(y,0,ge)+$a(y,0,ge))),ge),u=a!=a,T=m(m(Ie(y,0,W)+pe(y,0))+m(De(y,0,W)+Re(y,0))),!(u|T!=T)){a=he(a,T);break f}a=u?T:a}if((Xt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-X)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(X+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Xt=W>m(0),Qi=u&Ot&Y>>>0<2,h=Qi&&Xt?W:h,u=u^1,un(y,h,a,Bi,Qi&&Xt?2:u,a==a,h,a,0,6,K,tt,dt,q),h=m(I[y+516>>2]+Kp(y,2,W)),a=m(I[y+520>>2]+Kp(y,0,W))}un(y,h,a,Bi,1,1,h,a,1,1,K,tt,dt,q);s:{n:{a:{if(!el(y,Y)||nr(y,Y))break a;u=l[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?ge:W,a=m(m(m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])-Re(r,Y))-Se(y,Y,a))-$a(y,Y,a));break n}if(!(nr(y,Y)|(l[r+24>>2]&112)!=16)){u=l[(Y<<2)+4320>>2]<<2,a=m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(nr(y,Y)|(l[r+24>>2]&112)!=32)){u=l[(Y<<2)+4320>>2]<<2,a=m(I[u+pt>>2]-I[(u+y|0)+516>>2]);break n}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,Y))break s;a=I[pt+(l[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Ps(y,Y,a)+pe(r,Y))+ue(y,Y,a))}I[(y+(l[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!el(y,nt)||nr(y,nt))break n;u=l[(nt<<2)+4320>>2]<<2,a=Y>>>0<2?W:ge,a=m(m(m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])-Re(r,nt))-Se(y,nt,a))-$a(y,nt,a));break s}n:{if(nr(y,nt)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(nt<<2)+4320>>2]<<2,a=m(m(I[u+pt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(nr(y,nt))break n;Y=l[y+24>>2]>>>13&7,u=l[r+24>>2],Y=Y||u>>>10&7;a:{if((Y|0)==5){if((u&786432)==524288)break a;break n}if(((Y|0)==3|0)==((u&786432)==524288|0))break n}u=l[(nt<<2)+4320>>2]<<2,a=m(I[u+pt>>2]-I[(u+y|0)+516>>2]);break s}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,nt))break e;a=I[pt+(l[(nt<<2)+4320>>2]<<2)>>2],a=m(m(Ps(y,nt,a)+pe(r,nt))+ue(y,nt,a))}I[(y+(l[(nt<<2)+4288>>2]<<2)|0)+228>>2]=a}if(A=A+4|0,(P|0)==(A|0))break}if(!((et|Lt)&1))break i;for(A=et&1,P=Lt&1,K=Hr>>>0<=1?1:Hr,tt=(et<<2)+4304|0,dt=(Lt<<2)+4304|0,q=l[r+556>>2],et=l[r+560>>2]-q>>2,r=0;;){if((r|0)==(et|0))break r;u=l[q+(r<<2)>>2];e:{if(At[u+26|0]&64||(P&&(y=u+228|0,Y=l[Fs>>2]<<2,I[y+(l[dt>>2]<<2)>>2]=m(I[Y+pt>>2]-I[(y+Y|0)+288>>2])-I[y+(l[Lr>>2]<<2)>>2]),!A))break e;u=u+228|0,y=l[Pe>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+pt>>2]-I[(u+y|0)+288>>2])-I[u+(l[ri>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Pi)break t;gi(Pi);break t}Ds(),de()}Et=O+384|0}function op(){var r=0,a=0;Nn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7032,2922,6,4368,4392,19,r|0,1),Nn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ht(4),l[r>>2]=24,wt(7036,2359,2,4400,4408,25,r|0,0),as(7032,1398,2,4412,4420,26,27),as(7032,3027,3,4500,4512,28,29),Nn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7056,3293,2,4520,4408,32,r|0,1),Nn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ht(4),l[r>>2]=37,wt(7059,2359,2,4528,4408,38,r|0,0),as(7056,1398,2,4536,4420,39,40),as(7056,3027,3,4500,4512,28,41),Nn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),sp(7062,1,4584,4352,44,45),as(7062,2915,1,4584,4352,44,45),as(7062,1129,2,4588,4408,46,47),r=ht(8),l[r+4>>2]=0,l[r>>2]=48,wt(7062,3234,4,4608,4624,49,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=50,wt(7062,1981,3,4632,4644,51,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=52,wt(7062,1952,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=54,wt(7062,3389,3,4672,4664,55,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=56,wt(7062,1800,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=57,wt(7062,3264,3,4684,4512,58,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=59,wt(7062,1926,2,4696,4420,60,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=61,wt(7062,3399,2,4704,4420,62,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=63,wt(7062,1785,2,4696,4420,60,r|0,0),yh(7065,1271,4712,64,4357,65),Hn(1732,0),Hn(1612,8),Hn(2145,16),Hn(2455,24),Hn(2561,32),Hn(1618,40),vh(7065),yh(7035,2898,4712,66,4357,67),Fp(2561,0),Fp(1618,8),vh(7035),yh(7066,2909,4712,68,4357,69),r=ht(4),l[r>>2]=8,a=ht(4),l[a>>2]=8,Xo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ht(4),l[r>>2]=0,a=ht(4),l[a>>2]=0,Xo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),vh(7066),Nn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),sp(7067,1,4724,4352,76,77),as(7067,1593,1,4724,4352,76,77),as(7067,2851,2,4728,4420,78,79),as(7067,1129,2,4736,4408,80,81),r=ht(8),l[r+4>>2]=0,l[r>>2]=82,wt(7067,1753,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=84,wt(7067,3005,3,4744,4664,85,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=86,wt(7067,2930,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=88,wt(7067,2335,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=90,wt(7067,1485,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=91,wt(7067,1356,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=92,wt(7067,1818,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=93,wt(7067,2872,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=94,wt(7067,2379,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=95,wt(7067,2164,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=96,wt(7067,1320,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=97,wt(7067,2413,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=98,wt(7067,1504,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=99,wt(7067,2236,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=100,wt(7067,1220,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=101,wt(7067,1137,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=102,wt(7067,1159,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=104,wt(7067,1846,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=105,wt(7067,1465,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=106,wt(7067,2219,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=107,wt(7067,1196,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=108,wt(7067,2501,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=109,wt(7067,2591,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=110,wt(7067,1540,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=111,wt(7067,2250,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=112,wt(7067,1651,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=113,wt(7067,1428,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=114,wt(7067,2205,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=115,wt(7067,2609,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=116,wt(7067,1556,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=117,wt(7067,1671,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=118,wt(7067,1445,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=119,wt(7067,2567,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=120,wt(7067,1521,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=121,wt(7067,1625,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=122,wt(7067,1408,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=123,wt(7067,2305,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=124,wt(7067,2093,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=125,wt(7067,2719,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=126,wt(7067,1575,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=127,wt(7067,2188,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=128,wt(7067,2946,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=130,wt(7067,2347,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=132,wt(7067,1372,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=133,wt(7067,1832,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=134,wt(7067,2885,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=135,wt(7067,2396,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=136,wt(7067,2176,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=137,wt(7067,1338,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=138,wt(7067,2423,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=139,wt(7067,1859,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=141,wt(7067,1208,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=143,wt(7067,2515,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=144,wt(7067,2600,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=145,wt(7067,1661,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=146,wt(7067,2621,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=147,wt(7067,1684,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=148,wt(7067,2579,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=149,wt(7067,1638,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=150,wt(7067,2320,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=151,wt(7067,2103,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=153,wt(7067,1232,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=154,wt(7067,1148,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=155,wt(7067,2730,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=156,wt(7067,2195,3,4860,4872,157,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=158,wt(7067,3034,4,4880,4624,159,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=160,wt(7067,3055,3,4896,4664,161,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=162,wt(7067,1293,2,4908,4420,163,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=164,wt(7067,1388,2,4916,4420,165,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=166,wt(7067,3046,3,4924,4512,167,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=168,wt(7067,2962,2,4936,4420,169,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=170,wt(7067,2982,3,4944,4664,171,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=172,wt(7067,3357,3,4956,4664,173,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=174,wt(7067,3355,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=175,wt(7067,3374,3,4968,4664,176,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=177,wt(7067,3372,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=178,wt(7067,1119,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=179,wt(7067,1111,2,4980,4420,180,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=181,wt(7067,1244,5,4992,5012,182,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=183,wt(7067,1737,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=184,wt(7067,1715,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=185,wt(7067,2149,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=186,wt(7067,2462,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=187,wt(7067,2633,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=188,wt(7067,1697,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=189,wt(7067,1260,2,5020,4420,190,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=191,wt(7067,2433,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=192,wt(7067,2113,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=193,wt(7067,2741,3,4840,4852,152,r|0,0)}function dE(r,a,h,u,y,A){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,A=A|0;var T=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,X=0,nt=0,ot=0,pt=0,yt=0,Lt=0,Ot=0,$t=0;q=Et-560|0,Et=q,l[q+44>>2]=0,pi(+a),T=te(1)|0,te(0)|0;t:{if((T|0)<0){nt=1,Ot=1177,a=-a,pi(+a),T=te(1)|0,te(0)|0;break t}if(y&2048){nt=1,Ot=1180;break t}nt=y&1,Ot=nt?1183:1178,$t=!nt}t:{if((T&2146435072)==2146435072){T=nt+3|0,mi(r,32,h,T,y&-65537),hi(r,Ot,nt),u=A&32,hi(r,a!=a?u?2451:3459:u?2868:3463,3),mi(r,32,h,T,y^8192),et=(h|0)<(T|0)?T:h;break t}pt=q+16|0;r:{i:{e:{if(a=Rp(a,q+44|0),a=a+a,a!=0){if(T=l[q+44>>2],l[q+44>>2]=T-1,yt=A|32,(yt|0)!=97)break e;break r}if(yt=A|32,(yt|0)==97)break r;tt=l[q+44>>2],dt=(u|0)<0?6:u;break i}tt=T-29|0,l[q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(Y=(q+48|0)+((tt|0)>=0?288:0)|0,S=Y;a<4294967296&a>=0?u=~~a>>>0:u=0,l[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((tt|0)<=0){u=tt,T=S,P=Y;break i}for(P=Y,u=tt;;){O=(u|0)>=29?29:u,T=S-4|0;e:{if(P>>>0>T>>>0)break e;for(u=0;K=l[T>>2],Lt=u,u=O&31,(O&63)>>>0>=32?(et=K<<u,u=0):(et=(1<<u)-1&K>>>32-u,u=K<<u),Lt=Lt+u|0,K=et+W|0,u=fp(Lt,u>>>0>Lt>>>0?K+1|0:K,1e9),K=Rh(u,Fi,-1e9,0)+Lt|0,l[T>>2]=K,T=T-4|0,P>>>0<=T>>>0;);if(!u)break e;P=P-4|0,l[P>>2]=u}for(;T=S,P>>>0<T>>>0&&(S=T-4|0,!l[S>>2]););if(u=l[q+44>>2]-O|0,l[q+44>>2]=u,S=T,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(yt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(T>>>0<=P>>>0){S=l[P>>2];break i}for(O=1e9>>>et|0,K=-1<<et^-1,u=0,S=P;Lt=u,u=l[S>>2],l[S>>2]=Lt+(u>>>et|0),u=Ue(O,u&K),S=S+4|0,S>>>0<T>>>0;);if(S=l[P>>2],!u)break i;l[T>>2]=u,T=T+4|0}if(u=et+l[q+44>>2]|0,l[q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,T=T-S>>2>(ot|0)?S+(ot<<2)|0:T,!((u|0)<0))break}u=0;i:{if(T>>>0<=P>>>0||(u=Ue(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}if(S=(dt-((yt|0)!=102?u:0)|0)-((yt|0)==103&(dt|0)!=0)|0,(S|0)<(Ue(T-Y>>2,9)-9|0)){if(O=S+9216|0,K=(O|0)/9|0,tt=((((tt|0)<0?4:292)+q|0)+(K<<2)|0)-4048|0,S=10,et=O+Ue(K,-9)|0,(et|0)<=7)for(;S=Ue(S,10),et=et+1|0,(et|0)!=8;);O=l[tt>>2],ot=(O>>>0)/(S>>>0)|0,W=Ue(ot,S),K=tt+4|0;i:{if((O|0)==(W|0)&(K|0)==(T|0))break i;O=O-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(ft[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(X=(T|0)==(K|0)?1:1.5,K=S>>>1|0,X=K>>>0>O>>>0?.5:(K|0)==(O|0)?X:1.5,At[Ot|0]!=45|$t||(X=-X,a=-a),l[tt>>2]=W,a+X==a)break i;if(u=S+W|0,l[tt>>2]=u,u>>>0>=1e9)for(;l[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,l[P>>2]=0),u=l[tt>>2]+1|0,l[tt>>2]=u,u>>>0>999999999;);if(u=Ue(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}S=tt+4|0,T=T>>>0>S>>>0?S:T}for(;K=T,O=T>>>0<=P>>>0,!O&&(T=K-4|0,!l[T>>2]););i:{if((yt|0)!=103){tt=y&8;break i}if(S=dt||1,T=(S|0)>(u|0)&(u|0)>-5,dt=(T?u^-1:-1)+S|0,A=(T?-1:-2)+A|0,tt=y&8,tt)break i;T=-9;e:{if(O||(tt=l[K-4>>2],!tt)||(et=10,T=0,(tt>>>0)%10|0))break e;for(;S=T,T=T+1|0,et=Ue(et,10),!((tt>>>0)%(et>>>0)|0););T=S^-1}if(S=Ue(K-Y>>2,9),(A&-33)==70){tt=0,T=(T+S|0)-9|0,T=(T|0)>0?T:0,dt=(T|0)>(dt|0)?dt:T;break i}tt=0,T=((u+S|0)+T|0)-9|0,T=(T|0)>0?T:0,dt=(T|0)>(dt|0)?dt:T}if(et=-1,O=tt|dt,((O?2147483645:2147483646)|0)<(dt|0))break t;W=(((O|0)!=0)+dt|0)+1|0,S=A&-33;i:{if((S|0)==70){if((W^2147483647)<(u|0))break t;T=(u|0)>0?u:0;break i}if(T=u>>31,T=Bn((T^u)-T|0,0,pt),(pt-T|0)<=1)for(;T=T-1|0,ft[T|0]=48,(pt-T|0)<2;);if(ot=T-2|0,ft[ot|0]=A,ft[T-1|0]=(u|0)<0?45:43,T=pt-ot|0,(T|0)>(W^2147483647))break t}if(u=T+W|0,(u|0)>(nt^2147483647))break t;W=u+nt|0,mi(r,32,h,W,y),hi(r,Ot,nt),mi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(A=q+16|0,u=A|8,tt=A|9,S=P>>>0>Y>>>0?Y:P,P=S;;){T=Bn(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(q+16>>>0>=T>>>0)break n;for(;T=T-1|0,ft[T|0]=48,q+16>>>0<T>>>0;);break n}if((T|0)!=(tt|0))break n;ft[q+24|0]=48,T=u}if(hi(r,T,tt-T|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if(O&&hi(r,4275,1),(dt|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(T=Bn(l[P>>2],0,tt),T>>>0>q+16>>>0)for(;T=T-1|0,ft[T|0]=48,q+16>>>0<T>>>0;);if(hi(r,T,(dt|0)>=9?9:dt),T=dt-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=T,!u)break}break e}n:{if((dt|0)<0)break n;for(Y=P>>>0<K>>>0?K:P+4|0,A=q+16|0,u=A|8,K=A|9,S=P;;){T=Bn(l[S>>2],0,K),(K|0)==(T|0)&&(ft[q+24|0]=48,T=u);a:{if((S|0)!=(P|0)){if(q+16>>>0>=T>>>0)break a;for(;T=T-1|0,ft[T|0]=48,q+16>>>0<T>>>0;);break a}if(hi(r,T,1),T=T+1|0,!(tt|dt))break a;hi(r,4275,1)}if(A=K-T|0,hi(r,T,(A|0)>(dt|0)?dt:A),dt=dt-A|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}mi(r,48,dt+18|0,18,0),hi(r,ot,pt-ot|0);break i}T=dt}mi(r,48,T+9|0,9,0)}mi(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(A<<26>>31&9)+Ot|0;r:{if(u>>>0>11)break r;for(T=12-u|0,X=16;X=X*16,T=T-1|0,!!T;);if(At[tt|0]==45){a=-(X+(-a-X));break r}a=a+X-X}for(Y=nt|2,P=A&32,S=l[q+44>>2],T=S>>31,T=Bn((T^S)-T|0,0,pt),(pt|0)==(T|0)&&(ft[q+15|0]=48,T=q+15|0),dt=T-2|0,ft[dt|0]=A+15,ft[T-1|0]=(S|0)<0?45:43,T=y&8,S=q+16|0;A=S,Ve(a)<2147483648?K=~~a:K=-2147483648,ft[S|0]=P|At[K+5504|0],a=(a-+(K|0))*16,S=A+1|0,!(T|(u|0)>0)&a==0|(S-(q+16|0)|0)!=1||(ft[A+1|0]=46,S=A+2|0),a!=0;);if(et=-1,T=pt-dt|0,A=T+Y|0,(2147483645-A|0)<(u|0))break t;r:{i:{if(!u||(P=S-(q+16|0)|0,(P-2|0)>=(u|0)))break i;u=u+2|0;break r}P=S-(q+16|0)|0,u=P}A=u+A|0,mi(r,32,h,A,y),hi(r,tt,Y),mi(r,48,h,A,y^65536),hi(r,q+16|0,P),mi(r,48,u-P|0,0,0),hi(r,dt,T),mi(r,32,h,A,y^8192),et=(h|0)<(A|0)?A:h}return Et=q+560|0,et|0}function lp(r,a,h,u,y,A,T){var S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,X=0,nt=0,ot=0,pt=0,yt=0,Lt=0,Ot=0,$t=0,Vt=0,Xt=0;K=Et-80|0,Et=K,l[K+76>>2]=a,$t=K+55|0,ot=K+56|0;t:{r:{i:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=At[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(At[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=At[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Ot=W^2147483647,(S|0)>(Ot|0))break e;if(r&&hi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,X=-1,P=ft[a+1|0],!rl(P)|At[a+2|0]!=36||(X=P-48|0,pt=1,S=a+3|0),l[K+76>>2]=S,O=0,P=ft[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,l[K+76>>2]=dt,O=a|O,P=ft[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=ft[dt+1|0];h:{if(!(!rl(a)|At[dt+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,pt=1,Y=l[((ft[dt+1|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(P=dt+1|0,!r){l[K+76>>2]=P,pt=0,Y=0;break c}a=l[h>>2],l[h>>2]=a+4,pt=0,Y=l[a>>2]}if(l[K+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,O=O|8192;break c}if(Y=Dp(K+76|0),(Y|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(At[P|0]!=46){a=P,nt=0;break c}if(At[P+1|0]==42){a=ft[P+2|0];h:{if(!(!rl(a)|At[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((ft[P+2|0]<<3)+u|0)-384>>2];break h}if(pt)break o;if(a=P+2|0,et=0,!r)break h;P=l[h>>2],l[h>>2]=P+4,et=l[P>>2]}l[K+76>>2]=a,nt=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Dp(K+76|0),a=l[K+76>>2],nt=1}for(;;){if(q=S,dt=28,yt=a,S=ft[a|0],S-123>>>0<4294967238)break i;if(a=yt+1|0,S=At[(S+Ue(q,58)|0)+4975|0],!(S-1>>>0<8))break}l[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((X|0)>=0){l[(X<<2)+y>>2]=S,S=(X<<3)+u|0,P=l[S+4>>2],l[K+64>>2]=l[S>>2],l[K+68>>2]=P;break h}if(!r)break n;vp(K- -64|0,S,h,T);break c}if((X|0)>=0)break i}if(S=0,!r)continue s}P=O&-65537,O=O&8192?P:O,X=0,Lt=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{k:{T:{A:{w:{E:switch(S=ft[yt|0],S=q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break k;case 24:break T;case 22:break A;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break E}E:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break E}if((S|0)==83)break v;break a}P=l[K+64>>2],q=l[K+68>>2],S=1167;break g}S=0;A:switch(q&255){case 0:l[l[K+64>>2]>>2]=W;continue s;case 1:l[l[K+64>>2]>>2]=W;continue s;case 2:tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s;case 3:Nr[l[K+64>>2]>>1]=W;continue s;case 4:ft[l[K+64>>2]]=W;continue s;case 6:l[l[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,O=O|8,S=120}if(tt=ot,P=l[K+64>>2],q=l[K+68>>2],P|q)for(Vt=S&32;tt=tt-1|0,ft[tt|0]=Vt|At[(P&15)+5504|0],Xt=!q&P>>>0>15|(q|0)!=0,yt=q,q=q>>>4|0,P=(yt&15)<<28|P>>>4,!!Xt;);if(!(O&8)|!(l[K+64>>2]|l[K+68>>2]))break u;Lt=(S>>>4|0)+1167|0,X=2;break u}if(S=ot,tt=l[K+68>>2],q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,ft[S|0]=P&7|48,yt=!q&P>>>0>7|(q|0)!=0,tt=q,q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!yt;);if(tt=S,!(O&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=l[K+64>>2],S=l[K+68>>2],q=S,(S|0)<0){tt=0-(q+((P|0)!=0)|0)|0,q=tt,P=0-P|0,l[K+64>>2]=P,l[K+68>>2]=tt,X=1,S=1167;break g}if(O&2048){X=1,S=1168;break g}X=O&1,S=X?1169:1167}Lt=S,tt=Bn(P,q,ot)}if((et|0)<0&&nt)break e;if(O=nt?O&-65537:O,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}O=0,nt=et>>>0>=2147483647?2147483647:et,q=nt,dt=(q|0)!=0;y:{u:{S=l[K+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!q)break m;for(;;){if(O=At[S|0],!O)break b;if(q=q-1|0,dt=(q|0)!=0,S=S+1|0,!(S&3))break m;if(!q)break}}if(!dt)break u;m:{if(!(!At[S|0]|q>>>0<4))for(;;){if(dt=l[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,q=q-4|0,!(q>>>0>3))break}if(!q)break u}dt=0;break g}dt=1}for(;;){if(!dt){O=At[S|0],dt=1;continue}if(!O)break y;if(S=S+1|0,q=q-1|0,!q)break u;dt=0}}S=0}if(S=S?S-tt|0:nt,dt=S+tt|0,(et|0)>=0){O=P,et=S;break a}if(O=P,et=S,At[dt|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,mi(r,32,Y,0,O);break f}l[K+12>>2]=0,l[K+8>>2]=l[K+64>>2],P=K+8|0,l[K+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=l[P>>2],!tt)break d;if(tt=$p(K+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break r}if(dt=61,(S|0)<0)break i;if(mi(r,32,Y,S,O),!S){S=0;break f}for(dt=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=$p(K+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(hi(r,K+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}mi(r,32,Y,S,O^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&nt)break e;if(dt=61,S=Pt[A|0](r,Ne[K+64>>3],Y,et,O,S)|0,(S|0)>=0)continue s;break i}ft[K+55|0]=l[K+64>>2],et=1,tt=$t,O=P;break a}P=At[S+1|0],S=S+1|0}if(r)break t;if(!pt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(vp((S<<3)+u|0,r,h,T),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(l[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break i}if(q=dt-tt|0,et=(et|0)>(q|0)?et:q,(et|0)>(X^2147483647))break e;if(dt=61,P=et+X|0,S=(P|0)<(Y|0)?Y:P,(Ot|0)<(S|0))break i;mi(r,32,S,P,O),hi(r,Lt,X),mi(r,48,S,P,O^65536),mi(r,48,et,q,0),hi(r,tt,q),mi(r,32,S,P,O^8192);continue}break}W=0;break t}dt=61}l[1781]=dt}W=-1}return Et=K+80|0,W}function uE(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),A=m(0),T=0,S=m(0),P=0,K=m(0),tt=0,dt=m(0),q=0;q=Et+-64|0,Et=q,T=l[r>>2],Ui(q+8|0,0,56),l[1755]=l[1755]+1,hp(T),S=m(a),A=I[T+572>>2];t:{r:{i:switch(r=l[T+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[T+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*S)*m(.009999999776482582))}dt=m(y+m(ue(T,2,S)+Se(T,2,S))),tt=1;break t}y=m(0),A=I[T+216>>2];r:{i:{r=l[T+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(A==A)break n;tt=4344}switch(y=I[tt>>2],l[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],dt=m(zt),tt=2,l[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}K=m(h),A=I[T+580>>2];t:{r:{i:switch(r=l[T+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[T+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*K)*m(.009999999776482582))}A=m(y+m(ue(T,0,S)+Se(T,0,S))),r=1;break t}y=m(0),A=I[T+220>>2];r:{i:{r=l[T+220>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;P=4336;n:{if((r|0)!=2141891242){if(A==A)break n;P=4344}switch(y=I[P>>2],l[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*K)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],A=m(zt),r=2,l[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}A=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,A=K;break t}r=2,A=y}un(T,dt,A,u,tt,r,S,K,1,0,l[T+568>>2],q+8|0,0,l[1755])&&(Ep(T,At[T+300|0]&3,S,K,S),yp(T,+I[l[T+568>>2]+20>>2],0,0)),Et=q- -64|0}function fE(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,A=0,T=m(0),S=0,P=0,K=0,tt=m(0);t:{P=l[a>>2],a=l[r>>2];r:{if((l[P+24>>2]^l[a+24>>2])&8388607)break r;tt=I[P+40>>2],y=l[P+40>>2],u=I[a+40>>2];i:{e:{if(h=l[a+40>>2],(h|0)!=2139156720){if(T=m(zt),r=3,(h|0)==2141891242)break i;if((h|0)!=2140081935)break e;T=m(0),r=1;break i}r=2;break i}if(r=0,u!=u)break i;T=(xt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}i:{e:{if((y|0)!=2139156720){if(u=m(zt),h=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break e;u=m(0),h=1;break i}u=m(0),h=2;break i}if(h=0,tt!=tt)break i;u=(xt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|T!=T&u!=u|m(Ve(m(T-u)))<m(9999999747378752e-20))||(h=a+44|0,A=P+44|0,l[h>>2]!=l[A>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,A=P+80|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,A=P+116|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,A=P+152|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,A=P+188|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<2)break r}for(S=P+200|0,K=a+200|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0)||(T=I[P+28>>2],r=T!=T,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=T)||(u=I[a+32>>2],T=I[P+32>>2],(u==u|0)==(T!=T|0)|u==u&u!=T)||(T=I[P+36>>2],r=T!=T,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=T))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,T=I[P+224>>2],T!=T)||(T=u,u=I[P+224>>2],T==u|u!=u&r))break t}for(Ni(a+24|0,P+24|0,204);;){if(r=At[a+4|0],r&4)break t;if(ft[a+4|0]=r|4,r=l[a+20>>2],r&&Pt[r|0](a),l[a+308>>2]=2143289344,a=l[a+552>>2],!a)break}}}function pE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0,T=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0,W=0,Y=0,X=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,O=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],q=r,T=Et-32|0,Et=T,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=l[a+8>>2],a=h;t:{if((y|0)==(r|0)&a>>>0<a>>>0|r>>>0>y>>>0){if(r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){r=r+1073741824|0,a=a+1|0,r=a?r:r+1|0;break t}if(r=r+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,r=a>>>0<u>>>0?r+1|0:r;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h&524287|2146959360;break t}if(a=0,r=2146435072,S>>>0>1140785151||(r=0,et=S>>>16|0,et>>>0<15249))break t;a=P,r=u,y=q&65535|65536,S=y,dt=h,A=h,K=et-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,A=0):(r=(1<<a)-1&h>>>32-a|r<<a,A=h<<a),y=r,a=0,r=0;break r}if(!K)break r;tt=A,A=K&31,(K&63)>>>0>=32?(h=tt<<A,A=0):(h=(1<<A)-1&tt>>>32-A|y<<A,A=tt<<A),y=h,W=A,tt=a,h=64-K|0,A=h&31,(h&63)>>>0>=32?(h=0,a=r>>>A|0):(h=r>>>A|0,a=((1<<A)-1&r)<<32-A|tt>>>A),A=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|r<<a,a=tt<<a),r=h}l[T+16>>2]=a,l[T+20>>2]=r,l[T+24>>2]=A,l[T+28>>2]=y,a=15361-et|0;r:{if(a&64){u=dt,a=a+-64|0,r=a&31,(a&63)>>>0>=32?(h=0,P=S>>>r|0):(h=S>>>r|0,P=((1<<r)-1&S)<<32-r|u>>>r),u=h,dt=0,S=0;break r}if(!a)break r;y=dt,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,A=0):(r=(1<<h)-1&y>>>32-h|S<<h,A=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=A|y,u=r|h,y=dt,h=a&31,(a&63)>>>0>=32?(r=0,dt=S>>>h|0):(r=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[T>>2]=P,l[T+4>>2]=u,l[T+8>>2]=dt,l[T+12>>2]=S,a=l[T+8>>2],r=l[T+12>>2]<<4|a>>>28,a=a<<4,h=l[T>>2],S=l[T+4>>2],a=S>>>28|a,u=S&268435455,h=h|(l[T+16>>2]|l[T+24>>2]|(l[T+20>>2]|l[T+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,r=a?r:r+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,r=h>>>0>a>>>0?r+1|0:r}Et=T+32|0,xt(0,a|0),xt(1,q&-2147483648|r),Y=O,X=+Ae(),Ne[Y>>3]=X}function un(r,a,h,u,y,A,T,S,P,K,tt,dt,q,et){var O=m(0),W=0,Y=0,X=0,nt=0,ot=m(0),pt=0,yt=0,Lt=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&At[r+4|0]&4)&&(nt=0,l[r+316>>2]==(u|0)))break t;l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+320>>2]=0,nt=1}pt=q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(ot=ue(r,2,T),Lt=Se(r,2,T),O=m(ue(r,0,T)+Se(r,0,T)),q=r+524|0,ot=m(ot+Lt),up(y,a,A,h,l[r+532>>2],I[q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],ot,O,tt))break i;if(Y=l[r+320>>2],!Y)break e;for(W=r+324|0;;){if(q=W+Ue(X,24)|0,up(y,a,A,h,l[q+8>>2],I[q>>2],l[q+12>>2],I[q+4>>2],I[q+16>>2],I[q+20>>2],ot,O,tt))break i;if(X=X+1|0,(Y|0)==(X|0))break}break e}if(!P){if(yt=l[r+320>>2],!yt)break e;for(Y=r+324|0;;){W=Ue(X,24),q=W+Y|0,O=I[q>>2];s:{n:{if(!(O!=O|a!=a)){if(m(Ve(m(O-a)))<m(9999999747378752e-20))break n;break s}if(O==O|a==a)break s}W=Y+W|0,O=I[W+4>>2];n:{if(!(O!=O|h!=h)){if(m(Ve(m(O-h)))<m(9999999747378752e-20))break n;break s}if(O==O|h==h)break s}if(l[W+8>>2]!=(y|0))break s;if(l[W+12>>2]==(A|0))break i}if(X=X+1|0,(yt|0)==(X|0))break}break e}q=r+524|0,O=I[q>>2];s:{if(!(O!=O|a!=a)){if(m(Ve(m(O-a)))<m(9999999747378752e-20))break s;break e}if(O==O|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(A|0)?q:0,O=I[r+528>>2],q=O!=O,Y=h!=h;s:{if(q|Y){q=q&Y;break s}q=m(Ve(m(O-h)))<m(9999999747378752e-20)}q=q?W:0;break i}ap(r,a,h,u,y,A,T,S,P,tt,dt,pt,et,K),l[r+316>>2]=u;break r}if(!(!q|nt)){I[r+516>>2]=I[q+16>>2],I[r+520>>2]=I[q+20>>2],u=(P?12:16)+dt|0,l[u>>2]=l[u>>2]+1;break t}if(ap(r,a,h,u,y,A,T,S,P,tt,dt,pt,et,K),l[r+316>>2]=u,q)break t}q=l[r+320>>2],u=q+1|0,u>>>0>Jf[dt+8>>2]&&(l[dt+8>>2]=u),(q|0)==8&&(l[r+320>>2]=0,q=0),P?u=r+524|0:(l[r+320>>2]=q+1,u=(Ue(q,24)+r|0)+324|0),l[u+12>>2]=A,l[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[r+516>>2],I[u+20>>2]=I[r+520>>2],q=0}t:{if(!P||(u=l[r+520>>2],l[r+244>>2]=l[r+516>>2],l[r+248>>2]=u,u=At[r+4|0],y=u|1,ft[r+4|0]=y,!(u&4)))break t;ft[r+4|0]=y&251}return l[r+312>>2]=et,!q|nt}function bh(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,T=0,S=0,P=0,K=0,tt=0,dt=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=l[1751],A=a,y=l[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){T=(r>>>3|0)-1|0;break i}if(u=mr(r),T=((r>>>29-u^4)-(u<<2)|0)+110|0,r>>>0<=4095)break i;u=((r>>>30-u^2)-(u<<1)|0)+71|0,T=u>>>0>=63?63:u}if(h=T&31,(T&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;i:{if(a|u){h=u-1|0,P=h+1|0,A=h,h=a-1|0,A=(h|0)!=-1?P:A,u=mr(u^A),u=(u|0)==32?mr(a^h)+32|0:u,h=63-u|0,Fi=0-(u>>>0>63)|0;break i}Fi=0,h=64}A=h,h=A&31,(A&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,T=A+T|0,h=T<<4,a=l[h+5976>>2],A=h+5968|0;i:{if((a|0)!=(A|0)){if(y=kh(a,S,r),y)break t;y=l[a+4>>2],l[y+8>>2]=l[a+8>>2],l[l[a+8>>2]+4>>2]=y,l[a+8>>2]=A,y=h+5972|0,l[a+4>>2]=l[y>>2],l[y>>2]=a,l[l[a+4>>2]+8>>2]=a,T=T+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=l[1751],A=T&63,a=A,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=A&31,A>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,A=0-T&63,h=A,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=A&31,A>>>0>=32?(A=0,a=a>>>h|0):(A=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Fi=y|A,l[1750]=l[1750]&a,l[1751]=Fi&K,a=P^1}if(!(a|u))break}A=l[1751],y=l[1750]}i:{if(y|A){u=mr(A),h=63-((u|0)==32?mr(y)+32|0:u)|0,a=h<<4,u=l[a+5976>>2];e:{if(!A&y>>>0<1073741824||(T=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!T)break e;if(y=kh(u,S,r),y)break t;if(T=T-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(Eh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=kh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!Eh(r+48|0))break r}if(y=0,S-1&S)break t;if(!(r>>>0<=4294967239))break}break t}y=0}return y|0}function gE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,T=0,S=0,P=0,K=0,tt=0,dt=0,q=0;S=Et-80|0,Et=S,r=l[r>>2];t:{r:{if(P=l[a>>2],!l[P+552>>2]){if(l[r+8>>2])break r;a=l[r+556>>2],T=a+(h<<2)|0,u=l[r+560>>2],y=r+564|0,A=l[y>>2];i:{if(u>>>0<A>>>0){if((u|0)==(T|0)){l[T>>2]=P,l[r+560>>2]=T+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;l[h>>2]=l[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);l[r+560>>2]=h,a=T+4|0,(a|0)!=(u|0)&&(a=u-a|0,xs(u-(a&-4)|0,T,a)),l[T>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=A-a|0,A=a>>1,y=Fa(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<A>>>0?A:u,h,y),h=l[y+8>>2];e:{if((h|0)!=l[y+12>>2])break e;if(a=l[y+4>>2],u=l[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,A=a,a=h-a|0,h=xs(K,A,a)+a|0,l[y+8>>2]=h,l[y+4>>2]=u+l[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,A=Fa(S+56|0,a,a>>>2|0,l[y+16>>2]),u=l[A+8>>2],a=l[y+4>>2],h=l[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=l[y+8>>2],u=l[y+4>>2]}if(K=l[y>>2],l[y>>2]=l[A>>2],l[A>>2]=K,l[y+4>>2]=l[A+4>>2],l[A+4>>2]=u,l[y+8>>2]=h,l[A+8>>2]=a,tt=l[y+12>>2],l[y+12>>2]=l[A+12>>2],l[A+12>>2]=tt,(a|0)!=(u|0)&&(l[A+8>>2]=((u-a|0)+3&-4)+a),!K)break e;gi(K),h=l[y+8>>2]}if(l[h>>2]=P,l[y+8>>2]=l[y+8>>2]+4,a=l[r+556>>2],h=T-a|0,dt=y,q=xs(l[y+4>>2]-h|0,a,h),l[dt+4>>2]=q,u=l[r+560>>2]-T|0,T=xs(l[y+8>>2],T,u),a=l[r+556>>2],l[r+556>>2]=l[y+4>>2],l[y+4>>2]=a,h=l[r+560>>2],l[r+560>>2]=u+T,l[y+8>>2]=h,u=l[r+564>>2],l[r+564>>2]=l[y+12>>2],l[y>>2]=a,l[y+12>>2]=u,(a|0)!=(h|0)&&(l[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;gi(a)}for(l[P+552>>2]=r;a=At[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=S+80|0;return}l[S+16>>2]=4075,sr(r,S+16|0),qi(),de()}l[S>>2]=4208,sr(r,S),qi(),de()}Ds(),de()}function cp(r,a){var h=0,u=0;for(l[r>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r+24>>2]=0,l[r+36>>2]=2143289344,l[r+40>>2]=2141891242,l[r+28>>2]=2143289344,l[r+32>>2]=2143289344,ft[r+4|0]=At[r+4|0]&128,u=Ui(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Ui(r+152|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,l[r+196>>2]=0,u=r+188|0,l[u>>2]=0,l[u+4>>2]=0;l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(l[r+24>>2]=4224,l[r+224>>2]=2143289344,l[r+216>>2]=2143289344,l[r+220>>2]=2143289344,l[r+208>>2]=2143289344,l[r+212>>2]=2143289344,l[r+200>>2]=2141891242,l[r+204>>2]=2141891242,Ui(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Ui(r+252|0,0,49),l[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return l[r+548>>2]=0,l[r+552>>2]=0,l[r+516>>2]=2143289344,l[r+520>>2]=2143289344,l[r+572>>2]=2143289344,l[r+576>>2]=0,l[r+568>>2]=a,l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+556>>2]=0,l[r+560>>2]=0,l[r+564>>2]=0,l[r+580>>2]=2143289344,l[r+584>>2]=0,Vp((a|0)!=0,2760),ft[r+4|0]=At[r+4|0]|1,ft[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function He(r,a,h,u){var y=m(0),A=m(0),T=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){A=I[r+212>>2],a=l[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;T=4336;o:{if((a|0)!=2141891242){if(A==A)break o;T=4344}switch(y=I[T>>2],A=m(zt),l[T+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break n}A=m(m(y*u)*m(.009999999776482582));break s}A=I[r+208>>2];a:{o:{a=l[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;T=4336;c:{if((a|0)!=2141891242){if(A==A)break c;T=4344}switch(y=I[T>>2],A=m(zt),l[T+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break o}A=m(m(y*u)*m(.009999999776482582));break a}A=y}y=m(0),S=I[r+216>>2],r=l[r+216>>2];a:{if((r|0)==2139156720)break a;if((r|0)==2140081935)break i;a=4336;o:{if((r|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}A=y}y=m(0),S=I[r+220>>2],r=l[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;a=4336;n:{if((r|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break r}if(h>y)break t}if(!(A>=m(0)))return h;y=h<A?A:h}return y}function hp(r){var a=0,h=0,u=m(0),y=m(0),A=m(0),T=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,O=0;for(T=Et-16|0,l[T+8>>2]=0,l[T+12>>2]=1,tt=r+200|0,dt=r+572|0,q=r+208|0,et=r+216|0,r=0;;){O=r,K=l[(T+8|0)+(r<<2)>>2],S=K<<2,r=et+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=l[r>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;r=S+q|0,y=I[r>>2],h=l[r>>2];a:{o:{if((h|0)!=2139156720){if(A=m(zt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;A=m(0),r=1;break a}A=m(0),r=2;break a}if(r=0,y!=y)break a;A=(xt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(zt),r=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),r=1;break a}y=m(0),r=2;break a}if(r=0,u!=u)break a;y=(xt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&A!=A|m(Ve(m(y-A)))<m(9999999747378752e-20)))break n;if(r=0,P)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(r=0,a=S+tt|0,u=I[a>>2],a=l[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}r=2143289344,a=0;break t}r=2143289344,a=3;break t}a=1}if(h=(K<<3)+dt|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(O&1))break}}function Ni(r,a,h){var u=0,y=0,A=0;if(h>>>0>=512)return nE(r|0,a|0,h|0),r;y=r+h|0;t:{if(!((r^a)&3)){r:{if(!(r&3)){h=r;break r}if(!h){h=r;break r}for(h=r;;){if(ft[h|0]=At[a|0],a=a+1|0,h=h+1|0,!(h&3))break r;if(!(h>>>0<y>>>0))break}}u=y&-4;r:{if(u>>>0<64||(A=u+-64|0,A>>>0<h>>>0))break r;for(;l[h>>2]=l[a>>2],l[h+4>>2]=l[a+4>>2],l[h+8>>2]=l[a+8>>2],l[h+12>>2]=l[a+12>>2],l[h+16>>2]=l[a+16>>2],l[h+20>>2]=l[a+20>>2],l[h+24>>2]=l[a+24>>2],l[h+28>>2]=l[a+28>>2],l[h+32>>2]=l[a+32>>2],l[h+36>>2]=l[a+36>>2],l[h+40>>2]=l[a+40>>2],l[h+44>>2]=l[a+44>>2],l[h+48>>2]=l[a+48>>2],l[h+52>>2]=l[a+52>>2],l[h+56>>2]=l[a+56>>2],l[h+60>>2]=l[a+60>>2],a=a- -64|0,h=h- -64|0,A>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;l[h>>2]=l[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=r;break t}if(u=y-4|0,u>>>0<r>>>0){h=r;break t}for(h=r;ft[h|0]=At[a|0],ft[h+1|0]=At[a+1|0],ft[h+2|0]=At[a+2|0],ft[h+3|0]=At[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;ft[h|0]=At[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function dp(r,a,h,u,y){var A=m(0),T=0,S=m(0),P=m(0),K=0,tt=0,dt=m(0),q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),T=(a<<2)+r|0,A=I[T+208>>2];t:{r:{T=l[T+208>>2];i:{e:{if((T|0)==2139156720)break e;if((T|0)==2140081935)break r;K=4336;s:{if((T|0)!=2141891242){if(A==A)break s;K=4344}switch(h=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(2,(T&-1073741825)+536870912|0),Bt()),!(T&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;break t}P=m(h-u)}h=m(0),r=(a<<2)+r|0,A=I[r+216>>2];t:{r:{a=l[r+216>>2];i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break r;r=4336;s:{if((a|0)!=2141891242){if(A==A)break s;r=4344}switch(h=I[r>>2],A=m(34028234663852886e22),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;A=m(34028234663852886e22);break t}A=m(h-u)}if(h=(dt=S,q=Lh(S,A),et=A!=A|tt,et?dt:q),r=h!=h,!(r|P!=P))return he(h,P);S=r?P:h}return S}function up(r,a,h,u,y,A,T,S,P,K,tt,dt,q){var et=m(0),O=m(0),W=0,Y=0,X=m(0),nt=m(0),ot=m(0),pt=0,yt=0;if(P<m(0)|K<m(0))r=0;else{X=A,nt=a,ot=u,O=S;t:{if(!q||(et=I[q+20>>2],O=S,et==m(0)))break t;pt=+et,nt=Gr(+a,pt,0,0),ot=Gr(+u,pt,0,0),X=Gr(+A,pt,0,0),O=Gr(+S,pt,0,0)}et=O,q=0;t:{if((r|0)!=(y|0))break t;if(yt=X!=X,q=nt!=nt,yt|q){q=q&yt;break t}q=m(Ve(m(X-nt)))<m(9999999747378752e-20)}yt=q;t:{if((h|0)!=(T|0))break t;if(W=et!=et,q=ot!=ot,W|q){W=q&W;break t}W=m(Ve(m(et-ot)))<m(9999999747378752e-20)}Y=1,q=1;t:{if(yt)break t;a=m(a-tt);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(a>=P))break r;break t}if(q=0,!(a<A)|(r|(y|0)!=2|(a!=a|A!=A|P!=P))||(q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){q=r&y;break t}q=m(Ve(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|T)){if(!(a>=K))break r;break t}if(Y=0,!(a<S)|(r|(T|0)!=2|(a!=a|S!=S|K!=K))||(Y=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){Y=r&h;break t}Y=m(Ve(m(a-K)))<m(9999999747378752e-20)}r=q&Y}return r}function Ah(r){var a=0,h=0,u=0,y=0,A=0,T=0,S=0,P=0;if(pi(+r),A=te(1)|0,u=te(0)|0,y=A>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,T=A<<1|u>>>31,!a&(T|0)==2145386496|T>>>0<2145386496)return!a&(T|0)==2145386496?r*0:r;t:{if(!y){if(y=0,h=u<<12,a=A<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|A<<h,u=u<<h);break t}a=A&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,T=a<<1|h>>>31,h=h<<1,a=T,!!u;);return P=A&-2147483648,T=a+-1048576|y<<20,S=h,A=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=A>>>h|0):(a=A>>>h|0,u=((1<<h)-1&A)<<32-h|S>>>h),h=(y|0)>0,xt(0,(h?S:u)|0),xt(1,(h?T:a)|P),+Ae()}function Eh(r){var a=0,h=0,u=0,y=0,A=0;u=l[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>e2()<<16>>>0&&!(sE(h|0)|0))break r;l[1416]=h;break t}l[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,l[h+12>>2]=16,l[h>>2]=16,r=l[1748],r?A=l[r+8>>2]:A=0;t:{r:{if((A|0)==(u|0)){if(y=u-(l[u-4>>2]&-2)|0,A=l[y-4>>2],l[r+8>>2]=a,r=y-(A&-2)|0,a=-16,!(ft[(r+l[r>>2]|0)-4|0]&1))break r;a=l[r+4>>2],l[a+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=a,h=h-r|0,l[r>>2]=h;break t}l[u+12>>2]=16,l[u>>2]=16,l[u+8>>2]=a,l[u+4>>2]=r,l[1748]=u,a=16}r=a+u|0,h=h-r|0,l[r>>2]=h}l[((h&-4)+r|0)-4>>2]=h|1,a=l[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=mr(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,l[r+4>>2]=a+5968,a=a+5976|0,l[r+8>>2]=l[a>>2],l[a>>2]=r,l[l[r+8>>2]+4>>2]=r,a=l[1750],y=l[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,A=0):(A=1<<r,h=A-1&1>>>32-r),l[1750]=A|a,l[1751]=h|y}return(u|0)!=-1}function fp(r,a,h){var u=0,y=0,A=0,T=0,S=0,P=0,K=0,tt=0,dt=0;t:{r:{i:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}r=(r>>>0)/(h>>>0)|0,Fi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;A=(mr(h)+33|0)-mr(a)|0,T=0-A|0;break e}r=(a>>>0)/0|0,Fi=0;break t}if(u=32-mr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;A=h?31-mr(h-1^h)|0:32,h=A&31,(A&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Fi=u;break t}A=u+1|0,T=63-u|0}if(u=A&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|r>>>y),T=T&63,y=T&31,T>>>0>=32?(a=r<<y,r=0):(a=(1<<y)-1&r>>>32-y|a<<y,r=r<<y),A)for(T=h-1|0,dt=(T|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>T>>>0)|0)>>31,K=h&y,S=u-K|0,u=P-(u>>>0<K>>>0)|0,a=a<<1|r>>>31,r=tt|r<<1,tt=y&1,A=A-1|0,!!A;);Fi=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Fi=a}return r}function qo(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=l[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+196>>2],u=I[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break i;break r}if(a=l[r+192>>2],u=I[r+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[r+196>>2],a=l[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break i;if(u!=u)break r}u=m(0);i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function pp(r,a){var h=0,u=0,y=0,A=0,T=0,S=0;for(h=Et-320|0,Et=h,u=Ui(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Ui(h+24|0,0,49),l[h+80>>2]=2143289344,A=h+288|0,y=h+96|0;h=y,l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,y=h+24|0,(A|0)!=(y|0););if(l[u+312>>2]=-1082130432,l[u+316>>2]=-1082130432,l[u+304>>2]=0,l[u+308>>2]=0,l[u+296>>2]=-1082130432,l[u+300>>2]=-1082130432,l[u+288>>2]=2143289344,l[u+292>>2]=2143289344,Ni(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,ft[r+4|0]=At[r+4|0]|1,y=l[r+556>>2],T=l[r+560>>2],(y|0)!=(T|0))for(;h=l[y>>2],l[h+552>>2]!=(r|0)&&(A=l[r+568>>2],h=Ap(l[A>>2],At[A+8|0],h,r,S,a),l[y>>2]=h,l[h+552>>2]=r,h=l[y>>2]),pp(h,a),S=S+1|0,y=y+4|0,(T|0)!=(y|0););Et=u+320|0}function kh(r,a,h){var u=0,y=0,A=0,T=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=l[r>>2],y+h>>>0<=(a+r|0)-4>>>0){A=l[r+4>>2],l[A+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=A,(u|0)!=(y|0)&&(y=y-u|0,A=r-(l[r-4>>2]&-2)|0,u=y+l[A>>2]|0,l[A>>2]=u,l[(A+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,l[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,l[u>>2]=a,l[(u+(a&-4)|0)-4>>2]=a|1,y=l[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(A=mr(y),a=((y>>>29-A^4)-(A<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-A^2)-(A<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,l[u+4>>2]=y+5968,y=y+5976|0,l[u+8>>2]=l[y>>2],l[y>>2]=u,l[l[u+8>>2]+4>>2]=u,y=l[1750],A=l[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(T=1<<u,a=T-1&1>>>32-u,u=T),l[1750]=u|y,l[1751]=a|A,a=h+8|0,l[r>>2]=a,l[((a&-4)+r|0)-4>>2]=a;break t}l[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function mE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0;y=Et-320|0,Et=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!Sp(r,u)))break t;if((r|0)==(a|0)){for(h=Ui(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Ui(a+24|0,0,49),l[a+80>>2]=2143289344,A=a+288|0,a=a+96|0;l[a+16>>2]=-1082130432,l[a+20>>2]=-1082130432,l[a+8>>2]=0,l[a+12>>2]=0,l[a>>2]=-1082130432,l[a+4>>2]=-1082130432,a=a+24|0,(A|0)!=(a|0););l[h+312>>2]=-1082130432,l[h+316>>2]=-1082130432,l[h+304>>2]=0,l[h+308>>2]=0,l[h+296>>2]=-1082130432,l[h+300>>2]=-1082130432,l[h+288>>2]=2143289344,l[h+292>>2]=2143289344,Ni(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=y+320|0}function gp(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,T=0,S=0;if(r){if(T=Et-32|0,Et=T,a=l[r>>2],u=l[a+552>>2],u&&(Sp(u,a),l[a+552>>2]=0),u=l[a+556>>2],h=l[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;l[l[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););l[a+560>>2]=u,h=a+564|0;t:{if(l[h>>2]==(u|0)||(h=Fa(T+8|0,0,0,h),y=l[a+556>>2],A=l[a+560>>2]-y|0,u=l[h+4>>2]-A|0,A=xs(u,y,A),y=l[a+556>>2],l[a+556>>2]=A,l[h+4>>2]=y,A=l[a+560>>2],l[a+560>>2]=l[h+8>>2],l[h+8>>2]=A,S=l[a+564>>2],l[a+564>>2]=l[h+12>>2],l[h>>2]=y,l[h+12>>2]=S,(y|0)!=(A|0)&&(l[h+8>>2]=A+((y-A|0)+3&-4)),!y))break t;gi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,gi(u)),gi(a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Et=T+32|0,gi(r)}}function vE(r){r=r|0;var a=0,h=0,u=0;u=Et-624|0,Et=u,a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a);t:{if(r=l[r>>2],l[r+560>>2]==l[r+556>>2]){if(l[r+552>>2])break t;a=cp(u+32|0,l[r+568>>2]),h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h,h=l[a+20>>2],l[r+16>>2]=l[a+16>>2],l[r+20>>2]=h,h=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=h,Ni(r+24|0,a+24|0,204),Ni(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,gi(h)),l[r+556>>2]=l[a+556>>2],l[r+560>>2]=l[a+560>>2],l[r+564>>2]=l[a+564>>2],l[r+584>>2]=l[a+584>>2],h=l[a+580>>2],l[r+576>>2]=l[a+576>>2],l[r+580>>2]=h,h=l[a+572>>2],l[r+568>>2]=l[a+568>>2],l[r+572>>2]=h,Et=u+624|0;return}l[u+16>>2]=3301,sr(r,u+16|0),qi(),de()}l[u>>2]=2047,sr(r,u),qi(),de()}function mp(){hE(7084,3067),cE(7085,2480,1,1,0),os(7086,2140,1,-128,127),os(7087,2133,1,-128,127),os(7088,2131,1,0,255),os(7089,1287,2,-32768,32767),os(7090,1278,2,0,65535),os(7091,1316,4,-2147483648,2147483647),os(7092,1307,4,0,-1),os(7093,2659,4,-2147483648,2147483647),os(7094,2650,4,0,-1),Yp(7095,1777,-2147483648,2147483647),Yp(7096,1776,0,-1),ip(7097,1770,4),ip(7098,3015,8),rp(7099,2677),rp(7100,3904),mh(7101,4,2664),mh(7102,2,2689),mh(7103,4,2704),lE(7104,2485),Ei(7105,0,3835),Ei(7106,0,3937),Ei(7107,1,3865),Ei(7108,2,3467),Ei(7109,3,3498),Ei(7110,4,3538),Ei(7111,5,3567),Ei(7112,4,3974),Ei(7113,5,4004),Ei(7106,0,3669),Ei(7107,1,3636),Ei(7108,2,3735),Ei(7109,3,3701),Ei(7110,4,3802),Ei(7111,5,3768),Ei(7114,6,3605),Ei(7115,7,4043)}function xs(r,a,h){var u=0,y=0;t:{if((r|0)==(a|0))break t;if(y=r+h|0,a-y>>>0<=0-(h<<1)>>>0)return Ni(r,a,h);u=(r^a)&3;r:{i:{if(r>>>0<a>>>0){if(u){u=r;break r}if(!(r&3)){u=r;break i}for(u=r;;){if(!h)break t;if(ft[u|0]=At[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break i}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+r|0,ft[u|0]=At[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,l[h+r>>2]=l[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,ft[h+r|0]=At[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;ft[u|0]=At[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function vp(r,a,h,u){t:switch(a-9|0){case 0:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2];return;case 6:a=l[h>>2],l[h>>2]=a+4,a=Nr[a>>1],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 7:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=Fn[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=ft[a|0],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 9:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=At[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Ne[r>>3]=Ne[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=l[h>>2],l[h>>2]=a+4,a=l[a>>2],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2],l[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=l[h>>2]+7&-8,l[h>>2]=a+8,h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h}function yp(r,a,h,u){var y=0,A=0,T=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=m(0),O=m(0),W=m(0),Y=0,X=m(0);t:{if(a==0||(et=I[r+248>>2],O=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=At[r+4|0]&8,A=y>>>3|0,Y=r,X=Gr(P,a,0,A),I[Y+228>>2]=X,K=+W,Y=r,X=Gr(K,a,0,A),I[Y+232>>2]=X,tt=+O,T=Ah(tt*a),A=T==T&Ve(T)<1e-4,S=!(A|T!=T?A:Ve(T+-1)<1e-4),dt=+et,T=Ah(dt*a),A=T==T&Ve(T)<1e-4,q=!(A|T!=T?A:Ve(T+-1)<1e-4),A=0,h=P+h,y=(y|0)!=0,Y=r,X=m(Gr(h+tt,a,y&S,y&!S)-Gr(h,a,0,y)),I[Y+244>>2]=X,u=K+u,Y=r,X=m(Gr(u+dt,a,y&q,y&!q)-Gr(u,a,0,y)),I[Y+248>>2]=X,y=l[r+560>>2],S=l[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=l[r+556>>2],l[r+560>>2]-y>>2>>>0>A>>>0?y=l[y+(A<<2)>>2]:y=0,yp(y,a,h,u),A=A+1|0,(S|0)!=(A|0););}}function Ui(r,a,h){var u=0,y=0,A=0,T=0;t:{if(!h||(ft[r|0]=a,u=r+h|0,ft[u-1|0]=a,h>>>0<3)||(ft[r+2|0]=a,ft[r+1|0]=a,ft[u-3|0]=a,ft[u-2|0]=a,h>>>0<7)||(ft[r+3|0]=a,ft[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=Ue(a&255,16843009),l[y>>2]=a,u=h-u&-4,h=u+y|0,l[h-4>>2]=a,u>>>0<9)||(l[y+8>>2]=a,l[y+4>>2]=a,l[h-8>>2]=a,l[h-12>>2]=a,u>>>0<25)||(l[y+24>>2]=a,l[y+20>>2]=a,l[y+16>>2]=a,l[y+12>>2]=a,l[h-16>>2]=a,l[h-20>>2]=a,l[h-24>>2]=a,l[h-28>>2]=a,T=y&4|24,h=u-T|0,h>>>0<32))break t;for(u=Rh(a,0,1,1),A=Fi,a=y+T|0;l[a+24>>2]=u,l[a+28>>2]=A,l[a+16>>2]=u,l[a+20>>2]=A,l[a+8>>2]=u,l[a+12>>2]=A,l[a>>2]=u,l[a+4>>2]=A,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function gi(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;if(r){a=r-4|0,y=l[a>>2],h=y,u=a,A=l[r-8>>2],r=A&-2,(r|0)!=(A|0)&&(u=a-r|0,h=l[u+4>>2],l[h+8>>2]=l[u+8>>2],l[l[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=l[r>>2],(a|0)!=l[(r+a|0)-4>>2]&&(y=l[r+4>>2],l[y+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=y,h=a+h|0),l[u>>2]=h,l[((h&-4)+u|0)-4>>2]=h|1,a=l[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=mr(a),r=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;r=((a>>>30-h^2)-(h<<1)|0)+71|0,r=r>>>0>=63?63:r}a=r<<4,l[u+4>>2]=a+5968,a=a+5976|0,l[u+8>>2]=l[a>>2],l[a>>2]=u,l[l[u+8>>2]+4>>2]=u,a=l[1750],h=l[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),l[1750]=y|a,l[1751]=r|h}}function yE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,T=0,S=0,P=0,K=0;u=Et-32|0,Et=u,y=l[r+28>>2],l[u+16>>2]=y,A=l[r+20>>2],l[u+28>>2]=h,l[u+24>>2]=a,a=A-y|0,l[u+20>>2]=a,A=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!jp(aE(l[r+60>>2],a|0,P|0,u+12|0)|0)){if(T=l[u+12>>2],(T|0)==(A|0))break e;if((T|0)>=0)break i;break r}if((A|0)!=-1)break r}a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],r=h;break t}S=l[a+4>>2],K=S>>>0<T>>>0,y=(K<<3)+a|0,S=T-(K?S:0)|0,l[y>>2]=S+l[y>>2],a=(K?12:4)+a|0,l[a>>2]=l[a>>2]-S,A=A-T|0,P=P-K|0,a=y;continue}break}if(l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r>>2]=l[r>>2]|32,r=0,(P|0)==2)break t;r=h-l[a+4>>2]|0}return Et=u+32|0,r|0}function bE(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;h=Et-96|0,Et=h,l[h>>2]=r,u=Et-16|0,Et=u,l[u+12>>2]=h,r=Et-144|0,Et=r,r=Ni(r,5520,144),A=h+16|0,a=A,l[r+44>>2]=a,l[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,l[r+48>>2]=y,a=a+y|0,l[r+28>>2]=a,l[r+16>>2]=a,bp(r,2202,h,0,0),y&&(a=l[r+20>>2],ft[a-((a|0)==l[r+16>>2])|0]=0),Et=r+144|0,Et=u+16|0,r=A;t:{if(r&3)for(;;){if(!At[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=l[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!At[r|0];);}return r=(r-A|0)+1|0,a=bh(r),a?r=Ni(a,A,r):r=0,Et=h+96|0,r|0}function bp(r,a,h,u,y){var A=0,T=0,S=0,P=0;A=Et-208|0,Et=A,l[A+204>>2]=h,h=A+160|0,Ui(h,0,40),l[A+200>>2]=l[A+204>>2];t:{if((lp(0,a,A+200|0,A+80|0,h,u,y)|0)<0){y=-1;break t}P=l[r+76>>2]>=0,T=l[r>>2],l[r+72>>2]<=0&&(l[r>>2]=T&-33);r:{i:{e:{if(!l[r+48>>2]){l[r+48>>2]=80,l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,S=l[r+44>>2],l[r+44>>2]=A;break e}if(l[r+16>>2])break i}if(h=-1,xp(r))break r}h=lp(r,a,A+200|0,A+80|0,A+160|0,u,y)}if(S&&(Pt[l[r+36>>2]](r,0,0)|0,l[r+48>>2]=0,l[r+44>>2]=S,l[r+28>>2]=0,a=l[r+20>>2],l[r+16>>2]=0,l[r+20>>2]=0,h=a?h:-1),a=r,r=l[r>>2],l[a>>2]=r|T&32,y=r&32?-1:h,!P)break t}return Et=A+208|0,y}function Qo(r){var a=0,h=m(0),u=0,y=0,A=0,T=0,S=0,P=m(0),K=0;A=Et-16|0,Et=A,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(At[r+4|0]&32){h=m(Pt[a|0](r,h,P,0));break r}h=m(Pt[a|0](r,h,P))}if(h==h)break t;l[A>>2]=3409,sr(r,A),qi(),de()}r:{i:{if(T=l[r+556>>2],a=l[r+560>>2],(T|0)!=(a|0)){for(a=a-T>>2,K=a>>>0<=1?1:a;;){if(y=l[(S<<2)+T>>2],!l[y+548>>2]){if(a=l[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=l[r+24>>2]>>>10&7),At[y+4|0]&2|(At[r+24|0]&8?(a|0)==5:0))break i;u=u||y}if(S=S+1|0,(K|0)!=(S|0))continue}break}if(u)break r}h=I[r+520>>2];break t}u=y}h=m(Qo(u)+I[u+232>>2])}return Et=A+16|0,h}function Un(r,a,h,u,y,A){var T=0,S=m(0),P=0,K=m(0);T=(l[(a<<2)+4320>>2]<<2)+r|0,S=I[T+216>>2];t:{r:{T=l[T+216>>2];i:{if((T|0)==2139156720)break i;if((T|0)==2140081935)break r;P=4336;e:{if((T|0)!=2141891242){if(S==S)break e;P=4344}switch(K=I[P>>2],S=m(zt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(xt(2,(T&-1073741825)+536870912|0),Bt()),!(T&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(ue(r,a,u)+Se(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[A>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;l[y>>2]=2}I[A>>2]=u}}function Ie(r,a,h){var u=m(0),y=m(0),A=0,T=m(0);r=r+116|0,A=l[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Ur(r,4,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}T=y==y?y:m(0)}return T}function De(r,a,h){var u=m(0),y=m(0),A=0,T=m(0);r=r+116|0,A=l[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Ur(r,5,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}T=y==y?y:m(0)}return T}function Ap(r,a,h,u,y,A){var T=0;t:{r:{if(r){i:{if(a&4){A=Pt[r|0](h,u,y,A)|0;break i}A=Pt[r|0](h,u,y)|0}if(A)break r}if(A=ht(588),a=Ni(A,h,552),l[a+564>>2]=0,l[a+556>>2]=0,l[a+560>>2]=0,y=l[h+556>>2],u=l[h+560>>2],(y|0)!=(u|0)){if(T=u-y|0,(T|0)<0)break t;for(r=ht(T),l[a+556>>2]=r,l[a+564>>2]=r+T;l[r>>2]=l[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););l[a+560>>2]=r}r=l[h+572>>2],l[a+568>>2]=l[h+568>>2],l[a+572>>2]=r,l[a+584>>2]=l[h+584>>2],r=l[h+580>>2],l[a+576>>2]=l[h+576>>2],l[a+580>>2]=r,l[a+552>>2]=0}return A}Ds(),de()}function sr(r,a){var h=0,u=0,y=0;y=Et-16|0,Et=y,l[y+12>>2]=a;t:{r:{if(!r){a=l[y+12>>2];break r}if(a=l[y+12>>2],h=l[r+568>>2],!h)break r;if(u=l[h+4>>2],At[h+8|0]&8){Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0;break t}r:{if(!At[7016]){h=ht(28),l[h+20>>2]=1065353216,l[h+24>>2]=0,l[h+12>>2]=0,l[h+16>>2]=0,l[h>>2]=0,ft[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,ft[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(At[h+8|0]&8))break r;Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0}Et=y+16|0}function $a(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Ur(r,5,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(xt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Ps(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Ur(r,4,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(xt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(xt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Ur(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+r|0,y=I[a>>2],a=l[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=l[r+24>>2],y=I[r+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function AE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Et-16|0,Et=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Et-16|0,Et=u,l[u+12>>2]=h;t:{if(r)break t;if(At[7016]){r=l[1753];break t}r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,ft[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(At[r+8|0]&8){Pt[y|0](r,0,5,0,4284,h)|0;break t}Pt[y|0](r,0,5,4284,h)|0}Et=u+16|0,qi(),de()}I[r+20>>2]=a==m(0)?m(0):a,Et=h+16|0}function Ep(r,a,h,u,y){var A=0,T=0,S=m(0),P=0;A=2,T=l[r+24>>2]>>>2&3;t:{r:{i:{if(!(!l[r+552>>2]|(a|0)!=2)){a=0,A=3;e:switch(T-2|0){case 0:break t;case 1:break e;default:break i}A=2;break t}if(a=0,T>>>0>1)break r}a=A}A=T}h=Gp(r,A,h),u=Gp(r,a,u),S=ue(r,A,y),T=r+228|0,P=A<<2,I[T+(l[P+4288>>2]<<2)>>2]=h+S,S=Se(r,A,y),I[T+(l[P+4304>>2]<<2)>>2]=h+S,h=ue(r,a,y),A=a<<2,I[T+(l[A+4288>>2]<<2)>>2]=u+h,h=Se(r,a,y),I[T+(l[A+4304>>2]<<2)>>2]=u+h}function EE(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var T=0,S=0,P=0;T=Et-48|0,Et=T,P=l[a+8>>2];t:{if(ft[7052]&1){a=l[1762];break t}a=ep(5,4480)|0,ft[7052]=1,l[1762]=a}l[T+40>>2]=A,I[T+32>>2]=y,l[T+24>>2]=u,I[T+16>>2]=h,S=+tE(a|0,P|0,2922,T+12|0,T+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=l[T+12>>2],A=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=A,A=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=A,JA(u|0),Et=T+48|0}function kE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,T=0;if(u=Et-32|0,Et=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){A=(y|15)+1|0,T=ht(A),l[u+16>>2]=A|-2147483648,l[u+8>>2]=T,l[u+12>>2]=y,A=y+T|0;break r}if(ft[u+19|0]=y,T=u+8|0,A=T+y|0,!y)break t}Ni(T,a+4|0,y)}return ft[A|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),QA(l[u+24>>2]),r=l[u+24>>2],Ma(r|0),Ma(l[u>>2]),ft[u+19|0]<0&&gi(l[u+8>>2]),Et=u+32|0,r|0}Ds(),de()}function hi(r,a,h){var u=0,y=0,A=0;if(!(At[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(xp(a))break r;r=l[a+16>>2]}if(A=l[a+20>>2],r-A>>>0<h>>>0){Pt[l[a+36>>2]](a,u,h)|0;break t}i:{if(l[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,At[u+r|0]==10)break}if(Pt[l[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,A=l[a+20>>2]}Ni(A,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function Th(r,a,h){var u=0,y=0,A=0;u=Et-16|0,Et=u,y=r+24|0,Pt[a|0](u+8|0,y),A=l[u+12>>2];t:{if((l[l[u+8>>2]>>2]&7<<A)>>A==(h|0))break t;for(Pt[a|0](u+8|0,y),a=l[u+8>>2],y=a,A=l[a>>2],a=l[u+12>>2],l[y>>2]=A&(7<<a^-1)|(h&7)<<a;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=u+16|0}function Br(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+28>>2],u=I[r+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function Se(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(xt(2,r),Bt()),u!=u)return m(zt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function ue(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(xt(2,r),Bt()),u!=u)return m(zt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function TE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,T=0,S=0;return y=l[r+84>>2],A=l[y>>2],u=l[y+4>>2],S=l[r+28>>2],T=l[r+20>>2]-S|0,T=u>>>0<T>>>0?u:T,T&&(Ni(A,S,T),A=T+l[y>>2]|0,l[y>>2]=A,u=l[y+4>>2]-T|0,l[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Ni(A,a,u),A=u+l[y>>2]|0,l[y>>2]=A,l[y+4>>2]=l[y+4>>2]-u),ft[A|0]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,h|0}function Re(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(xt(2,r),Bt()),h!=h))break r;h=(xt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return he(h,m(0))}function pe(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(xt(2,r),Bt()),h!=h))break r;h=(xt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return he(h,m(0))}function wE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+116>>2];t:{r:{if(a=l[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function SE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+80>>2];t:{r:{if(a=l[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function RE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+44>>2];t:{r:{if(a=l[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ne[r+8>>3]=y,l[r>>2]=u}function Gr(r,a,h,u){var y=0,A=0,T=0;r=r*a,y=Ah(r),y=y<0?y+1:y,T=y!=y;t:{if(!(T|!(Ve(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ve(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;A=0;r:{if(T||(A=1,y>.5))break r;A=Ve(y+-.5)<1e-4?1:0}r=r+A}return r!=r|a!=a?m(zt):m(r/a)}function kp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;l[r>>2]=2143289344,l[r+4>>2]=3;return}l[r>>2]=0,l[r+4>>2]=1;return}l[r>>2]=0,l[r+4>>2]=2;return}if(h=(xt(2,a),Bt()),h!=h){l[r>>2]=2143289344,l[r+4>>2]=0;return}l[r+4>>2]=a&1073741824?2:1,l[r>>2]=(a&-1073741825)+536870912}function Tp(r){var a=0,h=0,u=0;h=l[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=l[r+560>>2],h=l[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=l[l[h+(r<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(r=r+1|0,(u|0)==(r|0))break}}return a}function LE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+220>>2];t:{r:{if(a=l[a+220>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function _E(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+200>>2];t:{r:{if(a=l[a+200>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function CE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+204>>2];t:{r:{if(a=l[a+204>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function IE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+208>>2];t:{r:{if(a=l[a+208>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function DE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+212>>2];t:{r:{if(a=l[a+212>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function xE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+216>>2];t:{r:{if(a=l[a+216>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ne[r+8>>3]=u,l[r>>2]=a}function PE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(At[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(At[r+300|0]&3)==2)break t;a=r+260|0;break t;default:break r}a=(r+(a<<2)|0)+252|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),de()}function OE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(At[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(At[r+300|0]&3)==2)break t;a=r+276|0;break t;default:break r}a=(r+(a<<2)|0)+268|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),de()}function ME(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(At[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(At[r+300|0]&3)==2)break t;a=r+292|0;break t;default:break r}a=(r+(a<<2)|0)+284|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),de()}function $E(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=l[a>>2],y=I[a+40>>2],a=l[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(xt(2,(a&-1073741825)+536870912|0),Bt()),h=a&1073741824?2:1}l[r>>2]=h,Ne[r+8>>3]=u}function Vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ve(r))==m(tp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(Xi(r),te(2)&-2147483648|1602224127)),Bt()),a=(Xi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ve(r))==m(tp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(Xi(r),te(2)&-2147483648|1610612735)),Bt()),a=(Xi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function FE(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=l[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(zt),(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return m((xt(2,(r&-1073741825)+536870912|0),Bt()))}h=m(0)}return m(h)}function NE(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var T=0,S=0;return T=Et-16|0,Et=T,S=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(S=l[S+l[a>>2]>>2]),Pt[S|0](T,a,h,u,y,A),r=ht(16),a=l[T+12>>2],l[r+8>>2]=l[T+8>>2],l[r+12>>2]=a,a=l[T+4>>2],l[r>>2]=l[T>>2],l[r+4>>2]=a,Et=T+16|0,r|0}function wp(r,a){t:{if(a){a=Wp(l[a>>2]);break t}r:{if(At[7016]){a=l[1753];break r}a=ht(28),l[a+20>>2]=1065353216,l[a+24>>2]=0,l[a+12>>2]=0,l[a+16>>2]=0,l[a>>2]=0,ft[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,ft[7016]=1,l[1752]=l[1752]+1}a=Wp(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function UE(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+152>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function BE(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+188>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function GE(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=l[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=zt,(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return xt(2,(r&-1073741825)+536870912|0),+Bt()}h=0}return+h}function VE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>20&3)==(a|0))break t;for(l[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Bn(r,a,h){var u=0,y=0,A=0;t:{if(!a){u=r;break t}for(;u=fp(r,a,10),y=Fi,r=Rh(u,y,246,0)+r|0,h=h-1|0,ft[h|0]=r|48,A=a>>>0>9,r=u,a=y,!!A;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,ft[h|0]=Ue(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function HE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>22&1)==(a|0))break t;for(l[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function WE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>18&3)==(a|0))break t;for(l[r+24>>2]=h&-786433|a<<18&786432;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function jE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>16&3)==(a|0))break t;for(l[r+24>>2]=h&-196609|a<<16&196608;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function KE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function YE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function zE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function ZE(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(ft[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function XE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>4&7)==(a|0))break t;for(l[r+24>>2]=h&-113|a<<4&112;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function qE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>2&3)==(a|0))break t;for(l[r+24>>2]=h&-13|a<<2&12;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function QE(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=At[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(ft[r+4|0]=h&253|(a?2:0);;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function JE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Et-16|0,Et=u,y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](u,a,h),r=ht(16),a=l[u+12>>2],l[r+8>>2]=l[u+8>>2],l[r+12>>2]=a,a=l[u+4>>2],l[r>>2]=l[u>>2],l[r+4>>2]=a,Et=u+16|0,r|0}function Sp(r,a){var h=0,u=0;t:{r:{if(h=l[r+556>>2],u=l[r+560>>2],(h|0)==(u|0))break r;for(;;){if(l[h>>2]==(a|0))break r;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,xs(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function tk(r){r=r|0;var a=0,h=0;if(h=Et-16|0,Et=h,r=l[r>>2],l[r+8>>2]){for(;a=At[r+4|0],!!(!(a&4)&&(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=h+16|0;return}l[h>>2]=1024,sr(r,h),qi(),de()}function Rp(r,a){var h=0,u=0,y=0;if(pi(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=Rp(r*18446744073709552e3,a),h=l[a>>2]+-64|0),l[a>>2]=h,r;l[a>>2]=h-1022,xt(0,y|0),xt(1,u&-2146435073|1071644672),r=+Ae()}return r}function ek(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-16|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=ht(16),a=l[h+12>>2],l[r+8>>2]=l[h+8>>2],l[r+12>>2]=a,a=l[h+4>>2],l[r>>2]=l[h>>2],l[r+4>>2]=a,Et=h+16|0,r|0}function Jo(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(l[((a<<2)+u|0)+184>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function tl(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(l[((a<<2)+u|0)+192>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Gn(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(l[((a<<2)+u|0)+176>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function wh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,l[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,l[u+16>>2]=y;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Lp(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(l[((a<<2)+u|0)+92>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Sh(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(l[((a<<2)+u|0)+20>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function _p(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(l[((a<<2)+u|0)+56>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(ft[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function ik(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,l[a+5972>>2]=h,l[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);Eh(48),l[1756]=16,l[1757]=0,op(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,mp(),l[1770]=l[1768],l[1768]=7076}function nr(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(xt(2,r),Bt()),r=u==u),r}function el(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(xt(2,r),Bt()),r=u==u),r}function Rh(r,a,h,u){var y=0,A=0,T=0,S=0,P=0,K=0;return y=h>>>16|0,A=r>>>16|0,K=Ue(y,A),T=h&65535,S=r&65535,P=Ue(T,S),A=(P>>>16|0)+Ue(A,T)|0,y=(A&65535)+Ue(y,S)|0,Fi=(Ue(a,h)+K|0)+Ue(r,u)+(A>>>16)+(y>>>16)|0,P&65535|y<<16}function Cp(r,a){var h=0,u=0,y=0;u=Et-16|0,Et=u,h=At[r+4|0],y=h&-17,ft[r+4|0]=y;t:{if(a){if(l[r+560>>2]!=l[r+556>>2])break t;h=y|8}else h=h&231;l[r+8>>2]=a,ft[r+4|0]=h,Et=u+16|0;return}l[u>>2]=4128,sr(r,u),qi(),de()}function Ip(r){var a=0,h=m(0);a=0;t:{if((l[r+24>>2]&196608)==131072)break t;r:{if(!l[r+552>>2]||(h=I[r+32>>2],h!=h&&(h=I[r+28>>2],!(h>m(0)))))break r;if(a=1,h!=m(0))break t}a=Vn(r)!=m(0)}return a}function mi(r,a,h,u,y){var A=0;if(A=Et-256|0,Et=A,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Ui(A,a&255,h?u:256),!h)for(;hi(r,A,256),u=u-256|0,u>>>0>255;);hi(r,A,u)}Et=A+256|0}function fn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=l[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}kp(r,u)}function pn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=l[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}kp(r,u)}function Vn(r){var a=m(0),h=m(0);if(!l[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),ft[l[r+568>>2]+8|0]&1)||(a=m(0),h=I[r+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function Dp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=ft[u|0],rl(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ue(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Fa(r,a,h,u){var y=0;l[r+12>>2]=0,l[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return l[r>>2]=y,h=(h<<2)+y|0,l[r+8>>2]=h,l[r+12>>2]=(a<<2)+y,l[r+4>>2]=h,r}xh(),de()}function xp(r){var a=0;return a=l[r+72>>2],l[r+72>>2]=a-1|a,a=l[r>>2],a&8?(l[r>>2]=a|32,-1):(l[r+4>>2]=0,l[r+8>>2]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],0)}function rk(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var T=0;T=Et-16|0,Et=T,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](T,a,h,u,y,A),I[r>>2]=Ne[T>>3],I[r+4>>2]=Ne[T+8>>3],Et=T+16|0}function sk(){var r=0,a=0;return a=ht(4),r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,ft[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function nk(r,a){r=r|0,a=a|0,a=l[a>>2],Ne[r>>3]=I[a+228>>2],Ne[r+8>>3]=I[a+236>>2],Ne[r+16>>3]=I[a+232>>2],Ne[r+24>>3]=I[a+240>>2],Ne[r+32>>3]=I[a+244>>2],Ne[r+40>>3]=I[a+248>>2]}function ak(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-48|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=Ni(ht(48),h,48),Et=h+48|0,r|0}function ok(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Et-16|0,Et=y,r=jp(iE(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Et=y+16|0,Fi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function lk(r,a){r=r|0,a=a|0;var h=0,u=0;h=l[r>>2],r=l[h+556>>2];t:{if(l[h+560>>2]-r>>2>>>0<=a>>>0||(r=l[r+(a<<2)>>2],!r))break t;u=l[r>>2]}return u|0}function ck(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=l[r>>2],h?a=a|l[r+12>>2]:a=l[r+12>>2]&(a^-1),l[r+12>>2]=a;return}Ds(),de()}function hk(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var A=0;A=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(A=l[A+l[a>>2]>>2]),Pt[A|0](a,h,u,y)}function dk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function Pp(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function Op(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)|0}function uk(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function fk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),+Pt[u|0](a,h)}function ht(r){var a=0;r=r||1;t:{for(;;){if(a=bh(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}Ds(),de()}return a}function pk(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function Os(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function gn(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)|0}function Lh(r,a){return Xi(r),(te(2)&2147483647)>>>0<=2139095040?(Xi(a),(te(2)&2147483647)>>>0>2139095040?r:m(XA(r,a))):a}function he(r,a){return Xi(r),(te(2)&2147483647)>>>0<=2139095040?(Xi(a),(te(2)&2147483647)>>>0>2139095040?r:m(qA(r,a))):a}function Mp(r,a){r=r|0,a=a|0;var h=0;return h=Et-16|0,Et=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ma(l[h+8>>2]),Et=h+16|0,r|0}function gk(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function mk(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?Zp(5816,u,y)|0:Zp(5672,u,y)|0}function $p(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}ft[r|0]=a,r=1}return r}function vk(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),+Pt[h|0](a)}function Fp(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Xo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Hn(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Xo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function _h(r,a){var h=0;t:{if(ft[7044]&1){h=l[1760];break t}h=ep(1,4464)|0,ft[7044]=1,l[1760]=h}eE(h|0,r|0,a|0,0)}function yk(r,a){r=r|0,a=a|0;var h=0;h=l[r+8>>2],l[r+8>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),l[l[r>>2]+20>>2]=15}function bk(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=np((ft[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function Ak(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=np((ft[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Np(r,a){r=r|0,a=a|0;var h=0;h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)}function Ek(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=ft[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function kk(r,a){r=r|0,a=a|0;var h=0;h=l[r+4>>2],l[r+4>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),Cp(l[r>>2],14)}function Tk(r){r=r|0;var a=0;a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),l[l[r>>2]+20>>2]=0}function wk(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function Sk(r){r=r|0;var a=0;return a=ht(12),ft[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function Rk(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function Lk(r){r=r|0;var a=0;a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Cp(l[r>>2],0)}function Up(r){return r=r|0,l[r>>2]=4572,At[r+4|0]&&_h(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function Bp(r){return r=r|0,l[r>>2]=4452,At[r+4|0]&&_h(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function _k(){var r=0;return r=ht(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function Gp(r,a,h){return nr(r,a)?Ps(r,a,h):(h=$a(r,a,h),h==h&&(h=m(-h)),h)}function Vp(r,a){var h=0;h=Et-16|0,Et=h,r||(l[h>>2]=a,sr(0,h),qi(),de()),Et=h+16|0}function Hp(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&gi(a),l[1752]=l[1752]-1,gi(r))}function Ck(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Ds(),de()),l[l[r>>2]+12>>2]>>>a&1}function Ik(r,a,h,u,y){return r=r|0,a=a|0,h=h|0,u=u|0,y=y|0,Pt[r|0](a,h,u,y)|0}function Dk(){var r=0;return r=ht(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function xk(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(zt):a)}function Pk(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function Ok(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function Wp(r){var a=0;return a=cp(ht(588),r),Vp((r|0)!=0,2808),a}function Mk(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function $k(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function Fk(r,a){r=r|0,a=a|0,r=l[r>>2],ft[r+8|0]=At[r+8|0]&254|a}function Nk(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function Uk(r,a,h){r=r|0,a=a|0,h=+h,Sh(l[r>>2],a,vr(m(h)))}function Bk(r,a,h){r=r|0,a=a|0,h=+h,Sh(l[r>>2],a,Vr(m(h)))}function Gk(r,a,h,u){return Fi=0,0}function Vk(r,a,h){r=r|0,a=a|0,h=+h,Lp(l[r>>2],a,vr(m(h)))}function Hk(r,a,h){r=r|0,a=a|0,h=+h,Lp(l[r>>2],a,Vr(m(h)))}function Wk(r,a,h){r=r|0,a=a|0,h=+h,_p(l[r>>2],a,vr(m(h)))}function jk(r,a,h){r=r|0,a=a|0,h=+h,_p(l[r>>2],a,Vr(m(h)))}function Kk(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function Yk(r,a){r=r|0,a=a|0,Sh(l[r>>2],a,2141891242)}function Ch(r,a,h){r=r|0,a=a|0,h=+h,Ne[l[r>>2]+a>>3]=h}function zk(r){return r=r|0,(At[l[r>>2]+4|0]&2)>>>1|0}function Zk(r){return r=r|0,(At[l[r>>2]+4|0]&4)>>>2|0}function Xk(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function qk(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function Qk(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function Jk(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function Ih(r,a){return r=r|0,a=a|0,+Ne[l[r>>2]+a>>3]}function tT(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function eT(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function iT(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function rT(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function sT(r,a){r=r|0,a=+a,Gn(l[r>>2],0,vr(m(a)))}function nT(r,a){r=r|0,a=+a,Gn(l[r>>2],0,Vr(m(a)))}function aT(r,a){r=r|0,a=+a,Gn(l[r>>2],1,vr(m(a)))}function oT(r,a){r=r|0,a=+a,Gn(l[r>>2],1,Vr(m(a)))}function lT(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function cT(r,a){r=r|0,a=+a,Jo(l[r>>2],0,vr(m(a)))}function hT(r,a){r=r|0,a=+a,Jo(l[r>>2],0,Vr(m(a)))}function dT(r,a){r=r|0,a=+a,Jo(l[r>>2],1,vr(m(a)))}function uT(r,a){r=r|0,a=+a,Jo(l[r>>2],1,Vr(m(a)))}function fT(r,a){r=r|0,a=+a,tl(l[r>>2],0,vr(m(a)))}function pT(r,a){r=r|0,a=+a,tl(l[r>>2],1,vr(m(a)))}function gT(r,a){r=r|0,a=+a,tl(l[r>>2],1,Vr(m(a)))}function mT(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function vT(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function yT(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function il(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function bT(r,a){r=r|0,a=+a,tl(l[r>>2],0,Vr(m(a)))}function jp(r){return r?(l[1781]=r,-1):0}function AT(r,a){r=r|0,a=+a,wh(l[r>>2],vr(m(a)))}function ET(r,a){r=r|0,a=+a,wh(l[r>>2],Vr(m(a)))}function Kp(r,a,h){return m(ue(r,a,h)+Se(r,a,h))}function kT(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function Yp(r,a,h,u){rE(r|0,a|0,8,0,h|0,-1,u|0)}function TT(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function wT(r){return r=r|0,l[l[r>>2]+16>>2]&1}function ST(r){return r=r|0,Fn[l[r>>2]+26>>1]&3}function RT(r){r=r|0,Gn(l[r>>2],0,2141891242)}function LT(r){r=r|0,Gn(l[r>>2],1,2141891242)}function _T(r){return r=r|0,+I[l[r>>2]+228>>2]}function CT(r){return r=r|0,+I[l[r>>2]+236>>2]}function IT(r){return r=r|0,+I[l[r>>2]+232>>2]}function DT(r){return r=r|0,+I[l[r>>2]+240>>2]}function xT(r){return r=r|0,+I[l[r>>2]+244>>2]}function PT(r){return r=r|0,+I[l[r>>2]+248>>2]}function OT(r){return r=r|0,oE(l[r+60>>2])|0}function MT(r){return r=r|0,l[l[r>>2]+16>>2]}function $T(r){return r=r|0,ft[l[r>>2]+8|0]&1}function FT(r,a){r=r|0,a=a|0,Th(l[r>>2],5,a)}function NT(r,a){r=r|0,a=a|0,Th(l[r>>2],6,a)}function UT(r,a){r=r|0,a=a|0,Th(l[r>>2],7,a)}function BT(r){r=r|0,wh(l[r>>2],2141891242)}function zp(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function GT(r){return r=r|0,wp(ht(12),r)|0}function VT(r){r=r|0,_h(l[r+8>>2],3293)}function Zp(r,a,h){return bp(r,a,h,2,3)}function Xp(r){return r=r|0,Pt[r|0]()|0}function qp(r,a){r=r|0,a=a|0,Pt[r|0](a)}function HT(){return Ui(ht(48),0,48)|0}function qi(){Pt[l[1490]](),xh(),de()}function WT(){return wp(ht(12),0)|0}function Dh(r){r=r|0,r&&gi(r)}function rl(r){return r-48>>>0<10}function jT(r){return 7032}function KT(r){return 7036}function YT(r){return 7056}function zT(r){return 7059}function ZT(r){return 7062}function XT(r){return 7067}function Sr(r){return r=r|0,r|0}function Qp(r){r=r|0,ft[r+4|0]=1}function qT(r){r=r|0,gi(Up(r))}function QT(r){r=r|0,gi(Bp(r))}function JT(r){return 0}function Jp(r){de()}function t2(){xh(),de()}function xh(){Ds(),de()}G=At,Rt();var Pt=B([null,mk,dE,pE,Sr,lT,Xk,qk,Sr,Sr,Sr,Sr,Sr,Sr,rk,Nk,op,jT,il,NE,KT,Sr,Sr,il,Qp,zp,Mp,wk,kE,bk,YT,il,Np,zT,Sr,Sr,il,Qp,zp,Mp,Sk,Ak,ZT,Hp,Xp,sk,qp,Hp,ck,Pp,AE,pk,Mk,Os,TT,Os,Fk,Ck,Op,wT,gn,MT,gn,$T,HT,Dh,_k,Dh,Dk,Dh,Ih,Ch,rT,Kk,XT,gp,Xp,WT,kT,GT,qp,gp,vE,Np,fE,Os,jE,Os,Wk,uk,jk,FT,NT,UT,qE,WE,XE,Uk,Bk,Yk,VE,HE,YE,gk,AT,ET,BT,zE,ZE,sT,nT,RT,aT,oT,LT,cT,hT,dT,uT,fT,bT,pT,gT,KE,UE,Vk,Hk,BE,ST,gn,SE,JE,mT,Qk,Jk,vT,tT,yT,RE,$E,ek,Ok,vk,Ek,_E,CE,IE,DE,xE,LE,xk,GE,fk,eT,iT,wE,FE,dk,gE,Pp,mE,Os,$k,gn,Pk,gn,lk,Op,zk,gn,QE,Os,kk,Os,Lk,yk,Os,Tk,tk,Zk,gn,uE,hk,_T,CT,IT,DT,xT,PT,nk,ak,PE,OE,ME,Ih,Ch,Ih,Ch,mp,Bp,QT,EE,Jp,t2,Up,qT,VT,Jp,OT,yE,ok,JT,Gk,TE,t2]);function e2(){return $i.byteLength/65536|0}function t3(r){r=r|0;var a=e2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ue(h,65536)),y=new Int8Array(u);y.set(ft),ft=new Int8Array(u),Nr=new Int16Array(u),l=new Int32Array(u),At=new Uint8Array(u),Fn=new Uint16Array(u),Jf=new Uint32Array(u),I=new Float32Array(u),Ne=new Float64Array(u),$i=u,rr.buffer=$i,G=At}return a}return{E:ik,F:bE,G:Rk,H:bh,I:Pt,J:gi,K:Ik}}return Zo(C)}(_)}var L=Error,x={};b=[],typeof x!="object"&&Dt("no native wasm support detected");var M,N=!1;function D(_,C,B){B=C+B;for(var G="";!(C>=B);){var it=_[C++];if(!it)break;if(it&128){var vt=_[C++]&63;if((it&224)==192)G+=String.fromCharCode((it&31)<<6|vt);else{var lt=_[C++]&63;it=(it&240)==224?(it&15)<<12|vt<<6|lt:(it&7)<<18|vt<<12|lt<<6|_[C++]&63,65536>it?G+=String.fromCharCode(it):(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023))}}else G+=String.fromCharCode(it)}return G}var F,H,j,st,at,Q,kt,gt,Ft;function Kt(_){F=_,o.HEAP8=H=new Int8Array(_),o.HEAP16=st=new Int16Array(_),o.HEAP32=Q=new Int32Array(_),o.HEAPU8=j=new Uint8Array(_),o.HEAPU16=at=new Uint16Array(_),o.HEAPU32=kt=new Uint32Array(_),o.HEAPF32=gt=new Float32Array(_),o.HEAPF64=Ft=new Float64Array(_)}var V=o.INITIAL_MEMORY||16777216;o.wasmMemory?M=o.wasmMemory:M=new E,M&&(F=M.buffer),V=F.byteLength,Kt(F);var J,St=[],$=[],U=[];function Z(){var _=o.preRun.shift();St.unshift(_)}var mt=0,bt=null;function Dt(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),N=!0,_=new L(_+". Build with -sASSERTIONS for more info."),d(_),_}function Ut(_){return _.startsWith("data:application/octet-stream;base64,")}var Qt;if(Qt="<<< WASM_BINARY_FILE >>>",!Ut(Qt)){var fe=Qt;Qt=o.locateFile?o.locateFile(fe,p):p+fe}function re(_){var C=Qt;try{try{if(C==Qt&&b)new Uint8Array(b);else{if(Ut(C)){try{var B=YA(C.slice(37)),G=new Uint8Array(B.length);for(C=0;C<B.length;++C)G[C]=B.charCodeAt(C);var it=G}catch{throw Error("Converting base64 string to bytes failed.")}var vt=it}else vt=void 0;if(!vt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(_t){Dt(_t)}var lt=new k,Rt=new w(_)}catch(_t){throw _=_t.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),_t}return[Rt,lt]}function Ht(_){for(;0<_.length;)_.shift()(o)}function Oe(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var C=_.charCodeAt(0);return 48<=C&&57>=C?"_"+_:_}function me(_,C){return _=Oe(_),function(){return C.apply(this,arguments)}}var Wt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],oe=[];function se(_){var C=Error,B=me(_,function(G){this.name=_,this.message=G,G=Error(G).stack,G!==void 0&&(this.stack=this.toString()+`
92
+ `+G.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(C.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Te=void 0;function Mt(_){throw new Te(_)}var Me=_=>(_||Mt("Cannot use deleted val. handle = "+_),Wt[_].value),qe=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var C=oe.length?oe.pop():Wt.length;return Wt[C]={fa:1,value:_},C}},Mi=void 0,kr=void 0;function we(_){for(var C="";j[_];)C+=kr[j[_++]];return C}var li=[];function ve(){for(;li.length;){var _=li.pop();_.L.Z=!1,_.delete()}}var Je=void 0,ti={};function Zi(_,C){for(C===void 0&&Mt("ptr should not be undefined");_.P;)C=_.aa(C),_=_.P;return C}var Fe={};function Ci(_){_=ZA(_);var C=we(_);return Is(_),C}function rs(_,C){var B=Fe[_];return B===void 0&&Mt(C+" has unknown type "+Ci(_)),B}function ci(){}var Tr=!1;function Rs(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function Ls(_,C,B){return C===B?_:B.P===void 0?null:(_=Ls(_,C,B.P),_===null?null:B.ma(_))}var ir={};function ct(_,C){return C=Zi(_,C),ti[C]}var Gt=void 0;function Zt(_){throw new Gt(_)}function ye(_,C){return C.O&&C.N||Zt("makeClassHandle requires ptr and ptrType"),!!C.T!=!!C.S&&Zt("Both smartPtrType and smartPtr must be specified"),C.count={value:1},le(Object.create(_,{L:{value:C}}))}function le(_){return typeof FinalizationRegistry>"u"?(le=C=>C,_):(Tr=new FinalizationRegistry(C=>{Rs(C.L)}),le=C=>{var B=C.L;return B.S&&Tr.register(C,{L:B},C),C},ci=C=>{Tr.unregister(C)},le(_))}var ni={};function Ii(_){for(;_.length;){var C=_.pop();_.pop()(C)}}function ur(_){return this.fromWireType(Q[_>>2])}var ss={},fr={};function pr(_,C,B){function G(Rt){Rt=B(Rt),Rt.length!==_.length&&Zt("Mismatched type converter count");for(var _t=0;_t<_.length;++_t)Di(_[_t],Rt[_t])}_.forEach(function(Rt){fr[Rt]=C});var it=Array(C.length),vt=[],lt=0;C.forEach((Rt,_t)=>{Fe.hasOwnProperty(Rt)?it[_t]=Fe[Rt]:(vt.push(Rt),ss.hasOwnProperty(Rt)||(ss[Rt]=[]),ss[Rt].push(()=>{it[_t]=Fe[Rt],++lt,lt===vt.length&&G(it)}))}),vt.length===0&&G(it)}function _s(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function Di(_,C,B={}){if(!("argPackAdvance"in C))throw new TypeError("registerType registeredInstance requires argPackAdvance");var G=C.name;if(_||Mt('type "'+G+'" must have a positive integer typeid pointer'),Fe.hasOwnProperty(_)){if(B.ta)return;Mt("Cannot register type '"+G+"' twice")}Fe[_]=C,delete fr[_],ss.hasOwnProperty(_)&&(C=ss[_],delete ss[_],C.forEach(it=>it()))}function Oa(_){Mt(_.L.O.M.name+" instance already deleted")}function gr(){}function Cs(_,C,B){if(_[C].R===void 0){var G=_[C];_[C]=function(){return _[C].R.hasOwnProperty(arguments.length)||Mt("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[C].R+")!"),_[C].R[arguments.length].apply(this,arguments)},_[C].R=[],_[C].R[G.Y]=G}}function _A(_,C){o.hasOwnProperty(_)?(Mt("Cannot register public name '"+_+"' twice"),Cs(o,_,_),o.hasOwnProperty(void 0)&&Mt("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=C):o[_]=C}function CA(_,C,B,G,it,vt,lt,Rt){this.name=_,this.constructor=C,this.W=B,this.V=G,this.P=it,this.oa=vt,this.aa=lt,this.ma=Rt,this.ia=[]}function dh(_,C,B){for(;C!==B;)C.aa||Mt("Expected null or instance of "+B.name+", got an instance of "+C.name),_=C.aa(_),C=C.P;return _}function IA(_,C){return C===null?(this.da&&Mt("null is not a valid "+this.name),0):(C.L||Mt('Cannot pass "'+gh(C)+'" as a '+this.name),C.L.N||Mt("Cannot pass deleted object as a pointer of type "+this.name),dh(C.L.N,C.L.O.M,this.M))}function DA(_,C){if(C===null){if(this.da&&Mt("null is not a valid "+this.name),this.ca){var B=this.ea();return _!==null&&_.push(this.V,B),B}return 0}if(C.L||Mt('Cannot pass "'+gh(C)+'" as a '+this.name),C.L.N||Mt("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&C.L.O.ba&&Mt("Cannot convert argument of type "+(C.L.T?C.L.T.name:C.L.O.name)+" to parameter type "+this.name),B=dh(C.L.N,C.L.O.M,this.M),this.ca)switch(C.L.S===void 0&&Mt("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:C.L.T===this?B=C.L.S:Mt("Cannot convert argument of type "+(C.L.T?C.L.T.name:C.L.O.name)+" to parameter type "+this.name);break;case 1:B=C.L.S;break;case 2:if(C.L.T===this)B=C.L.S;else{var G=C.clone();B=this.wa(B,qe(function(){G.delete()})),_!==null&&_.push(this.V,B)}break;default:Mt("Unsupporting sharing policy")}return B}function xA(_,C){return C===null?(this.da&&Mt("null is not a valid "+this.name),0):(C.L||Mt('Cannot pass "'+gh(C)+'" as a '+this.name),C.L.N||Mt("Cannot pass deleted object as a pointer of type "+this.name),C.L.O.ba&&Mt("Cannot convert argument of type "+C.L.O.name+" to parameter type "+this.name),dh(C.L.N,C.L.O.M,this.M))}function ns(_,C,B,G){this.name=_,this.M=C,this.da=B,this.ba=G,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,C.P!==void 0?this.toWireType=DA:(this.toWireType=G?IA:xA,this.U=null)}function PA(_,C){o.hasOwnProperty(_)||Zt("Replacing nonexistant public symbol"),o[_]=C,o[_].Y=void 0}function OA(_,C){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),_.includes("j")){var G=o["dynCall_"+_];G=B&&B.length?G.apply(null,[C].concat(B)):G.call(null,C)}else G=J.get(C).apply(null,B);return G}}function wr(_,C){_=we(_);var B=_.includes("j")?OA(_,C):J.get(C);return typeof B!="function"&&Mt("unknown function pointer with signature "+_+": "+C),B}var Yf=void 0;function jo(_,C){function B(vt){it[vt]||Fe[vt]||(fr[vt]?fr[vt].forEach(B):(G.push(vt),it[vt]=!0))}var G=[],it={};throw C.forEach(B),new Yf(_+": "+G.map(Ci).join([", "]))}function uh(_,C,B,G,it){var vt=C.length;2>vt&&Mt("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=C[1]!==null&&B!==null,Rt=!1;for(B=1;B<C.length;++B)if(C[B]!==null&&C[B].U===void 0){Rt=!0;break}var _t=C[0].name!=="void",Ct=vt-2,Nt=Array(Ct),Yt=[],te=[];return function(){if(arguments.length!==Ct&&Mt("function "+_+" called with "+arguments.length+" arguments, expected "+Ct+" args!"),te.length=0,Yt.length=lt?2:1,Yt[0]=it,lt){var xt=C[1].toWireType(te,this);Yt[1]=xt}for(var Ae=0;Ae<Ct;++Ae)Nt[Ae]=C[Ae+2].toWireType(te,arguments[Ae]),Yt.push(Nt[Ae]);if(Ae=G.apply(null,Yt),Rt)Ii(te);else for(var pi=lt?1:2;pi<C.length;pi++){var de=pi===1?xt:Nt[pi-2];C[pi].U!==null&&C[pi].U(de)}return xt=_t?C[0].fromWireType(Ae):void 0,xt}}function fh(_,C){for(var B=[],G=0;G<_;G++)B.push(kt[C+4*G>>2]);return B}function ph(_){4<_&&--Wt[_].fa===0&&(Wt[_]=void 0,oe.push(_))}function gh(_){if(_===null)return"null";var C=typeof _;return C==="object"||C==="array"||C==="function"?_.toString():""+_}function MA(_,C){switch(C){case 2:return function(B){return this.fromWireType(gt[B>>2])};case 3:return function(B){return this.fromWireType(Ft[B>>3])};default:throw new TypeError("Unknown float type: "+_)}}function $A(_,C,B){switch(C){case 0:return B?function(G){return H[G]}:function(G){return j[G]};case 1:return B?function(G){return st[G>>1]}:function(G){return at[G>>1]};case 2:return B?function(G){return Q[G>>2]}:function(G){return kt[G>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function FA(_,C){for(var B="",G=0;!(G>=C/2);++G){var it=st[_+2*G>>1];if(it==0)break;B+=String.fromCharCode(it)}return B}function NA(_,C,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var G=C;B=B<2*_.length?B/2:_.length;for(var it=0;it<B;++it)st[C>>1]=_.charCodeAt(it),C+=2;return st[C>>1]=0,C-G}function UA(_){return 2*_.length}function BA(_,C){for(var B=0,G="";!(B>=C/4);){var it=Q[_+4*B>>2];if(it==0)break;++B,65536<=it?(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023)):G+=String.fromCharCode(it)}return G}function GA(_,C,B){if(B===void 0&&(B=2147483647),4>B)return 0;var G=C;B=G+B-4;for(var it=0;it<_.length;++it){var vt=_.charCodeAt(it);if(55296<=vt&&57343>=vt){var lt=_.charCodeAt(++it);vt=65536+((vt&1023)<<10)|lt&1023}if(Q[C>>2]=vt,C+=4,C+4>B)break}return Q[C>>2]=0,C-G}function VA(_){for(var C=0,B=0;B<_.length;++B){var G=_.charCodeAt(B);55296<=G&&57343>=G&&++B,C+=4}return C}var HA={};function zf(_){var C=HA[_];return C===void 0?we(_):C}var Ko=[];function WA(_){var C=Ko.length;return Ko.push(_),C}function jA(_,C){for(var B=Array(_),G=0;G<_;++G)B[G]=rs(kt[C+4*G>>2],"parameter "+G);return B}var Zf=[],KA=[null,[],[]];Te=o.BindingError=se("BindingError"),o.count_emval_handles=function(){for(var _=0,C=5;C<Wt.length;++C)Wt[C]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<Wt.length;++_)if(Wt[_]!==void 0)return Wt[_];return null},Mi=o.PureVirtualError=se("PureVirtualError");for(var Xf=Array(256),Yo=0;256>Yo;++Yo)Xf[Yo]=String.fromCharCode(Yo);kr=Xf,o.getInheritedInstanceCount=function(){return Object.keys(ti).length},o.getLiveInheritedInstances=function(){var _=[],C;for(C in ti)ti.hasOwnProperty(C)&&_.push(ti[C]);return _},o.flushPendingDeletes=ve,o.setDelayFunction=function(_){Je=_,li.length&&Je&&Je(ve)},Gt=o.InternalError=se("InternalError"),gr.prototype.isAliasOf=function(_){if(!(this instanceof gr&&_ instanceof gr))return!1;var C=this.L.O.M,B=this.L.N,G=_.L.O.M;for(_=_.L.N;C.P;)B=C.aa(B),C=C.P;for(;G.P;)_=G.aa(_),G=G.P;return C===G&&B===_},gr.prototype.clone=function(){if(this.L.N||Oa(this),this.L.$)return this.L.count.value+=1,this;var _=le,C=Object,B=C.create,G=Object.getPrototypeOf(this),it=this.L;return _=_(B.call(C,G,{L:{value:{count:it.count,Z:it.Z,$:it.$,N:it.N,O:it.O,S:it.S,T:it.T}}})),_.L.count.value+=1,_.L.Z=!1,_},gr.prototype.delete=function(){this.L.N||Oa(this),this.L.Z&&!this.L.$&&Mt("Object already scheduled for deletion"),ci(this),Rs(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},gr.prototype.isDeleted=function(){return!this.L.N},gr.prototype.deleteLater=function(){return this.L.N||Oa(this),this.L.Z&&!this.L.$&&Mt("Object already scheduled for deletion"),li.push(this),li.length===1&&Je&&Je(ve),this.L.Z=!0,this},ns.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},ns.prototype.ga=function(_){this.V&&this.V(_)},ns.prototype.argPackAdvance=8,ns.prototype.readValueFromPointer=ur,ns.prototype.deleteObject=function(_){_!==null&&_.delete()},ns.prototype.fromWireType=function(_){function C(){return this.ca?ye(this.M.W,{O:this.va,N:B,T:this,S:_}):ye(this.M.W,{O:this,N:_})}var B=this.pa(_);if(!B)return this.ga(_),null;var G=ct(this.M,B);if(G!==void 0)return G.L.count.value===0?(G.L.N=B,G.L.S=_,G.clone()):(G=G.clone(),this.ga(_),G);if(G=this.M.oa(B),G=ir[G],!G)return C.call(this);G=this.ba?G.ka:G.pointerType;var it=Ls(B,this.M,G.M);return it===null?C.call(this):this.ca?ye(G.M.W,{O:G,N:it,T:this,S:_}):ye(G.M.W,{O:G,N:it})},Yf=o.UnboundTypeError=se("UnboundTypeError");var YA=typeof atob=="function"?atob:function(_){var C="",B=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++));G=G<<2|it>>4,it=(it&15)<<4|vt>>2;var Rt=(vt&3)<<6|lt;C+=String.fromCharCode(G),vt!==64&&(C+=String.fromCharCode(it)),lt!==64&&(C+=String.fromCharCode(Rt))}while(B<_.length);return C},zA={q:function(_,C,B){_=we(_),C=rs(C,"wrapper"),B=Me(B);var G=[].slice,it=C.M,vt=it.W,lt=it.P.W,Rt=it.P.constructor;_=me(_,function(){it.P.ia.forEach((function(Ct){if(this[Ct]===lt[Ct])throw new Mi("Pure virtual function "+Ct+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:vt}),this.__construct.apply(this,G.call(arguments))}),vt.__construct=function(){this===vt&&Mt("Pass correct 'this' to __construct");var Ct=Rt.implement.apply(void 0,[this].concat(G.call(arguments)));ci(Ct);var Nt=Ct.L;Ct.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),le(this),Ct=Nt.N,Ct=Zi(it,Ct),ti.hasOwnProperty(Ct)?Mt("Tried to register registered instance: "+Ct):ti[Ct]=this},vt.__destruct=function(){this===vt&&Mt("Pass correct 'this' to __destruct"),ci(this);var Ct=this.L.N;Ct=Zi(it,Ct),ti.hasOwnProperty(Ct)?delete ti[Ct]:Mt("Tried to unregister unregistered instance: "+Ct)},_.prototype=Object.create(vt);for(var _t in B)_.prototype[_t]=B[_t];return qe(_)},k:function(_){var C=ni[_];delete ni[_];var B=C.ea,G=C.V,it=C.ha,vt=it.map(lt=>lt.sa).concat(it.map(lt=>lt.ya));pr([_],vt,lt=>{var Rt={};return it.forEach((_t,Ct)=>{var Nt=lt[Ct],Yt=_t.qa,te=_t.ra,xt=lt[Ct+it.length],Ae=_t.xa,pi=_t.za;Rt[_t.na]={read:de=>Nt.fromWireType(Yt(te,de)),write:(de,Xi)=>{var Bt=[];Ae(pi,de,xt.toWireType(Bt,Xi)),Ii(Bt)}}}),[{name:C.name,fromWireType:function(_t){var Ct={},Nt;for(Nt in Rt)Ct[Nt]=Rt[Nt].read(_t);return G(_t),Ct},toWireType:function(_t,Ct){for(var Nt in Rt)if(!(Nt in Ct))throw new TypeError('Missing field: "'+Nt+'"');var Yt=B();for(Nt in Rt)Rt[Nt].write(Yt,Ct[Nt]);return _t!==null&&_t.push(G,Yt),Yt},argPackAdvance:8,readValueFromPointer:ur,U:G}]})},w:function(){},C:function(_,C,B,G,it){var vt=_s(B);C=we(C),Di(_,{name:C,fromWireType:function(lt){return!!lt},toWireType:function(lt,Rt){return Rt?G:it},argPackAdvance:8,readValueFromPointer:function(lt){if(B===1)var Rt=H;else if(B===2)Rt=st;else if(B===4)Rt=Q;else throw new TypeError("Unknown boolean type size: "+C);return this.fromWireType(Rt[lt>>vt])},U:null})},g:function(_,C,B,G,it,vt,lt,Rt,_t,Ct,Nt,Yt,te){Nt=we(Nt),vt=wr(it,vt),Rt&&(Rt=wr(lt,Rt)),Ct&&(Ct=wr(_t,Ct)),te=wr(Yt,te);var xt=Oe(Nt);_A(xt,function(){jo("Cannot construct "+Nt+" due to unbound types",[G])}),pr([_,C,B],G?[G]:[],function(Ae){if(Ae=Ae[0],G)var pi=Ae.M,de=pi.W;else de=gr.prototype;Ae=me(xt,function(){if(Object.getPrototypeOf(this)!==Xi)throw new Te("Use 'new' to construct "+Nt);if(Bt.X===void 0)throw new Te(Nt+" has no accessible constructor");var ei=Bt.X[arguments.length];if(ei===void 0)throw new Te("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ei.apply(this,arguments)});var Xi=Object.create(de,{constructor:{value:Ae}});Ae.prototype=Xi;var Bt=new CA(Nt,Ae,Xi,te,pi,vt,Rt,Ct);pi=new ns(Nt,Bt,!0,!1),de=new ns(Nt+"*",Bt,!1,!1);var Zo=new ns(Nt+" const*",Bt,!1,!0);return ir[_]={pointerType:de,ka:Zo},PA(xt,Ae),[pi,de,Zo]})},d:function(_,C,B,G,it,vt,lt){var Rt=fh(B,G);C=we(C),vt=wr(it,vt),pr([],[_],function(_t){function Ct(){jo("Cannot call "+Nt+" due to unbound types",Rt)}_t=_t[0];var Nt=_t.name+"."+C;C.startsWith("@@")&&(C=Symbol[C.substring(2)]);var Yt=_t.M.constructor;return Yt[C]===void 0?(Ct.Y=B-1,Yt[C]=Ct):(Cs(Yt,C,Nt),Yt[C].R[B-1]=Ct),pr([],Rt,function(te){return te=uh(Nt,[te[0],null].concat(te.slice(1)),null,vt,lt),Yt[C].R===void 0?(te.Y=B-1,Yt[C]=te):Yt[C].R[B-1]=te,[]}),[]})},p:function(_,C,B,G,it,vt){0<C||Dt();var lt=fh(C,B);it=wr(G,it),pr([],[_],function(Rt){Rt=Rt[0];var _t="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[C-1]!==void 0)throw new Te("Cannot register multiple constructors with identical number of parameters ("+(C-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[C-1]=()=>{jo("Cannot construct "+Rt.name+" due to unbound types",lt)},pr([],lt,function(Ct){return Ct.splice(1,0,null),Rt.M.X[C-1]=uh(_t,Ct,null,it,vt),[]}),[]})},b:function(_,C,B,G,it,vt,lt,Rt){var _t=fh(B,G);C=we(C),vt=wr(it,vt),pr([],[_],function(Ct){function Nt(){jo("Cannot call "+Yt+" due to unbound types",_t)}Ct=Ct[0];var Yt=Ct.name+"."+C;C.startsWith("@@")&&(C=Symbol[C.substring(2)]),Rt&&Ct.M.ia.push(C);var te=Ct.M.W,xt=te[C];return xt===void 0||xt.R===void 0&&xt.className!==Ct.name&&xt.Y===B-2?(Nt.Y=B-2,Nt.className=Ct.name,te[C]=Nt):(Cs(te,C,Yt),te[C].R[B-2]=Nt),pr([],_t,function(Ae){return Ae=uh(Yt,Ae,Ct,vt,lt),te[C].R===void 0?(Ae.Y=B-2,te[C]=Ae):te[C].R[B-2]=Ae,[]}),[]})},B:function(_,C){C=we(C),Di(_,{name:C,fromWireType:function(B){var G=Me(B);return ph(B),G},toWireType:function(B,G){return qe(G)},argPackAdvance:8,readValueFromPointer:ur,U:null})},n:function(_,C,B){B=_s(B),C=we(C),Di(_,{name:C,fromWireType:function(G){return G},toWireType:function(G,it){return it},argPackAdvance:8,readValueFromPointer:MA(C,B),U:null})},e:function(_,C,B,G,it){C=we(C),it===-1&&(it=4294967295),it=_s(B);var vt=Rt=>Rt;if(G===0){var lt=32-8*B;vt=Rt=>Rt<<lt>>>lt}B=C.includes("unsigned")?function(Rt,_t){return _t>>>0}:function(Rt,_t){return _t},Di(_,{name:C,fromWireType:vt,toWireType:B,argPackAdvance:8,readValueFromPointer:$A(C,it,G!==0),U:null})},c:function(_,C,B){function G(vt){vt>>=2;var lt=kt;return new it(F,lt[vt+1],lt[vt])}var it=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][C];B=we(B),Di(_,{name:B,fromWireType:G,argPackAdvance:8,readValueFromPointer:G},{ta:!0})},o:function(_,C){C=we(C);var B=C==="std::string";Di(_,{name:C,fromWireType:function(G){var it=kt[G>>2],vt=G+4;if(B)for(var lt=vt,Rt=0;Rt<=it;++Rt){var _t=vt+Rt;if(Rt==it||j[_t]==0){if(lt=lt?D(j,lt,_t-lt):"",Ct===void 0)var Ct=lt;else Ct+=String.fromCharCode(0),Ct+=lt;lt=_t+1}}else{for(Ct=Array(it),Rt=0;Rt<it;++Rt)Ct[Rt]=String.fromCharCode(j[vt+Rt]);Ct=Ct.join("")}return Is(G),Ct},toWireType:function(G,it){it instanceof ArrayBuffer&&(it=new Uint8Array(it));var vt,lt=typeof it=="string";if(lt||it instanceof Uint8Array||it instanceof Uint8ClampedArray||it instanceof Int8Array||Mt("Cannot pass non-string to std::string"),B&&lt){var Rt=0;for(vt=0;vt<it.length;++vt){var _t=it.charCodeAt(vt);127>=_t?Rt++:2047>=_t?Rt+=2:55296<=_t&&57343>=_t?(Rt+=4,++vt):Rt+=3}vt=Rt}else vt=it.length;if(Rt=qf(4+vt+1),_t=Rt+4,kt[Rt>>2]=vt,B&&lt){if(lt=_t,_t=vt+1,vt=j,0<_t){_t=lt+_t-1;for(var Ct=0;Ct<it.length;++Ct){var Nt=it.charCodeAt(Ct);if(55296<=Nt&&57343>=Nt){var Yt=it.charCodeAt(++Ct);Nt=65536+((Nt&1023)<<10)|Yt&1023}if(127>=Nt){if(lt>=_t)break;vt[lt++]=Nt}else{if(2047>=Nt){if(lt+1>=_t)break;vt[lt++]=192|Nt>>6}else{if(65535>=Nt){if(lt+2>=_t)break;vt[lt++]=224|Nt>>12}else{if(lt+3>=_t)break;vt[lt++]=240|Nt>>18,vt[lt++]=128|Nt>>12&63}vt[lt++]=128|Nt>>6&63}vt[lt++]=128|Nt&63}}vt[lt]=0}}else if(lt)for(lt=0;lt<vt;++lt)Ct=it.charCodeAt(lt),255<Ct&&(Is(_t),Mt("String has UTF-16 code units that do not fit in 8 bits")),j[_t+lt]=Ct;else for(lt=0;lt<vt;++lt)j[_t+lt]=it[lt];return G!==null&&G.push(Is,Rt),Rt},argPackAdvance:8,readValueFromPointer:ur,U:function(G){Is(G)}})},j:function(_,C,B){if(B=we(B),C===2)var G=FA,it=NA,vt=UA,lt=()=>at,Rt=1;else C===4&&(G=BA,it=GA,vt=VA,lt=()=>kt,Rt=2);Di(_,{name:B,fromWireType:function(_t){for(var Ct=kt[_t>>2],Nt=lt(),Yt,te=_t+4,xt=0;xt<=Ct;++xt){var Ae=_t+4+xt*C;(xt==Ct||Nt[Ae>>Rt]==0)&&(te=G(te,Ae-te),Yt===void 0?Yt=te:(Yt+=String.fromCharCode(0),Yt+=te),te=Ae+C)}return Is(_t),Yt},toWireType:function(_t,Ct){typeof Ct!="string"&&Mt("Cannot pass non-string to C++ string type "+B);var Nt=vt(Ct),Yt=qf(4+Nt+C);return kt[Yt>>2]=Nt>>Rt,it(Ct,Yt+4,Nt+C),_t!==null&&_t.push(Is,Yt),Yt},argPackAdvance:8,readValueFromPointer:ur,U:function(_t){Is(_t)}})},l:function(_,C,B,G,it,vt){ni[_]={name:we(C),ea:wr(B,G),V:wr(it,vt),ha:[]}},i:function(_,C,B,G,it,vt,lt,Rt,_t,Ct){ni[_].ha.push({na:we(C),sa:B,qa:wr(G,it),ra:vt,ya:lt,xa:wr(Rt,_t),za:Ct})},D:function(_,C){C=we(C),Di(_,{ua:!0,name:C,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,C,B,G,it){_=Ko[_],C=Me(C),B=zf(B);var vt=[];return kt[G>>2]=qe(vt),_(C,B,vt,it)},u:function(_,C,B,G){_=Ko[_],C=Me(C),B=zf(B),_(C,B,null,G)},h:ph,m:function(_,C){var B=jA(_,C),G=B[0];C=G.name+"_$"+B.slice(1).map(function(lt){return lt.name}).join("_")+"$";var it=Zf[C];if(it!==void 0)return it;var vt=Array(_-1);return it=WA((lt,Rt,_t,Ct)=>{for(var Nt=0,Yt=0;Yt<_-1;++Yt)vt[Yt]=B[Yt+1].readValueFromPointer(Ct+Nt),Nt+=B[Yt+1].argPackAdvance;for(lt=lt[Rt].apply(lt,vt),Yt=0;Yt<_-1;++Yt)B[Yt+1].la&&B[Yt+1].la(vt[Yt]);if(!G.ua)return G.toWireType(_t,lt)}),Zf[C]=it},r:function(_){4<_&&(Wt[_].fa+=1)},s:function(_){var C=Me(_);Ii(C),ph(_)},f:function(){Dt("")},y:function(_,C,B){j.copyWithin(_,C,C+B)},x:function(_){var C=j.length;if(_>>>=0,2147483648<_)return!1;for(var B=1;4>=B;B*=2){var G=C*(1+.2/B);G=Math.min(G,_+100663296);var it=Math;G=Math.max(_,G),it=it.min.call(it,2147483648,G+(65536-G%65536)%65536);t:{try{M.grow(it-F.byteLength+65535>>>16),Kt(M.buffer);var vt=1;break t}catch{}vt=void 0}if(vt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,C,B,G){for(var it=0,vt=0;vt<B;vt++){var lt=kt[C>>2],Rt=kt[C+4>>2];C+=8;for(var _t=0;_t<Rt;_t++){var Ct=j[lt+_t],Nt=KA[_];Ct===0||Ct===10?((_===1?g:v)(D(Nt,0)),Nt.length=0):Nt.push(Ct)}it+=Rt}return kt[G>>2]=it,0},a:M},$n=function(){function _(B){o.asm=B.exports,J=o.asm.I,$.unshift(o.asm.E),mt--,o.monitorRunDependencies&&o.monitorRunDependencies(mt),mt==0&&bt&&(B=bt,bt=null,B())}var C={a:zA};if(mt++,o.monitorRunDependencies&&o.monitorRunDependencies(mt),o.instantiateWasm)try{return o.instantiateWasm(C,_)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return C=re(C),_(C[0]),o.asm}();o.___wasm_call_ctors=$n.E;var ZA=o.___getTypeName=$n.F;o.__embind_initialize_bindings=$n.G;var qf=o._malloc=$n.H,Is=o._free=$n.J;o.dynCall_jiji=$n.K;var zo;bt=function _(){zo||Qf(),zo||(bt=_)};function Qf(){function _(){if(!zo&&(zo=!0,o.calledRun=!0,!N)){if(Ht($),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var C=o.postRun.shift();U.unshift(C)}Ht(U)}}if(!(0<mt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Z();Ht(St),0<mt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return Qf(),s}})();n.exports=e})(Nd);var Xg=Nd.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var e=s(Ol),i=ne;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in n&&n[d]===i[d]||Object.defineProperty(n,d,{enumerable:!0,get:function(){return i[d]}})});function s(d){return d&&d.__esModule?d:{default:d}}const o=Xg;var c=(0,e.default)(o());n.default=c})(Ee);const Ud=Kg(Ee),Xr=1.8;function qg(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:typeof n.top=="number"?n.top*t:n.top,right:typeof n.right=="number"?n.right*t:n.right,bottom:typeof n.bottom=="number"?n.bottom*t:n.bottom,left:typeof n.left=="number"?n.left*t:n.left}}function Bd(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:(typeof n.top=="number"?n.top*t:n.top)??0,right:(typeof n.right=="number"?n.right*t:n.right)??0,bottom:(typeof n.bottom=="number"?n.bottom*t:n.bottom)??0,left:(typeof n.left=="number"?n.left*t:n.left)??0}}function Qg(n,t=1){return typeof n=="number"?{topLeft:n*t,topRight:n*t,bottomRight:n*t,bottomLeft:n*t}:{topLeft:((n==null?void 0:n.topLeft)??0)*t,topRight:((n==null?void 0:n.topRight)??0)*t,bottomRight:((n==null?void 0:n.bottomRight)??0)*t,bottomLeft:((n==null?void 0:n.bottomLeft)??0)*t}}function Gd(n,{layout:t,scale:e=1}){const{position:i="static",inset:s,width:o,height:c,minWidth:d,minHeight:f,flex:p,gap:g,margin:v,padding:b,direction:E="column",align:k="start",justify:w="start"}=t,L={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(n.setPositionType(L[i]),s){const{top:D,right:F,bottom:H,left:j}=qg(s,e);D&&n.setPosition(Ee.Edge.Top,D),F&&n.setPosition(Ee.Edge.Right,F),H&&n.setPosition(Ee.Edge.Bottom,H),j&&n.setPosition(Ee.Edge.Left,j)}const x={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};n.setFlexDirection(x[E]);const M={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};n.setAlignItems(M[k]);const N={start:Ee.Justify.FlexStart,end:Ee.Justify.FlexEnd,center:Ee.Justify.Center,"space-between":Ee.Justify.SpaceBetween,"space-around":Ee.Justify.SpaceAround,"space-evenly":Ee.Justify.SpaceEvenly};if(n.setJustifyContent(N[w]),v){const{top:D,right:F,bottom:H,left:j}=Bd(v,e);n.setMargin(Ee.Edge.Top,D),n.setMargin(Ee.Edge.Right,F),n.setMargin(Ee.Edge.Bottom,H),n.setMargin(Ee.Edge.Left,j)}if(b){const{top:D,right:F,bottom:H,left:j}=Bd(b,e);n.setPadding(Ee.Edge.Top,D),n.setPadding(Ee.Edge.Right,F),n.setPadding(Ee.Edge.Bottom,H),n.setPadding(Ee.Edge.Left,j)}p&&n.setFlex(p),n.setGap(Ee.Gutter.All,(g??0)*e),o&&n.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?n.setHeight(0):n.setHeight(typeof c=="number"?c*e:c)),d&&n.setMinWidth(typeof d=="number"?d*e:d),f&&n.setMinWidth(typeof f=="number"?f*e:f)}function Vd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i=!1,scale:s=1,position:o=[]}){o.forEach(({x:c,y:d,width:f,height:p,childNodes:g,element:v})=>{const b=n.getContext("2d",{alpha:!1});if(b){const{radius:E,draw:k}=v;if(k){if(b.save(),E){const{topLeft:w,topRight:L,bottomRight:x,bottomLeft:M}=Qg(E,s);b.beginPath(),b.moveTo(c+Math.min(p/Xr,w),d),b.lineTo(c+f-Math.min(p/Xr,L),d),b.quadraticCurveTo(c+f,d,c+f,d+Math.min(p/Xr,L)),b.lineTo(c+f,d+p-Math.min(p/Xr,x)),b.quadraticCurveTo(c+f,d+p,c+f-Math.min(p/Xr,x),d+p),b.lineTo(c+Math.min(p/Xr,M),d+p),b.quadraticCurveTo(c,d+p,c,d+p-Math.min(p/Xr,M)),b.lineTo(c,d+Math.min(p/Xr,w)),b.quadraticCurveTo(c,d,c+Math.min(p/Xr,w),d),b.closePath(),i&&(b.strokeStyle="blue",b.stroke()),b.clip()}k({scale:s,canvas:n,context:b,cropCanvas:t,letterboxCanvas:e,dx:c,dy:d,dw:f,dh:p}),i&&(b.strokeStyle="red",b.strokeRect(c,d,f,p)),b.restore()}}Vd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i,scale:s,position:g})})}function Hd(n,t,e){const i=t.map((s,o)=>{const c=Ud.Node.create(),{radius:d,elements:f=[],draw:p,...g}=s;return Gd(c,{layout:g,scale:e}),n.insertChild(c,o),{node:c,element:s,childNodes:Hd(c,f,e)}});return n.calculateLayout(),i}function Wd(n,t,e=0,i=0){const{top:s,left:o}=n.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:b}=c.getComputedLayout(),E=e+g,k=i+p;return{x:o+E,y:s+k,width:v,height:b,element:d,childNodes:Wd(n,f,E,k)}})}function jd(n,t){n.forEach(({node:e,element:i,childNodes:s})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=o(c,t);e.setHeight(typeof d=="number"?d*t:d)}jd(s,t)})}function Jg({canvas:n,origin:t,elements:e,...i}){const s={inset:{top:0,left:0},width:n.width,height:n.height,...t},o=Ud.Node.create();Gd(o,{layout:s}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=Hd(o,e,f);jd(p,f),o.calculateLayout();const g=Wd(o,p);return Vd({...i,scale:f,canvas:n,position:g})}function co({context:n,node:t,maxW:e=1/0}){const i=(t.value??"").split(" ");return i.slice(1).reduce((s,o)=>{const c=`${s[s.length-1].text} ${o}`.trim(),d=n.measureText(c);return d.width>e?s=[...s,{text:o,metrics:n.measureText(o)}]:s[s.length-1]={text:c,metrics:d},s},[{text:i[0],metrics:n.measureText(i[0])}])}function Kd(n){const{visible:t=!0,node:e}=n,i=[...(e==null?void 0:e.elements)??[],...(n==null?void 0:n.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>Kd(s)):!1}function Yd({canvas:n,debug:t=!1,elements:e=[],currentTime:i,relativeTime:s}){return e.map(o=>{var c,d,f,p,g,v,b,E;const{node:k}=o,w=n.getContext("2d");if(w&&Kd(o)){let L=o.width,x=o.height;if((k==null?void 0:k.type)==="text"&&k.value){w.save();const M=/(?<value>\d+\.?\d*)(?=px)/,N=parseFloat(((d=(c=k.font.match(M))==null?void 0:c.groups)==null?void 0:d.value)??"0");k.wrap?x=(D,F)=>{var H,j;const st=parseFloat(((j=(H=k.font.match(M))==null?void 0:H.groups)==null?void 0:j.value)??"0")*F;return w.font=k.font.replace(M,st.toString()),co({context:w,node:k,maxW:D}).length*N}:(w.font=k.font,L=w.measureText(k.value).width,x=N),w.restore()}if((k==null?void 0:k.type)==="image"&&k.image&&k.size){const M=((f=k.image)==null?void 0:f.naturalWidth)??((p=k.image)==null?void 0:p.width),N=((g=k.image)==null?void 0:g.naturalHeight)??((v=k.image)==null?void 0:v.height),D=M/N,F=(b=k.size)==null?void 0:b.width,H=(E=k.size)==null?void 0:E.height;L=F??(D>=1?(H??0)*D:(H??0)/D),x=H??(D<1?(F??0)*D:(F??0)/D)}return{...o,width:L,height:x,elements:Yd({canvas:n,debug:t,elements:o.elements,currentTime:i,relativeTime:s}),draw:({canvas:M,cropCanvas:N,letterboxCanvas:D,context:F,dx:H,dy:j,dw:st,dh:at,scale:Q})=>{var kt,gt,Ft,Kt,V,J,St,$,U,Z,mt,bt,Dt;if(k){const{type:Ut,from:Qt=0,to:fe=1/0}=k;if(s>=Qt&&s<=fe){if(F.save(),s&&fe-.3333333333333333<=s&&(F.globalAlpha=1-(.16666666666666666-(fe-s))/.16666666666666666),Ut==="box"&&(F.fillStyle=k.background,F.fillRect(H,j,st,at)),Ut==="text"&&k.value){const re=/(?<value>\d+\.?\d*)(?=px)/;let Ht=0;const Oe=parseFloat(((gt=(kt=k.font.match(re))==null?void 0:kt.groups)==null?void 0:gt.value)??"0")*Q;if(k.fill){const{minSize:me,maxSize:Wt}=k.fill;Ht=me*Q,F.font=k.font.replace(re,Ht.toString());const oe=10*Q;let se=0,Te=co({context:F,node:k,maxW:st});for(;Ht+oe<Wt*Q&&(Te.length+1)*(Ht+oe)<at;)if(Ht+=oe,F.font=k.font.replace(re,Ht.toString()),Te=co({context:F,node:k,maxW:st}),se=Te.reduce((Mt,Me)=>(Me.metrics.width>Mt&&(Mt=Me.metrics.width),Mt),0),se>st){Ht-=oe;break}}else Ht=Oe;F.font=k.font.replace(re,Ht.toString()),F.textBaseline="top",F.fillStyle=k.color,k.wrap?co({context:F,node:k,maxW:st}).forEach((me,Wt)=>{F.fillText(me.text,H,j+Ht*Wt)}):F.fillText(k.value,H,j)}if(Ut==="image"&&k.image&&F.drawImage(k.image,H,j,st,at),Ut==="video"&&((Ft=k.video)!=null&&Ft.node||(Kt=k.video)!=null&&Kt.getSource)){const re=k.format??"letterbox",Ht=((J=(V=k.video)==null?void 0:V.getSource)==null?void 0:J.call(V,s))??k.video.node,Oe=(Ht==null?void 0:Ht.videoWidth)??(Ht==null?void 0:Ht.naturalWidth)??(Ht==null?void 0:Ht.width),me=(Ht==null?void 0:Ht.videoHeight)??(Ht==null?void 0:Ht.naturalHeight)??(Ht==null?void 0:Ht.height);if(Oe&&me){const{dx:oe,dy:se,dw:Te,dh:Mt}=Md({context:F,cropCanvas:N,letterboxCanvas:D,source:Ht,format:re,crop:(St=k==null?void 0:k.value)==null?void 0:St.crop,sourceWidth:Oe,sourceHeight:me,posX:H,posY:j,drawAreaWidth:st,drawAreaHeight:at});k.elements&&Nl({debug:t,canvas:M,cropCanvas:N,letterboxCanvas:D,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+se),left:Math.max(H,H+oe)},width:Math.min(st,Te),height:Math.min(at,Mt)},elements:k.elements})}const Wt=1/3;if(k.poster&&i>=0&&i<=Wt){F.save(),F.globalAlpha=1-i/Wt;const oe=(($=k.poster)==null?void 0:$.naturalWidth)??((U=k.poster)==null?void 0:U.width),se=((Z=k.poster)==null?void 0:Z.naturalHeight)??((mt=k.poster)==null?void 0:mt.height);if(oe&&se){const{dx:Te,dy:Mt,dw:Me,dh:qe}=Md({context:F,cropCanvas:N,letterboxCanvas:D,source:k.poster,format:re,crop:(bt=k==null?void 0:k.value)==null?void 0:bt.crop,sourceWidth:oe,sourceHeight:se,posX:H,posY:j,drawAreaWidth:st,drawAreaHeight:at});k.elements&&Nl({debug:t,canvas:M,cropCanvas:N,letterboxCanvas:D,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+Mt),left:Math.max(H,H+Te)},width:Math.min(st,Me),height:Math.min(at,qe)},elements:k.elements})}F.restore()}}if(Ut==="gradient"&&k.value){const re=F.createLinearGradient(H+st,j,H+st,j+at);(Dt=k.value)==null||Dt.forEach(Ht=>{re.addColorStop(Ht.percent,Ht.color)}),F.fillStyle=re,F.fillRect(H,j,st,at)}F.restore()}}}}}}).filter(Boolean)}function Nl({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s,...o}){return Jg({...o,debug:t,canvas:n,elements:Yd({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s})})}const tm={id:"default",name:"None",template:{id:"basic",name:"Basic",layouts:[{name:"basic",tree:`[
93
93
  {
94
- "w": "100%",
95
- "h": "100%",
94
+ "width": "100%",
95
+ "height": "100%",
96
96
  "node": {
97
97
  "type": "video",
98
98
  "format": {{@ parse(it.videoFormat) /}},
99
99
  "value": {
100
100
  "id": {{@ parse(it.id) /}},
101
+ "key": {{@ parse(it.key) /}},
101
102
  "src": {{@async resolve-source({ sources: [it.mp4, it.input] }) /}},
102
103
  "playlist": {{@async resolve-source({ sources: [it.playlist] }) /}},
103
104
  "poster": {{@ parse(it.poster) /}},
104
105
  "captions": {{@ parse(it.captions) /}},
105
106
  "duration": {{@ parse(it.duration) /}},
106
107
  "startOffset": {{@ parse(it.startOffset) /}},
107
- "endOffset": {{@ parse(it.endOffset) /}}
108
+ "endOffset": {{@ parse(it.endOffset) /}},
109
+ "crop": {
110
+ "x": {{@ parse(it.crop?.x) /}},
111
+ "y": {{@ parse(it.crop?.y) /}},
112
+ "width": {{@ parse(it.crop?.width) /}},
113
+ "height": {{@ parse(it.crop?.height) /}}
114
+ }
108
115
  }
109
116
  }
110
117
  }
111
118
  ]`}],content:[{scenes:[{layout:"basic",data:`{
112
- "id": "{{ it.root?.answer?.id }}-intro",
119
+ "id": {{@ parse(it.root?.answer?.id) /}},
120
+ "key": "{{ it.root?.answer?.id }}-intro",
113
121
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
114
122
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
115
123
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
@@ -117,9 +125,16 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
117
125
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
118
126
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
119
127
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
120
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
128
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
129
+ "crop": {
130
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
131
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
132
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
133
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
134
+ }
121
135
  }`}],root:"{{ it.intro?.questions?.items | stringify }}"},{scenes:[{layout:"basic",data:`{
122
136
  "id": {{@ parse(it.root?.answer?.id) /}},
137
+ "key": "{{ it.root?.answer?.id }}-{{ it.index }}",
123
138
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
124
139
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
125
140
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
@@ -127,9 +142,16 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
127
142
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
128
143
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
129
144
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
130
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
145
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
146
+ "crop": {
147
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
148
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
149
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
150
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
151
+ }
131
152
  }`}],root:"{{ it.questions?.items | stringify }}"},{scenes:[{layout:"basic",data:`{
132
- "id": "{{ it.root?.answer?.id }}-outro",
153
+ "id": {{@ parse(it.root?.answer?.id) /}},
154
+ "key": "{{ it.root?.answer?.id }}-outro",
133
155
  "mp4": {{@ parse(it.root?.answer?.media?.video) /}},
134
156
  "input": {{@ parse(it.root?.answer?.media?.input) /}},
135
157
  "playlist": {{@ parse(it.root?.answer?.media?.playlist) /}},
@@ -137,48 +159,58 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
137
159
  "captions": {{@ parse(it.root?.answer?.captions?.current) /}},
138
160
  "duration": {{@ parse(it.root?.answer?.metadata?.duration) /}},
139
161
  "startOffset": {{@ parse(it.root?.answer?.settings?.startOffset) /}},
140
- "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}}
141
- }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function Kg(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>Mf);return new n.Image}return new Image}const Ud=sa(async function(n){return n?new Promise((t,e)=>{Kg().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=n})}):null});async function Dl({element:n},t,e){var i,s,o;let c={...n};const{node:d}=n;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(s=d==null?void 0:d.value)!=null&&s.playlist)){const f=await t(d.value);let p;try{p=await Ud(d.value.poster)}catch{p=null}c={...c,node:{...d,video:f,poster:p,meta:await e(d.value,f.node)}}}if((d==null?void 0:d.type)==="image"&&d.value){let f;try{f=await Ud(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=n.node)!=null&&o.elements&&(c.node.elements=await Promise.all(n.node.elements.map(f=>Dl({element:f},t,e)))),n.elements&&(c.elements=await Promise.all(n.elements.map(f=>Dl({element:f},t,e)))),c}async function Bd(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>Mf),t=new n.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function jg(n){var t;try{if((t=await Cg(n,{method:"HEAD"}))!=null&&t.ok)return n}catch{return}}async function zg({sources:n}){let t=null;if(n){const e=n.filter(Boolean).map(i=>jg(i));t=(await Promise.all(e)).find(Boolean)}return t}js.filters.define("stringify",n=>JSON.stringify(n)),js.filters.define("nullify",n=>typeof n>"u"?null:n),js.filters.define("filter",(n,t)=>{if(!t)return n;if(!Array.isArray(n))throw new Error("Data for filter must be an array");return n.filter((e,i)=>t.includes(i))}),js.helpers.define("parse",n=>{const t=n.params[0];return typeof t=="string"?`"${t.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}"`:typeof t>"u"?null:t}),js.helpers.define("resolve-source",sa(async n=>{const{sources:t}=n.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),s=e==null?void 0:e.find(c=>!c.includes("http")),o=i??s??await zg({sources:t});return o?`"${o}"`:"null"},{cacheKey:([n])=>JSON.stringify(n.params[0]??{})}));const ao=(n,t,e)=>js.render(n,t,js.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function xl(n=[]){var t;for(const e of n){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=xl(e==null?void 0:e.elements);if(i)return i}}async function Gd({data:n,template:t,burnCaptions:e=!1},i,s){var o,c,d;const f=t??Wg,p=(await Promise.all(f.template.content.map(async({scenes:E,root:w})=>{const R={...f.options,...n,intro:f.intro,outro:f.outro};async function x(M){return Promise.all(E.map(async({layout:G,duration:_,data:F,options:H})=>{var j,nt,ot;const tt=F?JSON.parse(await ao(F,{...R,root:M})):{},kt=H?JSON.parse(await ao(H,R)):{},vt=(j=f.template.layouts.find(rt=>rt.name===G))==null?void 0:j.tree,$t=JSON.parse(await ao(vt,{...tt,...kt})),jt=await Promise.all($t.flatMap(rt=>Dl({element:rt},i,s))),V=xl(jt);return{duration:_??((nt=V==null?void 0:V.meta)==null?void 0:nt.duration)??0,captions:(ot=V==null?void 0:V.meta)==null?void 0:ot.captions,elements:jt}}))}if(w){const M=JSON.parse(await ao(w,R));return Array.isArray(M)?(await Promise.all(M.map(async G=>x(G)))).flatMap(G=>G):x(M)}return x(n)}))).flatMap(E=>E).filter(E=>E.duration>0),g=((o=f.meta)==null?void 0:o.frameRate)??30,v=((c=f.meta)==null?void 0:c.resolution)??720,A=((d=f.meta)==null?void 0:d.transitionDuration)??1/3,T=await Promise.all(p.map(async({duration:E,captions:w,elements:R},x)=>{var M,G;const _=await Bd(),F=await Bd(),H=xl(R),j=p.reduce((nt,ot,tt)=>(tt<x&&(nt+=ot.duration-A/2),nt),0);return{draw:({canvas:nt,currentTime:ot})=>{const tt=Math.max(0,ot-j);Il({canvas:nt,elements:R,currentTime:ot,relativeTime:tt,offscreenCanvas:_}),w&&e&&$g({canvas:nt,dx:0,dy:0,dw:nt.width,dh:nt.height,vttCaptions:w,relativeTime:tt+((H==null?void 0:H.meta.start)??0)})},duration:E,transitionCanvas:F,start:j,video:H==null?void 0:H.video,videoMeta:H==null?void 0:H.meta,audio:{duration:E,src:(M=H==null?void 0:H.value)==null?void 0:M.src,start:(G=H==null?void 0:H.meta)==null?void 0:G.start}}}));return{scenes:T,frameRate:g,resolution:v,transitionDuration:A,fonts:f.template.fonts??[],duration:Math.max(0,...T.map(({start:E,duration:w})=>E+w))}}/**
162
+ "endOffset": {{@ parse(it.root?.answer?.settings?.endOffset) /}},
163
+ "crop": {
164
+ "x": {{@ parse(it.root?.answer?.settings?.crop?.x) /}},
165
+ "y": {{@ parse(it.root?.answer?.settings?.crop?.y) /}},
166
+ "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
167
+ "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
168
+ }
169
+ }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]},meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function em(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>jf);return new n.Image}return new Image}const zd=vs(async function(n){return n?new Promise((t,e)=>{em().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=n})}):null});async function Ul({element:n},t,e){var i,s,o;let c={...n};const{node:d}=n;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(s=d==null?void 0:d.value)!=null&&s.playlist)){const f=await t(d.value);let p;try{p=await zd(d.value.poster)}catch{p=null}c={...c,node:{...d,video:f,poster:p,meta:await e(d.value,f.node)}}}if((d==null?void 0:d.type)==="image"&&d.value){let f;try{f=await zd(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=n.node)!=null&&o.elements&&(c.node.elements=await Promise.all(n.node.elements.map(f=>Ul({element:f},t,e)))),n.elements&&(c.elements=await Promise.all(n.elements.map(f=>Ul({element:f},t,e)))),c}async function Bl(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>jf),t=new n.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function im(n){var t;try{if((t=await Ug(n,{method:"HEAD"}))!=null&&t.ok)return n}catch{return}}async function rm({sources:n}){let t=null;if(n){const e=n.filter(Boolean).map(i=>im(i));t=(await Promise.all(e)).find(Boolean)}return t}qs.filters.define("stringify",n=>JSON.stringify(n)),qs.filters.define("nullify",n=>typeof n>"u"?null:n),qs.filters.define("filter",(n,t)=>{if(!t)return n;if(!Array.isArray(n))throw new Error("Data for filter must be an array");return n.filter((e,i)=>t.includes(i))}),qs.helpers.define("parse",n=>{const t=n.params[0];if(typeof t=="string"){let e=t;return e=e.replace(/\n/g,"\\n"),e=e.replace(/\r/g,"\\r"),e=e.replace(/"/g,'\\"'),`"${e}"`}return typeof t>"u"?null:t}),qs.helpers.define("resolve-source",vs(async n=>{const{sources:t}=n.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),s=e==null?void 0:e.find(c=>!c.includes("http")),o=i??s??await rm({sources:t});return o?`"${o}"`:"null"},{cacheKey:([n])=>JSON.stringify(n.params[0]??{})}));const fa=(n,t,e)=>qs.render(n,t,qs.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function Gl(n=[]){var t;for(const e of n){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Gl(e==null?void 0:e.elements);if(i)return i}}async function ho({data:n,template:t,burnCaptions:e=!1,debug:i=!1},s,o){var c,d,f;const p=t??tm,g=(await Promise.all(p.template.content.map(async({scenes:w,root:L})=>{const x={...p.options,...n,intro:p.intro,outro:p.outro};async function M(N,D){return Promise.all(w.map(async({layout:F,duration:H,data:j,options:st})=>{var at,Q,kt;const gt={...x,index:D,root:N},Ft=j?JSON.parse(await fa(j,gt)):{},Kt=st?JSON.parse(await fa(st,gt)):{},V=H?parseFloat(await fa(H,gt)):NaN,J=(at=p.template.layouts.find(Z=>Z.name===F))==null?void 0:at.tree,St=JSON.parse(await fa(J,{...Ft,...Kt})),$=await Promise.all(St.flatMap(Z=>Ul({element:Z},s,o))),U=Gl($);return{duration:(isNaN(V)?null:V)??((Q=U==null?void 0:U.meta)==null?void 0:Q.duration)??0,captions:(kt=U==null?void 0:U.meta)==null?void 0:kt.captions,elements:$}}))}if(L){const N=JSON.parse(await fa(L,x));return Array.isArray(N)?(await Promise.all(N.map(async(D,F)=>M(D,F)))).flatMap(D=>D):M(N,null)}return M(n,null)}))).flatMap(w=>w).filter(w=>w.duration>0),v=((c=p.meta)==null?void 0:c.frameRate)??30,b=((d=p.meta)==null?void 0:d.resolution)??720,E=((f=p.meta)==null?void 0:f.transitionDuration)??1/3,k=await Promise.all(g.map(async({duration:w,captions:L,elements:x},M)=>{var N,D;const F=await Bl(),H=await Bl(),j=await Bl(),st=Gl(x),at=g.reduce((Q,kt,gt)=>(gt<M&&(Q+=kt.duration-E/2),Q),0);return{draw:({canvas:Q,currentTime:kt})=>{const gt=Math.max(0,kt-at);Nl({debug:i,canvas:Q,elements:x,currentTime:kt,relativeTime:gt,cropCanvas:F,letterboxCanvas:H}),L&&e&&jg({canvas:Q,dx:0,dy:0,dw:Q.width,dh:Q.height,vttCaptions:L,relativeTime:gt+((st==null?void 0:st.meta.start)??0)})},duration:w,transitionCanvas:j,start:at,video:st==null?void 0:st.video,videoMeta:st==null?void 0:st.meta,audio:{duration:w,src:(N=st==null?void 0:st.value)==null?void 0:N.src,start:(D=st==null?void 0:st.meta)==null?void 0:D.start}}}));return{scenes:k,frameRate:v,resolution:b,transitionDuration:E,fonts:p.template.fonts??[],duration:Math.max(0,...k.map(({start:w,duration:L})=>w+L))}}/**
170
+ * @license
171
+ * Copyright 2018 Google LLC
172
+ * SPDX-License-Identifier: BSD-3-Clause
173
+ */const Ye=An(class extends na{constructor(n){var t;if(super(n),n.type!==bn.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.it===void 0){this.it=new Set,n.strings!==void 0&&(this.st=new Set(n.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in t)t[o]&&!((i=this.st)!=null&&i.has(o))&&this.it.add(o);return this.render(t)}const e=n.element.classList;for(const o of this.it)o in t||(e.remove(o),this.it.delete(o));for(const o in t){const c=!!t[o];c===this.it.has(o)||(s=this.st)!=null&&s.has(o)||(c?(e.add(o),this.it.add(o)):(e.remove(o),this.it.delete(o)))}return us}});var sm=pa;pa.flatten=pa,pa.unflatten=qd;function Zd(n){return n&&n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Xd(n){return n}function pa(n,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,s=t.transformKey||Xd,o={};function c(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],b=t.safe&&Array.isArray(v),E=Object.prototype.toString.call(v),k=Zd(v),w=E==="[object Object]"||E==="[object Array]",L=f?f+e+s(g):s(g);if(!b&&!k&&w&&Object.keys(v).length&&(!t.maxDepth||p<i))return c(v,L,p+1);o[L]=v})}return c(n),o}function qd(n,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,s=t.transformKey||Xd,o={};if(Zd(n)||Object.prototype.toString.call(n)!=="[object Object]")return n;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,b){return Object.keys(b).reduce(function(E,k){return E[g+e+k]=b[k],E},v)}function p(g){const v=Object.prototype.toString.call(g),b=v==="[object Array]",E=v==="[object Object]";if(g){if(b)return!g.length;if(E)return!Object.keys(g).length}else return!0}return n=Object.keys(n).reduce(function(g,v){const b=Object.prototype.toString.call(n[v]);return!(b==="[object Object]"||b==="[object Array]")||p(n[v])?(g[v]=n[v],g):f(v,g,pa(n[v],t))},{}),Object.keys(n).forEach(function(g){const v=g.split(e).map(s);let b=d(v.shift()),E=d(v[0]),k=o;for(;E!==void 0;){if(b==="__proto__")return;const w=Object.prototype.toString.call(k[b]),L=w==="[object Object]"||w==="[object Array]";if(!i&&!L&&typeof k[b]<"u")return;(i&&!L||!i&&k[b]==null)&&(k[b]=typeof E=="number"&&!t.object?[]:{}),k=k[b],v.length>0&&(b=d(v.shift()),E=d(v[0]))}k[b]=qd(n[g],t)}),o}const nm=Cl(sm);/**
142
174
  * @license
143
175
  * Copyright 2018 Google LLC
144
176
  * SPDX-License-Identifier: BSD-3-Clause
145
- */const je=Jn(class extends Va{constructor(n){var t;if(super(n),n.type!==Qn.ATTRIBUTE||n.name!=="class"||((t=n.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(n){return" "+Object.keys(n).filter(t=>n[t]).join(" ")+" "}update(n,[t]){var i,s;if(this.it===void 0){this.it=new Set,n.strings!==void 0&&(this.st=new Set(n.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in t)t[o]&&!((i=this.st)!=null&&i.has(o))&&this.it.add(o);return this.render(t)}const e=n.element.classList;for(const o of this.it)o in t||(e.remove(o),this.it.delete(o));for(const o in t){const c=!!t[o];c===this.it.has(o)||(s=this.st)!=null&&s.has(o)||(c?(e.add(o),this.it.add(o)):(e.remove(o),this.it.delete(o)))}return Ns}});var Yg=la;la.flatten=la,la.unflatten=Wd;function Hd(n){return n&&n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Vd(n){return n}function la(n,t){t=t||{};const e=t.delimiter||".",i=t.maxDepth,s=t.transformKey||Vd,o={};function c(d,f,p){p=p||1,Object.keys(d).forEach(function(g){const v=d[g],A=t.safe&&Array.isArray(v),T=Object.prototype.toString.call(v),E=Hd(v),w=T==="[object Object]"||T==="[object Array]",R=f?f+e+s(g):s(g);if(!A&&!E&&w&&Object.keys(v).length&&(!t.maxDepth||p<i))return c(v,R,p+1);o[R]=v})}return c(n),o}function Wd(n,t){t=t||{};const e=t.delimiter||".",i=t.overwrite||!1,s=t.transformKey||Vd,o={};if(Hd(n)||Object.prototype.toString.call(n)!=="[object Object]")return n;function d(g){const v=Number(g);return isNaN(v)||g.indexOf(".")!==-1||t.object?g:v}function f(g,v,A){return Object.keys(A).reduce(function(T,E){return T[g+e+E]=A[E],T},v)}function p(g){const v=Object.prototype.toString.call(g),A=v==="[object Array]",T=v==="[object Object]";if(g){if(A)return!g.length;if(T)return!Object.keys(g).length}else return!0}return n=Object.keys(n).reduce(function(g,v){const A=Object.prototype.toString.call(n[v]);return!(A==="[object Object]"||A==="[object Array]")||p(n[v])?(g[v]=n[v],g):f(v,g,la(n[v],t))},{}),Object.keys(n).forEach(function(g){const v=g.split(e).map(s);let A=d(v.shift()),T=d(v[0]),E=o;for(;T!==void 0;){if(A==="__proto__")return;const w=Object.prototype.toString.call(E[A]),R=w==="[object Object]"||w==="[object Array]";if(!i&&!R&&typeof E[A]<"u")return;(i&&!R||!i&&E[A]==null)&&(E[A]=typeof T=="number"&&!t.object?[]:{}),E=E[A],v.length>0&&(A=d(v.shift()),T=d(v[0]))}E[A]=Wd(n[g],t)}),o}const Zg=kl(Yg);/**
177
+ */const Qd="important",am=" !"+Qd,om=An(class extends na{constructor(n){var t;if(super(n),n.type!==bn.ATTRIBUTE||n.name!=="style"||((t=n.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(t)),this.render(t);for(const i of this.ut)t[i]==null&&(this.ut.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ut.add(i);const o=typeof s=="string"&&s.endsWith(am);i.includes("-")||o?e.setProperty(i,o?s.slice(0,-11):s,o?Qd:""):e[i]=s}}return us}});/**
146
178
  * @license
147
179
  * Copyright 2017 Google LLC
148
180
  * SPDX-License-Identifier: BSD-3-Clause
149
- */const Kd=(n,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(n[s],s);return i},jd=Jn(class extends Va{constructor(n){if(super(n),n.type!==Qn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(n,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],o=[];let c=0;for(const d of n)s[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:s}}render(n,t,e){return this.ht(n,t,e).values}update(n,[t,e,i]){const s=B2(n),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(s))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,A=s.length-1,T=0,E=o.length-1;for(;v<=A&&T<=E;)if(s[v]===null)v++;else if(s[A]===null)A--;else if(d[v]===c[T])f[T]=Ks(s[v],o[T]),v++,T++;else if(d[A]===c[E])f[E]=Ks(s[A],o[E]),A--,E--;else if(d[v]===c[E])f[E]=Ks(s[v],o[E]),qn(n,f[E+1],s[v]),v++,E--;else if(d[A]===c[T])f[T]=Ks(s[A],o[T]),qn(n,s[v],s[A]),A--,T++;else if(p===void 0&&(p=Kd(c,T,E),g=Kd(d,v,A)),p.has(d[v]))if(p.has(d[A])){const w=g.get(c[T]),R=w!==void 0?s[w]:null;if(R===null){const x=qn(n,s[v]);Ks(x,o[T]),f[T]=x}else f[T]=Ks(R,o[T]),qn(n,s[v],R),s[w]=null;T++}else vl(s[A]),A--;else vl(s[v]),v++;for(;T<=E;){const w=qn(n,f[E+1]);Ks(w,o[T]),f[T++]=w}for(;v<=A;){const w=s[v++];w!==null&&vl(w)}return this.dt=c,U2(n,f),Ns}});var Ni="top",nr="bottom",ar="right",Ui="left",Pl="auto",ca=[Ni,nr,ar,Ui],pn="start",ha="end",Xg="clippingParents",zd="viewport",da="popper",qg="reference",Yd=ca.reduce(function(n,t){return n.concat([t+"-"+pn,t+"-"+ha])},[]),Zd=[].concat(ca,[Pl]).reduce(function(n,t){return n.concat([t,t+"-"+pn,t+"-"+ha])},[]),Qg="beforeRead",Jg="read",t1="afterRead",e1="beforeMain",i1="main",r1="afterMain",s1="beforeWrite",n1="write",a1="afterWrite",o1=[Qg,Jg,t1,e1,i1,r1,s1,n1,a1];function Cr(n){return n?(n.nodeName||"").toLowerCase():null}function Xi(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function Zs(n){var t=Xi(n).Element;return n instanceof t||n instanceof Element}function or(n){var t=Xi(n).HTMLElement;return n instanceof t||n instanceof HTMLElement}function Ol(n){if(typeof ShadowRoot>"u")return!1;var t=Xi(n).ShadowRoot;return n instanceof t||n instanceof ShadowRoot}function l1(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},o=t.elements[e];!or(o)||!Cr(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(c){var d=s[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function c1(n){var t=n.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var s=t.elements[i],o=t.attributes[i]||{},c=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=c.reduce(function(f,p){return f[p]="",f},{});!or(s)||!Cr(s)||(Object.assign(s.style,d),Object.keys(o).forEach(function(f){s.removeAttribute(f)}))})}}const Xd={name:"applyStyles",enabled:!0,phase:"write",fn:l1,effect:c1,requires:["computeStyles"]};function Ir(n){return n.split("-")[0]}var Xs=Math.max,oo=Math.min,gn=Math.round;function Ml(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function qd(){return!/^((?!chrome|android).)*safari/i.test(Ml())}function mn(n,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=n.getBoundingClientRect(),s=1,o=1;t&&or(n)&&(s=n.offsetWidth>0&&gn(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&gn(i.height)/n.offsetHeight||1);var c=Zs(n)?Xi(n):window,d=c.visualViewport,f=!qd()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/s,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/s,A=i.height/o;return{width:v,height:A,top:g,right:p+v,bottom:g+A,left:p,x:p,y:g}}function $l(n){var t=mn(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function Qd(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&Ol(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Xr(n){return Xi(n).getComputedStyle(n)}function h1(n){return["table","td","th"].indexOf(Cr(n))>=0}function gs(n){return((Zs(n)?n.ownerDocument:n.document)||window.document).documentElement}function lo(n){return Cr(n)==="html"?n:n.assignedSlot||n.parentNode||(Ol(n)?n.host:null)||gs(n)}function Jd(n){return!or(n)||Xr(n).position==="fixed"?null:n.offsetParent}function d1(n){var t=/firefox/i.test(Ml()),e=/Trident/i.test(Ml());if(e&&or(n)){var i=Xr(n);if(i.position==="fixed")return null}var s=lo(n);for(Ol(s)&&(s=s.host);or(s)&&["html","body"].indexOf(Cr(s))<0;){var o=Xr(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function ua(n){for(var t=Xi(n),e=Jd(n);e&&h1(e)&&Xr(e).position==="static";)e=Jd(e);return e&&(Cr(e)==="html"||Cr(e)==="body"&&Xr(e).position==="static")?t:e||d1(n)||t}function Fl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function fa(n,t,e){return Xs(n,oo(t,e))}function u1(n,t,e){var i=fa(n,t,e);return i>e?e:i}function tu(){return{top:0,right:0,bottom:0,left:0}}function eu(n){return Object.assign({},tu(),n)}function iu(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}var f1=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,eu(typeof t!="number"?t:iu(t,ca))};function p1(n){var t,e=n.state,i=n.name,s=n.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=Ir(e.placement),f=Fl(d),p=[Ui,ar].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=f1(s.padding,e),A=$l(o),T=f==="y"?Ni:Ui,E=f==="y"?nr:ar,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],R=c[f]-e.rects.reference[f],x=ua(o),M=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,G=w/2-R/2,_=v[T],F=M-A[g]-v[E],H=M/2-A[g]/2+G,j=fa(_,H,F),nt=f;e.modifiersData[i]=(t={},t[nt]=j,t.centerOffset=j-H,t)}}function g1(n){var t=n.state,e=n.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||Qd(t.elements.popper,s)&&(t.elements.arrow=s))}const m1={name:"arrow",enabled:!0,phase:"main",fn:p1,effect:g1,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function vn(n){return n.split("-")[1]}var v1={top:"auto",right:"auto",bottom:"auto",left:"auto"};function y1(n,t){var e=n.x,i=n.y,s=t.devicePixelRatio||1;return{x:gn(e*s)/s||0,y:gn(i*s)/s||0}}function ru(n){var t,e=n.popper,i=n.popperRect,s=n.placement,o=n.variation,c=n.offsets,d=n.position,f=n.gpuAcceleration,p=n.adaptive,g=n.roundOffsets,v=n.isFixed,A=c.x,T=A===void 0?0:A,E=c.y,w=E===void 0?0:E,R=typeof g=="function"?g({x:T,y:w}):{x:T,y:w};T=R.x,w=R.y;var x=c.hasOwnProperty("x"),M=c.hasOwnProperty("y"),G=Ui,_=Ni,F=window;if(p){var H=ua(e),j="clientHeight",nt="clientWidth";if(H===Xi(e)&&(H=gs(e),Xr(H).position!=="static"&&d==="absolute"&&(j="scrollHeight",nt="scrollWidth")),H=H,s===Ni||(s===Ui||s===ar)&&o===ha){_=nr;var ot=v&&H===F&&F.visualViewport?F.visualViewport.height:H[j];w-=ot-i.height,w*=f?1:-1}if(s===Ui||(s===Ni||s===nr)&&o===ha){G=ar;var tt=v&&H===F&&F.visualViewport?F.visualViewport.width:H[nt];T-=tt-i.width,T*=f?1:-1}}var kt=Object.assign({position:d},p&&v1),vt=g===!0?y1({x:T,y:w},Xi(e)):{x:T,y:w};if(T=vt.x,w=vt.y,f){var $t;return Object.assign({},kt,($t={},$t[_]=M?"0":"",$t[G]=x?"0":"",$t.transform=(F.devicePixelRatio||1)<=1?"translate("+T+"px, "+w+"px)":"translate3d("+T+"px, "+w+"px, 0)",$t))}return Object.assign({},kt,(t={},t[_]=M?w+"px":"",t[G]=x?T+"px":"",t.transform="",t))}function b1(n){var t=n.state,e=n.options,i=e.gpuAcceleration,s=i===void 0?!0:i,o=e.adaptive,c=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:Ir(t.placement),variation:vn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,ru(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,ru(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const A1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:b1,data:{}};var co={passive:!0};function E1(n){var t=n.state,e=n.instance,i=n.options,s=i.scroll,o=s===void 0?!0:s,c=i.resize,d=c===void 0?!0:c,f=Xi(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,co)}),d&&f.addEventListener("resize",e.update,co),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,co)}),d&&f.removeEventListener("resize",e.update,co)}}const T1={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:E1,data:{}};var k1={left:"right",right:"left",bottom:"top",top:"bottom"};function ho(n){return n.replace(/left|right|bottom|top/g,function(t){return k1[t]})}var w1={start:"end",end:"start"};function su(n){return n.replace(/start|end/g,function(t){return w1[t]})}function Nl(n){var t=Xi(n),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function Ul(n){return mn(gs(n)).left+Nl(n).scrollLeft}function S1(n,t){var e=Xi(n),i=gs(n),s=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(s){o=s.width,c=s.height;var p=qd();(p||!p&&t==="fixed")&&(d=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:d+Ul(n),y:f}}function L1(n){var t,e=gs(n),i=Nl(n),s=(t=n.ownerDocument)==null?void 0:t.body,o=Xs(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),c=Xs(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),d=-i.scrollLeft+Ul(n),f=-i.scrollTop;return Xr(s||e).direction==="rtl"&&(d+=Xs(e.clientWidth,s?s.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Bl(n){var t=Xr(n),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function nu(n){return["html","body","#document"].indexOf(Cr(n))>=0?n.ownerDocument.body:or(n)&&Bl(n)?n:nu(lo(n))}function pa(n,t){var e;t===void 0&&(t=[]);var i=nu(n),s=i===((e=n.ownerDocument)==null?void 0:e.body),o=Xi(i),c=s?[o].concat(o.visualViewport||[],Bl(i)?i:[]):i,d=t.concat(c);return s?d:d.concat(pa(lo(c)))}function Gl(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function R1(n,t){var e=mn(n,!1,t==="fixed");return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}function au(n,t,e){return t===zd?Gl(S1(n,e)):Zs(t)?R1(t,e):Gl(L1(gs(n)))}function _1(n){var t=pa(lo(n)),e=["absolute","fixed"].indexOf(Xr(n).position)>=0,i=e&&or(n)?ua(n):n;return Zs(i)?t.filter(function(s){return Zs(s)&&Qd(s,i)&&Cr(s)!=="body"}):[]}function C1(n,t,e,i){var s=t==="clippingParents"?_1(n):[].concat(t),o=[].concat(s,[e]),c=o[0],d=o.reduce(function(f,p){var g=au(n,p,i);return f.top=Xs(g.top,f.top),f.right=oo(g.right,f.right),f.bottom=oo(g.bottom,f.bottom),f.left=Xs(g.left,f.left),f},au(n,c,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function ou(n){var t=n.reference,e=n.element,i=n.placement,s=i?Ir(i):null,o=i?vn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(s){case Ni:f={x:c,y:t.y-e.height};break;case nr:f={x:c,y:t.y+t.height};break;case ar:f={x:t.x+t.width,y:d};break;case Ui:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=s?Fl(s):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case pn:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ha:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function ga(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?n.placement:i,o=e.strategy,c=o===void 0?n.strategy:o,d=e.boundary,f=d===void 0?Xg:d,p=e.rootBoundary,g=p===void 0?zd:p,v=e.elementContext,A=v===void 0?da:v,T=e.altBoundary,E=T===void 0?!1:T,w=e.padding,R=w===void 0?0:w,x=eu(typeof R!="number"?R:iu(R,ca)),M=A===da?qg:da,G=n.rects.popper,_=n.elements[E?M:A],F=C1(Zs(_)?_:_.contextElement||gs(n.elements.popper),f,g,c),H=mn(n.elements.reference),j=ou({reference:H,element:G,strategy:"absolute",placement:s}),nt=Gl(Object.assign({},G,j)),ot=A===da?nt:H,tt={top:F.top-ot.top+x.top,bottom:ot.bottom-F.bottom+x.bottom,left:F.left-ot.left+x.left,right:ot.right-F.right+x.right},kt=n.modifiersData.offset;if(A===da&&kt){var vt=kt[s];Object.keys(tt).forEach(function($t){var jt=[ar,nr].indexOf($t)>=0?1:-1,V=[Ni,nr].indexOf($t)>=0?"y":"x";tt[$t]+=vt[V]*jt})}return tt}function I1(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?Zd:f,g=vn(i),v=g?d?Yd:Yd.filter(function(E){return vn(E)===g}):ca,A=v.filter(function(E){return p.indexOf(E)>=0});A.length===0&&(A=v);var T=A.reduce(function(E,w){return E[w]=ga(n,{placement:w,boundary:s,rootBoundary:o,padding:c})[Ir(w)],E},{});return Object.keys(T).sort(function(E,w){return T[E]-T[w]})}function D1(n){if(Ir(n)===Pl)return[];var t=ho(n);return[su(n),t,su(t)]}function x1(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,A=e.altBoundary,T=e.flipVariations,E=T===void 0?!0:T,w=e.allowedAutoPlacements,R=t.options.placement,x=Ir(R),M=x===R,G=f||(M||!E?[ho(R)]:D1(R)),_=[R].concat(G).reduce(function(Ut,Ot){return Ut.concat(Ir(Ot)===Pl?I1(t,{placement:Ot,boundary:g,rootBoundary:v,padding:p,flipVariations:E,allowedAutoPlacements:w}):Ot)},[]),F=t.rects.reference,H=t.rects.popper,j=new Map,nt=!0,ot=_[0],tt=0;tt<_.length;tt++){var kt=_[tt],vt=Ir(kt),$t=vn(kt)===pn,jt=[Ni,nr].indexOf(vt)>=0,V=jt?"width":"height",rt=ga(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:A,padding:p}),Lt=jt?$t?ar:Ui:$t?nr:Ni;F[V]>H[V]&&(Lt=ho(Lt));var $=ho(Lt),U=[];if(o&&U.push(rt[vt]<=0),d&&U.push(rt[Lt]<=0,rt[$]<=0),U.every(function(Ut){return Ut})){ot=kt,nt=!1;break}j.set(kt,U)}if(nt)for(var q=E?3:1,gt=function(Ot){var ae=_.find(function(oe){var he=j.get(oe);if(he)return he.slice(0,Ot).every(function(Te){return Te})});if(ae)return ot=ae,"break"},Et=q;Et>0;Et--){var Pt=gt(Et);if(Pt==="break")break}t.placement!==ot&&(t.modifiersData[i]._skip=!0,t.placement=ot,t.reset=!0)}}const P1={name:"flip",enabled:!0,phase:"main",fn:x1,requiresIfExists:["offset"],data:{_skip:!1}};function lu(n,t,e){return e===void 0&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function cu(n){return[Ni,ar,nr,Ui].some(function(t){return n[t]>=0})}function O1(n){var t=n.state,e=n.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,c=ga(t,{elementContext:"reference"}),d=ga(t,{altBoundary:!0}),f=lu(c,i),p=lu(d,s,o),g=cu(f),v=cu(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const M1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:O1};function $1(n,t,e){var i=Ir(n),s=[Ui,Ni].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:n})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*s,[Ui,ar].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function F1(n){var t=n.state,e=n.options,i=n.name,s=e.offset,o=s===void 0?[0,0]:s,c=Zd.reduce(function(g,v){return g[v]=$1(v,t.rects,o),g},{}),d=c[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[i]=c}const N1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:F1};function U1(n){var t=n.state,e=n.name;t.modifiersData[e]=ou({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const B1={name:"popperOffsets",enabled:!0,phase:"read",fn:U1,data:{}};function G1(n){return n==="x"?"y":"x"}function H1(n){var t=n.state,e=n.options,i=n.name,s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,A=e.tether,T=A===void 0?!0:A,E=e.tetherOffset,w=E===void 0?0:E,R=ga(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),x=Ir(t.placement),M=vn(t.placement),G=!M,_=Fl(x),F=G1(_),H=t.modifiersData.popperOffsets,j=t.rects.reference,nt=t.rects.popper,ot=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,tt=typeof ot=="number"?{mainAxis:ot,altAxis:ot}:Object.assign({mainAxis:0,altAxis:0},ot),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,vt={x:0,y:0};if(H){if(o){var $t,jt=_==="y"?Ni:Ui,V=_==="y"?nr:ar,rt=_==="y"?"height":"width",Lt=H[_],$=Lt+R[jt],U=Lt-R[V],q=T?-nt[rt]/2:0,gt=M===pn?j[rt]:nt[rt],Et=M===pn?-nt[rt]:-j[rt],Pt=t.elements.arrow,Ut=T&&Pt?$l(Pt):{width:0,height:0},Ot=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:tu(),ae=Ot[jt],oe=Ot[V],he=fa(0,j[rt],Ut[rt]),Te=G?j[rt]/2-q-he-ae-tt.mainAxis:gt-he-ae-tt.mainAxis,pe=G?-j[rt]/2+q+he+oe+tt.mainAxis:Et+he+oe+tt.mainAxis,Wt=t.elements.arrow&&ua(t.elements.arrow),de=Wt?_==="y"?Wt.clientTop||0:Wt.clientLeft||0:0,ie=($t=kt==null?void 0:kt[_])!=null?$t:0,Ce=Lt+Te-ie-de,Bt=Lt+pe-ie,Ze=fa(T?oo($,Ce):$,Lt,T?Xs(U,Bt):U);H[_]=Ze,vt[_]=Ze-Lt}if(d){var ri,xi=_==="x"?Ni:Ui,Er=_==="x"?nr:ar,ke=H[F],oi=F==="y"?"height":"width",ve=ke+R[xi],qe=ke-R[Er],Qe=[Ni,Ui].indexOf(x)!==-1,Wi=(ri=kt==null?void 0:kt[F])!=null?ri:0,$e=Qe?ve:ke-j[oi]-nt[oi]-Wi+tt.altAxis,Si=Qe?ke+j[oi]+nt[oi]-Wi-tt.altAxis:qe,es=T&&Qe?u1($e,ke,Si):fa(T?$e:ve,ke,T?Si:qe);H[F]=es,vt[F]=es-ke}t.modifiersData[i]=vt}}const V1={name:"preventOverflow",enabled:!0,phase:"main",fn:H1,requiresIfExists:["offset"]};function W1(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function K1(n){return n===Xi(n)||!or(n)?Nl(n):W1(n)}function j1(n){var t=n.getBoundingClientRect(),e=gn(t.width)/n.offsetWidth||1,i=gn(t.height)/n.offsetHeight||1;return e!==1||i!==1}function z1(n,t,e){e===void 0&&(e=!1);var i=or(t),s=or(t)&&j1(t),o=gs(t),c=mn(n,s,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Cr(t)!=="body"||Bl(o))&&(d=K1(t)),or(t)?(f=mn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=Ul(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function Y1(n){var t=new Map,e=new Set,i=[];n.forEach(function(o){t.set(o.name,o)});function s(o){e.add(o.name);var c=[].concat(o.requires||[],o.requiresIfExists||[]);c.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&s(f)}}),i.push(o)}return n.forEach(function(o){e.has(o.name)||s(o)}),i}function Z1(n){var t=Y1(n);return o1.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function X1(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}function q1(n){var t=n.reduce(function(e,i){var s=e[i.name];return e[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var hu={placement:"bottom",modifiers:[],strategy:"absolute"};function du(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function Q1(n){n===void 0&&(n={});var t=n,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,o=s===void 0?hu:s;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},hu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],A=!1,T={state:g,setOptions:function(x){var M=typeof x=="function"?x(g.options):x;w(),g.options=Object.assign({},o,g.options,M),g.scrollParents={reference:Zs(d)?pa(d):d.contextElement?pa(d.contextElement):[],popper:pa(f)};var G=Z1(q1([].concat(i,g.options.modifiers)));return g.orderedModifiers=G.filter(function(_){return _.enabled}),E(),T.update()},forceUpdate:function(){if(!A){var x=g.elements,M=x.reference,G=x.popper;if(du(M,G)){g.rects={reference:z1(M,ua(G),g.options.strategy==="fixed"),popper:$l(G)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(tt){return g.modifiersData[tt.name]=Object.assign({},tt.data)});for(var _=0;_<g.orderedModifiers.length;_++){if(g.reset===!0){g.reset=!1,_=-1;continue}var F=g.orderedModifiers[_],H=F.fn,j=F.options,nt=j===void 0?{}:j,ot=F.name;typeof H=="function"&&(g=H({state:g,options:nt,name:ot,instance:T})||g)}}}},update:X1(function(){return new Promise(function(R){T.forceUpdate(),R(g)})}),destroy:function(){w(),A=!0}};if(!du(d,f))return T;T.setOptions(p).then(function(R){!A&&p.onFirstUpdate&&p.onFirstUpdate(R)});function E(){g.orderedModifiers.forEach(function(R){var x=R.name,M=R.options,G=M===void 0?{}:M,_=R.effect;if(typeof _=="function"){var F=_({state:g,name:x,instance:T,options:G}),H=function(){};v.push(F||H)}})}function w(){v.forEach(function(R){return R()}),v=[]}return T}}var J1=[T1,B1,A1,Xd,N1,P1,V1,m1,M1],tm=Q1({defaultModifiers:J1}),em="tippy-box",uu="tippy-content",im="tippy-backdrop",fu="tippy-arrow",pu="tippy-svg-arrow",qs={passive:!0,capture:!0},gu=function(){return document.body};function Hl(n,t,e){if(Array.isArray(n)){var i=n[t];return i??(Array.isArray(e)?e[t]:e)}return n}function Vl(n,t){var e={}.toString.call(n);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function mu(n,t){return typeof n=="function"?n.apply(void 0,t):n}function vu(n,t){if(t===0)return n;var e;return function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)}}function rm(n){return n.split(/\s+/).filter(Boolean)}function yn(n){return[].concat(n)}function yu(n,t){n.indexOf(t)===-1&&n.push(t)}function sm(n){return n.filter(function(t,e){return n.indexOf(t)===e})}function nm(n){return n.split("-")[0]}function uo(n){return[].slice.call(n)}function bu(n){return Object.keys(n).reduce(function(t,e){return n[e]!==void 0&&(t[e]=n[e]),t},{})}function ma(){return document.createElement("div")}function fo(n){return["Element","Fragment"].some(function(t){return Vl(n,t)})}function am(n){return Vl(n,"NodeList")}function om(n){return Vl(n,"MouseEvent")}function lm(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function cm(n){return fo(n)?[n]:am(n)?uo(n):Array.isArray(n)?n:uo(document.querySelectorAll(n))}function Wl(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Au(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function hm(n){var t,e=yn(n),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function dm(n,t){var e=t.clientX,i=t.clientY;return n.every(function(s){var o=s.popperRect,c=s.popperState,d=s.props,f=d.interactiveBorder,p=nm(c.placement),g=c.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,A=p==="top"?g.bottom.y:0,T=p==="right"?g.left.x:0,E=p==="left"?g.right.x:0,w=o.top-i+v>f,R=i-o.bottom-A>f,x=o.left-e+T>f,M=e-o.right-E>f;return w||R||x||M})}function Kl(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[i](s,e)})}function Eu(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Dr={isTouch:!1},Tu=0;function um(){Dr.isTouch||(Dr.isTouch=!0,window.performance&&document.addEventListener("mousemove",ku))}function ku(){var n=performance.now();n-Tu<20&&(Dr.isTouch=!1,document.removeEventListener("mousemove",ku)),Tu=n}function fm(){var n=document.activeElement;if(lm(n)){var t=n._tippy;n.blur&&!t.state.isVisible&&n.blur()}}function pm(){document.addEventListener("touchstart",um,qs),window.addEventListener("blur",fm)}var gm=typeof window<"u"&&typeof document<"u",mm=gm?!!window.msCrypto:!1,vm={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},ym={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},vr=Object.assign({appendTo:gu,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},vm,ym),bm=Object.keys(vr),Am=function(t){var e=Object.keys(t);e.forEach(function(i){vr[i]=t[i]})};function wu(n){var t=n.plugins||[],e=t.reduce(function(i,s){var o=s.name,c=s.defaultValue;if(o){var d;i[o]=n[o]!==void 0?n[o]:(d=vr[o])!=null?d:c}return i},{});return Object.assign({},n,e)}function Em(n,t){var e=t?Object.keys(wu(Object.assign({},vr,{plugins:t}))):bm,i=e.reduce(function(s,o){var c=(n.getAttribute("data-tippy-"+o)||"").trim();if(!c)return s;if(o==="content")s[o]=c;else try{s[o]=JSON.parse(c)}catch{s[o]=c}return s},{});return i}function Su(n,t){var e=Object.assign({},t,{content:mu(t.content,[n])},t.ignoreAttributes?{}:Em(n,t.plugins));return e.aria=Object.assign({},vr.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Tm=function(){return"innerHTML"};function jl(n,t){n[Tm()]=t}function Lu(n){var t=ma();return n===!0?t.className=fu:(t.className=pu,fo(n)?t.appendChild(n):jl(t,n)),t}function Ru(n,t){fo(t.content)?(jl(n,""),n.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?jl(n,t.content):n.textContent=t.content)}function zl(n){var t=n.firstElementChild,e=uo(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(uu)}),arrow:e.find(function(i){return i.classList.contains(fu)||i.classList.contains(pu)}),backdrop:e.find(function(i){return i.classList.contains(im)})}}function _u(n){var t=ma(),e=ma();e.className=em,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=ma();i.className=uu,i.setAttribute("data-state","hidden"),Ru(i,n.props),t.appendChild(e),e.appendChild(i),s(n.props,n.props);function s(o,c){var d=zl(t),f=d.box,p=d.content,g=d.arrow;c.theme?f.setAttribute("data-theme",c.theme):f.removeAttribute("data-theme"),typeof c.animation=="string"?f.setAttribute("data-animation",c.animation):f.removeAttribute("data-animation"),c.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof c.maxWidth=="number"?c.maxWidth+"px":c.maxWidth,c.role?f.setAttribute("role",c.role):f.removeAttribute("role"),(o.content!==c.content||o.allowHTML!==c.allowHTML)&&Ru(p,n.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(Lu(c.arrow))):f.appendChild(Lu(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:s}}_u.$$tippy=!0;var km=1,po=[],Yl=[];function wm(n,t){var e=Su(n,Object.assign({},vr,wu(bu(t)))),i,s,o,c=!1,d=!1,f=!1,p=!1,g,v,A,T=[],E=vu(Ce,e.interactiveDebounce),w,R=km++,x=null,M=sm(e.plugins),G={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},_={id:R,reference:n,popper:ma(),popperInstance:x,props:e,state:G,plugins:M,clearDelayTimeouts:$e,setProps:Si,setContent:es,show:li,hide:Tr,hideWithInteractivity:Es,enable:Qe,disable:Wi,unmount:Ts,destroy:Ji};if(!e.render)return _;var F=e.render(_),H=F.popper,j=F.onUpdate;H.setAttribute("data-tippy-root",""),H.id="tippy-"+_.id,_.popper=H,n._tippy=_,H._tippy=_;var nt=M.map(function(ct){return ct.fn(_)}),ot=n.hasAttribute("aria-expanded");return Wt(),q(),Lt(),$("onCreate",[_]),e.showOnCreate&&ve(),H.addEventListener("mouseenter",function(){_.props.interactive&&_.state.isVisible&&_.clearDelayTimeouts()}),H.addEventListener("mouseleave",function(){_.props.interactive&&_.props.trigger.indexOf("mouseenter")>=0&&jt().addEventListener("mousemove",E)}),_;function tt(){var ct=_.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return tt()[0]==="hold"}function vt(){var ct;return!!((ct=_.props.render)!=null&&ct.$$tippy)}function $t(){return w||n}function jt(){var ct=$t().parentNode;return ct?hm(ct):document}function V(){return zl(H)}function rt(ct){return _.state.isMounted&&!_.state.isVisible||Dr.isTouch||g&&g.type==="focus"?0:Hl(_.props.delay,ct?0:1,vr.delay)}function Lt(ct){ct===void 0&&(ct=!1),H.style.pointerEvents=_.props.interactive&&!ct?"":"none",H.style.zIndex=""+_.props.zIndex}function $(ct,Ht,Zt){if(Zt===void 0&&(Zt=!0),nt.forEach(function(se){se[ct]&&se[ct].apply(se,Ht)}),Zt){var ye;(ye=_.props)[ct].apply(ye,Ht)}}function U(){var ct=_.props.aria;if(ct.content){var Ht="aria-"+ct.content,Zt=H.id,ye=yn(_.props.triggerTarget||n);ye.forEach(function(se){var si=se.getAttribute(Ht);if(_.state.isVisible)se.setAttribute(Ht,si?si+" "+Zt:Zt);else{var Li=si&&si.replace(Zt,"").trim();Li?se.setAttribute(Ht,Li):se.removeAttribute(Ht)}})}}function q(){if(!(ot||!_.props.aria.expanded)){var ct=yn(_.props.triggerTarget||n);ct.forEach(function(Ht){_.props.interactive?Ht.setAttribute("aria-expanded",_.state.isVisible&&Ht===$t()?"true":"false"):Ht.removeAttribute("aria-expanded")})}}function gt(){jt().removeEventListener("mousemove",E),po=po.filter(function(ct){return ct!==E})}function Et(ct){if(!(Dr.isTouch&&(f||ct.type==="mousedown"))){var Ht=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(_.props.interactive&&Eu(H,Ht))){if(yn(_.props.triggerTarget||n).some(function(Zt){return Eu(Zt,Ht)})){if(Dr.isTouch||_.state.isVisible&&_.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[_,ct]);_.props.hideOnClick===!0&&(_.clearDelayTimeouts(),_.hide(),d=!0,setTimeout(function(){d=!1}),_.state.isMounted||ae())}}}function Pt(){f=!0}function Ut(){f=!1}function Ot(){var ct=jt();ct.addEventListener("mousedown",Et,!0),ct.addEventListener("touchend",Et,qs),ct.addEventListener("touchstart",Ut,qs),ct.addEventListener("touchmove",Pt,qs)}function ae(){var ct=jt();ct.removeEventListener("mousedown",Et,!0),ct.removeEventListener("touchend",Et,qs),ct.removeEventListener("touchstart",Ut,qs),ct.removeEventListener("touchmove",Pt,qs)}function oe(ct,Ht){Te(ct,function(){!_.state.isVisible&&H.parentNode&&H.parentNode.contains(H)&&Ht()})}function he(ct,Ht){Te(ct,Ht)}function Te(ct,Ht){var Zt=V().box;function ye(se){se.target===Zt&&(Kl(Zt,"remove",ye),Ht())}if(ct===0)return Ht();Kl(Zt,"remove",v),Kl(Zt,"add",ye),v=ye}function pe(ct,Ht,Zt){Zt===void 0&&(Zt=!1);var ye=yn(_.props.triggerTarget||n);ye.forEach(function(se){se.addEventListener(ct,Ht,Zt),T.push({node:se,eventType:ct,handler:Ht,options:Zt})})}function Wt(){kt()&&(pe("touchstart",ie,{passive:!0}),pe("touchend",Bt,{passive:!0})),rm(_.props.trigger).forEach(function(ct){if(ct!=="manual")switch(pe(ct,ie),ct){case"mouseenter":pe("mouseleave",Bt);break;case"focus":pe(mm?"focusout":"blur",Ze);break;case"focusin":pe("focusout",Ze);break}})}function de(){T.forEach(function(ct){var Ht=ct.node,Zt=ct.eventType,ye=ct.handler,se=ct.options;Ht.removeEventListener(Zt,ye,se)}),T=[]}function ie(ct){var Ht,Zt=!1;if(!(!_.state.isEnabled||ri(ct)||d)){var ye=((Ht=g)==null?void 0:Ht.type)==="focus";g=ct,w=ct.currentTarget,q(),!_.state.isVisible&&om(ct)&&po.forEach(function(se){return se(ct)}),ct.type==="click"&&(_.props.trigger.indexOf("mouseenter")<0||c)&&_.props.hideOnClick!==!1&&_.state.isVisible?Zt=!0:ve(ct),ct.type==="click"&&(c=!Zt),Zt&&!ye&&qe(ct)}}function Ce(ct){var Ht=ct.target,Zt=$t().contains(Ht)||H.contains(Ht);if(!(ct.type==="mousemove"&&Zt)){var ye=oi().concat(H).map(function(se){var si,Li=se._tippy,dr=(si=Li.popperInstance)==null?void 0:si.state;return dr?{popperRect:se.getBoundingClientRect(),popperState:dr,props:e}:null}).filter(Boolean);dm(ye,ct)&&(gt(),qe(ct))}}function Bt(ct){var Ht=ri(ct)||_.props.trigger.indexOf("click")>=0&&c;if(!Ht){if(_.props.interactive){_.hideWithInteractivity(ct);return}qe(ct)}}function Ze(ct){_.props.trigger.indexOf("focusin")<0&&ct.target!==$t()||_.props.interactive&&ct.relatedTarget&&H.contains(ct.relatedTarget)||qe(ct)}function ri(ct){return Dr.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function xi(){Er();var ct=_.props,Ht=ct.popperOptions,Zt=ct.placement,ye=ct.offset,se=ct.getReferenceClientRect,si=ct.moveTransition,Li=vt()?zl(H).arrow:null,dr=se?{getBoundingClientRect:se,contextElement:se.contextElement||$t()}:n,is={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(ks){var Ri=ks.state;if(vt()){var _a=V(),pr=_a.box;["placement","reference-hidden","escaped"].forEach(function(ws){ws==="placement"?pr.setAttribute("data-placement",Ri.placement):Ri.attributes.popper["data-popper-"+ws]?pr.setAttribute("data-"+ws,""):pr.removeAttribute("data-"+ws)}),Ri.attributes.popper={}}}},ur=[{name:"offset",options:{offset:ye}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!si}},is];vt()&&Li&&ur.push({name:"arrow",options:{element:Li,padding:3}}),ur.push.apply(ur,(Ht==null?void 0:Ht.modifiers)||[]),_.popperInstance=tm(dr,H,Object.assign({},Ht,{placement:Zt,onFirstUpdate:A,modifiers:ur}))}function Er(){_.popperInstance&&(_.popperInstance.destroy(),_.popperInstance=null)}function ke(){var ct=_.props.appendTo,Ht,Zt=$t();_.props.interactive&&ct===gu||ct==="parent"?Ht=Zt.parentNode:Ht=mu(ct,[Zt]),Ht.contains(H)||Ht.appendChild(H),_.state.isMounted=!0,xi()}function oi(){return uo(H.querySelectorAll("[data-tippy-root]"))}function ve(ct){_.clearDelayTimeouts(),ct&&$("onTrigger",[_,ct]),Ot();var Ht=rt(!0),Zt=tt(),ye=Zt[0],se=Zt[1];Dr.isTouch&&ye==="hold"&&se&&(Ht=se),Ht?i=setTimeout(function(){_.show()},Ht):_.show()}function qe(ct){if(_.clearDelayTimeouts(),$("onUntrigger",[_,ct]),!_.state.isVisible){ae();return}if(!(_.props.trigger.indexOf("mouseenter")>=0&&_.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&c)){var Ht=rt(!1);Ht?s=setTimeout(function(){_.state.isVisible&&_.hide()},Ht):o=requestAnimationFrame(function(){_.hide()})}}function Qe(){_.state.isEnabled=!0}function Wi(){_.hide(),_.state.isEnabled=!1}function $e(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(o)}function Si(ct){if(!_.state.isDestroyed){$("onBeforeUpdate",[_,ct]),de();var Ht=_.props,Zt=Su(n,Object.assign({},Ht,bu(ct),{ignoreAttributes:!0}));_.props=Zt,Wt(),Ht.interactiveDebounce!==Zt.interactiveDebounce&&(gt(),E=vu(Ce,Zt.interactiveDebounce)),Ht.triggerTarget&&!Zt.triggerTarget?yn(Ht.triggerTarget).forEach(function(ye){ye.removeAttribute("aria-expanded")}):Zt.triggerTarget&&n.removeAttribute("aria-expanded"),q(),Lt(),j&&j(Ht,Zt),_.popperInstance&&(xi(),oi().forEach(function(ye){requestAnimationFrame(ye._tippy.popperInstance.forceUpdate)})),$("onAfterUpdate",[_,ct])}}function es(ct){_.setProps({content:ct})}function li(){var ct=_.state.isVisible,Ht=_.state.isDestroyed,Zt=!_.state.isEnabled,ye=Dr.isTouch&&!_.props.touch,se=Hl(_.props.duration,0,vr.duration);if(!(ct||Ht||Zt||ye)&&!$t().hasAttribute("disabled")&&($("onShow",[_],!1),_.props.onShow(_)!==!1)){if(_.state.isVisible=!0,vt()&&(H.style.visibility="visible"),Lt(),Ot(),_.state.isMounted||(H.style.transition="none"),vt()){var si=V(),Li=si.box,dr=si.content;Wl([Li,dr],0)}A=function(){var ur;if(!(!_.state.isVisible||p)){if(p=!0,H.offsetHeight,H.style.transition=_.props.moveTransition,vt()&&_.props.animation){var fr=V(),ks=fr.box,Ri=fr.content;Wl([ks,Ri],se),Au([ks,Ri],"visible")}U(),q(),yu(Yl,_),(ur=_.popperInstance)==null||ur.forceUpdate(),$("onMount",[_]),_.props.animation&&vt()&&he(se,function(){_.state.isShown=!0,$("onShown",[_])})}},ke()}}function Tr(){var ct=!_.state.isVisible,Ht=_.state.isDestroyed,Zt=!_.state.isEnabled,ye=Hl(_.props.duration,1,vr.duration);if(!(ct||Ht||Zt)&&($("onHide",[_],!1),_.props.onHide(_)!==!1)){if(_.state.isVisible=!1,_.state.isShown=!1,p=!1,c=!1,vt()&&(H.style.visibility="hidden"),gt(),ae(),Lt(!0),vt()){var se=V(),si=se.box,Li=se.content;_.props.animation&&(Wl([si,Li],ye),Au([si,Li],"hidden"))}U(),q(),_.props.animation?vt()&&oe(ye,_.unmount):_.unmount()}}function Es(ct){jt().addEventListener("mousemove",E),yu(po,E),E(ct)}function Ts(){_.state.isVisible&&_.hide(),_.state.isMounted&&(Er(),oi().forEach(function(ct){ct._tippy.unmount()}),H.parentNode&&H.parentNode.removeChild(H),Yl=Yl.filter(function(ct){return ct!==_}),_.state.isMounted=!1,$("onHidden",[_]))}function Ji(){_.state.isDestroyed||(_.clearDelayTimeouts(),_.unmount(),de(),delete n._tippy,_.state.isDestroyed=!0,$("onDestroy",[_]))}}function Qs(n,t){t===void 0&&(t={});var e=vr.plugins.concat(t.plugins||[]);pm();var i=Object.assign({},t,{plugins:e}),s=cm(n),o=s.reduce(function(c,d){var f=d&&wm(d,i);return f&&c.push(f),c},[]);return fo(n)?o[0]:o}Qs.defaultProps=vr,Qs.setDefaultProps=Am,Qs.currentInput=Dr,Object.assign({},Xd,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),Qs.setDefaultProps({render:_u});const Sm=5;class Lm{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._fakeBufferSegments=[],this._canvas=rr(),this._controls=rr(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,s,o,c;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<=g+v))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:g})=>d>=g-Sm&&d<g))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=Rd((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var A;const T=d-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return g&&v&&T>=Xa(g)&&T<=Xa(v)}))==null?void 0:c.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&!this.host.stalled&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set fakeBufferSegments(t){t!==this._fakeBufferSegments&&(this._fakeBufferSegments=t,this.host.requestUpdate())}get fakeBufferSegments(){return this._fakeBufferSegments}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return sr(this._canvas)}controls(){return sr(this._controls)}loadScenes(){var t;let e=this.fakeBufferSegments;(t=this.host.scenes)==null||t.forEach(i=>{var s,o;const{start:c,duration:d,video:f,videoMeta:p}=i,g=this.activeScenes.includes(i),v=(this._upcomingScenes.includes(i)||g)&&(this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused);if(f&&p){const{id:A,hls:T,node:E}=f,{start:w,duration:R}=p,x=this.host.videoState[A];E&&x&&(E.currentTime>=w+R||E.ended||v&&(T?(s=T.startLoadOnce)==null||s.call(T,E.currentTime):x.initialised||(o=E.startLoadOnce)==null||o.call(E)))}else if(v){const A={start:Math.max(0,c/this.host.duration*100),end:Math.min((c+d)/this.host.duration*100,100)};this.fakeBufferSegments.find(({start:T})=>T===A.start)||(e=[...e,A])}}),this.fakeBufferSegments=e}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{id:i,node:s}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(s&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&o.initialised)return s.play()}else s.paused||s.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function Rm(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Cu={exports:{}};(function(n,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var A=d.parseURL(p);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return g.alwaysNormalize?(A.path=d.normalizePath(A.path),d.buildURLFromParts(A)):p;var T=d.parseURL(f);if(!T)throw new Error("Error trying to parse base URL.");if(!T.netLoc&&T.path&&T.path[0]!=="/"){var E=s.exec(T.path);T.netLoc=E[1],T.path=E[2]}T.netLoc&&!T.path&&(T.path="/");var w={scheme:T.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(w.netLoc=T.netLoc,A.path[0]!=="/"))if(!A.path)w.path=T.path,A.params||(w.params=T.params,A.query||(w.query=T.query));else{var R=T.path,x=R.substring(0,R.lastIndexOf("/")+1)+A.path;w.path=d.normalizePath(x)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(A.path):A.path),d.buildURLFromParts(w)},parseURL:function(f){var p=i.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(c,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};n.exports=d})()})(Cu);var Zl=Cu.exports;function Iu(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Bi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Iu(Object(e),!0).forEach(function(i){_m(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Iu(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function _m(n,t,e){return t=Im(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function ni(){return ni=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},ni.apply(this,arguments)}function Cm(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Im(n){var t=Cm(n,"string");return typeof t=="symbol"?t:String(t)}const Kt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)};let L=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n}({}),qt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),ut=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const Js=function(){},Xl={trace:Js,debug:Js,log:Js,warn:Js,info:Js,error:Js};let va=Xl;function Dm(n){const t=self.console[n];return t?t.bind(self.console,`[${n}] >`):Js}function xm(n,...t){t.forEach(function(e){va[e]=n[e]?n[e].bind(n):Dm(e)})}function Pm(n,t){if(self.console&&n===!0||typeof n=="object"){xm(n,"debug","log","info","warn","error");try{va.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{va=Xl}}else va=Xl}const Y=va,Om=/^(\d+)x(\d+)$/,Du=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ze{constructor(t){typeof t=="string"&&(t=ze.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let s=0;s<e.length/2;s++)i[s]=parseInt(e.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=Om.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},s='"';for(Du.lastIndex=0;(e=Du.exec(t))!==null;){let o=e[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function Mm(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function $m(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class xu{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){Y.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=ni(new ze({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);Kt(i.getTime())&&(this._endDate=i)}}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 t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(Kt(t))return t}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&&Kt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class go{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 _e={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Pu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[_e.AUDIO]:null,[_e.VIDEO]:null,[_e.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),s=[];i.length===1?s[0]=e?e.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}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=Zl.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class ql extends Pu{constructor(t,e){super(e),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 go,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!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 i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Kt(this.programDateTime))return null;const t=Kt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,s,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:o,partial:c};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,s),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[_e.AUDIO]=null,t[_e.VIDEO]=null,t[_e.AUDIOVIDEO]=null}}class Fm extends Pu{constructor(t,e,i,s,o){super(i),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 go,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const Nm=10;class Um{constructor(t){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=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Kt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Nm}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.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 t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Ql(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function Bm(n){const t=Ou(n).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function Gm(n){const t=function(e,i,s){const o=e[i];e[i]=e[s],e[s]=o};t(n,0,3),t(n,1,2),t(n,4,5),t(n,6,7)}function Hm(n){const t=n.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const o=s[0]==="base64",c=s[1];o?(i.splice(-1,1),e=Ql(c)):e=Bm(c)}}return e}function Ou(n){return Uint8Array.from(unescape(encodeURIComponent(n)),t=>t.charCodeAt(0))}var Ye={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Gi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Mu(n){switch(n){case Gi.FAIRPLAY:return Ye.FAIRPLAY;case Gi.PLAYREADY:return Ye.PLAYREADY;case Gi.WIDEVINE:return Ye.WIDEVINE;case Gi.CLEARKEY:return Ye.CLEARKEY}}var $u={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Vm(n){if(n===$u.WIDEVINE)return Ye.WIDEVINE}function Fu(n){switch(n){case Ye.FAIRPLAY:return Gi.FAIRPLAY;case Ye.PLAYREADY:return Gi.PLAYREADY;case Ye.WIDEVINE:return Gi.WIDEVINE;case Ye.CLEARKEY:return Gi.CLEARKEY}}function Jl(n){const{drmSystems:t,widevineLicenseUrl:e}=n,i=t?[Ye.FAIRPLAY,Ye.WIDEVINE,Ye.PLAYREADY,Ye.CLEARKEY].filter(s=>!!t[s]):[];return!i[Ye.WIDEVINE]&&e&&i.push(Ye.WIDEVINE),i}const Nu=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Wm(n,t,e,i){let s;switch(n){case Ye.FAIRPLAY:s=["cenc","sinf"];break;case Ye.WIDEVINE:case Ye.PLAYREADY:s=["cenc"];break;case Ye.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return Km(s,t,e,i)}function Km(n,t,e,i){return[{initDataTypes:n,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function tn(n,t,e){return Uint8Array.prototype.slice?n.slice(t,e):new Uint8Array(Array.prototype.slice.call(n,t,e))}const tc=(n,t)=>t+10<=n.length&&n[t]===73&&n[t+1]===68&&n[t+2]===51&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,Uu=(n,t)=>t+10<=n.length&&n[t]===51&&n[t+1]===68&&n[t+2]===73&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,mo=(n,t)=>{const e=t;let i=0;for(;tc(n,t);){i+=10;const s=vo(n,t+6);i+=s,Uu(n,t+10)&&(i+=10),t+=i}if(i>0)return n.subarray(e,e+i)},vo=(n,t)=>{let e=0;return e=(n[t]&127)<<21,e|=(n[t+1]&127)<<14,e|=(n[t+2]&127)<<7,e|=n[t+3]&127,e},jm=(n,t)=>tc(n,t)&&vo(n,t+6)+10<=n.length-t,zm=n=>{const t=Gu(n);for(let e=0;e<t.length;e++){const i=t[e];if(Bu(i))return Jm(i)}},Bu=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",Ym=n=>{const t=String.fromCharCode(n[0],n[1],n[2],n[3]),e=vo(n,4),i=10;return{type:t,size:e,data:n.subarray(i,i+e)}},Gu=n=>{let t=0;const e=[];for(;tc(n,t);){const i=vo(n,t+6);t+=10;const s=t+i;for(;t+8<s;){const o=Ym(n.subarray(t)),c=Zm(o);c&&e.push(c),t+=o.size+10}Uu(n,t)&&(t+=10)}return e},Zm=n=>n.type==="PRIV"?Xm(n):n.type[0]==="W"?Qm(n):qm(n),Xm=n=>{if(n.size<2)return;const t=xr(n.data,!0),e=new Uint8Array(n.data.subarray(t.length+1));return{key:n.type,info:t,data:e.buffer}},qm=n=>{if(n.size<2)return;if(n.type==="TXXX"){let e=1;const i=xr(n.data.subarray(e),!0);e+=i.length+1;const s=xr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=xr(n.data.subarray(1));return{key:n.type,data:t}},Qm=n=>{if(n.type==="WXXX"){if(n.size<2)return;let e=1;const i=xr(n.data.subarray(e),!0);e+=i.length+1;const s=xr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=xr(n.data);return{key:n.type,data:t}},Jm=n=>{if(n.data.byteLength===8){const t=new Uint8Array(n.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},xr=(n,t=!1)=>{const e=tv();if(e){const p=e.decode(n);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=n.length;let s,o,c,d="",f=0;for(;f<i;){if(s=n[f++],s===0&&t)return d;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(s);break;case 12:case 13:o=n[f++],d+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=n[f++],c=n[f++],d+=String.fromCharCode((s&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let ec;function tv(){return!ec&&typeof self.TextDecoder<"u"&&(ec=new self.TextDecoder("utf-8")),ec}const Pr={hexDump:function(n){let t="";for(let e=0;e<n.length;e++){let i=n[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},yo=Math.pow(2,32)-1,ev=[].push,Hu={video:1,audio:2,id3:3,text:4};function bi(n){return String.fromCharCode.apply(null,n)}function Vu(n,t){const e=n[t]<<8|n[t+1];return e<0?65536+e:e}function te(n,t){const e=Wu(n,t);return e<0?4294967296+e:e}function Wu(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function ic(n,t,e){n[t]=e>>24,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255}function be(n,t){const e=[];if(!t.length)return e;const i=n.byteLength;for(let s=0;s<i;){const o=te(n,s),c=bi(n.subarray(s+4,s+8)),d=o>1?s+o:i;if(c===t[0])if(t.length===1)e.push(n.subarray(s+8,d));else{const f=be(n.subarray(s+8,d),t.slice(1));f.length&&ev.apply(e,f)}s=d}return e}function iv(n){const t=[],e=n[0];let i=8;const s=te(n,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=n.length+c;const f=Vu(n,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=te(n,g);g+=4;const A=v&2147483647;if((v&2147483648)>>>31===1)return Y.warn("SIDX has hierarchical references (not supported)"),null;const T=te(n,g);g+=4,t.push({referenceSize:A,subsegmentDuration:T,info:{duration:T/s,start:d,end:d+A-1}}),d+=A,g+=4,i=g}return{earliestPresentationTime:o,timescale:s,version:e,referencesCount:f,references:t}}function Ku(n){const t=[],e=be(n,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],o=be(s,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=te(o,d),p=be(s,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=te(p,d),v=be(s,["mdia","hdlr"])[0];if(v){const A=bi(v.subarray(8,12)),T={soun:_e.AUDIO,vide:_e.VIDEO}[A];if(T){const E=be(s,["mdia","minf","stbl","stsd"])[0];let w;E&&(w=bi(E.subarray(12,16))),t[f]={timescale:g,type:T},t[T]={timescale:g,id:f,codec:w}}}}}}return be(n,["moov","mvex","trex"]).forEach(i=>{const s=te(i,4),o=t[s];o&&(o.default={duration:te(i,12),flags:te(i,20)})}),t}function rv(n,t){if(!n||!t)return n;const e=t.keyId;return e&&t.isCommonEncryption&&be(n,["moov","trak"]).forEach(i=>{const s=be(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=be(s,["enca"]);const c=o.length>0;c||(o=be(s,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);be(f,["sinf"]).forEach(p=>{const g=ju(p);if(g){const v=g.subarray(8,24);v.some(A=>A!==0)||(Y.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Pr.hexDump(v)} -> ${Pr.hexDump(e)}`),g.set(e,8))}})})}),n}function ju(n){const t=be(n,["schm"])[0];if(t){const e=bi(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return be(n,["schi","tenc"])[0]}return Y.error("[eme] missing 'schm' box"),null}function sv(n,t){return be(t,["moof","traf"]).reduce((e,i)=>{const s=be(i,["tfdt"])[0],o=s[0],c=be(i,["tfhd"]).reduce((d,f)=>{const p=te(f,4),g=n[p];if(g){let v=te(s,4);if(o===1){if(v===yo)return Y.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=yo+1,v+=te(s,8)}const A=g.timescale||9e4,T=v/A;if(isFinite(T)&&(d===null||T<d))return T}return d},null);return c!==null&&isFinite(c)&&(e===null||c<e)?c:e},null)}function nv(n,t){let e=0,i=0,s=0;const o=be(n,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=be(d,["tfhd"])[0],p=te(f,4),g=t[p];if(!g)continue;const v=g.default,A=te(f,0)|(v==null?void 0:v.flags);let T=v==null?void 0:v.duration;A&8&&(A&2?T=te(f,12):T=te(f,8));const E=g.timescale||9e4,w=be(d,["trun"]);for(let R=0;R<w.length;R++){if(e=av(w[R]),!e&&T){const x=te(w[R],4);e=T*x}g.type===_e.VIDEO?i+=e/E:g.type===_e.AUDIO&&(s+=e/E)}}if(i===0&&s===0){let c=0;const d=be(n,["sidx"]);for(let f=0;f<d.length;f++){const p=iv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||s}function av(n){const t=te(n,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=te(n,4);for(let o=0;o<s;o++){if(t&256){const c=te(n,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function ov(n,t,e){be(t,["moof","traf"]).forEach(i=>{be(i,["tfhd"]).forEach(s=>{const o=te(s,4),c=n[o];if(!c)return;const d=c.timescale||9e4;be(i,["tfdt"]).forEach(f=>{const p=f[0];let g=te(f,4);if(p===0)g-=e*d,g=Math.max(g,0),ic(f,4,g);else{g*=Math.pow(2,32),g+=te(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(yo+1)),A=Math.floor(g%(yo+1));ic(f,4,v),ic(f,8,A)}})})})}function lv(n){const t={valid:null,remainder:null},e=be(n,["moof"]);if(e){if(e.length<2)return t.remainder=n,t}else return t;const i=e[e.length-1];return t.valid=tn(n,0,i.byteOffset-8),t.remainder=tn(n,i.byteOffset-8),t}function en(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function zu(n,t){const e=[],i=t.samples,s=t.timescale,o=t.id;let c=!1;return be(i,["moof"]).map(d=>{const f=d.byteOffset-8;be(d,["traf"]).map(p=>{const g=be(p,["tfdt"]).map(v=>{const A=v[0];let T=te(v,4);return A===1&&(T*=Math.pow(2,32),T+=te(v,8)),T/s})[0];return g!==void 0&&(n=g),be(p,["tfhd"]).map(v=>{const A=te(v,4),T=te(v,0)&16777215,E=(T&1)!==0,w=(T&2)!==0,R=(T&8)!==0;let x=0;const M=(T&16)!==0;let G=0;const _=(T&32)!==0;let F=8;A===o&&(E&&(F+=8),w&&(F+=4),R&&(x=te(v,F),F+=4),M&&(G=te(v,F),F+=4),_&&(F+=4),t.type==="video"&&(c=cv(t.codec)),be(p,["trun"]).map(H=>{const j=H[0],nt=te(H,0)&16777215,ot=(nt&1)!==0;let tt=0;const kt=(nt&4)!==0,vt=(nt&256)!==0;let $t=0;const jt=(nt&512)!==0;let V=0;const rt=(nt&1024)!==0,Lt=(nt&2048)!==0;let $=0;const U=te(H,4);let q=8;ot&&(tt=te(H,q),q+=4),kt&&(q+=4);let gt=tt+f;for(let Et=0;Et<U;Et++){if(vt?($t=te(H,q),q+=4):$t=x,jt?(V=te(H,q),q+=4):V=G,rt&&(q+=4),Lt&&(j===0?$=te(H,q):$=Wu(H,q),q+=4),t.type===_e.VIDEO){let Pt=0;for(;Pt<V;){const Ut=te(i,gt);if(gt+=4,hv(c,i[gt])){const Ot=i.subarray(gt,gt+Ut);Yu(Ot,c?2:1,n+$/s,e)}gt+=Ut,Pt+=Ut+4}}n+=$t/s}}))})})}),e}function cv(n){if(!n)return!1;const t=n.indexOf("."),e=t<0?n:n.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function hv(n,t){if(n){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function Yu(n,t,e,i){const s=Zu(n);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<s.length;){c=0;do{if(o>=s.length)break;p=s[o++],c+=p}while(p===255);d=0;do{if(o>=s.length)break;p=s[o++],d+=p}while(p===255);const g=s.length-o;if(!f&&c===4&&o<s.length){if(f=!0,s[o++]===181){const v=Vu(s,o);if(o+=2,v===49){const A=te(s,o);if(o+=4,A===1195456820){const T=s[o++];if(T===3){const E=s[o++],w=31&E,R=64&E,x=R?2+w*3:0,M=new Uint8Array(x);if(R){M[0]=E;for(let G=1;G<x;G++)M[G]=s[o++]}i.push({type:T,payloadType:c,pts:e,bytes:M})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let E=0;E<16;E++){const w=s[o++].toString(16);v.push(w.length==1?"0"+w:w),(E===3||E===5||E===7||E===9)&&v.push("-")}const A=d-16,T=new Uint8Array(A);for(let E=0;E<A;E++)T[E]=s[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:xr(T),userDataBytes:T})}}else if(d<g)o+=d;else if(d>g)break}}function Zu(n){const t=n.byteLength,e=[];let i=1;for(;i<t-2;)n[i]===0&&n[i+1]===0&&n[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return n;const s=t-e.length,o=new Uint8Array(s);let c=0;for(i=0;i<s;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=n[c];return o}function dv(n){const t=n[0];let e="",i="",s=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1,s=te(n,12),o=te(n,16),d=te(n,20),f=te(n,24),p=28}else if(t===1){p+=4,s=te(n,p),p+=4;const v=te(n,p);p+=4;const A=te(n,p);for(p+=4,c=4294967296*v+A,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,Y.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=te(n,p),p+=4,f=te(n,p),p+=4;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1}const g=n.subarray(p,n.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function uv(n,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(n,4),s=0,i=8;s<e;s++)o.set(t[s],i),i+=t[s].byteLength;return o}function fv(n,t,e){if(n.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");s.set(f,d*16)}}else i=0,s=new Uint8Array;let o;i>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),uv([112,115,115,104],new Uint8Array([i,0,0,0]),n,o,s,c,e||new Uint8Array)}function pv(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(n),i=e.getUint32(0);if(n.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Pr.hexDump(new Uint8Array(n,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(n,32,s)}else if(t.version===1){t.kids=[];for(let o=0;o<s;o++)t.kids.push(new Uint8Array(n,32+o*16,16))}return t}let bo={};class ya{static clearKeyUriToKeyIdMap(){bo={}}constructor(t,e,i,s=[1],o=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=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Gi.FAIRPLAY:case Gi.WIDEVINE:case Gi.PLAYREADY:case Gi.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&Y.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=gv(t);return new ya(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=Hm(this.uri);if(e)switch(this.keyFormat){case Gi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Gi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=fv(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),c=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=Ql(f).subarray(0,16);Gm(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=bo[this.uri];if(!i){const s=Object.keys(bo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),bo[this.uri]=i}this.keyId=i}return this}}function gv(n){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=n>>8*(15-e)&255;return t}const Xu=/\{\$([a-zA-Z0-9-_]+)\}/g;function qu(n){return Xu.test(n)}function Hi(n,t,e){if(n.variableList!==null||n.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],o=t[s];o&&(t[s]=rc(n,o))}}function rc(n,t){if(n.variableList!==null||n.hasVariableRefs){const e=n.variableList;return t.replace(Xu,i=>{const s=i.substring(2,i.length-1),o=e==null?void 0:e[s];return o===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):o})}return t}function Qu(n,t,e){let i=n.variableList;i||(n.variableList=i={});let s,o;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(s))o=c.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(c){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else s=t.NAME,o=t.VALUE;s in i?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=o||""}function mv(n,t,e){const i=t.IMPORT;if(e&&i in e){let s=n.variableList;s||(n.variableList=s={}),s[i]=e[i]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Ao(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const vv={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Ju=Ao();function yv(n,t){const e=vv[t];return!!e&&e[n.slice(0,4)]===!0}function sc(n,t){var e;return(e=Ju==null?void 0:Ju.isTypeSupported(`${t||"video"}/mp4;codecs="${n}"`))!=null?e:!1}const t0=/#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,e0=/#EXT-X-MEDIA:(.*)/g,bv=/^#EXT(?:INF|-X-TARGETDURATION):/m,i0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Av=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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class yr{static findGroup(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.id===e)return s}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return Zl.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return bv.test(t)}static parseMasterPlaylist(t,e){const i=qu(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];t0.lastIndex=0;let c;for(;(c=t0.exec(t))!=null;)if(c[1]){var d;const p=new ze(c[1]);Hi(s,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=rc(s,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:yr.resolve(g,e)},A=p.decimalResolution("RESOLUTION");A&&(v.width=A.width,v.height=A.height),Ev((p.CODECS||"").split(/[ ,]+/).filter(T=>T),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=yr.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),s.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ze(g);Hi(s,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=v["DATA-ID"];A&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[A]=v);break}case"SESSION-KEY":{const v=r0(g,e,s);v.encrypted&&v.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(v)):Y.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ze(g);Hi(s,v,["NAME","VALUE","QUERYPARAM"]),Qu(s,v,e)}break}case"CONTENT-STEERING":{const v=new ze(g);Hi(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:yr.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=s0(g);break}}}const f=o.length>0&&o.length<s.levels.length;return s.levels=f?o:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const o={},c=i.levels,d={AUDIO:c.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:c.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(e0.lastIndex=0;(s=e0.exec(t))!==null;){const p=new ze(s[1]),g=p.TYPE;if(g){const v=d[g],A=o[g]||[];o[g]=A,Hi(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const T={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?yr.resolve(p.URI,e):""};if(v!=null&&v.length){const E=yr.findGroup(v,T.groupId)||v[0];n0(T,E,"audioCodec"),n0(T,E,"textCodec")}A.push(T)}}return o}static parseLevelPlaylist(t,e,i,s,o,c){const d=new Um(e),f=d.fragments;let p=null,g=0,v=0,A=0,T=0,E=null,w=new ql(s,e),R,x,M,G=-1,_=!1;for(i0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=qu(t);(R=i0.exec(t))!==null;){_&&(_=!1,w=new ql(s,e),w.start=A,w.sn=g,w.cc=T,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const nt=R[1];if(nt){w.duration=parseFloat(nt);const ot=(" "+R[2]).slice(1);w.title=ot||null,w.tagList.push(ot?["INF",nt,ot]:["INF",nt])}else if(R[3]){if(Kt(w.duration)){w.start=A,M&&l0(w,M,d),w.sn=g,w.level=i,w.cc=T,w.urlId=o,f.push(w);const ot=(" "+R[3]).slice(1);w.relurl=rc(d,ot),a0(w,E),E=w,A+=w.duration,g++,v=0,_=!0}}else if(R[4]){const ot=(" "+R[4]).slice(1);E?w.setByteRange(ot,E):w.setByteRange(ot)}else if(R[5])w.rawProgramDateTime=(" "+R[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),G===-1&&(G=f.length);else{if(R=R[0].match(Av),!R){Y.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<R.length&&!(typeof R[x]<"u");x++);const ot=(" "+R[x]).slice(1),tt=(" "+R[x+1]).slice(1),kt=R[x+2]?(" "+R[x+2]).slice(1):"";switch(ot){case"PLAYLIST-TYPE":d.type=tt.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(tt);break;case"SKIP":{const vt=new ze(tt);Hi(d,vt,["RECENTLY-REMOVED-DATERANGES"]);const $t=vt.decimalInteger("SKIPPED-SEGMENTS");if(Kt($t)){d.skippedSegments=$t;for(let V=$t;V--;)f.unshift(null);g+=$t}const jt=vt.enumeratedString("RECENTLY-REMOVED-DATERANGES");jt&&(d.recentlyRemovedDateranges=jt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(tt),1);break;case"VERSION":d.version=parseInt(tt);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(tt||kt)&&w.tagList.push(kt?[tt,kt]:[tt]);break;case"DISCONTINUITY":T++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([ot]);break;case"BITRATE":w.tagList.push([ot,tt]);break;case"DATERANGE":{const vt=new ze(tt);Hi(d,vt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Hi(d,vt,vt.clientAttrs);const $t=new xu(vt,d.dateRanges[vt.ID]);$t.isValid||d.skippedSegments?d.dateRanges[$t.id]=$t:Y.warn(`Ignoring invalid DATERANGE tag: "${tt}"`),w.tagList.push(["EXT-X-DATERANGE",tt]);break}case"DEFINE":{{const vt=new ze(tt);Hi(d,vt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in vt?mv(d,vt,c):Qu(d,vt,e)}break}case"DISCONTINUITY-SEQUENCE":T=parseInt(tt);break;case"KEY":{const vt=r0(tt,e,d);if(vt.isSupported()){if(vt.method==="NONE"){M=void 0;break}M||(M={}),M[vt.keyFormat]&&(M=ni({},M)),M[vt.keyFormat]=vt}else Y.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${tt}"`);break}case"START":d.startTimeOffset=s0(tt);break;case"MAP":{const vt=new ze(tt);if(Hi(d,vt,["BYTERANGE","URI"]),w.duration){const $t=new ql(s,e);o0($t,vt,i,M),p=$t,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else o0(w,vt,i,M),p=w,_=!0;break}case"SERVER-CONTROL":{const vt=new ze(tt);d.canBlockReload=vt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=vt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&vt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=vt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=vt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const vt=new ze(tt);d.partTarget=vt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let vt=d.partList;vt||(vt=d.partList=[]);const $t=v>0?vt[vt.length-1]:void 0,jt=v++,V=new ze(tt);Hi(d,V,["BYTERANGE","URI"]);const rt=new Fm(V,w,e,jt,$t);vt.push(rt),w.duration+=rt.duration;break}case"PRELOAD-HINT":{const vt=new ze(tt);Hi(d,vt,["URI"]),d.preloadHint=vt;break}case"RENDITION-REPORT":{const vt=new ze(tt);Hi(d,vt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(vt);break}default:Y.warn(`line parsed but not handled: ${R}`);break}}}E&&!E.relurl?(f.pop(),A-=E.duration,d.partList&&(d.fragmentHint=E)):d.partList&&(a0(w,E),w.cc=T,d.fragmentHint=w,M&&l0(w,M,d));const F=f.length,H=f[0],j=f[F-1];if(A+=d.skippedSegments*d.targetduration,A>0&&F&&j){d.averagetargetduration=A/F;const nt=j.sn;d.endSN=nt!=="initSegment"?nt:0,d.live||(j.endList=!0),H&&(d.startCC=H.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(A+=d.fragmentHint.duration),d.totalduration=A,d.endCC=T,G>0&&Tv(f,G),d}}function r0(n,t,e){var i,s;const o=new ze(n);Hi(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const c=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(s=o.KEYFORMAT)!=null?s:"identity";d&&o.IV&&!f&&Y.error(`Invalid IV: ${o.IV}`);const v=d?yr.resolve(d,t):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new ya(c,v,g,A,f)}function s0(n){const t=new ze(n).decimalFloatingPoint("TIME-OFFSET");return Kt(t)?t:null}function Ev(n,t){["video","audio","text"].forEach(e=>{const i=n.filter(s=>yv(s,e));if(i.length){const s=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],n=n.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=n}function n0(n,t,e){const i=t[e];i&&(n[e]=i)}function Tv(n,t){let e=n[t];for(let i=t;i--;){const s=n[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function a0(n,t){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):t!=null&&t.programDateTime&&(n.programDateTime=t.endProgramDateTime),Kt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function o0(n,t,e,i){n.relurl=t.URI,t.BYTERANGE&&n.setByteRange(t.BYTERANGE),n.level=e,n.sn="initSegment",i&&(n.levelkeys=i),n.initSegment=null}function l0(n,t,e){n.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(n)}var Ee={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Qt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function c0(n){const{type:t}=n;switch(t){case Ee.AUDIO_TRACK:return Qt.AUDIO;case Ee.SUBTITLE_TRACK:return Qt.SUBTITLE;default:return Qt.MAIN}}function nc(n,t){let e=n.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class kv{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.LEVEL_LOADING,this.onLevelLoading,this),t.on(L.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(L.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.LEVEL_LOADING,this.onLevelLoading,this),t.off(L.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(L.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,o=i||s,c=new o(e);return this.loaders[t.type]=c,c}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Ee.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:o,deliveryDirectives:c}=e;this.load({id:i,level:s,responseType:"text",type:Ee.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Ee.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Ee.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const p=s.context;if(p&&p.url===t.url){Y.trace("[playlist-loader]: playlist request ongoing");return}Y.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let o;if(t.type===Ee.MANIFEST?o=i.manifestLoadPolicy.default:o=ni({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Ee.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Ee.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Ee.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const A=Math.max(g*3,v*.8)*1e3;o=ni({},o,{maxTimeToFirstByteMs:Math.min(A,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(A,o.maxTimeToFirstByteMs)})}}}const c=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},f={onSuccess:(p,g,v,A)=>{const T=this.getInternalLoader(v);this.resetInternalLoader(v.type);const E=p.data;if(E.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),A||null,g);return}g.parsing.start=performance.now(),yr.isMediaPlaylist(E)?this.handleTrackOrLevelPlaylist(p,g,v,A||null,T):this.handleMasterPlaylist(p,g,v,A)},onError:(p,g,v,A)=>{this.handleNetworkError(g,v,!1,p,A)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};s.load(t,d,f)}handleMasterPlaylist(t,e,i,s){const o=this.hls,c=t.data,d=nc(t,i),f=yr.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,s,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:A,startTimeOffset:T,variableList:E}=f;this.variableList=E;const{AUDIO:w=[],SUBTITLES:R,"CLOSED-CAPTIONS":x}=yr.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(Y.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ze({}),bitrate:0,url:""})),o.trigger(L.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:R,captions:x,contentSteering:p,url:d,stats:e,networkDetails:s,sessionData:v,sessionKeys:A,startTimeOffset:T,variableList:E})}handleTrackOrLevelPlaylist(t,e,i,s,o){const c=this.hls,{id:d,level:f,type:p}=i,g=nc(t,i),v=Kt(d)?d:0,A=Kt(f)?f:v,T=c0(i),E=yr.parseLevelPlaylist(t.data,g,A,T,v,this.variableList);if(p===Ee.MANIFEST){const w={attrs:new ze({}),bitrate:0,details:E,name:"",url:g};c.trigger(L.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=E,this.handlePlaylistLoaded(E,t,e,i,s,o)}handleManifestParsingError(t,e,i,s,o){this.hls.trigger(L.ERROR,{type:qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Ee.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:o})}handleNetworkError(t,e,i=!1,s,o){let c=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===Ee.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Ee.AUDIO_TRACK||t.type===Ee.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);Y.warn(`[playlist-loader]: ${c}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Ee.MANIFEST:f=i?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Ee.LEVEL:f=i?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Ee.AUDIO_TRACK:f=i?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Ee.SUBTITLE_TRACK:f=i?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(s){const A=(e==null?void 0:e.url)||t.url;v.response=Bi({url:A,data:void 0},s)}this.hls.trigger(L.ERROR,v)}handlePlaylistLoaded(t,e,i,s,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:A}=s,T=nc(e,s),E=c0(s),w=typeof s.level=="number"&&E===Qt.MAIN?p:void 0;if(!t.fragments.length){const x=new Error("No Segments found in Playlist");d.trigger(L.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:T,error:x,reason:x.message,response:e,context:s,level:w,parent:E,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const R=t.playlistParsingError;if(R){d.trigger(L.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:T,error:R,reason:R.message,response:e,context:s,level:w,parent:E,networkDetails:o,stats:i});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Ee.MANIFEST:case Ee.LEVEL:d.trigger(L.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:A});break;case Ee.AUDIO_TRACK:d.trigger(L.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break;case Ee.SUBTITLE_TRACK:d.trigger(L.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break}}}function h0(n,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=n,t.dispatchEvent(e)}function d0(n,t){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(t.id))try{if(n.addCue(t),!n.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){Y.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,n.addCue(s)}catch(s){Y.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(n.mode=e)}function bn(n){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let e=n.cues.length;e--;)n.removeCue(n.cues[e]);t==="disabled"&&(n.mode=t)}function ac(n,t,e,i){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const o=Sv(n.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&n.removeCue(o[c])}s==="disabled"&&(n.mode=s)}function wv(n,t){if(t<n[0].startTime)return 0;const e=n.length-1;if(t>n[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const o=Math.floor((s+i)/2);if(t<n[o].startTime)s=o-1;else if(t>n[o].startTime&&i<e)i=o+1;else return o}return n[i].startTime-t<t-n[s].startTime?i:s}function Sv(n,t,e){const i=[],s=wv(n,t);if(s>-1)for(let o=s,c=n.length;o<c;o++){const d=n[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var br={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Lv=.25;function oc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Eo=(()=>{const n=oc();try{new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function lc(n,t){return n.getTime()/1e3-t}function Rv(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class _v{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(L.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(L.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(bn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return h0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=oc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===br.emsg&&!i||!s)continue;const p=Gu(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Eo&&(v=Eo),v-g<=0&&(v=g+Lv);for(let A=0;A<p.length;A++){const T=p[A];if(!Bu(T)){this.updateId3CueEnds(g,f);const E=new c(g,v,"");E.value=T,f&&(E.type=f),this.id3Track.addCue(E)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let o=s.length;o--;){const c=s[o];c.type===e&&c.startTime<t&&c.endTime===Eo&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;s==="audio"?p=g=>g.type===br.audioId3&&f:s==="video"?p=g=>g.type===br.emsg&&d:p=g=>g.type===br.audioId3&&f||g.type===br.emsg&&d,ac(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:o}=e,c=Object.keys(o);if(s){const g=Object.keys(i).filter(v=>!c.includes(v));for(let v=g.length;v--;){const A=g[v];Object.keys(i[A].cues).forEach(T=>{s.removeCue(i[A].cues[T])}),delete i[A]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Kt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=oc();for(let g=0;g<c.length;g++){const v=c[g],A=o[v],T=i[v],E=(T==null?void 0:T.cues)||{};let w=(T==null?void 0:T.durationKnown)||!1;const R=lc(A.startDate,f);let x=Eo;const M=A.endDate;if(M)x=lc(M,f),w=!0;else if(A.endOnNext&&!w){const _=c.reduce((F,H)=>{const j=o[H];return j.class===A.class&&j.id!==H&&j.startDate>A.startDate&&F.push(j),F},[]).sort((F,H)=>F.startDate.getTime()-H.startDate.getTime())[0];_&&(x=lc(_.startDate,f),w=!0)}const G=Object.keys(A.attr);for(let _=0;_<G.length;_++){const F=G[_];if(!Mm(F))continue;let H=E[F];if(H)w&&!T.durationKnown&&(H.endTime=x);else{let j=A.attr[F];H=new p(R,x,""),$m(F)&&(j=Rv(j)),H.value={key:F,data:j},H.type=br.dateRange,H.id=v,this.id3Track.addCue(H),E[F]=H}}i[v]={cues:E,dateRange:A,durationKnown:w}}}}class Cv{constructor(t){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=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:o,liveSyncDurationCount:c,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:c*s);const g=s,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const s=i.edge,o=t-e-this.edgeStalled,c=s-i.totalduration,d=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(c,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(L.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(L.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(L.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(L.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(L.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&Y.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:o}=this.config;if(!s||o===1)return;const c=this.targetLatency;if(c===null)return;const d=i-c,f=Math.min(this.maxLatency,c+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const cc=["NONE","TYPE-0","TYPE-1",null];var ba={No:"",Yes:"YES",v2:"v2"};function Iv(n,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=n,o=t!==void 0?t-s:0;return e&&o<e?i?ba.v2:ba.Yes:ba.No}class u0{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Aa{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function hc(n,t){const e=t.startPTS;if(Kt(e)){let i=0,s;t.sn>n.sn?(i=e-n.start,s=n):(i=n.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>n.sn?n.cc===t.cc&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration:t.start=Math.max(n.start-t.duration,0)}function f0(n,t,e,i,s,o){i-e<=0&&(Y.warn("Fragment should have a positive duration",t),i=e+t.duration,o=s+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Kt(f)){const w=Math.abs(f-e);Kt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),s=Math.min(s,t.startDTS),d=Math.min(i,p),i=Math.max(i,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=c,t.startDTS=s,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!n||v<n.startSN||v>n.endSN)return 0;let A;const T=v-n.startSN,E=n.fragments;for(E[T]=t,A=T;A>0;A--)hc(E[A],E[A-1]);for(A=T;A<E.length-1;A++)hc(E[A],E[A+1]);return n.fragmentHint&&hc(E[E.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,g}function Dv(n,t){let e=null;const i=n.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,o;if(Ov(n,t,(f,p)=>{f.relurl&&(s=f.cc-p.cc),Kt(f.startPTS)&&Kt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){Y.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=xv(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(s){Y.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),Pv(n.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?f0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):p0(n,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function xv(n,t,e){const i=ni({},n);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const o=new xu(t[s].attr,i[s]);o.isValid?i[s]=o:Y.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function Pv(n,t,e){if(n&&t){let i=0;for(let s=0,o=n.length;s<=o;s++){const c=n[s],d=t[s+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function Ov(n,t,e){const i=t.skippedSegments,s=Math.max(n.startSN,t.startSN)-t.startSN,o=(n.fragmentHint?1:0)+(i?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let p=s;p<=o;p++){const g=f[c+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function p0(n,t){const e=t.startSN+t.skippedSegments-n.startSN,i=n.fragments;e<0||e>=i.length||dc(t,i[e].start)}function dc(n,t){if(t){const e=n.fragments;for(let i=n.skippedSegments;i<e.length;i++)e[i].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function Mv(n,t=1/0){let e=1e3*n.targetduration;if(n.updated){const i=n.fragments,s=4;if(i.length&&e*s>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function $v(n,t,e){if(!(n!=null&&n.details))return null;const i=n.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t)?s:t<i.startSN&&e&&e.sn===t?e:null}function g0(n,t,e){var i;return n!=null&&n.details?m0((i=n.details)==null?void 0:i.partList,t,e):null}function m0(n,t,e){if(n)for(let i=n.length;i--;){const s=n[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function To(n){switch(n.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function v0(n,t){const e=To(t);return n.default[`${e?"timeout":"error"}Retry`]}function uc(n,t){const e=n.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function y0(n){return Bi(Bi({},n),{errorRetry:null,timeoutRetry:null})}function ko(n,t,e,i){return!!n&&t<n.maxNumRetry&&(Fv(i)||!!e)}function Fv(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const b0={search:function(n,t){let e=0,i=n.length-1,s=null,o=null;for(;e<=i;){s=(e+i)/2|0,o=n[s];const c=t(o);if(c>0)e=s+1;else if(c<0)i=s-1;else return o}return null}};function Nv(n,t,e){if(t===null||!Array.isArray(n)||!n.length||!Kt(t))return null;const i=n[0].programDateTime;if(t<(i||0))return null;const s=n[n.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let o=0;o<n.length;++o){const c=n[o];if(Uv(t,e,c))return c}return null}function Ea(n,t,e=0,i=0){let s=null;if(n?s=t[n.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&fc(e,i,s)===0)return s;const o=b0.search(t,fc.bind(null,e,i));return o&&(o!==n||!s)?o:s}function fc(n=0,t=0,e){if(e.start<=n&&e.start+e.duration>n)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=n?1:e.start-i>n&&e.start?-1:0}function Uv(n,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>n}function Bv(n,t){return b0.search(n,e=>e.cc<t?1:e.cc>t?-1:0)}const Gv=3e5;var Ti={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},lr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class Hv{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=Y.log.bind(Y,"[info]:"),this.warn=Y.warn.bind(Y,"[warning]:"),this.error=Y.error.bind(Y,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(L.ERROR,this.onError,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(L.ERROR,this.onError,this),t.off(L.ERROR,this.onErrorOut,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Qt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,s;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ti.DoNothing,flags:lr.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ti.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Qt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Ee.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Ee.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ti.SendAlternateToPenaltyBox,e.errorAction.flags=lr.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ti.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ti.DoNothing,flags:lr.None};return}if(e.type===qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,o=v0(s.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(ko(o,c,To(t),d))return{action:Ti.RetryRequest,flags:lr.None,retryConfig:o,retryCount:c};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=c),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=v0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,A)=>v+A.fragmentError,0);if(s){var p;t.details!==ut.FRAG_GAP&&s.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(ko(d,f,To(t),v))return{action:Ti.RetryRequest,flags:lr.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,i);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const s=this.hls.levels[e];if(s&&(s.loadError++,i.autoLevelEnabled)){var o,c;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,A=(o=t.frag)==null?void 0:o.type,{type:T,groupId:E}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const R=(w+p)%f.length;if(R!==p&&R>=g&&R<=v&&f[R].loadError===0){const x=f[R];if(t.details===ut.FRAG_GAP&&t.frag){const M=f[R].details;if(M){const G=Ea(t.frag,M.fragments,t.frag.start);if(G!=null&&G.gap)continue}}else if(T===Ee.AUDIO_TRACK&&E===x.audioGroupId||T===Ee.SUBTITLE_TRACK&&E===x.textGroupId||A===Qt.AUDIO&&s.audioGroupId===x.audioGroupId||A===Qt.SUBTITLE&&s.textGroupId===x.textGroupId)continue;d=R;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ti.SendAlternateToPenaltyBox,flags:lr.None,nextAutoLevel:d}}return{action:Ti.SendAlternateToPenaltyBox,flags:lr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ti.DoNothing:break;case Ti.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:o,nextAutoLevel:c}=i;switch(s){case lr.None:this.switchLevel(t,c);break;case lr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case lr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=cc[cc.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,c)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,s=t.parent===Qt.MAIN?t.level:e.loadLevel,o=e.levels[s],c=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<c;f++){const p=(d+f)%c,g=i[p];if(!g||Vv(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${c}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,s=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(e),s.details=t.details,i[t.urlId]=s}}function Vv(n,t,e){if(performance.now()-n.lastErrorPerfMs>Gv)return!0;const i=n.details;if(t.details===ut.FRAG_GAP&&i&&t.frag){const s=t.frag.start,o=Ea(null,i.fragments,s);if(o&&!o.gap)return!0}if(e&&n.errors.length<e.errors.length){const s=n.errors[n.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class pc{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Y.log.bind(Y,`${e}:`),this.warn=Y.warn.bind(Y,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let s=-1;for(let o=0;o<i.length;o++){const c=i[o];let d;try{d=new self.URL(c.URI,e.url).href}catch(f){Y.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){s=o;break}else d===t.substring(0,d.length)&&(s=o)}if(s!==-1){const o=i[s],c=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new u0(c,d>=0?d:void 0,ba.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:s,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(s.advancedDateTime=Date.now()-d,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${t} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&Dv(i,s),!this.canLoad||!s.live)return;let f,p,g;if(s.canBlockReload&&s.endSN&&s.advanced){const R=this.hls.config.lowLatencyMode,x=s.lastPartSn,M=s.endSN,G=s.lastPartIndex,_=G!==-1,F=x===M,H=R?0:G;_?(p=F?M+1:x,g=F?H:G+1):p=M+1;const j=s.age,nt=j+s.ageHeader;let ot=Math.min(nt-s.partTarget,s.targetduration*1.5);if(ot>0){if(i&&ot>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${ot} with playlist age: ${s.age}`),ot=0;else{const tt=Math.floor(ot/s.targetduration);if(p+=tt,g!==void 0){const kt=Math.round(ot%s.targetduration/s.partTarget);g+=kt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${j.toFixed(2)}s goal: ${ot} skip sn ${tt} to part ${g}`)}s.tuneInGoal=ot}if(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g),R||!F){this.loadPlaylist(f);return}}else(s.canBlockReload||s.canSkipUntil)&&(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,A=v?v.end-v.len:0,T=(s.edge-A)*1e3,E=Mv(s,T);s.updated&&c>this.requestScheduled+E&&(this.requestScheduled=o.loading.start),p!==void 0&&s.canBlockReload?this.requestScheduled=o.loading.first+E-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+E<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=E);let w=this.requestScheduled-c;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let o=Iv(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,o=ba.No),new u0(i,s,o)}checkRetry(t){const e=t.details,i=To(t),s=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=s||{},f=!!s&&!!d&&(o===Ti.RetryRequest||!s.resolved&&o===Ti.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,c>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=uc(d,c);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,s.resolved=!0}return f}}let gc;class Wv extends pc{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(L.LEVEL_LOADED,this.onLevelLoaded,this),t.on(L.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(L.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(L.FRAG_LOADED,this.onFragLoaded,this),t.on(L.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(L.LEVEL_LOADED,this.onLevelLoaded,this),t.off(L.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(L.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(L.FRAG_LOADED,this.onFragLoaded,this),t.off(L.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],s={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(gc||(gc=/chrome|firefox/i.test(navigator.userAgent)),gc&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":A,RESOLUTION:T,SUBTITLES:E}=f,w=`${`${A||"."}-`}${c.bitrate}-${T}-${v}-${g}`;o=s[w],o?o.addFallback(c):(o=new Aa(c),s[w]=o,i.push(o)),wo(o,"audio",p),wo(o,"text",E)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:T,videoCodec:E,width:w,height:R,unknownCodecs:x})=>(o||(o=!!(w&&R)),c||(c=!!E),d||(d=!!T),!(x!=null&&x.length)&&(!T||sc(T,"audio"))&&(!E||sc(E,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:T,width:E,height:w})=>!!T||!!(E&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const T=new Error("no level with compatible codecs found in manifest");this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:T,reason:T.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(T=>!T.audioCodec||sc(T.audioCodec,"audio")),A0(i)),e.subtitles&&(s=e.subtitles,A0(s));const p=f.slice(0);f.sort((T,E)=>T.attrs["HDCP-LEVEL"]!==E.attrs["HDCP-LEVEL"]?(T.attrs["HDCP-LEVEL"]||"")>(E.attrs["HDCP-LEVEL"]||"")?1:-1:T.bitrate!==E.bitrate?T.bitrate-E.bitrate:T.attrs["FRAME-RATE"]!==E.attrs["FRAME-RATE"]?T.attrs.decimalFloatingPoint("FRAME-RATE")-E.attrs.decimalFloatingPoint("FRAME-RATE"):T.attrs.SCORE!==E.attrs.SCORE?T.attrs.decimalFloatingPoint("SCORE")-E.attrs.decimalFloatingPoint("SCORE"):o&&T.height!==E.height?T.height-E.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let T=0;T<p.length;T++)if(p[T].pathwayId===f[0].pathwayId){g=p[T];break}}this._levels=f;for(let T=0;T<f.length;T++)if(f[T]===g){this._firstLevel=T,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!c,A={levels:f,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:c,altAudio:!v&&i.some(T=>!!T.url)};this.hls.trigger(L.MANIFEST_PARSED,A),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(L.ERROR,{type:qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&s&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ni({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(L.LEVEL_SWITCHING,f);const p=c.details;if(!p||p.live){const g=this.switchParams(c.uri,s==null?void 0:s.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===Ee.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Qt.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:o}=e,c=this._levels[s];if(!c){var d;this.warn(`Invalid level index ${s}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(s,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===s){o=c;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const c=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${c?" Pathway "+c:""} URI ${s+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(L.LEVEL_LOADING,{url:o,level:e,id:s,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(o,c)=>c!==e,s=this._levels.filter((o,c)=>c!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(i),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(i)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(i)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(L.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=s})}),this._levels=e}}function wo(n,t,e){e&&(t==="audio"?(n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds[n.url.length-1]=e):t==="text"&&(n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds[n.url.length-1]=e))}function A0(n){const t={};n.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var di={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Kv{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(L.BUFFER_APPENDED,this.onBufferAppended,this),t.on(L.FRAG_BUFFERED,this.onFragBuffered,this),t.on(L.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.BUFFER_APPENDED,this.onBufferAppended,this),t.off(L.FRAG_BUFFERED,this.onFragBuffered,this),t.off(L.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let s=i.length;s--;){const o=i[s];if(!o)break;const c=o.end;if(o.start<=t&&c!==null&&t<=c)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let o=s.length;o--;){const c=i[s[o]];if((c==null?void 0:c.body.type)===e&&c.buffered){const d=c.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const o=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===i&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const o=An(i),c=this.fragments[o];if(!c||c.buffered&&i.gap)return;const d=!i.relurl;Object.keys(e).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;c.range[f]=this.getBufferedTimes(i,s,v,g)}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,(c.body.endList=i.endList||c.body.endList)&&(this.endListFragments[c.body.type]=c),So(c)||this.removeParts(i.sn-1,i.type)):this.removeFragment(c.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(s=>s.fragment.sn>=t))}fragBuffered(t,e){const i=An(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<s.length;g++){const v=s.start(g)-this.bufferPadding,A=s.end(g)+this.bufferPadding;if(p>=v&&f<=A){o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});break}else if(c<A&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,s,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&So(g)&&(s=g.body.start-d,o=g.body.end+d,t>=s&&t<=o&&(i=Math.min(t-s,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||So(e))}getState(t){const e=An(t),i=this.fragments[e];return i?i.buffered?So(i)?di.PARTIAL:di.OK:di.APPENDING:di.NOT_LOADED}isTimeBuffered(t,e,i){let s,o;for(let c=0;c<i.length;c++){if(s=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=s&&e<=o)return!0;if(e<=s)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:s}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=s?null:e,c=An(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(s){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(s)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=An(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,o){s&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||s&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=An(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const s=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==s)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function So(n){var t,e,i;return n.buffered&&(n.body.gap||((t=n.range.video)==null?void 0:t.partial)||((e=n.range.audio)==null?void 0:e.partial)||((i=n.range.audiovideo)==null?void 0:i.partial))}function An(n){return`${n.type}_${n.level}_${n.urlId}_${n.sn}`}const E0=Math.pow(2,17);class jv{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(T=>T[0]==="GAP")){f(k0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(s):new c(s),g=T0(t),v=y0(s.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:E0};t.stats=p.stats,p.load(g,A,{onSuccess:(T,E,w,R)=>{this.resetLoader(t,p);let x=T.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(x.slice(0,16)),x=x.slice(16)),d({frag:t,part:null,payload:x,networkDetails:R})},onError:(T,E,w,R)=>{this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Bi({url:i,data:void 0},T),error:new Error(`HTTP Error ${T.code} ${T.text}`),networkDetails:w,stats:R}))},onAbort:(T,E,w)=>{this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:T}))},onTimeout:(T,E,w)=>{this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:T}))},onProgress:(T,E,w,R)=>{e&&e({frag:t,part:null,payload:w,networkDetails:R})}})})}loadPart(t,e,i){this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(k0(t,e));return}const p=this.loader=t.loader=o?new o(s):new c(s),g=T0(t,e),v=y0(s.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:E0};e.stats=p.stats,p.load(g,A,{onSuccess:(T,E,w,R)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const x={frag:t,part:e,payload:T.data,networkDetails:R};i(x),d(x)},onError:(T,E,w,R)=>{this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Bi({url:g.url,data:void 0},T),error:new Error(`HTTP Error ${T.code} ${T.text}`),networkDetails:w,stats:R}))},onAbort:(T,E,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:T}))},onTimeout:(T,E,w)=>{this.resetLoader(t,p),f(new qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:T}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,o=s.total;if(i.loaded+=s.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(i.loaded/o),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const c=i.loading,d=s.loading;c.start?c.first+=d.first-d.start:(c.start=d.start,c.first=d.first),c.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function T0(n,t=null){const e=t||n,i={frag:n,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Kt(s)&&Kt(o)){var c;let d=s,f=o;if(n.sn==="initSegment"&&((c=n.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-s;p%16&&(f=o+(16-p%16)),s!==0&&(i.resetIV=!0,d=s-16)}i.rangeStart=d,i.rangeEnd=f}return i}function k0(n,t){const e=new Error(`GAP ${n.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return t&&(i.part=t),(t||n).stats.aborted=!0,new qr(i)}class qr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class zv{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,i,s,o){return new qr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let o=0;o<e.length;o++){const c=e[o];if(s<=c.cc&&(i==="initSegment"||c.sn==="initSegment"||i<c.sn)){this.emeController.selectKeySystemFormat(c).then(d=>{c.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));let d=this.keyUriToKeyInfo[c];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[c]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(t.keyLoadPromise=s.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,o=new s(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((c,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=i.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(A,T,E,w)=>{const{frag:R,keyInfo:x,url:M}=E;if(!R.decryptdata||x!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(R,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));x.decryptdata.key=R.decryptdata.key=new Uint8Array(A.data),R.keyLoader=null,x.loader=null,c({frag:R,keyInfo:x})},onError:(A,T,E,w)=>{this.resetLoader(T),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),E,Bi({url:f.url,data:void 0},A)))},onTimeout:(A,T,E)=>{this.resetLoader(T),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),E))},onAbort:(A,T,E)=>{this.resetLoader(T),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),E))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()}}class Yv{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(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Zv={length:0,start:()=>0,end:()=>0};class Me{static isBuffered(t,e){try{if(t){const i=Me.getBuffered(t);for(let s=0;s<i.length;s++)if(e>=i.start(s)&&e<=i.end(s))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const s=Me.getBuffered(t),o=[];let c;for(c=0;c<s.length;c++)o.push({start:s.start(c),end:s.end(c)});return this.bufferedInfo(o,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let s=[];if(i)for(let p=0;p<t.length;p++){const g=s.length;if(g){const v=s[g-1].end;t[p].start-v<i?t[p].end>v&&(s[g-1].end=t[p].end):s.push(t[p])}else s.push(t[p])}else s=t;let o=0,c,d=e,f=e;for(let p=0;p<s.length;p++){const g=s[p].start,v=s[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){c=g;break}}return{len:o,start:d||0,end:f||0,nextStart:c}}static getBuffered(t){try{return t.buffered}catch(e){return Y.log("failed to get media.buffered",e),Zv}}}class mc{constructor(t,e,i,s=0,o=-1,c=!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=Lo(),this.buffering={audio:Lo(),video:Lo(),audiovideo:Lo()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=o,this.partial=c}}function Lo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function w0(n,t){let e=null;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o&&o.cc===t){e=o;break}}return e}function Xv(n,t,e){return!!(t.details&&(e.endCC>e.startCC||n&&n.cc<e.startCC))}function qv(n,t,e=0){const i=n.fragments,s=t.fragments;if(!s.length||!i.length){Y.log("No fragments to align");return}const o=w0(i,s[0].cc);if(!o||o&&!o.startPTS){Y.log("No frag in previous level to align on");return}return o}function S0(n,t){if(n){const e=n.start+t;n.start=n.startPTS=e,n.endPTS=e+n.duration}}function vc(n,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)S0(e[i],n);t.fragmentHint&&S0(t.fragmentHint,n),t.alignedSliding=!0}function Qv(n,t,e){t&&(Jv(n,e,t),!e.alignedSliding&&t.details&&ty(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&p0(t.details,e))}function Jv(n,t,e){if(Xv(n,e,t)){const i=qv(e.details,t);i&&Kt(i.start)&&(Y.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),vc(i.start,t))}}function ty(n,t){if(!t.fragments.length||!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=n.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&Kt(s)&&(Y.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${n.url} `),vc(s,n))}function L0(n,t){if(!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=n.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,o=i[s],c=w0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=c.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(c.start-o.start);vc(p,n)}class ey{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class iy{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function ry(n){const t=n.byteLength,e=t&&new DataView(n.buffer).getUint8(t-1);return e?tn(n,0,t-e):n}class sy{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_(t){const e=new DataView(t),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=e.getUint32(s*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],o=i[1],c=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],A=f[3],T=new Uint32Array(256);let E=0,w=0,R=0;for(R=0;R<256;R++)R<128?T[R]=R<<1:T[R]=R<<1^283;for(R=0;R<256;R++){let x=w^w<<1^w<<2^w<<3^w<<4;x=x>>>8^x&255^99,t[E]=x,e[x]=E;const M=T[E],G=T[M],_=T[G];let F=T[x]*257^x*16843008;s[E]=F<<24|F>>>8,o[E]=F<<16|F>>>16,c[E]=F<<8|F>>>24,d[E]=F,F=_*16843009^G*65537^M*257^E*16843008,p[x]=F<<24|F>>>8,g[x]=F<<16|F>>>16,v[x]=F<<8|F>>>24,A[x]=F,E?(E=M^T[T[T[_^M]]],w^=T[T[w]]):E=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s<e.length&&i;)i=e[s]===this.key[s],s++;if(i)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const c=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(c),g=this.invKeySchedule=new Uint32Array(c),v=this.sBox,A=this.rcon,T=this.invSubMix,E=T[0],w=T[1],R=T[2],x=T[3];let M,G;for(d=0;d<c;d++){if(d<o){M=p[d]=e[d];continue}G=M,d%o===0?(G=G<<8|G>>>24,G=v[G>>>24]<<24|v[G>>>16&255]<<16|v[G>>>8&255]<<8|v[G&255],G^=A[d/o|0]<<24):o>6&&d%o===4&&(G=v[G>>>24]<<24|v[G>>>16&255]<<16|v[G>>>8&255]<<8|v[G&255]),p[d]=M=(p[d-o]^G)>>>0}for(f=0;f<c;f++)d=c-f,f&3?G=p[d]:G=p[d-4],f<4||d<=4?g[f]=G:g[f]=E[v[G>>>24]]^w[v[G>>>16&255]]^R[v[G>>>8&255]]^x[v[G&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,o=this.invKeySchedule,c=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],A=this.uint8ArrayToUint32Array_(i);let T=A[0],E=A[1],w=A[2],R=A[3];const x=new Int32Array(t),M=new Int32Array(x.length);let G,_,F,H,j,nt,ot,tt,kt,vt,$t,jt,V,rt;const Lt=this.networkToHostOrderSwap;for(;e<x.length;){for(kt=Lt(x[e]),vt=Lt(x[e+1]),$t=Lt(x[e+2]),jt=Lt(x[e+3]),j=kt^o[0],nt=jt^o[1],ot=$t^o[2],tt=vt^o[3],V=4,rt=1;rt<s;rt++)G=f[j>>>24]^p[nt>>16&255]^g[ot>>8&255]^v[tt&255]^o[V],_=f[nt>>>24]^p[ot>>16&255]^g[tt>>8&255]^v[j&255]^o[V+1],F=f[ot>>>24]^p[tt>>16&255]^g[j>>8&255]^v[nt&255]^o[V+2],H=f[tt>>>24]^p[j>>16&255]^g[nt>>8&255]^v[ot&255]^o[V+3],j=G,nt=_,ot=F,tt=H,V=V+4;G=c[j>>>24]<<24^c[nt>>16&255]<<16^c[ot>>8&255]<<8^c[tt&255]^o[V],_=c[nt>>>24]<<24^c[ot>>16&255]<<16^c[tt>>8&255]<<8^c[j&255]^o[V+1],F=c[ot>>>24]<<24^c[tt>>16&255]<<16^c[j>>8&255]<<8^c[nt&255]^o[V+2],H=c[tt>>>24]<<24^c[j>>16&255]<<16^c[nt>>8&255]<<8^c[ot&255]^o[V+3],M[e]=Lt(G^T),M[e+1]=Lt(H^E),M[e+2]=Lt(F^w),M[e+3]=Lt(_^R),T=kt,E=vt,w=$t,R=jt,e=e+4}return M.buffer}}const ny=16;class yc{constructor(t,{removePKCS7Padding:e=!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=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}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:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?ry(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((s,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?s(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=en(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;s&&(i=s);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new sy),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=tn(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new iy(s,e)),this.fastAesKey.expandKey().then(o=>s?(this.logOnce("WebCrypto AES decrypt"),new ey(s,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(Y.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%ny;return i!==t.length&&(e=tn(t,0,i),this.remainderData=tn(t,i)),e}logOnce(t){this.logEnabled&&(Y.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const ay={toString:function(n){let t="";const e=n.length;for(let i=0;i<e;i++)t+=`[${n.start(i).toFixed(3)}-${n.end(i).toFixed(3)}]`;return t}},Tt={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class bc extends Yv{constructor(t,e,i,s,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Tt.STOPPED,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=o,this.logPrefix=s,this.log=Y.log.bind(Y,`${s}:`),this.warn=Y.warn.bind(Y,`${s}:`),this.hls=t,this.fragmentLoader=new jv(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new yc(t.config),t.on(L.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Tt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const o=i[i.length-1];return Me.isBuffered(this.media,o.start+o.duration/2)}const s=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Tt.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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:t,fragCurrent:e,media:i,mediaBuffer:s,state:o}=this,c=i?i.currentTime:0,d=Me.bufferInfo(s||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Kt(c)?c.toFixed(3):c}, state: ${o}`),this.state===Tt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=c>g;(c<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=c),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Tt.STOPPED,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(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const s=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,i,s).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===Tt.FRAG_LOADING||!this.fragCurrent&&c===Tt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Tt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(L.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===di.APPENDING){const s=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,s),c=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===di.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(L.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:o}=i,c=t.decryptdata;if(o&&o.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),c.key.buffer,c.iv.buffer).catch(f=>{throw s.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return s.trigger(L.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:s,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Tt.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),i.frag===s&&o.trigger(L.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,s,o,c;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Qt.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${d?ay.toString(Me.getBuffered(d)):"(detached)"})`),this.state=Tt.IDLE,d&&(!this.loadedmetadata&&t.type==Qt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new mc(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var o;const c=e==null?void 0:e.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Tt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(L.KEY_LOADED,g),this.state===Tt.KEY_LOADING&&(this.state=Tt.IDLE),g}),this.hls.trigger(L.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(t,c.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=c.partList;if(g&&s){i>t.end&&c.fragmentHint&&(t=c.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const A=g[v];this.log(`Loading part sn: ${t.sn} p: ${A.index} cc: ${t.cc} of playlist [${c.startSN}-${c.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=A.start+A.duration,this.state=Tt.FRAG_LOADING;let T;return d?T=d.then(E=>!E||this.fragContextChanged(E.frag)?null:this.doFragPartsLoad(t,A,e,s)).catch(E=>this.handleFragLoadError(E)):T=this.doFragPartsLoad(t,A,e,s).catch(E=>this.handleFragLoadError(E)),this.hls.trigger(L.FRAG_LOADING,{frag:t,part:A,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):T}else if(!t.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${c?"of ["+c.startSN+"-"+c.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Kt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Tt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,s)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?s:void 0),d]).then(([g])=>(!f&&g&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(L.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,i,s){return new Promise((o,c)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,s).then(A=>{f[v.index]=A;const T=A.part;this.hls.trigger(L.FRAG_LOADED,A);const E=g0(i,t.sn,v.index+1)||m0(p,t.sn,v.index+1);if(E)g(E);else return o({frag:t,part:T,partsLoaded:f})}).catch(c)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(L.ERROR,e)}else this.hls.trigger(L.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Tt.PARSING){!this.fragCurrent&&this.state!==Tt.STOPPED&&this.state!==Tt.ERROR&&(this.state=Tt.IDLE);return}const{frag:i,part:s,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,s&&(s.stats.parsing.end=c),this.updateLevelTiming(i,s,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:o,part:c}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${s}. The current chunk will not be buffered.`),null;const d=e[s],f=c>-1?g0(d,o,c):null,p=f?f.fragment:$v(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,s,o){var c;if(!t||this.state!==Tt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=en(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:p};if(this.hls.trigger(L.BUFFER_APPENDING,g),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Me.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=Me.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,s.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Kt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,o=Me.bufferInfo(t,e,s);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return Me.bufferInfo(t,e,Math.max(o.nextStart,s))}return o}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Qt.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Qt.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,i),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=c&&(d=i[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===di.OK||i===di.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,o){const c=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,c&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let s=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,s>-1&&i<p.start)break;const g=p.loaded;g?s=-1:(o||p.independent||c)&&p.fragment===e&&(s=d),o=g}return s}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let s=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=Nv(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(s=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Bv(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(s=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=s.maxFragLookUpTolerance,g=i.partList,v=!!(s.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let A;if(t<e){const T=t>e-p?0:p;A=Ea(o,c,t,T)}else A=c[c.length-1];if(A){const T=A.sn-i.startSN,E=this.fragmentTracker.getState(A);if((E===di.OK||E===di.PARTIAL&&A.gap)&&(o=A),o&&A.sn===o.sn&&(!v||g[0].fragment.sn>A.sn)&&o&&A.level===o.level){const w=c[T+1];A.sn<d&&this.fragmentTracker.getState(w)!==di.OK?A=w:A=null}}return A}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(s!==null&&i.duration>s&&(o<s||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:o}=this,c=s!==null?i[s]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&Kt(f);if(p||!g&&!f){Qv(o,c,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,o=s?this.startTimeOffset:t.startTimeOffset;o!==null&&Kt(o)?(i=e+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${o} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Tt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Tt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ti.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=uc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),c.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Tt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):Y.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ti.SendAlternateToPenaltyBox?this.state=Tt.WAITING_LEVEL:this.state=Tt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Tt.PARSING||this.state===Tt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const o=!s;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Qt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=Me.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===Tt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Tt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){var o;const c=i.details;if(!c){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=s?0:f0(c,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(L.LEVEL_PTS_UPDATED,{details:c,level:i,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Tt.PARSED,this.hls.trigger(L.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(s=this.fragCurrent)==null?void 0:s.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function R0(){return self.SourceBuffer||self.WebKitSourceBuffer}function oy(){const n=Ao();if(!n)return!1;const t=R0(),e=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function ly(){var n;const t=R0();return typeof(t==null||(n=t.prototype)==null?void 0:n.changeType)=="function"}function cy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function hy(){const n=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(n);return{worker:new self.Worker(t),objectURL:t}}function dy(n){const t=new self.URL(n,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Or(n="",t=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class _0{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(t,e,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=en(this.cachedData,t),this.cachedData=null);let i=mo(t,0),s=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?zm(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Kt(f))&&(this.basePTS=uy(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:br.audioId3,duration:Number.POSITIVE_INFINITY});s<p;){if(this.canParse(t,s)){const g=this.appendFrame(c,t,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,o=s):s=p}else jm(t,s)?(i=mo(t,s),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:br.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,o=s):s++;if(s===p&&o!==p){const g=tn(t,o);this.cachedData?this.cachedData=en(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:Or(),id3Track:d,textTrack:Or()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Or(),id3Track:this._id3Track,textTrack:Or()}}destroy(){}}const uy=(n,t,e)=>{if(Kt(n))return n*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function fy(n,t,e,i){let s,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){n.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return c=(t[e+2]&1)<<2,c|=(t[e+3]&192)>>>6,Y.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(s=5,d=new Array(4),o=v-3):(s=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(s=2,d=new Array(2),o=v):(s=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?o=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(f))||!i&&c===1)&&(s=2,d=new Array(2)),o=v)),d[0]=s<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,s===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:c,codec:"mp4a.40."+s,manifestCodec:p}}function C0(n,t){return n[t]===255&&(n[t+1]&246)===240}function I0(n,t){return n[t+1]&1?7:9}function Ac(n,t){return(n[t+3]&3)<<11|n[t+4]<<3|(n[t+5]&224)>>>5}function py(n,t){return t+5<n.length}function Ro(n,t){return t+1<n.length&&C0(n,t)}function gy(n,t){return py(n,t)&&C0(n,t)&&Ac(n,t)<=n.length-t}function my(n,t){if(Ro(n,t)){const e=I0(n,t);if(t+e>=n.length)return!1;const i=Ac(n,t);if(i<=e)return!1;const s=t+i;return s===n.length||Ro(n,s)}return!1}function D0(n,t,e,i,s){if(!n.samplerate){const o=fy(t,e,i,s);if(!o)return;n.config=o.config,n.samplerate=o.samplerate,n.channelCount=o.channelCount,n.codec=o.codec,n.manifestCodec=o.manifestCodec,Y.log(`parsed codec:${n.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function x0(n){return 9216e4/n}function vy(n,t){const e=I0(n,t);if(t+e<=n.length){const i=Ac(n,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function P0(n,t,e,i,s){const o=x0(n.samplerate),c=i+s*o,d=vy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,A=v+g,T=Math.max(0,e+A-t.length);T?(f=new Uint8Array(A-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+A);const E={unit:f,pts:c};return T||n.samples.push(E),{sample:E,length:A,missing:T}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:c},length:p,missing:-1}}class yy extends _0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(mo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(my(t,e))return Y.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return gy(t,e)}appendFrame(t,e,i){D0(t,this.observer,e,i,t.manifestCodec);const s=P0(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const by=/\/emsg[-/]ID3/i;class Ay{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const o=this.videoTrack=Or("video",1),c=this.audioTrack=Or("audio",1),d=this.txtTrack=Or("text",1);if(this.id3Track=Or("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=Ku(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;c.id=p,c.timescale=g,c.codec=v}d.id=Hu.text,o.sampleDuration=0,o.duration=c.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,be(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=en(this.remainderData,t));const d=lv(i);this.remainderData=d.remainder,s.samples=d.valid||new Uint8Array}else s.samples=i;const c=this.extractID3Track(s,e);return o.samples=zu(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=zu(t,e),{videoTrack:e,audioTrack:Or(),id3Track:s,textTrack:Or()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=be(t.samples,["emsg"]);s&&s.forEach(o=>{const c=dv(o);if(by.test(c.schemeIdUri)){const d=Kt(c.presentationTime)?c.presentationTime/c.timeScale:e+c.presentationTimeDelta/c.timeScale;let f=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=c.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:br.emsg,duration:f})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let _o=null;const Ey=[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],Ty=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],ky=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],wy=[0,1,1,4];function O0(n,t,e,i,s){if(e+24>t.length)return;const o=M0(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+s*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return n.config=[],n.channelCount=o.channelCount,n.samplerate=o.sampleRate,n.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function M0(n,t){const e=n[t+1]>>3&3,i=n[t+1]>>1&3,s=n[t+2]>>4&15,o=n[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&o!==3){const c=n[t+2]>>1&1,d=n[t+3]>>6,f=e===3?3-i:i===3?3:4,p=Ey[f*14+s-1]*1e3,g=Ty[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,A=ky[e][i],T=wy[i],E=A*8*T,w=Math.floor(A*p/g+c)*T;if(_o===null){const R=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);_o=R?parseInt(R[1]):0}return _o&&_o<=87&&i===2&&p>=224e3&&d===0&&(n[t+3]=n[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:E}}}function Ec(n,t){return n[t]===255&&(n[t+1]&224)===224&&(n[t+1]&6)!==0}function $0(n,t){return t+1<n.length&&Ec(n,t)}function Sy(n,t){return Ec(n,t)&&4<=n.length-t}function Ly(n,t){if(t+1<n.length&&Ec(n,t)){const e=M0(n,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===n.length||$0(n,s)}return!1}class F0{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");s.set(t.subarray(i,i+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&Y.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,s;for(let o=0;o<t;o++)i!==0&&(s=this.readEG(),i=(e+s+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,s=0,o,c,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),A=this.skipBits.bind(this),T=this.skipEG.bind(this),E=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const R=f();if(p(5),A(3),f(),E(),R===100||R===110||R===122||R===244||R===44||R===83||R===86||R===118||R===128){const H=g();if(H===3&&A(1),E(),E(),A(1),v())for(c=H!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}E();const x=g();if(x===0)g();else if(x===1)for(A(1),T(),T(),o=g(),d=0;d<o;d++)T();E(),A(1);const M=g(),G=g(),_=p(1);_===0&&A(1),A(1),v()&&(t=g(),e=g(),i=g(),s=g());let F=[1,1];if(v()&&v())switch(f()){case 1:F=[1,1];break;case 2:F=[12,11];break;case 3:F=[10,11];break;case 4:F=[16,11];break;case 5:F=[40,33];break;case 6:F=[24,11];break;case 7:F=[20,11];break;case 8:F=[32,11];break;case 9:F=[80,33];break;case 10:F=[18,11];break;case 11:F=[15,11];break;case 12:F=[64,33];break;case 13:F=[160,99];break;case 14:F=[4,3];break;case 15:F=[3,2];break;case 16:F=[2,1];break;case 255:{F=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-_)*(G+1)*16-(_?2:4)*(i+s),pixelRatio:F}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Ry{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new yc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const o=s.subarray(16,s.length-s.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);s.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)i.set(t.subarray(o,o+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)t.set(i.subarray(s,s+16),o);return t}decryptAvcSample(t,e,i,s,o){const c=Zu(o.data),d=this.getAvcEncryptedData(c);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(c,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)})}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){s();return}const o=t[e].units;for(;!(i>=o.length);i++){const c=o[i];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,e,i,s,c),!this.decrypter.isSync()))return}}}}const ki=188;class ms{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=ms.syncOffset(t);return e>0&&Y.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(ki*5,t.length-ki)+1,s=0;for(;s<i;){let o=!1,c=-1,d=0;for(let f=s;f<e;f+=ki)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+ki*99,t.length-ki)+1)),o||(o=Tc(t,f)===0),o&&d>1&&(c===0&&d>2||f+ki>i))return c}else{if(d)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Hu[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=ms.createTrack("video"),this._audioTrack=ms.createTrack("audio",s),this._id3Track=ms.createTrack("id3"),this._txtTrack=ms.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,s=!1){i||(this.sampleAes=null);let o;const c=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=c.pid,v=c.pesData,A=d.pid,T=f.pid,E=d.pesData,w=f.pesData,R=null,x=this.pmtParsed,M=this._pmtId,G=t.length;if(this.remainderData&&(t=en(this.remainderData,t),G=t.length,this.remainderData=null),G<ki&&!s)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const _=Math.max(0,ms.syncOffset(t));G-=(G-_)%ki,G<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,G,t.buffer.byteLength-G));let F=0;for(let j=_;j<G;j+=ki)if(t[j]===71){const nt=!!(t[j+1]&64),ot=Tc(t,j),tt=(t[j+3]&48)>>4;let kt;if(tt>1){if(kt=j+5+t[j+4],kt===j+ki)continue}else kt=j+4;switch(ot){case g:nt&&(v&&(o=En(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,j+ki)),v.size+=j+ki-kt);break;case A:if(nt){if(E&&(o=En(E)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}E={data:[],size:0}}E&&(E.data.push(t.subarray(kt,j+ki)),E.size+=j+ki-kt);break;case T:nt&&(w&&(o=En(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,j+ki)),w.size+=j+ki-kt);break;case 0:nt&&(kt+=t[kt]+1),M=this._pmtId=_y(t,kt);break;case M:{nt&&(kt+=t[kt]+1);const vt=Cy(t,kt,this.typeSupported,i);g=vt.avc,g>0&&(c.pid=g),A=vt.audio,A>0&&(d.pid=A,d.segmentCodec=vt.segmentCodec),T=vt.id3,T>0&&(f.pid=T),R!==null&&!x&&(Y.warn(`MPEG-TS PMT found at ${j} after unknown PID '${R}'. Backtracking to sync byte @${_} to parse all TS packets.`),R=null,j=_-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:R=ot;break}}else F++;if(F>0){const j=new Error(`Found ${F} TS packet/s that do not start with 0x47`);this.observer.emit(L.ERROR,L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:j,reason:j.message})}c.pesData=v,d.pesData=E,f.pesData=w;const H={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return s&&this.extractRemainingSamples(H),H}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:o}=t,c=i.pesData,d=e.pesData,f=s.pesData;let p;if(c&&(p=En(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=En(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&Y.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=En(f))?(this.parseID3PES(s,p),s.pesData=null):s.pesData=f}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new Ry(this.observer,this.config,e);return this.decrypt(s,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:o}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{i(t)}):i(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(Ta(c,t),c=this.avcSample=Co(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let A=!1;d=!0;const T=p.data;if(f&&T.length>4){const E=new F0(T).readSliceType();(E===2||E===4||E===7||E===9)&&(A=!0)}if(A){var v;(v=c)!=null&&v.frame&&!c.key&&(Ta(c,t),c=this.avcSample=null)}c||(c=this.avcSample=Co(!0,i.pts,i.dts,"")),c.frame=!0,c.key=A;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(Ta(c,t),c=this.avcSample=null),c||(c=this.avcSample=Co(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,Yu(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const A=p.data,T=new F0(A).readSPS();t.width=T.width,t.height=T.height,t.pixelRatio=T.pixelRatio,t.sps=[A],t.duration=this._duration;const E=A.subarray(1,4);let w="avc1.";for(let R=0;R<3;R++){let x=E[R].toString(16);x.length<2&&(x="0"+x),w+=x}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,c&&Ta(c,t),c=this.avcSample=Co(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,c&&(c.debug+="unknown NAL "+p.type+" ");break}c&&d&&c.units.push(p)}),s&&c&&(Ta(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;s=o[o.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const o=s,c=[];let d=0,f,p,g,v=-1,A=0;for(s===-1&&(v=0,A=e[0]&31,s=0,d=1);d<i;){if(f=e[d++],!s){s=f?0:1;continue}if(s===1){s=f?0:2;continue}if(!f)s=3;else if(f===1){if(v>=0){const T={data:e.subarray(v,d-s-1),type:A};c.push(T)}else{const T=this.getLastNalUnit(t.samples);if(T&&(o&&d<=4-o&&T.state&&(T.data=T.data.subarray(0,T.data.byteLength-o)),p=d-s-1,p>0)){const E=new Uint8Array(T.data.byteLength+p);E.set(T.data,0),E.set(e.subarray(0,p),T.data.byteLength),T.data=E,T.state=0}}d<i?(g=e[d]&31,v=d,A=g,s=0):s=-1}else s=0}if(v>=0&&s>=0){const T={data:e.subarray(v,i),type:A,state:s};c.push(T)}if(c.length===0){const T=this.getLastNalUnit(t.samples);if(T){const E=new Uint8Array(T.data.byteLength+e.byteLength);E.set(T.data,0),E.set(e,T.data.byteLength),T.data=E}}return t.naluState=s,c}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let o=e.data;if(s){this.aacOverFlow=null;const v=s.missing,A=s.sample.unit.byteLength;if(v===-1){const T=new Uint8Array(A+o.byteLength);T.set(s.sample.unit,0),T.set(o,A),o=T}else{const T=A-v;s.sample.unit.set(o.subarray(0,v),T),t.samples.push(s.sample),i=s.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Ro(o,c);c++);if(c!==i){let v;const A=c<d-1;A?v=`AAC PES did not start with ADTS header,offset:${c}`:v="No ADTS header found in AAC PES";const T=new Error(v);if(Y.warn(`parsing error: ${v}`),this.observer.emit(L.ERROR,L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:T,reason:v}),!A)return}D0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(s){const v=x0(t.samplerate);f=s.sample.pts+v}else{Y.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=P0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Ro(o,c);c++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){Y.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<s;)if($0(i,c)){const f=O0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){Y.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ni({},e,{type:this._avcTrack?br.emsg:br.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Co(n,t,e,i){return{key:n,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Tc(n,t){return((n[t+1]&31)<<8)+n[t+2]}function _y(n,t){return(n[t+10]&31)<<8|n[t+11]}function Cy(n,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(n[t+1]&15)<<8|n[t+2],c=t+3+o-4,d=(n[t+10]&15)<<8|n[t+11];for(t+=12+d;t<c;){const f=Tc(n,t);switch(n[t]){case 207:if(!i){Y.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=f);break;case 21:s.id3===-1&&(s.id3=f);break;case 219:if(!i){Y.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?Y.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=f,s.segmentCodec="mp3");break;case 36:Y.warn("Unsupported HEVC stream type found");break}t+=((n[t+3]&15)<<8|n[t+4])+5}return s}function En(n){let t=0,e,i,s,o,c;const d=n.data;if(!n||n.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>n.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(c=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-c>54e5&&(Y.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),s=e[8];let p=s+9;if(n.size<=p)return null;n.size-=p;const g=new Uint8Array(n.size);for(let v=0,A=d.length;v<A;v++){e=d[v];let T=e.byteLength;if(p)if(p>T){p-=T;continue}else e=e.subarray(p),T-=p,p=0;g.set(e,t),t+=T}return i&&(i-=s+3),{data:g,pts:o,dts:c,len:i}}return null}function Ta(n,t){if(n.units.length&&n.frame){if(n.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];n.pts=s.pts,n.dts=s.dts}else{t.dropped++;return}}t.samples.push(n)}n.debug.length&&Y.log(n.pts+"/"+n.dts+":"+n.debug)}class Iy extends _0{resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(mo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Ly(t,e))return Y.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Sy(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return O0(t,e,i,this.basePTS,this.frameIndex)}}class N0{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const vs=Math.pow(2,32)-1;class it{static init(){it.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in it.types)it.types.hasOwnProperty(t)&&(it.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=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]),i=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]);it.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);it.STTS=it.STSC=it.STCO=o,it.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),it.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),it.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),it.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);it.FTYP=it.box(it.types.ftyp,c,f,c,d),it.DINF=it.box(it.types.dinf,it.box(it.types.dref,s))}static box(t,...e){let i=8,s=e.length;const o=s;for(;s--;)i+=e[s].byteLength;const c=new Uint8Array(i);for(c[0]=i>>24&255,c[1]=i>>16&255,c[2]=i>>8&255,c[3]=i&255,c.set(t,4),s=0,i=8;s<o;s++)c.set(e[s],i),i+=e[s].byteLength;return c}static hdlr(t){return it.box(it.types.hdlr,it.HDLR_TYPES[t])}static mdat(t){return it.box(it.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(vs+1)),s=Math.floor(e%(vs+1));return it.box(it.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(t){return it.box(it.types.mdia,it.mdhd(t.timescale,t.duration),it.hdlr(t.type),it.minf(t))}static mfhd(t){return it.box(it.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?it.box(it.types.minf,it.box(it.types.smhd,it.SMHD),it.DINF,it.stbl(t)):it.box(it.types.minf,it.box(it.types.vmhd,it.VMHD),it.DINF,it.stbl(t))}static moof(t,e,i){return it.box(it.types.moof,it.mfhd(t),it.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=it.trak(t[e]);return it.box.apply(null,[it.types.moov,it.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(it.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=it.trex(t[e]);return it.box.apply(null,[it.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(vs+1)),s=Math.floor(e%(vs+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return it.box(it.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,o;for(s=0;s<e.length;s++)o=e[s].flags,i[s+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return it.box(it.types.sdtp,i)}static stbl(t){return it.box(it.types.stbl,it.stsd(t),it.box(it.types.stts,it.STTS),it.box(it.types.stsc,it.STSC),it.box(it.types.stsz,it.STSZ),it.box(it.types.stco,it.STCO))}static avc1(t){let e=[],i=[],s,o,c;for(s=0;s<t.sps.length;s++)o=t.sps[s],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(s=0;s<t.pps.length;s++)o=t.pps[s],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=it.box(it.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return it.box(it.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,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,it.box(it.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),it.box(it.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return it.box(it.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),it.box(it.types.esds,it.esds(t)))}static mp3(t){const e=t.samplerate;return it.box(it.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?it.box(it.types.stsd,it.STSD,it.mp3(t)):it.box(it.types.stsd,it.STSD,it.mp4a(t)):it.box(it.types.stsd,it.STSD,it.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,o=t.height,c=Math.floor(i/(vs+1)),d=Math.floor(i%(vs+1));return it.box(it.types.tkhd,new Uint8Array([1,0,0,7,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,e&255,0,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=it.sdtp(t),s=t.id,o=Math.floor(e/(vs+1)),c=Math.floor(e%(vs+1));return it.box(it.types.traf,it.box(it.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),it.box(it.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,c>>24,c>>16&255,c>>8&255,c&255])),it.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,it.box(it.types.trak,it.tkhd(t),it.mdia(t))}static trex(t){const e=t.id;return it.box(it.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,o=12+16*s,c=new Uint8Array(o);let d,f,p,g,v,A;for(e+=8+o,c.set([t.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<s;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,A=f.cts,c.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*d);return it.box(it.types.trun,c)}static initSegment(t){it.types||it.init();const e=it.moov(t),i=new Uint8Array(it.FTYP.byteLength+e.byteLength);return i.set(it.FTYP),i.set(e,it.FTYP.byteLength),i}}it.types=void 0,it.HDLR_TYPES=void 0,it.STTS=void 0,it.STSC=void 0,it.STCO=void 0,it.STSZ=void 0,it.VMHD=void 0,it.SMHD=void 0,it.STSD=void 0,it.FTYP=void 0,it.DINF=void 0;const U0=9e4;function kc(n,t,e=1,i=!1){const s=n*t*e;return i?Math.round(s):s}function Dy(n,t,e=1,i=!1){return kc(n,t,1/e,i)}function ka(n,t=!1){return kc(n,1e3,1/U0,t)}function xy(n,t=1){return kc(n,U0,1/t)}const Py=10*1e3,B0=1024,Oy=1152;let Io=null,wc=null;class Sc{constructor(t,e,i,s=""){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.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,Io===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Io=o?parseInt(o[1]):0}if(wc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);wc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){Y.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Y.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Y.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,o)=>{const c=o.pts-s;return c<-4294967296?(e=!0,cr(s,o.pts)):c>0?s:o.pts},t[0].pts);return e&&Y.debug("PTS rollover detected"),i}remux(t,e,i,s,o,c,d,f){let p,g,v,A,T,E,w=o,R=o;const x=t.pid>-1,M=e.pid>-1,G=e.samples.length,_=t.samples.length>0,F=d&&G>0||G>1;if((!x||_)&&(!M||F)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const H=this.isVideoContiguous;let j=-1,nt;if(F&&(j=My(e.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(E=!0,j>0){Y.warn(`[mp4-remuxer]: Dropped ${j} out of ${G} video samples due to a missing keyframe`);const ot=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(j),e.dropped+=j,R+=(e.samples[0].pts-ot)/e.inputTimeScale,nt=R}else j===-1&&(Y.warn(`[mp4-remuxer]: No keyframe found out of ${G} video samples`),E=!1);if(this.ISGenerated){if(_&&F){const ot=this.getVideoStartPts(e.samples),tt=(cr(t.samples[0].pts,ot)-ot)/e.inputTimeScale;w+=Math.max(0,tt),R+=Math.max(0,-tt)}if(_){if(t.samplerate||(Y.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,M||F||f===Qt.AUDIO?R:void 0),F){const ot=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(Y.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,R,H,ot)}}else F&&(p=this.remuxVideo(e,R,H,0));p&&(p.firstKeyFrame=j,p.independent=j!==-1,p.firstKeyFramePTS=nt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(T=G0(i,o,this._initPTS,this._initDTS)),s.samples.length&&(A=H0(s,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:E,text:A,id3:T}}generateIS(t,e,i,s){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||s,v="audio/mp4",A,T,E;if(g&&(A=T=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):it.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(E=t.inputTimeScale,!p||E!==p.timescale?A=T=o[0].pts-Math.round(E*i):g=!1)}if(e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:it.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(E=e.inputTimeScale,!p||E!==p.timescale){const w=this.getVideoStartPts(c),R=Math.round(E*i);T=Math.min(T,cr(c[0].dts,w)-R),A=Math.min(A,w-R)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:A,timescale:E},this._initDTS={baseTime:T,timescale:E}):A=E=void 0,{tracks:f,initPTS:A,timescale:E}}remuxVideo(t,e,i,s){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,A=this.videoSampleDuration,T,E,w=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY,x=!1;if(!i||g===null){const $=e*o,U=c[0].pts-cr(c[0].dts,c[0].pts);g=$-U}const M=p.baseTime*o/p.timescale;for(let $=0;$<f;$++){const U=c[$];U.pts=cr(U.pts-M,g),U.dts=cr(U.dts-M,g),U.dts<c[$>0?$-1:$].dts&&(x=!0)}x&&c.sort(function($,U){const q=$.dts-U.dts,gt=$.pts-U.pts;return q||gt}),T=c[0].dts,E=c[c.length-1].dts;const G=E-T,_=G?Math.round(G/(f-1)):A||t.inputTimeScale/30;if(i){const $=T-g,U=$>_,q=$<-1;if((U||q)&&(U?Y.warn(`AVC: ${ka($,!0)} ms (${$}dts) hole between fragments detected, filling it`):Y.warn(`AVC: ${ka(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!q||g>=c[0].pts)){T=g;const gt=c[0].pts-$;c[0].dts=T,c[0].pts=gt,Y.log(`Video: First PTS/DTS adjusted: ${ka(gt,!0)}/${ka(T,!0)}, delta: ${ka($,!0)} ms`)}}T=Math.max(0,T);let F=0,H=0;for(let $=0;$<f;$++){const U=c[$],q=U.units,gt=q.length;let Et=0;for(let Pt=0;Pt<gt;Pt++)Et+=q[Pt].data.length;H+=Et,F+=gt,U.length=Et,U.dts=Math.max(U.dts,T),w=Math.min(U.pts,w),R=Math.max(U.pts,R)}E=c[f-1].dts;const j=H+4*F+8;let nt;try{nt=new Uint8Array(j)}catch($){this.observer.emit(L.ERROR,L.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:j,reason:`fail allocating video mdat ${j}`});return}const ot=new DataView(nt.buffer);ot.setUint32(0,j),nt.set(it.types.mdat,4);let tt=!1,kt=Number.POSITIVE_INFINITY,vt=Number.POSITIVE_INFINITY,$t=Number.NEGATIVE_INFINITY,jt=Number.NEGATIVE_INFINITY;for(let $=0;$<f;$++){const U=c[$],q=U.units;let gt=0;for(let Ut=0,Ot=q.length;Ut<Ot;Ut++){const ae=q[Ut],oe=ae.data,he=ae.data.byteLength;ot.setUint32(v,he),v+=4,nt.set(oe,v),v+=he,gt+=4+he}let Et;if($<f-1)A=c[$+1].dts-U.dts,Et=c[$+1].pts-U.pts;else{const Ut=this.config,Ot=$>0?U.dts-c[$-1].dts:_;if(Et=$>0?U.pts-c[$-1].pts:_,Ut.stretchShortVideoTrack&&this.nextAudioPts!==null){const ae=Math.floor(Ut.maxBufferHole*o),oe=(s?w+s*o:this.nextAudioPts)-U.pts;oe>ae?(A=oe-Ot,A<0?A=Ot:tt=!0,Y.log(`[mp4-remuxer]: It is approximately ${oe/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=Ot}else A=Ot}const Pt=Math.round(U.pts-U.dts);kt=Math.min(kt,A),$t=Math.max($t,A),vt=Math.min(vt,Et),jt=Math.max(jt,Et),d.push(new V0(U.key,A,gt,Pt))}if(d.length){if(Io){if(Io<70){const $=d[0].flags;$.dependsOn=2,$.isNonSync=0}}else if(wc&&jt-vt<$t-kt&&_/$t<.025&&d[0].cts===0){Y.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=T;for(let U=0,q=d.length;U<q;U++){const gt=$+d[U].duration,Et=$+d[U].cts;if(U<q-1){const Pt=gt+d[U+1].cts;d[U].duration=Pt-Et}else d[U].duration=U?d[U-1].duration:_;d[U].cts=0,$=gt}}}A=tt||!A?_:A,this.nextAvcDts=g=E+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const V=it.moof(t.sequenceNumber++,T,ni({},t,{samples:d})),rt="video",Lt={data1:V,data2:nt,startPTS:w/o,endPTS:(R+A)/o,startDTS:T/o,endDTS:g/o,type:rt,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,Lt}remuxAudio(t,e,i,s,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?B0:Oy,g=p*f,v=this._initPTS,A=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,T=[],E=o!==void 0;let w=t.samples,R=A?0:8,x=this.nextAudioPts||-1;const M=e*c,G=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&x>0&&(s&&Math.abs(M-x)<9e3||Math.abs(cr(w[0].pts-G,M)-x)<20*g),w.forEach(function(V){V.pts=cr(V.pts-G,M)}),!i||x<0){if(w=w.filter(V=>V.pts>=0),!w.length)return;o===0?x=0:s&&!E?x=Math.max(0,M):x=w[0].pts}if(t.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let rt=0,Lt=x;rt<w.length;rt++){const $=w[rt],U=$.pts,q=U-Lt,gt=Math.abs(1e3*q/c);if(q<=-V*g&&E)rt===0&&(Y.warn(`Audio frame @ ${(U/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*q/c)} ms.`),this.nextAudioPts=x=Lt=U);else if(q>=V*g&&gt<Py&&E){let Et=Math.round(q/g);Lt=U-Et*g,Lt<0&&(Et--,Lt+=g),rt===0&&(this.nextAudioPts=x=Lt),Y.warn(`[mp4-remuxer]: Injecting ${Et} audio frame @ ${(Lt/c).toFixed(3)}s due to ${Math.round(1e3*q/c)} ms gap.`);for(let Pt=0;Pt<Et;Pt++){const Ut=Math.max(Lt,0);let Ot=N0.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Ot||(Y.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ot=$.unit.subarray()),w.splice(rt,0,{unit:Ot,pts:Ut}),Lt+=g,rt++}}$.pts=Lt,Lt+=g}}let _=null,F=null,H,j=0,nt=w.length;for(;nt--;)j+=w[nt].unit.byteLength;for(let V=0,rt=w.length;V<rt;V++){const Lt=w[V],$=Lt.unit;let U=Lt.pts;if(F!==null){const gt=T[V-1];gt.duration=Math.round((U-F)/f)}else if(i&&t.segmentCodec==="aac"&&(U=x),_=U,j>0){j+=R;try{H=new Uint8Array(j)}catch(gt){this.observer.emit(L.ERROR,L.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:gt,bytes:j,reason:`fail allocating audio mdat ${j}`});return}A||(new DataView(H.buffer).setUint32(0,j),H.set(it.types.mdat,4))}else return;H.set($,R);const q=$.byteLength;R+=q,T.push(new V0(!0,p,q,0)),F=U}const ot=T.length;if(!ot)return;const tt=T[T.length-1];this.nextAudioPts=x=F+f*tt.duration;const kt=A?new Uint8Array(0):it.moof(t.sequenceNumber++,_/f,ni({},t,{samples:T}));t.samples=[];const vt=_/c,$t=x/c,jt={data1:kt,data2:H,startPTS:vt,endPTS:$t,startDTS:vt,endDTS:$t,type:"audio",hasAudio:!0,hasVideo:!1,nb:ot};return this.isAudioContiguous=!0,jt}remuxEmptyAudio(t,e,i,s){const o=t.inputTimeScale,c=t.samplerate?t.samplerate:o,d=o/c,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:s.startDTS*o)+g,A=s.endDTS*o+g,T=d*B0,E=Math.ceil((A-v)/T),w=N0.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Y.warn("[mp4-remuxer]: remux empty Audio"),!w){Y.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const R=[];for(let x=0;x<E;x++){const M=v+x*T;R.push({unit:w,pts:M,dts:M})}return t.samples=R,this.remuxAudio(t,e,i,!1)}}function cr(n,t){let e;if(t===null)return n;for(t<n?e=-8589934592:e=8589934592;Math.abs(n-t)>4294967296;)n+=e;return n}function My(n){for(let t=0;t<n.length;t++)if(n[t].key)return t;return-1}function G0(n,t,e,i){const s=n.samples.length;if(!s)return;const o=n.inputTimeScale;for(let d=0;d<s;d++){const f=n.samples[d];f.pts=cr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=cr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=n.samples;return n.samples=[],{samples:c}}function H0(n,t,e){const i=n.samples.length;if(!i)return;const s=n.inputTimeScale;for(let c=0;c<i;c++){const d=n.samples[c];d.pts=cr(d.pts-e.baseTime*s/e.timescale,t*s)/s}n.samples.sort((c,d)=>c.pts-d.pts);const o=n.samples;return n.samples=[],{samples:o}}class V0{constructor(t,e,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=s,this.flags=new $y(t)}}class $y{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class Fy{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(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(rv(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=Ku(t);e||(e=W0(s.audio,_e.AUDIO)),i||(i=W0(s.video,_e.VIDEO));const o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:Y.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,s,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Kt(g)||(g=this.lastEndTime=o||0);const A=e.samples;if(!(A!=null&&A.length))return v;const T={initPTS:void 0,timescale:1};let E=this.initData;if((d=E)!=null&&d.length||(this.generateInitSegment(A),E=this.initData),!((f=E)!=null&&f.length))return Y.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(T.tracks=this.initTracks,this.emitInitSegment=!1);const w=nv(A,E),R=sv(E,A),x=R===null?o:R;(Ny(p,x,o,w)||T.timescale!==p.timescale&&c)&&(T.initPTS=x-o,p&&p.timescale===1&&Y.warn(`Adjusting initPTS by ${T.initPTS-p.baseTime}`),this.initPTS=p={baseTime:T.initPTS,timescale:1});const M=t?x-p.baseTime/p.timescale:g,G=M+w;ov(E,A,p.baseTime/p.timescale),w>0?this.lastEndTime=G:(Y.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const _=!!E.audio,F=!!E.video;let H="";_&&(H+="audio"),F&&(H+="video");const j={data1:A,startPTS:M,startDTS:M,endPTS:G,endDTS:G,type:H,hasAudio:_,hasVideo:F,nb:1,dropped:0};return v.audio=j.type==="audio"?j:void 0,v.video=j.type!=="audio"?j:void 0,v.initSegment=T,v.id3=G0(i,o,p,p),s.samples.length&&(v.text=H0(s,o,p)),v}}function Ny(n,t,e,i){if(n===null)return!0;const s=Math.max(i,1),o=t-n.baseTime/n.timescale;return Math.abs(o-e)>s}function W0(n,t){const e=n==null?void 0:n.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===_e.VIDEO?"avc1.42e01e":"mp4a.40.5"}let Qr;try{Qr=self.performance.now.bind(self.performance)}catch{Y.debug("Unable to use Performance API on this environment"),Qr=typeof self<"u"&&self.Date.now}const Lc=[{demux:Ay,remux:Fy},{demux:ms,remux:Sc},{demux:yy,remux:Sc},{demux:Iy,remux:Sc}];class K0{constructor(t,e,i,s,o){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=t,this.typeSupported=e,this.config=i,this.vendor=s,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const o=i.transmuxing;o.executeStart=Qr();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;s&&(this.currentTransmuxState=s);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:A,timeOffset:T,initSegmentChange:E}=s||d,{audioCodec:w,videoCodec:R,defaultInitPts:x,duration:M,initSegmentData:G}=f,_=Uy(c,e);if(_&&_.method==="AES-128"){const nt=this.getDecrypter();if(nt.isSync()){let ot=nt.softwareDecrypt(c,_.key.buffer,_.iv.buffer);if(i.part>-1&&(ot=nt.flush()),!ot)return o.executeEnd=Qr(),Rc(i);c=new Uint8Array(ot)}else return this.decryptionPromise=nt.webCryptoDecrypt(c,_.key.buffer,_.iv.buffer).then(ot=>{const tt=this.push(ot,null,i);return this.decryptionPromise=null,tt}),this.decryptionPromise}const F=this.needsProbing(g,v);if(F){const nt=this.configureTransmuxer(c);if(nt)return Y.warn(`[transmuxer] ${nt.message}`),this.observer.emit(L.ERROR,L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:nt,reason:nt.message}),o.executeEnd=Qr(),Rc(i)}(g||v||E||F)&&this.resetInitSegment(G,w,R,M,e),(g||E||F)&&this.resetInitialTimestamp(x),p||this.resetContiguity();const H=this.transmux(c,_,T,A,i),j=this.currentTransmuxState;return j.contiguous=!0,j.discontinuity=!1,j.trackSwitch=!1,o.executeEnd=Qr(),H}flush(t){const e=t.transmuxing;e.executeStart=Qr();const{decrypter:i,currentTransmuxState:s,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=s;if(i){const v=i.flush();v&&c.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=Qr(),[Rc(t)];const g=f.flush(d);return Do(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;Y.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(s,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=Qr()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,s),d.resetInitSegment(t,e,i,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,s,o):c=this.transmuxUnencrypted(t,i,s,o),c}transmuxUnencrypted(t,e,i,s){const{audioTrack:o,videoTrack:c,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,c,d,f,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,s,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:o}=this;let c;for(let v=0,A=Lc.length;v<A;v++)if(Lc[v].demux.probe(t)){c=Lc[v];break}if(!c)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=c.remux,g=c.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,s,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,s),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new yc(this.config)),t}}function Uy(n,t){let e=null;return n.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Rc=n=>({remuxResult:{},chunkMeta:n});function Do(n){return"then"in n&&n.then instanceof Function}class By{constructor(t,e,i,s,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=o||null}}class Gy{constructor(t,e,i,s,o,c){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=o,this.initSegmentChange=c}}var j0={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,A){if(typeof g!="function")throw new TypeError("The listener must be a function");var T=new s(g,v||f,A),E=e?e+p:p;return f._events[E]?f._events[E].fn?f._events[E]=[f._events[E],T]:f._events[E].push(T):(f._events[E]=T,f._eventsCount++),f}function c(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,A=g.length,T=new Array(A);v<A;v++)T[v]=g[v].fn;return T},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,A,T){var E=e?e+f:f;if(!this._events[E])return!1;var w=this._events[E],R=arguments.length,x,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),R){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,A),!0;case 6:return w.fn.call(w.context,p,g,v,A,T),!0}for(M=1,x=new Array(R-1);M<R;M++)x[M-1]=arguments[M];w.fn.apply(w.context,x)}else{var G=w.length,_;for(M=0;M<G;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),R){case 1:w[M].fn.call(w[M].context);break;case 2:w[M].fn.call(w[M].context,p);break;case 3:w[M].fn.call(w[M].context,p,g);break;case 4:w[M].fn.call(w[M].context,p,g,v);break;default:if(!x)for(_=1,x=new Array(R-1);_<R;_++)x[_-1]=arguments[_];w[M].fn.apply(w[M].context,x)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var A=e?e+f:f;if(!this._events[A])return this;if(!p)return c(this,A),this;var T=this._events[A];if(T.fn)T.fn===p&&(!v||T.once)&&(!g||T.context===g)&&c(this,A);else{for(var E=0,w=[],R=T.length;E<R;E++)(T[E].fn!==p||v&&!T[E].once||g&&T[E].context!==g)&&w.push(T[E]);w.length?this._events[A]=w.length===1?w[0]:w:c(this,A)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&c(this,p)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,n.exports=d})(j0);var Hy=j0.exports,_c=Rm(Hy);const Cc=Ao()||{isTypeSupported:()=>!1};class z0{constructor(t,e,i,s){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 o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const c=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===L.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new _c,this.observer.on(L.FRAG_DECRYPTED,c),this.observer.on(L.ERROR,c);const d={mp4:Cc.isTypeSupported("video/mp4"),mpeg:Cc.isTypeSupported("audio/mpeg"),mp3:Cc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||cy())){try{o.workerPath?(Y.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=dy(o.workerPath)):(Y.log(`injecting Web Worker for "${e}"`),this.workerContext=hy()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,Y.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(L.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){Y.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new K0(this.observer,d,o,f,e)}return}this.transmuxer=new K0(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.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 t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,s,o,c,d,f,p,g){var v,A;p.transmuxing.start=self.performance.now();const{transmuxer:T}=this,E=c?c.start:o.start,w=o.decryptdata,R=this.frag,x=!(R&&o.cc===R.cc),M=!(R&&p.level===R.level),G=R?p.sn-R.sn:-1,_=this.part?p.part-this.part.index:-1,F=G===0&&p.id>1&&p.id===(R==null?void 0:R.stats.chunkCount),H=!M&&(G===1||G===0&&(_===1||F&&_<=0)),j=self.performance.now();(M||G||o.stats.parsing.start===0)&&(o.stats.parsing.start=j),c&&(_||!H)&&(c.stats.parsing.start=j);const nt=!(R&&((v=o.initSegment)==null?void 0:v.url)===((A=R.initSegment)==null?void 0:A.url)),ot=new Gy(x,H,f,M,E,nt);if(!H||x||nt){Y.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
181
+ */const Jd=(n,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(n[s],s);return i},tu=An(class extends na{constructor(n){if(super(n),n.type!==bn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(n,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],o=[];let c=0;for(const d of n)s[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:s}}render(n,t,e){return this.ht(n,t,e).values}update(n,[t,e,i]){const s=X2(n),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(s))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,b=s.length-1,E=0,k=o.length-1;for(;v<=b&&E<=k;)if(s[v]===null)v++;else if(s[b]===null)b--;else if(d[v]===c[E])f[E]=Zs(s[v],o[E]),v++,E++;else if(d[b]===c[k])f[k]=Zs(s[b],o[k]),b--,k--;else if(d[v]===c[k])f[k]=Zs(s[v],o[k]),sa(n,f[k+1],s[v]),v++,k--;else if(d[b]===c[E])f[E]=Zs(s[b],o[E]),sa(n,s[v],s[b]),b--,E++;else if(p===void 0&&(p=Jd(c,E,k),g=Jd(d,v,b)),p.has(d[v]))if(p.has(d[b])){const w=g.get(c[E]),L=w!==void 0?s[w]:null;if(L===null){const x=sa(n,s[v]);Zs(x,o[E]),f[E]=x}else f[E]=Zs(L,o[E]),sa(n,s[v],L),s[w]=null;E++}else kl(s[b]),b--;else kl(s[v]),v++;for(;E<=k;){const w=sa(n,f[k+1]);Zs(w,o[E]),f[E++]=w}for(;v<=b;){const w=s[v++];w!==null&&kl(w)}return this.dt=c,Z2(n,f),us}});var Gi="top",ar="bottom",or="right",Vi="left",Vl="auto",ga=[Gi,ar,or,Vi],En="start",ma="end",lm="clippingParents",eu="viewport",va="popper",cm="reference",iu=ga.reduce(function(n,t){return n.concat([t+"-"+En,t+"-"+ma])},[]),ru=[].concat(ga,[Vl]).reduce(function(n,t){return n.concat([t,t+"-"+En,t+"-"+ma])},[]),hm="beforeRead",dm="read",um="afterRead",fm="beforeMain",pm="main",gm="afterMain",mm="beforeWrite",vm="write",ym="afterWrite",bm=[hm,dm,um,fm,pm,gm,mm,vm,ym];function Ir(n){return n?(n.nodeName||"").toLowerCase():null}function er(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function tn(n){var t=er(n).Element;return n instanceof t||n instanceof Element}function lr(n){var t=er(n).HTMLElement;return n instanceof t||n instanceof HTMLElement}function Hl(n){if(typeof ShadowRoot>"u")return!1;var t=er(n).ShadowRoot;return n instanceof t||n instanceof ShadowRoot}function Am(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},o=t.elements[e];!lr(o)||!Ir(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(c){var d=s[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function Em(n){var t=n.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var s=t.elements[i],o=t.attributes[i]||{},c=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=c.reduce(function(f,p){return f[p]="",f},{});!lr(s)||!Ir(s)||(Object.assign(s.style,d),Object.keys(o).forEach(function(f){s.removeAttribute(f)}))})}}const su={name:"applyStyles",enabled:!0,phase:"write",fn:Am,effect:Em,requires:["computeStyles"]};function Dr(n){return n.split("-")[0]}var en=Math.max,uo=Math.min,kn=Math.round;function Wl(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function nu(){return!/^((?!chrome|android).)*safari/i.test(Wl())}function Tn(n,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=n.getBoundingClientRect(),s=1,o=1;t&&lr(n)&&(s=n.offsetWidth>0&&kn(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&kn(i.height)/n.offsetHeight||1);var c=tn(n)?er(n):window,d=c.visualViewport,f=!nu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/s,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/s,b=i.height/o;return{width:v,height:b,top:g,right:p+v,bottom:g+b,left:p,x:p,y:g}}function jl(n){var t=Tn(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function au(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&Hl(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function qr(n){return er(n).getComputedStyle(n)}function km(n){return["table","td","th"].indexOf(Ir(n))>=0}function bs(n){return((tn(n)?n.ownerDocument:n.document)||window.document).documentElement}function fo(n){return Ir(n)==="html"?n:n.assignedSlot||n.parentNode||(Hl(n)?n.host:null)||bs(n)}function ou(n){return!lr(n)||qr(n).position==="fixed"?null:n.offsetParent}function Tm(n){var t=/firefox/i.test(Wl()),e=/Trident/i.test(Wl());if(e&&lr(n)){var i=qr(n);if(i.position==="fixed")return null}var s=fo(n);for(Hl(s)&&(s=s.host);lr(s)&&["html","body"].indexOf(Ir(s))<0;){var o=qr(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function ya(n){for(var t=er(n),e=ou(n);e&&km(e)&&qr(e).position==="static";)e=ou(e);return e&&(Ir(e)==="html"||Ir(e)==="body"&&qr(e).position==="static")?t:e||Tm(n)||t}function Kl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function ba(n,t,e){return en(n,uo(t,e))}function wm(n,t,e){var i=ba(n,t,e);return i>e?e:i}function lu(){return{top:0,right:0,bottom:0,left:0}}function cu(n){return Object.assign({},lu(),n)}function hu(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}var Sm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,cu(typeof t!="number"?t:hu(t,ga))};function Rm(n){var t,e=n.state,i=n.name,s=n.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=Dr(e.placement),f=Kl(d),p=[Vi,or].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Sm(s.padding,e),b=jl(o),E=f==="y"?Gi:Vi,k=f==="y"?ar:or,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],L=c[f]-e.rects.reference[f],x=ya(o),M=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,N=w/2-L/2,D=v[E],F=M-b[g]-v[k],H=M/2-b[g]/2+N,j=ba(D,H,F),st=f;e.modifiersData[i]=(t={},t[st]=j,t.centerOffset=j-H,t)}}function Lm(n){var t=n.state,e=n.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||au(t.elements.popper,s)&&(t.elements.arrow=s))}const _m={name:"arrow",enabled:!0,phase:"main",fn:Rm,effect:Lm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wn(n){return n.split("-")[1]}var Cm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Im(n,t){var e=n.x,i=n.y,s=t.devicePixelRatio||1;return{x:kn(e*s)/s||0,y:kn(i*s)/s||0}}function du(n){var t,e=n.popper,i=n.popperRect,s=n.placement,o=n.variation,c=n.offsets,d=n.position,f=n.gpuAcceleration,p=n.adaptive,g=n.roundOffsets,v=n.isFixed,b=c.x,E=b===void 0?0:b,k=c.y,w=k===void 0?0:k,L=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=L.x,w=L.y;var x=c.hasOwnProperty("x"),M=c.hasOwnProperty("y"),N=Vi,D=Gi,F=window;if(p){var H=ya(e),j="clientHeight",st="clientWidth";if(H===er(e)&&(H=bs(e),qr(H).position!=="static"&&d==="absolute"&&(j="scrollHeight",st="scrollWidth")),H=H,s===Gi||(s===Vi||s===or)&&o===ma){D=ar;var at=v&&H===F&&F.visualViewport?F.visualViewport.height:H[j];w-=at-i.height,w*=f?1:-1}if(s===Vi||(s===Gi||s===ar)&&o===ma){N=or;var Q=v&&H===F&&F.visualViewport?F.visualViewport.width:H[st];E-=Q-i.width,E*=f?1:-1}}var kt=Object.assign({position:d},p&&Cm),gt=g===!0?Im({x:E,y:w},er(e)):{x:E,y:w};if(E=gt.x,w=gt.y,f){var Ft;return Object.assign({},kt,(Ft={},Ft[D]=M?"0":"",Ft[N]=x?"0":"",Ft.transform=(F.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Ft))}return Object.assign({},kt,(t={},t[D]=M?w+"px":"",t[N]=x?E+"px":"",t.transform="",t))}function Dm(n){var t=n.state,e=n.options,i=e.gpuAcceleration,s=i===void 0?!0:i,o=e.adaptive,c=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:Dr(t.placement),variation:wn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,du(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,du(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const xm={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Dm,data:{}};var po={passive:!0};function Pm(n){var t=n.state,e=n.instance,i=n.options,s=i.scroll,o=s===void 0?!0:s,c=i.resize,d=c===void 0?!0:c,f=er(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,po)}),d&&f.addEventListener("resize",e.update,po),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,po)}),d&&f.removeEventListener("resize",e.update,po)}}const Om={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Pm,data:{}};var Mm={left:"right",right:"left",bottom:"top",top:"bottom"};function go(n){return n.replace(/left|right|bottom|top/g,function(t){return Mm[t]})}var $m={start:"end",end:"start"};function uu(n){return n.replace(/start|end/g,function(t){return $m[t]})}function Yl(n){var t=er(n),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function zl(n){return Tn(bs(n)).left+Yl(n).scrollLeft}function Fm(n,t){var e=er(n),i=bs(n),s=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(s){o=s.width,c=s.height;var p=nu();(p||!p&&t==="fixed")&&(d=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:d+zl(n),y:f}}function Nm(n){var t,e=bs(n),i=Yl(n),s=(t=n.ownerDocument)==null?void 0:t.body,o=en(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),c=en(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),d=-i.scrollLeft+zl(n),f=-i.scrollTop;return qr(s||e).direction==="rtl"&&(d+=en(e.clientWidth,s?s.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Zl(n){var t=qr(n),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function fu(n){return["html","body","#document"].indexOf(Ir(n))>=0?n.ownerDocument.body:lr(n)&&Zl(n)?n:fu(fo(n))}function Aa(n,t){var e;t===void 0&&(t=[]);var i=fu(n),s=i===((e=n.ownerDocument)==null?void 0:e.body),o=er(i),c=s?[o].concat(o.visualViewport||[],Zl(i)?i:[]):i,d=t.concat(c);return s?d:d.concat(Aa(fo(c)))}function Xl(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function Um(n,t){var e=Tn(n,!1,t==="fixed");return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}function pu(n,t,e){return t===eu?Xl(Fm(n,e)):tn(t)?Um(t,e):Xl(Nm(bs(n)))}function Bm(n){var t=Aa(fo(n)),e=["absolute","fixed"].indexOf(qr(n).position)>=0,i=e&&lr(n)?ya(n):n;return tn(i)?t.filter(function(s){return tn(s)&&au(s,i)&&Ir(s)!=="body"}):[]}function Gm(n,t,e,i){var s=t==="clippingParents"?Bm(n):[].concat(t),o=[].concat(s,[e]),c=o[0],d=o.reduce(function(f,p){var g=pu(n,p,i);return f.top=en(g.top,f.top),f.right=uo(g.right,f.right),f.bottom=uo(g.bottom,f.bottom),f.left=en(g.left,f.left),f},pu(n,c,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function gu(n){var t=n.reference,e=n.element,i=n.placement,s=i?Dr(i):null,o=i?wn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(s){case Gi:f={x:c,y:t.y-e.height};break;case ar:f={x:c,y:t.y+t.height};break;case or:f={x:t.x+t.width,y:d};break;case Vi:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=s?Kl(s):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case En:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ma:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Ea(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?n.placement:i,o=e.strategy,c=o===void 0?n.strategy:o,d=e.boundary,f=d===void 0?lm:d,p=e.rootBoundary,g=p===void 0?eu:p,v=e.elementContext,b=v===void 0?va:v,E=e.altBoundary,k=E===void 0?!1:E,w=e.padding,L=w===void 0?0:w,x=cu(typeof L!="number"?L:hu(L,ga)),M=b===va?cm:va,N=n.rects.popper,D=n.elements[k?M:b],F=Gm(tn(D)?D:D.contextElement||bs(n.elements.popper),f,g,c),H=Tn(n.elements.reference),j=gu({reference:H,element:N,strategy:"absolute",placement:s}),st=Xl(Object.assign({},N,j)),at=b===va?st:H,Q={top:F.top-at.top+x.top,bottom:at.bottom-F.bottom+x.bottom,left:F.left-at.left+x.left,right:at.right-F.right+x.right},kt=n.modifiersData.offset;if(b===va&&kt){var gt=kt[s];Object.keys(Q).forEach(function(Ft){var Kt=[or,ar].indexOf(Ft)>=0?1:-1,V=[Gi,ar].indexOf(Ft)>=0?"y":"x";Q[Ft]+=gt[V]*Kt})}return Q}function Vm(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?ru:f,g=wn(i),v=g?d?iu:iu.filter(function(k){return wn(k)===g}):ga,b=v.filter(function(k){return p.indexOf(k)>=0});b.length===0&&(b=v);var E=b.reduce(function(k,w){return k[w]=Ea(n,{placement:w,boundary:s,rootBoundary:o,padding:c})[Dr(w)],k},{});return Object.keys(E).sort(function(k,w){return E[k]-E[w]})}function Hm(n){if(Dr(n)===Vl)return[];var t=go(n);return[uu(n),t,uu(t)]}function Wm(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,b=e.altBoundary,E=e.flipVariations,k=E===void 0?!0:E,w=e.allowedAutoPlacements,L=t.options.placement,x=Dr(L),M=x===L,N=f||(M||!k?[go(L)]:Hm(L)),D=[L].concat(N).reduce(function(Ut,Qt){return Ut.concat(Dr(Qt)===Vl?Vm(t,{placement:Qt,boundary:g,rootBoundary:v,padding:p,flipVariations:k,allowedAutoPlacements:w}):Qt)},[]),F=t.rects.reference,H=t.rects.popper,j=new Map,st=!0,at=D[0],Q=0;Q<D.length;Q++){var kt=D[Q],gt=Dr(kt),Ft=wn(kt)===En,Kt=[Gi,ar].indexOf(gt)>=0,V=Kt?"width":"height",J=Ea(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:b,padding:p}),St=Kt?Ft?or:Vi:Ft?ar:Gi;F[V]>H[V]&&(St=go(St));var $=go(St),U=[];if(o&&U.push(J[gt]<=0),d&&U.push(J[St]<=0,J[$]<=0),U.every(function(Ut){return Ut})){at=kt,st=!1;break}j.set(kt,U)}if(st)for(var Z=k?3:1,mt=function(Qt){var fe=D.find(function(re){var Ht=j.get(re);if(Ht)return Ht.slice(0,Qt).every(function(Oe){return Oe})});if(fe)return at=fe,"break"},bt=Z;bt>0;bt--){var Dt=mt(bt);if(Dt==="break")break}t.placement!==at&&(t.modifiersData[i]._skip=!0,t.placement=at,t.reset=!0)}}const jm={name:"flip",enabled:!0,phase:"main",fn:Wm,requiresIfExists:["offset"],data:{_skip:!1}};function mu(n,t,e){return e===void 0&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function vu(n){return[Gi,or,ar,Vi].some(function(t){return n[t]>=0})}function Km(n){var t=n.state,e=n.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,c=Ea(t,{elementContext:"reference"}),d=Ea(t,{altBoundary:!0}),f=mu(c,i),p=mu(d,s,o),g=vu(f),v=vu(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const Ym={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:Km};function zm(n,t,e){var i=Dr(n),s=[Vi,Gi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:n})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*s,[Vi,or].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function Zm(n){var t=n.state,e=n.options,i=n.name,s=e.offset,o=s===void 0?[0,0]:s,c=ru.reduce(function(g,v){return g[v]=zm(v,t.rects,o),g},{}),d=c[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[i]=c}const Xm={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:Zm};function qm(n){var t=n.state,e=n.name;t.modifiersData[e]=gu({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const Qm={name:"popperOffsets",enabled:!0,phase:"read",fn:qm,data:{}};function Jm(n){return n==="x"?"y":"x"}function t1(n){var t=n.state,e=n.options,i=n.name,s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,b=e.tether,E=b===void 0?!0:b,k=e.tetherOffset,w=k===void 0?0:k,L=Ea(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),x=Dr(t.placement),M=wn(t.placement),N=!M,D=Kl(x),F=Jm(D),H=t.modifiersData.popperOffsets,j=t.rects.reference,st=t.rects.popper,at=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,Q=typeof at=="number"?{mainAxis:at,altAxis:at}:Object.assign({mainAxis:0,altAxis:0},at),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,gt={x:0,y:0};if(H){if(o){var Ft,Kt=D==="y"?Gi:Vi,V=D==="y"?ar:or,J=D==="y"?"height":"width",St=H[D],$=St+L[Kt],U=St-L[V],Z=E?-st[J]/2:0,mt=M===En?j[J]:st[J],bt=M===En?-st[J]:-j[J],Dt=t.elements.arrow,Ut=E&&Dt?jl(Dt):{width:0,height:0},Qt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:lu(),fe=Qt[Kt],re=Qt[V],Ht=ba(0,j[J],Ut[J]),Oe=N?j[J]/2-Z-Ht-fe-Q.mainAxis:mt-Ht-fe-Q.mainAxis,me=N?-j[J]/2+Z+Ht+re+Q.mainAxis:bt+Ht+re+Q.mainAxis,Wt=t.elements.arrow&&ya(t.elements.arrow),oe=Wt?D==="y"?Wt.clientTop||0:Wt.clientLeft||0:0,se=(Ft=kt==null?void 0:kt[D])!=null?Ft:0,Te=St+Oe-se-oe,Mt=St+me-se,Me=ba(E?uo($,Te):$,St,E?en(U,Mt):U);H[D]=Me,gt[D]=Me-St}if(d){var qe,Mi=D==="x"?Gi:Vi,kr=D==="x"?ar:or,we=H[F],li=F==="y"?"height":"width",ve=we+L[Mi],Je=we-L[kr],ti=[Gi,Vi].indexOf(x)!==-1,Zi=(qe=kt==null?void 0:kt[F])!=null?qe:0,Fe=ti?ve:we-j[li]-st[li]-Zi+Q.altAxis,Ci=ti?we+j[li]+st[li]-Zi-Q.altAxis:Je,rs=E&&ti?wm(Fe,we,Ci):ba(E?Fe:ve,we,E?Ci:Je);H[F]=rs,gt[F]=rs-we}t.modifiersData[i]=gt}}const e1={name:"preventOverflow",enabled:!0,phase:"main",fn:t1,requiresIfExists:["offset"]};function i1(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function r1(n){return n===er(n)||!lr(n)?Yl(n):i1(n)}function s1(n){var t=n.getBoundingClientRect(),e=kn(t.width)/n.offsetWidth||1,i=kn(t.height)/n.offsetHeight||1;return e!==1||i!==1}function n1(n,t,e){e===void 0&&(e=!1);var i=lr(t),s=lr(t)&&s1(t),o=bs(t),c=Tn(n,s,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Ir(t)!=="body"||Zl(o))&&(d=r1(t)),lr(t)?(f=Tn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=zl(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function a1(n){var t=new Map,e=new Set,i=[];n.forEach(function(o){t.set(o.name,o)});function s(o){e.add(o.name);var c=[].concat(o.requires||[],o.requiresIfExists||[]);c.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&s(f)}}),i.push(o)}return n.forEach(function(o){e.has(o.name)||s(o)}),i}function o1(n){var t=a1(n);return bm.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function l1(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}function c1(n){var t=n.reduce(function(e,i){var s=e[i.name];return e[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var yu={placement:"bottom",modifiers:[],strategy:"absolute"};function bu(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function h1(n){n===void 0&&(n={});var t=n,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,o=s===void 0?yu:s;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},yu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],b=!1,E={state:g,setOptions:function(x){var M=typeof x=="function"?x(g.options):x;w(),g.options=Object.assign({},o,g.options,M),g.scrollParents={reference:tn(d)?Aa(d):d.contextElement?Aa(d.contextElement):[],popper:Aa(f)};var N=o1(c1([].concat(i,g.options.modifiers)));return g.orderedModifiers=N.filter(function(D){return D.enabled}),k(),E.update()},forceUpdate:function(){if(!b){var x=g.elements,M=x.reference,N=x.popper;if(bu(M,N)){g.rects={reference:n1(M,ya(N),g.options.strategy==="fixed"),popper:jl(N)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(Q){return g.modifiersData[Q.name]=Object.assign({},Q.data)});for(var D=0;D<g.orderedModifiers.length;D++){if(g.reset===!0){g.reset=!1,D=-1;continue}var F=g.orderedModifiers[D],H=F.fn,j=F.options,st=j===void 0?{}:j,at=F.name;typeof H=="function"&&(g=H({state:g,options:st,name:at,instance:E})||g)}}}},update:l1(function(){return new Promise(function(L){E.forceUpdate(),L(g)})}),destroy:function(){w(),b=!0}};if(!bu(d,f))return E;E.setOptions(p).then(function(L){!b&&p.onFirstUpdate&&p.onFirstUpdate(L)});function k(){g.orderedModifiers.forEach(function(L){var x=L.name,M=L.options,N=M===void 0?{}:M,D=L.effect;if(typeof D=="function"){var F=D({state:g,name:x,instance:E,options:N}),H=function(){};v.push(F||H)}})}function w(){v.forEach(function(L){return L()}),v=[]}return E}}var d1=[Om,Qm,xm,su,Xm,jm,e1,_m,Ym],u1=h1({defaultModifiers:d1}),f1="tippy-box",Au="tippy-content",p1="tippy-backdrop",Eu="tippy-arrow",ku="tippy-svg-arrow",rn={passive:!0,capture:!0},Tu=function(){return document.body};function ql(n,t,e){if(Array.isArray(n)){var i=n[t];return i??(Array.isArray(e)?e[t]:e)}return n}function Ql(n,t){var e={}.toString.call(n);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function wu(n,t){return typeof n=="function"?n.apply(void 0,t):n}function Su(n,t){if(t===0)return n;var e;return function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)}}function g1(n){return n.split(/\s+/).filter(Boolean)}function Sn(n){return[].concat(n)}function Ru(n,t){n.indexOf(t)===-1&&n.push(t)}function m1(n){return n.filter(function(t,e){return n.indexOf(t)===e})}function v1(n){return n.split("-")[0]}function mo(n){return[].slice.call(n)}function Lu(n){return Object.keys(n).reduce(function(t,e){return n[e]!==void 0&&(t[e]=n[e]),t},{})}function ka(){return document.createElement("div")}function vo(n){return["Element","Fragment"].some(function(t){return Ql(n,t)})}function y1(n){return Ql(n,"NodeList")}function b1(n){return Ql(n,"MouseEvent")}function A1(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function E1(n){return vo(n)?[n]:y1(n)?mo(n):Array.isArray(n)?n:mo(document.querySelectorAll(n))}function Jl(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function _u(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function k1(n){var t,e=Sn(n),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function T1(n,t){var e=t.clientX,i=t.clientY;return n.every(function(s){var o=s.popperRect,c=s.popperState,d=s.props,f=d.interactiveBorder,p=v1(c.placement),g=c.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,b=p==="top"?g.bottom.y:0,E=p==="right"?g.left.x:0,k=p==="left"?g.right.x:0,w=o.top-i+v>f,L=i-o.bottom-b>f,x=o.left-e+E>f,M=e-o.right-k>f;return w||L||x||M})}function tc(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[i](s,e)})}function Cu(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var xr={isTouch:!1},Iu=0;function w1(){xr.isTouch||(xr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Du))}function Du(){var n=performance.now();n-Iu<20&&(xr.isTouch=!1,document.removeEventListener("mousemove",Du)),Iu=n}function S1(){var n=document.activeElement;if(A1(n)){var t=n._tippy;n.blur&&!t.state.isVisible&&n.blur()}}function R1(){document.addEventListener("touchstart",w1,rn),window.addEventListener("blur",S1)}var L1=typeof window<"u"&&typeof document<"u",_1=L1?!!window.msCrypto:!1,C1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},I1={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},yr=Object.assign({appendTo:Tu,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},C1,I1),D1=Object.keys(yr),x1=function(t){var e=Object.keys(t);e.forEach(function(i){yr[i]=t[i]})};function xu(n){var t=n.plugins||[],e=t.reduce(function(i,s){var o=s.name,c=s.defaultValue;if(o){var d;i[o]=n[o]!==void 0?n[o]:(d=yr[o])!=null?d:c}return i},{});return Object.assign({},n,e)}function P1(n,t){var e=t?Object.keys(xu(Object.assign({},yr,{plugins:t}))):D1,i=e.reduce(function(s,o){var c=(n.getAttribute("data-tippy-"+o)||"").trim();if(!c)return s;if(o==="content")s[o]=c;else try{s[o]=JSON.parse(c)}catch{s[o]=c}return s},{});return i}function Pu(n,t){var e=Object.assign({},t,{content:wu(t.content,[n])},t.ignoreAttributes?{}:P1(n,t.plugins));return e.aria=Object.assign({},yr.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var O1=function(){return"innerHTML"};function ec(n,t){n[O1()]=t}function Ou(n){var t=ka();return n===!0?t.className=Eu:(t.className=ku,vo(n)?t.appendChild(n):ec(t,n)),t}function Mu(n,t){vo(t.content)?(ec(n,""),n.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?ec(n,t.content):n.textContent=t.content)}function ic(n){var t=n.firstElementChild,e=mo(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Au)}),arrow:e.find(function(i){return i.classList.contains(Eu)||i.classList.contains(ku)}),backdrop:e.find(function(i){return i.classList.contains(p1)})}}function $u(n){var t=ka(),e=ka();e.className=f1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=ka();i.className=Au,i.setAttribute("data-state","hidden"),Mu(i,n.props),t.appendChild(e),e.appendChild(i),s(n.props,n.props);function s(o,c){var d=ic(t),f=d.box,p=d.content,g=d.arrow;c.theme?f.setAttribute("data-theme",c.theme):f.removeAttribute("data-theme"),typeof c.animation=="string"?f.setAttribute("data-animation",c.animation):f.removeAttribute("data-animation"),c.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof c.maxWidth=="number"?c.maxWidth+"px":c.maxWidth,c.role?f.setAttribute("role",c.role):f.removeAttribute("role"),(o.content!==c.content||o.allowHTML!==c.allowHTML)&&Mu(p,n.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(Ou(c.arrow))):f.appendChild(Ou(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:s}}$u.$$tippy=!0;var M1=1,yo=[],rc=[];function $1(n,t){var e=Pu(n,Object.assign({},yr,xu(Lu(t)))),i,s,o,c=!1,d=!1,f=!1,p=!1,g,v,b,E=[],k=Su(Te,e.interactiveDebounce),w,L=M1++,x=null,M=m1(e.plugins),N={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},D={id:L,reference:n,popper:ka(),popperInstance:x,props:e,state:N,plugins:M,clearDelayTimeouts:Fe,setProps:Ci,setContent:rs,show:ci,hide:Tr,hideWithInteractivity:Rs,enable:ti,disable:Zi,unmount:Ls,destroy:ir};if(!e.render)return D;var F=e.render(D),H=F.popper,j=F.onUpdate;H.setAttribute("data-tippy-root",""),H.id="tippy-"+D.id,D.popper=H,n._tippy=D,H._tippy=D;var st=M.map(function(ct){return ct.fn(D)}),at=n.hasAttribute("aria-expanded");return Wt(),Z(),St(),$("onCreate",[D]),e.showOnCreate&&ve(),H.addEventListener("mouseenter",function(){D.props.interactive&&D.state.isVisible&&D.clearDelayTimeouts()}),H.addEventListener("mouseleave",function(){D.props.interactive&&D.props.trigger.indexOf("mouseenter")>=0&&Kt().addEventListener("mousemove",k)}),D;function Q(){var ct=D.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return Q()[0]==="hold"}function gt(){var ct;return!!((ct=D.props.render)!=null&&ct.$$tippy)}function Ft(){return w||n}function Kt(){var ct=Ft().parentNode;return ct?k1(ct):document}function V(){return ic(H)}function J(ct){return D.state.isMounted&&!D.state.isVisible||xr.isTouch||g&&g.type==="focus"?0:ql(D.props.delay,ct?0:1,yr.delay)}function St(ct){ct===void 0&&(ct=!1),H.style.pointerEvents=D.props.interactive&&!ct?"":"none",H.style.zIndex=""+D.props.zIndex}function $(ct,Gt,Zt){if(Zt===void 0&&(Zt=!0),st.forEach(function(le){le[ct]&&le[ct].apply(le,Gt)}),Zt){var ye;(ye=D.props)[ct].apply(ye,Gt)}}function U(){var ct=D.props.aria;if(ct.content){var Gt="aria-"+ct.content,Zt=H.id,ye=Sn(D.props.triggerTarget||n);ye.forEach(function(le){var ni=le.getAttribute(Gt);if(D.state.isVisible)le.setAttribute(Gt,ni?ni+" "+Zt:Zt);else{var Ii=ni&&ni.replace(Zt,"").trim();Ii?le.setAttribute(Gt,Ii):le.removeAttribute(Gt)}})}}function Z(){if(!(at||!D.props.aria.expanded)){var ct=Sn(D.props.triggerTarget||n);ct.forEach(function(Gt){D.props.interactive?Gt.setAttribute("aria-expanded",D.state.isVisible&&Gt===Ft()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function mt(){Kt().removeEventListener("mousemove",k),yo=yo.filter(function(ct){return ct!==k})}function bt(ct){if(!(xr.isTouch&&(f||ct.type==="mousedown"))){var Gt=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(D.props.interactive&&Cu(H,Gt))){if(Sn(D.props.triggerTarget||n).some(function(Zt){return Cu(Zt,Gt)})){if(xr.isTouch||D.state.isVisible&&D.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[D,ct]);D.props.hideOnClick===!0&&(D.clearDelayTimeouts(),D.hide(),d=!0,setTimeout(function(){d=!1}),D.state.isMounted||fe())}}}function Dt(){f=!0}function Ut(){f=!1}function Qt(){var ct=Kt();ct.addEventListener("mousedown",bt,!0),ct.addEventListener("touchend",bt,rn),ct.addEventListener("touchstart",Ut,rn),ct.addEventListener("touchmove",Dt,rn)}function fe(){var ct=Kt();ct.removeEventListener("mousedown",bt,!0),ct.removeEventListener("touchend",bt,rn),ct.removeEventListener("touchstart",Ut,rn),ct.removeEventListener("touchmove",Dt,rn)}function re(ct,Gt){Oe(ct,function(){!D.state.isVisible&&H.parentNode&&H.parentNode.contains(H)&&Gt()})}function Ht(ct,Gt){Oe(ct,Gt)}function Oe(ct,Gt){var Zt=V().box;function ye(le){le.target===Zt&&(tc(Zt,"remove",ye),Gt())}if(ct===0)return Gt();tc(Zt,"remove",v),tc(Zt,"add",ye),v=ye}function me(ct,Gt,Zt){Zt===void 0&&(Zt=!1);var ye=Sn(D.props.triggerTarget||n);ye.forEach(function(le){le.addEventListener(ct,Gt,Zt),E.push({node:le,eventType:ct,handler:Gt,options:Zt})})}function Wt(){kt()&&(me("touchstart",se,{passive:!0}),me("touchend",Mt,{passive:!0})),g1(D.props.trigger).forEach(function(ct){if(ct!=="manual")switch(me(ct,se),ct){case"mouseenter":me("mouseleave",Mt);break;case"focus":me(_1?"focusout":"blur",Me);break;case"focusin":me("focusout",Me);break}})}function oe(){E.forEach(function(ct){var Gt=ct.node,Zt=ct.eventType,ye=ct.handler,le=ct.options;Gt.removeEventListener(Zt,ye,le)}),E=[]}function se(ct){var Gt,Zt=!1;if(!(!D.state.isEnabled||qe(ct)||d)){var ye=((Gt=g)==null?void 0:Gt.type)==="focus";g=ct,w=ct.currentTarget,Z(),!D.state.isVisible&&b1(ct)&&yo.forEach(function(le){return le(ct)}),ct.type==="click"&&(D.props.trigger.indexOf("mouseenter")<0||c)&&D.props.hideOnClick!==!1&&D.state.isVisible?Zt=!0:ve(ct),ct.type==="click"&&(c=!Zt),Zt&&!ye&&Je(ct)}}function Te(ct){var Gt=ct.target,Zt=Ft().contains(Gt)||H.contains(Gt);if(!(ct.type==="mousemove"&&Zt)){var ye=li().concat(H).map(function(le){var ni,Ii=le._tippy,ur=(ni=Ii.popperInstance)==null?void 0:ni.state;return ur?{popperRect:le.getBoundingClientRect(),popperState:ur,props:e}:null}).filter(Boolean);T1(ye,ct)&&(mt(),Je(ct))}}function Mt(ct){var Gt=qe(ct)||D.props.trigger.indexOf("click")>=0&&c;if(!Gt){if(D.props.interactive){D.hideWithInteractivity(ct);return}Je(ct)}}function Me(ct){D.props.trigger.indexOf("focusin")<0&&ct.target!==Ft()||D.props.interactive&&ct.relatedTarget&&H.contains(ct.relatedTarget)||Je(ct)}function qe(ct){return xr.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function Mi(){kr();var ct=D.props,Gt=ct.popperOptions,Zt=ct.placement,ye=ct.offset,le=ct.getReferenceClientRect,ni=ct.moveTransition,Ii=gt()?ic(H).arrow:null,ur=le?{getBoundingClientRect:le,contextElement:le.contextElement||Ft()}:n,ss={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(_s){var Di=_s.state;if(gt()){var Oa=V(),gr=Oa.box;["placement","reference-hidden","escaped"].forEach(function(Cs){Cs==="placement"?gr.setAttribute("data-placement",Di.placement):Di.attributes.popper["data-popper-"+Cs]?gr.setAttribute("data-"+Cs,""):gr.removeAttribute("data-"+Cs)}),Di.attributes.popper={}}}},fr=[{name:"offset",options:{offset:ye}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ni}},ss];gt()&&Ii&&fr.push({name:"arrow",options:{element:Ii,padding:3}}),fr.push.apply(fr,(Gt==null?void 0:Gt.modifiers)||[]),D.popperInstance=u1(ur,H,Object.assign({},Gt,{placement:Zt,onFirstUpdate:b,modifiers:fr}))}function kr(){D.popperInstance&&(D.popperInstance.destroy(),D.popperInstance=null)}function we(){var ct=D.props.appendTo,Gt,Zt=Ft();D.props.interactive&&ct===Tu||ct==="parent"?Gt=Zt.parentNode:Gt=wu(ct,[Zt]),Gt.contains(H)||Gt.appendChild(H),D.state.isMounted=!0,Mi()}function li(){return mo(H.querySelectorAll("[data-tippy-root]"))}function ve(ct){D.clearDelayTimeouts(),ct&&$("onTrigger",[D,ct]),Qt();var Gt=J(!0),Zt=Q(),ye=Zt[0],le=Zt[1];xr.isTouch&&ye==="hold"&&le&&(Gt=le),Gt?i=setTimeout(function(){D.show()},Gt):D.show()}function Je(ct){if(D.clearDelayTimeouts(),$("onUntrigger",[D,ct]),!D.state.isVisible){fe();return}if(!(D.props.trigger.indexOf("mouseenter")>=0&&D.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&c)){var Gt=J(!1);Gt?s=setTimeout(function(){D.state.isVisible&&D.hide()},Gt):o=requestAnimationFrame(function(){D.hide()})}}function ti(){D.state.isEnabled=!0}function Zi(){D.hide(),D.state.isEnabled=!1}function Fe(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(o)}function Ci(ct){if(!D.state.isDestroyed){$("onBeforeUpdate",[D,ct]),oe();var Gt=D.props,Zt=Pu(n,Object.assign({},Gt,Lu(ct),{ignoreAttributes:!0}));D.props=Zt,Wt(),Gt.interactiveDebounce!==Zt.interactiveDebounce&&(mt(),k=Su(Te,Zt.interactiveDebounce)),Gt.triggerTarget&&!Zt.triggerTarget?Sn(Gt.triggerTarget).forEach(function(ye){ye.removeAttribute("aria-expanded")}):Zt.triggerTarget&&n.removeAttribute("aria-expanded"),Z(),St(),j&&j(Gt,Zt),D.popperInstance&&(Mi(),li().forEach(function(ye){requestAnimationFrame(ye._tippy.popperInstance.forceUpdate)})),$("onAfterUpdate",[D,ct])}}function rs(ct){D.setProps({content:ct})}function ci(){var ct=D.state.isVisible,Gt=D.state.isDestroyed,Zt=!D.state.isEnabled,ye=xr.isTouch&&!D.props.touch,le=ql(D.props.duration,0,yr.duration);if(!(ct||Gt||Zt||ye)&&!Ft().hasAttribute("disabled")&&($("onShow",[D],!1),D.props.onShow(D)!==!1)){if(D.state.isVisible=!0,gt()&&(H.style.visibility="visible"),St(),Qt(),D.state.isMounted||(H.style.transition="none"),gt()){var ni=V(),Ii=ni.box,ur=ni.content;Jl([Ii,ur],0)}b=function(){var fr;if(!(!D.state.isVisible||p)){if(p=!0,H.offsetHeight,H.style.transition=D.props.moveTransition,gt()&&D.props.animation){var pr=V(),_s=pr.box,Di=pr.content;Jl([_s,Di],le),_u([_s,Di],"visible")}U(),Z(),Ru(rc,D),(fr=D.popperInstance)==null||fr.forceUpdate(),$("onMount",[D]),D.props.animation&&gt()&&Ht(le,function(){D.state.isShown=!0,$("onShown",[D])})}},we()}}function Tr(){var ct=!D.state.isVisible,Gt=D.state.isDestroyed,Zt=!D.state.isEnabled,ye=ql(D.props.duration,1,yr.duration);if(!(ct||Gt||Zt)&&($("onHide",[D],!1),D.props.onHide(D)!==!1)){if(D.state.isVisible=!1,D.state.isShown=!1,p=!1,c=!1,gt()&&(H.style.visibility="hidden"),mt(),fe(),St(!0),gt()){var le=V(),ni=le.box,Ii=le.content;D.props.animation&&(Jl([ni,Ii],ye),_u([ni,Ii],"hidden"))}U(),Z(),D.props.animation?gt()&&re(ye,D.unmount):D.unmount()}}function Rs(ct){Kt().addEventListener("mousemove",k),Ru(yo,k),k(ct)}function Ls(){D.state.isVisible&&D.hide(),D.state.isMounted&&(kr(),li().forEach(function(ct){ct._tippy.unmount()}),H.parentNode&&H.parentNode.removeChild(H),rc=rc.filter(function(ct){return ct!==D}),D.state.isMounted=!1,$("onHidden",[D]))}function ir(){D.state.isDestroyed||(D.clearDelayTimeouts(),D.unmount(),oe(),delete n._tippy,D.state.isDestroyed=!0,$("onDestroy",[D]))}}function sn(n,t){t===void 0&&(t={});var e=yr.plugins.concat(t.plugins||[]);R1();var i=Object.assign({},t,{plugins:e}),s=E1(n),o=s.reduce(function(c,d){var f=d&&$1(d,i);return f&&c.push(f),c},[]);return vo(n)?o[0]:o}sn.defaultProps=yr,sn.setDefaultProps=x1,sn.currentInput=xr,Object.assign({},su,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),sn.setDefaultProps({render:$u});const F1=5;class N1{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wi(),this._controls=wi(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,s,o,c;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<=g+v))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:g})=>d>=g-F1&&d<g))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=$d((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var b;const E=d-f.start+(((b=f.videoMeta)==null?void 0:b.start)??0);return g&&v&&E>=to(g)&&E<=to(v)}))==null?void 0:c.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Si(this._canvas)}controls(){return Si(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,s;const{start:o,duration:c,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:b}=d,{start:E,duration:k}=f,w=this.host.videoState[g];b&&w&&(b.currentTime>=E+k||b.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,b.currentTime):w.initialised||(i=b.startLoadOnce)==null||i.call(b)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((s=v==null?void 0:v.buffered)!=null&&s.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+c)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:s}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(s&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&o.initialised)return s.play()}else s.paused||s.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}class nn extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}function U1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Fu={exports:{}};(function(n,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var b=d.parseURL(p);if(!b)throw new Error("Error trying to parse relative URL.");if(b.scheme)return g.alwaysNormalize?(b.path=d.normalizePath(b.path),d.buildURLFromParts(b)):p;var E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var k=s.exec(E.path);E.netLoc=k[1],E.path=k[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:b.netLoc,path:null,params:b.params,query:b.query,fragment:b.fragment};if(!b.netLoc&&(w.netLoc=E.netLoc,b.path[0]!=="/"))if(!b.path)w.path=E.path,b.params||(w.params=E.params,b.query||(w.query=E.query));else{var L=E.path,x=L.substring(0,L.lastIndexOf("/")+1)+b.path;w.path=d.normalizePath(x)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(b.path):b.path),d.buildURLFromParts(w)},parseURL:function(f){var p=i.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(c,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};n.exports=d})()})(Fu);var sc=Fu.exports;function Nu(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Hi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Nu(Object(e),!0).forEach(function(i){B1(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Nu(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function B1(n,t,e){return t=V1(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function ai(){return ai=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},ai.apply(this,arguments)}function G1(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function V1(n){var t=G1(n,"string");return typeof t=="symbol"?t:String(t)}const jt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)};let R=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n}({}),qt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),ut=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const an=function(){},nc={trace:an,debug:an,log:an,warn:an,info:an,error:an};let Ta=nc;function H1(n){const t=self.console[n];return t?t.bind(self.console,`[${n}] >`):an}function W1(n,...t){t.forEach(function(e){Ta[e]=n[e]?n[e].bind(n):H1(e)})}function j1(n,t){if(self.console&&n===!0||typeof n=="object"){W1(n,"debug","log","info","warn","error");try{Ta.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{Ta=nc}}else Ta=nc}const z=Ta,K1=/^(\d+)x(\d+)$/,Uu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ze{constructor(t){typeof t=="string"&&(t=ze.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let s=0;s<e.length/2;s++)i[s]=parseInt(e.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=K1.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},s='"';for(Uu.lastIndex=0;(e=Uu.exec(t))!==null;){let o=e[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function Y1(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function z1(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class Bu{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){z.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=ai(new ze({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);jt(i.getTime())&&(this._endDate=i)}}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 t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(jt(t))return t}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&&jt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class bo{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 Ce={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Gu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ce.AUDIO]:null,[Ce.VIDEO]:null,[Ce.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),s=[];i.length===1?s[0]=e?e.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}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=sc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class ac extends Gu{constructor(t,e){super(e),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 bo,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!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 i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!jt(this.programDateTime))return null;const t=jt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,s,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:o,partial:c};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,s),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Ce.AUDIO]=null,t[Ce.VIDEO]=null,t[Ce.AUDIOVIDEO]=null}}class Z1 extends Gu{constructor(t,e,i,s,o){super(i),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 bo,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const X1=10;class q1{constructor(t){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=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?jt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||X1}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.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 t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function oc(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function Q1(n){const t=Vu(n).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function J1(n){const t=function(e,i,s){const o=e[i];e[i]=e[s],e[s]=o};t(n,0,3),t(n,1,2),t(n,4,5),t(n,6,7)}function tv(n){const t=n.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const o=s[0]==="base64",c=s[1];o?(i.splice(-1,1),e=oc(c)):e=Q1(c)}}return e}function Vu(n){return Uint8Array.from(unescape(encodeURIComponent(n)),t=>t.charCodeAt(0))}var Ze={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Wi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Hu(n){switch(n){case Wi.FAIRPLAY:return Ze.FAIRPLAY;case Wi.PLAYREADY:return Ze.PLAYREADY;case Wi.WIDEVINE:return Ze.WIDEVINE;case Wi.CLEARKEY:return Ze.CLEARKEY}}var Wu={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function ev(n){if(n===Wu.WIDEVINE)return Ze.WIDEVINE}function ju(n){switch(n){case Ze.FAIRPLAY:return Wi.FAIRPLAY;case Ze.PLAYREADY:return Wi.PLAYREADY;case Ze.WIDEVINE:return Wi.WIDEVINE;case Ze.CLEARKEY:return Wi.CLEARKEY}}function lc(n){const{drmSystems:t,widevineLicenseUrl:e}=n,i=t?[Ze.FAIRPLAY,Ze.WIDEVINE,Ze.PLAYREADY,Ze.CLEARKEY].filter(s=>!!t[s]):[];return!i[Ze.WIDEVINE]&&e&&i.push(Ze.WIDEVINE),i}const Ku=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function iv(n,t,e,i){let s;switch(n){case Ze.FAIRPLAY:s=["cenc","sinf"];break;case Ze.WIDEVINE:case Ze.PLAYREADY:s=["cenc"];break;case Ze.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return rv(s,t,e,i)}function rv(n,t,e,i){return[{initDataTypes:n,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function on(n,t,e){return Uint8Array.prototype.slice?n.slice(t,e):new Uint8Array(Array.prototype.slice.call(n,t,e))}const cc=(n,t)=>t+10<=n.length&&n[t]===73&&n[t+1]===68&&n[t+2]===51&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,Yu=(n,t)=>t+10<=n.length&&n[t]===51&&n[t+1]===68&&n[t+2]===73&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,Ao=(n,t)=>{const e=t;let i=0;for(;cc(n,t);){i+=10;const s=Eo(n,t+6);i+=s,Yu(n,t+10)&&(i+=10),t+=i}if(i>0)return n.subarray(e,e+i)},Eo=(n,t)=>{let e=0;return e=(n[t]&127)<<21,e|=(n[t+1]&127)<<14,e|=(n[t+2]&127)<<7,e|=n[t+3]&127,e},sv=(n,t)=>cc(n,t)&&Eo(n,t+6)+10<=n.length-t,nv=n=>{const t=Zu(n);for(let e=0;e<t.length;e++){const i=t[e];if(zu(i))return dv(i)}},zu=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",av=n=>{const t=String.fromCharCode(n[0],n[1],n[2],n[3]),e=Eo(n,4),i=10;return{type:t,size:e,data:n.subarray(i,i+e)}},Zu=n=>{let t=0;const e=[];for(;cc(n,t);){const i=Eo(n,t+6);t+=10;const s=t+i;for(;t+8<s;){const o=av(n.subarray(t)),c=ov(o);c&&e.push(c),t+=o.size+10}Yu(n,t)&&(t+=10)}return e},ov=n=>n.type==="PRIV"?lv(n):n.type[0]==="W"?hv(n):cv(n),lv=n=>{if(n.size<2)return;const t=Pr(n.data,!0),e=new Uint8Array(n.data.subarray(t.length+1));return{key:n.type,info:t,data:e.buffer}},cv=n=>{if(n.size<2)return;if(n.type==="TXXX"){let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data.subarray(1));return{key:n.type,data:t}},hv=n=>{if(n.type==="WXXX"){if(n.size<2)return;let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data);return{key:n.type,data:t}},dv=n=>{if(n.data.byteLength===8){const t=new Uint8Array(n.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},Pr=(n,t=!1)=>{const e=uv();if(e){const p=e.decode(n);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=n.length;let s,o,c,d="",f=0;for(;f<i;){if(s=n[f++],s===0&&t)return d;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(s);break;case 12:case 13:o=n[f++],d+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=n[f++],c=n[f++],d+=String.fromCharCode((s&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let hc;function uv(){return!hc&&typeof self.TextDecoder<"u"&&(hc=new self.TextDecoder("utf-8")),hc}const Or={hexDump:function(n){let t="";for(let e=0;e<n.length;e++){let i=n[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},ko=Math.pow(2,32)-1,fv=[].push,Xu={video:1,audio:2,id3:3,text:4};function bi(n){return String.fromCharCode.apply(null,n)}function qu(n,t){const e=n[t]<<8|n[t+1];return e<0?65536+e:e}function ee(n,t){const e=Qu(n,t);return e<0?4294967296+e:e}function Qu(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function dc(n,t,e){n[t]=e>>24,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255}function be(n,t){const e=[];if(!t.length)return e;const i=n.byteLength;for(let s=0;s<i;){const o=ee(n,s),c=bi(n.subarray(s+4,s+8)),d=o>1?s+o:i;if(c===t[0])if(t.length===1)e.push(n.subarray(s+8,d));else{const f=be(n.subarray(s+8,d),t.slice(1));f.length&&fv.apply(e,f)}s=d}return e}function pv(n){const t=[],e=n[0];let i=8;const s=ee(n,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=n.length+c;const f=qu(n,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(n,g);g+=4;const b=v&2147483647;if((v&2147483648)>>>31===1)return z.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(n,g);g+=4,t.push({referenceSize:b,subsegmentDuration:E,info:{duration:E/s,start:d,end:d+b-1}}),d+=b,g+=4,i=g}return{earliestPresentationTime:o,timescale:s,version:e,referencesCount:f,references:t}}function Ju(n){const t=[],e=be(n,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],o=be(s,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ee(o,d),p=be(s,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ee(p,d),v=be(s,["mdia","hdlr"])[0];if(v){const b=bi(v.subarray(8,12)),E={soun:Ce.AUDIO,vide:Ce.VIDEO}[b];if(E){const k=be(s,["mdia","minf","stbl","stsd"])[0];let w;k&&(w=bi(k.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return be(n,["moov","mvex","trex"]).forEach(i=>{const s=ee(i,4),o=t[s];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function gv(n,t){if(!n||!t)return n;const e=t.keyId;return e&&t.isCommonEncryption&&be(n,["moov","trak"]).forEach(i=>{const s=be(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=be(s,["enca"]);const c=o.length>0;c||(o=be(s,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);be(f,["sinf"]).forEach(p=>{const g=t0(p);if(g){const v=g.subarray(8,24);v.some(b=>b!==0)||(z.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Or.hexDump(v)} -> ${Or.hexDump(e)}`),g.set(e,8))}})})}),n}function t0(n){const t=be(n,["schm"])[0];if(t){const e=bi(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return be(n,["schi","tenc"])[0]}return z.error("[eme] missing 'schm' box"),null}function mv(n,t){return be(t,["moof","traf"]).reduce((e,i)=>{const s=be(i,["tfdt"])[0],o=s[0],c=be(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=n[p];if(g){let v=ee(s,4);if(o===1){if(v===ko)return z.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=ko+1,v+=ee(s,8)}const b=g.timescale||9e4,E=v/b;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return c!==null&&isFinite(c)&&(e===null||c<e)?c:e},null)}function vv(n,t){let e=0,i=0,s=0;const o=be(n,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=be(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,b=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;b&8&&(b&2?E=ee(f,12):E=ee(f,8));const k=g.timescale||9e4,w=be(d,["trun"]);for(let L=0;L<w.length;L++){if(e=yv(w[L]),!e&&E){const x=ee(w[L],4);e=E*x}g.type===Ce.VIDEO?i+=e/k:g.type===Ce.AUDIO&&(s+=e/k)}}if(i===0&&s===0){let c=0;const d=be(n,["sidx"]);for(let f=0;f<d.length;f++){const p=pv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||s}function yv(n){const t=ee(n,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=ee(n,4);for(let o=0;o<s;o++){if(t&256){const c=ee(n,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function bv(n,t,e){be(t,["moof","traf"]).forEach(i=>{be(i,["tfhd"]).forEach(s=>{const o=ee(s,4),c=n[o];if(!c)return;const d=c.timescale||9e4;be(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),dc(f,4,g);else{g*=Math.pow(2,32),g+=ee(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(ko+1)),b=Math.floor(g%(ko+1));dc(f,4,v),dc(f,8,b)}})})})}function Av(n){const t={valid:null,remainder:null},e=be(n,["moof"]);if(e){if(e.length<2)return t.remainder=n,t}else return t;const i=e[e.length-1];return t.valid=on(n,0,i.byteOffset-8),t.remainder=on(n,i.byteOffset-8),t}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function e0(n,t){const e=[],i=t.samples,s=t.timescale,o=t.id;let c=!1;return be(i,["moof"]).map(d=>{const f=d.byteOffset-8;be(d,["traf"]).map(p=>{const g=be(p,["tfdt"]).map(v=>{const b=v[0];let E=ee(v,4);return b===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/s})[0];return g!==void 0&&(n=g),be(p,["tfhd"]).map(v=>{const b=ee(v,4),E=ee(v,0)&16777215,k=(E&1)!==0,w=(E&2)!==0,L=(E&8)!==0;let x=0;const M=(E&16)!==0;let N=0;const D=(E&32)!==0;let F=8;b===o&&(k&&(F+=8),w&&(F+=4),L&&(x=ee(v,F),F+=4),M&&(N=ee(v,F),F+=4),D&&(F+=4),t.type==="video"&&(c=Ev(t.codec)),be(p,["trun"]).map(H=>{const j=H[0],st=ee(H,0)&16777215,at=(st&1)!==0;let Q=0;const kt=(st&4)!==0,gt=(st&256)!==0;let Ft=0;const Kt=(st&512)!==0;let V=0;const J=(st&1024)!==0,St=(st&2048)!==0;let $=0;const U=ee(H,4);let Z=8;at&&(Q=ee(H,Z),Z+=4),kt&&(Z+=4);let mt=Q+f;for(let bt=0;bt<U;bt++){if(gt?(Ft=ee(H,Z),Z+=4):Ft=x,Kt?(V=ee(H,Z),Z+=4):V=N,J&&(Z+=4),St&&(j===0?$=ee(H,Z):$=Qu(H,Z),Z+=4),t.type===Ce.VIDEO){let Dt=0;for(;Dt<V;){const Ut=ee(i,mt);if(mt+=4,kv(c,i[mt])){const Qt=i.subarray(mt,mt+Ut);i0(Qt,c?2:1,n+$/s,e)}mt+=Ut,Dt+=Ut+4}}n+=Ft/s}}))})})}),e}function Ev(n){if(!n)return!1;const t=n.indexOf("."),e=t<0?n:n.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function kv(n,t){if(n){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function i0(n,t,e,i){const s=r0(n);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<s.length;){c=0;do{if(o>=s.length)break;p=s[o++],c+=p}while(p===255);d=0;do{if(o>=s.length)break;p=s[o++],d+=p}while(p===255);const g=s.length-o;if(!f&&c===4&&o<s.length){if(f=!0,s[o++]===181){const v=qu(s,o);if(o+=2,v===49){const b=ee(s,o);if(o+=4,b===1195456820){const E=s[o++];if(E===3){const k=s[o++],w=31&k,L=64&k,x=L?2+w*3:0,M=new Uint8Array(x);if(L){M[0]=k;for(let N=1;N<x;N++)M[N]=s[o++]}i.push({type:E,payloadType:c,pts:e,bytes:M})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let k=0;k<16;k++){const w=s[o++].toString(16);v.push(w.length==1?"0"+w:w),(k===3||k===5||k===7||k===9)&&v.push("-")}const b=d-16,E=new Uint8Array(b);for(let k=0;k<b;k++)E[k]=s[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:Pr(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function r0(n){const t=n.byteLength,e=[];let i=1;for(;i<t-2;)n[i]===0&&n[i+1]===0&&n[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return n;const s=t-e.length,o=new Uint8Array(s);let c=0;for(i=0;i<s;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=n[c];return o}function Tv(n){const t=n[0];let e="",i="",s=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1,s=ee(n,12),o=ee(n,16),d=ee(n,20),f=ee(n,24),p=28}else if(t===1){p+=4,s=ee(n,p),p+=4;const v=ee(n,p);p+=4;const b=ee(n,p);for(p+=4,c=4294967296*v+b,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,z.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(n,p),p+=4,f=ee(n,p),p+=4;bi(n.subarray(p,p+1))!=="\0";)e+=bi(n.subarray(p,p+1)),p+=1;for(e+=bi(n.subarray(p,p+1)),p+=1;bi(n.subarray(p,p+1))!=="\0";)i+=bi(n.subarray(p,p+1)),p+=1;i+=bi(n.subarray(p,p+1)),p+=1}const g=n.subarray(p,n.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function wv(n,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(n,4),s=0,i=8;s<e;s++)o.set(t[s],i),i+=t[s].byteLength;return o}function Sv(n,t,e){if(n.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");s.set(f,d*16)}}else i=0,s=new Uint8Array;let o;i>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),wv([112,115,115,104],new Uint8Array([i,0,0,0]),n,o,s,c,e||new Uint8Array)}function Rv(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(n),i=e.getUint32(0);if(n.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Or.hexDump(new Uint8Array(n,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(n,32,s)}else if(t.version===1){t.kids=[];for(let o=0;o<s;o++)t.kids.push(new Uint8Array(n,32+o*16,16))}return t}let To={};class wa{static clearKeyUriToKeyIdMap(){To={}}constructor(t,e,i,s=[1],o=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=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Wi.FAIRPLAY:case Wi.WIDEVINE:case Wi.PLAYREADY:case Wi.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&z.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=Lv(t);return new wa(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=tv(this.uri);if(e)switch(this.keyFormat){case Wi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case Wi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Sv(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),c=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=oc(f).subarray(0,16);J1(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=To[this.uri];if(!i){const s=Object.keys(To).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),To[this.uri]=i}this.keyId=i}return this}}function Lv(n){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=n>>8*(15-e)&255;return t}const s0=/\{\$([a-zA-Z0-9-_]+)\}/g;function n0(n){return s0.test(n)}function ji(n,t,e){if(n.variableList!==null||n.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],o=t[s];o&&(t[s]=uc(n,o))}}function uc(n,t){if(n.variableList!==null||n.hasVariableRefs){const e=n.variableList;return t.replace(s0,i=>{const s=i.substring(2,i.length-1),o=e==null?void 0:e[s];return o===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):o})}return t}function a0(n,t,e){let i=n.variableList;i||(n.variableList=i={});let s,o;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(s))o=c.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(c){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else s=t.NAME,o=t.VALUE;s in i?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=o||""}function _v(n,t,e){const i=t.IMPORT;if(e&&i in e){let s=n.variableList;s||(n.variableList=s={}),s[i]=e[i]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function wo(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Cv={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},o0=wo();function Iv(n,t){const e=Cv[t];return!!e&&e[n.slice(0,4)]===!0}function fc(n,t){var e;return(e=o0==null?void 0:o0.isTypeSupported(`${t||"video"}/mp4;codecs="${n}"`))!=null?e:!1}const l0=/#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,c0=/#EXT-X-MEDIA:(.*)/g,Dv=/^#EXT(?:INF|-X-TARGETDURATION):/m,h0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),xv=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)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class br{static findGroup(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.id===e)return s}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return sc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Dv.test(t)}static parseMasterPlaylist(t,e){const i=n0(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];l0.lastIndex=0;let c;for(;(c=l0.exec(t))!=null;)if(c[1]){var d;const p=new ze(c[1]);ji(s,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=uc(s,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:br.resolve(g,e)},b=p.decimalResolution("RESOLUTION");b&&(v.width=b.width,v.height=b.height),Pv((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=br.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),s.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ze(g);ji(s,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const b=v["DATA-ID"];b&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[b]=v);break}case"SESSION-KEY":{const v=d0(g,e,s);v.encrypted&&v.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(v)):z.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ze(g);ji(s,v,["NAME","VALUE","QUERYPARAM"]),a0(s,v,e)}break}case"CONTENT-STEERING":{const v=new ze(g);ji(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:br.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=u0(g);break}}}const f=o.length>0&&o.length<s.levels.length;return s.levels=f?o:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const o={},c=i.levels,d={AUDIO:c.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:c.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(c0.lastIndex=0;(s=c0.exec(t))!==null;){const p=new ze(s[1]),g=p.TYPE;if(g){const v=d[g],b=o[g]||[];o[g]=b,ji(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const E={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?br.resolve(p.URI,e):""};if(v!=null&&v.length){const k=br.findGroup(v,E.groupId)||v[0];f0(E,k,"audioCodec"),f0(E,k,"textCodec")}b.push(E)}}return o}static parseLevelPlaylist(t,e,i,s,o,c){const d=new q1(e),f=d.fragments;let p=null,g=0,v=0,b=0,E=0,k=null,w=new ac(s,e),L,x,M,N=-1,D=!1;for(h0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=n0(t);(L=h0.exec(t))!==null;){D&&(D=!1,w=new ac(s,e),w.start=b,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const st=L[1];if(st){w.duration=parseFloat(st);const at=(" "+L[2]).slice(1);w.title=at||null,w.tagList.push(at?["INF",st,at]:["INF",st])}else if(L[3]){if(jt(w.duration)){w.start=b,M&&m0(w,M,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const at=(" "+L[3]).slice(1);w.relurl=uc(d,at),p0(w,k),k=w,b+=w.duration,g++,v=0,D=!0}}else if(L[4]){const at=(" "+L[4]).slice(1);k?w.setByteRange(at,k):w.setByteRange(at)}else if(L[5])w.rawProgramDateTime=(" "+L[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),N===-1&&(N=f.length);else{if(L=L[0].match(xv),!L){z.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<L.length&&!(typeof L[x]<"u");x++);const at=(" "+L[x]).slice(1),Q=(" "+L[x+1]).slice(1),kt=L[x+2]?(" "+L[x+2]).slice(1):"";switch(at){case"PLAYLIST-TYPE":d.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(Q);break;case"SKIP":{const gt=new ze(Q);ji(d,gt,["RECENTLY-REMOVED-DATERANGES"]);const Ft=gt.decimalInteger("SKIPPED-SEGMENTS");if(jt(Ft)){d.skippedSegments=Ft;for(let V=Ft;V--;)f.unshift(null);g+=Ft}const Kt=gt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Kt&&(d.recentlyRemovedDateranges=Kt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":d.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(Q||kt)&&w.tagList.push(kt?[Q,kt]:[Q]);break;case"DISCONTINUITY":E++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([at]);break;case"BITRATE":w.tagList.push([at,Q]);break;case"DATERANGE":{const gt=new ze(Q);ji(d,gt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ji(d,gt,gt.clientAttrs);const Ft=new Bu(gt,d.dateRanges[gt.ID]);Ft.isValid||d.skippedSegments?d.dateRanges[Ft.id]=Ft:z.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),w.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const gt=new ze(Q);ji(d,gt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in gt?_v(d,gt,c):a0(d,gt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(Q);break;case"KEY":{const gt=d0(Q,e,d);if(gt.isSupported()){if(gt.method==="NONE"){M=void 0;break}M||(M={}),M[gt.keyFormat]&&(M=ai({},M)),M[gt.keyFormat]=gt}else z.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":d.startTimeOffset=u0(Q);break;case"MAP":{const gt=new ze(Q);if(ji(d,gt,["BYTERANGE","URI"]),w.duration){const Ft=new ac(s,e);g0(Ft,gt,i,M),p=Ft,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else g0(w,gt,i,M),p=w,D=!0;break}case"SERVER-CONTROL":{const gt=new ze(Q);d.canBlockReload=gt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=gt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&gt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=gt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=gt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const gt=new ze(Q);d.partTarget=gt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let gt=d.partList;gt||(gt=d.partList=[]);const Ft=v>0?gt[gt.length-1]:void 0,Kt=v++,V=new ze(Q);ji(d,V,["BYTERANGE","URI"]);const J=new Z1(V,w,e,Kt,Ft);gt.push(J),w.duration+=J.duration;break}case"PRELOAD-HINT":{const gt=new ze(Q);ji(d,gt,["URI"]),d.preloadHint=gt;break}case"RENDITION-REPORT":{const gt=new ze(Q);ji(d,gt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(gt);break}default:z.warn(`line parsed but not handled: ${L}`);break}}}k&&!k.relurl?(f.pop(),b-=k.duration,d.partList&&(d.fragmentHint=k)):d.partList&&(p0(w,k),w.cc=E,d.fragmentHint=w,M&&m0(w,M,d));const F=f.length,H=f[0],j=f[F-1];if(b+=d.skippedSegments*d.targetduration,b>0&&F&&j){d.averagetargetduration=b/F;const st=j.sn;d.endSN=st!=="initSegment"?st:0,d.live||(j.endList=!0),H&&(d.startCC=H.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(b+=d.fragmentHint.duration),d.totalduration=b,d.endCC=E,N>0&&Ov(f,N),d}}function d0(n,t,e){var i,s;const o=new ze(n);ji(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const c=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(s=o.KEYFORMAT)!=null?s:"identity";d&&o.IV&&!f&&z.error(`Invalid IV: ${o.IV}`);const v=d?br.resolve(d,t):"",b=(p||"1").split("/").map(Number).filter(Number.isFinite);return new wa(c,v,g,b,f)}function u0(n){const t=new ze(n).decimalFloatingPoint("TIME-OFFSET");return jt(t)?t:null}function Pv(n,t){["video","audio","text"].forEach(e=>{const i=n.filter(s=>Iv(s,e));if(i.length){const s=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],n=n.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=n}function f0(n,t,e){const i=t[e];i&&(n[e]=i)}function Ov(n,t){let e=n[t];for(let i=t;i--;){const s=n[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function p0(n,t){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):t!=null&&t.programDateTime&&(n.programDateTime=t.endProgramDateTime),jt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function g0(n,t,e,i){n.relurl=t.URI,t.BYTERANGE&&n.setByteRange(t.BYTERANGE),n.level=e,n.sn="initSegment",i&&(n.levelkeys=i),n.initSegment=null}function m0(n,t,e){n.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(n)}var ke={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function v0(n){const{type:t}=n;switch(t){case ke.AUDIO_TRACK:return Jt.AUDIO;case ke.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function pc(n,t){let e=n.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Mv{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,o=i||s,c=new o(e);return this.loaders[t.type]=c,c}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ke.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:o,deliveryDirectives:c}=e;this.load({id:i,level:s,responseType:"text",type:ke.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:ke.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:ke.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const p=s.context;if(p&&p.url===t.url){z.trace("[playlist-loader]: playlist request ongoing");return}z.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let o;if(t.type===ke.MANIFEST?o=i.manifestLoadPolicy.default:o=ai({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===ke.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===ke.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===ke.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const b=Math.max(g*3,v*.8)*1e3;o=ai({},o,{maxTimeToFirstByteMs:Math.min(b,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(b,o.maxTimeToFirstByteMs)})}}}const c=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},f={onSuccess:(p,g,v,b)=>{const E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const k=p.data;if(k.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),b||null,g);return}g.parsing.start=performance.now(),br.isMediaPlaylist(k)?this.handleTrackOrLevelPlaylist(p,g,v,b||null,E):this.handleMasterPlaylist(p,g,v,b)},onError:(p,g,v,b)=>{this.handleNetworkError(g,v,!1,p,b)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};s.load(t,d,f)}handleMasterPlaylist(t,e,i,s){const o=this.hls,c=t.data,d=pc(t,i),f=br.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,s,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:k}=f;this.variableList=k;const{AUDIO:w=[],SUBTITLES:L,"CLOSED-CAPTIONS":x}=br.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(M=>!M.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(z.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ze({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:L,captions:x,contentSteering:p,url:d,stats:e,networkDetails:s,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:k})}handleTrackOrLevelPlaylist(t,e,i,s,o){const c=this.hls,{id:d,level:f,type:p}=i,g=pc(t,i),v=jt(d)?d:0,b=jt(f)?f:v,E=v0(i),k=br.parseLevelPlaylist(t.data,g,b,E,v,this.variableList);if(p===ke.MANIFEST){const w={attrs:new ze({}),bitrate:0,details:k,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=k,this.handlePlaylistLoaded(k,t,e,i,s,o)}handleManifestParsingError(t,e,i,s,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===ke.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:o})}handleNetworkError(t,e,i=!1,s,o){let c=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===ke.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===ke.AUDIO_TRACK||t.type===ke.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);z.warn(`[playlist-loader]: ${c}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case ke.MANIFEST:f=i?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case ke.LEVEL:f=i?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case ke.AUDIO_TRACK:f=i?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case ke.SUBTITLE_TRACK:f=i?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(s){const b=(e==null?void 0:e.url)||t.url;v.response=Hi({url:b,data:void 0},s)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,s,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:b}=s,E=pc(e,s),k=v0(s),w=typeof s.level=="number"&&k===Jt.MAIN?p:void 0;if(!t.fragments.length){const x=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:x,reason:x.message,response:e,context:s,level:w,parent:k,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const L=t.playlistParsingError;if(L){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:L,reason:L.message,response:e,context:s,level:w,parent:k,networkDetails:o,stats:i});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case ke.MANIFEST:case ke.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:b});break;case ke.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break;case ke.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break}}}function y0(n,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=n,t.dispatchEvent(e)}function b0(n,t){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(t.id))try{if(n.addCue(t),!n.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){z.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,n.addCue(s)}catch(s){z.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(n.mode=e)}function Rn(n){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let e=n.cues.length;e--;)n.removeCue(n.cues[e]);t==="disabled"&&(n.mode=t)}function gc(n,t,e,i){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const o=Fv(n.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&n.removeCue(o[c])}s==="disabled"&&(n.mode=s)}function $v(n,t){if(t<n[0].startTime)return 0;const e=n.length-1;if(t>n[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const o=Math.floor((s+i)/2);if(t<n[o].startTime)s=o-1;else if(t>n[o].startTime&&i<e)i=o+1;else return o}return n[i].startTime-t<t-n[s].startTime?i:s}function Fv(n,t,e){const i=[],s=$v(n,t);if(s>-1)for(let o=s,c=n.length;o<c;o++){const d=n[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Ar={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Nv=.25;function mc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const So=(()=>{const n=mc();try{new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function vc(n,t){return n.getTime()/1e3-t}function Uv(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Bv{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Rn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return y0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=mc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Ar.emsg&&!i||!s)continue;const p=Zu(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>So&&(v=So),v-g<=0&&(v=g+Nv);for(let b=0;b<p.length;b++){const E=p[b];if(!zu(E)){this.updateId3CueEnds(g,f);const k=new c(g,v,"");k.value=E,f&&(k.type=f),this.id3Track.addCue(k)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let o=s.length;o--;){const c=s[o];c.type===e&&c.startTime<t&&c.endTime===So&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;s==="audio"?p=g=>g.type===Ar.audioId3&&f:s==="video"?p=g=>g.type===Ar.emsg&&d:p=g=>g.type===Ar.audioId3&&f||g.type===Ar.emsg&&d,gc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:o}=e,c=Object.keys(o);if(s){const g=Object.keys(i).filter(v=>!c.includes(v));for(let v=g.length;v--;){const b=g[v];Object.keys(i[b].cues).forEach(E=>{s.removeCue(i[b].cues[E])}),delete i[b]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!jt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=mc();for(let g=0;g<c.length;g++){const v=c[g],b=o[v],E=i[v],k=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const L=vc(b.startDate,f);let x=So;const M=b.endDate;if(M)x=vc(M,f),w=!0;else if(b.endOnNext&&!w){const D=c.reduce((F,H)=>{const j=o[H];return j.class===b.class&&j.id!==H&&j.startDate>b.startDate&&F.push(j),F},[]).sort((F,H)=>F.startDate.getTime()-H.startDate.getTime())[0];D&&(x=vc(D.startDate,f),w=!0)}const N=Object.keys(b.attr);for(let D=0;D<N.length;D++){const F=N[D];if(!Y1(F))continue;let H=k[F];if(H)w&&!E.durationKnown&&(H.endTime=x);else{let j=b.attr[F];H=new p(L,x,""),z1(F)&&(j=Uv(j)),H.value={key:F,data:j},H.type=Ar.dateRange,H.id=v,this.id3Track.addCue(H),k[F]=H}}i[v]={cues:k,dateRange:b,durationKnown:w}}}}class Gv{constructor(t){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=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:o,liveSyncDurationCount:c,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:c*s);const g=s,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const s=i.edge,o=t-e-this.edgeStalled,c=s-i.totalduration,d=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(c,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&z.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:o}=this.config;if(!s||o===1)return;const c=this.targetLatency;if(c===null)return;const d=i-c,f=Math.min(this.maxLatency,c+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const yc=["NONE","TYPE-0","TYPE-1",null];var Sa={No:"",Yes:"YES",v2:"v2"};function Vv(n,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=n,o=t!==void 0?t-s:0;return e&&o<e?i?Sa.v2:Sa.Yes:Sa.No}class A0{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Ra{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function bc(n,t){const e=t.startPTS;if(jt(e)){let i=0,s;t.sn>n.sn?(i=e-n.start,s=n):(i=n.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>n.sn?n.cc===t.cc&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration:t.start=Math.max(n.start-t.duration,0)}function E0(n,t,e,i,s,o){i-e<=0&&(z.warn("Fragment should have a positive duration",t),i=e+t.duration,o=s+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(jt(f)){const w=Math.abs(f-e);jt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),s=Math.min(s,t.startDTS),d=Math.min(i,p),i=Math.max(i,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=c,t.startDTS=s,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!n||v<n.startSN||v>n.endSN)return 0;let b;const E=v-n.startSN,k=n.fragments;for(k[E]=t,b=E;b>0;b--)bc(k[b],k[b-1]);for(b=E;b<k.length-1;b++)bc(k[b],k[b+1]);return n.fragmentHint&&bc(k[k.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,g}function Hv(n,t){let e=null;const i=n.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,o;if(Kv(n,t,(f,p)=>{f.relurl&&(s=f.cc-p.cc),jt(f.startPTS)&&jt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){z.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=Wv(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(s){z.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),jv(n.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?E0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):k0(n,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function Wv(n,t,e){const i=ai({},n);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const o=new Bu(t[s].attr,i[s]);o.isValid?i[s]=o:z.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function jv(n,t,e){if(n&&t){let i=0;for(let s=0,o=n.length;s<=o;s++){const c=n[s],d=t[s+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function Kv(n,t,e){const i=t.skippedSegments,s=Math.max(n.startSN,t.startSN)-t.startSN,o=(n.fragmentHint?1:0)+(i?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let p=s;p<=o;p++){const g=f[c+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function k0(n,t){const e=t.startSN+t.skippedSegments-n.startSN,i=n.fragments;e<0||e>=i.length||Ac(t,i[e].start)}function Ac(n,t){if(t){const e=n.fragments;for(let i=n.skippedSegments;i<e.length;i++)e[i].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function Yv(n,t=1/0){let e=1e3*n.targetduration;if(n.updated){const i=n.fragments,s=4;if(i.length&&e*s>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function zv(n,t,e){if(!(n!=null&&n.details))return null;const i=n.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t)?s:t<i.startSN&&e&&e.sn===t?e:null}function T0(n,t,e){var i;return n!=null&&n.details?w0((i=n.details)==null?void 0:i.partList,t,e):null}function w0(n,t,e){if(n)for(let i=n.length;i--;){const s=n[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function Ro(n){switch(n.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function S0(n,t){const e=Ro(t);return n.default[`${e?"timeout":"error"}Retry`]}function Ec(n,t){const e=n.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function R0(n){return Hi(Hi({},n),{errorRetry:null,timeoutRetry:null})}function Lo(n,t,e,i){return!!n&&t<n.maxNumRetry&&(Zv(i)||!!e)}function Zv(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const L0={search:function(n,t){let e=0,i=n.length-1,s=null,o=null;for(;e<=i;){s=(e+i)/2|0,o=n[s];const c=t(o);if(c>0)e=s+1;else if(c<0)i=s-1;else return o}return null}};function Xv(n,t,e){if(t===null||!Array.isArray(n)||!n.length||!jt(t))return null;const i=n[0].programDateTime;if(t<(i||0))return null;const s=n[n.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let o=0;o<n.length;++o){const c=n[o];if(qv(t,e,c))return c}return null}function La(n,t,e=0,i=0){let s=null;if(n?s=t[n.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&kc(e,i,s)===0)return s;const o=L0.search(t,kc.bind(null,e,i));return o&&(o!==n||!s)?o:s}function kc(n=0,t=0,e){if(e.start<=n&&e.start+e.duration>n)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=n?1:e.start-i>n&&e.start?-1:0}function qv(n,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>n}function Qv(n,t){return L0.search(n,e=>e.cc<t?1:e.cc>t?-1:0)}const Jv=3e5;var Ri={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},cr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class ty{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=z.log.bind(z,"[info]:"),this.warn=z.warn.bind(z,"[warning]:"),this.error=z.error.bind(z,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Jt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,s;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ri.DoNothing,flags:cr.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ri.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===ke.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===ke.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ri.SendAlternateToPenaltyBox,e.errorAction.flags=cr.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ri.DoNothing,flags:cr.None};return}if(e.type===qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,o=S0(s.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Lo(o,c,Ro(t),d))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:o,retryCount:c};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=c),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=S0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,b)=>v+b.fragmentError,0);if(s){var p;t.details!==ut.FRAG_GAP&&s.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Lo(d,f,Ro(t),v))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,i);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const s=this.hls.levels[e];if(s&&(s.loadError++,i.autoLevelEnabled)){var o,c;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,b=(o=t.frag)==null?void 0:o.type,{type:E,groupId:k}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const L=(w+p)%f.length;if(L!==p&&L>=g&&L<=v&&f[L].loadError===0){const x=f[L];if(t.details===ut.FRAG_GAP&&t.frag){const M=f[L].details;if(M){const N=La(t.frag,M.fragments,t.frag.start);if(N!=null&&N.gap)continue}}else if(E===ke.AUDIO_TRACK&&k===x.audioGroupId||E===ke.SUBTITLE_TRACK&&k===x.textGroupId||b===Jt.AUDIO&&s.audioGroupId===x.audioGroupId||b===Jt.SUBTITLE&&s.textGroupId===x.textGroupId)continue;d=L;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ri.SendAlternateToPenaltyBox,flags:cr.None,nextAutoLevel:d}}return{action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ri.DoNothing:break;case Ri.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:o,nextAutoLevel:c}=i;switch(s){case cr.None:this.switchLevel(t,c);break;case cr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case cr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=yc[yc.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,c)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,s=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[s],c=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<c;f++){const p=(d+f)%c,g=i[p];if(!g||ey(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${c}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,s=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(e),s.details=t.details,i[t.urlId]=s}}function ey(n,t,e){if(performance.now()-n.lastErrorPerfMs>Jv)return!0;const i=n.details;if(t.details===ut.FRAG_GAP&&i&&t.frag){const s=t.frag.start,o=La(null,i.fragments,s);if(o&&!o.gap)return!0}if(e&&n.errors.length<e.errors.length){const s=n.errors[n.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Tc{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=z.log.bind(z,`${e}:`),this.warn=z.warn.bind(z,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let s=-1;for(let o=0;o<i.length;o++){const c=i[o];let d;try{d=new self.URL(c.URI,e.url).href}catch(f){z.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){s=o;break}else d===t.substring(0,d.length)&&(s=o)}if(s!==-1){const o=i[s],c=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new A0(c,d>=0?d:void 0,Sa.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:s,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(s.advancedDateTime=Date.now()-d,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${t} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&Hv(i,s),!this.canLoad||!s.live)return;let f,p,g;if(s.canBlockReload&&s.endSN&&s.advanced){const L=this.hls.config.lowLatencyMode,x=s.lastPartSn,M=s.endSN,N=s.lastPartIndex,D=N!==-1,F=x===M,H=L?0:N;D?(p=F?M+1:x,g=F?H:N+1):p=M+1;const j=s.age,st=j+s.ageHeader;let at=Math.min(st-s.partTarget,s.targetduration*1.5);if(at>0){if(i&&at>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${at} with playlist age: ${s.age}`),at=0;else{const Q=Math.floor(at/s.targetduration);if(p+=Q,g!==void 0){const kt=Math.round(at%s.targetduration/s.partTarget);g+=kt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${j.toFixed(2)}s goal: ${at} skip sn ${Q} to part ${g}`)}s.tuneInGoal=at}if(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g),L||!F){this.loadPlaylist(f);return}}else(s.canBlockReload||s.canSkipUntil)&&(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,b=v?v.end-v.len:0,E=(s.edge-b)*1e3,k=Yv(s,E);s.updated&&c>this.requestScheduled+k&&(this.requestScheduled=o.loading.start),p!==void 0&&s.canBlockReload?this.requestScheduled=o.loading.first+k-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+k<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=k);let w=this.requestScheduled-c;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let o=Vv(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,o=Sa.No),new A0(i,s,o)}checkRetry(t){const e=t.details,i=Ro(t),s=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=s||{},f=!!s&&!!d&&(o===Ri.RetryRequest||!s.resolved&&o===Ri.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,c>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=Ec(d,c);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,s.resolved=!0}return f}}let wc;class iy extends Tc{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],s={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(wc||(wc=/chrome|firefox/i.test(navigator.userAgent)),wc&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":b,RESOLUTION:E,SUBTITLES:k}=f,w=`${`${b||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=s[w],o?o.addFallback(c):(o=new Ra(c),s[w]=o,i.push(o)),_o(o,"audio",p),_o(o,"text",k)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:k,width:w,height:L,unknownCodecs:x})=>(o||(o=!!(w&&L)),c||(c=!!k),d||(d=!!E),!(x!=null&&x.length)&&(!E||fc(E,"audio"))&&(!k||fc(k,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:k,height:w})=>!!E||!!(k&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const E=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||fc(E.audioCodec,"audio")),_0(i)),e.subtitles&&(s=e.subtitles,_0(s));const p=f.slice(0);f.sort((E,k)=>E.attrs["HDCP-LEVEL"]!==k.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(k.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==k.bitrate?E.bitrate-k.bitrate:E.attrs["FRAME-RATE"]!==k.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-k.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==k.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-k.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==k.height?E.height-k.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let E=0;E<p.length;E++)if(p[E].pathwayId===f[0].pathwayId){g=p[E];break}}this._levels=f;for(let E=0;E<f.length;E++)if(f[E]===g){this._firstLevel=E,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!c,b={levels:f,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:c,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&s&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ai({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=c.details;if(!p||p.live){const g=this.switchParams(c.uri,s==null?void 0:s.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===ke.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:o}=e,c=this._levels[s];if(!c){var d;this.warn(`Invalid level index ${s}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(s,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===s){o=c;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const c=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${c?" Pathway "+c:""} URI ${s+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:s,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(o,c)=>c!==e,s=this._levels.filter((o,c)=>c!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(i),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(i)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(i)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=s})}),this._levels=e}}function _o(n,t,e){e&&(t==="audio"?(n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds[n.url.length-1]=e):t==="text"&&(n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds[n.url.length-1]=e))}function _0(n){const t={};n.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var ui={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class ry{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let s=i.length;s--;){const o=i[s];if(!o)break;const c=o.end;if(o.start<=t&&c!==null&&t<=c)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let o=s.length;o--;){const c=i[s[o]];if((c==null?void 0:c.body.type)===e&&c.buffered){const d=c.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const o=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===i&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const o=Ln(i),c=this.fragments[o];if(!c||c.buffered&&i.gap)return;const d=!i.relurl;Object.keys(e).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;c.range[f]=this.getBufferedTimes(i,s,v,g)}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,(c.body.endList=i.endList||c.body.endList)&&(this.endListFragments[c.body.type]=c),Co(c)||this.removeParts(i.sn-1,i.type)):this.removeFragment(c.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(s=>s.fragment.sn>=t))}fragBuffered(t,e){const i=Ln(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<s.length;g++){const v=s.start(g)-this.bufferPadding,b=s.end(g)+this.bufferPadding;if(p>=v&&f<=b){o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});break}else if(c<b&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,s,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Co(g)&&(s=g.body.start-d,o=g.body.end+d,t>=s&&t<=o&&(i=Math.min(t-s,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Co(e))}getState(t){const e=Ln(t),i=this.fragments[e];return i?i.buffered?Co(i)?ui.PARTIAL:ui.OK:ui.APPENDING:ui.NOT_LOADED}isTimeBuffered(t,e,i){let s,o;for(let c=0;c<i.length;c++){if(s=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=s&&e<=o)return!0;if(e<=s)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:s}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=s?null:e,c=Ln(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(s){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(s)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Ln(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,o){s&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||s&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=Ln(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const s=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==s)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Co(n){var t,e,i;return n.buffered&&(n.body.gap||((t=n.range.video)==null?void 0:t.partial)||((e=n.range.audio)==null?void 0:e.partial)||((i=n.range.audiovideo)==null?void 0:i.partial))}function Ln(n){return`${n.type}_${n.level}_${n.urlId}_${n.sn}`}const C0=Math.pow(2,17);class sy{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(D0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(s):new c(s),g=I0(t),v=R0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:C0};t.stats=p.stats,p.load(g,b,{onSuccess:(E,k,w,L)=>{this.resetLoader(t,p);let x=E.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(x.slice(0,16)),x=x.slice(16)),d({frag:t,part:null,payload:x,networkDetails:L})},onError:(E,k,w,L)=>{this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Hi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:L}))},onAbort:(E,k,w)=>{this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,k,w)=>{this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,k,w,L)=>{e&&e({frag:t,part:null,payload:w,networkDetails:L})}})})}loadPart(t,e,i){this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(D0(t,e));return}const p=this.loader=t.loader=o?new o(s):new c(s),g=I0(t,e),v=R0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:C0};e.stats=p.stats,p.load(g,b,{onSuccess:(E,k,w,L)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const x={frag:t,part:e,payload:E.data,networkDetails:L};i(x),d(x)},onError:(E,k,w,L)=>{this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Hi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:L}))},onAbort:(E,k,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,k,w)=>{this.resetLoader(t,p),f(new Qr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,o=s.total;if(i.loaded+=s.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(i.loaded/o),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const c=i.loading,d=s.loading;c.start?c.first+=d.first-d.start:(c.start=d.start,c.first=d.first),c.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function I0(n,t=null){const e=t||n,i={frag:n,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(jt(s)&&jt(o)){var c;let d=s,f=o;if(n.sn==="initSegment"&&((c=n.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-s;p%16&&(f=o+(16-p%16)),s!==0&&(i.resetIV=!0,d=s-16)}i.rangeStart=d,i.rangeEnd=f}return i}function D0(n,t){const e=new Error(`GAP ${n.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return t&&(i.part=t),(t||n).stats.aborted=!0,new Qr(i)}class Qr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class ny{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,i,s,o){return new Qr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let o=0;o<e.length;o++){const c=e[o];if(s<=c.cc&&(i==="initSegment"||c.sn==="initSegment"||i<c.sn)){this.emeController.selectKeySystemFormat(c).then(d=>{c.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));let d=this.keyUriToKeyInfo[c];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[c]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(t.keyLoadPromise=s.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,o=new s(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((c,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=i.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,k,w)=>{const{frag:L,keyInfo:x,url:M}=k;if(!L.decryptdata||x!==this.keyUriToKeyInfo[M])return d(this.createKeyLoadError(L,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));x.decryptdata.key=L.decryptdata.key=new Uint8Array(b.data),L.keyLoader=null,x.loader=null,c({frag:L,keyInfo:x})},onError:(b,E,k,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${b.code} loading key ${b.text}`),k,Hi({url:f.url,data:void 0},b)))},onTimeout:(b,E,k)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),k))},onAbort:(b,E,k)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),k))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()}}class ay{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(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const oy={length:0,start:()=>0,end:()=>0};class $e{static isBuffered(t,e){try{if(t){const i=$e.getBuffered(t);for(let s=0;s<i.length;s++)if(e>=i.start(s)&&e<=i.end(s))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const s=$e.getBuffered(t),o=[];let c;for(c=0;c<s.length;c++)o.push({start:s.start(c),end:s.end(c)});return this.bufferedInfo(o,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let s=[];if(i)for(let p=0;p<t.length;p++){const g=s.length;if(g){const v=s[g-1].end;t[p].start-v<i?t[p].end>v&&(s[g-1].end=t[p].end):s.push(t[p])}else s.push(t[p])}else s=t;let o=0,c,d=e,f=e;for(let p=0;p<s.length;p++){const g=s[p].start,v=s[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){c=g;break}}return{len:o,start:d||0,end:f||0,nextStart:c}}static getBuffered(t){try{return t.buffered}catch(e){return z.log("failed to get media.buffered",e),oy}}}class Sc{constructor(t,e,i,s=0,o=-1,c=!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=Io(),this.buffering={audio:Io(),video:Io(),audiovideo:Io()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=o,this.partial=c}}function Io(){return{start:0,executeStart:0,executeEnd:0,end:0}}function x0(n,t){let e=null;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o&&o.cc===t){e=o;break}}return e}function ly(n,t,e){return!!(t.details&&(e.endCC>e.startCC||n&&n.cc<e.startCC))}function cy(n,t,e=0){const i=n.fragments,s=t.fragments;if(!s.length||!i.length){z.log("No fragments to align");return}const o=x0(i,s[0].cc);if(!o||o&&!o.startPTS){z.log("No frag in previous level to align on");return}return o}function P0(n,t){if(n){const e=n.start+t;n.start=n.startPTS=e,n.endPTS=e+n.duration}}function Rc(n,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)P0(e[i],n);t.fragmentHint&&P0(t.fragmentHint,n),t.alignedSliding=!0}function hy(n,t,e){t&&(dy(n,e,t),!e.alignedSliding&&t.details&&uy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&k0(t.details,e))}function dy(n,t,e){if(ly(n,e,t)){const i=cy(e.details,t);i&&jt(i.start)&&(z.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Rc(i.start,t))}}function uy(n,t){if(!t.fragments.length||!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=n.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&jt(s)&&(z.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${n.url} `),Rc(s,n))}function O0(n,t){if(!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=n.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,o=i[s],c=x0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=c.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(c.start-o.start);Rc(p,n)}class fy{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class py{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function gy(n){const t=n.byteLength,e=t&&new DataView(n.buffer).getUint8(t-1);return e?on(n,0,t-e):n}class my{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_(t){const e=new DataView(t),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=e.getUint32(s*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],o=i[1],c=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],b=f[3],E=new Uint32Array(256);let k=0,w=0,L=0;for(L=0;L<256;L++)L<128?E[L]=L<<1:E[L]=L<<1^283;for(L=0;L<256;L++){let x=w^w<<1^w<<2^w<<3^w<<4;x=x>>>8^x&255^99,t[k]=x,e[x]=k;const M=E[k],N=E[M],D=E[N];let F=E[x]*257^x*16843008;s[k]=F<<24|F>>>8,o[k]=F<<16|F>>>16,c[k]=F<<8|F>>>24,d[k]=F,F=D*16843009^N*65537^M*257^k*16843008,p[x]=F<<24|F>>>8,g[x]=F<<16|F>>>16,v[x]=F<<8|F>>>24,b[x]=F,k?(k=M^E[E[E[D^M]]],w^=E[E[w]]):k=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s<e.length&&i;)i=e[s]===this.key[s],s++;if(i)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const c=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(c),g=this.invKeySchedule=new Uint32Array(c),v=this.sBox,b=this.rcon,E=this.invSubMix,k=E[0],w=E[1],L=E[2],x=E[3];let M,N;for(d=0;d<c;d++){if(d<o){M=p[d]=e[d];continue}N=M,d%o===0?(N=N<<8|N>>>24,N=v[N>>>24]<<24|v[N>>>16&255]<<16|v[N>>>8&255]<<8|v[N&255],N^=b[d/o|0]<<24):o>6&&d%o===4&&(N=v[N>>>24]<<24|v[N>>>16&255]<<16|v[N>>>8&255]<<8|v[N&255]),p[d]=M=(p[d-o]^N)>>>0}for(f=0;f<c;f++)d=c-f,f&3?N=p[d]:N=p[d-4],f<4||d<=4?g[f]=N:g[f]=k[v[N>>>24]]^w[v[N>>>16&255]]^L[v[N>>>8&255]]^x[v[N&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,o=this.invKeySchedule,c=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],b=this.uint8ArrayToUint32Array_(i);let E=b[0],k=b[1],w=b[2],L=b[3];const x=new Int32Array(t),M=new Int32Array(x.length);let N,D,F,H,j,st,at,Q,kt,gt,Ft,Kt,V,J;const St=this.networkToHostOrderSwap;for(;e<x.length;){for(kt=St(x[e]),gt=St(x[e+1]),Ft=St(x[e+2]),Kt=St(x[e+3]),j=kt^o[0],st=Kt^o[1],at=Ft^o[2],Q=gt^o[3],V=4,J=1;J<s;J++)N=f[j>>>24]^p[st>>16&255]^g[at>>8&255]^v[Q&255]^o[V],D=f[st>>>24]^p[at>>16&255]^g[Q>>8&255]^v[j&255]^o[V+1],F=f[at>>>24]^p[Q>>16&255]^g[j>>8&255]^v[st&255]^o[V+2],H=f[Q>>>24]^p[j>>16&255]^g[st>>8&255]^v[at&255]^o[V+3],j=N,st=D,at=F,Q=H,V=V+4;N=c[j>>>24]<<24^c[st>>16&255]<<16^c[at>>8&255]<<8^c[Q&255]^o[V],D=c[st>>>24]<<24^c[at>>16&255]<<16^c[Q>>8&255]<<8^c[j&255]^o[V+1],F=c[at>>>24]<<24^c[Q>>16&255]<<16^c[j>>8&255]<<8^c[st&255]^o[V+2],H=c[Q>>>24]<<24^c[j>>16&255]<<16^c[st>>8&255]<<8^c[at&255]^o[V+3],M[e]=St(N^E),M[e+1]=St(H^k),M[e+2]=St(F^w),M[e+3]=St(D^L),E=kt,k=gt,w=Ft,L=Kt,e=e+4}return M.buffer}}const vy=16;class Lc{constructor(t,{removePKCS7Padding:e=!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=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}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:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?gy(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((s,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?s(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=ln(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;s&&(i=s);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new my),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=on(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new py(s,e)),this.fastAesKey.expandKey().then(o=>s?(this.logOnce("WebCrypto AES decrypt"),new fy(s,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(z.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%vy;return i!==t.length&&(e=on(t,0,i),this.remainderData=on(t,i)),e}logOnce(t){this.logEnabled&&(z.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const yy={toString:function(n){let t="";const e=n.length;for(let i=0;i<e;i++)t+=`[${n.start(i).toFixed(3)}-${n.end(i).toFixed(3)}]`;return t}},Tt={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class _c extends ay{constructor(t,e,i,s,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Tt.STOPPED,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=o,this.logPrefix=s,this.log=z.log.bind(z,`${s}:`),this.warn=z.warn.bind(z,`${s}:`),this.hls=t,this.fragmentLoader=new sy(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Lc(t.config),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Tt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const o=i[i.length-1];return $e.isBuffered(this.media,o.start+o.duration/2)}const s=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Tt.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.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:t,fragCurrent:e,media:i,mediaBuffer:s,state:o}=this,c=i?i.currentTime:0,d=$e.bufferInfo(s||i,c,t.maxBufferHole);if(this.log(`media seeking to ${jt(c)?c.toFixed(3):c}, state: ${o}`),this.state===Tt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=c>g;(c<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=c),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Tt.STOPPED,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(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const s=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,i,s).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===Tt.FRAG_LOADING||!this.fragCurrent&&c===Tt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Tt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===ui.APPENDING){const s=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,s),c=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===ui.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:o}=i,c=t.decryptdata;if(o&&o.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),c.key.buffer,c.iv.buffer).catch(f=>{throw s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return s.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:s,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Tt.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),i.frag===s&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,s,o,c;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${d?yy.toString($e.getBuffered(d)):"(detached)"})`),this.state=Tt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Sc(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var o;const c=e==null?void 0:e.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Tt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===Tt.KEY_LOADING&&(this.state=Tt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(t,c.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=c.partList;if(g&&s){i>t.end&&c.fragmentHint&&(t=c.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const b=g[v];this.log(`Loading part sn: ${t.sn} p: ${b.index} cc: ${t.cc} of playlist [${c.startSN}-${c.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=Tt.FRAG_LOADING;let E;return d?E=d.then(k=>!k||this.fragContextChanged(k.frag)?null:this.doFragPartsLoad(t,b,e,s)).catch(k=>this.handleFragLoadError(k)):E=this.doFragPartsLoad(t,b,e,s).catch(k=>this.handleFragLoadError(k)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!t.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${c?"of ["+c.startSN+"-"+c.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),jt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Tt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,s)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?s:void 0),d]).then(([g])=>(!f&&g&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,i,s){return new Promise((o,c)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,s).then(b=>{f[v.index]=b;const E=b.part;this.hls.trigger(R.FRAG_LOADED,b);const k=T0(i,t.sn,v.index+1)||w0(p,t.sn,v.index+1);if(k)g(k);else return o({frag:t,part:E,partsLoaded:f})}).catch(c)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Tt.PARSING){!this.fragCurrent&&this.state!==Tt.STOPPED&&this.state!==Tt.ERROR&&(this.state=Tt.IDLE);return}const{frag:i,part:s,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,s&&(s.stats.parsing.end=c),this.updateLevelTiming(i,s,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:o,part:c}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${s}. The current chunk will not be buffered.`),null;const d=e[s],f=c>-1?T0(d,o,c):null,p=f?f.fragment:zv(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,s,o){var c;if(!t||this.state!==Tt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=ln(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!$e.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=$e.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,s.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return jt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,o=$e.bufferInfo(t,e,s);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return $e.bufferInfo(t,e,Math.max(o.nextStart,s))}return o}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Jt.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Jt.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,i),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=c&&(d=i[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===ui.OK||i===ui.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,o){const c=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,c&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let s=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,s>-1&&i<p.start)break;const g=p.loaded;g?s=-1:(o||p.independent||c)&&p.fragment===e&&(s=d),o=g}return s}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let s=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=Xv(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(s=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=Qv(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(s=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=s.maxFragLookUpTolerance,g=i.partList,v=!!(s.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let b;if(t<e){const E=t>e-p?0:p;b=La(o,c,t,E)}else b=c[c.length-1];if(b){const E=b.sn-i.startSN,k=this.fragmentTracker.getState(b);if((k===ui.OK||k===ui.PARTIAL&&b.gap)&&(o=b),o&&b.sn===o.sn&&(!v||g[0].fragment.sn>b.sn)&&o&&b.level===o.level){const w=c[E+1];b.sn<d&&this.fragmentTracker.getState(w)!==ui.OK?b=w:b=null}}return b}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(s!==null&&i.duration>s&&(o<s||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:o}=this,c=s!==null?i[s]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&jt(f);if(p||!g&&!f){hy(o,c,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,o=s?this.startTimeOffset:t.startTimeOffset;o!==null&&jt(o)?(i=e+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${o} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Tt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Tt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ri.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=Ec(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),c.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Tt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):z.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ri.SendAlternateToPenaltyBox?this.state=Tt.WAITING_LEVEL:this.state=Tt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Tt.PARSING||this.state===Tt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const o=!s;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=$e.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===Tt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Tt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){var o;const c=i.details;if(!c){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=s?0:E0(c,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:c,level:i,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Tt.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(s=this.fragCurrent)==null?void 0:s.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function M0(){return self.SourceBuffer||self.WebKitSourceBuffer}function by(){const n=wo();if(!n)return!1;const t=M0(),e=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function Ay(){var n;const t=M0();return typeof(t==null||(n=t.prototype)==null?void 0:n.changeType)=="function"}function Ey(){return typeof __HLS_WORKER_BUNDLE__=="function"}function ky(){const n=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(n);return{worker:new self.Worker(t),objectURL:t}}function Ty(n){const t=new self.URL(n,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Mr(n="",t=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class $0{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(t,e,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=ln(this.cachedData,t),this.cachedData=null);let i=Ao(t,0),s=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?nv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&jt(f))&&(this.basePTS=wy(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY});s<p;){if(this.canParse(t,s)){const g=this.appendFrame(c,t,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,o=s):s=p}else sv(t,s)?(i=Ao(t,s),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,o=s):s++;if(s===p&&o!==p){const g=on(t,o);this.cachedData?this.cachedData=ln(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:Mr(),id3Track:d,textTrack:Mr()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Mr(),id3Track:this._id3Track,textTrack:Mr()}}destroy(){}}const wy=(n,t,e)=>{if(jt(n))return n*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Sy(n,t,e,i){let s,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return c=(t[e+2]&1)<<2,c|=(t[e+3]&192)>>>6,z.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(s=5,d=new Array(4),o=v-3):(s=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(s=2,d=new Array(2),o=v):(s=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?o=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(f))||!i&&c===1)&&(s=2,d=new Array(2)),o=v)),d[0]=s<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,s===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:c,codec:"mp4a.40."+s,manifestCodec:p}}function F0(n,t){return n[t]===255&&(n[t+1]&246)===240}function N0(n,t){return n[t+1]&1?7:9}function Cc(n,t){return(n[t+3]&3)<<11|n[t+4]<<3|(n[t+5]&224)>>>5}function Ry(n,t){return t+5<n.length}function Do(n,t){return t+1<n.length&&F0(n,t)}function Ly(n,t){return Ry(n,t)&&F0(n,t)&&Cc(n,t)<=n.length-t}function _y(n,t){if(Do(n,t)){const e=N0(n,t);if(t+e>=n.length)return!1;const i=Cc(n,t);if(i<=e)return!1;const s=t+i;return s===n.length||Do(n,s)}return!1}function U0(n,t,e,i,s){if(!n.samplerate){const o=Sy(t,e,i,s);if(!o)return;n.config=o.config,n.samplerate=o.samplerate,n.channelCount=o.channelCount,n.codec=o.codec,n.manifestCodec=o.manifestCodec,z.log(`parsed codec:${n.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function B0(n){return 9216e4/n}function Cy(n,t){const e=N0(n,t);if(t+e<=n.length){const i=Cc(n,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function G0(n,t,e,i,s){const o=B0(n.samplerate),c=i+s*o,d=Cy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,b=v+g,E=Math.max(0,e+b-t.length);E?(f=new Uint8Array(b-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+b);const k={unit:f,pts:c};return E||n.samples.push(k),{sample:k,length:b,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:c},length:p,missing:-1}}class Iy extends $0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Ao(t,0)||[]).length;for(let i=t.length;e<i;e++)if(_y(t,e))return z.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return Ly(t,e)}appendFrame(t,e,i){U0(t,this.observer,e,i,t.manifestCodec);const s=G0(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Dy=/\/emsg[-/]ID3/i;class xy{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const o=this.videoTrack=Mr("video",1),c=this.audioTrack=Mr("audio",1),d=this.txtTrack=Mr("text",1);if(this.id3Track=Mr("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=Ju(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;c.id=p,c.timescale=g,c.codec=v}d.id=Xu.text,o.sampleDuration=0,o.duration=c.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,be(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ln(this.remainderData,t));const d=Av(i);this.remainderData=d.remainder,s.samples=d.valid||new Uint8Array}else s.samples=i;const c=this.extractID3Track(s,e);return o.samples=e0(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=e0(t,e),{videoTrack:e,audioTrack:Mr(),id3Track:s,textTrack:Mr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=be(t.samples,["emsg"]);s&&s.forEach(o=>{const c=Tv(o);if(Dy.test(c.schemeIdUri)){const d=jt(c.presentationTime)?c.presentationTime/c.timeScale:e+c.presentationTimeDelta/c.timeScale;let f=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=c.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Ar.emsg,duration:f})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let xo=null;const Py=[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],Oy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],My=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],$y=[0,1,1,4];function V0(n,t,e,i,s){if(e+24>t.length)return;const o=H0(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+s*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return n.config=[],n.channelCount=o.channelCount,n.samplerate=o.sampleRate,n.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function H0(n,t){const e=n[t+1]>>3&3,i=n[t+1]>>1&3,s=n[t+2]>>4&15,o=n[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&o!==3){const c=n[t+2]>>1&1,d=n[t+3]>>6,f=e===3?3-i:i===3?3:4,p=Py[f*14+s-1]*1e3,g=Oy[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,b=My[e][i],E=$y[i],k=b*8*E,w=Math.floor(b*p/g+c)*E;if(xo===null){const L=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);xo=L?parseInt(L[1]):0}return xo&&xo<=87&&i===2&&p>=224e3&&d===0&&(n[t+3]=n[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:k}}}function Ic(n,t){return n[t]===255&&(n[t+1]&224)===224&&(n[t+1]&6)!==0}function W0(n,t){return t+1<n.length&&Ic(n,t)}function Fy(n,t){return Ic(n,t)&&4<=n.length-t}function Ny(n,t){if(t+1<n.length&&Ic(n,t)){const e=H0(n,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===n.length||W0(n,s)}return!1}class j0{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");s.set(t.subarray(i,i+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&z.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,s;for(let o=0;o<t;o++)i!==0&&(s=this.readEG(),i=(e+s+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,s=0,o,c,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),b=this.skipBits.bind(this),E=this.skipEG.bind(this),k=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const L=f();if(p(5),b(3),f(),k(),L===100||L===110||L===122||L===244||L===44||L===83||L===86||L===118||L===128){const H=g();if(H===3&&b(1),k(),k(),b(1),v())for(c=H!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}k();const x=g();if(x===0)g();else if(x===1)for(b(1),E(),E(),o=g(),d=0;d<o;d++)E();k(),b(1);const M=g(),N=g(),D=p(1);D===0&&b(1),b(1),v()&&(t=g(),e=g(),i=g(),s=g());let F=[1,1];if(v()&&v())switch(f()){case 1:F=[1,1];break;case 2:F=[12,11];break;case 3:F=[10,11];break;case 4:F=[16,11];break;case 5:F=[40,33];break;case 6:F=[24,11];break;case 7:F=[20,11];break;case 8:F=[32,11];break;case 9:F=[80,33];break;case 10:F=[18,11];break;case 11:F=[15,11];break;case 12:F=[64,33];break;case 13:F=[160,99];break;case 14:F=[4,3];break;case 15:F=[3,2];break;case 16:F=[2,1];break;case 255:{F=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((M+1)*16-t*2-e*2),height:(2-D)*(N+1)*16-(D?2:4)*(i+s),pixelRatio:F}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Uy{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Lc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const o=s.subarray(16,s.length-s.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);s.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)i.set(t.subarray(o,o+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)t.set(i.subarray(s,s+16),o);return t}decryptAvcSample(t,e,i,s,o){const c=r0(o.data),d=this.getAvcEncryptedData(c);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(c,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)})}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){s();return}const o=t[e].units;for(;!(i>=o.length);i++){const c=o[i];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,e,i,s,c),!this.decrypter.isSync()))return}}}}const Li=188;class As{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=As.syncOffset(t);return e>0&&z.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Li*5,t.length-Li)+1,s=0;for(;s<i;){let o=!1,c=-1,d=0;for(let f=s;f<e;f+=Li)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+Li*99,t.length-Li)+1)),o||(o=Dc(t,f)===0),o&&d>1&&(c===0&&d>2||f+Li>i))return c}else{if(d)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:Xu[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=As.createTrack("video"),this._audioTrack=As.createTrack("audio",s),this._id3Track=As.createTrack("id3"),this._txtTrack=As.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,s=!1){i||(this.sampleAes=null);let o;const c=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=c.pid,v=c.pesData,b=d.pid,E=f.pid,k=d.pesData,w=f.pesData,L=null,x=this.pmtParsed,M=this._pmtId,N=t.length;if(this.remainderData&&(t=ln(this.remainderData,t),N=t.length,this.remainderData=null),N<Li&&!s)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const D=Math.max(0,As.syncOffset(t));N-=(N-D)%Li,N<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,N,t.buffer.byteLength-N));let F=0;for(let j=D;j<N;j+=Li)if(t[j]===71){const st=!!(t[j+1]&64),at=Dc(t,j),Q=(t[j+3]&48)>>4;let kt;if(Q>1){if(kt=j+5+t[j+4],kt===j+Li)continue}else kt=j+4;switch(at){case g:st&&(v&&(o=_n(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,j+Li)),v.size+=j+Li-kt);break;case b:if(st){if(k&&(o=_n(k)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}k={data:[],size:0}}k&&(k.data.push(t.subarray(kt,j+Li)),k.size+=j+Li-kt);break;case E:st&&(w&&(o=_n(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,j+Li)),w.size+=j+Li-kt);break;case 0:st&&(kt+=t[kt]+1),M=this._pmtId=By(t,kt);break;case M:{st&&(kt+=t[kt]+1);const gt=Gy(t,kt,this.typeSupported,i);g=gt.avc,g>0&&(c.pid=g),b=gt.audio,b>0&&(d.pid=b,d.segmentCodec=gt.segmentCodec),E=gt.id3,E>0&&(f.pid=E),L!==null&&!x&&(z.warn(`MPEG-TS PMT found at ${j} after unknown PID '${L}'. Backtracking to sync byte @${D} to parse all TS packets.`),L=null,j=D-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:L=at;break}}else F++;if(F>0){const j=new Error(`Found ${F} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:j,reason:j.message})}c.pesData=v,d.pesData=k,f.pesData=w;const H={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return s&&this.extractRemainingSamples(H),H}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:o}=t,c=i.pesData,d=e.pesData,f=s.pesData;let p;if(c&&(p=_n(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=_n(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&z.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=_n(f))?(this.parseID3PES(s,p),s.pesData=null):s.pesData=f}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new Uy(this.observer,this.config,e);return this.decrypt(s,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:o}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{i(t)}):i(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(_a(c,t),c=this.avcSample=Po(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let b=!1;d=!0;const E=p.data;if(f&&E.length>4){const k=new j0(E).readSliceType();(k===2||k===4||k===7||k===9)&&(b=!0)}if(b){var v;(v=c)!=null&&v.frame&&!c.key&&(_a(c,t),c=this.avcSample=null)}c||(c=this.avcSample=Po(!0,i.pts,i.dts,"")),c.frame=!0,c.key=b;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(_a(c,t),c=this.avcSample=null),c||(c=this.avcSample=Po(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,i0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const b=p.data,E=new j0(b).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[b],t.duration=this._duration;const k=b.subarray(1,4);let w="avc1.";for(let L=0;L<3;L++){let x=k[L].toString(16);x.length<2&&(x="0"+x),w+=x}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,c&&_a(c,t),c=this.avcSample=Po(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,c&&(c.debug+="unknown NAL "+p.type+" ");break}c&&d&&c.units.push(p)}),s&&c&&(_a(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;s=o[o.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const o=s,c=[];let d=0,f,p,g,v=-1,b=0;for(s===-1&&(v=0,b=e[0]&31,s=0,d=1);d<i;){if(f=e[d++],!s){s=f?0:1;continue}if(s===1){s=f?0:2;continue}if(!f)s=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-s-1),type:b};c.push(E)}else{const E=this.getLastNalUnit(t.samples);if(E&&(o&&d<=4-o&&E.state&&(E.data=E.data.subarray(0,E.data.byteLength-o)),p=d-s-1,p>0)){const k=new Uint8Array(E.data.byteLength+p);k.set(E.data,0),k.set(e.subarray(0,p),E.data.byteLength),E.data=k,E.state=0}}d<i?(g=e[d]&31,v=d,b=g,s=0):s=-1}else s=0}if(v>=0&&s>=0){const E={data:e.subarray(v,i),type:b,state:s};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const k=new Uint8Array(E.data.byteLength+e.byteLength);k.set(E.data,0),k.set(e,E.data.byteLength),E.data=k}}return t.naluState=s,c}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let o=e.data;if(s){this.aacOverFlow=null;const v=s.missing,b=s.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(b+o.byteLength);E.set(s.sample.unit,0),E.set(o,b),o=E}else{const E=b-v;s.sample.unit.set(o.subarray(0,v),E),t.samples.push(s.sample),i=s.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Do(o,c);c++);if(c!==i){let v;const b=c<d-1;b?v=`AAC PES did not start with ADTS header,offset:${c}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(z.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:b,error:E,reason:v}),!b)return}U0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(s){const v=B0(t.samplerate);f=s.sample.pts+v}else{z.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=G0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Do(o,c);c++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){z.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<s;)if(W0(i,c)){const f=V0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){z.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ai({},e,{type:this._avcTrack?Ar.emsg:Ar.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Po(n,t,e,i){return{key:n,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Dc(n,t){return((n[t+1]&31)<<8)+n[t+2]}function By(n,t){return(n[t+10]&31)<<8|n[t+11]}function Gy(n,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(n[t+1]&15)<<8|n[t+2],c=t+3+o-4,d=(n[t+10]&15)<<8|n[t+11];for(t+=12+d;t<c;){const f=Dc(n,t);switch(n[t]){case 207:if(!i){z.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=f);break;case 21:s.id3===-1&&(s.id3=f);break;case 219:if(!i){z.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?z.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=f,s.segmentCodec="mp3");break;case 36:z.warn("Unsupported HEVC stream type found");break}t+=((n[t+3]&15)<<8|n[t+4])+5}return s}function _n(n){let t=0,e,i,s,o,c;const d=n.data;if(!n||n.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>n.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(c=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-c>54e5&&(z.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),s=e[8];let p=s+9;if(n.size<=p)return null;n.size-=p;const g=new Uint8Array(n.size);for(let v=0,b=d.length;v<b;v++){e=d[v];let E=e.byteLength;if(p)if(p>E){p-=E;continue}else e=e.subarray(p),E-=p,p=0;g.set(e,t),t+=E}return i&&(i-=s+3),{data:g,pts:o,dts:c,len:i}}return null}function _a(n,t){if(n.units.length&&n.frame){if(n.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];n.pts=s.pts,n.dts=s.dts}else{t.dropped++;return}}t.samples.push(n)}n.debug.length&&z.log(n.pts+"/"+n.dts+":"+n.debug)}class Vy extends $0{resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(Ao(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Ny(t,e))return z.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return Fy(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return V0(t,e,i,this.basePTS,this.frameIndex)}}class K0{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Es=Math.pow(2,32)-1;class rt{static init(){rt.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in rt.types)rt.types.hasOwnProperty(t)&&(rt.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=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]),i=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]);rt.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);rt.STTS=rt.STSC=rt.STCO=o,rt.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),rt.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),rt.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),rt.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);rt.FTYP=rt.box(rt.types.ftyp,c,f,c,d),rt.DINF=rt.box(rt.types.dinf,rt.box(rt.types.dref,s))}static box(t,...e){let i=8,s=e.length;const o=s;for(;s--;)i+=e[s].byteLength;const c=new Uint8Array(i);for(c[0]=i>>24&255,c[1]=i>>16&255,c[2]=i>>8&255,c[3]=i&255,c.set(t,4),s=0,i=8;s<o;s++)c.set(e[s],i),i+=e[s].byteLength;return c}static hdlr(t){return rt.box(rt.types.hdlr,rt.HDLR_TYPES[t])}static mdat(t){return rt.box(rt.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Es+1)),s=Math.floor(e%(Es+1));return rt.box(rt.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(t){return rt.box(rt.types.mdia,rt.mdhd(t.timescale,t.duration),rt.hdlr(t.type),rt.minf(t))}static mfhd(t){return rt.box(rt.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?rt.box(rt.types.minf,rt.box(rt.types.smhd,rt.SMHD),rt.DINF,rt.stbl(t)):rt.box(rt.types.minf,rt.box(rt.types.vmhd,rt.VMHD),rt.DINF,rt.stbl(t))}static moof(t,e,i){return rt.box(rt.types.moof,rt.mfhd(t),rt.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trak(t[e]);return rt.box.apply(null,[rt.types.moov,rt.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(rt.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trex(t[e]);return rt.box.apply(null,[rt.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Es+1)),s=Math.floor(e%(Es+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return rt.box(rt.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,o;for(s=0;s<e.length;s++)o=e[s].flags,i[s+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return rt.box(rt.types.sdtp,i)}static stbl(t){return rt.box(rt.types.stbl,rt.stsd(t),rt.box(rt.types.stts,rt.STTS),rt.box(rt.types.stsc,rt.STSC),rt.box(rt.types.stsz,rt.STSZ),rt.box(rt.types.stco,rt.STCO))}static avc1(t){let e=[],i=[],s,o,c;for(s=0;s<t.sps.length;s++)o=t.sps[s],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(s=0;s<t.pps.length;s++)o=t.pps[s],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=rt.box(rt.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return rt.box(rt.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,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,rt.box(rt.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),rt.box(rt.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return rt.box(rt.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),rt.box(rt.types.esds,rt.esds(t)))}static mp3(t){const e=t.samplerate;return rt.box(rt.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?rt.box(rt.types.stsd,rt.STSD,rt.mp3(t)):rt.box(rt.types.stsd,rt.STSD,rt.mp4a(t)):rt.box(rt.types.stsd,rt.STSD,rt.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,o=t.height,c=Math.floor(i/(Es+1)),d=Math.floor(i%(Es+1));return rt.box(rt.types.tkhd,new Uint8Array([1,0,0,7,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,e&255,0,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=rt.sdtp(t),s=t.id,o=Math.floor(e/(Es+1)),c=Math.floor(e%(Es+1));return rt.box(rt.types.traf,rt.box(rt.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),rt.box(rt.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,c>>24,c>>16&255,c>>8&255,c&255])),rt.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,rt.box(rt.types.trak,rt.tkhd(t),rt.mdia(t))}static trex(t){const e=t.id;return rt.box(rt.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,o=12+16*s,c=new Uint8Array(o);let d,f,p,g,v,b;for(e+=8+o,c.set([t.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<s;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,b=f.cts,c.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,b>>>24&255,b>>>16&255,b>>>8&255,b&255],12+16*d);return rt.box(rt.types.trun,c)}static initSegment(t){rt.types||rt.init();const e=rt.moov(t),i=new Uint8Array(rt.FTYP.byteLength+e.byteLength);return i.set(rt.FTYP),i.set(e,rt.FTYP.byteLength),i}}rt.types=void 0,rt.HDLR_TYPES=void 0,rt.STTS=void 0,rt.STSC=void 0,rt.STCO=void 0,rt.STSZ=void 0,rt.VMHD=void 0,rt.SMHD=void 0,rt.STSD=void 0,rt.FTYP=void 0,rt.DINF=void 0;const Y0=9e4;function xc(n,t,e=1,i=!1){const s=n*t*e;return i?Math.round(s):s}function Hy(n,t,e=1,i=!1){return xc(n,t,1/e,i)}function Ca(n,t=!1){return xc(n,1e3,1/Y0,t)}function Wy(n,t=1){return xc(n,Y0,1/t)}const jy=10*1e3,z0=1024,Ky=1152;let Oo=null,Pc=null;class Oc{constructor(t,e,i,s=""){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.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,Oo===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Oo=o?parseInt(o[1]):0}if(Pc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);Pc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){z.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){z.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){z.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,o)=>{const c=o.pts-s;return c<-4294967296?(e=!0,hr(s,o.pts)):c>0?s:o.pts},t[0].pts);return e&&z.debug("PTS rollover detected"),i}remux(t,e,i,s,o,c,d,f){let p,g,v,b,E,k,w=o,L=o;const x=t.pid>-1,M=e.pid>-1,N=e.samples.length,D=t.samples.length>0,F=d&&N>0||N>1;if((!x||D)&&(!M||F)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const H=this.isVideoContiguous;let j=-1,st;if(F&&(j=Yy(e.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(k=!0,j>0){z.warn(`[mp4-remuxer]: Dropped ${j} out of ${N} video samples due to a missing keyframe`);const at=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(j),e.dropped+=j,L+=(e.samples[0].pts-at)/e.inputTimeScale,st=L}else j===-1&&(z.warn(`[mp4-remuxer]: No keyframe found out of ${N} video samples`),k=!1);if(this.ISGenerated){if(D&&F){const at=this.getVideoStartPts(e.samples),Q=(hr(t.samples[0].pts,at)-at)/e.inputTimeScale;w+=Math.max(0,Q),L+=Math.max(0,-Q)}if(D){if(t.samplerate||(z.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,M||F||f===Jt.AUDIO?L:void 0),F){const at=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(z.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,L,H,at)}}else F&&(p=this.remuxVideo(e,L,H,0));p&&(p.firstKeyFrame=j,p.independent=j!==-1,p.firstKeyFramePTS=st)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=Z0(i,o,this._initPTS,this._initDTS)),s.samples.length&&(b=X0(s,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:k,text:b,id3:E}}generateIS(t,e,i,s){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||s,v="audio/mp4",b,E,k;if(g&&(b=E=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):rt.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(k=t.inputTimeScale,!p||k!==p.timescale?b=E=o[0].pts-Math.round(k*i):g=!1)}if(e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:rt.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(k=e.inputTimeScale,!p||k!==p.timescale){const w=this.getVideoStartPts(c),L=Math.round(k*i);E=Math.min(E,hr(c[0].dts,w)-L),b=Math.min(b,w-L)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:b,timescale:k},this._initDTS={baseTime:E,timescale:k}):b=k=void 0,{tracks:f,initPTS:b,timescale:k}}remuxVideo(t,e,i,s){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,b=this.videoSampleDuration,E,k,w=Number.POSITIVE_INFINITY,L=Number.NEGATIVE_INFINITY,x=!1;if(!i||g===null){const $=e*o,U=c[0].pts-hr(c[0].dts,c[0].pts);g=$-U}const M=p.baseTime*o/p.timescale;for(let $=0;$<f;$++){const U=c[$];U.pts=hr(U.pts-M,g),U.dts=hr(U.dts-M,g),U.dts<c[$>0?$-1:$].dts&&(x=!0)}x&&c.sort(function($,U){const Z=$.dts-U.dts,mt=$.pts-U.pts;return Z||mt}),E=c[0].dts,k=c[c.length-1].dts;const N=k-E,D=N?Math.round(N/(f-1)):b||t.inputTimeScale/30;if(i){const $=E-g,U=$>D,Z=$<-1;if((U||Z)&&(U?z.warn(`AVC: ${Ca($,!0)} ms (${$}dts) hole between fragments detected, filling it`):z.warn(`AVC: ${Ca(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!Z||g>=c[0].pts)){E=g;const mt=c[0].pts-$;c[0].dts=E,c[0].pts=mt,z.log(`Video: First PTS/DTS adjusted: ${Ca(mt,!0)}/${Ca(E,!0)}, delta: ${Ca($,!0)} ms`)}}E=Math.max(0,E);let F=0,H=0;for(let $=0;$<f;$++){const U=c[$],Z=U.units,mt=Z.length;let bt=0;for(let Dt=0;Dt<mt;Dt++)bt+=Z[Dt].data.length;H+=bt,F+=mt,U.length=bt,U.dts=Math.max(U.dts,E),w=Math.min(U.pts,w),L=Math.max(U.pts,L)}k=c[f-1].dts;const j=H+4*F+8;let st;try{st=new Uint8Array(j)}catch($){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:j,reason:`fail allocating video mdat ${j}`});return}const at=new DataView(st.buffer);at.setUint32(0,j),st.set(rt.types.mdat,4);let Q=!1,kt=Number.POSITIVE_INFINITY,gt=Number.POSITIVE_INFINITY,Ft=Number.NEGATIVE_INFINITY,Kt=Number.NEGATIVE_INFINITY;for(let $=0;$<f;$++){const U=c[$],Z=U.units;let mt=0;for(let Ut=0,Qt=Z.length;Ut<Qt;Ut++){const fe=Z[Ut],re=fe.data,Ht=fe.data.byteLength;at.setUint32(v,Ht),v+=4,st.set(re,v),v+=Ht,mt+=4+Ht}let bt;if($<f-1)b=c[$+1].dts-U.dts,bt=c[$+1].pts-U.pts;else{const Ut=this.config,Qt=$>0?U.dts-c[$-1].dts:D;if(bt=$>0?U.pts-c[$-1].pts:D,Ut.stretchShortVideoTrack&&this.nextAudioPts!==null){const fe=Math.floor(Ut.maxBufferHole*o),re=(s?w+s*o:this.nextAudioPts)-U.pts;re>fe?(b=re-Qt,b<0?b=Qt:Q=!0,z.log(`[mp4-remuxer]: It is approximately ${re/90} ms to the next segment; using duration ${b/90} ms for the last video frame.`)):b=Qt}else b=Qt}const Dt=Math.round(U.pts-U.dts);kt=Math.min(kt,b),Ft=Math.max(Ft,b),gt=Math.min(gt,bt),Kt=Math.max(Kt,bt),d.push(new q0(U.key,b,mt,Dt))}if(d.length){if(Oo){if(Oo<70){const $=d[0].flags;$.dependsOn=2,$.isNonSync=0}}else if(Pc&&Kt-gt<Ft-kt&&D/Ft<.025&&d[0].cts===0){z.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=E;for(let U=0,Z=d.length;U<Z;U++){const mt=$+d[U].duration,bt=$+d[U].cts;if(U<Z-1){const Dt=mt+d[U+1].cts;d[U].duration=Dt-bt}else d[U].duration=U?d[U-1].duration:D;d[U].cts=0,$=mt}}}b=Q||!b?D:b,this.nextAvcDts=g=k+b,this.videoSampleDuration=b,this.isVideoContiguous=!0;const V=rt.moof(t.sequenceNumber++,E,ai({},t,{samples:d})),J="video",St={data1:V,data2:st,startPTS:w/o,endPTS:(L+b)/o,startDTS:E/o,endDTS:g/o,type:J,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,St}remuxAudio(t,e,i,s,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?z0:Ky,g=p*f,v=this._initPTS,b=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],k=o!==void 0;let w=t.samples,L=b?0:8,x=this.nextAudioPts||-1;const M=e*c,N=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&x>0&&(s&&Math.abs(M-x)<9e3||Math.abs(hr(w[0].pts-N,M)-x)<20*g),w.forEach(function(V){V.pts=hr(V.pts-N,M)}),!i||x<0){if(w=w.filter(V=>V.pts>=0),!w.length)return;o===0?x=0:s&&!k?x=Math.max(0,M):x=w[0].pts}if(t.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let J=0,St=x;J<w.length;J++){const $=w[J],U=$.pts,Z=U-St,mt=Math.abs(1e3*Z/c);if(Z<=-V*g&&k)J===0&&(z.warn(`Audio frame @ ${(U/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Z/c)} ms.`),this.nextAudioPts=x=St=U);else if(Z>=V*g&&mt<jy&&k){let bt=Math.round(Z/g);St=U-bt*g,St<0&&(bt--,St+=g),J===0&&(this.nextAudioPts=x=St),z.warn(`[mp4-remuxer]: Injecting ${bt} audio frame @ ${(St/c).toFixed(3)}s due to ${Math.round(1e3*Z/c)} ms gap.`);for(let Dt=0;Dt<bt;Dt++){const Ut=Math.max(St,0);let Qt=K0.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Qt||(z.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Qt=$.unit.subarray()),w.splice(J,0,{unit:Qt,pts:Ut}),St+=g,J++}}$.pts=St,St+=g}}let D=null,F=null,H,j=0,st=w.length;for(;st--;)j+=w[st].unit.byteLength;for(let V=0,J=w.length;V<J;V++){const St=w[V],$=St.unit;let U=St.pts;if(F!==null){const mt=E[V-1];mt.duration=Math.round((U-F)/f)}else if(i&&t.segmentCodec==="aac"&&(U=x),D=U,j>0){j+=L;try{H=new Uint8Array(j)}catch(mt){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:mt,bytes:j,reason:`fail allocating audio mdat ${j}`});return}b||(new DataView(H.buffer).setUint32(0,j),H.set(rt.types.mdat,4))}else return;H.set($,L);const Z=$.byteLength;L+=Z,E.push(new q0(!0,p,Z,0)),F=U}const at=E.length;if(!at)return;const Q=E[E.length-1];this.nextAudioPts=x=F+f*Q.duration;const kt=b?new Uint8Array(0):rt.moof(t.sequenceNumber++,D/f,ai({},t,{samples:E}));t.samples=[];const gt=D/c,Ft=x/c,Kt={data1:kt,data2:H,startPTS:gt,endPTS:Ft,startDTS:gt,endDTS:Ft,type:"audio",hasAudio:!0,hasVideo:!1,nb:at};return this.isAudioContiguous=!0,Kt}remuxEmptyAudio(t,e,i,s){const o=t.inputTimeScale,c=t.samplerate?t.samplerate:o,d=o/c,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:s.startDTS*o)+g,b=s.endDTS*o+g,E=d*z0,k=Math.ceil((b-v)/E),w=K0.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(z.warn("[mp4-remuxer]: remux empty Audio"),!w){z.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const L=[];for(let x=0;x<k;x++){const M=v+x*E;L.push({unit:w,pts:M,dts:M})}return t.samples=L,this.remuxAudio(t,e,i,!1)}}function hr(n,t){let e;if(t===null)return n;for(t<n?e=-8589934592:e=8589934592;Math.abs(n-t)>4294967296;)n+=e;return n}function Yy(n){for(let t=0;t<n.length;t++)if(n[t].key)return t;return-1}function Z0(n,t,e,i){const s=n.samples.length;if(!s)return;const o=n.inputTimeScale;for(let d=0;d<s;d++){const f=n.samples[d];f.pts=hr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=hr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=n.samples;return n.samples=[],{samples:c}}function X0(n,t,e){const i=n.samples.length;if(!i)return;const s=n.inputTimeScale;for(let c=0;c<i;c++){const d=n.samples[c];d.pts=hr(d.pts-e.baseTime*s/e.timescale,t*s)/s}n.samples.sort((c,d)=>c.pts-d.pts);const o=n.samples;return n.samples=[],{samples:o}}class q0{constructor(t,e,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=s,this.flags=new zy(t)}}class zy{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class Zy{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(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(gv(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=Ju(t);e||(e=Q0(s.audio,Ce.AUDIO)),i||(i=Q0(s.video,Ce.VIDEO));const o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:z.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,s,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};jt(g)||(g=this.lastEndTime=o||0);const b=e.samples;if(!(b!=null&&b.length))return v;const E={initPTS:void 0,timescale:1};let k=this.initData;if((d=k)!=null&&d.length||(this.generateInitSegment(b),k=this.initData),!((f=k)!=null&&f.length))return z.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=vv(b,k),L=mv(k,b),x=L===null?o:L;(Xy(p,x,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=x-o,p&&p.timescale===1&&z.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const M=t?x-p.baseTime/p.timescale:g,N=M+w;bv(k,b,p.baseTime/p.timescale),w>0?this.lastEndTime=N:(z.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const D=!!k.audio,F=!!k.video;let H="";D&&(H+="audio"),F&&(H+="video");const j={data1:b,startPTS:M,startDTS:M,endPTS:N,endDTS:N,type:H,hasAudio:D,hasVideo:F,nb:1,dropped:0};return v.audio=j.type==="audio"?j:void 0,v.video=j.type!=="audio"?j:void 0,v.initSegment=E,v.id3=Z0(i,o,p,p),s.samples.length&&(v.text=X0(s,o,p)),v}}function Xy(n,t,e,i){if(n===null)return!0;const s=Math.max(i,1),o=t-n.baseTime/n.timescale;return Math.abs(o-e)>s}function Q0(n,t){const e=n==null?void 0:n.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===Ce.VIDEO?"avc1.42e01e":"mp4a.40.5"}let Jr;try{Jr=self.performance.now.bind(self.performance)}catch{z.debug("Unable to use Performance API on this environment"),Jr=typeof self<"u"&&self.Date.now}const Mc=[{demux:xy,remux:Zy},{demux:As,remux:Oc},{demux:Iy,remux:Oc},{demux:Vy,remux:Oc}];class J0{constructor(t,e,i,s,o){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=t,this.typeSupported=e,this.config=i,this.vendor=s,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const o=i.transmuxing;o.executeStart=Jr();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;s&&(this.currentTransmuxState=s);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:b,timeOffset:E,initSegmentChange:k}=s||d,{audioCodec:w,videoCodec:L,defaultInitPts:x,duration:M,initSegmentData:N}=f,D=qy(c,e);if(D&&D.method==="AES-128"){const st=this.getDecrypter();if(st.isSync()){let at=st.softwareDecrypt(c,D.key.buffer,D.iv.buffer);if(i.part>-1&&(at=st.flush()),!at)return o.executeEnd=Jr(),$c(i);c=new Uint8Array(at)}else return this.decryptionPromise=st.webCryptoDecrypt(c,D.key.buffer,D.iv.buffer).then(at=>{const Q=this.push(at,null,i);return this.decryptionPromise=null,Q}),this.decryptionPromise}const F=this.needsProbing(g,v);if(F){const st=this.configureTransmuxer(c);if(st)return z.warn(`[transmuxer] ${st.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:st,reason:st.message}),o.executeEnd=Jr(),$c(i)}(g||v||k||F)&&this.resetInitSegment(N,w,L,M,e),(g||k||F)&&this.resetInitialTimestamp(x),p||this.resetContiguity();const H=this.transmux(c,D,E,b,i),j=this.currentTransmuxState;return j.contiguous=!0,j.discontinuity=!1,j.trackSwitch=!1,o.executeEnd=Jr(),H}flush(t){const e=t.transmuxing;e.executeStart=Jr();const{decrypter:i,currentTransmuxState:s,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=s;if(i){const v=i.flush();v&&c.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=Jr(),[$c(t)];const g=f.flush(d);return Mo(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;z.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(s,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=Jr()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,s),d.resetInitSegment(t,e,i,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,s,o):c=this.transmuxUnencrypted(t,i,s,o),c}transmuxUnencrypted(t,e,i,s){const{audioTrack:o,videoTrack:c,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,c,d,f,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,s,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:o}=this;let c;for(let v=0,b=Mc.length;v<b;v++)if(Mc[v].demux.probe(t)){c=Mc[v];break}if(!c)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=c.remux,g=c.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,s,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,s),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Lc(this.config)),t}}function qy(n,t){let e=null;return n.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const $c=n=>({remuxResult:{},chunkMeta:n});function Mo(n){return"then"in n&&n.then instanceof Function}class Qy{constructor(t,e,i,s,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=o||null}}class Jy{constructor(t,e,i,s,o,c){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=o,this.initSegmentChange=c}}var tf={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,b){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new s(g,v||f,b),k=e?e+p:p;return f._events[k]?f._events[k].fn?f._events[k]=[f._events[k],E]:f._events[k].push(E):(f._events[k]=E,f._eventsCount++),f}function c(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,b=g.length,E=new Array(b);v<b;v++)E[v]=g[v].fn;return E},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,b,E){var k=e?e+f:f;if(!this._events[k])return!1;var w=this._events[k],L=arguments.length,x,M;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),L){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,b),!0;case 6:return w.fn.call(w.context,p,g,v,b,E),!0}for(M=1,x=new Array(L-1);M<L;M++)x[M-1]=arguments[M];w.fn.apply(w.context,x)}else{var N=w.length,D;for(M=0;M<N;M++)switch(w[M].once&&this.removeListener(f,w[M].fn,void 0,!0),L){case 1:w[M].fn.call(w[M].context);break;case 2:w[M].fn.call(w[M].context,p);break;case 3:w[M].fn.call(w[M].context,p,g);break;case 4:w[M].fn.call(w[M].context,p,g,v);break;default:if(!x)for(D=1,x=new Array(L-1);D<L;D++)x[D-1]=arguments[D];w[M].fn.apply(w[M].context,x)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var b=e?e+f:f;if(!this._events[b])return this;if(!p)return c(this,b),this;var E=this._events[b];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,b);else{for(var k=0,w=[],L=E.length;k<L;k++)(E[k].fn!==p||v&&!E[k].once||g&&E[k].context!==g)&&w.push(E[k]);w.length?this._events[b]=w.length===1?w[0]:w:c(this,b)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&c(this,p)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,n.exports=d})(tf);var tb=tf.exports,Fc=U1(tb);const Nc=wo()||{isTypeSupported:()=>!1};class ef{constructor(t,e,i,s){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 o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const c=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new Fc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Nc.isTypeSupported("video/mp4"),mpeg:Nc.isTypeSupported("audio/mpeg"),mp3:Nc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||Ey())){try{o.workerPath?(z.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=Ty(o.workerPath)):(z.log(`injecting Web Worker for "${e}"`),this.workerContext=ky()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,z.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){z.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new J0(this.observer,d,o,f,e)}return}this.transmuxer=new J0(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.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 t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,s,o,c,d,f,p,g){var v,b;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,k=c?c.start:o.start,w=o.decryptdata,L=this.frag,x=!(L&&o.cc===L.cc),M=!(L&&p.level===L.level),N=L?p.sn-L.sn:-1,D=this.part?p.part-this.part.index:-1,F=N===0&&p.id>1&&p.id===(L==null?void 0:L.stats.chunkCount),H=!M&&(N===1||N===0&&(D===1||F&&D<=0)),j=self.performance.now();(M||N||o.stats.parsing.start===0)&&(o.stats.parsing.start=j),c&&(D||!H)&&(c.stats.parsing.start=j);const st=!(L&&((v=o.initSegment)==null?void 0:v.url)===((b=L.initSegment)==null?void 0:b.url)),at=new Jy(x,H,f,M,k,st);if(!H||x||st){z.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
150
182
  discontinuity: ${x}
151
183
  trackSwitch: ${M}
152
184
  contiguous: ${H}
153
185
  accurateTimeOffset: ${f}
154
- timeOffset: ${E}
155
- initSegmentChange: ${nt}`);const tt=new By(i,s,e,d,g);this.configureTransmuxer(tt)}if(this.frag=o,this.part=c,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:ot},t instanceof ArrayBuffer?[t]:[]);else if(T){const tt=T.push(t,w,p,ot);Do(tt)?(T.async=!0,tt.then(kt=>{this.handleTransmuxComplete(kt)}).catch(kt=>{this.transmuxerError(kt,p,"transmuxer-interface push error")})):(T.async=!1,this.handleTransmuxComplete(tt))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let i=e.flush(t);Do(i)||e.async?(Do(i)||(i=Promise.resolve(i)),i.then(s=>{this.handleFlushResult(s,t)}).catch(s=>{this.transmuxerError(s,t,"transmuxer-interface flush error")})):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:i}))}handleFlushResult(t,e){t.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,i=this.hls;switch(e.event){case"init":{var s;const o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":Y[e.data.logType]&&Y[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const Vy=250,Ic=2,Wy=.1,Ky=.05;class jy{constructor(t,e,i,s){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=t,this.media=e,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:s,stalled:o}=this;if(s===null)return;const{currentTime:c,seeking:d}=s,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,c!==t){if(this.moved=!0,o!==null){if(this.stallReported){const x=self.performance.now()-o;Y.warn(`playback not stuck anymore @${c}, after ${Math.round(x)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(s.paused&&!d||s.ended||s.playbackRate===0||!Me.getBuffered(s).length)return;const g=Me.bufferInfo(s,c,0),v=g.len>0,A=g.nextStart||0;if(!v&&!A)return;if(d){const x=g.len>Ic,M=!A||e&&e.start<=c||A-c>Ic&&!this.fragmentTracker.getPartialFragment(c);if(x||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var T;const x=Math.max(A,g.start||0)-c,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,G=!(M==null||(T=M.details)==null)&&T.live?M.details.targetduration*2:Ic,_=this.fragmentTracker.getPartialFragment(c);if(x>0&&(x<=G||_)){this._trySkipBufferHole(_);return}}const E=self.performance.now();if(o===null){this.stalled=E;return}const w=E-o;if(!d&&w>=Vy&&(this._reportStall(g),!this.media))return;const R=Me.bufferInfo(s,c,i.maxBufferHole);this._tryFixBufferStall(R,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:s,media:o}=this;if(o===null)return;const c=o.currentTime,d=s.getPartialFragment(c);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-c<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(Y.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);Y.warn(o.message),e.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:s}=this;if(s===null)return 0;const o=s.currentTime,c=Me.bufferInfo(s,o,0),d=o<c.start?c.start:c.nextStart;if(d){const f=c.len<=e.maxBufferHole,p=c.len>0&&c.len<1&&s.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:A}=this;let T=!1;if(o===0){const E=A.getAppendedFrag(0,Qt.MAIN);E&&d<E.end&&(T=!0)}if(!T){const E=t||A.getAppendedFrag(o,Qt.MAIN);if(E){let w=!1,R=E.end;for(;R<d;){const x=A.getPartialFragment(R);if(x)R+=x.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+Ky,o+Wy);if(Y.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,s.currentTime=v,t&&!t.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:s}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,s<t.nudgeMaxRetry){const c=o+(s+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${c}`);Y.warn(d.message),i.currentTime=c,e.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const c=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);Y.error(c.message),e.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}const zy=100;class Yy extends bc{constructor(t,e,i){super(t,e,i,"[stream-controller]",Qt.MAIN),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:t}=this;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.LEVEL_LOADING,this.onLevelLoading,this),t.on(L.LEVEL_LOADED,this.onLevelLoaded,this),t.on(L.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(L.ERROR,this.onError,this),t.on(L.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(L.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(L.BUFFER_CREATED,this.onBufferCreated,this),t.on(L.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(L.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(L.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.LEVEL_LOADED,this.onLevelLoaded,this),t.off(L.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(L.ERROR,this.onError,this),t.off(L.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(L.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(L.BUFFER_CREATED,this.onBufferCreated,this),t.off(L.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(L.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(L.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(zy),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.nextAutoLevel),this.level=i.nextLoadLevel=s,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Tt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Tt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Tt.WAITING_LEVEL:{var t;const{levels:i,level:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=Tt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Tt.IDLE;break}break}case Tt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Tt.IDLE)}break}this.state===Tt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:s}=this,{config:o,nextLoadLevel:c}=t;if(e===null||!s&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[c]))return;const d=i[c],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const R={};this.altAudio&&(R.type="video"),this.hls.trigger(L.BUFFER_EOS,R),this.state=Tt.ENDED;return}t.loadLevel!==c&&t.manualLevel===-1&&this.log(`Adapting to level ${c} from level ${this.level}`),this.level=t.nextLoadLevel=c;const g=d.details;if(!g||this.state===Tt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==c){this.level=c,this.state=Tt.WAITING_LEVEL;return}const v=f.len,A=this.getMaxBufferLength(d.maxBitrate);if(v>=A)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const T=this.backtrackFragment?this.backtrackFragment.start:f.end;let E=this.getNextFragment(T,g);if(this.couldBacktrack&&!this.fragPrevious&&E&&E.sn!=="initSegment"&&this.fragmentTracker.getState(E)!==di.OK){var w;const R=((w=this.backtrackFragment)!=null?w:E).sn-g.startSN,x=g.fragments[R-1];x&&E.cc===x.cc&&(E=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(E&&this.isLoopLoading(E,T)){if(!E.gap){const R=this.audioOnly&&!this.altAudio?_e.AUDIO:_e.VIDEO,x=(R===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,R,Qt.MAIN)}E=this.getNextFragmentLoopLoading(E,g,f,Qt.MAIN,A)}E&&(E.initSegment&&!E.initSegment.data&&!this.bitrateTest&&(E=E.initSegment),this.loadFragment(E,d,T))}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);this.fragCurrent=t,s===di.NOT_LOADED||s===di.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Qt.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let i;const s=this.getAppendedFrag(e.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const o=this.getLevelDetails();if(o!=null&&o.live){const d=this.getMainFwdBufferInfo();if(!d||d.len<o.targetduration*2)return}if(!e.paused&&t){const d=this.hls.nextLoadLevel,f=t[d],p=this.fragLastKbps;p&&this.fragCurrent?i=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:i=0}else i=0;const c=this.getBufferedFrag(e.currentTime+i);if(c){const d=this.followingBufferedFrag(c);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(c.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Tt.KEY_LOADING:case Tt.FRAG_LOADING:case Tt.FRAG_LOADING_WAITING_RETRY:case Tt.PARSING:case Tt.PARSED:this.state=Tt.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new jy(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;Kt(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(L.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let i=!1,s=!1,o;e.levels.forEach(c=>{o=c.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!ly(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:i}=this;if(!i||this.state!==Tt.IDLE)return;const s=i[e.level];(!s.details||s.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(s.details))&&(this.state=Tt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:s}=this,o=e.level,c=e.details,d=c.totalduration;if(!s){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${c.startSN},${c.endSN}]${c.lastPartSn?`[part-${c.lastPartSn}-${c.lastPartIndex}]`:""}, cc [${c.startCC}, ${c.endCC}] duration:${d}`);const f=s[o],p=this.fragCurrent;p&&(this.state===Tt.FRAG_LOADING||this.state===Tt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(c.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;g=this.alignPlaylists(c,f.details)}if(f.details=c,this.levelLastLoaded=o,this.hls.trigger(L.LEVEL_UPDATED,{details:c,level:o}),this.state===Tt.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=Tt.IDLE}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{levels:c}=this;if(!c){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const d=c[i.level],f=d.details;if(!f){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const p=d.videoCodec,g=f.PTSKnown||!f.live,v=(e=i.initSegment)==null?void 0:e.data,A=this._getAudioCodec(d),T=this.transmuxer=this.transmuxer||new z0(this.hls,Qt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),E=s?s.index:-1,w=E!==-1,R=new mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,E,w),x=this.initPTS[i.cc];T.push(o,v,A,p,i,s,f.totalduration,g,R,x)}onAudioTrackSwitching(t,e){const i=this.altAudio;if(!e.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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const s=this.hls;i&&(s.trigger(L.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(L.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,s=!!this.hls.audioTracks[i].url;if(s){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=s,this.tick()}onBufferCreated(t,e){const i=e.tracks;let s,o,c=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,s=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&s?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i&&i.type!==Qt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Tt.PARSED&&(this.state=Tt.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=Tt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.MAIN,e);break;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Tt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===Ee.LEVEL&&(this.state=Tt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Me.getBuffered(t).length){const i=this.state!==Tt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Tt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==_e.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===_e.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,Qt.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let i=this.startPosition;if(i>=0&&e<i){if(t.seeking){this.log(`could not seek to ${i}, already seeking at ${e}`);return}const s=Me.getBuffered(t),o=(s.length?s.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),i+=o,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(i=>{const{hls:s}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Tt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),s.trigger(L.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{video:v,text:A,id3:T,initSegment:E}=o,{details:w}=g,R=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=Tt.PARSING,E){if(E!=null&&E.tracks){const G=f.initSegment||f;this._bufferInitSegment(g,E.tracks,G,c),s.trigger(L.FRAG_PARSING_INIT_SEGMENT,{frag:G,id:i,tracks:E.tracks})}const x=E.initPTS,M=E.timescale;Kt(x)&&(this.initPTS[f.cc]={baseTime:x,timescale:M},s.trigger(L.INIT_PTS_FOUND,{frag:f,id:i,initPTS:x,timescale:M}))}if(v&&w&&f.sn!=="initSegment"){const x=w.fragments[f.sn-1-w.startSN],M=f.sn===w.startSN,G=!x||f.cc>x.cc;if(o.independent!==!1){const{startPTS:_,endPTS:F,startDTS:H,endDTS:j}=v;if(p)p.elementaryStreams[v.type]={startPTS:_,endPTS:F,startDTS:H,endDTS:j};else if(v.firstKeyFrame&&v.independent&&c.id===1&&!G&&(this.couldBacktrack=!0),v.dropped&&v.independent){const nt=this.getMainFwdBufferInfo(),ot=(nt?nt.end:this.getLoadPosition())+this.config.maxBufferHole,tt=v.firstKeyFramePTS?v.firstKeyFramePTS:_;if(!M&&ot<tt-this.config.maxBufferHole&&!G){this.backtrack(f);return}else G&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,F,f.start,j,!0)}f.setElementaryStreamInfo(v.type,_,F,H,j),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,c,M||G)}else if(M||G)f.gap=!0;else{this.backtrack(f);return}}if(R){const{startPTS:x,endPTS:M,startDTS:G,endDTS:_}=R;p&&(p.elementaryStreams[_e.AUDIO]={startPTS:x,endPTS:M,startDTS:G,endDTS:_}),f.setElementaryStreamInfo(_e.AUDIO,x,M,G,_),this.bufferFragmentData(R,f,p,c)}if(w&&T!=null&&(e=T.samples)!=null&&e.length){const x={id:i,frag:f,details:w,samples:T.samples};s.trigger(L.FRAG_PARSING_METADATA,x)}if(w&&A){const x={id:i,frag:f,details:w,samples:A.samples};s.trigger(L.FRAG_PARSING_USERDATA,x)}}_bufferInitSegment(t,e,i,s){if(this.state!==Tt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:c,audiovideo:d}=e;if(o){let f=t.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),o.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&o.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),t.audioCodec&&t.audioCodec!==f&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${f}"`),o.levelCodec=f,o.id="main",this.log(`Init audio buffer, container:${o.container}, codecs[selected/level/parsed]=[${f||""}/${t.audioCodec||""}/${o.codec}]`)}c&&(c.levelCodec=t.videoCodec,c.id="main",this.log(`Init video buffer, container:${c.container}, codecs[level/parsed]=[${t.videoCodec||""}/${c.codec}]`)),d&&this.log(`Init audiovideo buffer, container:${d.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${d.codec}]`),this.hls.trigger(L.BUFFER_CODECS,e),Object.keys(e).forEach(f=>{const p=e[f].initSegment;p!=null&&p.byteLength&&this.hls.trigger(L.BUFFER_APPENDING,{type:f,data:p,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Qt.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Tt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Me.isBuffered(t,i)?e=this.getAppendedFrag(i):Me.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const s=this.fragPlaying,o=e.level;(!s||e.sn!==s.sn||s.level!==o||e.urlId!==s.urlId)&&(this.fragPlaying=e,this.hls.trigger(L.FRAG_CHANGED,{frag:e}),(!s||s.level!==o)&&this.hls.trigger(L.LEVEL_SWITCHED,{level:o}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,i=this.currentFrag;if(i&&Kt(e)&&Kt(i.programDateTime)){const s=i.programDateTime+(e-i.start)*1e3;return new Date(s)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class Tn{constructor(t,e=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class Zy{constructor(t,e,i,s=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Tn(t),this.fast_=new Tn(e),this.defaultTTFB_=s,this.ttfb_=new Tn(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new Tn(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new Tn(e,s.getEstimate(),s.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Tn(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,s=t/1e3,o=i/s;this.fast_.sample(s,o),this.slow_.sample(s,o)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,Math.max(t,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(){}}class Xy{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new Zy(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(L.FRAG_LOADING,this.onFragLoading,this),t.on(L.FRAG_LOADED,this.onFragLoaded,this),t.on(L.FRAG_BUFFERED,this.onFragBuffered,this),t.on(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(L.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(L.FRAG_LOADING,this.onFragLoading,this),t.off(L.FRAG_LOADED,this.onFragLoaded,this),t.off(L.FRAG_BUFFERED,this.onFragBuffered,this),t.off(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(L.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var i;const s=e.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(i=e.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,i,s){const o=t+i/e,c=s?this.lastLevelLoadSec:0;return o+c}onLevelLoaded(t,e){const i=this.hls.config,{total:s,bwEstimate:o}=e.stats;Kt(s)&&Kt(o)&&(this.lastLevelLoadSec=8*s/o),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{autoLevelEnabled:s,media:o}=i;if(!t||!o)return;const c=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=c-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||o.paused||!o.playbackRate||!o.readyState)return;const g=i.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),A=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(A*2))))return;const T=g.len/A;if(T>=2*f/A)return;const E=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&E>-1,R=this.bwEstimator.getEstimate(),{levels:x,minAutoLevel:M}=i,G=x[t.level],_=d.total||Math.max(d.loaded,Math.round(f*G.maxBitrate/8));let F=p-E;F<1&&w&&(F=Math.min(p,d.loaded*8/R));const H=w?d.loaded*1e3/F:0,j=H?(_-d.loaded)/H:_*8/R+v/1e3;if(j<=T)return;const nt=H?H*8:R;let ot=Number.POSITIVE_INFINITY,tt;for(tt=t.level-1;tt>M;tt--){const kt=x[tt].maxBitrate;if(ot=this.getTimeToLoadFrag(v/1e3,nt,f*kt,!x[tt].details),ot<T)break}ot>=j||ot>f*10||(i.nextLoadLevel=tt,w?this.bwEstimator.sample(p-Math.min(v,E),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),Y.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
156
- Time to underbuffer: ${T.toFixed(3)} s
186
+ timeOffset: ${k}
187
+ initSegmentChange: ${st}`);const Q=new Qy(i,s,e,d,g);this.configureTransmuxer(Q)}if(this.frag=o,this.part=c,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:w,chunkMeta:p,state:at},t instanceof ArrayBuffer?[t]:[]);else if(E){const Q=E.push(t,w,p,at);Mo(Q)?(E.async=!0,Q.then(kt=>{this.handleTransmuxComplete(kt)}).catch(kt=>{this.transmuxerError(kt,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(Q))}}flush(t){t.transmuxing.start=self.performance.now();const{transmuxer:e}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(e){let i=e.flush(t);Mo(i)||e.async?(Mo(i)||(i=Promise.resolve(i)),i.then(s=>{this.handleFlushResult(s,t)}).catch(s=>{this.transmuxerError(s,t,"transmuxer-interface flush error")})):this.handleFlushResult(i,t)}}transmuxerError(t,e,i){this.hls&&(this.error=t,this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:i}))}handleFlushResult(t,e){t.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(e)}onWorkerMessage(t){const e=t.data,i=this.hls;switch(e.event){case"init":{var s;const o=(s=this.workerContext)==null?void 0:s.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":z[e.data.logType]&&z[e.data.logType](e.data.message);break;default:{e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,i.trigger(e.event,e.data);break}}}configureTransmuxer(t){const{transmuxer:e}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}const eb=250,Uc=2,ib=.1,rb=.05;class sb{constructor(t,e,i,s){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=t,this.media=e,this.fragmentTracker=i,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:s,stalled:o}=this;if(s===null)return;const{currentTime:c,seeking:d}=s,f=this.seeking&&!d,p=!this.seeking&&d;if(this.seeking=d,c!==t){if(this.moved=!0,o!==null){if(this.stallReported){const x=self.performance.now()-o;z.warn(`playback not stuck anymore @${c}, after ${Math.round(x)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(s.paused&&!d||s.ended||s.playbackRate===0||!$e.getBuffered(s).length)return;const g=$e.bufferInfo(s,c,0),v=g.len>0,b=g.nextStart||0;if(!v&&!b)return;if(d){const x=g.len>Uc,M=!b||e&&e.start<=c||b-c>Uc&&!this.fragmentTracker.getPartialFragment(c);if(x||M)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const x=Math.max(b,g.start||0)-c,M=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,N=!(M==null||(E=M.details)==null)&&E.live?M.details.targetduration*2:Uc,D=this.fragmentTracker.getPartialFragment(c);if(x>0&&(x<=N||D)){this._trySkipBufferHole(D);return}}const k=self.performance.now();if(o===null){this.stalled=k;return}const w=k-o;if(!d&&w>=eb&&(this._reportStall(g),!this.media))return;const L=$e.bufferInfo(s,c,i.maxBufferHole);this._tryFixBufferStall(L,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:s,media:o}=this;if(o===null)return;const c=o.currentTime,d=s.getPartialFragment(c);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-c<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(z.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:s}=this;if(!s&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);z.warn(o.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:s}=this;if(s===null)return 0;const o=s.currentTime,c=$e.bufferInfo(s,o,0),d=o<c.start?c.start:c.nextStart;if(d){const f=c.len<=e.maxBufferHole,p=c.len>0&&c.len<1&&s.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:b}=this;let E=!1;if(o===0){const k=b.getAppendedFrag(0,Jt.MAIN);k&&d<k.end&&(E=!0)}if(!E){const k=t||b.getAppendedFrag(o,Jt.MAIN);if(k){let w=!1,L=k.end;for(;L<d;){const x=b.getPartialFragment(L);if(x)L+=x.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+rb,o+ib);if(z.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,s.currentTime=v,t&&!t.gap){const b=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:b,reason:b.message,frag:t})}return v}}return 0}_tryNudgeBuffer(){const{config:t,hls:e,media:i,nudgeRetry:s}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,s<t.nudgeMaxRetry){const c=o+(s+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${c}`);z.warn(d.message),i.currentTime=c,e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_NUDGE_ON_STALL,error:d,fatal:!1})}else{const c=new Error(`Playhead still not moving while enough data buffered @${o} after ${t.nudgeMaxRetry} nudges`);z.error(c.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}const nb=100;class ab extends _c{constructor(t,e,i){super(t,e,i,"[stream-controller]",Jt.MAIN),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:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(R.ERROR,this.onError,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(R.ERROR,this.onError,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(t){if(this.levels){const{lastCurrentTime:e,hls:i}=this;if(this.stopLoad(),this.setInterval(nb),this.level=-1,!this.startFragRequested){let s=i.startLevel;s===-1&&(i.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=i.nextAutoLevel),this.level=i.nextLoadLevel=s,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=Tt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Tt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Tt.WAITING_LEVEL:{var t;const{levels:i,level:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=Tt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Tt.IDLE;break}break}case Tt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Tt.IDLE)}break}this.state===Tt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:s}=this,{config:o,nextLoadLevel:c}=t;if(e===null||!s&&(this.startFragRequested||!o.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[c]))return;const d=i[c],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const L={};this.altAudio&&(L.type="video"),this.hls.trigger(R.BUFFER_EOS,L),this.state=Tt.ENDED;return}t.loadLevel!==c&&t.manualLevel===-1&&this.log(`Adapting to level ${c} from level ${this.level}`),this.level=t.nextLoadLevel=c;const g=d.details;if(!g||this.state===Tt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==c){this.level=c,this.state=Tt.WAITING_LEVEL;return}const v=f.len,b=this.getMaxBufferLength(d.maxBitrate);if(v>=b)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const E=this.backtrackFragment?this.backtrackFragment.start:f.end;let k=this.getNextFragment(E,g);if(this.couldBacktrack&&!this.fragPrevious&&k&&k.sn!=="initSegment"&&this.fragmentTracker.getState(k)!==ui.OK){var w;const L=((w=this.backtrackFragment)!=null?w:k).sn-g.startSN,x=g.fragments[L-1];x&&k.cc===x.cc&&(k=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(k&&this.isLoopLoading(k,E)){if(!k.gap){const L=this.audioOnly&&!this.altAudio?Ce.AUDIO:Ce.VIDEO,x=(L===Ce.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,L,Jt.MAIN)}k=this.getNextFragmentLoopLoading(k,g,f,Jt.MAIN,b)}k&&(k.initSegment&&!k.initSegment.data&&!this.bitrateTest&&(k=k.initSegment),this.loadFragment(k,d,E))}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);this.fragCurrent=t,s===ui.NOT_LOADED||s===ui.PARTIAL?t.sn==="initSegment"?this._loadInitSegment(t,e):this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):(this.startFragRequested=!0,super.loadFragment(t,e,i)):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,Jt.MAIN)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(e!=null&&e.readyState){let i;const s=this.getAppendedFrag(e.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const o=this.getLevelDetails();if(o!=null&&o.live){const d=this.getMainFwdBufferInfo();if(!d||d.len<o.targetduration*2)return}if(!e.paused&&t){const d=this.hls.nextLoadLevel,f=t[d],p=this.fragLastKbps;p&&this.fragCurrent?i=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:i=0}else i=0;const c=this.getBufferedFrag(e.currentTime+i);if(c){const d=this.followingBufferedFrag(c);if(d){this.abortCurrentFrag();const f=d.maxStartPTS?d.maxStartPTS:d.start,p=d.duration,g=Math.max(c.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(g,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Tt.KEY_LOADING:case Tt.FRAG_LOADING:case Tt.FRAG_LOADING_WAITING_RETRY:case Tt.PARSING:case Tt.PARSED:this.state=Tt.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const i=e.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new sb(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:t}=this;t&&this.onvplaying&&this.onvseeked&&(t.removeEventListener("playing",this.onvplaying),t.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const t=this.media,e=t?t.currentTime:null;jt(e)&&this.log(`Media seeked to ${e.toFixed(3)}`);const i=this.getMainFwdBufferInfo();if(i===null||i.len===0){this.warn(`Main forward buffer length on "seeked" event ${i?i.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(R.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(t,e){let i=!1,s=!1,o;e.levels.forEach(c=>{o=c.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(s=!0))}),this.audioCodecSwitch=i&&s&&!Ay(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:i}=this;if(!i||this.state!==Tt.IDLE)return;const s=i[e.level];(!s.details||s.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(s.details))&&(this.state=Tt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:s}=this,o=e.level,c=e.details,d=c.totalduration;if(!s){this.warn(`Levels were reset while loading level ${o}`);return}this.log(`Level ${o} loaded [${c.startSN},${c.endSN}]${c.lastPartSn?`[part-${c.lastPartSn}-${c.lastPartIndex}]`:""}, cc [${c.startCC}, ${c.endCC}] duration:${d}`);const f=s[o],p=this.fragCurrent;p&&(this.state===Tt.FRAG_LOADING||this.state===Tt.FRAG_LOADING_WAITING_RETRY)&&(p.level!==e.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let g=0;if(c.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(c),c.deltaUpdateFailed)return;g=this.alignPlaylists(c,f.details)}if(f.details=c,this.levelLastLoaded=o,this.hls.trigger(R.LEVEL_UPDATED,{details:c,level:o}),this.state===Tt.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=Tt.IDLE}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{levels:c}=this;if(!c){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const d=c[i.level],f=d.details;if(!f){this.warn(`Dropping fragment ${i.sn} of level ${i.level} after level details were reset`),this.fragmentTracker.removeFragment(i);return}const p=d.videoCodec,g=f.PTSKnown||!f.live,v=(e=i.initSegment)==null?void 0:e.data,b=this._getAudioCodec(d),E=this.transmuxer=this.transmuxer||new ef(this.hls,Jt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),k=s?s.index:-1,w=k!==-1,L=new Sc(i.level,i.sn,i.stats.chunkCount,o.byteLength,k,w),x=this.initPTS[i.cc];E.push(o,v,b,p,i,s,f.totalduration,g,L,x)}onAudioTrackSwitching(t,e){const i=this.altAudio;if(!e.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 o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const s=this.hls;i&&(s.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),s.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,s=!!this.hls.audioTracks[i].url;if(s){const o=this.videoBuffer;o&&this.mediaBuffer!==o&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=o)}this.altAudio=s,this.tick()}onBufferCreated(t,e){const i=e.tracks;let s,o,c=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,s=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&s?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i&&i.type!==Jt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===Tt.PARSED&&(this.state=Tt.IDLE);return}const o=s?s.stats:i.stats;this.fragLastKbps=Math.round(8*o.total/(o.buffering.end-o.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=Tt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.MAIN,e);break;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Tt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===ke.LEVEL&&(this.state=Tt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!$e.getBuffered(t).length){const i=this.state!==Tt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=Tt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Ce.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===Ce.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,e,Jt.MAIN)}}onLevelsUpdated(t,e){this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let i=this.startPosition;if(i>=0&&e<i){if(t.seeking){this.log(`could not seek to ${i}, already seeking at ${e}`);return}const s=$e.getBuffered(t),o=(s.length?s.start(0):0)-i;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),i+=o,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${e}`),t.currentTime=i}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e.indexOf("mp4a.40.5")!==-1?e="mp4a.40.2":e="mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(i=>{const{hls:s}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=Tt.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const o=t.stats;o.parsing.start=o.parsing.end=o.buffering.start=o.buffering.end=self.performance.now(),s.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{video:v,text:b,id3:E,initSegment:k}=o,{details:w}=g,L=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=Tt.PARSING,k){if(k!=null&&k.tracks){const N=f.initSegment||f;this._bufferInitSegment(g,k.tracks,N,c),s.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:i,tracks:k.tracks})}const x=k.initPTS,M=k.timescale;jt(x)&&(this.initPTS[f.cc]={baseTime:x,timescale:M},s.trigger(R.INIT_PTS_FOUND,{frag:f,id:i,initPTS:x,timescale:M}))}if(v&&w&&f.sn!=="initSegment"){const x=w.fragments[f.sn-1-w.startSN],M=f.sn===w.startSN,N=!x||f.cc>x.cc;if(o.independent!==!1){const{startPTS:D,endPTS:F,startDTS:H,endDTS:j}=v;if(p)p.elementaryStreams[v.type]={startPTS:D,endPTS:F,startDTS:H,endDTS:j};else if(v.firstKeyFrame&&v.independent&&c.id===1&&!N&&(this.couldBacktrack=!0),v.dropped&&v.independent){const st=this.getMainFwdBufferInfo(),at=(st?st.end:this.getLoadPosition())+this.config.maxBufferHole,Q=v.firstKeyFramePTS?v.firstKeyFramePTS:D;if(!M&&at<Q-this.config.maxBufferHole&&!N){this.backtrack(f);return}else N&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,F,f.start,j,!0)}f.setElementaryStreamInfo(v.type,D,F,H,j),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,c,M||N)}else if(M||N)f.gap=!0;else{this.backtrack(f);return}}if(L){const{startPTS:x,endPTS:M,startDTS:N,endDTS:D}=L;p&&(p.elementaryStreams[Ce.AUDIO]={startPTS:x,endPTS:M,startDTS:N,endDTS:D}),f.setElementaryStreamInfo(Ce.AUDIO,x,M,N,D),this.bufferFragmentData(L,f,p,c)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const x={id:i,frag:f,details:w,samples:E.samples};s.trigger(R.FRAG_PARSING_METADATA,x)}if(w&&b){const x={id:i,frag:f,details:w,samples:b.samples};s.trigger(R.FRAG_PARSING_USERDATA,x)}}_bufferInitSegment(t,e,i,s){if(this.state!==Tt.PARSING)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;const{audio:o,video:c,audiovideo:d}=e;if(o){let f=t.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),o.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&o.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),t.audioCodec&&t.audioCodec!==f&&this.log(`Swapping manifest audio codec "${t.audioCodec}" for "${f}"`),o.levelCodec=f,o.id="main",this.log(`Init audio buffer, container:${o.container}, codecs[selected/level/parsed]=[${f||""}/${t.audioCodec||""}/${o.codec}]`)}c&&(c.levelCodec=t.videoCodec,c.id="main",this.log(`Init video buffer, container:${c.container}, codecs[level/parsed]=[${t.videoCodec||""}/${c.codec}]`)),d&&this.log(`Init audiovideo buffer, container:${d.container}, codecs[level/parsed]=[${t.attrs.CODECS||""}/${d.codec}]`),this.hls.trigger(R.BUFFER_CODECS,e),Object.keys(e).forEach(f=>{const p=e[f].initSegment;p!=null&&p.byteLength&&this.hls.trigger(R.BUFFER_APPENDING,{type:f,data:p,frag:i,part:null,chunkMeta:s,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,Jt.MAIN)}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=Tt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if($e.isBuffered(t,i)?e=this.getAppendedFrag(i):$e.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const s=this.fragPlaying,o=e.level;(!s||e.sn!==s.sn||s.level!==o||e.urlId!==s.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!s||s.level!==o)&&this.hls.trigger(R.LEVEL_SWITCHED,{level:o}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){const t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}get currentProgramDateTime(){const t=this.media;if(t){const e=t.currentTime,i=this.currentFrag;if(i&&jt(e)&&jt(i.programDateTime)){const s=i.programDateTime+(e-i.start)*1e3;return new Date(s)}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class Cn{constructor(t,e=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=i}sample(t,e){const i=Math.pow(this.alpha_,t);this.estimate_=e*(1-i)+i*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class ob{constructor(t,e,i,s=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_=i,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Cn(t),this.fast_=new Cn(e),this.defaultTTFB_=s,this.ttfb_=new Cn(t)}update(t,e){const{slow_:i,fast_:s,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new Cn(t,i.getEstimate(),i.getTotalWeight())),s.halfLife!==e&&(this.fast_=new Cn(e,s.getEstimate(),s.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Cn(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,s=t/1e3,o=i/s;this.fast_.sample(s,o),this.slow_.sample(s,o)}sampleTTFB(t){const e=t/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(i,Math.max(t,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(){}}class lb{constructor(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;const e=t.config;this.bwEstimator=new ob(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:t}=this;t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(t,e){var i;const s=e.frag;this.ignoreFragment(s)||(this.fragCurrent=s,this.partCurrent=(i=e.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(t,e){this.clearTimer()}getTimeToLoadFrag(t,e,i,s){const o=t+i/e,c=s?this.lastLevelLoadSec:0;return o+c}onLevelLoaded(t,e){const i=this.hls.config,{total:s,bwEstimate:o}=e.stats;jt(s)&&jt(o)&&(this.lastLevelLoadSec=8*s/o),e.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{autoLevelEnabled:s,media:o}=i;if(!t||!o)return;const c=performance.now(),d=e?e.stats:t.stats,f=e?e.duration:t.duration,p=c-d.loading.start;if(d.aborted||d.loaded&&d.loaded===d.total||t.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!s||o.paused||!o.playbackRate||!o.readyState)return;const g=i.mainForwardBufferInfo;if(g===null)return;const v=this.bwEstimator.getEstimateTTFB(),b=Math.abs(o.playbackRate);if(p<=Math.max(v,1e3*(f/(b*2))))return;const E=g.len/b;if(E>=2*f/b)return;const k=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&k>-1,L=this.bwEstimator.getEstimate(),{levels:x,minAutoLevel:M}=i,N=x[t.level],D=d.total||Math.max(d.loaded,Math.round(f*N.maxBitrate/8));let F=p-k;F<1&&w&&(F=Math.min(p,d.loaded*8/L));const H=w?d.loaded*1e3/F:0,j=H?(D-d.loaded)/H:D*8/L+v/1e3;if(j<=E)return;const st=H?H*8:L;let at=Number.POSITIVE_INFINITY,Q;for(Q=t.level-1;Q>M;Q--){const kt=x[Q].maxBitrate;if(at=this.getTimeToLoadFrag(v/1e3,st,f*kt,!x[Q].details),at<E)break}at>=j||at>f*10||(i.nextLoadLevel=Q,w?this.bwEstimator.sample(p-Math.min(v,k),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),z.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
188
+ Time to underbuffer: ${E.toFixed(3)} s
157
189
  Estimated load time for current fragment: ${j.toFixed(3)} s
158
- Estimated load time for down switch fragment: ${ot.toFixed(3)} s
159
- TTFB estimate: ${E}
160
- Current BW estimate: ${Kt(R)?(R/1024).toFixed(3):"Unknown"} Kb/s
190
+ Estimated load time for down switch fragment: ${at.toFixed(3)} s
191
+ TTFB estimate: ${k}
192
+ Current BW estimate: ${jt(L)?(L/1024).toFixed(3):"Unknown"} Kb/s
161
193
  New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
162
- Aborting and switching to level ${tt}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(L.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d}))}onFragLoaded(t,{frag:e,part:i}){const s=i?i.stats:e.stats;if(e.type===Qt.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const o=i?i.duration:e.duration,c=this.hls.levels[e.level],d=(c.loaded?c.loaded.bytes:0)+s.loaded,f=(c.loaded?c.loaded.duration:0)+o;c.loaded={bytes:d,duration:f},c.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:s,frag:e,part:i,id:e.type};this.onFragBuffered(L.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:s}=e,o=s!=null&&s.stats.loaded?s.stats:i.stats;if(o.aborted||this.ignoreFragment(i))return;const c=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(c,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=c/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Qt.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let i=this.getNextABRAutoLevel();if(t!==-1){const s=this.hls.levels;if(s.length>Math.max(t,i)&&s[t].loadError<=s[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:s,config:o,minAutoLevel:c,media:d}=i,f=e?e.duration:t?t.duration:0,p=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():o.abrEwmaDefaultEstimate,v=i.mainForwardBufferInfo,A=(v?v.len:0)/p;let T=this.findBestLevel(g,c,s,A,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(T>=0)return T;Y.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let E=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,R=o.abrBandWidthUpFactor;if(!A){const x=this.bitrateTestDelay;x&&(E=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-x,Y.trace(`[abr] bitrate test took ${Math.round(1e3*x)}ms, set first fragment max fetchDuration to ${Math.round(1e3*E)} ms`),w=R=1)}return T=this.findBestLevel(g,c,s,A+E,w,R),Math.max(T,0)}findBestLevel(t,e,i,s,o,c){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,A=v[g],T=!!(A!=null&&(d=A.details)!=null&&d.live),E=A==null?void 0:A.codecSet,w=p?p.duration:f?f.duration:0,R=this.bwEstimator.getEstimateTTFB()/1e3;let x=e,M=-1;for(let G=i;G>=e;G--){const _=v[G];if(!_||E&&_.codecSet!==E){_&&(x=Math.min(G,x),M=Math.max(G,M));continue}M!==-1&&Y.trace(`[abr] Skipped level(s) ${x}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const F=_.details,H=(p?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||w;let j;G<=g?j=o*t:j=c*t;const nt=v[G].maxBitrate,ot=this.getTimeToLoadFrag(R,j,nt*H,F===void 0);if(Y.trace(`[abr] level:${G} adjustedbw-bitrate:${Math.round(j-nt)} avgDuration:${H.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${ot.toFixed(1)}`),j>nt&&(ot===0||!Kt(ot)||T&&!this.bitrateTestDelay||ot<s))return G}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class Y0{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;if(t.length)t.length===1?i=t[0]:i=qy(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function qy(n,t){const e=new Uint8Array(t);let i=0;for(let s=0;s<n.length;s++){const o=n[s];e.set(o,i),i+=o.length}return e}const Z0=100;class Qy extends bc{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Qt.AUDIO),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.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.LEVEL_LOADED,this.onLevelLoaded,this),t.on(L.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(L.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(L.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(L.ERROR,this.onError,this),t.on(L.BUFFER_RESET,this.onBufferReset,this),t.on(L.BUFFER_CREATED,this.onBufferCreated,this),t.on(L.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(L.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(L.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.LEVEL_LOADED,this.onLevelLoaded,this),t.off(L.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(L.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(L.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(L.ERROR,this.onError,this),t.off(L.BUFFER_RESET,this.onBufferReset,this),t.off(L.BUFFER_CREATED,this.onBufferCreated,this),t.off(L.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(L.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(L.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){if(i==="main"){const c=e.cc;this.initPTS[e.cc]={baseTime:s,timescale:o},this.log(`InitPTS for cc: ${c} found from main: ${s}`),this.videoTrackCC=c,this.state===Tt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=Tt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(Z0),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Tt.IDLE):(this.loadedmetadata=!1,this.state=Tt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Tt.IDLE:this.doTickIdle();break;case Tt.WAITING_TRACK:{var t;const{levels:i,trackId:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=Tt.WAITING_INIT_PTS}break}case Tt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Tt.IDLE);break}case Tt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:s,part:o,cache:c,complete:d}=i;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Tt.FRAG_LOADING;const f=c.flush(),p={frag:s,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Me.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);fc(p.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=Tt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Tt.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:i,trackId:s}=this,o=t.config;if(!(e!=null&&e[s])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const c=e[s],d=c.details;if(!d||d.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(d)){this.state=Tt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,_e.AUDIO,Qt.AUDIO));const p=this.getFwdBufferInfo(f,Qt.AUDIO);if(p===null)return;const{bufferedTrack:g,switchingTrack:v}=this;if(!v&&this._streamEnded(p,d)){t.trigger(L.BUFFER_EOS,{type:"audio"}),this.state=Tt.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Qt.MAIN),T=p.len,E=this.getMaxBufferLength(A==null?void 0:A.len);if(T>=E&&!v)return;const w=d.fragments[0].start;let R=p.end;if(v&&i){const _=this.getLoadPosition();g&&v.attrs!==g.attrs&&(R=_),d.PTSKnown&&_<w&&(p.end>w||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=w+.05)}let x=this.getNextFragment(R,d),M=!1;if(x&&this.isLoopLoading(x,R)&&(M=!!x.gap,x=this.getNextFragmentLoopLoading(x,d,p,Qt.MAIN,E)),!x){this.bufferFlushed=!0;return}const G=A&&x.start>A.end+d.targetduration;if(G||!(A!=null&&A.len)&&p.len){const _=this.getAppendedFrag(x.start,Qt.MAIN);if(_===null||(M||(M=!!_.gap||!!G&&A.len===0),G&&!M||M&&p.nextStart&&p.nextStart<_.end))return}this.loadFragment(x,c,R)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(i=>new Aa(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(Z0):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=Tt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Tt.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!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(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(L.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:s}=this,{details:o,id:c}=e;if(!s){this.warn(`Audio tracks were reset while loading level ${c}`);return}this.log(`Track ${c} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=s[c];let f=0;if(o.live||(i=d.details)!=null&&i.live){this.checkLiveUpdate(o);const p=this.mainDetails;if(o.deltaUpdateFailed||!p)return;!d.details&&o.hasProgramDateTime&&p.hasProgramDateTime?(L0(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=c,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===Tt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=Tt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{config:c,trackId:d,levels:f}=this;if(!f){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const p=f[d];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const g=p.details;if(!g){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const v=c.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new z0(this.hls,Qt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const T=this.initPTS[i.cc],E=(e=i.initSegment)==null?void 0:e.data;if(T!==void 0){const w=s?s.index:-1,R=w!==-1,x=new mc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,R);A.push(o,E,v,"",i,s,g.totalduration,!1,x,T)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${g.startSN} ,${g.endSN}],track ${d}`);const{cache:w}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new Y0,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Tt.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i.type!==Qt.AUDIO){if(!this.loadedmetadata&&i.type===Qt.MAIN){const o=this.videoBuffer||this.media;o&&Me.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;const o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(L.AUDIO_TRACK_SWITCHED,Bi({},o)))}this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=Tt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.AUDIO,e);break;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Tt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===Ee.AUDIO_TRACK&&(this.state=Tt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===_e.AUDIO&&(this.bufferFlushed=!0,this.state===Tt.ENDED&&(this.state=Tt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:A,text:T,id3:E,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=Tt.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const R=f.initSegment||f;this._bufferInitSegment(w.tracks,R,c),s.trigger(L.FRAG_PARSING_INIT_SEGMENT,{frag:R,id:i,tracks:w.tracks})}if(A){const{startPTS:R,endPTS:x,startDTS:M,endDTS:G}=A;p&&(p.elementaryStreams[_e.AUDIO]={startPTS:R,endPTS:x,startDTS:M,endDTS:G}),f.setElementaryStreamInfo(_e.AUDIO,R,x,M,G),this.bufferFragmentData(A,f,p,c)}if(E!=null&&(e=E.samples)!=null&&e.length){const R=ni({id:i,frag:f,details:v},E);s.trigger(L.FRAG_PARSING_METADATA,R)}if(T){const R=ni({id:i,frag:f,details:v},T);s.trigger(L.FRAG_PARSING_USERDATA,R)}}_bufferInitSegment(t,e,i){if(this.state!==Tt.PARSING)return;t.video&&delete t.video;const s=t.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(L.BUFFER_CODECS,t);const o=s.initSegment;if(o!=null&&o.byteLength){const c={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(L.BUFFER_APPENDING,c)}this.tick()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||s===di.NOT_LOADED||s===di.PARTIAL){var o;t.sn==="initSegment"?this._loadInitSegment(t,e):(o=e.details)!=null&&o.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=Tt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:s}=this,o=s==null?void 0:s.attrs,c=t.attrs;i&&o&&(o.CHANNELS!==c.CHANNELS||o.NAME!==c.NAME||o.LANGUAGE!==c.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(L.AUDIO_TRACK_SWITCHED,Bi({},t))}}class Jy extends pc{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.LEVEL_LOADING,this.onLevelLoading,this),t.on(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(L.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(L.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.LEVEL_LOADING,this.onLevelLoading,this),t.off(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(L.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(L.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:i,groupId:s,details:o}=e,c=this.tracksInGroup[i];if(!c||c.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${c.groupId}`);return}const d=c.details;c.details=e.details,this.log(`audio-track ${i} "${c.name}" lang:${c.lang} group:${s} loaded [${o.startSN}-${o.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i||null;const s=this.tracks.filter(c=>!i||c.groupId===i);this.selectDefaultTrack&&!s.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;const o={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${i}`),this.hls.trigger(L.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===Ee.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;e[this.trackId];const s=e[t],{groupId:o,name:c}=s;if(this.log(`Switching to audio-track ${t} "${c}" lang:${s.lang} group:${o}`),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(L.AUDIO_TRACK_SWITCHING,Bi({},s)),s.details&&!s.details.live)return;const d=this.switchParams(s.url,i==null?void 0:i.details);this.loadPlaylist(d)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(i.message),this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||t.name===s.name&&t.lang===s.lang))return s.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${s}`),this.clearTimer(),this.hls.trigger(L.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}}function X0(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(!tb(n[e].attrs,t[e].attrs))return!1;return!0}function tb(n,t){const e=n["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>n[i]!==t[i])}const q0=500;class eb extends bc{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Qt.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.LEVEL_LOADED,this.onLevelLoaded,this),t.on(L.ERROR,this.onError,this),t.on(L.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(L.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(L.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(L.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(L.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.LEVEL_LOADED,this.onLevelLoaded,this),t.off(L.ERROR,this.onError,this),t.off(L.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(L.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(L.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(L.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(L.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Tt.IDLE,this.setInterval(q0),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:i,success:s}=e;if(this.fragPrevious=i,this.state=Tt.IDLE,!s)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let c;const d=i.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){c=o[p];break}const f=i.start+i.duration;c?c.end=f:(c={start:d,end:f},o.push(c)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:s}=e;if(i===0&&s!==Number.POSITIVE_INFINITY){const o=s-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(c=>{for(let d=0;d<c.length;){if(c[d].end<=o){c.shift();continue}else if(c[d].start<o)c[d].start=o;else break;d++}}),this.fragmentTracker.removeFragmentsInRange(i,o,Qt.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Qt.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const i=e.frag;(i==null?void 0:i.type)===Qt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(X0(this.levels,e)){this.levels=e.map(i=>new Aa(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const s=new Aa(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Qt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(q0)}onSubtitleTrackLoaded(t,e){var i;const{details:s,id:o}=e,{currentTrackId:c,levels:d}=this;if(!d.length)return;const f=d[c];if(o>=d.length||o!==c||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(s.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(s.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(s,f.details),p===0&&v&&(p=v.start,dc(s,p))):s.hasProgramDateTime&&g.hasProgramDateTime?(L0(s,g),p=s.fragments[0].start):v&&(p=v.start,dc(s,p))}f.details=s,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(f.details,p),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Tt.IDLE&&(Ea(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,s=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){const c=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(d=>{throw o.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const f=performance.now();o.trigger(L.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:c,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=Tt.IDLE})}}doTick(){if(!this.media){this.state=Tt.IDLE;return}if(this.state===Tt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:s}=this,o=this.getLoadPosition(),c=Me.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,s.maxBufferHole),{end:d,len:f}=c,p=this.getFwdBufferInfo(this.media,Qt.MAIN),g=i.details,v=this.getMaxBufferLength(p==null?void 0:p.len)+g.levelTargetDuration;if(f>v)return;const A=g.fragments,T=A.length,E=g.edge;let w=null;const R=this.fragPrevious;if(d<E){const x=s.maxFragLookUpTolerance,M=d>E-x?0:x;w=Ea(R,A,Math.max(A[0].start,d),M),!w&&R&&R.start<A[0].start&&(w=A[0])}else w=A[T-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const x=w.sn-g.startSN,M=A[x-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===di.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===di.NOT_LOADED&&this.loadFragment(w,i,d)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new ib(this.tracksBuffered[this.currentTrackId]||[])}}class ib{constructor(t){this.buffered=void 0;const e=(i,s,o)=>{if(s=s>>>0,s>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${o})`);return t[s][i]};this.buffered={get length(){return t.length},end(i){return e("end",i,t.length)},start(i){return e("start",i,t.length)}}}}class rb extends pc{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.LEVEL_LOADING,this.onLevelLoading,this),t.on(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(L.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(L.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.LEVEL_LOADING,this.onLevelLoading,this),t.off(L.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(L.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(L.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Dc(this.media.textTracks).forEach(t=>{bn(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:i,details:s}=e,{trackId:o}=this,c=this.tracksInGroup[o];if(!c){this.warn(`Invalid subtitle track id ${i}`);return}const d=c.details;c.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const i=e.textGroupIds[e.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const o=this.tracks.filter(f=>!i||f.groupId===i);this.tracksInGroup=o;const c=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${i}" group-id`),this.hls.trigger(L.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.setSubtitleTrack(c,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t===s.name))return s.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===Ee.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(L.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const s=Dc(e.textTracks),o=s.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(s).forEach(d=>{d.mode="disabled"});else{const d=o[i];d&&(d.mode="disabled")}const c=o[t];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=s[t])!=null&&i.details)||t<-1||t>=s.length)return;this.clearTimer();const o=s[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:c,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(L.SUBTITLE_TRACK_SWITCH,{id:c,groupId:d,name:f,type:p,url:g});const v=this.switchParams(o.url,e==null?void 0:e.details);this.loadPlaylist(v)}else this.hls.trigger(L.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=Dc(this.media.textTracks);for(let i=0;i<e.length;i++)if(e[i].mode==="hidden")t=i;else if(e[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function Dc(n){const t=[];for(let e=0;e<n.length;e++){const i=n[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(n[e])}return t}class sb{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const i=this.queues[e];i.push(t),i.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise(o=>{e=o}),s={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,t),i}executeNext(t){const{buffers:e,queues:i}=this,s=e[t],o=i[t];if(o.length){const c=o[0];try{c.execute()}catch(d){Y.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),c.onError(d),s!=null&&s.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const Q0=Ao(),J0=/([ha]vc.)(?:\.[^.,]+)+/;class nb{constructor(t){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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:i}=this;Y.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(L.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{Y.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{Y.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&Y.error(`Media element src was set while attaching MediaSource (${i} > ${e.src})`)},this.hls=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}registerListeners(){const{hls:t}=this;t.on(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.BUFFER_RESET,this.onBufferReset,this),t.on(L.BUFFER_APPENDING,this.onBufferAppending,this),t.on(L.BUFFER_CODECS,this.onBufferCodecs,this),t.on(L.BUFFER_EOS,this.onBufferEos,this),t.on(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(L.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(L.FRAG_PARSED,this.onFragParsed,this),t.on(L.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.BUFFER_RESET,this.onBufferReset,this),t.off(L.BUFFER_APPENDING,this.onBufferAppending,this),t.off(L.BUFFER_CODECS,this.onBufferCodecs,this),t.off(L.BUFFER_EOS,this.onBufferEos,this),t.off(L.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(L.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(L.FRAG_PARSED,this.onFragParsed,this),t.off(L.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new sb(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,Y.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&Q0){const s=this.mediaSource=new Q0;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(s),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(Y.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(s){Y.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):Y.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(L.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(i){Y.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(s=>{if(i){const o=this.tracks[s];if(o&&typeof o.buffer.changeType=="function"){const{id:c,codec:d,levelCodec:f,container:p,metadata:g}=e[s],v=(o.levelCodec||o.codec).replace(J0,"$1"),A=(f||d).replace(J0,"$1");if(v!==A){const T=`${p};codecs=${f||d}`;this.appendChangeType(s,T),Y.log(`[buffer-controller]: switching codec ${v} to ${A}`),this.tracks[s]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:c}}}}else this.pendingTracks[s]=e[s]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,s={execute:()=>{const o=this.sourceBuffer[t];o&&(Y.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{Y.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(s,t)}onBufferAppending(t,e){const{hls:i,operationQueue:s,tracks:o}=this,{data:c,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],A=self.performance.now();v.start=A;const T=f.stats.buffering,E=p?p.stats.buffering:null;T.start===0&&(T.start=A),E&&E.start===0&&(E.start=A);const w=o.audio;let R=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(R=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const x=f.start,M={execute:()=>{if(v.executeStart=self.performance.now(),R){const G=this.sourceBuffer[d];if(G){const _=x-G.timestampOffset;Math.abs(_)>=.1&&(Y.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${x} (delta: ${_}) sn: ${f.sn})`),G.timestampOffset=x)}}this.appendExecutor(c,d)},onStart:()=>{},onComplete:()=>{const G=self.performance.now();v.executeEnd=v.end=G,T.first===0&&(T.first=G),E&&E.first===0&&(E.first=G);const{sourceBuffer:_}=this,F={};for(const H in _)F[H]=Me.getBuffered(_[H]);this.appendError=0,this.hls.trigger(L.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:F})},onError:G=>{Y.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,G);const _={type:qt.MEDIA_ERROR,parent:f.type,details:ut.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:G,err:G,fatal:!1};G.code===DOMException.QUOTA_EXCEEDED_ERR?_.details=ut.BUFFER_FULL_ERROR:(this.appendError++,_.details=ut.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(Y.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),_.fatal=!0)),i.trigger(L.ERROR,_)}};s.append(M,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,s=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(L.BUFFER_FLUSHED,{type:o})},onError:c=>{Y.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,c)}});e.type?i.append(s(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(s(o),o)})}onFragParsed(t,e){const{frag:i,part:s}=e,o=[],c=s?s.elementaryStreams:i.elementaryStreams;c[_e.AUDIOVIDEO]?o.push("audiovideo"):(c[_e.AUDIO]&&o.push("audio"),c[_e.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,s&&(s.stats.buffering.end=f);const p=s?s.stats:i.stats;this.hls.trigger(L.FRAG_BUFFERED,{frag:i,part:s,stats:p,id:i.type})};o.length===0&&Y.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(d,o)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((i,s)=>{const o=this.sourceBuffer[s];return o&&(!e.type||e.type===s)&&(o.ending=!0,o.ended||(o.ended=!0,Y.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(Y.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(s=>{const o=this.sourceBuffer[s];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&Y.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}Y.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:i,sourceBuffer:s}=this;if(!i||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const c=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!Kt(c)||c<0)return;const d=i.currentTime,f=e.levelTargetDuration,p=Math.max(c,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const A=s[v];if(A){const T=Me.getBuffered(A);if(T.length>0&&g>T.start(0)){if(t.trigger(L.BACK_BUFFER_REACHED,{bufferEnd:g}),e.live)t.trigger(L.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g});else if(A.ended&&T.end(T.length-1)-d<f*2){Y.info(`[buffer-controller]: Cannot flush ${v} back buffer while SourceBuffer is in ended state`);return}t.trigger(L.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:v})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:i,mediaSource:s}=this,o=t.fragments[0].start+t.totalduration,c=i.duration,d=Kt(s.duration)?s.duration:0;t.live&&e.config.liveDurationInfinity?(Y.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>c||!Kt(c))&&(Y.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),s.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const s=Math.max(0,i[0].start),o=Math.max(s,s+t.totalduration);e.setLiveSeekableRange(s,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!t||s===2){this.createSourceBuffers(i),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(L.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(c=>{e.executeNext(c)});else{const c=new Error("could not create source buffer for media codec(s)");this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:c,reason:c.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const s in t)if(!e[s]){const o=t[s];if(!o)throw Error(`source buffer exists for track ${s}, however track does not`);const c=o.levelCodec||o.codec,d=`${o.container};codecs=${c}`;Y.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[s]=i.addSourceBuffer(d),p=s;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[s]={buffer:f,codec:c,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){Y.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const i=new Error(`${t} SourceBuffer error`);Y.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(L.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const s=this.operationQueue.current(t);s&&s.onError(e)}removeExecutor(t,e,i){const{media:s,mediaSource:o,operationQueue:c,sourceBuffer:d}=this,f=d[t];if(!s||!o||!f){Y.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),c.shiftAndExecuteNext(t);return}const p=Kt(s.duration)?s.duration:1/0,g=Kt(o.duration)?o.duration:1/0,v=Math.max(0,e),A=Math.min(i,p,g);A>v&&!f.ending?(f.ended=!1,Y.log(`[buffer-controller]: Removing [${v},${A}] from the ${t} SourceBuffer`),f.remove(v,A)):c.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:s}=this,o=s[e];if(!o){Y.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(e);return}o.ended=!1,o.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){Y.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,s=e.map(o=>i.appendBlocker(o));Promise.all(s).then(()=>{t(),e.forEach(o=>{const c=this.sourceBuffer[o];c!=null&&c.updating||i.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const s=this.sourceBuffer[t];if(!s)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),s.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const tf={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},ef=function(n){let t=n;return tf.hasOwnProperty(n)&&(t=tf[n]),String.fromCharCode(t)},Ar=15,Jr=100,ab={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},ob={17:2,18:4,21:6,22:8,23:10,19:13,20:15},lb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},cb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},hb=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class db{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;Y.log(`${this.time} [${t}] ${i}`)}}}const rn=function(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e].toString(16));return t};class rf{constructor(t,e,i,s,o){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=i||!1,this.background=s||"black",this.flash=o||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const s=e[i];t.hasOwnProperty(s)&&(this[s]=t[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class ub{constructor(t,e,i,s,o,c){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new rf(e,i,s,o,c)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class fb{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<Jr;e++)this.chars.push(new ub);this.logger=t,this.pos=0,this.currPenState=new rf}equals(t){let e=!0;for(let i=0;i<Jr;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<Jr;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<Jr;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Jr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Jr)}moveCursor(t){const e=this.pos+t;if(t>1)for(let i=this.pos+1;i<e+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=ef(t);if(this.pos>=Jr){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<Jr;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<Jr;i++){const s=this.chars[i].uchar;s!==" "&&(e=!1),t.push(s)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class xc{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<Ar;e++)this.rows.push(new fb(t));this.logger=t,this.currRow=Ar-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Ar;t++)this.rows[t].clear();this.currRow=Ar-1}equals(t){let e=!0;for(let i=0;i<Ar;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Ar;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Ar;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let d=0;d<Ar;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,c=this.lastOutputScreen;if(c){const d=c.rows[o].cueStartTime,f=this.logger.time;if(d&&f!==null&&d<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[e-this.nrRollUpRows+p+1].copy(c.rows[o+p])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,c=Math.max(o-1,0);i.setCursor(t.indent),t.color=i.chars[c].penState.foreground}const s={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let i="",s=-1;for(let o=0;o<Ar;o++){const c=this.rows[o].getTextString();c&&(s=o+1,t?e.push("Row "+s+": '"+c+"'"):e.push(c.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
163
- `)),i}getTextAndFormat(){return this.rows}}class sf{constructor(t,e,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new xc(i),this.nonDisplayedMemory=new xc(i),this.lastOutputScreen=new xc(i),this.currRollUpRow=this.displayedMemory.rows[Ar-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Ar-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}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"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const i=Math.floor(t/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=s[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class nf{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new db;this.channels=[null,new sf(t,e,s),new sf(t+1,i,s)],this.cmdHistory=of(),this.logger=s}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,s,o,c=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(s=e[d]&127,o=e[d+1]&127,!(s===0&&o===0)){if(this.logger.log(3,"["+rn([e[d],e[d+1]])+"] -> ("+rn([s,o])+")"),i=this.parseCmd(s,o),i||(i=this.parseMidrow(s,o)),i||(i=this.parsePAC(s,o)),i||(i=this.parseBackgroundAttributes(s,o)),!i&&(c=this.parseChars(s,o),c)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(c):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!c&&this.logger.log(2,"Couldn't parse cleaned data "+rn([s,o])+" orig: "+rn([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,s=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(s||o))return!1;if(af(t,e,i))return kn(null,null,i),this.logger.log(3,"Repeated command ("+rn([t,e])+") is dropped"),!0;const c=t===20||t===21||t===23?1:2,d=this.channels[c];return t===20||t===21||t===28||t===29?e===32?d.ccRCL():e===33?d.ccBS():e===34?d.ccAOF():e===35?d.ccAON():e===36?d.ccDER():e===37?d.ccRU(2):e===38?d.ccRU(3):e===39?d.ccRU(4):e===40?d.ccFON():e===41?d.ccRDC():e===42?d.ccTR():e===43?d.ccRTD():e===44?d.ccEDM():e===45?d.ccCR():e===46?d.ccENM():e===47&&d.ccEOC():d.ccTO(e-32),kn(t,e,i),this.currentChannel=c,!0}parseMidrow(t,e){let i=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(e),this.logger.log(3,"MIDROW ("+rn([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const s=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,c=(t===16||t===24)&&e>=64&&e<=95;if(!(o||c))return!1;if(af(t,e,s))return kn(null,null,s),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?ab[t]:lb[t]:i=d===1?ob[t]:cb[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),kn(t,e,s),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(t,e){let i,s=null,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19){let c;o===17?c=e+80:o===18?c=e+112:c=e+144,this.logger.log(2,"Special char '"+ef(c)+"' in channel "+i),s=[c]}else t>=32&&t<=127&&(s=e===0?[t]:[t,e]);if(s){const c=rn(s);this.logger.log(3,"Char codes = "+c.join(",")),kn(t,e,this.cmdHistory)}return s}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,s=(t===23||t===31)&&e>=45&&e<=47;if(!(i||s))return!1;let o;const c={};t===16||t===24?(o=Math.floor((e-32)/2),c.background=hb[o],e%2===1&&(c.background=c.background+"_semi")):e===45?c.background="transparent":(c.foreground="black",e===47&&(c.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(c),kn(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=of()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function kn(n,t,e){e.a=n,e.b=t}function af(n,t,e){return e.a===n&&e.b===t}function of(){return{a:null,b:null}}class xo{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Pc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const n=["","lr","rl"],t=["start","middle","end","left","right"];function e(d,f){if(typeof f!="string"||!Array.isArray(d))return!1;const p=f.toLowerCase();return~d.indexOf(p)?p:!1}function i(d){return e(n,d)}function s(d){return e(t,d)}function o(d,...f){let p=1;for(;p<arguments.length;p++){const g=arguments[p];for(const v in g)d[v]=g[v]}return d}function c(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let A="",T=!1,E=d,w=f,R=p,x=null,M="",G=!0,_="auto",F="start",H=50,j="middle",nt=50,ot="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return A},set:function(tt){A=""+tt}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return T},set:function(tt){T=!!tt}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return E},set:function(tt){if(typeof tt!="number")throw new TypeError("Start time must be set to a number.");E=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(tt){if(typeof tt!="number")throw new TypeError("End time must be set to a number.");w=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return R},set:function(tt){R=""+tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return x},set:function(tt){x=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(tt){const kt=i(tt);if(kt===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return G},set:function(tt){G=!!tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return _},set:function(tt){if(typeof tt!="number"&&tt!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");_=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return F},set:function(tt){const kt=s(tt);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");F=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return H},set:function(tt){if(tt<0||tt>100)throw new Error("Position must be between 0 and 100.");H=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return j},set:function(tt){const kt=s(tt);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");j=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return nt},set:function(tt){if(tt<0||tt>100)throw new Error("Size must be between 0 and 100.");nt=tt,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return ot},set:function(tt){const kt=s(tt);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");ot=kt,this.hasBeenReset=!0}})),g.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class pb{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function lf(n){function t(i,s,o,c){return(i|0)*3600+(s|0)*60+(o|0)+parseFloat(c||0)}const e=n.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class gb{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let s=0;s<i.length;++s)if(e===i[s]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function cf(n,t,e,i){const s=i?n.split(i):[n];for(const o in s){if(typeof s[o]!="string")continue;const c=s[o].split(e);if(c.length!==2)continue;const d=c[0],f=c[1];t(d,f)}}const Oc=new Pc(0,0,""),Po=Oc.align==="middle"?"middle":"center";function mb(n,t,e){const i=n;function s(){const d=lf(n);if(d===null)throw new Error("Malformed timestamp: "+i);return n=n.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new gb;cf(d,function(A,T){let E;switch(A){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===T){p.set(A,e[w].region);break}break;case"vertical":p.alt(A,T,["rl","lr"]);break;case"line":E=T.split(","),p.integer(A,E[0]),p.percent(A,E[0])&&p.set("snapToLines",!1),p.alt(A,E[0],["auto"]),E.length===2&&p.alt("lineAlign",E[1],["start",Po,"end"]);break;case"position":E=T.split(","),p.percent(A,E[0]),E.length===2&&p.alt("positionAlign",E[1],["start",Po,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,T);break;case"align":p.alt(A,T,["start",Po,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Oc.line===-1&&(g=-1),f.line=g,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",Po);let v=p.get("position","auto");v==="auto"&&Oc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function c(){n=n.replace(/^\s+/,"")}if(c(),t.startTime=s(),c(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);n=n.slice(3),c(),t.endTime=s(),c(),o(n,t)}function hf(n){return n.replace(/<br(?: \/)?>/gi,`
164
- `)}class vb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new pb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function i(){let o=e.buffer,c=0;for(o=hf(o);c<o.length&&o[c]!=="\r"&&o[c]!==`
194
+ Aborting and switching to level ${Q}`),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),i.trigger(R.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:d}))}onFragLoaded(t,{frag:e,part:i}){const s=i?i.stats:e.stats;if(e.type===Jt.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),this.lastLoadedFragLevel=e.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const o=i?i.duration:e.duration,c=this.hls.levels[e.level],d=(c.loaded?c.loaded.bytes:0)+s.loaded,f=(c.loaded?c.loaded.duration:0)+o;c.loaded={bytes:d,duration:f},c.realBitrate=Math.round(8*d/f)}if(e.bitrateTest){const o={stats:s,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:s}=e,o=s!=null&&s.stats.loaded?s.stats:i.stats;if(o.aborted||this.ignoreFragment(i))return;const c=o.parsing.end-o.loading.start-Math.min(o.loading.first-o.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(c,o.loaded),o.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=c/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==Jt.MAIN||t.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const t=this._nextAutoLevel,e=this.bwEstimator;if(t!==-1&&!e.canEstimate())return t;let i=this.getNextABRAutoLevel();if(t!==-1){const s=this.hls.levels;if(s.length>Math.max(t,i)&&s[t].loadError<=s[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:s,config:o,minAutoLevel:c,media:d}=i,f=e?e.duration:t?t.duration:0,p=d&&d.playbackRate!==0?Math.abs(d.playbackRate):1,g=this.bwEstimator?this.bwEstimator.getEstimate():o.abrEwmaDefaultEstimate,v=i.mainForwardBufferInfo,b=(v?v.len:0)/p;let E=this.findBestLevel(g,c,s,b,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;z.trace(`[abr] ${b?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let k=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,L=o.abrBandWidthUpFactor;if(!b){const x=this.bitrateTestDelay;x&&(k=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-x,z.trace(`[abr] bitrate test took ${Math.round(1e3*x)}ms, set first fragment max fetchDuration to ${Math.round(1e3*k)} ms`),w=L=1)}return E=this.findBestLevel(g,c,s,b+k,w,L),Math.max(E,0)}findBestLevel(t,e,i,s,o,c){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,b=v[g],E=!!(b!=null&&(d=b.details)!=null&&d.live),k=b==null?void 0:b.codecSet,w=p?p.duration:f?f.duration:0,L=this.bwEstimator.getEstimateTTFB()/1e3;let x=e,M=-1;for(let N=i;N>=e;N--){const D=v[N];if(!D||k&&D.codecSet!==k){D&&(x=Math.min(N,x),M=Math.max(N,M));continue}M!==-1&&z.trace(`[abr] Skipped level(s) ${x}-${M} with CODECS:"${v[M].attrs.CODECS}"; not compatible with "${b.attrs.CODECS}"`);const F=D.details,H=(p?F==null?void 0:F.partTarget:F==null?void 0:F.averagetargetduration)||w;let j;N<=g?j=o*t:j=c*t;const st=v[N].maxBitrate,at=this.getTimeToLoadFrag(L,j,st*H,F===void 0);if(z.trace(`[abr] level:${N} adjustedbw-bitrate:${Math.round(j-st)} avgDuration:${H.toFixed(1)} maxFetchDuration:${s.toFixed(1)} fetchDuration:${at.toFixed(1)}`),j>st&&(at===0||!jt(at)||E&&!this.bitrateTestDelay||at<s))return N}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class rf{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let i;if(t.length)t.length===1?i=t[0]:i=cb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function cb(n,t){const e=new Uint8Array(t);let i=0;for(let s=0;s<n.length;s++){const o=n[s];e.set(o,i),i+=o.length}return e}const sf=100;class hb extends _c{constructor(t,e,i){super(t,e,i,"[audio-stream-controller]",Jt.AUDIO),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.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this),t.on(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(R.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this),t.off(R.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){if(i==="main"){const c=e.cc;this.initPTS[e.cc]={baseTime:s,timescale:o},this.log(`InitPTS for cc: ${c} found from main: ${s}`),this.videoTrackCC=c,this.state===Tt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=Tt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(sf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=Tt.IDLE):(this.loadedmetadata=!1,this.state=Tt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case Tt.IDLE:this.doTickIdle();break;case Tt.WAITING_TRACK:{var t;const{levels:i,trackId:s}=this,o=i==null||(t=i[s])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=Tt.WAITING_INIT_PTS}break}case Tt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),s=this.retryDate;(!s||i>=s||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Tt.IDLE);break}case Tt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:s,part:o,cache:c,complete:d}=i;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Tt.FRAG_LOADING;const f=c.flush(),p={frag:s,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=$e.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);kc(p.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=Tt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Tt.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:t}=this;t!=null&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){const{hls:t,levels:e,media:i,trackId:s}=this,o=t.config;if(!(e!=null&&e[s])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const c=e[s],d=c.details;if(!d||d.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(d)){this.state=Tt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Ce.AUDIO,Jt.AUDIO));const p=this.getFwdBufferInfo(f,Jt.AUDIO);if(p===null)return;const{bufferedTrack:g,switchingTrack:v}=this;if(!v&&this._streamEnded(p,d)){t.trigger(R.BUFFER_EOS,{type:"audio"}),this.state=Tt.ENDED;return}const b=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Jt.MAIN),E=p.len,k=this.getMaxBufferLength(b==null?void 0:b.len);if(E>=k&&!v)return;const w=d.fragments[0].start;let L=p.end;if(v&&i){const D=this.getLoadPosition();g&&v.attrs!==g.attrs&&(L=D),d.PTSKnown&&D<w&&(p.end>w||p.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=w+.05)}let x=this.getNextFragment(L,d),M=!1;if(x&&this.isLoopLoading(x,L)&&(M=!!x.gap,x=this.getNextFragmentLoopLoading(x,d,p,Jt.MAIN,k)),!x){this.bufferFlushed=!0;return}const N=b&&x.start>b.end+d.targetduration;if(N||!(b!=null&&b.len)&&p.len){const D=this.getAppendedFrag(x.start,Jt.MAIN);if(D===null||(M||(M=!!D.gap||!!N&&b.len===0),N&&!M||M&&p.nextStart&&p.nextStart<D.end))return}this.loadFragment(x,c,L)}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.min(Math.max(e,t),this.config.maxMaxBufferLength):e}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(i=>new Ra(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),i?this.setInterval(sf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=Tt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=Tt.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!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(t,e){this.mainDetails=e.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(R.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(t,e){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=e;return}const{levels:s}=this,{details:o,id:c}=e;if(!s){this.warn(`Audio tracks were reset while loading level ${c}`);return}this.log(`Track ${c} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""},duration:${o.totalduration}`);const d=s[c];let f=0;if(o.live||(i=d.details)!=null&&i.live){this.checkLiveUpdate(o);const p=this.mainDetails;if(o.deltaUpdateFailed||!p)return;!d.details&&o.hasProgramDateTime&&p.hasProgramDateTime?(O0(o,p),f=o.fragments[0].start):f=this.alignPlaylists(o,d.details)}d.details=o,this.levelLastLoaded=c,!this.startFragRequested&&(this.mainDetails||!o.live)&&this.setStartPosition(d.details,f),this.state===Tt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=Tt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:s,payload:o}=t,{config:c,trackId:d,levels:f}=this;if(!f){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const p=f[d];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const g=p.details;if(!g){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const v=c.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let b=this.transmuxer;b||(b=this.transmuxer=new ef(this.hls,Jt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const E=this.initPTS[i.cc],k=(e=i.initSegment)==null?void 0:e.data;if(E!==void 0){const w=s?s.index:-1,L=w!==-1,x=new Sc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,L);b.push(o,k,v,"",i,s,g.totalduration,!1,x,E)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${g.startSN} ,${g.endSN}],track ${d}`);const{cache:w}=this.waitingData=this.waitingData||{frag:i,part:s,cache:new rf,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=Tt.WAITING_INIT_PTS}}_handleFragmentLoadComplete(t){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(t,e){const i=e.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),e.tracks.video&&(this.videoBuffer=e.tracks.video.buffer||null)}onFragBuffered(t,e){const{frag:i,part:s}=e;if(i.type!==Jt.AUDIO){if(!this.loadedmetadata&&i.type===Jt.MAIN){const o=this.videoBuffer||this.media;o&&$e.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${s?" p: "+s.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(i.sn!=="initSegment"){this.fragPrevious=i;const o=this.switchingTrack;o&&(this.bufferedTrack=o,this.switchingTrack=null,this.hls.trigger(R.AUDIO_TRACK_SWITCHED,Hi({},o)))}this.fragBufferedComplete(i,s)}onError(t,e){var i;if(e.fatal){this.state=Tt.ERROR;return}switch(e.details){case ut.FRAG_GAP:case ut.FRAG_PARSING_ERROR:case ut.FRAG_DECRYPT_ERROR:case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Jt.AUDIO,e);break;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===Tt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===ke.AUDIO_TRACK&&(this.state=Tt.IDLE);break;case ut.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="audio")return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case ut.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Ce.AUDIO&&(this.bufferFlushed=!0,this.state===Tt.ENDED&&(this.state=Tt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:s}=this,{remuxResult:o,chunkMeta:c}=t,d=this.getCurrentContext(c);if(!d){this.resetWhenMissingContext(c);return}const{frag:f,part:p,level:g}=d,{details:v}=g,{audio:b,text:E,id3:k,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=Tt.PARSING,this.switchingTrack&&b&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const L=f.initSegment||f;this._bufferInitSegment(w.tracks,L,c),s.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:L,id:i,tracks:w.tracks})}if(b){const{startPTS:L,endPTS:x,startDTS:M,endDTS:N}=b;p&&(p.elementaryStreams[Ce.AUDIO]={startPTS:L,endPTS:x,startDTS:M,endDTS:N}),f.setElementaryStreamInfo(Ce.AUDIO,L,x,M,N),this.bufferFragmentData(b,f,p,c)}if(k!=null&&(e=k.samples)!=null&&e.length){const L=ai({id:i,frag:f,details:v},k);s.trigger(R.FRAG_PARSING_METADATA,L)}if(E){const L=ai({id:i,frag:f,details:v},E);s.trigger(R.FRAG_PARSING_USERDATA,L)}}_bufferInitSegment(t,e,i){if(this.state!==Tt.PARSING)return;t.video&&delete t.video;const s=t.audio;if(!s)return;s.levelCodec=s.codec,s.id="audio",this.log(`Init audio buffer, container:${s.container}, codecs[parsed]=[${s.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=s.initSegment;if(o!=null&&o.byteLength){const c={type:"audio",frag:e,part:null,chunkMeta:i,parent:e.type,data:o};this.hls.trigger(R.BUFFER_APPENDING,c)}this.tick()}loadFragment(t,e,i){const s=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||s===ui.NOT_LOADED||s===ui.PARTIAL){var o;t.sn==="initSegment"?this._loadInitSegment(t,e):(o=e.details)!=null&&o.live&&!this.initPTS[t.cc]?(this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=Tt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:s}=this,o=s==null?void 0:s.attrs,c=t.attrs;i&&o&&(o.CHANNELS!==c.CHANNELS||o.NAME!==c.NAME||o.LANGUAGE!==c.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(R.AUDIO_TRACK_SWITCHED,Hi({},t))}}class db extends Tc{constructor(t){super(t,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:i,groupId:s,details:o}=e,c=this.tracksInGroup[i];if(!c||c.groupId!==s){this.warn(`Track with id:${i} and group:${s} not found in active group ${c.groupId}`);return}const d=c.details;c.details=e.details,this.log(`audio-track ${i} "${c.name}" lang:${c.lang} group:${s} loaded [${o.startSN}-${o.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.audioGroupIds))return;const i=e.audioGroupIds[e.urlId];if(this.groupId!==i){this.groupId=i||null;const s=this.tracks.filter(c=>!i||c.groupId===i);this.selectDefaultTrack&&!s.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=s;const o={audioTracks:s};this.log(`Updating audio tracks, ${s.length} track(s) found in group:${i}`),this.hls.trigger(R.AUDIO_TRACKS_UPDATED,o),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(t,e){e.fatal||!e.context||e.context.type===ke.AUDIO_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(e))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;e[this.trackId];const s=e[t],{groupId:o,name:c}=s;if(this.log(`Switching to audio-track ${t} "${c}" lang:${s.lang} group:${o}`),this.trackId=t,this.currentTrack=s,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,Hi({},s)),s.details&&!s.details.live)return;const d=this.switchParams(s.url,i==null?void 0:i.details);this.loadPlaylist(d)}selectInitialTrack(){const t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(e!==-1)this.setAudioTrack(e);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${t.length}`);this.warn(i.message),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===s.attrs["STABLE-RENDITION-ID"]||t.name===s.name&&t.lang===s.lang))return s.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`loading audio-track playlist ${i} "${e.name}" lang:${e.lang} group:${s}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}}function nf(n,t){if(n.length!==t.length)return!1;for(let e=0;e<n.length;e++)if(!ub(n[e].attrs,t[e].attrs))return!1;return!0}function ub(n,t){const e=n["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>n[i]!==t[i])}const af=500;class fb extends _c{constructor(t,e,i){super(t,e,i,"[subtitle-stream-controller]",Jt.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.ERROR,this.onError,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.ERROR,this.onError,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(t){this.stopLoad(),this.state=Tt.IDLE,this.setInterval(af),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:i,success:s}=e;if(this.fragPrevious=i,this.state=Tt.IDLE,!s)return;const o=this.tracksBuffered[this.currentTrackId];if(!o)return;let c;const d=i.start;for(let p=0;p<o.length;p++)if(d>=o[p].start&&d<=o[p].end){c=o[p];break}const f=i.start+i.duration;c?c.end=f:(c={start:d,end:f},o.push(c)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(t,e){const{startOffset:i,endOffset:s}=e;if(i===0&&s!==Number.POSITIVE_INFINITY){const o=s-1;if(o<=0)return;e.endOffsetSubtitles=Math.max(0,o),this.tracksBuffered.forEach(c=>{for(let d=0;d<c.length;){if(c[d].end<=o){c.shift();continue}else if(c[d].start<o)c[d].start=o;else break;d++}}),this.fragmentTracker.removeFragmentsInRange(i,o,Jt.SUBTITLE)}}onFragBuffered(t,e){if(!this.loadedmetadata&&e.frag.type===Jt.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(t,e){const i=e.frag;(i==null?void 0:i.type)===Jt.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(nf(this.levels,e)){this.levels=e.map(i=>new Ra(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const s=new Ra(i);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Jt.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(t,e){if(this.currentTrackId=e.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const i=this.levels[this.currentTrackId];i!=null&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.setInterval(af)}onSubtitleTrackLoaded(t,e){var i;const{details:s,id:o}=e,{currentTrackId:c,levels:d}=this;if(!d.length)return;const f=d[c];if(o>=d.length||o!==c||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(s.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(s.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(s,f.details),p===0&&v&&(p=v.start,Ac(s,p))):s.hasProgramDateTime&&g.hasProgramDateTime?(O0(s,g),p=s.fragments[0].start):v&&(p=v.start,Ac(s,p))}f.details=s,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!s.live)&&this.setStartPosition(f.details,p),this.tick(),s.live&&!this.fragCurrent&&this.media&&this.state===Tt.IDLE&&(La(null,s.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:i}=t,s=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&s&&s.key&&s.iv&&s.method==="AES-128"){const c=performance.now();this.decrypter.decrypt(new Uint8Array(i),s.key.buffer,s.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:d,reason:d.message,frag:e}),d}).then(d=>{const f=performance.now();o.trigger(R.FRAG_DECRYPTED,{frag:e,payload:d,stats:{tstart:c,tdecrypt:f}})}).catch(d=>{this.warn(`${d.name}: ${d.message}`),this.state=Tt.IDLE})}}doTick(){if(!this.media){this.state=Tt.IDLE;return}if(this.state===Tt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:s}=this,o=this.getLoadPosition(),c=$e.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,s.maxBufferHole),{end:d,len:f}=c,p=this.getFwdBufferInfo(this.media,Jt.MAIN),g=i.details,v=this.getMaxBufferLength(p==null?void 0:p.len)+g.levelTargetDuration;if(f>v)return;const b=g.fragments,E=b.length,k=g.edge;let w=null;const L=this.fragPrevious;if(d<k){const x=s.maxFragLookUpTolerance,M=d>k-x?0:x;w=La(L,b,Math.max(b[0].start,d),M),!w&&L&&L.start<b[0].start&&(w=b[0])}else w=b[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const x=w.sn-g.startSN,M=b[x-1];M&&M.cc===w.cc&&this.fragmentTracker.getState(M)===ui.NOT_LOADED&&(w=M)}this.fragmentTracker.getState(w)===ui.NOT_LOADED&&this.loadFragment(w,i,d)}}getMaxBufferLength(t){const e=super.getMaxBufferLength();return t?Math.max(e,t):e}loadFragment(t,e,i){this.fragCurrent=t,t.sn==="initSegment"?this._loadInitSegment(t,e):(this.startFragRequested=!0,super.loadFragment(t,e,i))}get mediaBufferTimeRanges(){return new pb(this.tracksBuffered[this.currentTrackId]||[])}}class pb{constructor(t){this.buffered=void 0;const e=(i,s,o)=>{if(s=s>>>0,s>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${o})`);return t[s][i]};this.buffered={get length(){return t.length},end(i){return e("end",i,t.length)},start(i){return e("start",i,t.length)}}}}class gb extends Tc{constructor(t){super(t,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(R.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.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(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Bc(this.media.textTracks).forEach(t=>{Rn(t)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:i,details:s}=e,{trackId:o}=this,c=this.tracksInGroup[o];if(!c){this.warn(`Invalid subtitle track id ${i}`);return}const d=c.details;c.details=e.details,this.log(`subtitle track ${i} loaded [${s.startSN}-${s.endSN}]`),i===this.trackId&&this.playlistLoaded(i,e,d)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!(e!=null&&e.textGroupIds))return;const i=e.textGroupIds[e.urlId],s=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const o=this.tracks.filter(f=>!i||f.groupId===i);this.tracksInGroup=o;const c=this.findTrackId(s==null?void 0:s.name)||this.findTrackId();this.groupId=i||null;const d={subtitleTracks:o};this.log(`Updating subtitle tracks, ${o.length} track(s) found in "${i}" group-id`),this.hls.trigger(R.SUBTITLE_TRACKS_UPDATED,d),c!==-1&&this.setSubtitleTrack(c,s)}else this.shouldReloadPlaylist(s)&&this.setSubtitleTrack(this.trackId,s)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const s=e[i];if((!this.selectDefaultTrack||s.default)&&(!t||t===s.name))return s.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===ke.SUBTITLE_TRACK&&e.context.id===this.trackId&&e.context.groupId===this.groupId&&this.checkRetry(e)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1;const e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,s=e.groupId;let o=e.url;if(t)try{o=t.addDirectives(o)}catch(c){this.warn(`Could not construct new URL with HLS Delivery Directives: ${c}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(R.SUBTITLE_TRACK_LOADING,{url:o,id:i,groupId:s,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const s=Bc(e.textTracks),o=s.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(s).forEach(d=>{d.mode="disabled"});else{const d=o[i];d&&(d.mode="disabled")}const c=o[t];c&&(c.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(t,e){var i;const s=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=s[t])!=null&&i.details)||t<-1||t>=s.length)return;this.clearTimer();const o=s[t];if(this.log(`Switching to subtitle-track ${t}`+(o?` "${o.name}" lang:${o.lang} group:${o.groupId}`:"")),this.trackId=t,o){const{id:c,groupId:d="",name:f,type:p,url:g}=o;this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:c,groupId:d,name:f,type:p,url:g});const v=this.switchParams(o.url,e==null?void 0:e.details);this.loadPlaylist(v)}else this.hls.trigger(R.SUBTITLE_TRACK_SWITCH,{id:t})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=-1;const e=Bc(this.media.textTracks);for(let i=0;i<e.length;i++)if(e[i].mode==="hidden")t=i;else if(e[i].mode==="showing"){t=i;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}}function Bc(n){const t=[];for(let e=0;e<n.length;e++){const i=n[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(n[e])}return t}class mb{constructor(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}append(t,e){const i=this.queues[e];i.push(t),i.length===1&&this.buffers[e]&&this.executeNext(e)}insertAbort(t,e){this.queues[e].unshift(t),this.executeNext(e)}appendBlocker(t){let e;const i=new Promise(o=>{e=o}),s={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,t),i}executeNext(t){const{buffers:e,queues:i}=this,s=e[t],o=i[t];if(o.length){const c=o[0];try{c.execute()}catch(d){z.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),c.onError(d),s!=null&&s.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const of=wo(),lf=/([ha]vc.)(?:\.[^.,]+)+/;class vb{constructor(t){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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:e,mediaSource:i}=this;z.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(R.MEDIA_ATTACHED,{media:e})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{z.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{z.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&z.error(`Media element src was set while attaching MediaSource (${i} > ${e.src})`)},this.hls=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}registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_RESET,this.onBufferReset,this),t.on(R.BUFFER_APPENDING,this.onBufferAppending,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.BUFFER_EOS,this.onBufferEos,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(R.FRAG_PARSED,this.onFragParsed,this),t.on(R.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_RESET,this.onBufferReset,this),t.off(R.BUFFER_APPENDING,this.onBufferAppending,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.BUFFER_EOS,this.onBufferEos,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(R.FRAG_PARSED,this.onFragParsed,this),t.off(R.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new mb(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){let i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,z.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&of){const s=this.mediaSource=new of;s.addEventListener("sourceopen",this._onMediaSourceOpen),s.addEventListener("sourceended",this._onMediaSourceEnded),s.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(s),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(z.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(s){z.warn(`[buffer-controller]: onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),t.src===i?(t.removeAttribute("src"),t.load()):z.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(R.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(t=>{const e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(i){z.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(s=>{if(i){const o=this.tracks[s];if(o&&typeof o.buffer.changeType=="function"){const{id:c,codec:d,levelCodec:f,container:p,metadata:g}=e[s],v=(o.levelCodec||o.codec).replace(lf,"$1"),b=(f||d).replace(lf,"$1");if(v!==b){const E=`${p};codecs=${f||d}`;this.appendChangeType(s,E),z.log(`[buffer-controller]: switching codec ${v} to ${b}`),this.tracks[s]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:c}}}}else this.pendingTracks[s]=e[s]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,s={execute:()=>{const o=this.sourceBuffer[t];o&&(z.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{z.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(s,t)}onBufferAppending(t,e){const{hls:i,operationQueue:s,tracks:o}=this,{data:c,type:d,frag:f,part:p,chunkMeta:g}=e,v=g.buffering[d],b=self.performance.now();v.start=b;const E=f.stats.buffering,k=p?p.stats.buffering:null;E.start===0&&(E.start=b),k&&k.start===0&&(k.start=b);const w=o.audio;let L=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(L=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const x=f.start,M={execute:()=>{if(v.executeStart=self.performance.now(),L){const N=this.sourceBuffer[d];if(N){const D=x-N.timestampOffset;Math.abs(D)>=.1&&(z.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${x} (delta: ${D}) sn: ${f.sn})`),N.timestampOffset=x)}}this.appendExecutor(c,d)},onStart:()=>{},onComplete:()=>{const N=self.performance.now();v.executeEnd=v.end=N,E.first===0&&(E.first=N),k&&k.first===0&&(k.first=N);const{sourceBuffer:D}=this,F={};for(const H in D)F[H]=$e.getBuffered(D[H]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:F})},onError:N=>{z.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,N);const D={type:qt.MEDIA_ERROR,parent:f.type,details:ut.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:N,err:N,fatal:!1};N.code===DOMException.QUOTA_EXCEEDED_ERR?D.details=ut.BUFFER_FULL_ERROR:(this.appendError++,D.details=ut.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(z.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),D.fatal=!0)),i.trigger(R.ERROR,D)}};s.append(M,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,s=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:c=>{z.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,c)}});e.type?i.append(s(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(s(o),o)})}onFragParsed(t,e){const{frag:i,part:s}=e,o=[],c=s?s.elementaryStreams:i.elementaryStreams;c[Ce.AUDIOVIDEO]?o.push("audiovideo"):(c[Ce.AUDIO]&&o.push("audio"),c[Ce.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,s&&(s.stats.buffering.end=f);const p=s?s.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:s,stats:p,id:i.type})};o.length===0&&z.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(d,o)}onFragChanged(t,e){this.flushBackBuffer()}onBufferEos(t,e){this.getSourceBufferTypes().reduce((i,s)=>{const o=this.sourceBuffer[s];return o&&(!e.type||e.type===s)&&(o.ending=!0,o.ended||(o.ended=!0,z.log(`[buffer-controller]: ${s} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(z.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(s=>{const o=this.sourceBuffer[s];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&z.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}z.log("[buffer-controller]: Calling mediaSource.endOfStream()"),i.endOfStream()}))}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:t,details:e,media:i,sourceBuffer:s}=this;if(!i||e===null)return;const o=this.getSourceBufferTypes();if(!o.length)return;const c=e.live&&t.config.liveBackBufferLength!==null?t.config.liveBackBufferLength:t.config.backBufferLength;if(!jt(c)||c<0)return;const d=i.currentTime,f=e.levelTargetDuration,p=Math.max(c,f),g=Math.floor(d/f)*f-p;o.forEach(v=>{const b=s[v];if(b){const E=$e.getBuffered(b);if(E.length>0&&g>E.start(0)){if(t.trigger(R.BACK_BUFFER_REACHED,{bufferEnd:g}),e.live)t.trigger(R.LIVE_BACK_BUFFER_REACHED,{bufferEnd:g});else if(b.ended&&E.end(E.length-1)-d<f*2){z.info(`[buffer-controller]: Cannot flush ${v} back buffer while SourceBuffer is in ended state`);return}t.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:g,type:v})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:t,hls:e,media:i,mediaSource:s}=this,o=t.fragments[0].start+t.totalduration,c=i.duration,d=jt(s.duration)?s.duration:0;t.live&&e.config.liveDurationInfinity?(z.log("[buffer-controller]: Media Source duration is set to Infinity"),s.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>c||!jt(c))&&(z.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),s.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const s=Math.max(0,i[0].start),o=Math.max(s,s+t.totalduration);e.setLiveSeekableRange(s,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,s=Object.keys(i).length;if(s&&!t||s===2){this.createSourceBuffers(i),this.pendingTracks={};const o=this.getSourceBufferTypes();if(o.length)this.hls.trigger(R.BUFFER_CREATED,{tracks:this.tracks}),o.forEach(c=>{e.executeNext(c)});else{const c=new Error("could not create source buffer for media codec(s)");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:c,reason:c.message})}}}createSourceBuffers(t){const{sourceBuffer:e,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const s in t)if(!e[s]){const o=t[s];if(!o)throw Error(`source buffer exists for track ${s}, however track does not`);const c=o.levelCodec||o.codec,d=`${o.container};codecs=${c}`;z.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[s]=i.addSourceBuffer(d),p=s;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[s]={buffer:f,codec:c,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){z.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:d})}}}_onSBUpdateStart(t){const{operationQueue:e}=this;e.current(t).onStart()}_onSBUpdateEnd(t){const{operationQueue:e}=this;e.current(t).onComplete(),e.shiftAndExecuteNext(t)}_onSBUpdateError(t,e){const i=new Error(`${t} SourceBuffer error`);z.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const s=this.operationQueue.current(t);s&&s.onError(e)}removeExecutor(t,e,i){const{media:s,mediaSource:o,operationQueue:c,sourceBuffer:d}=this,f=d[t];if(!s||!o||!f){z.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),c.shiftAndExecuteNext(t);return}const p=jt(s.duration)?s.duration:1/0,g=jt(o.duration)?o.duration:1/0,v=Math.max(0,e),b=Math.min(i,p,g);b>v&&!f.ending?(f.ended=!1,z.log(`[buffer-controller]: Removing [${v},${b}] from the ${t} SourceBuffer`),f.remove(v,b)):c.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:s}=this,o=s[e];if(!o){z.warn(`[buffer-controller]: Attempting to append to the ${e} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(e);return}o.ended=!1,o.appendBuffer(t)}blockBuffers(t,e=this.getSourceBufferTypes()){if(!e.length){z.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,s=e.map(o=>i.appendBlocker(o));Promise.all(s).then(()=>{t(),e.forEach(o=>{const c=this.sourceBuffer[o];c!=null&&c.updating||i.shiftAndExecuteNext(o)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(t,e,i){const s=this.sourceBuffer[t];if(!s)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),s.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const cf={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},hf=function(n){let t=n;return cf.hasOwnProperty(n)&&(t=cf[n]),String.fromCharCode(t)},Er=15,ts=100,yb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},bb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ab={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Eb={25:2,26:4,29:6,30:8,31:10,27:13,28:15},kb=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Tb{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;z.log(`${this.time} [${t}] ${i}`)}}}const cn=function(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e].toString(16));return t};class df{constructor(t,e,i,s,o){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=e||!1,this.italics=i||!1,this.background=s||"black",this.flash=o||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let i=0;i<e.length;i++){const s=e[i];t.hasOwnProperty(s)&&(this[s]=t[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class wb{constructor(t,e,i,s,o,c){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new df(e,i,s,o,c)}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Sb{constructor(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let e=0;e<ts;e++)this.chars.push(new wb);this.logger=t,this.pos=0,this.currPenState=new df}equals(t){let e=!0;for(let i=0;i<ts;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<ts;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<ts;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>ts&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ts)}moveCursor(t){const e=this.pos+t;if(t>1)for(let i=this.pos+1;i<e+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=hf(t);if(this.pos>=ts){this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1)}clearFromPos(t){let e;for(e=t;e<ts;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let i=0;i<ts;i++){const s=this.chars[i].uchar;s!==" "&&(e=!1),t.push(s)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class Gc{constructor(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let e=0;e<Er;e++)this.rows.push(new Sb(t));this.logger=t,this.currRow=Er-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Er;t++)this.rows[t].clear();this.currRow=Er-1}equals(t){let e=!0;for(let i=0;i<Er;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Er;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Er;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+JSON.stringify(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let d=0;d<Er;d++)this.rows[d].clear();const o=this.currRow+1-this.nrRollUpRows,c=this.lastOutputScreen;if(c){const d=c.rows[o].cueStartTime,f=this.logger.time;if(d&&f!==null&&d<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[e-this.nrRollUpRows+p+1].copy(c.rows[o+p])}}this.currRow=e;const i=this.rows[this.currRow];if(t.indent!==null){const o=t.indent,c=Math.max(o-1,0);i.setCursor(t.indent),t.color=i.chars[c].penState.foreground}const s={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let i="",s=-1;for(let o=0;o<Er;o++){const c=this.rows[o].getTextString();c&&(s=o+1,t?e.push("Row "+s+": '"+c+"'"):e.push(c.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
195
+ `)),i}getTextAndFormat(){return this.rows}}class uf{constructor(t,e,i){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Gc(i),this.nonDisplayedMemory=new Gc(i),this.lastOutputScreen=new Gc(i),this.currRollUpRow=this.displayedMemory.rows[Er-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=i}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Er-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}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"),this.mode==="MODE_POP-ON"){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2===1,e.italics=t>=46,e.italics)e.foreground="white";else{const i=Math.floor(t/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=s[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;e!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=e:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class ff{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const s=new Tb;this.channels=[null,new uf(t,e,s),new uf(t+1,i,s)],this.cmdHistory=gf(),this.logger=s}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,s,o,c=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(s=e[d]&127,o=e[d+1]&127,!(s===0&&o===0)){if(this.logger.log(3,"["+cn([e[d],e[d+1]])+"] -> ("+cn([s,o])+")"),i=this.parseCmd(s,o),i||(i=this.parseMidrow(s,o)),i||(i=this.parsePAC(s,o)),i||(i=this.parseBackgroundAttributes(s,o)),!i&&(c=this.parseChars(s,o),c)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(c):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!c&&this.logger.log(2,"Couldn't parse cleaned data "+cn([s,o])+" orig: "+cn([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,s=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(s||o))return!1;if(pf(t,e,i))return In(null,null,i),this.logger.log(3,"Repeated command ("+cn([t,e])+") is dropped"),!0;const c=t===20||t===21||t===23?1:2,d=this.channels[c];return t===20||t===21||t===28||t===29?e===32?d.ccRCL():e===33?d.ccBS():e===34?d.ccAOF():e===35?d.ccAON():e===36?d.ccDER():e===37?d.ccRU(2):e===38?d.ccRU(3):e===39?d.ccRU(4):e===40?d.ccFON():e===41?d.ccRDC():e===42?d.ccTR():e===43?d.ccRTD():e===44?d.ccEDM():e===45?d.ccCR():e===46?d.ccENM():e===47&&d.ccEOC():d.ccTO(e-32),In(t,e,i),this.currentChannel=c,!0}parseMidrow(t,e){let i=0;if((t===17||t===25)&&e>=32&&e<=47){if(t===17?i=1:i=2,i!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[i];return s?(s.ccMIDROW(e),this.logger.log(3,"MIDROW ("+cn([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const s=this.cmdHistory,o=(t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127,c=(t===16||t===24)&&e>=64&&e<=95;if(!(o||c))return!1;if(pf(t,e,s))return In(null,null,s),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?yb[t]:Ab[t]:i=d===1?bb[t]:Eb[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),In(t,e,s),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const s={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,s.underline=(i&1)===1,i<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((i-16)/2)*4,s}parseChars(t,e){let i,s=null,o=null;if(t>=25?(i=2,o=t-8):(i=1,o=t),o>=17&&o<=19){let c;o===17?c=e+80:o===18?c=e+112:c=e+144,this.logger.log(2,"Special char '"+hf(c)+"' in channel "+i),s=[c]}else t>=32&&t<=127&&(s=e===0?[t]:[t,e]);if(s){const c=cn(s);this.logger.log(3,"Char codes = "+c.join(",")),In(t,e,this.cmdHistory)}return s}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,s=(t===23||t===31)&&e>=45&&e<=47;if(!(i||s))return!1;let o;const c={};t===16||t===24?(o=Math.floor((e-32)/2),c.background=kb[o],e%2===1&&(c.background=c.background+"_semi")):e===45?c.background="transparent":(c.foreground="black",e===47&&(c.underline=!0));const d=t<=23?1:2;return this.channels[d].setBkgData(c),In(t,e,this.cmdHistory),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}this.cmdHistory=gf()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function In(n,t,e){e.a=n,e.b=t}function pf(n,t,e){return e.a===n&&e.b===t}function gf(){return{a:null,b:null}}class $o{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,i){(this.startTime===null||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Vc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const n=["","lr","rl"],t=["start","middle","end","left","right"];function e(d,f){if(typeof f!="string"||!Array.isArray(d))return!1;const p=f.toLowerCase();return~d.indexOf(p)?p:!1}function i(d){return e(n,d)}function s(d){return e(t,d)}function o(d,...f){let p=1;for(;p<arguments.length;p++){const g=arguments[p];for(const v in g)d[v]=g[v]}return d}function c(d,f,p){const g=this,v={enumerable:!0};g.hasBeenReset=!1;let b="",E=!1,k=d,w=f,L=p,x=null,M="",N=!0,D="auto",F="start",H=50,j="middle",st=50,at="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return b},set:function(Q){b=""+Q}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(Q){E=!!Q}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return k},set:function(Q){if(typeof Q!="number")throw new TypeError("Start time must be set to a number.");k=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(Q){if(typeof Q!="number")throw new TypeError("End time must be set to a number.");w=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return L},set:function(Q){L=""+Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return x},set:function(Q){x=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return M},set:function(Q){const kt=i(Q);if(kt===!1)throw new SyntaxError("An invalid or illegal string was specified.");M=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return N},set:function(Q){N=!!Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return D},set:function(Q){if(typeof Q!="number"&&Q!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return F},set:function(Q){const kt=s(Q);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");F=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return H},set:function(Q){if(Q<0||Q>100)throw new Error("Position must be between 0 and 100.");H=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return j},set:function(Q){const kt=s(Q);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");j=kt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return st},set:function(Q){if(Q<0||Q>100)throw new Error("Size must be between 0 and 100.");st=Q,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return at},set:function(Q){const kt=s(Q);if(!kt)throw new SyntaxError("An invalid or illegal string was specified.");at=kt,this.hasBeenReset=!0}})),g.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class Rb{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function mf(n){function t(i,s,o,c){return(i|0)*3600+(s|0)*60+(o|0)+parseFloat(c||0)}const e=n.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return e?parseFloat(e[2])>59?t(e[2],e[3],0,e[4]):t(e[1],e[2],e[3],e[4]):null}class Lb{constructor(){this.values=Object.create(null)}set(t,e){!this.get(t)&&e!==""&&(this.values[t]=e)}get(t,e,i){return i?this.has(t)?this.values[t]:e[i]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,i){for(let s=0;s<i.length;++s)if(e===i[s]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const i=parseFloat(e);if(i>=0&&i<=100)return this.set(t,i),!0}return!1}}function vf(n,t,e,i){const s=i?n.split(i):[n];for(const o in s){if(typeof s[o]!="string")continue;const c=s[o].split(e);if(c.length!==2)continue;const d=c[0],f=c[1];t(d,f)}}const Hc=new Vc(0,0,""),Fo=Hc.align==="middle"?"middle":"center";function _b(n,t,e){const i=n;function s(){const d=mf(n);if(d===null)throw new Error("Malformed timestamp: "+i);return n=n.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new Lb;vf(d,function(b,E){let k;switch(b){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(b,e[w].region);break}break;case"vertical":p.alt(b,E,["rl","lr"]);break;case"line":k=E.split(","),p.integer(b,k[0]),p.percent(b,k[0])&&p.set("snapToLines",!1),p.alt(b,k[0],["auto"]),k.length===2&&p.alt("lineAlign",k[1],["start",Fo,"end"]);break;case"position":k=E.split(","),p.percent(b,k[0]),k.length===2&&p.alt("positionAlign",k[1],["start",Fo,"end","line-left","line-right","auto"]);break;case"size":p.percent(b,E);break;case"align":p.alt(b,E,["start",Fo,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&Hc.line===-1&&(g=-1),f.line=g,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",Fo);let v=p.get("position","auto");v==="auto"&&Hc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function c(){n=n.replace(/^\s+/,"")}if(c(),t.startTime=s(),c(),n.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);n=n.slice(3),c(),t.endTime=s(),c(),o(n,t)}function yf(n){return n.replace(/<br(?: \/)?>/gi,`
196
+ `)}class Cb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Rb,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));function i(){let o=e.buffer,c=0;for(o=yf(o);c<o.length&&o[c]!=="\r"&&o[c]!==`
165
197
  `;)++c;const d=o.slice(0,c);return o[c]==="\r"&&++c,o[c]===`
166
- `&&++c,e.buffer=o.slice(c),d}function s(o){cf(o,function(c,d){},/:/)}try{let o="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;o=i();const d=o.match(/^()?WEBVTT([ \t].*)?$/);if(!(d!=null&&d[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let c=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(c?c=!1:o=i(),e.state){case"HEADER":/:/.test(o)?s(o):o||(e.state="ID");continue;case"NOTE":o||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){e.state="NOTE";break}if(!o)continue;if(e.cue=new Pc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{mb(o,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const d=o.indexOf("-->")!==-1;if(!o||d&&(c=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
198
+ `&&++c,e.buffer=o.slice(c),d}function s(o){vf(o,function(c,d){},/:/)}try{let o="";if(e.state==="INITIAL"){if(!/\r\n|\n/.test(e.buffer))return this;o=i();const d=o.match(/^()?WEBVTT([ \t].*)?$/);if(!(d!=null&&d[0]))throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let c=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(c?c=!1:o=i(),e.state){case"HEADER":/:/.test(o)?s(o):o||(e.state="ID");continue;case"NOTE":o||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(o)){e.state="NOTE";break}if(!o)continue;if(e.cue=new Vc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{_b(o,e.cue,e.regionList)}catch{e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const d=o.indexOf("-->")!==-1;if(!o||d&&(c=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(e.cue===null)continue;e.cue.text&&(e.cue.text+=`
167
199
  `),e.cue.text+=o}continue;case"BADCUE":o||(e.state="ID")}}}catch{e.state==="CUETEXT"&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state=e.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||t.state==="HEADER")&&(t.buffer+=`
168
200
 
169
- `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const yb=/\r\n|\n\r|\n|\r/g,Mc=function(n,t,e=0){return n.slice(e,e+t.length)===t},bb=function(n){let t=parseInt(n.slice(-3));const e=parseInt(n.slice(-6,-4)),i=parseInt(n.slice(-9,-7)),s=n.length>9?parseInt(n.substring(0,n.indexOf(":"))):0;if(!Kt(t)||!Kt(e)||!Kt(i)||!Kt(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${n}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*s,t},$c=function(n){let t=5381,e=n.length;for(;e;)t=t*33^n.charCodeAt(--e);return(t>>>0).toString()};function Fc(n,t,e){return $c(n.toString())+$c(t.toString())+$c(e)}const Ab=function(n,t,e){let i=n[t],s=n[i.prevCC];if(!s||!s.new&&i.new){n.ccOffset=n.presentationOffset=i.start,i.new=!1;return}for(;(o=s)!=null&&o.new;){var o;n.ccOffset+=i.start-s.start,i.new=!1,i=s,s=n[i.prevCC]}n.presentationOffset=e};function Eb(n,t,e,i,s,o,c){const d=new vb,f=xr(new Uint8Array(n)).trim().replace(yb,`
201
+ `,t.parse()),t.state==="INITIAL"||t.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const Ib=/\r\n|\n\r|\n|\r/g,Wc=function(n,t,e=0){return n.slice(e,e+t.length)===t},Db=function(n){let t=parseInt(n.slice(-3));const e=parseInt(n.slice(-6,-4)),i=parseInt(n.slice(-9,-7)),s=n.length>9?parseInt(n.substring(0,n.indexOf(":"))):0;if(!jt(t)||!jt(e)||!jt(i)||!jt(s))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${n}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*s,t},jc=function(n){let t=5381,e=n.length;for(;e;)t=t*33^n.charCodeAt(--e);return(t>>>0).toString()};function Kc(n,t,e){return jc(n.toString())+jc(t.toString())+jc(e)}const xb=function(n,t,e){let i=n[t],s=n[i.prevCC];if(!s||!s.new&&i.new){n.ccOffset=n.presentationOffset=i.start,i.new=!1;return}for(;(o=s)!=null&&o.new;){var o;n.ccOffset+=i.start-s.start,i.new=!1,i=s,s=n[i.prevCC]}n.presentationOffset=e};function Pb(n,t,e,i,s,o,c){const d=new Cb,f=Pr(new Uint8Array(n)).trim().replace(Ib,`
170
202
  `).split(`
171
- `),p=[],g=t?xy(t.baseTime,t.timescale):0;let v="00:00.000",A=0,T=0,E,w=!0;d.oncue=function(R){const x=e[i];let M=e.ccOffset;const G=(A-g)/9e4;if(x!=null&&x.new&&(T!==void 0?M=e.ccOffset=x.start:Ab(e,i,G)),G){if(!t){E=new Error("Missing initPTS for VTT MPEGTS");return}M=G-e.presentationOffset}const _=R.endTime-R.startTime,F=cr((R.startTime+M-T)*9e4,s*9e4)/9e4;R.startTime=Math.max(F,0),R.endTime=Math.max(F+_,0);const H=R.text.trim();R.text=decodeURIComponent(encodeURIComponent(H)),R.id||(R.id=Fc(R.startTime,R.endTime,H)),R.endTime>0&&p.push(R)},d.onparsingerror=function(R){E=R},d.onflush=function(){if(E){c(E);return}o(p)},f.forEach(R=>{if(w)if(Mc(R,"X-TIMESTAMP-MAP=")){w=!1,R.slice(16).split(",").forEach(x=>{Mc(x,"LOCAL:")?v=x.slice(6):Mc(x,"MPEGTS:")&&(A=parseInt(x.slice(7)))});try{T=bb(v)/1e3}catch(x){E=x}return}else R===""&&(w=!1);d.parse(R+`
172
- `)}),d.flush()}const Nc="stpp.ttml.im1t",df=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,uf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Tb={left:"start",center:"center",right:"end",start:"start",end:"end"};function ff(n,t,e,i){const s=be(new Uint8Array(n),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=s.map(d=>xr(d)),c=Dy(t.baseTime,1,t.timescale);try{o.forEach(d=>e(kb(d,c)))}catch(d){i(d)}}function kb(n,t){const e=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",c=pf(Uc(e,"styling","style")),d=pf(Uc(e,"layout","region")),f=Uc(e,"body","[begin]");return[].map.call(f,p=>{const g=gf(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=Gc(p.getAttribute("begin"),s),A=Gc(p.getAttribute("dur"),s);let T=Gc(p.getAttribute("end"),s);if(v===null)throw mf(p);if(T===null){if(A===null)throw mf(p);T=v+A}const E=new Pc(v-t,T-t,g);E.id=Fc(E.startTime,E.endTime,E.text);const w=d[p.getAttribute("region")],R=c[p.getAttribute("style")],x=wb(w,R,c),{textAlign:M}=x;if(M){const G=Tb[M];G&&(E.lineAlign=G),E.align=M}return ni(E,x),E}).filter(p=>p!==null)}function Uc(n,t,e){const i=n.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function pf(n){return n.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function gf(n,t){return[].slice.call(n.childNodes).reduce((e,i,s)=>{var o;return i.nodeName==="br"&&s?e+`
173
- `:(o=i.childNodes)!=null&&o.length?gf(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function wb(n,t,e){const i="http://www.w3.org/ns/ttml#styling";let s=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(s=e[c]),o.reduce((d,f)=>{const p=Bc(t,i,f)||Bc(n,i,f)||Bc(s,i,f);return p&&(d[f]=p),d},{})}function Bc(n,t,e){return n&&n.hasAttributeNS(t,e)?n.getAttributeNS(t,e):null}function mf(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Gc(n,t){if(!n)return null;let e=lf(n);return e===null&&(df.test(n)?e=Sb(n,t):uf.test(n)&&(e=Lb(n,t))),e}function Sb(n,t){const e=df.exec(n),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function Lb(n,t){const e=uf.exec(n),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class Rb{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=vf(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new xo(this,"textTrack1"),i=new xo(this,"textTrack2"),s=new xo(this,"textTrack3"),o=new xo(this,"textTrack4");this.cea608Parser1=new nf(1,e,i),this.cea608Parser2=new nf(3,s,o)}t.on(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(L.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(L.FRAG_LOADING,this.onFragLoading,this),t.on(L.FRAG_LOADED,this.onFragLoaded,this),t.on(L.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(L.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(L.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(L.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(L.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(L.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(L.FRAG_LOADING,this.onFragLoading,this),t.off(L.FRAG_LOADED,this.onFragLoaded,this),t.off(L.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(L.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(L.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(L.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(L.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,s,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=Cb(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),c=!0,p/(i-e)>.5))return}if(c||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,s)}else{const d=this.Cues.newCue(null,e,i,s);this.hls.trigger(L.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:s,timescale:o}),c.length&&(this.unparsedVttFrags=[],c.forEach(d=>{this.onFragLoaded(L.FRAG_LOADED,d)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let i=0;i<e.textTracks.length;i++){const s=e.textTracks[i];if(s[t])return s}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:s}=this,{label:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,bn(i[t]),h0(i[t],s);else{const f=this.createTextTrack("captions",o,c);f&&(f[t]=!0,i[t]=f)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i=e.label,s={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(L.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,i){const s=this.media;if(s)return s.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{bn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=vf(),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:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let i=0;i<e.length;i++)bn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(o=>o.textCodec===Nc);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(X0(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((c,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(_b(o[g],c)){p=o[g];break}p&&(f=p)}if(f)bn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(c);f=this.createTextTrack(p,c.name,c.lang),f&&(f.mode="disabled")}f&&(f.groupId=c.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(c=>({label:c.name,kind:c.type.toLowerCase(),default:c.default,subtitleTrack:c}));this.hls.trigger(L.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&i)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const o=`textTrack${s[1]}`,c=this.captionsProperties[o];c&&(c.label=i.name,i.lang&&(c.languageCode=i.lang),c.media=i)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:i,cea608Parser2:s,lastSn:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&s))&&e.frag.type===Qt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===c+1||(i.reset(),s.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===Qt.SUBTITLE)if(s.byteLength){const o=i.decryptdata,c="stats"in e;if(o==null||!o.encrypted||c){const d=this.tracks[i.level],f=this.vttCCs;f[i.cc]||(f[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),d&&d.textCodec===Nc?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(L.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;ff(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(L.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{Y.log(`Failed to parse IMSC1: ${s}`),i.trigger(L.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:s})})}_parseVTTs(t){var e;const{frag:i,payload:s}=t,{initPTS:o,unparsedVttFrags:c}=this,d=o.length-1;if(!o[i.cc]&&d===-1){c.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?en(i.initSegment.data,new Uint8Array(s)):s;Eb(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,g=>{this._appendCues(g,i.level),f.trigger(L.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?c.push(t):this._fallbackToIMSC1(i,s),Y.log(`Failed to parse VTT cue: ${g}`),!(v&&d>i.cc)&&f.trigger(L.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:g})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||ff(e,this.initPTS[t.cc],()=>{i.textCodec=Nc,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||s.mode==="disabled")return;t.forEach(o=>d0(s,o))}else{const s=this.tracks[e];if(!s)return;const o=s.default?"default":"subtitles"+e;i.trigger(L.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Qt.SUBTITLE&&this.onFragLoaded(L.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&s))return;const{frag:o,samples:c}=e;if(!(o.type===Qt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<c.length;d++){const f=c[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(c[d].pts,p[0]),s.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:s,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>ac(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>ac(d[f],e,s))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let s=2;for(let o=0;o<i;o++){const c=t[s++],d=127&t[s++],f=127&t[s++];if(!(d===0&&f===0)&&4&c){const p=3&c;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function _b(n,t){return!!n&&n.label===t.name&&!(n.textTrack1||n.textTrack2)}function Cb(n,t,e,i){return Math.min(t,i)-Math.max(n,e)}function vf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class Hc{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(L.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.BUFFER_CODECS,this.onBufferCodecs,this),t.on(L.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(L.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(L.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.BUFFER_CODECS,this.onBufferCodecs,this),t.off(L.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter((s,o)=>this.isLevelAllowed(s)&&o<=t);return this.clientRect=null,Hc.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}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 t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,!e.width&&!e.height&&(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,i){if(!(t!=null&&t.length))return-1;const s=(c,d)=>d?c.width!==d.width||c.height!==d.height:!0;let o=t.length-1;for(let c=0;c<t.length;c+=1){const d=t[c];if((d.width>=e||d.height>=i)&&s(d,t[c+1])){o=c;break}}return o}}class Ib{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(L.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(L.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const s=performance.now();if(e){if(this.lastTime){const o=s-this.lastTime,c=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*c/o,p=this.hls;if(p.trigger(L.FPS_DROP,{currentDropped:c,currentDecoded:d,totalDroppedFrames:i}),f>0&&c>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;Y.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(L.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const Oo="[eme]";class wn{constructor(t){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=wn.CDMCleanupPromise?[wn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Y.debug.bind(Y,Oo),this.log=Y.log.bind(Y,Oo),this.warn=Y.warn.bind(Y,Oo),this.error=Y.error.bind(Y,Oo),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(L.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(L.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(L.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(L.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(L.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(L.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===Ye.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(c,d,f)=>!!c&&f.indexOf(c)===d,s=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,s,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof hr?d(v):d(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Nu===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(t,e)}getMediaKeysPromise(t,e,i){const s=Wm(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let c=o==null?void 0:o.keySystemAccess;if(!c){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(s)}`),c=this.requestMediaKeySystemAccess(t,s);const d=this.keySystemAccessPromises[t]={keySystemAccess:c};return c.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),c.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return c.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Pr.hexDump(t.keyId||[])}`);const s=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,o,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return Pr.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Pr.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
174
- } (data length: ${e&&e.byteLength})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const s=Jl(this.config),o=t.map(Mu).filter(c=>!!c&&s.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=Fu(c);d?e(d):i(new Error(`Unable to find format for key-system "${c}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(c=>this.handleError(c))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof hr?this.hls.trigger(L.ERROR,t.data):this.hls.trigger(L.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=Mu(t.keyFormat),o=s?[s]:Jl(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=Jl(this.config)),t.length===0)throw new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let s,o;if(e==="sinf"&&this.config.drmSystems[Ye.FAIRPLAY]){const g=bi(new Uint8Array(i));try{const v=Ql(JSON.parse(g).sinf),A=ju(new Uint8Array(v));if(!A)return;s=A.subarray(8,24),o=Ye.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=pv(i);if(g===null)return;g.version===0&&g.systemId===$u.WIDEVINE&&g.data&&(s=g.data.subarray(8,24)),o=Vm(g.systemId)}if(!o||!s)return;const c=Pr.hexDump(s),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[c];for(let g=0;g<f.length;g++){const v=f[g],A=v.decryptdata;if(A.pssh||!A.keyId)continue;const T=Pr.hexDump(A.keyId);if(c===T||A.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[T],delete d[T],A.pssh=new Uint8Array(i),A.keyId=s,p=d[c]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[c]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var A;this.throwIfDestroyed();const T=new ya("ISO-23001-7",c,(A=Fu(g))!=null?A:"");return T.pssh=new Uint8Array(i),T.keyId=s,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const E=this.createMediaKeySessionContext({decryptdata:T,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(E,e,i,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var o,c;const d=(o=this.config.drmSystems)==null||(c=o[t.keySystem])==null?void 0:c.generateRequest;if(d)try{const A=d.call(this.hls,e,i,t);if(!A)throw new Error("Invalid response from configured generateRequest filter");e=A.initDataType,i=t.decryptdata.pssh=A.initData?new Uint8Array(A.initData):null}catch(A){var f;if(this.warn(A.message),(f=this.hls)!=null&&f.config.debug)throw A}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new _c;t.mediaKeysSession.onmessage=A=>{const T=t.mediaKeysSession;if(!T){g.emit("error",new Error("invalid state"));return}const{messageType:E,message:w}=A;this.log(`"${E}" message event for session "${T.sessionId}" message size: ${w.byteLength}`),E==="license-request"||E==="license-renewal"?this.renewLicense(t,w).catch(R=>{this.handleError(R),g.emit("error",R)}):E==="license-release"?t.keySystem===Ye.FAIRPLAY&&(this.updateKeySession(t,Ou("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${E}"`)},t.mediaKeysSession.onkeystatuseschange=A=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const T=t.keyStatus;g.emit("keyStatus",T),T==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((A,T)=>{g.on("error",T),g.on("keyStatus",E=>{E.startsWith("usable")?A():E==="output-restricted"?T(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):E==="internal-error"?T(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${E}"`)):E==="expired"?T(new Error("key expired while generating request")):this.warn(`unhandled key status change "${E}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var A;this.log(`Request generated for key-session "${(A=t.mediaKeysSession)==null?void 0:A.sessionId}" keyId: ${p}`)}).catch(A=>{throw new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:A,fatal:!1},`Error generating key-session request: ${A}`)}).then(()=>v).catch(A=>{throw g.removeAllListeners(),this.removeSession(t),A}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Pr.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Pr.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,s=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((c,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(A,T,E,w)=>{c(A.data)},onError:(A,T,E,w)=>{d(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:E,response:Bi({url:f.url,data:void 0},A)},`"${t}" certificate request failed (${o}). Status: ${A.code} (${A.text})`))},onTimeout:(A,T,E)=>{d(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:E,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(A,T,E)=>{d(new Error("aborted"))}};s.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(c=>{o(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,i,s)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,s)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||s})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((s,o)=>{const c=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${c}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,c,t)}catch(g){this.error(g)}s(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new hr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:c,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${c}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(s,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,c,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ya.clearKeyUriToKeyIdMap();const i=e.length;wn.CDMCleanupPromise=Promise.all(e.map(s=>this.removeSession(s)).concat(t==null?void 0:t.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.reduce((s,o)=>(s.indexOf(o.keyFormat)===-1&&s.push(o.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);return s>-1&&this.mediaKeySessions.splice(s,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}wn.CDMCleanupPromise=void 0;class hr extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const Db=1;var Vi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const xb="h";class ys{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Vi.MANIFEST,su:!this.initialized})}catch(o){Y.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=s=>{try{const o=s.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Vi.VIDEO||d===Vi.AUDIO||d==Vi.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(s,f)}catch(o){Y.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||ys.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(L.MEDIA_DETACHED,this.onMediaDetached,this),t.on(L.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(L.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(L.MEDIA_DETACHED,this.onMediaDetached,this),t.off(L.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.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(t,e){var i,s;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=e.tracks.video)==null?void 0:s.buffer}createData(){var t;return{v:Db,sf:xb,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ni(e,this.createData());const i=e.ot===Vi.INIT||e.ot===Vi.VIDEO||e.ot===Vi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const s=ys.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),ni(t.headers,s)}else{const s=ys.toQuery(e);if(!s)return;t.url=ys.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Vi.TIMED_TEXT;if(t.sn==="initSegment")return Vi.INIT;if(e==="audio")return Vi.AUDIO;if(e==="main")return this.hls.audioTracks.length?Vi.VIDEO:Vi.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===Vi.AUDIO)i=s.audioTracks;else{const o=s.maxAutoLevel,c=o>-1?o+1:s.levels.length;i=s.levels.slice(0,c)}for(const o of i)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===Vi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Me.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,s=f=>Math.round(f),o=f=>s(f/100)*100,c={br:s,d:s,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:s},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!i(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=c[f];g&&(p=g(p));const v=typeof p;let A;f==="ot"||f==="sf"||f==="st"?A=`${f}=${p}`:v==="boolean"?A=f:v==="number"?A=`${f}=${p}`:A=`${f}=${JSON.stringify(p)}`,e.push(A)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],o=[{},{},{},{}],c={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=c[d]!=null?c[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=ys.serialize(o[d]);f&&(i[`CMCD-${s[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(ys.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const Pb=3e5;class Ob{constructor(t){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=t,this.log=Y.log.bind(Y,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(L.MANIFEST_LOADING,this.onManifestLoading,this),t.on(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(L.MANIFEST_PARSED,this.onManifestParsed,this),t.on(L.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(L.MANIFEST_LOADING,this.onManifestLoading,this),t.off(L.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(L.MANIFEST_PARSED,this.onManifestParsed,this),t.off(L.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}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(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ti.SendAlternateToPenaltyBox&&i.flags===lr.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(o=>{s-i[o]>Pb&&delete i[o]});for(let o=0;o<t.length;o++){const c=t[o];if(i[c])continue;if(c===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(c),e.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,this.hls.trigger(L.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(o=>{const{ID:c,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===c))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ni({},g);v.details=void 0,v.url=bf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new ze(g.attrs);A["PATHWAY-ID"]=c;const T=A.AUDIO&&`${A.AUDIO}_clone_${c}`,E=A.SUBTITLES&&`${A.SUBTITLES}_clone_${c}`;T&&(i[A.AUDIO]=T,A.AUDIO=T),E&&(s[A.SUBTITLES]=E,A.SUBTITLES=E),v.attrs=A;const w=new Aa(v);return wo(w,"audio",T),wo(w,"text",E),w});e.push(...p),yf(this.audioTracks,i,f,c),yf(this.subtitleTracks,s,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(s.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:s.href},c=e.steeringManifestLoadPolicy.default,d=c.errorRetry||c.timeoutRetry||{},f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,A,T)=>{this.log(`Loaded steering manifest: "${s}"`);const E=g.data;if(E.VERSION!==1){this.log(`Steering VERSION ${E.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=E.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":R,"PATHWAY-PRIORITY":x}=E;if(w)try{this.uri=new self.URL(w,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||A.url),R&&this.clonePathways(R),x&&this.updatePathwayPriority(x)},onError:(g,v,A,T)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let E=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const R=w.getResponseHeader("Retry-After");R&&(E=parseFloat(R)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,E)},onTimeout:(g,v,A)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function yf(n,t,e,i){n&&Object.keys(t).forEach(s=>{const o=n.filter(c=>c.groupId===s).map(c=>{const d=ni({},c);return d.details=void 0,d.attrs=new ze(d.attrs),d.url=d.attrs.URI=bf(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[s],d.attrs["PATHWAY-ID"]=i,d});n.push(...o)})}function bf(n,t,e,i){const{HOST:s,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(n=d));const f=new self.URL(n);return s&&!d&&(f.host=s),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const Mb=/^age:\s*[\d.]+\s*$/im;class Af{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new go,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(c=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(c=>{this.callbacks.onError({code:i.status,text:c.message},e,i,s)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(s)for(const d in s)t.setRequestHeader(d,s[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=o&&Kt(o)?o:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,o=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const c=e.status,d=e.responseType!=="text";if(c>=200&&c<300&&(d&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(i,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:c};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;ko(f,p,!1,c)?this.retry(f):(Y.error(`${c} while loading ${t.url}`),this.callbacks.onError({code:c,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(ko(e,i,!0))this.retry(e);else{Y.warn(`timeout while loading ${this.context.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=uc(t,i.retry),i.retry++,Y.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.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(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Mb.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function $b(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Fb=/(\d+)-(\d+)\/(\d+)/;class Ef{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Gb,this.controller=new self.AbortController,this.stats=new go}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const o=Nb(t,this.controller.signal),c=i.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&Kt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const A=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},g-(A-s.loading.start)),!v.ok){const{status:T,statusText:E}=v;throw new Hb(E||"fetch, bad network response",T,v)}return s.loading.first=A,s.total=Bb(v.headers)||s.total,c&&Kt(e.highWaterMark)?this.loadProgressively(v,s,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const T=v[f];T&&(s.loaded=s.total=T);const E={url:A.url,data:v,code:A.status};c&&!Kt(e.highWaterMark)&&c(s,t,v,A),i.onSuccess(E,s,t,A)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const A=v&&v.code||0,T=v?v.message:null;i.onError({code:A,text:T},t,v?v.details:null,s)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,o){const c=new Y0,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return c.dataLength&&o(e,i,c.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<s||c.dataLength?(c.push(g),c.dataLength>=s&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function Nb(n,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ni({},n.headers))};return n.rangeEnd&&e.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),e}function Ub(n){const t=Fb.exec(n);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Bb(n){const t=n.get("Content-Range");if(t){const i=Ub(t);if(Kt(i))return i}const e=n.get("Content-Length");if(e)return parseInt(e)}function Gb(n,t){return new self.Request(n.url,t)}class Hb extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const Vb=/\s/,Wb={newCue(n,t,e,i){const s=[];let o,c,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let A=0;A<i.rows.length;A++)if(o=i.rows[A],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)Vb.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const T=hf(p.trim()),E=Fc(t,e,T);n!=null&&(v=n.cues)!=null&&v.getCueById(E)||(c=new g(t,e,T),c.id=E,c.line=A+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),s.push(c))}return n&&s.length&&(s.sort((A,T)=>A.line==="auto"||T.line==="auto"?0:A.line>8&&T.line>8?T.line-A.line:A.line-T.line),s.forEach(A=>d0(n,A))),s}},Kb={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},jb=Bi(Bi({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Af,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Xy,bufferController:nb,capLevelController:Hc,errorController:Hv,fpsController:Ib,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Nu,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:Kb},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},zb()),{},{subtitleStreamController:eb,subtitleTrackController:rb,timelineController:Rb,audioStreamController:Qy,audioTrackController:Jy,emeController:wn,cmcdController:ys,contentSteeringController:Ob});function zb(){return{cueHandler:Wb,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function Yb(n,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(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Vc(n),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];s.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const A=e[c].default;switch(t[c]={default:A},p){case"TimeOut":A.maxLoadTimeMs=v,A.maxTimeToFirstByteMs=v;break;case"MaxRetry":A.errorRetry.maxNumRetry=v,A.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":A.errorRetry.retryDelayMs=v,A.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=v,A.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&Y.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Bi(Bi({},e),t)}function Vc(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Vc):Object.keys(n).reduce((t,e)=>(t[e]=Vc(n[e]),t),{}):n}function Zb(n){const t=n.loader;t!==Ef&&t!==Af?(Y.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):$b()&&(n.loader=Ef,n.progressive=!0,n.enableSoftwareAES=!0,Y.log("[config]: Progressive streaming enabled, using FetchLoader"))}class ts{static get version(){return"1.4.12"}static isSupported(){return oy()}static get Events(){return L}static get ErrorTypes(){return qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return ts.defaultConfig?ts.defaultConfig:jb}static set DefaultConfig(t){ts.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new _c,this._autoLevelCapping=void 0,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,Pm(t.debug||!1,"Hls instance");const e=this.config=Yb(ts.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&Zb(e);const{abrController:i,bufferController:s,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new s(this),v=this.capLevelController=new o(this),A=new d(this),T=new kv(this),E=new _v(this),w=e.contentSteeringController,R=w?new w(this):null,x=this.levelController=new Wv(this,R),M=new Kv(this),G=new zv(this.config),_=this.streamController=new Yy(this,M,G);v.setStreamController(_),A.setStreamController(_);const F=[T,x,_];R&&F.splice(1,0,R),this.networkControllers=F;const H=[p,g,v,A,E,M];this.audioTrackController=this.createController(e.audioTrackController,F);const j=e.audioStreamController;j&&F.push(new j(this,M,G)),this.subtitleTrackController=this.createController(e.subtitleTrackController,F);const nt=e.subtitleStreamController;nt&&F.push(new nt(this,M,G)),this.createController(e.timelineController,H),G.emeController=this.emeController=this.createController(e.emeController,H),this.cmcdController=this.createController(e.cmcdController,H),this.latencyController=this.createController(Cv,H),this.coreComponents=H,F.push(f);const ot=f.onErrorOut;typeof ot=="function"&&this.on(L.ERROR,ot,f)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){Y.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(L.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Y.log("destroy"),this.trigger(L.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 t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){Y.log("attachMedia"),this._media=t,this.trigger(L.MEDIA_ATTACHING,{media:t})}detachMedia(){Y.log("detachMedia"),this.trigger(L.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=Zl.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});Y.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(L.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Y.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){Y.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){Y.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Y.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){Y.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Y.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Y.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){Y.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){Y.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(Y.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){cc.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s<i;s++)if(t[s].maxBitrate>=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(e===-1&&t&&t.length?s=t.length-1:s=e,i)for(let o=s;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}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}}ts.defaultConfig=void 0;function Xb(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function qb(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Qb=sa(async function(n){return new FontFace(n.name,`url(${n.url})`,{style:n.style,weight:n.weight}).load()},{cacheKey:([n])=>JSON.stringify(n)});async function Jb(n){return n.duration===1/0?new Promise(t=>{n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,t(n.duration),n.currentTime=0}}):n.duration}class t4{constructor(t){this._memoKey=null,this._lastDeps=null,this._duration=0,this._processing=!1,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=sa(e=>{const{id:i,src:s,playlist:o,duration:c}=e;return this._cleanupVideo(i),new Promise(d=>{let f=null;const p=document.createElement("video");p.playsInline=!0,p.muted=!0,p.loop=!1,p.volume=this.host.volume,p.playbackRate=this.host.playbackRate;const g={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},v=Object.keys(g).reduce((A,T)=>{const E=T,w=g[E](i,p);return A[E]=w,p.addEventListener(T,w),A},{});if(o&&!Xb()&&ts.isSupported()){let A=!1;f=new ts({autoStartLoad:!0,xhrSetup:T=>{const{open:E}=T,w=o.split("?")[1];T.open=function(R,x,M){x.toString().includes("?")||(x+="?"+w),E.apply(this,[R,x,M])}}}),f.loadSource(o),f.attachMedia(p),f.startLoadOnce=(T=-1)=>{f&&!A&&(f.startLoad(T),A=!0)},f.on(ts.Events.LEVEL_LOADED,async()=>{A||f==null||f.stopLoad(),d({id:i,hls:f,node:p})})}else{p.src=s;let A=!1;if(p.startLoadOnce=()=>{A||(p.preload="auto",p.load(),A=!0)},c)p.preload="none",d({id:i,hls:f,node:p});else{p.preload="metadata";const T=async()=>{d({id:i,hls:f,node:p}),p.removeEventListener("loadedmetadata",T)};p.addEventListener("loadedmetadata",T)}}this.videos[i]={id:i,hls:f,node:p,listeners:v},this.videoState[i]={initialised:!1,waiting:!0,buffered:[]}})},{cacheKey:([{id:e,src:i,playlist:s}])=>JSON.stringify({id:e,src:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=sa(async(e,i)=>{const{id:s,captions:o,duration:c,startOffset:d,endOffset:f}=e,p=c??await Jb(i),g=(d??0)*p,v=(1-(f??0))*p,A={id:s,captions:o,start:g,duration:v};return this.videoMeta[s]=A,A},{cacheKey:([{id:e,captions:i,duration:s,startOffset:o,endOffset:c}])=>JSON.stringify({id:e,captions:i,duration:s,startOffset:o,endOffset:c})}),this._handleLoadedData=(e,i)=>()=>{const s=this.videoState[e];s!=null&&s.initialised||(this.videoState={...this.videoState,[e]:{...s,initialised:!0,waiting:!1,buffered:(s==null?void 0:s.buffered)??[]}},this.setVideosCurrentTime(this.host.currentTime),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:e,node:i}})))},this._handleWaiting=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&!(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[e]:{...i,waiting:!0}})},this._handleCanPlay=e=>()=>{const i=this.videoState[e];i!=null&&i.initialised&&i!=null&&i.waiting&&(this.videoState={...this.videoState,[e]:{...i,waiting:!1}})},this._handleProgress=(e,i)=>()=>{var s;const o=i==null?void 0:i.buffered,c=[],{start:d,video:f,videoMeta:p}=((s=this.scenes)==null?void 0:s.scenes.find(({video:g})=>e===(g==null?void 0:g.id)))??{};if(i&&o&&f&&p&&typeof d<"u"){for(let v=0;v<o.length;v++){const A=o.start(v),T=o.end(v);Math.max(A,p.start)<=Math.min(T,p.start+p.duration)&&c.push({start:Math.max(0,(Math.max(A-p.start,0)+d)/this.host.duration*100),end:Math.min((Math.min(T-p.start,p.duration)+d)/this.host.duration*100,100)})}const g=this.videoState[e];this.videoState={...this.videoState,[e]:{...g,buffered:c}}}},this._handleSeeked=(e,i)=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:e,node:i}})))},this._handlePlay=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:e,node:i}}))},this._handlePlaying=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:e,node:i}}))},this._handlePause=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:e,node:i}}))},this._handleStalled=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:e,node:i}}))},this._handleTimeUpdate=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:e,node:i}}))},this._handleEnded=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:e,node:i}}))},this._handleError=(e,i)=>()=>{this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:e,node:i}}))},this.host=t,this.host.addController(this)}set processing(t){t!==this._processing&&(this._processing=t,this.host.requestUpdate())}get processing(){return this._processing}set duration(t){!isNaN(t)&&t!==this._duration&&(this._duration=t,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(t){this._scenes=t,this.host.requestUpdate()}get scenes(){return this._scenes}set videos(t){this._videos=t,this.host.requestUpdate()}get videos(){return this._videos}set videoMeta(t){this._videoMeta=t,this.host.requestUpdate()}get videoMeta(){return this._videoMeta}set videoState(t){this._videoState=t,this.host.requestUpdate()}get videoState(){return this._videoState}_setupTask(){new Td(this.host,async([t,e,i,s,o])=>{try{if(i||t){if(this.processing=!0,i){let c=null;if(s)try{c=await(await fetch(s,{method:"GET"})).text()}catch{this.host.dispatchEvent(new ErrorEvent("error",new Error("Track failed to fetch")))}const d=i.includes(".m3u8")?"playlist":"video";this.scenes=await Gd({data:{questions:{items:[{answer:{id:"source",media:{[d]:i},captions:{current:c}}}]}},template:e,burnCaptions:o},this._resolveVideo,this._resolveVideoMeta)}else this.scenes=await Gd({data:t,template:e,burnCaptions:o},this._resolveVideo,this._resolveVideoMeta);(await Promise.all(this.scenes.fonts.map(c=>Qb(c)))).forEach(c=>{document.fonts.add(c)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused),this.host.autoplay&&this.host.play()}}catch(c){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",c))}finally{this.processing=!1}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions];return this._memoKey=t,this._lastDeps=e,e})}_setVideoCurrentTime({time:t,scene:e}){const{start:i,video:s,videoMeta:o}=e;if(s&&s.node&&o&&typeof i<"u"){const c=t-i;s.node.currentTime=Math.max(o.start,Math.min(o.start+o.duration,c+o.start))}}setVideosCurrentTime(t){var e;(e=this.scenes)==null||e.scenes.forEach(i=>{this._setVideoCurrentTime({time:t,scene:i})})}_cleanupVideo(t){var e;const i=this.videos[t];i&&((e=i.hls)==null||e.destroy(),i.node.pause(),i.node.src="",Object.keys(i.listeners).forEach(s=>{var o;if((o=this.videos)!=null&&o[t]){const c=i.listeners[s];i.node.removeEventListener(s,c)}}),delete this.videos[t])}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(t=>{this._cleanupVideo(t)}),this.videos={}}}function e4(n){n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen&&n.msRequestFullscreen()}function i4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const Wc=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen"],r4={id:"captions",event:"captions:click",label:"Closed Captions"},s4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Tf={title:"Playback Speed",items:[{id:"playback-rate-0.5",event:"playbackRate:click",label:"0.5x",value:.5},{id:"playback-rate-1",event:"playbackRate:click",label:"1.0x",value:1},{id:"playback-rate-1.5",event:"playbackRate:click",label:"1.5x",value:1.5},{id:"playback-rate-2",event:"playbackRate:click",label:"2.0x",value:2}]},n4={id:"playbackRate",label:"Playback playbackRate",subItems:Tf};class a4 extends md{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==Qn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),us}}const Kc=Jn(a4),Mr={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-100":"#a5e9ed","teal-600":"#006776","purple-100":"#d7cfff","purple-700":"#5f2fe9","green-200":"#a4d7aa","green-500":"#38b319","green-800":"#2b3c2f","grey-100":"#f0f0f0","light-50":"rgba(255, 255, 255, .05)","light-100":"rgba(255, 255, 255, .1)","light-200":"rgba(255, 255, 255, .2)","light-400":"rgba(255, 255, 255, .4)","light-500":"rgba(255, 255, 255, .5)","light-640":"rgba(255, 255, 255, .64)","light-800":"rgba(255, 255, 255, .8)","light-1000":"#fff","dark-50":"rgba(0, 0, 0, .05)","dark-80":"rgba(0, 0, 0, .08)","dark-100":"rgba(0, 0, 0, .1)","dark-200":"rgba(0, 0, 0, .2)","dark-250":"rgba(0, 0, 0, .25)","dark-400":"rgba(0, 0, 0, .4)","dark-500":"rgba(0, 0, 0, .5)","dark-640":"rgba(0, 0, 0, .64)","dark-800":"rgba(0, 0, 0, .8)","dark-900":"rgba(0, 0, 0, .9)","dark-1000":"#000"},o4={colors:Mr,space:{xxs:".25rem",xs:".5rem",small:".75rem",medium:"1rem",large:"1.5rem",xl:"2.5rem"},sizes:{xxs:"1rem",xs:"1.5rem",small:"2rem",medium:"2.5rem",large:"3rem"},fontWeights:{regular:400,semibold:600},lineHeights:{small:1.1,medium:1.25,large:1.4},letterSpacings:{xxs:"-.04rem",xs:"-.03rem",small:"-.02rem",medium:"-.01rem",large:0},fontSizes:{micro:".625rem",small:".75rem",medium:".875rem",large:"1rem",xl:"1.25rem",xxl:"1.5rem",xxxl:"2rem",huge:"2.75rem"},fontFamilies:{sans:'Roobert, "Times New Roman", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',mono:'"Maison Neue Mono", Menlo, Monaco, Consolas, Liberation Mono, "Courier New", monospace'},borderWidths:{thin:".0625rem"},radii:{small:".25rem",medium:".5rem",large:".75rem",xl:"1rem"},shadows:{small:`.25rem .25rem .25rem ${Mr["dark-100"]}`,medium:`0 .125rem .625rem ${Mr["dark-100"]}`,large:`0 .25rem 1rem ${Mr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Mr["dark-250"]}`,xxl:`0 .25rem 2rem ${Mr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Mr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Mr["dark-50"]}`,text:`0 0 .25rem ${Mr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Mr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},kf=Zg.flatten(o4,{delimiter:"-"}),l4=Object.keys(kf).map(n=>Wn(`:host { --${n}: ${kf[n]}; }`)),c4=n=>{class t extends n{firstUpdated(){const i=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),s=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"});document.fonts.add(i),document.fonts.add(s)}}return t.styles=[(n==null?void 0:n.styles)??[],l4,Ii`
203
+ `),p=[],g=t?Wy(t.baseTime,t.timescale):0;let v="00:00.000",b=0,E=0,k,w=!0;d.oncue=function(L){const x=e[i];let M=e.ccOffset;const N=(b-g)/9e4;if(x!=null&&x.new&&(E!==void 0?M=e.ccOffset=x.start:xb(e,i,N)),N){if(!t){k=new Error("Missing initPTS for VTT MPEGTS");return}M=N-e.presentationOffset}const D=L.endTime-L.startTime,F=hr((L.startTime+M-E)*9e4,s*9e4)/9e4;L.startTime=Math.max(F,0),L.endTime=Math.max(F+D,0);const H=L.text.trim();L.text=decodeURIComponent(encodeURIComponent(H)),L.id||(L.id=Kc(L.startTime,L.endTime,H)),L.endTime>0&&p.push(L)},d.onparsingerror=function(L){k=L},d.onflush=function(){if(k){c(k);return}o(p)},f.forEach(L=>{if(w)if(Wc(L,"X-TIMESTAMP-MAP=")){w=!1,L.slice(16).split(",").forEach(x=>{Wc(x,"LOCAL:")?v=x.slice(6):Wc(x,"MPEGTS:")&&(b=parseInt(x.slice(7)))});try{E=Db(v)/1e3}catch(x){k=x}return}else L===""&&(w=!1);d.parse(L+`
204
+ `)}),d.flush()}const Yc="stpp.ttml.im1t",bf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Af=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Ob={left:"start",center:"center",right:"end",start:"start",end:"end"};function Ef(n,t,e,i){const s=be(new Uint8Array(n),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=s.map(d=>Pr(d)),c=Hy(t.baseTime,1,t.timescale);try{o.forEach(d=>e(Mb(d,c)))}catch(d){i(d)}}function Mb(n,t){const e=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",c=kf(zc(e,"styling","style")),d=kf(zc(e,"layout","region")),f=zc(e,"body","[begin]");return[].map.call(f,p=>{const g=Tf(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=Xc(p.getAttribute("begin"),s),b=Xc(p.getAttribute("dur"),s);let E=Xc(p.getAttribute("end"),s);if(v===null)throw wf(p);if(E===null){if(b===null)throw wf(p);E=v+b}const k=new Vc(v-t,E-t,g);k.id=Kc(k.startTime,k.endTime,k.text);const w=d[p.getAttribute("region")],L=c[p.getAttribute("style")],x=$b(w,L,c),{textAlign:M}=x;if(M){const N=Ob[M];N&&(k.lineAlign=N),k.align=M}return ai(k,x),k}).filter(p=>p!==null)}function zc(n,t,e){const i=n.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function kf(n){return n.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Tf(n,t){return[].slice.call(n.childNodes).reduce((e,i,s)=>{var o;return i.nodeName==="br"&&s?e+`
205
+ `:(o=i.childNodes)!=null&&o.length?Tf(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function $b(n,t,e){const i="http://www.w3.org/ns/ttml#styling";let s=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(s=e[c]),o.reduce((d,f)=>{const p=Zc(t,i,f)||Zc(n,i,f)||Zc(s,i,f);return p&&(d[f]=p),d},{})}function Zc(n,t,e){return n&&n.hasAttributeNS(t,e)?n.getAttributeNS(t,e):null}function wf(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Xc(n,t){if(!n)return null;let e=mf(n);return e===null&&(bf.test(n)?e=Fb(n,t):Af.test(n)&&(e=Nb(n,t))),e}function Fb(n,t){const e=bf.exec(n),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function Nb(n,t){const e=Af.exec(n),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class Ub{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Sf(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new $o(this,"textTrack1"),i=new $o(this,"textTrack2"),s=new $o(this,"textTrack3"),o=new $o(this,"textTrack4");this.cea608Parser1=new ff(1,e,i),this.cea608Parser2=new ff(3,s,o)}t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,s,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=Gb(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),c=!0,p/(i-e)>.5))return}if(c||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,s)}else{const d=this.Cues.newCue(null,e,i,s);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:s,timescale:o}),c.length&&(this.unparsedVttFrags=[],c.forEach(d=>{this.onFragLoaded(R.FRAG_LOADED,d)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let i=0;i<e.textTracks.length;i++){const s=e.textTracks[i];if(s[t])return s}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:s}=this,{label:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Rn(i[t]),y0(i[t],s);else{const f=this.createTextTrack("captions",o,c);f&&(f[t]=!0,i[t]=f)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i=e.label,s={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,i){const s=this.media;if(s)return s.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Rn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Sf(),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:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let i=0;i<e.length;i++)Rn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(o=>o.textCodec===Yc);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(nf(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((c,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(Bb(o[g],c)){p=o[g];break}p&&(f=p)}if(f)Rn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(c);f=this.createTextTrack(p,c.name,c.lang),f&&(f.mode="disabled")}f&&(f.groupId=c.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(c=>({label:c.name,kind:c.type.toLowerCase(),default:c.default,subtitleTrack:c}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&i)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const o=`textTrack${s[1]}`,c=this.captionsProperties[o];c&&(c.label=i.name,i.lang&&(c.languageCode=i.lang),c.media=i)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:i,cea608Parser2:s,lastSn:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&s))&&e.frag.type===Jt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===c+1||(i.reset(),s.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===Jt.SUBTITLE)if(s.byteLength){const o=i.decryptdata,c="stats"in e;if(o==null||!o.encrypted||c){const d=this.tracks[i.level],f=this.vttCCs;f[i.cc]||(f[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),d&&d.textCodec===Yc?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;Ef(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{z.log(`Failed to parse IMSC1: ${s}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:s})})}_parseVTTs(t){var e;const{frag:i,payload:s}=t,{initPTS:o,unparsedVttFrags:c}=this,d=o.length-1;if(!o[i.cc]&&d===-1){c.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?ln(i.initSegment.data,new Uint8Array(s)):s;Pb(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,g=>{this._appendCues(g,i.level),f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?c.push(t):this._fallbackToIMSC1(i,s),z.log(`Failed to parse VTT cue: ${g}`),!(v&&d>i.cc)&&f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:g})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||Ef(e,this.initPTS[t.cc],()=>{i.textCodec=Yc,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||s.mode==="disabled")return;t.forEach(o=>b0(s,o))}else{const s=this.tracks[e];if(!s)return;const o=s.default?"default":"subtitles"+e;i.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Jt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&s))return;const{frag:o,samples:c}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<c.length;d++){const f=c[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(c[d].pts,p[0]),s.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:s,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>gc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>gc(d[f],e,s))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let s=2;for(let o=0;o<i;o++){const c=t[s++],d=127&t[s++],f=127&t[s++];if(!(d===0&&f===0)&&4&c){const p=3&c;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function Bb(n,t){return!!n&&n.label===t.name&&!(n.textTrack1||n.textTrack2)}function Gb(n,t,e,i){return Math.min(t,i)-Math.max(n,e)}function Sf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class qc{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter((s,o)=>this.isLevelAllowed(s)&&o<=t);return this.clientRect=null,qc.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}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 t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,!e.width&&!e.height&&(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,i){if(!(t!=null&&t.length))return-1;const s=(c,d)=>d?c.width!==d.width||c.height!==d.height:!0;let o=t.length-1;for(let c=0;c<t.length;c+=1){const d=t[c];if((d.width>=e||d.height>=i)&&s(d,t[c+1])){o=c;break}}return o}}class Vb{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const s=performance.now();if(e){if(this.lastTime){const o=s-this.lastTime,c=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*c/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:c,currentDecoded:d,totalDroppedFrames:i}),f>0&&c>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;z.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const No="[eme]";class Dn{constructor(t){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=Dn.CDMCleanupPromise?[Dn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=z.debug.bind(z,No),this.log=z.log.bind(z,No),this.warn=z.warn.bind(z,No),this.error=z.error.bind(z,No),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===Ze.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(c,d,f)=>!!c&&f.indexOf(c)===d,s=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,s,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof dr?d(v):d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return Ku===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(t,e)}getMediaKeysPromise(t,e,i){const s=iv(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let c=o==null?void 0:o.keySystemAccess;if(!c){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(s)}`),c=this.requestMediaKeySystemAccess(t,s);const d=this.keySystemAccessPromises[t]={keySystemAccess:c};return c.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),c.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return c.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Or.hexDump(t.keyId||[])}`);const s=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,o,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return Or.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Or.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
206
+ } (data length: ${e&&e.byteLength})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const s=lc(this.config),o=t.map(Hu).filter(c=>!!c&&s.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=ju(c);d?e(d):i(new Error(`Unable to find format for key-system "${c}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(c=>this.handleError(c))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof dr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=Hu(t.keyFormat),o=s?[s]:lc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=lc(this.config)),t.length===0)throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let s,o;if(e==="sinf"&&this.config.drmSystems[Ze.FAIRPLAY]){const g=bi(new Uint8Array(i));try{const v=oc(JSON.parse(g).sinf),b=t0(new Uint8Array(v));if(!b)return;s=b.subarray(8,24),o=Ze.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Rv(i);if(g===null)return;g.version===0&&g.systemId===Wu.WIDEVINE&&g.data&&(s=g.data.subarray(8,24)),o=ev(g.systemId)}if(!o||!s)return;const c=Or.hexDump(s),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[c];for(let g=0;g<f.length;g++){const v=f[g],b=v.decryptdata;if(b.pssh||!b.keyId)continue;const E=Or.hexDump(b.keyId);if(c===E||b.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],b.pssh=new Uint8Array(i),b.keyId=s,p=d[c]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[c]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var b;this.throwIfDestroyed();const E=new wa("ISO-23001-7",c,(b=ju(g))!=null?b:"");return E.pssh=new Uint8Array(i),E.keyId=s,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const k=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(k,e,i,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var o,c;const d=(o=this.config.drmSystems)==null||(c=o[t.keySystem])==null?void 0:c.generateRequest;if(d)try{const b=d.call(this.hls,e,i,t);if(!b)throw new Error("Invalid response from configured generateRequest filter");e=b.initDataType,i=t.decryptdata.pssh=b.initData?new Uint8Array(b.initData):null}catch(b){var f;if(this.warn(b.message),(f=this.hls)!=null&&f.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Fc;t.mediaKeysSession.onmessage=b=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:k,message:w}=b;this.log(`"${k}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),k==="license-request"||k==="license-renewal"?this.renewLicense(t,w).catch(L=>{this.handleError(L),g.emit("error",L)}):k==="license-release"?t.keySystem===Ze.FAIRPLAY&&(this.updateKeySession(t,Vu("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${k}"`)},t.mediaKeysSession.onkeystatuseschange=b=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const E=t.keyStatus;g.emit("keyStatus",E),E==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((b,E)=>{g.on("error",E),g.on("keyStatus",k=>{k.startsWith("usable")?b():k==="output-restricted"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):k==="internal-error"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${k}"`)):k==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${k}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var b;this.log(`Request generated for key-session "${(b=t.mediaKeysSession)==null?void 0:b.sessionId}" keyId: ${p}`)}).catch(b=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:b,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>{throw g.removeAllListeners(),this.removeSession(t),b}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Or.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Or.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,s=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((c,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,k,w)=>{c(b.data)},onError:(b,E,k,w)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:k,response:Hi({url:f.url,data:void 0},b)},`"${t}" certificate request failed (${o}). Status: ${b.code} (${b.text})`))},onTimeout:(b,E,k)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:k,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(b,E,k)=>{d(new Error("aborted"))}};s.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(c=>{o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,i,s)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,s)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||s})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((s,o)=>{const c=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${c}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,c,t)}catch(g){this.error(g)}s(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:c,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${c}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(s,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,c,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},wa.clearKeyUriToKeyIdMap();const i=e.length;Dn.CDMCleanupPromise=Promise.all(e.map(s=>this.removeSession(s)).concat(t==null?void 0:t.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.reduce((s,o)=>(s.indexOf(o.keyFormat)===-1&&s.push(o.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);return s>-1&&this.mediaKeySessions.splice(s,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}Dn.CDMCleanupPromise=void 0;class dr extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const Hb=1;var Ki={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const Wb="h";class ks{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:Ki.MANIFEST,su:!this.initialized})}catch(o){z.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=s=>{try{const o=s.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Ki.VIDEO||d===Ki.AUDIO||d==Ki.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(s,f)}catch(o){z.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||ks.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.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(t,e){var i,s;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=e.tracks.video)==null?void 0:s.buffer}createData(){var t;return{v:Hb,sf:Wb,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ai(e,this.createData());const i=e.ot===Ki.INIT||e.ot===Ki.VIDEO||e.ot===Ki.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const s=ks.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),ai(t.headers,s)}else{const s=ks.toQuery(e);if(!s)return;t.url=ks.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Ki.TIMED_TEXT;if(t.sn==="initSegment")return Ki.INIT;if(e==="audio")return Ki.AUDIO;if(e==="main")return this.hls.audioTracks.length?Ki.VIDEO:Ki.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===Ki.AUDIO)i=s.audioTracks;else{const o=s.maxAutoLevel,c=o>-1?o+1:s.levels.length;i=s.levels.slice(0,c)}for(const o of i)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===Ki.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:$e.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,s=f=>Math.round(f),o=f=>s(f/100)*100,c={br:s,d:s,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:s},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!i(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=c[f];g&&(p=g(p));const v=typeof p;let b;f==="ot"||f==="sf"||f==="st"?b=`${f}=${p}`:v==="boolean"?b=f:v==="number"?b=`${f}=${p}`:b=`${f}=${JSON.stringify(p)}`,e.push(b)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],o=[{},{},{},{}],c={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=c[d]!=null?c[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=ks.serialize(o[d]);f&&(i[`CMCD-${s[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(ks.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const jb=3e5;class Kb{constructor(t){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=t,this.log=z.log.bind(z,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}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(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ri.SendAlternateToPenaltyBox&&i.flags===cr.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(o=>{s-i[o]>jb&&delete i[o]});for(let o=0;o<t.length;o++){const c=t[o];if(i[c])continue;if(c===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(c),e.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(o=>{const{ID:c,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===c))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ai({},g);v.details=void 0,v.url=Lf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const b=new ze(g.attrs);b["PATHWAY-ID"]=c;const E=b.AUDIO&&`${b.AUDIO}_clone_${c}`,k=b.SUBTITLES&&`${b.SUBTITLES}_clone_${c}`;E&&(i[b.AUDIO]=E,b.AUDIO=E),k&&(s[b.SUBTITLES]=k,b.SUBTITLES=k),v.attrs=b;const w=new Ra(v);return _o(w,"audio",E),_o(w,"text",k),w});e.push(...p),Rf(this.audioTracks,i,f,c),Rf(this.subtitleTracks,s,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(s.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:s.href},c=e.steeringManifestLoadPolicy.default,d=c.errorRetry||c.timeoutRetry||{},f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,b,E)=>{this.log(`Loaded steering manifest: "${s}"`);const k=g.data;if(k.VERSION!==1){this.log(`Steering VERSION ${k.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=k.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":L,"PATHWAY-PRIORITY":x}=k;if(w)try{this.uri=new self.URL(w,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||b.url),L&&this.clonePathways(L),x&&this.updatePathwayPriority(x)},onError:(g,v,b,E)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let k=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const L=w.getResponseHeader("Retry-After");L&&(k=parseFloat(L)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,k)},onTimeout:(g,v,b)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Rf(n,t,e,i){n&&Object.keys(t).forEach(s=>{const o=n.filter(c=>c.groupId===s).map(c=>{const d=ai({},c);return d.details=void 0,d.attrs=new ze(d.attrs),d.url=d.attrs.URI=Lf(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[s],d.attrs["PATHWAY-ID"]=i,d});n.push(...o)})}function Lf(n,t,e,i){const{HOST:s,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(n=d));const f=new self.URL(n);return s&&!d&&(f.host=s),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const Yb=/^age:\s*[\d.]+\s*$/im;class _f{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new bo,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(c=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(c=>{this.callbacks.onError({code:i.status,text:c.message},e,i,s)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(s)for(const d in s)t.setRequestHeader(d,s[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=o&&jt(o)?o:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,o=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const c=e.status,d=e.responseType!=="text";if(c>=200&&c<300&&(d&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(i,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:c};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;Lo(f,p,!1,c)?this.retry(f):(z.error(`${c} while loading ${t.url}`),this.callbacks.onError({code:c,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(Lo(e,i,!0))this.retry(e);else{z.warn(`timeout while loading ${this.context.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=Ec(t,i.retry),i.retry++,z.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.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(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&Yb.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function zb(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Zb=/(\d+)-(\d+)\/(\d+)/;class Cf{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Jb,this.controller=new self.AbortController,this.stats=new bo}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const o=Xb(t,this.controller.signal),c=i.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&jt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const b=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},g-(b-s.loading.start)),!v.ok){const{status:E,statusText:k}=v;throw new t4(k||"fetch, bad network response",E,v)}return s.loading.first=b,s.total=Qb(v.headers)||s.total,c&&jt(e.highWaterMark)?this.loadProgressively(v,s,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:b}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=v[f];E&&(s.loaded=s.total=E);const k={url:b.url,data:v,code:b.status};c&&!jt(e.highWaterMark)&&c(s,t,v,b),i.onSuccess(k,s,t,b)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const b=v&&v.code||0,E=v?v.message:null;i.onError({code:b,text:E},t,v?v.details:null,s)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,o){const c=new rf,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return c.dataLength&&o(e,i,c.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<s||c.dataLength?(c.push(g),c.dataLength>=s&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function Xb(n,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ai({},n.headers))};return n.rangeEnd&&e.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),e}function qb(n){const t=Zb.exec(n);if(t)return parseInt(t[2])-parseInt(t[1])+1}function Qb(n){const t=n.get("Content-Range");if(t){const i=qb(t);if(jt(i))return i}const e=n.get("Content-Length");if(e)return parseInt(e)}function Jb(n,t){return new self.Request(n.url,t)}class t4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const e4=/\s/,i4={newCue(n,t,e,i){const s=[];let o,c,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let b=0;b<i.rows.length;b++)if(o=i.rows[b],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)e4.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const E=yf(p.trim()),k=Kc(t,e,E);n!=null&&(v=n.cues)!=null&&v.getCueById(k)||(c=new g(t,e,E),c.id=k,c.line=b+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),s.push(c))}return n&&s.length&&(s.sort((b,E)=>b.line==="auto"||E.line==="auto"?0:b.line>8&&E.line>8?E.line-b.line:b.line-E.line),s.forEach(b=>b0(n,b))),s}},r4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},s4=Hi(Hi({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:_f,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:lb,bufferController:vb,capLevelController:qc,errorController:ty,fpsController:Vb,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Ku,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:r4},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},n4()),{},{subtitleStreamController:fb,subtitleTrackController:gb,timelineController:Ub,audioStreamController:hb,audioTrackController:db,emeController:Dn,cmcdController:ks,contentSteeringController:Kb});function n4(){return{cueHandler:i4,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function a4(n,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(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=Qc(n),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];s.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const b=e[c].default;switch(t[c]={default:b},p){case"TimeOut":b.maxLoadTimeMs=v,b.maxTimeToFirstByteMs=v;break;case"MaxRetry":b.errorRetry.maxNumRetry=v,b.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":b.errorRetry.retryDelayMs=v,b.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":b.errorRetry.maxRetryDelayMs=v,b.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&z.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Hi(Hi({},e),t)}function Qc(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(Qc):Object.keys(n).reduce((t,e)=>(t[e]=Qc(n[e]),t),{}):n}function o4(n){const t=n.loader;t!==Cf&&t!==_f?(z.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):zb()&&(n.loader=Cf,n.progressive=!0,n.enableSoftwareAES=!0,z.log("[config]: Progressive streaming enabled, using FetchLoader"))}class es{static get version(){return"1.4.12"}static isSupported(){return by()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return es.defaultConfig?es.defaultConfig:s4}static set DefaultConfig(t){es.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Fc,this._autoLevelCapping=void 0,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,j1(t.debug||!1,"Hls instance");const e=this.config=a4(es.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&o4(e);const{abrController:i,bufferController:s,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new s(this),v=this.capLevelController=new o(this),b=new d(this),E=new Mv(this),k=new Bv(this),w=e.contentSteeringController,L=w?new w(this):null,x=this.levelController=new iy(this,L),M=new ry(this),N=new ny(this.config),D=this.streamController=new ab(this,M,N);v.setStreamController(D),b.setStreamController(D);const F=[E,x,D];L&&F.splice(1,0,L),this.networkControllers=F;const H=[p,g,v,b,k,M];this.audioTrackController=this.createController(e.audioTrackController,F);const j=e.audioStreamController;j&&F.push(new j(this,M,N)),this.subtitleTrackController=this.createController(e.subtitleTrackController,F);const st=e.subtitleStreamController;st&&F.push(new st(this,M,N)),this.createController(e.timelineController,H),N.emeController=this.emeController=this.createController(e.emeController,H),this.cmcdController=this.createController(e.cmcdController,H),this.latencyController=this.createController(Gv,H),this.coreComponents=H,F.push(f);const at=f.onErrorOut;typeof at=="function"&&this.on(R.ERROR,at,f)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){z.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){z.log("destroy"),this.trigger(R.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 t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){z.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){z.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=sc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});z.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){z.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){z.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){z.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){z.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){z.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){z.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){z.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){z.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){z.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(z.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){yc.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s<i;s++)if(t[s].maxBitrate>=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(e===-1&&t&&t.length?s=t.length-1:s=e,i)for(let o=s;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}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}}es.defaultConfig=void 0;function l4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function c4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function If(n){const{id:t,key:e,src:i,playlist:s,duration:o}=n;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,s&&!l4()&&es.isSupported()){let p=!1;d=new es({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,b=s.split("?")[1];g.open=function(E,k,w){k.toString().includes("?")||(k+="?"+b),v.apply(this,[E,k,w])}}}),d.loadSource(s),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const b=d==null?void 0:d.levels.findIndex(E=>Math.min(E.height,E.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=b!==-1?b:d.firstLevel}},d.on(es.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:n,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",c({id:t,key:e,hls:d,config:n,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:n,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Df(n){return n.duration===1/0?new Promise(t=>{n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,t(n.duration),n.currentTime=0}}):n.duration}const h4=vs(async function(n){return new FontFace(n.name,`url(${n.url})`,{style:n.style,weight:n.weight}).load()},{cacheKey:([n])=>JSON.stringify(n)});let d4=class{constructor(n){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=vs(async t=>{const{id:e,key:i}=t,s=await If(t);s.node.volume=this.host.volume,s.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},c=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:s.node});return d[p]=g,s.node.addEventListener(f,g),d},{});return{...s,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:s}])=>JSON.stringify({id:t,key:e,src:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=vs(async(t,e)=>{const{id:i,captions:s,duration:o,startOffset:c,endOffset:d}=t,f=o??await Df(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:s,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var s,o;const c=this.videoState[e];if(!(c!=null&&c.initialised)){this.videoState={...this.videoState,[e]:{...c,initialised:!0,waiting:!1,buffered:(c==null?void 0:c.buffered)??[]}};const d=(o=(s=this.scenes)==null?void 0:s.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:i}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const i=this.videoState[t],s=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:s}}},this._handleSeeking=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:i}}))},this._handleSeeked=({id:t,key:e,node:i})=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:i}})))},this._handlePlay=({id:t,key:e,node:i})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:i}}))},this._handlePlaying=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:i}}))},this._handlePause=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:i}}))},this._handleStalled=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:i}}))},this._handleTimeUpdate=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:i}}))},this._handleEnded=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:i}}))},this._handleError=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:i}}))},this._cleanupVideo=t=>{var e;const i=this.videos[t];i&&(i.node.pause(),i.node.src="",(e=i.hls)==null||e.destroy(),Object.keys(i.listeners??{}).forEach(s=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[s];d&&i.node.removeEventListener(s,d)}}),delete this.videos[t])},this.host=n,this.host.addController(this)}set hasPlayed(n){n!==this._hasPlayed&&(this._hasPlayed=n,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(n){!isNaN(n)&&n!==this._duration&&(this._duration=n,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(n){n!==this._scenes&&(this._scenes=n,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(n){n!==this._videos&&(this._videos=n,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(n){n!==this._videoMeta&&(this._videoMeta=n,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(n){n!==this._videoState&&(this._videoState=n,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:n,node:t,duration:e}){var i;const s=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>n===(p==null?void 0:p.key)))??{};if(t&&s&&d&&f&&typeof c<"u")for(let p=0;p<s.length;p++){const g=s.start(p),v=s.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+c)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+c)/e*100,100)})}return o}_setupTask(){new _l(this.host,async([n,t,e,i,s,o])=>{try{if(e||n){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new nn("Track failed to fetch");this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:f,message:f.message}))}try{const f=e.includes(".m3u8")?"playlist":"video";this.scenes=await ho({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new nn(`Source template error: ${f.message}`,!0)}}else try{this.scenes=await ho({data:n,template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new nn(`Data template error: ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new nn("Template error - No scenes created",!0);Object.keys(this.videos).forEach(d=>{this.scenes.scenes.find(({video:f})=>d===(f==null?void 0:f.key))||this._videos[d].node.pause()});const c=this.scenes.scenes.reduce((d,{video:f})=>(f&&(d[f.key]=f),d),{});Object.keys(this.videos).join("|")!==Object.keys(c).join("|")&&this.host.reset(0,!1),this.videos=c,this.videoState={...this.videoState,...this.scenes.scenes.reduce((d,{video:f,start:p,duration:g})=>{var v;const b=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:b,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[b]={initialised:!f,waiting:!!f,...this.videoState[b],buffered:f?E:(v=this.videoState[b])==null?void 0:v.buffered},d},{})},this.videoMeta=this.scenes.scenes.reduce((d,{video:f,videoMeta:p})=>(f&&p&&(d[f.key]=p),d),{}),(await Promise.all(this.scenes.fonts.map(d=>h4(d)))).forEach(d=>{document.fonts.add(d)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}}catch(c){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.message}))}finally{this.host._processing=!1}},()=>{const n=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions,debug:this.host.debug});if(this._lastDeps&&this._memoKey===n)return this._lastDeps;const t=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions,this.host.debug];return this._memoKey=n,this._lastDeps=t,t})}_setVideoCurrentTime({time:n,scene:t}){const{start:e,video:i,videoMeta:s}=t;if(i&&i.node&&s&&typeof e<"u"){const o=n-e;i.node.currentTime=Math.max(s.start,Math.min(s.start+s.duration,o+s.start))}}setVideosCurrentTime(n){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:n,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(n=>{this._cleanupVideo(n)}),this.videos={}}};function u4(n){n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen&&n.msRequestFullscreen()}function f4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const Jc=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],p4={id:"captions",event:"captions:click",label:"Closed Captions"},g4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},xf={title:"Playback Speed",items:[{id:"playback-rate-0.5",event:"playbackRate:click",label:"0.5x",value:.5},{id:"playback-rate-1",event:"playbackRate:click",label:"1.0x",value:1},{id:"playback-rate-1.5",event:"playbackRate:click",label:"1.5x",value:1.5},{id:"playback-rate-2",event:"playbackRate:click",label:"2.0x",value:2}]},m4={id:"playbackRate",label:"Playback playbackRate",subItems:xf};class v4 extends Sd{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==bn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),gs}}const Uo=An(v4),$r={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-100":"#a5e9ed","teal-600":"#006776","purple-100":"#d7cfff","purple-700":"#5f2fe9","green-200":"#a4d7aa","green-500":"#38b319","green-800":"#2b3c2f","grey-100":"#f0f0f0","light-50":"rgba(255, 255, 255, .05)","light-100":"rgba(255, 255, 255, .1)","light-200":"rgba(255, 255, 255, .2)","light-400":"rgba(255, 255, 255, .4)","light-500":"rgba(255, 255, 255, .5)","light-640":"rgba(255, 255, 255, .64)","light-800":"rgba(255, 255, 255, .8)","light-1000":"#fff","dark-50":"rgba(0, 0, 0, .05)","dark-80":"rgba(0, 0, 0, .08)","dark-100":"rgba(0, 0, 0, .1)","dark-200":"rgba(0, 0, 0, .2)","dark-250":"rgba(0, 0, 0, .25)","dark-400":"rgba(0, 0, 0, .4)","dark-500":"rgba(0, 0, 0, .5)","dark-640":"rgba(0, 0, 0, .64)","dark-800":"rgba(0, 0, 0, .8)","dark-900":"rgba(0, 0, 0, .9)","dark-1000":"#000"},y4={colors:$r,space:{xxs:".25rem",xs:".5rem",small:".75rem",medium:"1rem",large:"1.5rem",xl:"2.5rem"},sizes:{xxs:"1rem",xs:"1.5rem",small:"2rem",medium:"2.5rem",large:"3rem"},fontWeights:{regular:400,semibold:600},lineHeights:{small:1.1,medium:1.25,large:1.4},letterSpacings:{xxs:"-.04rem",xs:"-.03rem",small:"-.02rem",medium:"-.01rem",large:0},fontSizes:{micro:".625rem",small:".75rem",medium:".875rem",large:"1rem",xl:"1.25rem",xxl:"1.5rem",xxxl:"2rem",huge:"2.75rem"},fontFamilies:{sans:'Roobert, "Times New Roman", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',mono:'"Maison Neue Mono", Menlo, Monaco, Consolas, Liberation Mono, "Courier New", monospace'},borderWidths:{thin:".0625rem"},radii:{small:".25rem",medium:".5rem",large:".75rem",xl:"1rem"},shadows:{small:`.25rem .25rem .25rem ${$r["dark-100"]}`,medium:`0 .125rem .625rem ${$r["dark-100"]}`,large:`0 .25rem 1rem ${$r["dark-50"]}`,xl:`.25rem .25rem 1rem ${$r["dark-250"]}`,xxl:`0 .25rem 2rem ${$r["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${$r["dark-250"]}`,toolbar:`0 -.625rem .625rem ${$r["dark-50"]}`,text:`0 0 .25rem ${$r["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:$r["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Pf=nm.flatten(y4,{delimiter:"-"}),b4=Object.keys(Pf).map(n=>qn(`:host { --${n}: ${Pf[n]}; }`)),A4=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),E4=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),k4=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),T4=n=>{class t extends n{firstUpdated(){document.fonts.add(A4),document.fonts.add(E4),document.fonts.add(k4)}}return t.styles=[(n==null?void 0:n.styles)??[],b4,ki`
175
207
  :host {
176
208
  font-family: var(--fontFamilies-sans);
177
209
  font-size: var(--fontSizes-medium);
178
210
  line-height: var(--lineHeights-medium);
179
211
  font-weight: var(--fontWeights-regular);
180
212
  }
181
- `,Ii`
213
+ `,ki`
182
214
  *,
183
215
  *::before,
184
216
  *::after,
@@ -252,12 +284,12 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
252
284
  scroll-behavior: auto !important;
253
285
  }
254
286
  }
255
- `],t},Oe=c4(un),h4=(n,t)=>(typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,t)),t),d4=(n,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(s){typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,s))}}},qi=n=>t=>typeof t=="function"?h4(n,t):d4(n,t);class u4 extends Va{constructor(t){if(super(t),t.type!==Qn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),us}}const wf=Jn(u4);class f4{constructor(t){this.hiddenControls=[],this._measureRef=rr(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,s,o;const c=this._measureRef.value,d=(o=(s=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:s[0])==null?void 0:o.inlineSize;if(c&&d&&d!==this._prevControlsWidth){Object.keys(this._hideables).forEach(p=>{this._hideables[p].element.style.display=""}),Object.keys(this._showables).forEach(p=>{this._showables[p].element.style.display="none"});const f=[];for(;c.scrollWidth>c.offsetWidth;){const p=Object.keys(this._hideables).find(g=>this._hideables[g].hideIndex===f.length);if(p){const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p)}Object.keys(this._showables).forEach(g=>{this._showables[g].showOn.some(v=>f.includes(v))&&(this._showables[g].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return sr(this._measureRef)}contain(){return Kc(this._onResize)}hide(t,e){return wf(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return wf(i=>{this._showables[t]={element:i,showOn:e}})}}function Sf(n,t={}){const e=Math.max(0,n||0),i=Math.floor(e/3600),s=Math.floor(e%3600/60),o=Math.floor(e%3600%60),c=Math.floor(e%1*1e3);let d=i?`${i}:${`${s}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${s}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${c}`.padStart(3,"0")}`),d}var p4=Object.defineProperty,g4=Object.getOwnPropertyDescriptor,Sn=(n,t,e,i)=>{for(var s=i>1?void 0:i?g4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&p4(t,e,s),s};let bs=class extends Oe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ne`<button
256
- class=${je({active:this.active,"size-tiny":this.size==="tiny","size-small":this.size==="small","size-large":this.size==="large","radius-medium":this.rounded==="medium","radius-full":this.rounded==="full","weight-light":this.weight==="light","weight-heavy":this.weight==="heavy"})}
287
+ `],t},Le=T4(yn),w4=(n,t)=>(typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,t)),t),S4=(n,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(s){typeof window<"u"&&(window.customElements.get(n)??window.customElements.define(n,s))}}},Oi=n=>t=>typeof t=="function"?w4(n,t):S4(n,t);class R4{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=vs(async e=>{const i=await If(e);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:e,src:i,playlist:s}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveAnswer=vs(async e=>{const{id:i,key:s,poster:o}=e,c=new Image;return{id:i,key:s,config:e,node:null,getSource:()=>(o&&c.src!==o&&(c.onload=()=>{this.host._draw()},c.src=o),c)}},{cacheKey:([{id:e,poster:i}])=>JSON.stringify({id:e,poster:i==null?void 0:i.split("?")[0]})}),this._resolveVideoMeta=vs(async(e,i)=>{const{id:s,duration:o,startOffset:c,endOffset:d}=e,f=o??await Df(i),p=(c??0)*f,g=(1-(d??0))*f;return{id:s,start:p,duration:g-p}},{cacheKey:([{id:e,duration:i,startOffset:s,endOffset:o}])=>JSON.stringify({id:e,duration:i,startOffset:s,endOffset:o})}),this.host=t,this.host.addController(this)}set scenes(t){t!==this._scenes&&(this._scenes=t,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new _l(this.host,async([t,e,i])=>{var s;try{if(t){const o=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await ho({data:{questions:{items:[{answer:{id:"source",media:{[o]:t}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(c){throw new nn(`Video preview source template error: ${c.message}`)}this._video=((s=this.scenes.scenes[0].video)==null?void 0:s.node)??null}else if(e)try{this.scenes=await ho({data:e,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(o){throw new nn(`Video preview data template error: ${o.message}`)}}catch(o){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:o,message:o.message}))}},()=>{const t=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===t)return this._lastDeps;const e=[this.host.src,this.host.data,this.host.template];return this._memoKey=t,this._lastDeps=e,e})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function Of(n,t,e){return Math.min(Math.max(t,n),e)}function th(n,t={}){const e=Math.max(0,n||0),i=Math.floor(e/3600),s=Math.floor(e%3600/60),o=Math.floor(e%3600%60),c=Math.floor(e%1*1e3);let d=i?`${i}:${`${s}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${s}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${c}`.padStart(3,"0")}`),d}var L4=Object.defineProperty,_4=Object.getOwnPropertyDescriptor,xn=(n,t,e,i)=>{for(var s=i>1?void 0:i?_4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&L4(t,e,s),s};let Ts=class extends Le{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ie`<button
288
+ class=${Ye({active:this.active,"size-tiny":this.size==="tiny","size-small":this.size==="small","size-large":this.size==="large","radius-medium":this.rounded==="medium","radius-full":this.rounded==="full","weight-light":this.weight==="light","weight-heavy":this.weight==="heavy"})}
257
289
  >
258
290
  <slot></slot>
259
- ${this.icon&&ne`<vmp-new-icon icon=${this.icon}></vmp-new-icon>`}
260
- </button>`}};bs.styles=[Oe.styles??[],Ii`
291
+ ${this.icon&&ie`<vmp-new-icon icon=${this.icon}></vmp-new-icon>`}
292
+ </button>`}};Ts.styles=[Le.styles??[],ki`
261
293
  :host {
262
294
  --button-color: var(--vu-button-color, var(--colors-dark-640));
263
295
  --button-background: var(--vu-button-background, var(--colors-light-1000));
@@ -333,37 +365,42 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
333
365
  .weight-light:focus {
334
366
  background: #9d9d9d;
335
367
  }
336
- `],Sn([Mt({type:Boolean})],bs.prototype,"active",2),Sn([Mt({type:String})],bs.prototype,"size",2),Sn([Mt({type:String})],bs.prototype,"rounded",2),Sn([Mt({type:String})],bs.prototype,"weight",2),Sn([Mt({type:String})],bs.prototype,"icon",2),bs=Sn([qi("vmp-new-button")],bs);const Lf={"arrow-left":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
368
+ `],xn([It({type:Boolean})],Ts.prototype,"active",2),xn([It({type:String})],Ts.prototype,"size",2),xn([It({type:String})],Ts.prototype,"rounded",2),xn([It({type:String})],Ts.prototype,"weight",2),xn([It({type:String})],Ts.prototype,"icon",2),Ts=xn([Oi("vmp-new-button")],Ts);const Mf={"arrow-left":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
337
369
  <path
338
370
  d="M16.6666 9.21875H6.52492L11.1833 4.85156L9.99992 3.75L3.33325 10L9.99992 16.25L11.1749 15.1484L6.52492 10.7812H16.6666V9.21875Z"
339
371
  fill="currentColor"
340
372
  />
341
- </svg>`,"arrow-right":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
373
+ </svg>`,"arrow-right":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
342
374
  <path
343
375
  d="M3.75 9.21875H13.2578L8.89062 4.85156L10 3.75L16.25 10L10 16.25L8.89844 15.1484L13.2578 10.7812H3.75V9.21875Z"
344
376
  fill="currentColor"
345
377
  />
346
- </svg>`,"captions-cross":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
378
+ </svg>`,"captions-cross":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
347
379
  <path
348
380
  d="M17.0625 19.4167L14.3125 16.6667H3.33333C2.875 16.6667 2.4825 16.5036 2.15583 16.1775C1.82972 15.8509 1.66667 15.4584 1.66667 15V4.16669C1.66667 4.13891 1.66667 4.11446 1.66667 4.09335C1.66667 4.0728 1.66667 4.04863 1.66667 4.02085L0.5625 2.91669L1.75 1.72919L18.25 18.2292L17.0625 19.4167ZM18.3333 15.9375L14.7083 12.3125C14.8056 12.2431 14.8786 12.1495 14.9275 12.0317C14.9758 11.9134 15 11.7917 15 11.6667V10.8334H13.75V11.25H13.6458L12.0833 9.68752V8.75002H13.75V9.16669H15V8.33335C15 8.09724 14.92 7.89919 14.76 7.73919C14.6006 7.57974 14.4028 7.50002 14.1667 7.50002H11.6667C11.4306 7.50002 11.2328 7.57974 11.0733 7.73919C10.9133 7.89919 10.8333 8.09724 10.8333 8.33335V8.43752L5.72917 3.33335H16.6667C17.125 3.33335 17.5175 3.49669 17.8442 3.82335C18.1703 4.14946 18.3333 4.54169 18.3333 5.00002V15.9375ZM5.83333 12.5H8.33333C8.56944 12.5 8.7675 12.42 8.9275 12.26C9.08694 12.1006 9.16667 11.9028 9.16667 11.6667V11.5209L8.47917 10.8334H7.91667V11.25H6.25V8.60419L5.3125 7.66669C5.21528 7.73613 5.13889 7.82974 5.08333 7.94752C5.02778 8.06585 5 8.19446 5 8.33335V11.6667C5 11.9028 5.07972 12.1006 5.23917 12.26C5.39917 12.42 5.59722 12.5 5.83333 12.5Z"
349
381
  fill="currentColor"
350
382
  />
351
- </svg>`,captions:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
383
+ </svg>`,captions:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
352
384
  <path
353
385
  d="M5.83342 12.5H8.33342C8.56953 12.5 8.76758 12.42 8.92758 12.26C9.08703 12.1005 9.16675 11.9028 9.16675 11.6666V10.8333H7.91675V11.25H6.25008V8.74998H7.91675V9.16665H9.16675V8.33331C9.16675 8.0972 9.08703 7.89915 8.92758 7.73915C8.76758 7.5797 8.56953 7.49998 8.33342 7.49998H5.83342C5.5973 7.49998 5.39925 7.5797 5.23925 7.73915C5.0798 7.89915 5.00008 8.0972 5.00008 8.33331V11.6666C5.00008 11.9028 5.0798 12.1005 5.23925 12.26C5.39925 12.42 5.5973 12.5 5.83342 12.5ZM11.6667 12.5H14.1667C14.4029 12.5 14.6006 12.42 14.7601 12.26C14.9201 12.1005 15.0001 11.9028 15.0001 11.6666V10.8333H13.7501V11.25H12.0834V8.74998H13.7501V9.16665H15.0001V8.33331C15.0001 8.0972 14.9201 7.89915 14.7601 7.73915C14.6006 7.5797 14.4029 7.49998 14.1667 7.49998H11.6667C11.4306 7.49998 11.2329 7.5797 11.0734 7.73915C10.9134 7.89915 10.8334 8.0972 10.8334 8.33331V11.6666C10.8334 11.9028 10.9134 12.1005 11.0734 12.26C11.2329 12.42 11.4306 12.5 11.6667 12.5ZM3.33341 16.6666C2.87508 16.6666 2.48258 16.5036 2.15591 16.1775C1.8298 15.8508 1.66675 15.4583 1.66675 15V4.99998C1.66675 4.54165 1.8298 4.14942 2.15591 3.82331C2.48258 3.49665 2.87508 3.33331 3.33341 3.33331H16.6667C17.1251 3.33331 17.5176 3.49665 17.8442 3.82331C18.1704 4.14942 18.3334 4.54165 18.3334 4.99998V15C18.3334 15.4583 18.1704 15.8508 17.8442 16.1775C17.5176 16.5036 17.1251 16.6666 16.6667 16.6666H3.33341Z"
354
386
  fill="currentColor"
355
387
  />
356
- </svg>`,"chevron-down":()=>ne`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
388
+ </svg>`,"chevron-down":()=>ie`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
357
389
  <path
358
390
  d="M11.8032 7.13666L10.8632 6.19666L7.80322 9.24999L4.74322 6.19666L3.80322 7.13666L7.80322 11.1367L11.8032 7.13666Z"
359
391
  fill="currentColor"
360
392
  />
361
- </svg>`,close:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
393
+ </svg>`,close:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
362
394
  <path
363
395
  d="M15.8334 5.34163L14.6584 4.16663L10 8.82496L5.34169 4.16663L4.16669 5.34163L8.82502 9.99996L4.16669 14.6583L5.34169 15.8333L10 11.175L14.6584 15.8333L15.8334 14.6583L11.175 9.99996L15.8334 5.34163Z"
364
396
  fill="currentColor"
365
397
  />
366
- </svg>`,loading:()=>ne`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
398
+ </svg>`,error:()=>ie`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
399
+ <path
400
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z"
401
+ fill="currentColor"
402
+ />
403
+ </svg>`,loading:()=>ie`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
367
404
  <style>
368
405
  /* SVG spinner icon animation */
369
406
  .spinner {
@@ -423,62 +460,62 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
423
460
  }
424
461
  </style>
425
462
  <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5" />
426
- </svg>`,maximize:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
463
+ </svg>`,maximize:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
427
464
  <path
428
465
  fill-rule="evenodd"
429
466
  clip-rule="evenodd"
430
467
  d="M6.66675 3.33331H3.33341H1.66675V4.99998V8.33331H3.33341V4.99998H6.66675V3.33331ZM6.66675 15H3.33341V11.6666H1.66675V15V16.6666H3.33341H6.66675V15ZM13.3334 3.33331H16.6667H18.3334V4.99998V8.33331H16.6667V4.99998H13.3334V3.33331ZM16.6667 15H13.3334V16.6666H16.6667H18.3334V15V11.6666H16.6667V15Z"
431
468
  fill="currentColor"
432
469
  />
433
- </svg>`,minimize:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
470
+ </svg>`,minimize:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
434
471
  <path
435
472
  fill-rule="evenodd"
436
473
  clip-rule="evenodd"
437
474
  d="M5.00008 3.33331H6.66675V6.66665V8.33331H5.00008H1.66675V6.66665H5.00008V3.33331ZM5.00008 11.6666H1.66675V13.3333H5.00008V16.6666H6.66675V13.3333V11.6666H5.00008ZM15.0001 6.66665H18.3334V8.33331H15.0001H13.3334V6.66665V3.33331H15.0001V6.66665ZM18.3334 11.6666H15.0001H13.3334V13.3333V16.6666H15.0001V13.3333H18.3334V11.6666Z"
438
475
  fill="currentColor"
439
476
  />
440
- </svg>`,muted:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
477
+ </svg>`,muted:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
441
478
  <path
442
479
  d="M13.75 10C13.75 8.525 12.9 7.25833 11.6667 6.64167V8.48333L13.7083 10.525C13.7333 10.3583 13.75 10.1833 13.75 10ZM15.8333 10C15.8333 10.7833 15.6667 11.5167 15.3833 12.2L16.6417 13.4583C17.1917 12.425 17.5 11.25 17.5 10C17.5 6.43333 15.0083 3.45 11.6667 2.69167V4.40833C14.075 5.125 15.8333 7.35833 15.8333 10ZM3.55833 2.5L2.5 3.55833L6.44167 7.5H2.5V12.5H5.83333L10 16.6667V11.0583L13.5417 14.6C12.9833 15.0333 12.3583 15.375 11.6667 15.5833V17.3C12.8167 17.0417 13.8583 16.5083 14.7417 15.7917L16.4417 17.5L17.5 16.4417L10 8.94167L3.55833 2.5ZM10 3.33333L8.25833 5.075L10 6.81667V3.33333Z"
443
480
  fill="currentColor"
444
481
  />
445
- </svg>`,pause:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
482
+ </svg>`,pause:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
446
483
  <path
447
484
  fill-rule="evenodd"
448
485
  clip-rule="evenodd"
449
486
  d="M8.33333 2.5H5V17.5H8.33333V2.5ZM15 2.5H11.6667V17.5H15V2.5Z"
450
487
  fill="currentColor"
451
488
  />
452
- </svg>`,"play-large":()=>ne`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
489
+ </svg>`,"play-large":()=>ie`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
453
490
  <path
454
491
  d="M43.5 23.8319C45.5 25.0083 45.5 27.9492 43.5 29.1256L4.5 52.0647C2.5 53.2411 0 51.7706 0 49.4179V3.53961C0 1.18687 2.5 -0.283582 4.5 0.892785L43.5 23.8319Z"
455
492
  fill="currentColor"
456
493
  />
457
- </svg>`,play:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
494
+ </svg>`,play:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
458
495
  <path d="M17.3803 9.99998L5.83325 16.6666V3.33331L17.3803 9.99998Z" fill="currentColor" />
459
- </svg>`,settings:()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
496
+ </svg>`,settings:()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
460
497
  <path
461
498
  d="M7.70833 18.3334L7.375 15.6667C7.19445 15.5972 7.02444 15.5139 6.865 15.4167C6.705 15.3195 6.54861 15.2153 6.39583 15.1042L3.91667 16.1459L1.625 12.1875L3.77083 10.5625C3.75694 10.4653 3.75 10.3714 3.75 10.2809C3.75 10.1909 3.75 10.0972 3.75 10C3.75 9.9028 3.75 9.80891 3.75 9.71835C3.75 9.62835 3.75694 9.53474 3.77083 9.43752L1.625 7.81252L3.91667 3.85419L6.39583 4.89585C6.54861 4.78474 6.70833 4.68058 6.875 4.58335C7.04167 4.48613 7.20833 4.4028 7.375 4.33335L7.70833 1.66669H12.2917L12.625 4.33335C12.8056 4.4028 12.9758 4.48613 13.1358 4.58335C13.2953 4.68058 13.4514 4.78474 13.6042 4.89585L16.0833 3.85419L18.375 7.81252L16.2292 9.43752C16.2431 9.53474 16.25 9.62835 16.25 9.71835C16.25 9.80891 16.25 9.9028 16.25 10C16.25 10.0972 16.25 10.1909 16.25 10.2809C16.25 10.3714 16.2361 10.4653 16.2083 10.5625L18.3542 12.1875L16.0625 16.1459L13.6042 15.1042C13.4514 15.2153 13.2917 15.3195 13.125 15.4167C12.9583 15.5139 12.7917 15.5972 12.625 15.6667L12.2917 18.3334H7.70833ZM10.0417 12.9167C10.8472 12.9167 11.5347 12.632 12.1042 12.0625C12.6736 11.4931 12.9583 10.8056 12.9583 10C12.9583 9.19447 12.6736 8.50696 12.1042 7.93752C11.5347 7.36808 10.8472 7.08335 10.0417 7.08335C9.22222 7.08335 8.53111 7.36808 7.96833 7.93752C7.40611 8.50696 7.125 9.19447 7.125 10C7.125 10.8056 7.40611 11.4931 7.96833 12.0625C8.53111 12.632 9.22222 12.9167 10.0417 12.9167ZM10.0417 11.25C9.69445 11.25 9.39945 11.1284 9.15667 10.885C8.91333 10.6422 8.79167 10.3472 8.79167 10C8.79167 9.6528 8.91333 9.3578 9.15667 9.11502C9.39945 8.87169 9.69445 8.75002 10.0417 8.75002C10.3889 8.75002 10.6842 8.87169 10.9275 9.11502C11.1703 9.3578 11.2917 9.6528 11.2917 10C11.2917 10.3472 11.1703 10.6422 10.9275 10.885C10.6842 11.1284 10.3889 11.25 10.0417 11.25ZM9.16667 16.6667H10.8125L11.1042 14.4584C11.5347 14.3472 11.9342 14.1839 12.3025 13.9684C12.6703 13.7534 13.0069 13.4931 13.3125 13.1875L15.375 14.0417L16.1875 12.625L14.3958 11.2709C14.4653 11.0764 14.5139 10.8714 14.5417 10.6559C14.5694 10.4409 14.5833 10.2222 14.5833 10C14.5833 9.7778 14.5694 9.55891 14.5417 9.34335C14.5139 9.12835 14.4653 8.92363 14.3958 8.72919L16.1875 7.37502L15.375 5.95835L13.3125 6.83335C13.0069 6.51391 12.6703 6.24641 12.3025 6.03085C11.9342 5.81585 11.5347 5.6528 11.1042 5.54169L10.8333 3.33335H9.1875L8.89583 5.54169C8.46528 5.6528 8.06611 5.81585 7.69833 6.03085C7.33 6.24641 6.99306 6.50697 6.6875 6.81252L4.625 5.95835L3.8125 7.37502L5.60417 8.70835C5.53472 8.91669 5.48611 9.12502 5.45833 9.33335C5.43056 9.54169 5.41667 9.76391 5.41667 10C5.41667 10.2222 5.43056 10.4375 5.45833 10.6459C5.48611 10.8542 5.53472 11.0625 5.60417 11.2709L3.8125 12.625L4.625 14.0417L6.6875 13.1667C6.99306 13.4861 7.33 13.7534 7.69833 13.9684C8.06611 14.1839 8.46528 14.3472 8.89583 14.4584L9.16667 16.6667Z"
462
499
  fill="currentColor"
463
500
  />
464
- </svg>`,tick:()=>ne`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
501
+ </svg>`,tick:()=>ie`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
465
502
  <path
466
503
  d="M7.50016 14.0001L4.00016 10.5001L2.8335 11.6667L7.50016 16.3334L17.5002 6.33341L16.3335 5.16675L7.50016 14.0001Z"
467
504
  fill="currentColor"
468
505
  />
469
- </svg>`,"volume-high":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
506
+ </svg>`,"volume-high":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
470
507
  <path
471
508
  d="M2.5 7.49998V12.5H5.83333L10 16.6667V3.33332L5.83333 7.49998H2.5ZM13.75 9.99998C13.75 8.52498 12.9 7.25832 11.6667 6.64165V13.35C12.9 12.7417 13.75 11.475 13.75 9.99998ZM11.6667 2.69165V4.40832C14.075 5.12498 15.8333 7.35832 15.8333 9.99998C15.8333 12.6417 14.075 14.875 11.6667 15.5917V17.3083C15.0083 16.55 17.5 13.5667 17.5 9.99998C17.5 6.43332 15.0083 3.44998 11.6667 2.69165Z"
472
509
  fill="currentColor"
473
510
  />
474
- </svg>`,"volume-low":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
511
+ </svg>`,"volume-low":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
475
512
  <path d="M5.83325 7.49998V12.5H9.16658L13.3333 16.6666V3.33331L9.16658 7.49998H5.83325Z" fill="currentColor" />
476
- </svg>`,"volume-medium":()=>ne`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
513
+ </svg>`,"volume-medium":()=>ie`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
477
514
  <path
478
515
  d="M15.4167 9.99998C15.4167 8.52498 14.5667 7.25831 13.3334 6.64165V13.35C14.5667 12.7416 15.4167 11.475 15.4167 9.99998ZM4.16675 7.49998V12.5H7.50008L11.6667 16.6666V3.33331L7.50008 7.49998H4.16675Z"
479
516
  fill="currentColor"
480
517
  />
481
- </svg>`,vouch:()=>ne`<svg
518
+ </svg>`,vouch:()=>ie`<svg
482
519
  xmlns="http://www.w3.org/2000/svg"
483
520
  height="28"
484
521
  width="105"
@@ -489,26 +526,26 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
489
526
  <path
490
527
  d="M9.853 23.246L4.86 7.688H0L7 27.42h5.52l7.265-19.733h-4.65L9.854 23.246zM95.12 7.08a8.905 8.905 0 00-4.648 1.294V0H86.14v27.419h4.332V16.087a4.656 4.656 0 014.649-4.65 4.656 4.656 0 014.649 4.65v11.332h4.332V16.087c.026-4.966-4.015-9.008-8.981-9.008zM57.188 19.02a4.656 4.656 0 01-4.649 4.649 4.656 4.656 0 01-4.649-4.65V7.689h-4.332V19.02c0 4.966 4.041 8.98 8.981 8.98 4.94 0 8.981-4.04 8.981-8.98V7.688h-4.332V19.02zM30.483 7.133c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408c5.732 0 10.408-4.676 10.408-10.408 0-5.732-4.676-10.407-10.408-10.407zm0 16.483a6.076 6.076 0 116.075-6.076c0 3.355-2.747 6.076-6.075 6.076zM74.517 23.616a6.076 6.076 0 010-12.151 6.132 6.132 0 015.045 2.668l3.592-2.43a10.473 10.473 0 00-8.637-4.57c-5.732 0-10.408 4.675-10.408 10.407s4.676 10.408 10.408 10.408a10.35 10.35 0 008.611-4.596l-3.593-2.43a5.975 5.975 0 01-5.018 2.694z"
491
528
  />
492
- </svg>`};var m4=Object.defineProperty,v4=Object.getOwnPropertyDescriptor,Rf=(n,t,e,i)=>{for(var s=i>1?void 0:i?v4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&m4(t,e,s),s};let Mo=class extends Oe{render(){return!this.icon||!Object.keys(Lf).includes(this.icon)?null:Lf[this.icon]()}};Mo.styles=[Oe.styles??[],Ii`
529
+ </svg>`};var C4=Object.defineProperty,I4=Object.getOwnPropertyDescriptor,$f=(n,t,e,i)=>{for(var s=i>1?void 0:i?I4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&C4(t,e,s),s};let Bo=class extends Le{render(){return!this.icon||!Object.keys(Mf).includes(this.icon)?null:Mf[this.icon]()}};Bo.styles=[Le.styles??[],ki`
493
530
  :host {
494
531
  display: flex;
495
532
  align-items: center;
496
533
  justify-content: center;
497
534
  flex-shrink: 0;
498
535
  }
499
- `],Rf([Mt({type:String})],Mo.prototype,"icon",2),Mo=Rf([qi("vmp-new-icon")],Mo);var y4=Object.defineProperty,b4=Object.getOwnPropertyDescriptor,Ln=(n,t,e,i)=>{for(var s=i>1?void 0:i?b4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&y4(t,e,s),s};let As=class extends Oe{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ne`
536
+ `],$f([It({type:String})],Bo.prototype,"icon",2),Bo=$f([Oi("vmp-new-icon")],Bo);var D4=Object.defineProperty,x4=Object.getOwnPropertyDescriptor,Pn=(n,t,e,i)=>{for(var s=i>1?void 0:i?x4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&D4(t,e,s),s};let ws=class extends Le{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return ie`
500
537
  <vmp-new-button
501
538
  ?active=${this.active}
502
- size=${Ws(this.size)}
503
- rounded=${Ws(this.rounded)}
504
- weight=${Ws(this.weight)}
539
+ size=${zs(this.size)}
540
+ rounded=${zs(this.rounded)}
541
+ weight=${zs(this.weight)}
505
542
  >
506
543
  <vmp-new-icon
507
- class=${je({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
508
- icon=${Ws(this.icon)}
544
+ class=${Ye({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
545
+ icon=${zs(this.icon)}
509
546
  ></vmp-new-icon>
510
547
  </vmp-new-button>
511
- `}};As.styles=[Oe.styles??[],Ii`
548
+ `}};ws.styles=[Le.styles??[],ki`
512
549
  .tiny::part(svg) {
513
550
  height: 12px;
514
551
  width: 12px;
@@ -523,15 +560,63 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
523
560
  height: 32px;
524
561
  width: 32px;
525
562
  }
526
- `],Ln([Mt({type:Boolean})],As.prototype,"active",2),Ln([Mt({type:String})],As.prototype,"size",2),Ln([Mt({type:String})],As.prototype,"rounded",2),Ln([Mt({type:String})],As.prototype,"weight",2),Ln([Mt({type:String})],As.prototype,"icon",2),As=Ln([qi("vmp-new-icon-button")],As);const jc=`.tippy-box[data-animation=shift-away-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=top]{transform:translateY(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=bottom]{transform:translateY(-5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=left]{transform:translate(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translate(-5px)}
527
- `;var A4=Object.defineProperty,E4=Object.getOwnPropertyDescriptor,wa=(n,t,e,i)=>{for(var s=i>1?void 0:i?E4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&A4(t,e,s),s};let sn=class extends Oe{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return ne`
563
+ `],Pn([It({type:Boolean})],ws.prototype,"active",2),Pn([It({type:String})],ws.prototype,"size",2),Pn([It({type:String})],ws.prototype,"rounded",2),Pn([It({type:String})],ws.prototype,"weight",2),Pn([It({type:String})],ws.prototype,"icon",2),ws=Pn([Oi("vmp-new-icon-button")],ws);var P4=Object.defineProperty,O4=Object.getOwnPropertyDescriptor,Yi=(n,t,e,i)=>{for(var s=i>1?void 0:i?O4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&P4(t,e,s),s};let is=class extends Le{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=xl,this._currentTime=0,this._sceneController=new R4(this),this._canvasRef=wi(),this._previewRef=wi(),this._previewTimeRef=wi(),this._handleScrubberMouseEnter=({detail:{x:n,y:t,elementLeft:e,elementRight:i}})=>{var s;if((s=this._previewRef)!=null&&s.value){const o=window.scrollY,c=window.scrollX,d=this._previewRef.value.getBoundingClientRect();d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Of(e,n+c-d.width/2,i-d.width)}px, ${t+o-d.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:n,x:t,elementLeft:e,elementRight:i}})=>{var s,o,c,d,f,p;if(this._currentTime=n,(s=this._sceneController.scenes)!=null&&s.scenes.length){const g=(f=(d=(c=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:c.find(({start:v,duration:b,video:E})=>E&&n>=v&&n<=v+b))==null?void 0:d.video)==null?void 0:f.node;if(g&&(g.currentTime=n),this._draw(),(p=this._previewRef)!=null&&p.value){const v=window.scrollX,b=this._previewRef.value.getBoundingClientRect();if(b){const E=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0)",[,k]=Array.from(E.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Of(e,t+v-b.width/2,i-b.width)}px, ${k[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",th(this._currentTime,{includeMs:!0}))}},this._handleScrubberMouseLeave=()=>{var n;(n=this._previewRef)!=null&&n.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:n}})=>{var t;if((t=this._previewRef)!=null&&t.value){const e=this._previewRef.value.getBoundingClientRect();if(e){const i=window.scrollY,s=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0)",[o]=Array.from(s.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${o[1]}px, ${n+i-e.height-28}px, 0)`}}}}_draw(n=this._currentTime){var t;this._sceneController.scenes&&this._canvasRef.value&&((t=this.compilation)==null||t.call(this,{currentTime:n,scenes:this._sceneController.scenes,canvas:this._canvasRef.value}))}connectedCallback(){super.connectedCallback(),document.addEventListener("scrubber:resize",this._handleScrubberResize),document.addEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.addEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.addEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("scrubber:resize",this._handleScrubberResize),document.removeEventListener("scrubber:mouseenter",this._handleScrubberMouseEnter),document.removeEventListener("scrubber:mousemove",this._handleScrubberMouseMove),document.removeEventListener("scrubber:mouseleave",this._handleScrubberMouseLeave)}render(){var n;const{height:t,width:e}=Pl({resolution:180,aspectRatio:this.aspectRatio}),i=((n=this._sceneController.scenes)==null?void 0:n.scenes.length)??0;return!this.disabled&&i>1?ie`
564
+ <div
565
+ ${Si(this._previewRef)}
566
+ class="preview"
567
+ style=${om({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
568
+ >
569
+ <canvas ${Si(this._canvasRef)} class="preview-canvas" width=${e} height=${t}></canvas>
570
+ <vmp-new-text ${Si(this._previewTimeRef)} class="preview-text"></vmp-new-text>
571
+ </div>
572
+ `:null}};is.styles=[Le.styles??[],ki`
573
+ .preview {
574
+ position: absolute;
575
+ display: flex;
576
+ top: 0;
577
+ left: 0;
578
+ align-items: center;
579
+ flex-direction: column;
580
+ opacity: 0;
581
+ // Always on top
582
+ z-index: 2147483647;
583
+ pointer-events: none;
584
+ border: 3px solid var(--colors-light-1000);
585
+ background: var(--colors-dark-1000);
586
+ border-radius: var(--radii-medium);
587
+ transition: opacity 150ms ease-out;
588
+ }
589
+
590
+ .preview-canvas {
591
+ width: 100%;
592
+ height: 100%;
593
+ border-radius: var(--radii-small);
594
+ }
595
+
596
+ .preview-text {
597
+ position: absolute;
598
+ bottom: 0;
599
+ transform: translate3d(0, calc(100% + 5px), 0);
600
+ color: var(--colors-light-1000);
601
+ }
602
+ `],Yi([It({type:String})],is.prototype,"src",2),Yi([It({type:Object})],is.prototype,"data",2),Yi([It({type:Object})],is.prototype,"template",2),Yi([It({type:Boolean})],is.prototype,"disabled",2),Yi([It({type:Number})],is.prototype,"aspectRatio",2),Yi([It({attribute:!1})],is.prototype,"compilation",2),is=Yi([Oi("vmp-new-video-preview-content")],is);let Ss=class extends Le{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=xl}render(){return ie`
603
+ <vmp-new-video-preview-content
604
+ ?disabled=${this.disabled}
605
+ .src=${this.src}
606
+ .data=${this.data}
607
+ .template=${this.template}
608
+ .aspectRatio=${this.aspectRatio}
609
+ .compilation=${this.compilation}
610
+ ></vmp-new-video-preview-content>
611
+ `}};Yi([It({type:String})],Ss.prototype,"src",2),Yi([It({type:Object})],Ss.prototype,"data",2),Yi([It({type:Object})],Ss.prototype,"template",2),Yi([It({type:Boolean})],Ss.prototype,"disabled",2),Yi([It({type:Number})],Ss.prototype,"aspectRatio",2),Yi([It({attribute:!1})],Ss.prototype,"compilation",2),Ss=Yi([Oi("vmp-new-video-preview")],Ss);class M4 extends na{constructor(t){if(super(t),t.type!==bn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),gs}}const Ff=An(M4);class $4{constructor(t){this.hiddenControls=[],this._measureRef=wi(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,s,o;const c=this._measureRef.value,d=(o=(s=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:s[0])==null?void 0:o.inlineSize;if(c&&d&&d!==this._prevControlsWidth){Object.keys(this._hideables).forEach(p=>{this._hideables[p].element.style.display=""}),Object.keys(this._showables).forEach(p=>{this._showables[p].element.style.display="none"});const f=[];for(;c.scrollWidth>c.offsetWidth;){const p=Object.keys(this._hideables).find(g=>this._hideables[g].hideIndex===f.length);if(p){const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p)}Object.keys(this._showables).forEach(g=>{this._showables[g].showOn.some(v=>f.includes(v))&&(this._showables[g].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Si(this._measureRef)}contain(){return Uo(this._onResize)}hide(t,e){return Ff(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return Ff(i=>{this._showables[t]={element:i,showOn:e}})}}const eh=`.tippy-box[data-animation=shift-away-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=top]{transform:translateY(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=bottom]{transform:translateY(-5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=left]{transform:translate(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translate(-5px)}
612
+ `;var F4=Object.defineProperty,N4=Object.getOwnPropertyDescriptor,Ia=(n,t,e,i)=>{for(var s=i>1?void 0:i?N4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&F4(t,e,s),s};let hn=class extends Le{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return ie`
528
613
  <div
529
614
  part="content"
530
- class=${je({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
615
+ class=${Ye({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
531
616
  >
532
617
  ${this.content}
533
618
  </div>
534
- `}};sn.styles=[Oe.styles??[],Ii`
619
+ `}};hn.styles=[Le.styles??[],ki`
535
620
  :host {
536
621
  --text-size: var(--fontSizes-medium);
537
622
  --text-line-height: var(--lineHeights-medium);
@@ -569,11 +654,11 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
569
654
  text-overflow: ellipsis;
570
655
  overflow: hidden;
571
656
  }
572
- `],wa([Mt({type:Boolean})],sn.prototype,"semibold",2),wa([Mt({type:Boolean})],sn.prototype,"truncate",2),wa([Mt({type:String})],sn.prototype,"size",2),wa([Mt({type:String})],sn.prototype,"content",2),sn=wa([qi("vmp-new-text")],sn);var T4=Object.defineProperty,k4=Object.getOwnPropertyDescriptor,Sa=(n,t,e,i)=>{for(var s=i>1?void 0:i?k4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&T4(t,e,s),s};let nn=class extends Oe{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=rr()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var n,t;const e=(t=(n=this.items)==null?void 0:n.items.find(({id:i})=>this.subItemsActive===i))==null?void 0:t.subItems;this.visibleItems=e??this.items??null,e||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=Qs(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",trigger:"click",onShow:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){var n,t;return ne`
657
+ `],Ia([It({type:Boolean})],hn.prototype,"semibold",2),Ia([It({type:Boolean})],hn.prototype,"truncate",2),Ia([It({type:String})],hn.prototype,"size",2),Ia([It({type:String})],hn.prototype,"content",2),hn=Ia([Oi("vmp-new-text")],hn);var U4=Object.defineProperty,B4=Object.getOwnPropertyDescriptor,Da=(n,t,e,i)=>{for(var s=i>1?void 0:i?B4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&U4(t,e,s),s};let dn=class extends Le{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=wi()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var n,t;const e=(t=(n=this.items)==null?void 0:n.items.find(({id:i})=>this.subItemsActive===i))==null?void 0:t.subItems;this.visibleItems=e??this.items??null,e||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=sn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",trigger:"click",onShow:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){var n,t;return ie`
573
658
  <slot></slot>
574
- <div ${sr(this._contentRef)} class="content">
659
+ <div ${Si(this._contentRef)} class="content">
575
660
  <div class="title">
576
- ${this.subItemsActive?ne`
661
+ ${this.subItemsActive?ie`
577
662
  <button class="back" @click=${this._handleBackClick}>
578
663
  <vmp-new-icon icon="chevron-down"></vmp-new-icon>
579
664
  </button>
@@ -585,17 +670,17 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
585
670
  .content=${((n=this.visibleItems)==null?void 0:n.title)??"Sub Menu"}
586
671
  ></vmp-new-text>
587
672
  </div>
588
- ${jd(((t=this.visibleItems)==null?void 0:t.items)??[],({id:e})=>e,e=>ne`
673
+ ${tu(((t=this.visibleItems)==null?void 0:t.items)??[],({id:e})=>e,e=>ie`
589
674
  <button
590
675
  class="item"
591
676
  @click=${()=>{e.subItems&&(this.subItemsActive=e.id,this.visibleItems=e.subItems),e.event&&this.dispatchEvent(new CustomEvent(e.event,{detail:e,bubbles:!0,composed:!0}))}}
592
677
  >
593
678
  <vmp-new-text ?semibold=${!0} size="small" content=${e.label}></vmp-new-text>
594
- ${e.subItems?ne`<vmp-new-icon class="forward" icon="chevron-down"></vmp-new-icon>`:this.activeItems.includes(e.id)?ne`<vmp-new-icon icon="tick"></vmp-new-icon>`:null}
679
+ ${e.subItems?ie`<vmp-new-icon class="forward" icon="chevron-down"></vmp-new-icon>`:this.activeItems.includes(e.id)?ie`<vmp-new-icon icon="tick"></vmp-new-icon>`:null}
595
680
  </button>
596
681
  `)}
597
682
  </div>
598
- `}};nn.styles=[Oe.styles??[],Wn(jc),Ii`
683
+ `}};dn.styles=[Le.styles??[],qn(eh),ki`
599
684
  :host {
600
685
  display: flex;
601
686
  }
@@ -653,12 +738,12 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
653
738
  height: 20px;
654
739
  width: 20px;
655
740
  }
656
- `],Sa([Mt({type:Object})],nn.prototype,"items",2),Sa([Mt({type:Array})],nn.prototype,"activeItems",2),Sa([Di()],nn.prototype,"visibleItems",2),Sa([Di()],nn.prototype,"subItemsActive",2),nn=Sa([qi("vmp-new-menu")],nn);var w4=Object.defineProperty,S4=Object.getOwnPropertyDescriptor,zc=(n,t,e,i)=>{for(var s=i>1?void 0:i?S4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&w4(t,e,s),s};let La=class extends Oe{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=rr()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=Qs(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}updated(){var n,t;this.disabled?(n=this.tippy)==null||n.disable():(t=this.tippy)==null||t.enable()}render(){return ne`
741
+ `],Da([It({type:Object})],dn.prototype,"items",2),Da([It({type:Array})],dn.prototype,"activeItems",2),Da([Ti()],dn.prototype,"visibleItems",2),Da([Ti()],dn.prototype,"subItemsActive",2),dn=Da([Oi("vmp-new-menu")],dn);var G4=Object.defineProperty,V4=Object.getOwnPropertyDescriptor,ih=(n,t,e,i)=>{for(var s=i>1?void 0:i?V4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&G4(t,e,s),s};let xa=class extends Le{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wi()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=sn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}updated(){var n,t;this.disabled?(n=this.tippy)==null||n.disable():(t=this.tippy)==null||t.enable()}render(){return ie`
657
742
  <slot></slot>
658
- <div ${sr(this._contentRef)} class="content">
743
+ <div ${Si(this._contentRef)} class="content">
659
744
  <vmp-new-text content=${this.content}></vmp-new-text>
660
745
  </div>
661
- `}};La.styles=[Oe.styles??[],Wn(jc),Ii`
746
+ `}};xa.styles=[Le.styles??[],qn(eh),ki`
662
747
  :host {
663
748
  display: flex;
664
749
  }
@@ -672,19 +757,19 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
672
757
  background: var(--colors-dark-800);
673
758
  border-radius: var(--radii-medium);
674
759
  }
675
- `],zc([Mt({type:String})],La.prototype,"content",2),zc([Mt({type:Boolean})],La.prototype,"disabled",2),La=zc([qi("vmp-new-tooltip")],La);var L4=Object.defineProperty,R4=Object.getOwnPropertyDescriptor,Yc=(n,t,e,i)=>{for(var s=i>1?void 0:i?R4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&L4(t,e,s),s};let Ra=class extends Oe{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=rr(),this._anchorRef=rr(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=Qs(this._anchorRef.value,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",interactiveBorder:20,onShow:()=>{this._menuOpen=!0,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this._menuOpen=!1,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){return ne`
760
+ `],ih([It({type:String})],xa.prototype,"content",2),ih([It({type:Boolean})],xa.prototype,"disabled",2),xa=ih([Oi("vmp-new-tooltip")],xa);var H4=Object.defineProperty,W4=Object.getOwnPropertyDescriptor,rh=(n,t,e,i)=>{for(var s=i>1?void 0:i?W4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&H4(t,e,s),s};let Pa=class extends Le{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=wi(),this._anchorRef=wi(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=sn(this._anchorRef.value,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!0,placement:"top",interactiveBorder:20,onShow:()=>{this._menuOpen=!0,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!0}))},onHide:()=>{this._menuOpen=!1,this.dispatchEvent(new CustomEvent("menu:toggle",{detail:!1}))},appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}render(){return ie`
676
761
  <vmp-new-icon-button
677
- ${sr(this._anchorRef)}
762
+ ${Si(this._anchorRef)}
678
763
  icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
679
764
  weight="heavy"
680
765
  rounded="full"
681
766
  @pointerdown=${n=>{this._menuOpen&&n.preventDefault()}}
682
767
  @click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
683
768
  ></vmp-new-icon-button>
684
- <div ${sr(this._contentRef)} class="content">
769
+ <div ${Si(this._contentRef)} class="content">
685
770
  <input key="volume" type="range" min="0" max="1" step="0.01" .value=${this.volume.toString()} />
686
771
  </div>
687
- `}};Ra.styles=[Oe.styles??[],Wn(jc),Ii`
772
+ `}};Pa.styles=[Le.styles??[],qn(eh),ki`
688
773
  .content {
689
774
  --volume-slider-height: 4px;
690
775
  --volume-slider-width: 78px;
@@ -812,8 +897,15 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
812
897
  --volume-slider-height: 8px;
813
898
  color: var(--colors-light-800);
814
899
  }
815
- `],Yc([Mt({type:Number})],Ra.prototype,"volume",2),Yc([Mt({type:Boolean})],Ra.prototype,"muted",2),Ra=Yc([qi("vmp-new-volume-button")],Ra);var _4=Object.defineProperty,C4=Object.getOwnPropertyDescriptor,$o=(n,t,e,i)=>{for(var s=i>1?void 0:i?C4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&_4(t,e,s),s};let Rn=class extends Oe{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[]}render(){var n;const t=((n=this.buffer)==null?void 0:n.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:s},o)=>{const c=e[o-1],d=Math.floor(i),f=Math.ceil(s);return e.push({id:i,start:Math.max(0,d),end:Math.min(f,100)}),c&&c.end>=i-1&&(e[o].start=c.end),e},[]))??[];return ne`
816
- <div class="container">
900
+ `],rh([It({type:Number})],Pa.prototype,"volume",2),rh([It({type:Boolean})],Pa.prototype,"muted",2),Pa=rh([Oi("vmp-new-volume-button")],Pa);var j4=Object.defineProperty,K4=Object.getOwnPropertyDescriptor,Go=(n,t,e,i)=>{for(var s=i>1?void 0:i?K4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&j4(t,e,s),s};let On=class extends Le{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=wi(),this._handleContainerResize=()=>{var n;const t=(n=this._containerRef.value)==null?void 0:n.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=n=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:n.clientX,y:n.clientY,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=n=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),i=(n.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:n.clientX,y:n.clientY,time:i*this.duration,elementLeft:(e==null?void 0:e.left)??0,elementRight:(e==null?void 0:e.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseLeave=n=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:n.clientX,y:n.clientY},bubbles:!0,composed:!0}))}}render(){var n;const t=((n=this.buffer)==null?void 0:n.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:s},o)=>{const c=e[o-1],d=Math.floor(i),f=Math.ceil(s);return e.push({id:i,start:Math.max(0,d),end:Math.min(f,100)}),c&&c.end>=i-1&&(e[o].start=c.end),e},[]))??[];return ie`
901
+ <div
902
+ class="container"
903
+ ${Si(this._containerRef)}
904
+ ${Uo(this._handleContainerResize)}
905
+ @mouseenter=${this._handleMouseEnter}
906
+ @mousemove=${this._handleMouseMove}
907
+ @mouseleave=${this._handleMouseLeave}
908
+ >
817
909
  <input
818
910
  key="scrubber"
819
911
  aria-label="Progress scrubber"
@@ -824,11 +916,11 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
824
916
  .value=${this.currentTime.toString()}
825
917
  data-testid="scrubber"
826
918
  />
827
- ${jd(t,({id:e})=>e,e=>ne`
919
+ ${tu(t,({id:e})=>e,e=>ie`
828
920
  <div class="buffer" style=${`left: ${e.start}%; width: ${e.end-e.start}%`}></div>
829
921
  `)}
830
922
  </div>
831
- `}};Rn.styles=[Oe.styles??[],Ii`
923
+ `}};On.styles=[Le.styles??[],ki`
832
924
  :host {
833
925
  --player-scrubber-height: 8px;
834
926
  --player-scrubber-shadow-width: 4000px;
@@ -961,17 +1053,17 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
961
1053
  --player-scrubber-height: 16px;
962
1054
  color: var(--colors-light-800);
963
1055
  }
964
- `],$o([Mt({type:Number})],Rn.prototype,"duration",2),$o([Mt({type:Number})],Rn.prototype,"currentTime",2),$o([Mt({type:Array})],Rn.prototype,"buffer",2),Rn=$o([qi("vmp-new-progress-scrubber")],Rn);var I4=Object.defineProperty,D4=Object.getOwnPropertyDescriptor,Ai=(n,t,e,i)=>{for(var s=i>1?void 0:i?D4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&I4(t,e,s),s};let ai=class extends Oe{constructor(){super(...arguments),this.resizeHider=new f4(this),this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.level=-1,this.playbackRate=1,this.buffer=[],this.levels=[],this.captions=!1,this.fullscreen=!1,this.controls=Wc,this.volumeMenuOpen=!1,this.levelsMenuOpen=!1,this.playbackRateMenuOpen=!1,this.settingsMenuOpen=!1}_handleNavigateBackClick(){this.dispatchEvent(new CustomEvent("navigate:back",{bubbles:!0,composed:!0}))}_handleNavigateForwardClick(){this.dispatchEvent(new CustomEvent("navigate:forward",{bubbles:!0,composed:!0}))}_handlePlayClick(){this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}_handleCaptionsClick(){this.dispatchEvent(new CustomEvent("captions:click",{bubbles:!0,composed:!0,detail:this.captions}))}_handleFullscreenClick(){this.dispatchEvent(new CustomEvent("fullscreen:click",{bubbles:!0,composed:!0,detail:this.fullscreen}))}_handleVolumeMenuToggle({detail:n}){this.volumeMenuOpen=n}_handleLevelsMenuOpen({detail:n}){this.levelsMenuOpen=n}_handlePlaybackMenuToggle({detail:n}){this.playbackRateMenuOpen=n}_handleSettingsMenuToggle({detail:n}){this.settingsMenuOpen=n}hideMenus(){var n,t;(t=Array.from((n=this.shadowRoot)==null?void 0:n.querySelectorAll("vmp-new-menu, vmp-new-tooltip, vmp-new-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var n,t,e,i,s,o,c,d,f,p,g,v,A;const T=((n=this.levels)==null?void 0:n.map((V,rt)=>{const Lt=Math.min(V.width,V.height);return{id:`level-${rt.toString()}`,event:"level:click",label:`${Lt}p`,value:{resolution:Lt,level:rt}}}))??[],E={title:"Quality",items:[...T.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:E},R=(t=E.items)==null?void 0:t.find(({value:V})=>V.level===this.level),x=["levels","playback-rate","captions","fullscreen"].filter(V=>{var rt;return(rt=this.controls)==null?void 0:rt.includes(V)}),M={title:"Settings",items:[r4,s4,w,n4].filter(({id:V})=>x.includes(V)&&this.resizeHider.hiddenControls.includes(V))},G=(e=this.controls)==null?void 0:e.includes("progress"),_=(i=this.controls)==null?void 0:i.includes("navigation"),F=(s=this.controls)==null?void 0:s.includes("play"),H=(o=this.controls)==null?void 0:o.includes("volume"),j=(c=this.controls)==null?void 0:c.includes("current-time"),nt=(d=this.controls)==null?void 0:d.includes("duration"),ot=(f=this.controls)==null?void 0:f.includes("levels"),tt=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),vt=(v=this.controls)==null?void 0:v.includes("fullscreen"),$t=F||H||j||nt||ot||tt||kt||vt,jt=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return ne`
1056
+ `],Go([It({type:Number})],On.prototype,"duration",2),Go([It({type:Number})],On.prototype,"currentTime",2),Go([It({type:Array})],On.prototype,"buffer",2),On=Go([Oi("vmp-new-progress-scrubber")],On);var Y4=Object.defineProperty,z4=Object.getOwnPropertyDescriptor,Ai=(n,t,e,i)=>{for(var s=i>1?void 0:i?z4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&Y4(t,e,s),s};let oi=class extends Le{constructor(){super(...arguments),this.resizeHider=new $4(this),this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.level=-1,this.playbackRate=1,this.buffer=[],this.levels=[],this.captions=!1,this.fullscreen=!1,this.controls=Jc,this.volumeMenuOpen=!1,this.levelsMenuOpen=!1,this.playbackRateMenuOpen=!1,this.settingsMenuOpen=!1}_handleNavigateBackClick(){this.dispatchEvent(new CustomEvent("navigate:back",{bubbles:!0,composed:!0}))}_handleNavigateForwardClick(){this.dispatchEvent(new CustomEvent("navigate:forward",{bubbles:!0,composed:!0}))}_handlePlayClick(){this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}_handleCaptionsClick(){this.dispatchEvent(new CustomEvent("captions:click",{bubbles:!0,composed:!0,detail:this.captions}))}_handleFullscreenClick(){this.dispatchEvent(new CustomEvent("fullscreen:click",{bubbles:!0,composed:!0,detail:this.fullscreen}))}_handleVolumeMenuToggle({detail:n}){this.volumeMenuOpen=n}_handleLevelsMenuOpen({detail:n}){this.levelsMenuOpen=n}_handlePlaybackMenuToggle({detail:n}){this.playbackRateMenuOpen=n}_handleSettingsMenuToggle({detail:n}){this.settingsMenuOpen=n}hideMenus(){var n,t;(t=Array.from((n=this.shadowRoot)==null?void 0:n.querySelectorAll("vmp-new-menu, vmp-new-tooltip, vmp-new-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var n,t,e,i,s,o,c,d,f,p,g,v,b;const E=((n=this.levels)==null?void 0:n.map((V,J)=>{const St=Math.min(V.width,V.height);return{id:`level-${J.toString()}`,event:"level:click",label:`${St}p`,value:{resolution:St,level:J}}}))??[],k={title:"Quality",items:[...E.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:k},L=(t=k.items)==null?void 0:t.find(({value:V})=>V.level===this.level),x=["levels","playback-rate","captions","fullscreen"].filter(V=>{var J;return(J=this.controls)==null?void 0:J.includes(V)}),M={title:"Settings",items:[p4,g4,w,m4].filter(({id:V})=>x.includes(V)&&this.resizeHider.hiddenControls.includes(V))},N=(e=this.controls)==null?void 0:e.includes("progress"),D=(i=this.controls)==null?void 0:i.includes("navigation"),F=(s=this.controls)==null?void 0:s.includes("play"),H=(o=this.controls)==null?void 0:o.includes("volume"),j=(c=this.controls)==null?void 0:c.includes("current-time"),st=(d=this.controls)==null?void 0:d.includes("duration"),at=(f=this.controls)==null?void 0:f.includes("levels"),Q=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),gt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Ft=F||H||j||st||at||Q||kt||gt,Kt=[`level-${(b=this.level)==null?void 0:b.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return ie`
965
1057
  <div
966
1058
  ${this.resizeHider.measure()}
967
1059
  ${this.resizeHider.contain()}
968
- class=${je({container:!0,hidden:!G&&!$t})}
1060
+ class=${Ye({container:!0,hidden:!N&&!Ft})}
969
1061
  >
970
1062
  <div
971
- class=${je({"scrubber-container":!0,hidden:!G})}
1063
+ class=${Ye({"scrubber-container":!0,hidden:!N})}
972
1064
  >
973
1065
  <vmp-new-progress-scrubber
974
- class=${je({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
1066
+ class=${Ye({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
975
1067
  duration=${this.duration}
976
1068
  currentTime=${this.currentTime}
977
1069
  .buffer=${this.buffer}
@@ -979,12 +1071,12 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
979
1071
  </div>
980
1072
  <div
981
1073
  ${this.resizeHider.contain()}
982
- class=${je({buttons:!0,hidden:!$t})}
1074
+ class=${Ye({buttons:!0,hidden:!Ft})}
983
1075
  >
984
1076
  <div class="section">
985
1077
  <div
986
1078
  ${this.resizeHider.hide("navigation",6)}
987
- class=${je({navigation:!0,hidden:!_})}
1079
+ class=${Ye({navigation:!0,hidden:!D})}
988
1080
  >
989
1081
  <vmp-new-icon-button
990
1082
  icon="arrow-left"
@@ -1000,7 +1092,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1000
1092
  ></vmp-new-icon-button>
1001
1093
  </div>
1002
1094
  <vmp-new-icon-button
1003
- class=${je({hidden:!F})}
1095
+ class=${Ye({hidden:!F})}
1004
1096
  icon=${this.playing?"pause":"play"}
1005
1097
  weight="heavy"
1006
1098
  rounded="full"
@@ -1008,7 +1100,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1008
1100
  @click=${this._handlePlayClick}
1009
1101
  ></vmp-new-icon-button>
1010
1102
  <vmp-new-volume-button
1011
- class=${je({hidden:!H})}
1103
+ class=${Ye({hidden:!H})}
1012
1104
  ?muted=${this.muted}
1013
1105
  volume=${this.volume}
1014
1106
  @menu:toggle=${this._handleVolumeMenuToggle}
@@ -1016,37 +1108,37 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1016
1108
  <div class="time">
1017
1109
  <vmp-new-text
1018
1110
  ${this.resizeHider.hide("current-time",1)}
1019
- class=${je({hidden:!j})}
1111
+ class=${Ye({hidden:!j})}
1020
1112
  ?semibold=${!0}
1021
- content="${Sf(this.currentTime)}${nt?"/":null}"
1113
+ content="${th(this.currentTime)}${st?"/":null}"
1022
1114
  ></vmp-new-text>
1023
1115
  <vmp-new-text
1024
1116
  ${this.resizeHider.hide("duration",5)}
1025
- class=${je({hidden:!nt})}
1117
+ class=${Ye({hidden:!st})}
1026
1118
  ?semibold=${!0}
1027
- content=${Sf(this.duration)}
1119
+ content=${th(this.duration)}
1028
1120
  ></vmp-new-text>
1029
1121
  </div>
1030
1122
  </div>
1031
1123
  <div class="section">
1032
1124
  <vmp-new-menu
1033
1125
  ${this.resizeHider.hide("levels",0)}
1034
- class=${je({hidden:!ot||T.length<=0})}
1035
- .items=${E}
1036
- .activeItems=${jt}
1126
+ class=${Ye({hidden:!at||E.length<=0})}
1127
+ .items=${k}
1128
+ .activeItems=${Kt}
1037
1129
  @menu:toggle=${this._handleLevelsMenuOpen}
1038
1130
  >
1039
1131
  <vmp-new-tooltip content="Quality" ?disabled=${this.levelsMenuOpen}>
1040
1132
  <vmp-new-button ?active=${this.levelsMenuOpen} icon="chevron-down"
1041
- >${R==null?void 0:R.label}</vmp-new-button
1133
+ >${L==null?void 0:L.label}</vmp-new-button
1042
1134
  >
1043
1135
  </vmp-new-tooltip>
1044
1136
  </vmp-new-menu>
1045
1137
  <vmp-new-menu
1046
1138
  ${this.resizeHider.hide("playback-rate",4)}
1047
- class=${je({hidden:!tt})}
1048
- .items=${Tf}
1049
- .activeItems=${jt}
1139
+ class=${Ye({hidden:!Q})}
1140
+ .items=${xf}
1141
+ .activeItems=${Kt}
1050
1142
  @menu:toggle=${this._handlePlaybackMenuToggle}
1051
1143
  >
1052
1144
  <vmp-new-tooltip content="Playback speed" ?disabled=${this.playbackRateMenuOpen}>
@@ -1057,7 +1149,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1057
1149
  </vmp-new-menu>
1058
1150
  <vmp-new-tooltip
1059
1151
  ${this.resizeHider.hide("captions",3)}
1060
- class=${je({hidden:!kt})}
1152
+ class=${Ye({hidden:!kt})}
1061
1153
  content="Captions"
1062
1154
  >
1063
1155
  <vmp-new-icon-button
@@ -1070,7 +1162,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1070
1162
  <vmp-new-tooltip
1071
1163
  ${this.resizeHider.hide("fullscreen",2)}
1072
1164
  content="Fullscreen"
1073
- class=${je({hidden:!vt})}
1165
+ class=${Ye({hidden:!gt})}
1074
1166
  >
1075
1167
  <vmp-new-icon-button
1076
1168
  ?active=${this.fullscreen}
@@ -1083,7 +1175,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1083
1175
  <vmp-new-menu
1084
1176
  ${this.resizeHider.show("settings",["levels","playback-rate","captions","fullscreen"])}
1085
1177
  .items=${M}
1086
- .activeItems=${jt}
1178
+ .activeItems=${Kt}
1087
1179
  @menu:toggle=${this._handleSettingsMenuToggle}
1088
1180
  >
1089
1181
  <vmp-new-tooltip content="Settings" ?disabled=${this.settingsMenuOpen}>
@@ -1097,7 +1189,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1097
1189
  </div>
1098
1190
  </div>
1099
1191
  </div>
1100
- `}};ai.styles=[Oe.styles??[],Ii`
1192
+ `}};oi.styles=[Le.styles??[],ki`
1101
1193
  :host {
1102
1194
  --controls-border-radius: var(--player-border-radius, 0px);
1103
1195
 
@@ -1168,17 +1260,17 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1168
1260
  .hidden {
1169
1261
  display: none;
1170
1262
  }
1171
- `],Ai([Mt({type:Boolean})],ai.prototype,"playing",2),Ai([Mt({type:Number})],ai.prototype,"volume",2),Ai([Mt({type:Boolean})],ai.prototype,"muted",2),Ai([Mt({type:Number})],ai.prototype,"currentTime",2),Ai([Mt({type:Number})],ai.prototype,"duration",2),Ai([Mt({type:Number})],ai.prototype,"level",2),Ai([Mt({type:Number})],ai.prototype,"playbackRate",2),Ai([Mt({type:Array})],ai.prototype,"buffer",2),Ai([Mt({type:Array,attribute:!1})],ai.prototype,"levels",2),Ai([Mt({type:Boolean})],ai.prototype,"captions",2),Ai([Mt({type:Boolean})],ai.prototype,"fullscreen",2),Ai([Mt({type:Array})],ai.prototype,"controls",2),Ai([Di()],ai.prototype,"volumeMenuOpen",2),Ai([Di()],ai.prototype,"levelsMenuOpen",2),Ai([Di()],ai.prototype,"playbackRateMenuOpen",2),Ai([Di()],ai.prototype,"settingsMenuOpen",2),ai=Ai([qi("vmp-new-player-controls")],ai);var x4=Object.defineProperty,P4=Object.getOwnPropertyDescriptor,O4=(n,t,e,i)=>{for(var s=i>1?void 0:i?P4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&x4(t,e,s),s};let Zc=class extends Oe{render(){return ne`<vmp-new-icon icon="loading"></vmp-new-icon>`}};Zc.styles=[Oe.styles??[],Ii`
1263
+ `],Ai([It({type:Boolean})],oi.prototype,"playing",2),Ai([It({type:Number})],oi.prototype,"volume",2),Ai([It({type:Boolean})],oi.prototype,"muted",2),Ai([It({type:Number})],oi.prototype,"currentTime",2),Ai([It({type:Number})],oi.prototype,"duration",2),Ai([It({type:Number})],oi.prototype,"level",2),Ai([It({type:Number})],oi.prototype,"playbackRate",2),Ai([It({type:Array})],oi.prototype,"buffer",2),Ai([It({type:Array,attribute:!1})],oi.prototype,"levels",2),Ai([It({type:Boolean})],oi.prototype,"captions",2),Ai([It({type:Boolean})],oi.prototype,"fullscreen",2),Ai([It({type:Array})],oi.prototype,"controls",2),Ai([Ti()],oi.prototype,"volumeMenuOpen",2),Ai([Ti()],oi.prototype,"levelsMenuOpen",2),Ai([Ti()],oi.prototype,"playbackRateMenuOpen",2),Ai([Ti()],oi.prototype,"settingsMenuOpen",2),oi=Ai([Oi("vmp-new-player-controls")],oi);var Z4=Object.defineProperty,X4=Object.getOwnPropertyDescriptor,q4=(n,t,e,i)=>{for(var s=i>1?void 0:i?X4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&Z4(t,e,s),s};let sh=class extends Le{render(){return ie`<vmp-new-icon icon="loading"></vmp-new-icon>`}};sh.styles=[Le.styles??[],ki`
1172
1264
  :host {
1173
1265
  display: flex;
1174
1266
  align-items: center;
1175
1267
  justify-content: center;
1176
1268
  }
1177
- `],Zc=O4([qi("vmp-new-loading-spinner")],Zc);var M4=Object.defineProperty,$4=Object.getOwnPropertyDescriptor,_f=(n,t,e,i)=>{for(var s=i>1?void 0:i?$4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&M4(t,e,s),s};let Fo=class extends Oe{constructor(){super(...arguments),this.caption=""}render(){return ne`
1269
+ `],sh=q4([Oi("vmp-new-loading-spinner")],sh);var Q4=Object.defineProperty,J4=Object.getOwnPropertyDescriptor,Nf=(n,t,e,i)=>{for(var s=i>1?void 0:i?J4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&Q4(t,e,s),s};let Vo=class extends Le{constructor(){super(...arguments),this.caption=""}render(){return ie`
1178
1270
  <div class="container">
1179
1271
  <vmp-new-text content=${this.caption} size="large"></vmp-new-text>
1180
1272
  </div>
1181
- `}};Fo.styles=[Oe.styles??[],Ii`
1273
+ `}};Vo.styles=[Le.styles??[],ki`
1182
1274
  .container {
1183
1275
  display: block;
1184
1276
  margin: 0 var(--space-small);
@@ -1197,37 +1289,37 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1197
1289
  /* Line height controls the spacing between the cloned boxes so has to override the default */
1198
1290
  line-height: 2.2;
1199
1291
  }
1200
- `],_f([Mt({type:String})],Fo.prototype,"caption",2),Fo=_f([qi("vmp-new-captions")],Fo);var F4=Object.defineProperty,N4=Object.getOwnPropertyDescriptor,wi=(n,t,e,i)=>{for(var s=i>1?void 0:i?N4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&F4(t,e,s),s};const U4=3e3;let ui=class extends Oe{constructor(){super(...arguments),this.loading=!1,this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.levels=[],this.level=-1,this.playbackRate=1,this.caption="",this.buffer=[],this.captions=!1,this.fullscreen=!1,this.controls=Wc,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=rr()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},U4)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(n){var t;n.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var n;const t=(n=this.controls)==null?void 0:n.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return ne`
1292
+ `],Nf([It({type:String})],Vo.prototype,"caption",2),Vo=Nf([Oi("vmp-new-captions")],Vo);var tA=Object.defineProperty,eA=Object.getOwnPropertyDescriptor,_i=(n,t,e,i)=>{for(var s=i>1?void 0:i?eA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&tA(t,e,s),s};const iA=3e3;let fi=class extends Le{constructor(){super(...arguments),this.loading=!1,this.playing=!1,this.volume=1,this.muted=!1,this.currentTime=0,this.duration=0,this.levels=[],this.level=-1,this.playbackRate=1,this.caption="",this.buffer=[],this.captions=!1,this.fullscreen=!1,this.controls=Jc,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=wi()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},iA)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(n){var t;n.has("playing")&&this.playing&&this._startHideControls(),n.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var n;const t=(n=this.controls)==null?void 0:n.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return ie`
1201
1293
  <div
1202
- class=${je({container:!0,hide:e})}
1294
+ class=${Ye({container:!0,hide:e})}
1203
1295
  @mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
1204
1296
  @mouseleave=${this._immediateHideControls}
1205
1297
  @touchstart=${s=>{this.playing&&!this.showControls&&!this._hasTouched&&(s.preventDefault(),this._hasTouched=!0,this._immediateShowControls(),this._startHideControls())}}
1206
1298
  >
1207
1299
  <div
1208
- class=${je({fixtures:!0,invisible:!this.loading&&!i})}
1300
+ class=${Ye({fixtures:!0,invisible:!this.loading&&!i})}
1209
1301
  @click=${()=>{this.showControls&&this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}}
1210
1302
  >
1211
1303
  <vmp-new-icon
1212
- class=${je({hidden:!i})}
1304
+ class=${Ye({hidden:!i})}
1213
1305
  icon="play-large"
1214
1306
  ></vmp-new-icon>
1215
1307
  <vmp-new-loading-spinner
1216
- class=${je({hidden:!this.loading||i})}
1308
+ class=${Ye({hidden:!this.loading||i})}
1217
1309
  ></vmp-new-loading-spinner>
1218
1310
  </div>
1219
1311
  <div
1220
- class=${je({controls:!0,hide:e})}
1312
+ class=${Ye({controls:!0,hide:e})}
1221
1313
  @focusin=${this._immediateShowControls}
1222
1314
  @mousemove=${s=>{s.stopPropagation(),this._immediateShowControls()}}
1223
1315
  @click=${this._immediateShowControls}
1224
1316
  >
1225
- ${this.captions?ne`<vmp-new-captions
1226
- class=${je({hidden:!this.caption,hiddenControls:e})}
1317
+ ${this.captions?ie`<vmp-new-captions
1318
+ class=${Ye({hidden:!this.caption,hiddenControls:e})}
1227
1319
  caption=${this.caption}
1228
1320
  ></vmp-new-captions>`:null}
1229
1321
  <vmp-new-player-controls
1230
- ${sr(this._playerControlsRef)}
1322
+ ${Si(this._playerControlsRef)}
1231
1323
  ?playing=${this.playing}
1232
1324
  ?muted=${this.muted}
1233
1325
  volume=${this.volume}
@@ -1243,7 +1335,7 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1243
1335
  ></vmp-new-player-controls>
1244
1336
  </div>
1245
1337
  </div>
1246
- `}};ui.styles=[Oe.styles??[],Ii`
1338
+ `}};fi.styles=[Le.styles??[],ki`
1247
1339
  :host {
1248
1340
  --overlay-border-radius: var(--player-border-radius, 0px);
1249
1341
  }
@@ -1315,49 +1407,64 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1315
1407
  vmp-new-captions.hiddenControls {
1316
1408
  transform: translateY(calc(var(--space-small) * -1));
1317
1409
  }
1318
- `],wi([Mt({type:Boolean})],ui.prototype,"loading",2),wi([Mt({type:Boolean})],ui.prototype,"playing",2),wi([Mt({type:Number})],ui.prototype,"volume",2),wi([Mt({type:Boolean})],ui.prototype,"muted",2),wi([Mt({type:Number})],ui.prototype,"currentTime",2),wi([Mt({type:Number})],ui.prototype,"duration",2),wi([Mt({type:Array,attribute:!1})],ui.prototype,"levels",2),wi([Mt({type:Number})],ui.prototype,"level",2),wi([Mt({type:Number})],ui.prototype,"playbackRate",2),wi([Mt({type:String})],ui.prototype,"caption",2),wi([Mt({type:Array})],ui.prototype,"buffer",2),wi([Mt({type:Boolean})],ui.prototype,"captions",2),wi([Mt({type:Boolean})],ui.prototype,"fullscreen",2),wi([Mt({type:Array})],ui.prototype,"controls",2),wi([Di()],ui.prototype,"showControls",2),ui=wi([qi("vmp-new-player-overlay")],ui);var B4=Object.defineProperty,G4=Object.getOwnPropertyDescriptor,fi=(n,t,e,i)=>{for(var s=i>1?void 0:i?G4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&B4(t,e,s),s};let ii=class extends Oe{constructor(){super(...arguments),this.burnCaptions=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Ig,this._sceneController=new t4(this),this._drawController=new Lm(this),this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._lastTimeUpdate=null,this._playerRef=rr(),this._canvasRef=rr(),this._aspectRatio=this.propAspectRatio,this._waiting=!1,this._stalled=!1,this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{this._playerRef.value&&(this.propAspectRatio||(this._aspectRatio=this._playerRef.value.offsetWidth/this._playerRef.value.offsetHeight))},this._handleCanvasResize=()=>{this.draw()},this._seeker=n=>{var t;this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:e})=>{if(e){const i=this._sceneController.videoState[e.id];return!i||!i.initialised||i.waiting}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),!this.stalled&&n-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(n-(this._lastTimestamp??n))/1e3*this.playbackRate,this._lastTimestamp=n),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||((t=this.scene)!=null&&t.video?this._lastTimeUpdate&&n-this._lastTimeUpdate>1e3&&(this._stalled=!0):(this._stalled=!1,this._lastTimeUpdate=n),this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get waiting(){return!this.paused&&this._waiting}get stalled(){return this._stalled}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get processing(){return this._sceneController.processing}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var n;return((n=this._sceneController.scenes)==null?void 0:n.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}set paused(n){n!==this._paused&&(this._paused=n,this.requestUpdate(),this.dispatchEvent(new CustomEvent(n?"pause":"play")))}get paused(){return this._paused}set playbackRate(n){n!==this._playbackRate&&(this._playbackRate=n,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=n)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:n})))}get playbackRate(){return this._playbackRate}set volume(n){const t=Math.min(1,Math.max(0,n));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-new-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-new-player-volume")??"1"))}set muted(n){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=n)}),n!==this._muted&&(this._muted=n,localStorage.setItem("vmp-new-player-muted",n.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-new-player-muted")==="true")}set videoResolution(n){n!==this._videoResolution&&(this._videoResolution=n,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===n);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(n){n!==this._drawController.currentTime&&(this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n))}get currentTime(){return this._drawController.currentTime}reset(n=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this._lastTimeUpdate=1/0,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._seekerRAF||(this._seekerRAF=requestAnimationFrame(this._seeker))}pause(){this._seekerRAF&&(cancelAnimationFrame(this._seekerRAF),this._seekerRAF=null),this.paused=!0,this.scenes.forEach(({video:n})=>{n&&n.node.pause()})}draw(n){return this._drawController.draw(n)}setScene(n){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[n];if(!i)return this.dispatchEvent(new ErrorEvent("error",new Error(`No scene at index: ${n}`)));this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(n){n??this.fullscreen?i4():this._playerRef.value&&e4(this._playerRef.value)}connectedCallback(){super.connectedCallback(),document.addEventListener("fullscreenchange",this._handleFullscreenChange),this.addEventListener("video:timeupdate",n=>{this._stalled=!1,this._lastTimeUpdate=n.timeStamp})}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(n){n.has("_stalled")&&this.stalled&&this.dispatchEvent(new CustomEvent("stalled")),n.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}render(){var n,t,e,i,s,o;const c=this.loading||!this.scenes||this.duration<=0,{height:d,width:f}=fn({resolution:((n=this.sceneConfig)==null?void 0:n.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.videoState).reduce((E,w)=>E.concat(this.videoState[w].buffered??[]),[...this._drawController.fakeBufferSegments]),g=c?[]:(t=this.controls??Wc)==null?void 0:t.filter(E=>!(E==="fullscreen"&&qb()||E==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=(((e=this.scenes)==null?void 0:e.length)??0)-1,A=((i=this.scenes)==null?void 0:i.findIndex(E=>E===this._drawController.activeScenes[0]))??0,T=(o=(s=this._drawController.activeScenes[0])==null?void 0:s.video)==null?void 0:o.hls;return ne`
1410
+ `],_i([It({type:Boolean})],fi.prototype,"loading",2),_i([It({type:Boolean})],fi.prototype,"playing",2),_i([It({type:Number})],fi.prototype,"volume",2),_i([It({type:Boolean})],fi.prototype,"muted",2),_i([It({type:Number})],fi.prototype,"currentTime",2),_i([It({type:Number})],fi.prototype,"duration",2),_i([It({type:Array,attribute:!1})],fi.prototype,"levels",2),_i([It({type:Number})],fi.prototype,"level",2),_i([It({type:Number})],fi.prototype,"playbackRate",2),_i([It({type:String})],fi.prototype,"caption",2),_i([It({type:Array})],fi.prototype,"buffer",2),_i([It({type:Boolean})],fi.prototype,"captions",2),_i([It({type:Boolean})],fi.prototype,"fullscreen",2),_i([It({type:Array})],fi.prototype,"controls",2),_i([Ti()],fi.prototype,"showControls",2),fi=_i([Oi("vmp-new-player-overlay")],fi);var rA=Object.defineProperty,sA=Object.getOwnPropertyDescriptor,si=(n,t,e,i)=>{for(var s=i>1?void 0:i?sA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&rA(t,e,s),s};let Xe=class extends Le{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=xl,this._sceneController=new d4(this),this._drawController=new N1(this),this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=wi(),this._canvasRef=wi(),this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{this._playerRef.value&&(this.propAspectRatio||(this._aspectRatio=this._playerRef.value.offsetWidth/this._playerRef.value.offsetHeight))},this._handleCanvasResize=()=>{this.draw()},this._seeker=n=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,i=this.videoState[e];return!i||!i.initialised||i.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),n-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(n-(this._lastTimestamp??n))/1e3*this.playbackRate,this._lastTimestamp=n),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||(this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleError=n=>{this._errors.push(n.error)},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var n;return((n=this._sceneController.scenes)==null?void 0:n.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((n,{video:t,start:e,duration:i})=>{const s=(t==null?void 0:t.key)??`${e}-${i}`;return n[s]=this.videoState[s],n},{})}set paused(n){n!==this._paused&&(this._paused=n,this.requestUpdate(),this.dispatchEvent(new CustomEvent(n?"pause":"play")))}get paused(){return this._paused}set playbackRate(n){n!==this._playbackRate&&(this._playbackRate=n,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=n)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:n})))}get playbackRate(){return this._playbackRate}set volume(n){const t=Math.min(1,Math.max(0,n));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-new-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-new-player-volume")??"1"))}set muted(n){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=n)}),n!==this._muted&&(this._muted=n,localStorage.setItem("vmp-new-player-muted",n.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-new-player-muted")==="true")}set videoResolution(n){n!==this._videoResolution&&(this._videoResolution=n,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===n);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(n){n!==this._drawController.currentTime&&(this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n))}get currentTime(){return this._drawController.currentTime}reset(n=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._seekerRAF||(this._seekerRAF=requestAnimationFrame(this._seeker))}pause(){this._seekerRAF&&(cancelAnimationFrame(this._seekerRAF),this._seekerRAF=null),this.paused=!0,this.scenes.forEach(({video:n})=>{n&&n.node.pause()})}draw(n){return this._drawController.draw(n)}setScene(n){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[n];if(!i){const s=new nn(`No scene at index: ${n}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:s,message:s.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(n){n??this.fullscreen?f4():this._playerRef.value&&u4(this._playerRef.value)}connectedCallback(){super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange)}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(n){n.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&n.has("_processing")&&this.play()}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}render(){var n,t,e,i,s,o;const c=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=Pl({resolution:((n=this.sceneConfig)==null?void 0:n.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((L,x)=>L.concat(this.sceneVideoState[x].buffered??[]),[]),g=c?[]:(t=this.controls??Jc)==null?void 0:t.filter(L=>!(L==="fullscreen"&&c4()||L==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),b=(((e=this.scenes)==null?void 0:e.length)??0)-1,E=((i=this.scenes)==null?void 0:i.findIndex(L=>L===this._drawController.activeScenes[0]))??0,k=(o=(s=this._drawController.activeScenes[0])==null?void 0:s.video)==null?void 0:o.hls,w=!!this.errors.find(L=>L.fatal);return ie`
1319
1411
  <div
1320
- ${sr(this._playerRef)}
1321
- ${Kc(this._handleContainerResize)}
1322
- class=${je({player:!0,responsive:!this.propAspectRatio})}
1412
+ ${Si(this._playerRef)}
1413
+ ${Uo(this._handleContainerResize)}
1414
+ class=${Ye({player:!0,responsive:!this.propAspectRatio})}
1323
1415
  >
1324
- <canvas
1325
- ${sr(this._canvasRef)}
1326
- ${this._drawController.canvas()}
1327
- ${Kc(this._handleCanvasResize)}
1328
- height=${d}
1329
- width=${f}
1330
- ></canvas>
1331
- <vmp-new-player-overlay
1332
- ${this._drawController.controls()}
1333
- ?disabled=${c}
1334
- ?playing=${!this.paused}
1335
- ?loading=${this.loading||this.waiting||this.stalled}
1336
- ?muted=${this.muted}
1337
- volume=${this.volume}
1338
- duration=${this.duration}
1339
- .levels=${(T==null?void 0:T.levels)??[]}
1340
- level=${Ws(T!=null&&T.autoLevelEnabled?-1:T==null?void 0:T.currentLevel)}
1341
- playbackRate=${this.playbackRate}
1342
- caption=${this._drawController.caption}
1343
- .buffer=${p}
1344
- .controls=${g}
1345
- ?captions=${this.captions}
1346
- ?fullscreen=${this.fullscreen}
1347
- @navigate:back=${E=>{E.defaultPrevented||this.setScene(A<=0?v:A-1)}}
1348
- @navigate:forward=${E=>{E.defaultPrevented||this.setScene(A>=v?0:A+1)}}
1349
- @play:click=${({detail:E})=>{c||(E?this.pause():(this.muted=this._manualMute,this.play()))}}
1350
- @volume:click=${({detail:E})=>{this.muted=!E,this._manualMute=!E}}
1351
- @level:click=${({detail:E})=>{this.videoResolution=E.value.resolution}}
1352
- @playbackRate:click=${({detail:E})=>{this.playbackRate=E.value??1}}
1353
- @captions:click=${()=>{this._captions=!this._captions}}
1354
- @fullscreen:click=${()=>{this.toggleFullscreen()}}
1355
- @input=${E=>{const w=E.composedPath()[0],R=w.getAttribute("key");if(R==="scrubber"){const x=parseFloat(w.value);this._drawController.currentTime=x,this._sceneController.setVideosCurrentTime(x),this.dispatchEvent(new CustomEvent("seeking",{detail:x}))}R==="volume"&&(this.volume=parseFloat(w.value))}}
1356
- @pointerdown=${E=>{E.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1357
- @pointerup=${E=>{E.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1358
- ></vmp-new-player-overlay>
1416
+ ${w?ie`<div class="error">
1417
+ <div class="error-icon">
1418
+ <vmp-new-icon icon="error"></vmp-new-icon>
1419
+ </div>
1420
+ <vmp-new-text semibold content=${"Fatal error - please contact support"}></vmp-new-text>
1421
+ </div>`:ie`<canvas
1422
+ ${Si(this._canvasRef)}
1423
+ ${this._drawController.canvas()}
1424
+ ${Uo(this._handleCanvasResize)}
1425
+ height=${d}
1426
+ width=${f}
1427
+ ></canvas>
1428
+ <vmp-new-player-overlay
1429
+ ${this._drawController.controls()}
1430
+ .data=${this.data}
1431
+ .template=${this.template}
1432
+ ?disabled=${c}
1433
+ ?playing=${!this.paused}
1434
+ ?loading=${this.loading||this.waiting||this.processing}
1435
+ ?muted=${this.muted}
1436
+ volume=${this.volume}
1437
+ duration=${this.duration}
1438
+ .levels=${(k==null?void 0:k.levels)??[]}
1439
+ level=${zs(k!=null&&k.autoLevelEnabled?-1:k==null?void 0:k.currentLevel)}
1440
+ playbackRate=${this.playbackRate}
1441
+ caption=${this._drawController.caption}
1442
+ .buffer=${p}
1443
+ .controls=${g}
1444
+ ?captions=${this.captions}
1445
+ ?fullscreen=${this.fullscreen}
1446
+ @navigate:back=${L=>{L.defaultPrevented||this.setScene(E<=0?b:E-1)}}
1447
+ @navigate:forward=${L=>{L.defaultPrevented||this.setScene(E>=b?0:E+1)}}
1448
+ @play:click=${({detail:L})=>{c||(L?this.pause():(this.muted=this._manualMute,this.play()))}}
1449
+ @volume:click=${({detail:L})=>{this.muted=!L,this._manualMute=!L}}
1450
+ @level:click=${({detail:L})=>{this.videoResolution=L.value.resolution}}
1451
+ @playbackRate:click=${({detail:L})=>{this.playbackRate=L.value??1}}
1452
+ @captions:click=${()=>{this._captions=!this._captions}}
1453
+ @fullscreen:click=${()=>{this.toggleFullscreen()}}
1454
+ @input=${L=>{const x=L.composedPath()[0],M=x.getAttribute("key");if(M==="scrubber"){const N=parseFloat(x.value);this._drawController.currentTime=N,this._sceneController.setVideosCurrentTime(N),this.dispatchEvent(new CustomEvent("seeking",{detail:N}))}M==="volume"&&(this.volume=parseFloat(x.value))}}
1455
+ @pointerdown=${L=>{L.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1456
+ @pointerup=${L=>{L.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1457
+ ></vmp-new-player-overlay>
1458
+ <vmp-new-video-preview
1459
+ ?disabled=${v}
1460
+ .src=${this.src}
1461
+ .data=${this.data}
1462
+ .template=${this.template}
1463
+ .aspectRatio=${this.aspectRatio}
1464
+ .compilation=${this.compilation}
1465
+ ></vmp-new-video-preview>`}
1359
1466
  </div>
1360
- `}};ii.styles=[Oe.styles??[],Ii`
1467
+ `}};Xe.styles=[Le.styles??[],ki`
1361
1468
  :host {
1362
1469
  --player-border-radius: var(--vouch-media-player-border-radius, 0px);
1363
1470
  }
@@ -1372,8 +1479,22 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1372
1479
  }
1373
1480
 
1374
1481
  .responsive {
1482
+ width: 100%;
1375
1483
  height: 100%;
1484
+ }
1485
+
1486
+ .error {
1487
+ display: flex;
1488
+ align-items: center;
1489
+ justify-content: center;
1490
+ gap: var(--space-xxs);
1376
1491
  width: 100%;
1492
+ height: 100%;
1493
+ color: white;
1494
+ }
1495
+
1496
+ .error-icon {
1497
+ color: var(--colors-red-500);
1377
1498
  }
1378
1499
 
1379
1500
  canvas {
@@ -1390,17 +1511,17 @@ ${t}`,kg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),wg=Objec
1390
1511
  right: 0;
1391
1512
  bottom: 0;
1392
1513
  }
1393
- `],fi([Mt({type:Object})],ii.prototype,"data",2),fi([Mt({type:Object})],ii.prototype,"template",2),fi([Mt({type:Boolean})],ii.prototype,"burnCaptions",2),fi([Mt({type:String})],ii.prototype,"src",2),fi([Mt({type:String})],ii.prototype,"track",2),fi([Mt({type:Number,attribute:"aspectratio"})],ii.prototype,"propAspectRatio",2),fi([Mt({type:String})],ii.prototype,"preload",2),fi([Mt({type:Boolean})],ii.prototype,"autoplay",2),fi([Mt({type:Boolean})],ii.prototype,"loading",2),fi([Mt({type:Array})],ii.prototype,"controls",2),fi([Mt({attribute:!1})],ii.prototype,"compilation",2),fi([Di()],ii.prototype,"_aspectRatio",2),fi([Di()],ii.prototype,"_waiting",2),fi([Di()],ii.prototype,"_stalled",2),fi([Di()],ii.prototype,"_seeking",2),fi([Di()],ii.prototype,"_captions",2),fi([Di()],ii.prototype,"_fullscreen",2),ii=fi([qi("vmp-new-media-player")],ii);var H4=Object.defineProperty,V4=Object.getOwnPropertyDescriptor,Qi=(n,t,e,i)=>{for(var s=i>1?void 0:i?V4(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&H4(t,e,s),s};Ke.Embed=class extends un{constructor(){super(...arguments),this._mediaPlayerRef=rr(),this.env="prod",this.apiKey="",this.trackingSource="embed",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new j2(this,["durationchange","ended","error","loadeddata","pause","stalled","play","playing","ratechange","scenechange","seeking","seeked","timeupdate","volumechange","waiting","video:loadeddata","video:seeked","video:play","video:playing","video:pause","video:stalled","video:timeupdate","video:ended","video:error"]),this._fetcherController=new fg(this),this._trackingController=new yg(this)}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}render(){return ne`
1514
+ `],si([It({type:Object})],Xe.prototype,"data",2),si([It({type:Object})],Xe.prototype,"template",2),si([It({type:Boolean})],Xe.prototype,"burnCaptions",2),si([It({type:Boolean})],Xe.prototype,"debug",2),si([It({type:String})],Xe.prototype,"src",2),si([It({type:String})],Xe.prototype,"track",2),si([It({type:Number,attribute:"aspectratio"})],Xe.prototype,"propAspectRatio",2),si([It({type:String})],Xe.prototype,"preload",2),si([It({type:Boolean})],Xe.prototype,"autoplay",2),si([It({type:Boolean})],Xe.prototype,"loading",2),si([It({type:Array})],Xe.prototype,"controls",2),si([It({attribute:!1})],Xe.prototype,"compilation",2),si([Ti()],Xe.prototype,"_aspectRatio",2),si([Ti()],Xe.prototype,"_processing",2),si([Ti()],Xe.prototype,"_waiting",2),si([Ti()],Xe.prototype,"_errors",2),si([Ti()],Xe.prototype,"_seeking",2),si([Ti()],Xe.prototype,"_captions",2),si([Ti()],Xe.prototype,"_fullscreen",2),Xe=si([Oi("vmp-new-media-player")],Xe);var nA=Object.defineProperty,aA=Object.getOwnPropertyDescriptor,zi=(n,t,e,i)=>{for(var s=i>1?void 0:i?aA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&nA(t,e,s),s};Ge.Embed=class extends yn{constructor(){super(...arguments),this._mediaPlayerRef=wi(),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embed",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new ig(this,["durationchange","ended","error","loadeddata","pause","stalled","play","playing","ratechange","scenechange","seeking","seeked","timeupdate","volumechange","waiting","video:loadeddata","video:seeking","video:seeked","video:play","video:playing","video:pause","video:stalled","video:timeupdate","video:ended","video:error"]),this._fetcherController=new Rg(this),this._trackingController=new _g(this)}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get sceneConfig(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.sceneConfig)??null}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}render(){return ie`
1394
1515
  <vmp-new-media-player
1395
- ${sr(this._mediaPlayerRef)}
1516
+ ${Si(this._mediaPlayerRef)}
1396
1517
  ${this.eventController.register()}
1397
1518
  ?autoplay=${this.autoplay}
1398
1519
  ?loading=${this.fetching}
1399
1520
  .data=${this.vouch}
1400
1521
  .template=${this.template}
1401
- aspectRatio=${Ws(this.aspectRatio)}
1402
- preload=${Ws(this.preload)}
1522
+ aspectRatio=${zs(this.aspectRatio)}
1523
+ preload=${zs(this.preload)}
1403
1524
  .controls=${this.controls}
1404
1525
  ></vmp-new-media-player>
1405
- `}},Qi([Mt({type:Object,attribute:"data"})],Ke.Embed.prototype,"data",2),Qi([Mt({type:String})],Ke.Embed.prototype,"vouchId",2),Qi([Mt({type:String})],Ke.Embed.prototype,"templateId",2),Qi([Mt({type:String})],Ke.Embed.prototype,"env",2),Qi([Mt({type:String})],Ke.Embed.prototype,"apiKey",2),Qi([Mt({type:String})],Ke.Embed.prototype,"trackingSource",2),Qi([Mt({type:Array})],Ke.Embed.prototype,"controls",2),Qi([Mt({type:String})],Ke.Embed.prototype,"preload",2),Qi([Mt({type:Boolean})],Ke.Embed.prototype,"autoplay",2),Qi([Mt({type:Number})],Ke.Embed.prototype,"aspectRatio",2),Qi([Di()],Ke.Embed.prototype,"vouch",2),Qi([Di()],Ke.Embed.prototype,"template",2),Ke.Embed=Qi([P2("vouch-embed")],Ke.Embed);function $r(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Cf(n,t){for(var e="",i=0,s=-1,o=0,c,d=0;d<=n.length;++d){if(d<n.length)c=n.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",i=0):(e=e.slice(0,f),i=e.length-1-e.lastIndexOf("/")),s=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+n.slice(s+1,d):e=n.slice(s+1,d),i=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function W4(n,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+n+i:i}var _n={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var o;s>=0?o=arguments[s]:(i===void 0&&(i=process.cwd()),o=i),$r(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Cf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if($r(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Cf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return $r(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];$r(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":_n.normalize(t)},relative:function(t,e){if($r(t),$r(e),t===e||(t=_n.resolve(t),e=_n.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,o=s-i,c=1;c<e.length&&e.charCodeAt(c)===47;++c);for(var d=e.length,f=d-c,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(c+v)===47)return e.slice(c+v+1);if(v===0)return e.slice(c+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var A=t.charCodeAt(i+v),T=e.charCodeAt(c+v);if(A!==T)break;A===47&&(g=v)}var E="";for(v=i+g+1;v<=s;++v)(v===s||t.charCodeAt(v)===47)&&(E.length===0?E+="..":E+="/..");return E.length>0?E+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if($r(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){s=c;break}}else o=!1;return s===-1?i?"/":".":i&&s===1?"//":t.slice(0,s)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');$r(t);var i=0,s=-1,o=!0,c;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(c=t.length-1;c>=0;--c){var p=t.charCodeAt(c);if(p===47){if(!o){i=c+1;break}}else f===-1&&(o=!1,f=c+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(s=c):(d=-1,s=f))}return i===s?s=f:s===-1&&(s=t.length),t.slice(i,s)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else s===-1&&(o=!1,s=c+1);return s===-1?"":t.slice(i,s)}},extname:function(t){$r(t);for(var e=-1,i=0,s=-1,o=!0,c=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}s===-1&&(o=!1,s=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||s===-1||c===0||c===1&&e===s-1&&e===i+1?"":t.slice(e,s)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return W4("/",t)},parse:function(t){$r(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,o;s?(e.root="/",o=1):o=0;for(var c=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(i=t.charCodeAt(g),i===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),i===46?c===-1?c=g:v!==1&&(v=1):c!==-1&&(v=-1)}return c===-1||f===-1||v===0||v===1&&c===f-1&&c===d+1?f!==-1&&(d===0&&s?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&s?(e.name=t.slice(1,c),e.base=t.slice(1,f)):(e.name=t.slice(d,c),e.base=t.slice(d,f)),e.ext=t.slice(c,f)),d>0?e.dir=t.slice(0,d-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};_n.posix=_n;var K4=_n;const{basename:If,extname:j4}=K4;class z4{constructor(){let t=(()=>typeof Ya>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",o="image/webp",c="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:s,webp:o}:{png:e,jpg:i,jpeg:s,pdf:c,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[c]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function Y4(n,{filename:t="",extension:e="",format:w,page:s,quality:o,matte:c,density:d,outline:f,archive:T}={}){var{fromMime:g,toMime:v,expected:A}=new z4,T=T||"canvas",E=w||e.replace(/@\d+x$/i,"")||j4(t),w=g(v(E)||E),R=v(w),x=n.length;if(!E)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${E}" (expected ${A})`);if(!x)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,G,_=t.replace(/{(\d*)}/g,(H,j)=>(G=!0,j=parseInt(j,10),M=isFinite(j)?j:isFinite(M)?M:-1,"{}")),F=s>0?s-1:s<0?x+s:void 0;if(isFinite(F)&&F<0||F>=x)throw new RangeError(x==1?`Canvas only has a ‘page 1’ (${F} is out of bounds)`:`Canvas has pages 1–${x} (${F} is out of bounds)`);if(n=isFinite(F)?[n[F]]:G||w=="pdf"?n:n.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let H=(e||If(t,E)).match(/@(\d+)x$/i);d=H?parseInt(H[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:_,format:w,mime:R,pages:n,padding:M,quality:o,matte:c,density:d,outline:f,archive:T}}class No{static for(t){return new No().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,o=t.length|0;s<o;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}No.prototype.table=(()=>{var n,t,e,i=[];for(n=0;n<256;n++){for(e=n,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[n]=e}return i})();function Xc(n){let t=new Uint8Array(n),e=new DataView(t.buffer),i={array:t,view:e,size:n,set8(s,o){return e.setUint8(s,o),i},set16(s,o){return e.setUint16(s,o,!0),i},set32(s,o){return e.setUint32(s,o,!0),i},bytes(s,o){return t.set(o,s),i}};return i}const Uo=class Uo{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,s=Uo.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+s.length,d=c+o.length,f=16,{offset:p}=this,g=Xc(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,No.for(o)).set32(14,o.length).set32(18,o.length).set16(22,s.length);p+=c;let v=Xc(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,s).bytes(c,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:s,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:A})=>46+A.length+v,0),e=Xc(t+22),i=0;for(var{offset:s,name:o,header:c,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,c.array).set8(i+38,d?16:0).set32(i+42,s).bytes(i+46,o),i+=46+o.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};Jp(Uo,"encoder",new TextEncoder);let qc=Uo;const Qc=(n,t,e,i)=>{if(i){let{width:s,height:o}=n,c=Object.assign(document.createElement("canvas"),{width:s,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,s,o),d.drawImage(n,0,0),n=c}return new Promise((s,o)=>n.toBlob(s,t,e))},Z4=(...n)=>Qc(...n).then(t=>t.arrayBuffer()),X4=async(n,t,e,i,s)=>{Df(s,await Qc(n,t,e,i))},q4=async(n,t,e,i,s,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=If(s,".zip")||"archive",p=new qc(f);await Promise.all(n.map(async(g,v)=>{let A=d(v);await p.add(A,await Qc(g,t,e,i))})),Df(`${f}.zip`,p.blob)},Df=(n,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",n),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var Q4={asBuffer:Z4,asDownload:X4,asZipDownload:q4,atScale:(n,t,e)=>n.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),o=s.getContext("2d"),c=i.canvas?i.canvas:i;return s.width=c.width*t,s.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,s.width,s.height)),o.scale(t,t),o.drawImage(c,0,0),s}),options:Y4};const{asBuffer:Jc,asDownload:J4,asZipDownload:tA,atScale:th,options:eh}=Q4,xf=Symbol.for("toDataURL"),eA=n=>{let t=Object.assign(new Pf,{crossOrigin:"Anonymous",src:n});return t.decode().then(()=>t)};class iA{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>Jc(i,"image/png"),jpg:()=>Jc(i,"image/jpeg"),pages:()=>s.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:c});return Object.assign(i,{width:t,height:e,newPage(...d){var{width:p,height:g}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(i,0,0),s.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(i,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=eh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:A,quality:T,matte:E,density:w,archive:R}=p,x=th(p.pages,w);return v==null?J4(x[0],A,T,E,d):tA(x,A,T,E,R,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=eh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:T,density:E}=p,w=th(T,E,A)[0];return Jc(w,g,v,A)},[xf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=eh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:T,density:E}=p,w=th(T,E,A)[0],R=w[w===i?xf:"toDataURL"](g,v);return Promise.resolve(R)}})}}const{CanvasRenderingContext2D:rA,CanvasGradient:sA,CanvasPattern:nA,Image:Pf,ImageData:aA,Path2D:oA,DOMMatrix:lA,DOMRect:cA,DOMPoint:hA}=window;var Of={Canvas:iA,loadImage:eA,CanvasRenderingContext2D:rA,CanvasGradient:sA,CanvasPattern:nA,Image:Pf,ImageData:aA,Path2D:oA,DOMMatrix:lA,DOMRect:cA,DOMPoint:hA};const Mf=jr({__proto__:null,default:kl(Of)},[Of]);return Object.defineProperty(Ke,Symbol.toStringTag,{value:"Module"}),Ke}({});
1526
+ `}},zi([It({type:Object,attribute:"data"})],Ge.Embed.prototype,"data",2),zi([It({type:String})],Ge.Embed.prototype,"vouchId",2),zi([It({type:String})],Ge.Embed.prototype,"templateId",2),zi([It({type:String})],Ge.Embed.prototype,"env",2),zi([It({type:String})],Ge.Embed.prototype,"apiKey",2),zi([It({type:Boolean})],Ge.Embed.prototype,"disableTracking",2),zi([It({type:String})],Ge.Embed.prototype,"trackingSource",2),zi([It({type:Array})],Ge.Embed.prototype,"controls",2),zi([It({type:String})],Ge.Embed.prototype,"preload",2),zi([It({type:Boolean})],Ge.Embed.prototype,"autoplay",2),zi([It({type:Number})],Ge.Embed.prototype,"aspectRatio",2),zi([Ti()],Ge.Embed.prototype,"vouch",2),zi([Ti()],Ge.Embed.prototype,"template",2),Ge.Embed=zi([H2("vouch-embed")],Ge.Embed);function Fr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Uf(n,t){for(var e="",i=0,s=-1,o=0,c,d=0;d<=n.length;++d){if(d<n.length)c=n.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",i=0):(e=e.slice(0,f),i=e.length-1-e.lastIndexOf("/")),s=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+n.slice(s+1,d):e=n.slice(s+1,d),i=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function oA(n,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+n+i:i}var Mn={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var o;s>=0?o=arguments[s]:(i===void 0&&(i=process.cwd()),o=i),Fr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Uf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Fr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Uf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Fr(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];Fr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Mn.normalize(t)},relative:function(t,e){if(Fr(t),Fr(e),t===e||(t=Mn.resolve(t),e=Mn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,o=s-i,c=1;c<e.length&&e.charCodeAt(c)===47;++c);for(var d=e.length,f=d-c,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(c+v)===47)return e.slice(c+v+1);if(v===0)return e.slice(c+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var b=t.charCodeAt(i+v),E=e.charCodeAt(c+v);if(b!==E)break;b===47&&(g=v)}var k="";for(v=i+g+1;v<=s;++v)(v===s||t.charCodeAt(v)===47)&&(k.length===0?k+="..":k+="/..");return k.length>0?k+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if(Fr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){s=c;break}}else o=!1;return s===-1?i?"/":".":i&&s===1?"//":t.slice(0,s)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Fr(t);var i=0,s=-1,o=!0,c;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(c=t.length-1;c>=0;--c){var p=t.charCodeAt(c);if(p===47){if(!o){i=c+1;break}}else f===-1&&(o=!1,f=c+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(s=c):(d=-1,s=f))}return i===s?s=f:s===-1&&(s=t.length),t.slice(i,s)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else s===-1&&(o=!1,s=c+1);return s===-1?"":t.slice(i,s)}},extname:function(t){Fr(t);for(var e=-1,i=0,s=-1,o=!0,c=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}s===-1&&(o=!1,s=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||s===-1||c===0||c===1&&e===s-1&&e===i+1?"":t.slice(e,s)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return oA("/",t)},parse:function(t){Fr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,o;s?(e.root="/",o=1):o=0;for(var c=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(i=t.charCodeAt(g),i===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),i===46?c===-1?c=g:v!==1&&(v=1):c!==-1&&(v=-1)}return c===-1||f===-1||v===0||v===1&&c===f-1&&c===d+1?f!==-1&&(d===0&&s?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&s?(e.name=t.slice(1,c),e.base=t.slice(1,f)):(e.name=t.slice(d,c),e.base=t.slice(d,f)),e.ext=t.slice(c,f)),d>0?e.dir=t.slice(0,d-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Mn.posix=Mn;var lA=Mn;const{basename:Bf,extname:cA}=lA;class hA{constructor(){let t=(()=>typeof Ja>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",o="image/webp",c="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:s,webp:o}:{png:e,jpg:i,jpeg:s,pdf:c,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[c]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function dA(n,{filename:t="",extension:e="",format:w,page:s,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:b}=new hA,E=E||"canvas",k=w||e.replace(/@\d+x$/i,"")||cA(t),w=g(v(k)||k),L=v(w),x=n.length;if(!k)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${k}" (expected ${b})`);if(!x)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let M,N,D=t.replace(/{(\d*)}/g,(H,j)=>(N=!0,j=parseInt(j,10),M=isFinite(j)?j:isFinite(M)?M:-1,"{}")),F=s>0?s-1:s<0?x+s:void 0;if(isFinite(F)&&F<0||F>=x)throw new RangeError(x==1?`Canvas only has a ‘page 1’ (${F} is out of bounds)`:`Canvas has pages 1–${x} (${F} is out of bounds)`);if(n=isFinite(F)?[n[F]]:N||w=="pdf"?n:n.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let H=(e||Bf(t,k)).match(/@(\d+)x$/i);d=H?parseInt(H[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:D,format:w,mime:L,pages:n,padding:M,quality:o,matte:c,density:d,outline:f,archive:E}}class Ho{static for(t){return new Ho().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,o=t.length|0;s<o;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}Ho.prototype.table=(()=>{var n,t,e,i=[];for(n=0;n<256;n++){for(e=n,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[n]=e}return i})();function nh(n){let t=new Uint8Array(n),e=new DataView(t.buffer),i={array:t,view:e,size:n,set8(s,o){return e.setUint8(s,o),i},set16(s,o){return e.setUint16(s,o,!0),i},set32(s,o){return e.setUint32(s,o,!0),i},bytes(s,o){return t.set(o,s),i}};return i}const Wo=class Wo{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,s=Wo.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+s.length,d=c+o.length,f=16,{offset:p}=this,g=nh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ho.for(o)).set32(14,o.length).set32(18,o.length).set16(22,s.length);p+=c;let v=nh(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,s).bytes(c,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:s,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:b})=>46+b.length+v,0),e=nh(t+22),i=0;for(var{offset:s,name:o,header:c,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,c.array).set8(i+38,d?16:0).set32(i+42,s).bytes(i+46,o),i+=46+o.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};c2(Wo,"encoder",new TextEncoder);let ah=Wo;const oh=(n,t,e,i)=>{if(i){let{width:s,height:o}=n,c=Object.assign(document.createElement("canvas"),{width:s,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,s,o),d.drawImage(n,0,0),n=c}return new Promise((s,o)=>n.toBlob(s,t,e))},uA=(...n)=>oh(...n).then(t=>t.arrayBuffer()),fA=async(n,t,e,i,s)=>{Gf(s,await oh(n,t,e,i))},pA=async(n,t,e,i,s,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=Bf(s,".zip")||"archive",p=new ah(f);await Promise.all(n.map(async(g,v)=>{let b=d(v);await p.add(b,await oh(g,t,e,i))})),Gf(`${f}.zip`,p.blob)},Gf=(n,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",n),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var gA={asBuffer:uA,asDownload:fA,asZipDownload:pA,atScale:(n,t,e)=>n.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),o=s.getContext("2d"),c=i.canvas?i.canvas:i;return s.width=c.width*t,s.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,s.width,s.height)),o.scale(t,t),o.drawImage(c,0,0),s}),options:dA};const{asBuffer:lh,asDownload:mA,asZipDownload:vA,atScale:ch,options:hh}=gA,Vf=Symbol.for("toDataURL"),yA=n=>{let t=Object.assign(new Hf,{crossOrigin:"Anonymous",src:n});return t.decode().then(()=>t)};class bA{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>lh(i,"image/png"),jpg:()=>lh(i,"image/jpeg"),pages:()=>s.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:c});return Object.assign(i,{width:t,height:e,newPage(...d){var{width:p,height:g}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(i,0,0),s.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(i,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=hh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:b,quality:E,matte:k,density:w,archive:L}=p,x=ch(p.pages,w);return v==null?mA(x[0],b,E,k,d):vA(x,b,E,k,L,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=hh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:k}=p,w=ch(E,k,b)[0];return lh(w,g,v,b)},[Vf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=hh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:k}=p,w=ch(E,k,b)[0],L=w[w===i?Vf:"toDataURL"](g,v);return Promise.resolve(L)}})}}const{CanvasRenderingContext2D:AA,CanvasGradient:EA,CanvasPattern:kA,Image:Hf,ImageData:TA,Path2D:wA,DOMMatrix:SA,DOMRect:RA,DOMPoint:LA}=window;var Wf={Canvas:bA,loadImage:yA,CanvasRenderingContext2D:AA,CanvasGradient:EA,CanvasPattern:kA,Image:Hf,ImageData:TA,Path2D:wA,DOMMatrix:SA,DOMRect:RA,DOMPoint:LA};const jf=Yr({__proto__:null,default:Cl(Wf)},[Wf]);return Object.defineProperty(Ge,Symbol.toStringTag,{value:"Module"}),Ge}({});
1406
1527
  //# sourceMappingURL=embeds.iife.js.map