@vouchfor/embeds 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/es/{browser-11f53075.js → browser-e6172048.js} +2 -2
- package/dist/es/{browser-11f53075.js.map → browser-e6172048.js.map} +1 -1
- package/dist/es/embeds.js +1 -1
- package/dist/es/{index-f9437731.js → index-450872d3.js} +771 -771
- package/dist/es/index-450872d3.js.map +1 -0
- package/dist/iife/embeds.iife.js +79 -79
- package/dist/iife/embeds.iife.js.map +1 -1
- package/package.json +2 -2
- package/dist/es/index-f9437731.js.map +0 -1
package/dist/iife/embeds.iife.js
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
var
|
1
|
+
var _k=Object.defineProperty;var Lk=($e,Yr,Cr)=>Yr in $e?_k($e,Yr,{enumerable:!0,configurable:!0,writable:!0,value:Cr}):$e[Yr]=Cr;var A2=($e,Yr,Cr)=>(Lk($e,typeof Yr!="symbol"?Yr+"":Yr,Cr),Cr);var embeds=function($e){var rp;"use strict";function Yr(s,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in s)){const o=Object.getOwnPropertyDescriptor(i,n);o&&Object.defineProperty(s,n,o.get?o:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}/**
|
2
2
|
* @license
|
3
3
|
* Copyright 2019 Google LLC
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
5
|
-
*/const
|
5
|
+
*/const Cr=globalThis,ll=Cr.ShadowRoot&&(Cr.ShadyCSS===void 0||Cr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,jh=Symbol(),Kh=new WeakMap;let w2=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==jh)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(ll&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Kh.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Kh.set(e,t))}return t}toString(){return this.cssText}};const S2=s=>new w2(typeof s=="string"?s:s+"",void 0,jh),R2=(s,t)=>{if(ll)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=Cr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},zh=ll?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return S2(e)})(s):s;/**
|
6
6
|
* @license
|
7
7
|
* Copyright 2017 Google LLC
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
9
|
-
*/const{is:
|
9
|
+
*/const{is:_2,defineProperty:L2,getOwnPropertyDescriptor:C2,getOwnPropertyNames:I2,getOwnPropertySymbols:D2,getPrototypeOf:x2}=Object,us=globalThis,Yh=us.trustedTypes,P2=Yh?Yh.emptyScript:"",cl=us.reactiveElementPolyfillSupport,Wn=(s,t)=>s,Va={toAttribute(s,t){switch(t){case Boolean:s=s?P2:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},hl=(s,t)=>!_2(s,t),Xh={attribute:!0,type:String,converter:Va,reflect:!1,hasChanged:hl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),us.litPropertyMetadata??(us.litPropertyMetadata=new WeakMap);let jn=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=Xh){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&L2(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=C2(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return n==null?void 0:n.call(this)},set(c){const d=n==null?void 0:n.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Xh}static _$Ei(){if(this.hasOwnProperty(Wn("elementProperties")))return;const t=x2(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Wn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Wn("properties"))){const e=this.properties,i=[...I2(e),...D2(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(zh(n))}else t!==void 0&&e.push(zh(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 R2(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Va).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(n):this.setAttribute(n,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const c=i.getPropertyOptions(n),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Va;this._$Em=n,this[n]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??hl)(n?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 n=this.constructor.elementProperties;if(n.size>0)for(const[o,c]of n)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(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$E_)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}};jn.elementStyles=[],jn.shadowRootOptions={mode:"open"},jn[Wn("elementProperties")]=new Map,jn[Wn("finalized")]=new Map,cl==null||cl({ReactiveElement:jn}),(us.reactiveElementVersions??(us.reactiveElementVersions=[])).push("2.0.2");/**
|
10
10
|
* @license
|
11
11
|
* Copyright 2017 Google LLC
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
13
|
-
*/const Kn=globalThis,Ha=Kn.trustedTypes,Zh=Ha?Ha.createPolicy("lit-html",{createHTML:s=>s}):void 0,dl="$lit$",
|
13
|
+
*/const Kn=globalThis,Ha=Kn.trustedTypes,Zh=Ha?Ha.createPolicy("lit-html",{createHTML:s=>s}):void 0,dl="$lit$",Xr=`lit$${(Math.random()+"").slice(9)}$`,ul="?"+Xr,O2=`<${ul}>`,Vs=document,Wa=()=>Vs.createComment(""),zn=s=>s===null||typeof s!="object"&&typeof s!="function",qh=Array.isArray,Qh=s=>qh(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",fl=`[
|
14
14
|
\f\r]`,Yn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Jh=/-->/g,td=/>/g,Hs=RegExp(`>|${fl}(?:([^\\s"'>=/]+)(${fl}*=${fl}*(?:[^
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),ed=/'/g,id=/"/g,rd=/^(?:script|style|textarea|title)$/i,fs=Symbol.for("lit-noChange"),ri=Symbol.for("lit-nothing"),sd=new WeakMap,Ws=Vs.createTreeWalker(Vs,129);function nd(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zh!==void 0?Zh.createHTML(t):t}const ad=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",c=Yn;for(let d=0;d<e;d++){const f=s[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===Yn?g[1]==="!--"?c=Jh:g[1]!==void 0?c=td:g[2]!==void 0?(rd.test(g[2])&&(n=RegExp("</"+g[2],"g")),c=Hs):g[3]!==void 0&&(c=Hs):c===Hs?g[0]===">"?(c=n??Yn,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]==='"'?id:ed):c===id||c===ed?c=Hs:c===Jh||c===td?c=Yn:(c=Hs,n=void 0);const E=c===Hs&&s[d+1].startsWith("/>")?" ":"";o+=c===Yn?f+O2:v>=0?(i.push(p),f.slice(0,v)+dl+f.slice(v)+
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),ed=/'/g,id=/"/g,rd=/^(?:script|style|textarea|title)$/i,fs=Symbol.for("lit-noChange"),ri=Symbol.for("lit-nothing"),sd=new WeakMap,Ws=Vs.createTreeWalker(Vs,129);function nd(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zh!==void 0?Zh.createHTML(t):t}const ad=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",c=Yn;for(let d=0;d<e;d++){const f=s[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===Yn?g[1]==="!--"?c=Jh:g[1]!==void 0?c=td:g[2]!==void 0?(rd.test(g[2])&&(n=RegExp("</"+g[2],"g")),c=Hs):g[3]!==void 0&&(c=Hs):c===Hs?g[0]===">"?(c=n??Yn,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]==='"'?id:ed):c===id||c===ed?c=Hs:c===Jh||c===td?c=Yn:(c=Hs,n=void 0);const E=c===Hs&&s[d+1].startsWith("/>")?" ":"";o+=c===Yn?f+O2:v>=0?(i.push(p),f.slice(0,v)+dl+f.slice(v)+Xr+E):f+Xr+(v===-2?d:E)}return[nd(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};let pl=class E2{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=ad(t,e);if(this.el=E2.createElement(p,i),Ws.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Ws.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(dl)){const A=g[c++],E=n.getAttribute(v).split(Xr),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?ld:T[1]==="?"?cd:T[1]==="@"?hd:Xn}),n.removeAttribute(v)}else v.startsWith(Xr)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(rd.test(n.tagName)){const v=n.textContent.split(Xr),A=v.length-1;if(A>0){n.textContent=Ha?Ha.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],Wa()),Ws.nextNode(),f.push({type:2,index:++o});n.append(v[A],Wa())}}}else if(n.nodeType===8)if(n.data===ul)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(Xr,v+1))!==-1;)f.push({type:7,index:o}),v+=Xr.length-1}o++}}static createElement(t,e){const i=Vs.createElement("template");return i.innerHTML=t,i}};function js(s,t,e=s,i){var c,d;if(t===fs)return t;let n=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=zn(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=js(s,n._$AS(s,t.values),n,i)),t}let od=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,n=((t==null?void 0:t.creationScope)??Vs).importNode(e,!0);Ws.currentNode=n;let o=Ws.nextNode(),c=0,d=0,f=i[0];for(;f!==void 0;){if(c===f.index){let p;f.type===2?p=new gl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new dd(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Ws.nextNode(),c++)}return Ws.currentNode=Vs,n}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++}},gl=class T2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=ri,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=js(this,t,e),zn(t)?t===ri||t==null||t===""?(this._$AH!==ri&&this._$AR(),this._$AH=ri):t!==this._$AH&&t!==fs&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):Qh(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!==ri&&zn(this._$AH)?this._$AA.nextSibling.data=t:this.$(Vs.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=pl.createElement(nd(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const c=new od(n,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=sd.get(t.strings);return e===void 0&&sd.set(t.strings,e=new pl(t)),e}T(t){qh(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new T2(this.k(Wa()),this.k(Wa()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}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,n,o){this.type=1,this._$AH=ri,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ri}_$AI(t,e=this,i,n){const o=this.strings;let c=!1;if(o===void 0)t=js(this,t,e,0),c=!zn(t)||t!==this._$AH&&t!==fs,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=js(this,d[i+f],e,f),p===fs&&(p=this._$AH[f]),c||(c=!zn(p)||p!==this._$AH[f]),p===ri?t=ri:t!==ri&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!n&&this.O(t)}O(t){t===ri?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},ld=class extends Xn{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===ri?void 0:t}},cd=class extends Xn{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==ri)}},hd=class extends Xn{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=js(this,t,e,0)??ri)===fs)return;const i=this._$AH,n=t===ri&&i!==ri||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==ri&&(i===ri||n);n&&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)}},dd=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){js(this,t)}};const M2={j:dl,P:Xr,A:ul,C:1,M:ad,L:od,R:Qh,V:js,D:gl,I:Xn,H:cd,N:hd,U:ld,B:dd},ml=Kn.litHtmlPolyfillSupport;ml==null||ml(pl,gl),(Kn.litHtmlVersions??(Kn.litHtmlVersions=[])).push("3.1.0");/**
|
16
16
|
* @license
|
17
17
|
* Copyright 2019 Google LLC
|
18
18
|
* SPDX-License-Identifier: BSD-3-Clause
|
19
|
-
*/const ja=globalThis,vl=ja.ShadowRoot&&(ja.ShadyCSS===void 0||ja.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,yl=Symbol(),ud=new WeakMap;let fd=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==yl)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(vl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ud.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ud.set(e,t))}return t}toString(){return this.cssText}};const Zn=s=>new fd(typeof s=="string"?s:s+"",void 0,yl),
|
19
|
+
*/const ja=globalThis,vl=ja.ShadowRoot&&(ja.ShadyCSS===void 0||ja.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,yl=Symbol(),ud=new WeakMap;let fd=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==yl)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(vl&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=ud.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&ud.set(e,t))}return t}toString(){return this.cssText}};const Zn=s=>new fd(typeof s=="string"?s:s+"",void 0,yl),Ti=(s,...t)=>{const e=s.length===1?s[0]:t.reduce((i,n,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.")})(n)+s[o+1],s[0]);return new fd(e,s,yl)},$2=(s,t)=>{if(vl)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=ja.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},pd=vl?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return Zn(e)})(s):s;/**
|
20
20
|
* @license
|
21
21
|
* Copyright 2017 Google LLC
|
22
22
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -26,7 +26,7 @@ var Lk=Object.defineProperty;var _k=($e,zr,_r)=>zr in $e?Lk($e,zr,{enumerable:!0
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
27
27
|
*/const Qn=globalThis,Ka=Qn.trustedTypes,yd=Ka?Ka.createPolicy("lit-html",{createHTML:s=>s}):void 0,bd="$lit$",gs=`lit$${(Math.random()+"").slice(9)}$`,Ad="?"+gs,W2=`<${Ad}>`,Ks=document,Jn=()=>Ks.createComment(""),ta=s=>s===null||typeof s!="object"&&typeof s!="function",Ed=Array.isArray,j2=s=>Ed(s)||typeof(s==null?void 0:s[Symbol.iterator])=="function",El=`[
|
28
28
|
\f\r]`,ea=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Td=/-->/g,kd=/>/g,zs=RegExp(`>|${El}(?:([^\\s"'>=/]+)(${El}*=${El}*(?:[^
|
29
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),wd=/'/g,Sd=/"/g,Rd=/^(?:script|style|textarea|title)$/i,K2=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),te=K2(1),ms=Symbol.for("lit-noChange"),pi=Symbol.for("lit-nothing"),
|
29
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),wd=/'/g,Sd=/"/g,Rd=/^(?:script|style|textarea|title)$/i,K2=s=>(t,...e)=>({_$litType$:s,strings:t,values:e}),te=K2(1),ms=Symbol.for("lit-noChange"),pi=Symbol.for("lit-nothing"),_d=new WeakMap,Ys=Ks.createTreeWalker(Ks,129);function Ld(s,t){if(!Array.isArray(s)||!s.hasOwnProperty("raw"))throw Error("invalid template strings array");return yd!==void 0?yd.createHTML(t):t}const z2=(s,t)=>{const e=s.length-1,i=[];let n,o=t===2?"<svg>":"",c=ea;for(let d=0;d<e;d++){const f=s[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===ea?g[1]==="!--"?c=Td:g[1]!==void 0?c=kd:g[2]!==void 0?(Rd.test(g[2])&&(n=RegExp("</"+g[2],"g")),c=zs):g[3]!==void 0&&(c=zs):c===zs?g[0]===">"?(c=n??ea,v=-1):g[1]===void 0?v=-2:(v=c.lastIndex-g[2].length,p=g[1],c=g[3]===void 0?zs:g[3]==='"'?Sd:wd):c===Sd||c===wd?c=zs:c===Td||c===kd?c=ea:(c=zs,n=void 0);const E=c===zs&&s[d+1].startsWith("/>")?" ":"";o+=c===ea?f+W2:v>=0?(i.push(p),f.slice(0,v)+bd+f.slice(v)+gs+E):f+gs+(v===-2?d:E)}return[Ld(s,o+(s[e]||"<?>")+(t===2?"</svg>":"")),i]};class ia{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let o=0,c=0;const d=t.length-1,f=this.parts,[p,g]=z2(t,e);if(this.el=ia.createElement(p,i),Ys.currentNode=this.el.content,e===2){const v=this.el.content.firstChild;v.replaceWith(...v.childNodes)}for(;(n=Ys.nextNode())!==null&&f.length<d;){if(n.nodeType===1){if(n.hasAttributes())for(const v of n.getAttributeNames())if(v.endsWith(bd)){const A=g[c++],E=n.getAttribute(v).split(gs),T=/([.?@])?(.*)/.exec(A);f.push({type:1,index:o,name:T[2],strings:E,ctor:T[1]==="."?X2:T[1]==="?"?Z2:T[1]==="@"?q2:za}),n.removeAttribute(v)}else v.startsWith(gs)&&(f.push({type:6,index:o}),n.removeAttribute(v));if(Rd.test(n.tagName)){const v=n.textContent.split(gs),A=v.length-1;if(A>0){n.textContent=Ka?Ka.emptyScript:"";for(let E=0;E<A;E++)n.append(v[E],Jn()),Ys.nextNode(),f.push({type:2,index:++o});n.append(v[A],Jn())}}}else if(n.nodeType===8)if(n.data===Ad)f.push({type:2,index:o});else{let v=-1;for(;(v=n.data.indexOf(gs,v+1))!==-1;)f.push({type:7,index:o}),v+=gs.length-1}o++}}static createElement(t,e){const i=Ks.createElement("template");return i.innerHTML=t,i}}function mn(s,t,e=s,i){var c,d;if(t===ms)return t;let n=i!==void 0?(c=e._$Co)==null?void 0:c[i]:e._$Cl;const o=ta(t)?void 0:t._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((d=n==null?void 0:n._$AO)==null||d.call(n,!1),o===void 0?n=void 0:(n=new o(s),n._$AT(s,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=n:e._$Cl=n),n!==void 0&&(t=mn(s,n._$AS(s,t.values),n,i)),t}let Y2=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,n=((t==null?void 0:t.creationScope)??Ks).importNode(e,!0);Ys.currentNode=n;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 Tl(o,o.nextSibling,this,t):f.type===1?p=new f.ctor(o,f.name,f.strings,this,t):f.type===6&&(p=new Q2(o,this,t)),this._$AV.push(p),f=i[++d]}c!==(f==null?void 0:f.index)&&(o=Ys.nextNode(),c++)}return Ys.currentNode=Ks,n}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++}},Tl=class k2{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,n){this.type=2,this._$AH=pi,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.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=mn(this,t,e),ta(t)?t===pi||t==null||t===""?(this._$AH!==pi&&this._$AR(),this._$AH=pi):t!==this._$AH&&t!==ms&&this._(t):t._$litType$!==void 0?this.g(t):t.nodeType!==void 0?this.$(t):j2(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!==pi&&ta(this._$AH)?this._$AA.nextSibling.data=t:this.$(Ks.createTextNode(t)),this._$AH=t}g(t){var o;const{values:e,_$litType$:i}=t,n=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=ia.createElement(Ld(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(e);else{const c=new Y2(n,this),d=c.u(this.options);c.p(e),this.$(d),this._$AH=c}}_$AC(t){let e=_d.get(t.strings);return e===void 0&&_d.set(t.strings,e=new ia(t)),e}T(t){Ed(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const o of t)n===e.length?e.push(i=new k2(this.k(Jn()),this.k(Jn()),this,this.options)):i=e[n],i._$AI(o),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$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 n=t.nextSibling;t.remove(),t=n}}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,n,o){this.type=1,this._$AH=pi,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=pi}_$AI(t,e=this,i,n){const o=this.strings;let c=!1;if(o===void 0)t=mn(this,t,e,0),c=!ta(t)||t!==this._$AH&&t!==ms,c&&(this._$AH=t);else{const d=t;let f,p;for(t=o[0],f=0;f<o.length-1;f++)p=mn(this,d[i+f],e,f),p===ms&&(p=this._$AH[f]),c||(c=!ta(p)||p!==this._$AH[f]),p===pi?t=pi:t!==pi&&(t+=(p??"")+o[f+1]),this._$AH[f]=p}c&&!n&&this.O(t)}O(t){t===pi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class X2 extends za{constructor(){super(...arguments),this.type=3}O(t){this.element[this.name]=t===pi?void 0:t}}let Z2=class extends za{constructor(){super(...arguments),this.type=4}O(t){this.element.toggleAttribute(this.name,!!t&&t!==pi)}};class q2 extends za{constructor(t,e,i,n,o){super(t,e,i,n,o),this.type=5}_$AI(t,e=this){if((t=mn(this,t,e,0)??pi)===ms)return;const i=this._$AH,n=t===pi&&i!==pi||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==pi&&(i===pi||n);n&&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 Q2=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){mn(this,t)}};const kl=Qn.litHtmlPolyfillSupport;kl==null||kl(ia,Tl),(Qn.litHtmlVersions??(Qn.litHtmlVersions=[])).push("3.1.0");const J2=(s,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let n=i._$litPart$;if(n===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=n=new Tl(t.insertBefore(Jn(),o),o,void 0,e??{})}return n._$AI(s),n};/**
|
30
30
|
* @license
|
31
31
|
* Copyright 2017 Google LLC
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -42,7 +42,7 @@ var Lk=Object.defineProperty;var _k=($e,zr,_r)=>zr in $e?Lk($e,zr,{enumerable:!0
|
|
42
42
|
* @license
|
43
43
|
* Copyright 2017 Google LLC
|
44
44
|
* SPDX-License-Identifier: BSD-3-Clause
|
45
|
-
*/function
|
45
|
+
*/function ki(s){return Dt({...s,state:!0,attribute:!1})}/**
|
46
46
|
* @license
|
47
47
|
* Copyright 2018 Google LLC
|
48
48
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -62,32 +62,32 @@ var Lk=Object.defineProperty;var _k=($e,zr,_r)=>zr in $e?Lk($e,zr,{enumerable:!0
|
|
62
62
|
* @license
|
63
63
|
* Copyright 2020 Google LLC
|
64
64
|
* SPDX-License-Identifier: BSD-3-Clause
|
65
|
-
*/const Li=()=>new dg;let dg=class{};const Rl=new WeakMap,
|
65
|
+
*/const Li=()=>new dg;let dg=class{};const Rl=new WeakMap,Ci=bn(class extends Dd{render(s){return ri}update(s,[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=s.options)==null?void 0:i.host,this.ot(this.lt=s.element)),ri}ot(s){if(typeof this.G=="function"){const t=this.ct??globalThis;let e=Rl.get(t);e===void 0&&(e=new WeakMap,Rl.set(t,e)),e.get(this.G)!==void 0&&this.G.call(this.ct,void 0),e.set(this.G,s),s!==void 0&&this.G.call(this.ct,s)}else this.G.value=s}get rt(){var s,t;return typeof this.G=="function"?(s=Rl.get(this.ct??globalThis))==null?void 0:s.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 ug(s,t,e){function i(n){e.dispatchEvent(new CustomEvent(n.type,n))}return t.addEventListener(s,i),()=>{t.removeEventListener(s,i)}}class fg{constructor(t,e){this._events=[],this._cleanup=[],this._forwardElementRef=Li(),this.host=t,this._events=e,t.addController(this)}register(){return Ci(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(t=>{this._forwardElementRef.value&&this._cleanup.push(ug(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 Xa=globalThis,
|
69
|
+
*/const Xa=globalThis,_l=Xa.ShadowRoot&&(Xa.ShadyCSS===void 0||Xa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,xd=Symbol(),Pd=new WeakMap;let pg=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==xd)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(_l&&t===void 0){const i=e!==void 0&&e.length===1;i&&(t=Pd.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&Pd.set(e,t))}return t}toString(){return this.cssText}};const gg=s=>new pg(typeof s=="string"?s:s+"",void 0,xd),mg=(s,t)=>{if(_l)s.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const i=document.createElement("style"),n=Xa.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=e.cssText,s.appendChild(i)}},Od=_l?s=>s:s=>s instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return gg(e)})(s):s;/**
|
70
70
|
* @license
|
71
71
|
* Copyright 2017 Google LLC
|
72
72
|
* SPDX-License-Identifier: BSD-3-Clause
|
73
|
-
*/const{is:vg,defineProperty:yg,getOwnPropertyDescriptor:bg,getOwnPropertyNames:Ag,getOwnPropertySymbols:Eg,getPrototypeOf:Tg}=Object,vs=globalThis,Md=vs.trustedTypes,kg=Md?Md.emptyScript:"",
|
73
|
+
*/const{is:vg,defineProperty:yg,getOwnPropertyDescriptor:bg,getOwnPropertyNames:Ag,getOwnPropertySymbols:Eg,getPrototypeOf:Tg}=Object,vs=globalThis,Md=vs.trustedTypes,kg=Md?Md.emptyScript:"",Ll=vs.reactiveElementPolyfillSupport,aa=(s,t)=>s,Cl={toAttribute(s,t){switch(t){case Boolean:s=s?kg:null;break;case Object:case Array:s=s==null?s:JSON.stringify(s)}return s},fromAttribute(s,t){let e=s;switch(t){case Boolean:e=s!==null;break;case Number:e=s===null?null:Number(s);break;case Object:case Array:try{e=JSON.parse(s)}catch{e=null}}return e}},Il=(s,t)=>!vg(s,t),$d={attribute:!0,type:String,converter:Cl,reflect:!1,hasChanged:Il};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),vs.litPropertyMetadata??(vs.litPropertyMetadata=new WeakMap);class oa 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=$d){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(t,i,e);n!==void 0&&yg(this.prototype,t,n)}}static getPropertyDescriptor(t,e,i){const{get:n,set:o}=bg(this.prototype,t)??{get(){return this[e]},set(c){this[e]=c}};return{get(){return n==null?void 0:n.call(this)},set(c){const d=n==null?void 0:n.call(this);o.call(this,c),this.requestUpdate(t,d,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??$d}static _$Ei(){if(this.hasOwnProperty(aa("elementProperties")))return;const t=Tg(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(aa("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(aa("properties"))){const e=this.properties,i=[...Ag(e),...Eg(e)];for(const n of i)this.createProperty(n,e[n])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,n]of e)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const n=this._$Eu(e,i);n!==void 0&&this._$Eh.set(n,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 n of i)e.unshift(Od(n))}else t!==void 0&&e.push(Od(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 mg(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),n=this.constructor._$Eu(t,i);if(n!==void 0&&i.reflect===!0){const c=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:Cl).toAttribute(e,i.type);this._$Em=t,c==null?this.removeAttribute(n):this.setAttribute(n,c),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,n=i._$Eh.get(t);if(n!==void 0&&this._$Em!==n){const c=i.getPropertyOptions(n),d=typeof c.converter=="function"?{fromAttribute:c.converter}:((o=c.converter)==null?void 0:o.fromAttribute)!==void 0?c.converter:Cl;this._$Em=n,this[n]=d.fromAttribute(e,c.type),this._$Em=null}}requestUpdate(t,e,i,n=!1,o){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??Il)(n?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 n=this.constructor.elementProperties;if(n.size>0)for(const[o,c]of n)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(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(e)):this._$ET()}catch(n){throw t=!1,this._$ET(),n}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$ES)==null||e.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.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){}}oa.elementStyles=[],oa.shadowRootOptions={mode:"open"},oa[aa("elementProperties")]=new Map,oa[aa("finalized")]=new Map,Ll==null||Ll({ReactiveElement:oa}),(vs.reactiveElementVersions??(vs.reactiveElementVersions=[])).push("2.0.0");/**
|
74
74
|
* @license
|
75
75
|
* Copyright 2017 Google LLC
|
76
76
|
* SPDX-License-Identifier: BSD-3-Clause
|
77
|
-
*/const wg=Symbol();class Za{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 n=typeof e=="object"?e:{task:e,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??Sg,this.m=n.onComplete,this.g=n.onError,this.autoRun=n.autoRun??!0,"initialValue"in n&&(this.l=n.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 n=++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===n){if(e===wg)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,n,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(n=t.complete)==null?void 0:n.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=(s,t)=>s===t||s.length===t.length&&s.every((e,i)=>!Il(e,t[i]));let qa;const Rg=new Uint8Array(16);function
|
78
|
-
${t}`,Vg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Hg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Wg=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=Gg.bind(null,i,t.toString());Object.defineProperty(n,"name",Hg),Object.defineProperty(s,"toString",{...Vg,value:n})};function jg(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))Ng(s,t,n,e);return Bg(s,t),Wg(s,t,i),s}const Kg=new WeakMap;function ys(s,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,n=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 s.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return jg(n,s,{ignoreNonConfigurable:!0}),Kg.set(n,e),n}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dl(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xl={exports:{}};(function(s,t){(function(e,i){i(t)})(Ja,function(e){function i(F){var N,j,nt=new Error(F);return N=nt,j=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j,nt}function n(F,N,j){var nt=N.slice(0,j).split(/\n/),
|
79
|
-
|
80
|
-
`+N.split(/\n/)[
|
81
|
-
`+Array(
|
82
|
-
`).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,A.lastIndex=0;var j=N.prefixes,nt=[j.h,j.b,j.i,j.r,j.c,j.e].reduce(function(Re,Kt){return Re&&Kt?Re+"|"+T(Kt):Kt?T(Kt):Re},""),
|
83
|
-
`)}}return
|
84
|
-
|
85
|
-
`+
|
86
|
-
`+Array(
|
87
|
-
`+C(F,j)):
|
88
|
-
`)===0?F.substr(1,F.length):F}).forEach(function(F){var N=F.split(":"),j=N.shift().trim();if(j){var nt=N.join(":").trim();q.append(j,nt)}}),q}$.call(at.prototype);function vt(U,q){if(!(this instanceof vt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q||(q={}),this.type="default",this.status=q.status===void 0?200:q.status,this.ok=this.status>=200&&this.status<300,this.statusText=q.statusText===void 0?"":""+q.statusText,this.headers=new w(q.headers),this.url=q.url||"",this._initBody(U)}$.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 U=new vt(null,{status:0,statusText:""});return U.type="error",U};var Ot=[301,302,303,307,308];vt.redirect=function(U,q){if(Ot.indexOf(q)===-1)throw new RangeError("Invalid status code");return new vt(null,{status:q,headers:{location:U}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(q,At){this.message=q,this.name=At;var F=Error(q);this.stack=F.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Gt(U,q){return new Promise(function(At,F){var N=new at(U,q);if(N.signal&&N.signal.aborted)return F(new c.DOMException("Aborted","AbortError"));var j=new XMLHttpRequest;function nt(){j.abort()}j.onload=function(){var
|
89
|
-
${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),sm=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=em.bind(null,i,t.toString());Object.defineProperty(n,"name",rm),Object.defineProperty(s,"toString",{...im,value:n})};function nm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))Qg(s,t,n,e);return tm(s,t),sm(s,t,i),s}const am=new WeakMap,Gd=new WeakMap;function Vd(s,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return s;if(typeof i=="number"){if(i>2147483647)throw new TypeError("The `maxAge` option cannot exceed 2147483647.");if(i<0)throw new TypeError("The `maxAge` option should not be a negative number.")}const n=function(...o){var c;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=s.apply(this,o);if(e.set(d,{data:p,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},i);(c=g.unref)==null||c.call(g);const v=Gd.get(s)??new Set;v.add(g),Gd.set(s,v)}return p};return nm(n,s,{ignoreNonConfigurable:!0}),am.set(n,e),n}function Hd({context:s,word:t,maxW:e=1/0}){const i=[],n=s.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const c=i[i.length-1],d=((c==null?void 0:c.text)??"")+t[o],f=s.measureText(d);f.width<e?i[c?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:s.measureText(t[o])})}return i}const Wd=Vd(({font:s,scale:t,context:e,maxW:i,maxH:n,text:o,minSize:c,maxSize:d})=>{var f,p;let g=0;if(d){g=(c??0)*t;let v=0;for(;d*t>g+1;){g+=1;const A=uo({context:e,font:s,fontSize:g,text:o,maxW:i});if(v=A.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||A.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=s.match(ho))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:s,text:t,minSize:e,maxSize:i,scale:n,maxW:o,maxH:c}])=>`${s}_${t}_${e}_${i}_${n}_${o}_${c}`});function om(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ee={},$l={},ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.default=ie.Wrap=ie.Unit=ie.PrintOptions=ie.PositionType=ie.Overflow=ie.NodeType=ie.MeasureMode=ie.LogLevel=ie.Justify=ie.Gutter=ie.FlexDirection=ie.ExperimentalFeature=ie.Errata=ie.Edge=ie.Display=ie.Direction=ie.Dimension=ie.Align=void 0;let Xr=function(s){return s[s.Auto=0]="Auto",s[s.FlexStart=1]="FlexStart",s[s.Center=2]="Center",s[s.FlexEnd=3]="FlexEnd",s[s.Stretch=4]="Stretch",s[s.Baseline=5]="Baseline",s[s.SpaceBetween=6]="SpaceBetween",s[s.SpaceAround=7]="SpaceAround",s}({});ie.Align=Xr;let Fl=function(s){return s[s.Width=0]="Width",s[s.Height=1]="Height",s}({});ie.Dimension=Fl;let eo=function(s){return s[s.Inherit=0]="Inherit",s[s.LTR=1]="LTR",s[s.RTL=2]="RTL",s}({});ie.Direction=eo;let Nl=function(s){return s[s.Flex=0]="Flex",s[s.None=1]="None",s}({});ie.Display=Nl;let Cr=function(s){return s[s.Left=0]="Left",s[s.Top=1]="Top",s[s.Right=2]="Right",s[s.Bottom=3]="Bottom",s[s.Start=4]="Start",s[s.End=5]="End",s[s.Horizontal=6]="Horizontal",s[s.Vertical=7]="Vertical",s[s.All=8]="All",s}({});ie.Edge=Cr;let ca=function(s){return s[s.None=0]="None",s[s.StretchFlexBasis=1]="StretchFlexBasis",s[s.All=2147483647]="All",s[s.Classic=2147483646]="Classic",s}({});ie.Errata=ca;let io=function(s){return s[s.WebFlexBasis=0]="WebFlexBasis",s[s.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",s[s.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",s}({});ie.ExperimentalFeature=io;let ha=function(s){return s[s.Column=0]="Column",s[s.ColumnReverse=1]="ColumnReverse",s[s.Row=2]="Row",s[s.RowReverse=3]="RowReverse",s}({});ie.FlexDirection=ha;let ro=function(s){return s[s.Column=0]="Column",s[s.Row=1]="Row",s[s.All=2]="All",s}({});ie.Gutter=ro;let Qs=function(s){return s[s.FlexStart=0]="FlexStart",s[s.Center=1]="Center",s[s.FlexEnd=2]="FlexEnd",s[s.SpaceBetween=3]="SpaceBetween",s[s.SpaceAround=4]="SpaceAround",s[s.SpaceEvenly=5]="SpaceEvenly",s}({});ie.Justify=Qs;let Js=function(s){return s[s.Error=0]="Error",s[s.Warn=1]="Warn",s[s.Info=2]="Info",s[s.Debug=3]="Debug",s[s.Verbose=4]="Verbose",s[s.Fatal=5]="Fatal",s}({});ie.LogLevel=Js;let so=function(s){return s[s.Undefined=0]="Undefined",s[s.Exactly=1]="Exactly",s[s.AtMost=2]="AtMost",s}({});ie.MeasureMode=so;let Ul=function(s){return s[s.Default=0]="Default",s[s.Text=1]="Text",s}({});ie.NodeType=Ul;let no=function(s){return s[s.Visible=0]="Visible",s[s.Hidden=1]="Hidden",s[s.Scroll=2]="Scroll",s}({});ie.Overflow=no;let ao=function(s){return s[s.Static=0]="Static",s[s.Relative=1]="Relative",s[s.Absolute=2]="Absolute",s}({});ie.PositionType=ao;let oo=function(s){return s[s.Layout=1]="Layout",s[s.Style=2]="Style",s[s.Children=4]="Children",s}({});ie.PrintOptions=oo;let da=function(s){return s[s.Undefined=0]="Undefined",s[s.Point=1]="Point",s[s.Percent=2]="Percent",s[s.Auto=3]="Auto",s}({});ie.Unit=da;let lo=function(s){return s[s.NoWrap=0]="NoWrap",s[s.Wrap=1]="Wrap",s[s.WrapReverse=2]="WrapReverse",s}({});ie.Wrap=lo;var lm={ALIGN_AUTO:Xr.Auto,ALIGN_FLEX_START:Xr.FlexStart,ALIGN_CENTER:Xr.Center,ALIGN_FLEX_END:Xr.FlexEnd,ALIGN_STRETCH:Xr.Stretch,ALIGN_BASELINE:Xr.Baseline,ALIGN_SPACE_BETWEEN:Xr.SpaceBetween,ALIGN_SPACE_AROUND:Xr.SpaceAround,DIMENSION_WIDTH:Fl.Width,DIMENSION_HEIGHT:Fl.Height,DIRECTION_INHERIT:eo.Inherit,DIRECTION_LTR:eo.LTR,DIRECTION_RTL:eo.RTL,DISPLAY_FLEX:Nl.Flex,DISPLAY_NONE:Nl.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:ca.None,ERRATA_STRETCH_FLEX_BASIS:ca.StretchFlexBasis,ERRATA_ALL:ca.All,ERRATA_CLASSIC:ca.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:ha.Column,FLEX_DIRECTION_COLUMN_REVERSE:ha.ColumnReverse,FLEX_DIRECTION_ROW:ha.Row,FLEX_DIRECTION_ROW_REVERSE:ha.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:Ul.Default,NODE_TYPE_TEXT:Ul.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:da.Undefined,UNIT_POINT:da.Point,UNIT_PERCENT:da.Percent,UNIT_AUTO:da.Auto,WRAP_NO_WRAP:lo.NoWrap,WRAP_WRAP:lo.Wrap,WRAP_WRAP_REVERSE:lo.WrapReverse};ie.default=lm,Object.defineProperty($l,"__esModule",{value:!0}),$l.default=hm;var bs=cm(ie);function jd(s){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(jd=function(i){return i?e:t})(s)}function cm(s,t){if(!t&&s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var e=jd(t);if(e&&e.has(s))return e.get(s);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in s)if(o!=="default"&&Object.prototype.hasOwnProperty.call(s,o)){var c=n?Object.getOwnPropertyDescriptor(s,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=s[o]}return i.default=s,e&&e.set(s,i),i}function hm(s){function t(n,o,c){const d=n[o];n[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 n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[bs.Unit.Point]:s.Node.prototype[n],[bs.Unit.Percent]:s.Node.prototype[`${n}Percent`],[bs.Unit.Auto]:s.Node.prototype[`${n}Auto`]};t(s.Node.prototype,n,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=bs.Unit.Auto,A=void 0;else if(typeof g=="object")v=g.unit,A=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?bs.Unit.Percent:bs.Unit.Point,A=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(A))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return A!==void 0?o[v].call(this,...f,A):o[v].call(this,...f)})}function e(n){return s.MeasureCallback.implement({measure:function(){const{width:o,height:c}=n(...arguments);return{width:o??NaN,height:c??NaN}}})}t(s.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function i(n){return s.DirtiedCallback.implement({dirtied:n})}return t(s.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,i(o))}),t(s.Config.prototype,"free",function(){s.Config.destroy(this)}),t(s.Node,"create",(n,o)=>o?s.Node.createWithConfig(o):s.Node.createDefault()),t(s.Node.prototype,"free",function(){s.Node.destroy(this)}),t(s.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(s.Node.prototype,"calculateLayout",function(n){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]:bs.Direction.LTR;return n.call(this,o,c,d)}),{Config:s.Config,Node:s.Node,...bs.default}}var Kd={exports:{}};(function(s,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var c,d;o.ready=new Promise(function(L,_){c=L,d=_});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 E(){this.buffer=new ArrayBuffer(U/65536*65536)}function T(){}function w(L){this.exports=function(_){function G(ni){return ni.set=function(ne,sr){this[ne]=sr},ni.get=function(ne){return this[ne]},ni}for(var H,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function ct(ni,ne,sr){for(var Ui,gt,Nr=0,l=ne,Et=sr.length,$n=ne+(Et*3>>2)-(sr[Et-2]=="=")-(sr[Et-1]=="=");Nr<Et;Nr+=4)Ui=rt[sr.charCodeAt(Nr+1)],gt=rt[sr.charCodeAt(Nr+2)],ni[l++]=rt[sr.charCodeAt(Nr)]<<2|Ui>>4,l<$n&&(ni[l++]=Ui<<4|gt>>2),l<$n&&(ni[l++]=gt<<6|rt[sr.charCodeAt(Nr+3)])}function Rt(ni){ct(H,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),ct(H,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),ct(H,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),ct(H,4432,"xwAAAMgAAADJ"),ct(H,4452,"xwAAAMoAAADLAAAArBs="),ct(H,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),ct(H,4552,"zAAAAM0AAADO"),ct(H,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),ct(H,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),ct(H,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),ct(H,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),ct(H,5179,"DA=="),ct(H,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),ct(H,5237,"EA=="),ct(H,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),ct(H,5295,"Eg=="),ct(H,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),ct(H,5362,"GgAAABoaGgAAAAAAAAk="),ct(H,5411,"FA=="),ct(H,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),ct(H,5469,"Fg=="),ct(H,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),ct(H,5556,"1Q=="),ct(H,5596,"//////////8="),ct(H,5664,"8B8BAAAAAAAF"),ct(H,5684,"0A=="),ct(H,5708,"0QAAANIAAADUGw=="),ct(H,5732,"Ag=="),ct(H,5748,"//////////8="),ct(H,5816,"BQ=="),ct(H,5828,"0w=="),ct(H,5852,"0QAAANQAAADoGwAAAAQ="),ct(H,5876,"AQ=="),ct(H,5892,"/////wo="),ct(H,5960,"1g==")}var Ct=new ArrayBuffer(16),It=new Int32Array(Ct),Ft=new Float32Array(Ct),zt=new Float64Array(Ct);function Jt(ni){return It[ni]}function xt(ni,ne){It[ni]=ne}function Ae(){return zt[0]}function vi(ni){zt[0]=ni}function le(){throw new Error("abort")}function qi(ni){Ft[2]=ni}function Bt(){return Ft[2]}function Qo(ni){var ne=ni.a,sr=ne.a,Ui=sr.buffer;sr.grow=Rk;var gt=new Int8Array(Ui),Nr=new Int16Array(Ui),l=new Int32Array(Ui),Et=new Uint8Array(Ui),$n=new Uint16Array(Ui),hp=new Uint32Array(Ui),I=new Float32Array(Ui),Ve=new Float64Array(Ui),He=Math.imul,m=Math.fround,Ye=Math.abs,vr=Math.clz32,TE=Math.min,kE=Math.max,Yt=NaN,dp=1/0,St=ne.b,Ri=ne.c,os=ne.d,ls=ne.e,xs=ne.f,Fn=ne.g,Oa=ne.h,Jo=ne.i,Th=ne.j,kh=ne.k,wh=ne.l,up=ne.m,fp=ne.n,pp=ne.o,gp=ne.p,mp=ne.q,wE=ne.r,SE=ne.s,RE=ne.t,LE=ne.u,_E=ne.v,CE=ne.w,IE=ne.x,DE=ne.y,xE=ne.z,PE=ne.A,OE=ne.B,ME=ne.C,$E=ne.D,Tt=73712,Bi=0;function vp(r,a,h,u,y,b,k,S,P,K,tt,ft,Q,et){var M=0,W=m(0),Y=0,Z=m(0),ot=0,lt=m(0),mt=0,bt=m(0),Lt=0,Mt=0,$t=m(0),Ht=0,Zt=0,re=m(0),pe=m(0),_e=m(0),xe=m(0),Me=0,We=m(0),Ze=m(0),ai=0,oi=0,Ai=m(0),Mi=0,Ji=0,$i=0,Hi=0,tr=m(0),er=0,Rr=0,Lr=0,Hr=0,Wr=m(0),jr=0,Kr=0,cs=0,hs=0,ds=m(0),$s=0,Fs=0,Ns=0,Us=m(0),Bs=0,Gs=m(0),Fa=0,Na=m(0),Ua=m(0),Ba=m(0),Ga=0,ol=m(0),Uh=0,Bh=m(0),Gh=m(0),Vh=m(0),Hh=m(0),Wh=0,f2=0,p2=0,g2=0,m2=0,v2=0,y2=0,b2=0,qe=0,Qe=m(0),Hn=m(0);M=Tt-384|0,Tt=M;t:{r:{i:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(Y=(P?0:4)+tt|0,l[Y>>2]=l[Y>>2]+1,Y=l[r+24>>2]&3,Uh=(u|0)<=1?1:u,Hi=Y||Uh,gt[r+300|0]=Et[r+300|0]&252|Hi&3,Y=r+252|0,u=((Hi|0)!=1)<<3,$s=(Hi|0)==2?3:2,lt=ce(r,$s,k),I[Y+u>>2]=lt,ot=Y,Y=((Hi|0)==1)<<3,pe=we(r,$s,k),I[ot+Y>>2]=pe,bt=ce(r,0,k),I[r+256>>2]=bt,xe=we(r,0,k),I[r+264>>2]=xe,ot=r+268|0,qe=ot+u|0,Qe=fe(r,$s),I[qe>>2]=Qe,qe=Y+ot|0,Qe=Se(r,$s),I[qe>>2]=Qe,W=fe(r,0),I[r+272>>2]=W,We=Se(r,0),I[r+280>>2]=We,ot=u,u=r+284|0,qe=ot+u|0,Qe=Ie(r,$s,k),I[qe>>2]=Qe,qe=u+Y|0,Qe=De(r,$s,k),I[qe>>2]=Qe,Z=Ie(r,0,k),I[r+288>>2]=Z,$t=De(r,0,k),I[r+296>>2]=$t,lt=m(lt+pe),pe=m(bt+xe),u=l[r+8>>2],u){bt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(b?h-pe:Yt),W=m(m(Z+$t)+W),Z=m(y?a-lt:Yt),a=Z;e:{if(a!=a)break e;if(a=m(Z-bt),a!=a){a=m(0);break e}a=ae(a,m(0))}lt=m(W+We),W=h;e:{if(h!=h)break e;if(W=m(h-lt),W!=W){W=m(0);break e}W=ae(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Xe(r,2,Z,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ae(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=Xe(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(Et[r+4|0]&16){Pt[u|0](M+24|0,r,a,y,W,b,0);break e}Pt[u|0](M+24|0,r,a,y,W,b)}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(bt+I[M+24>>2]),a=Xe(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ae(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(lt+I[M+28>>2]),a=Xe(r,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(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)){pe=m(h-pe),a=Xe(r,2,y&-3?m(a-lt):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(De(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=Xe(r,0,b&-3?pe:m(m(m(Z+$t)+W)+We),S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(De(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-lt),Z=m(h-pe),!(!(!(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=Xe(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(De(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ae(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=Xe(r,0,Z!=Z||(b|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(De(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ae(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(ai=et-u|0,Hr=ai>>2;Y=l[u>>2],l[Y+552>>2]!=(r|0)&&(ot=l[r+568>>2],Y=Dp(l[ot>>2],Et[ot+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););gt[r+300|0]=Et[r+300|0]&251,Lt=3,Mi=l[r+24>>2],u=Mi>>>2&3;e:{s:{n:{if((Hi|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}Bh=m(a-lt),Wr=m(m(Ie(r,Lt,k)+fe(r,Lt))+m(De(r,Lt,k)+Se(r,Lt))),We=m(Ie(r,et,k)+fe(r,et)),tr=m(We+m(De(r,et,k)+Se(r,et))),er=Lt>>>0>1,bt=Tp(r,0,Bh,er?Wr:tr,k),Gh=m(h-pe),Ze=Tp(r,1,Gh,er?tr:Wr,S),xe=er?Ze:bt,pe=er?bt:Ze,jr=l[r+560>>2],Y=l[r+556>>2],Ji=er?y:b;e:{if((Ji|0)!=1)break e;if((Y|0)==(jr|0))break i;for(u=Y;;){ot=l[u>>2];s:{if(!Gp(ot))break s;if(Zt=0,mt)break e;n:{a:{if(!l[ot+552>>2]){W=m(0);break a}if(h=I[ot+32>>2],h!=h&&(W=m(0),h=I[ot+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ye(W))<m(9999999747378752e-20))break e}if(a=Gn(ot),a!=a){mt=ot;break s}if(mt=ot,m(Ye(a))<m(9999999747378752e-20))break e}if(Zt=mt,u=u+4|0,(jr|0)==(u|0))break}}if((Y|0)==(jr|0))break i;for(Fa=(Hi|0)<=1?1:Hi,Fs=bt!=bt,Kr=Fs|(y|0)!=1,cs=Ze==Ze,Ns=bt==bt,W=m(0);;){Ht=l[Y>>2],Ep(Ht),ot=l[Ht+24>>2];e:{if(ot&4194304){if(Sp(Ht,0),u=Et[Ht+4|0],ot=u|1,gt[Ht+4|0]=ot,!(u&4))break e;gt[Ht+4|0]=ot&251;break e}if(P&&(u=ot&3,xp(Ht,u||Fa,pe,xe,bt),ot=l[Ht+24>>2]),(ot&196608)==131072)break e;s:{if((Ht|0)==(Zt|0)){l[Zt+308>>2]=0,l[Zt+304>>2]=Q,h=m(0);break s}hs=l[r+24>>2],u=hs>>>2&3;n:{a:{if((Hi|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}Rr=mt>>>0>1,lt=Rr?bt:Ze,h=m(0),a=I[Ht+40>>2];n:{a:{Mt=l[Ht+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=l[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(Yt),!(I[Ht+28>>2]>m(0)))break n;Mt=gt[l[Ht+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(xt(2,u),Bt())}switch(a=m(Yt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(xt(2,(Mt&-1073741825)+536870912|0),Bt()),!(Mt&1073741824))break a}a=m(m(lt*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Mt=0;n:{a:switch(Me=l[Ht+576>>2],Me|0){case 0:case 3:break n;default:break a}if(Z=I[Ht+572>>2],!((Me|0)!=1|Z!=Z)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,(Me|0)!=2|Z!=Z||(Mt=0,h<m(0)))break n;Mt=Ns}Z=I[Ht+580>>2],u=0;n:{a:switch(oi=l[Ht+584>>2],oi|0){case 0:case 3:break n;default:break a}if($t=I[Ht+580>>2],!((oi|0)!=1|$t!=$t)){if(Z<m(0))break n;u=1;break n}if(u=1,(oi|0)!=2|$t!=$t||(u=0,Z<m(0)))break n;u=cs}n:{a:{if(!(a!=a|lt!=lt)){if(h=I[Ht+308>>2],(!(gt[l[Ht+568>>2]+12|0]&1)|l[Ht+304>>2]==(Q|0))&h==h)break n;if(h=m(m(Ie(Ht,mt,bt)+fe(Ht,mt))+m(De(Ht,mt,bt)+Se(Ht,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&Rr){Z=m(m(Ie(Ht,2,bt)+fe(Ht,2))+m(De(Ht,2,bt)+Se(Ht,2))),a=m(Yt);o:switch(Me-1|0){case 1:h=m(m(bt*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(!(Rr|u^1)){a=m(m(Ie(Ht,0,bt)+fe(Ht,0))+m(De(Ht,0,bt)+Se(Ht,0))),h=m(Yt);o:switch(oi-1|0){case 1:Z=m(m(Ze*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[M+360>>2]=2143289344,l[M+24>>2]=2143289344,$i=0,l[M+356>>2]=0,l[M+352>>2]=0,$t=m(ce(Ht,2,bt)+we(Ht,2,bt)),re=ce(Ht,0,bt),_e=we(Ht,0,bt),lt=m(Yt),Lr=0,a=m(Yt),Mt){o:{l:switch(Me-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(bt*h)*m(.009999999776482582))}l[M+356>>2]=1,a=m($t+a),I[M+24>>2]=a,Lr=1}if(re=m(re+_e),u){h=m(Yt);o:{l:switch(oi-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(Ze*Z)*m(.009999999776482582))}l[M+352>>2]=1,lt=m(re+h),I[M+360>>2]=lt,$i=1}Me=(hs&3145728)==2097152,oi=mt>>>0<2;o:{l:{c:{if(!(Me&oi)){if(Me|Fs)break l;if(a!=a)break c;break l}if(Fs|a==a)break o}Lr=2,l[M+356>>2]=2,I[M+24>>2]=bt,a=bt}l:{if(!Me||oi){if(Me|Ze!=Ze)break o;if(lt!=lt)break l;break o}if(lt==lt|Ze!=Ze)break o}$i=2,l[M+352>>2]=2,I[M+360>>2]=Ze,lt=Ze}h=I[Ht+224>>2],Me=h!=h;o:{if(Me)break o;l:{if(!(Rr|(Lr|0)!=1)){l[M+352>>2]=1,I[M+360>>2]=re+m(m(a-$t)/h);break l}if(oi|($i|0)!=1)break o;l[M+356>>2]=1,I[M+24>>2]=m(m(lt-re)*h)+$t}$i=1,Lr=1}ot=ot>>>13&7,ot=ot||hs>>>10&7;o:{if((ot|0)==5|(Lr|0)==1|(Rr|(Mt|Kr))|(ot|0)!=4||(l[M+356>>2]=1,I[M+24>>2]=bt,Me))break o;$i=1,l[M+352>>2]=1,I[M+360>>2]=m(bt-$t)/h}o:{if(oi|(b|0)!=1|Ze!=Ze|u|(ot|0)!=4|($i|0)==1||(l[M+352>>2]=1,I[M+360>>2]=Ze,Me))break o;l[M+356>>2]=1,I[M+24>>2]=m(Ze-re)*h}if(Nn(Ht,2,bt,bt,M+356|0,M+24|0),Nn(Ht,0,Ze,bt,M+352|0,M+360|0),dn(Ht,I[M+24>>2],I[M+360>>2],Hi,l[M+356>>2],l[M+352>>2],bt,Ze,0,5,K,tt,ft,Q),a=I[(Ht+(l[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Ht,mt,bt)+fe(Ht,mt))+m(De(Ht,mt,bt)+Se(Ht,mt))),!(u|h!=h)){h=ae(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}l[Ht+304>>2]=Q}W=m(W+m(h+m(ce(Ht,Lt,bt)+we(Ht,Lt,bt))))}if(Y=Y+4|0,(jr|0)==(Y|0))break}break r}l[M>>2]=3072,nr(r,M),Qi(),le()}l[M+16>>2]=3154,nr(r,M+16|0),Qi(),le()}W=m(0)}a=m(W+m(0)),Na=er?S:k,Us=er?k:S,ai>>>0>=5&&(a=m(m(tl(r,Lt,xe)*m(Hr-1>>>0))+a)),u=a>pe,jr=Mi&786432,cs=(Ji|0)==2&&jr&&u?1:Ji,Ht=er?b:y,Rr=(Ht|0)==1,f2=Rr&(P^1),er=Lt>>>0<2,p2=Ht&-3,Fs=r+208|0,b=et<<2,oi=b+4288|0,g2=Rr&!jr,m2=(Ht|0)!=1|P,Y=Lt<<2,Lr=Y+4288|0,Ns=Y+4320|0,hs=xe==xe,v2=hs<<1,Me=b+4320|0,y2=!Ji|!u,Fa=M+52|0,Vh=tl(r,et,xe),ot=0,u=0,$i=0;r:{for(;;){Ji=u,Vi(M+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(Y=$a(M+360|0,u>>2,0,Fa),u=l[M+44>>2],b=l[M+48>>2]-u|0,b=Ps(l[M+364>>2]-b|0,u,b),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=b,mt=l[M+368>>2],Mt=l[M+372>>2],b=l[M+48>>2],l[M+368>>2]=b,Zt=l[M+52>>2],l[M+48>>2]=mt,l[M+52>>2]=Mt,l[M+372>>2]=Zt,l[Y>>2]=u,(u|0)!=(b|0)&&(l[M+368>>2]=b+((u-b|0)+3&-4)),!u)break i;yi(u)}Zt=l[r+24>>2],u=Zt>>>2&3;i:{e:{if(b=Zt&3,((b||Uh)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}mt=2;break i}mt=u}W=tl(r,mt,bt),Y=ot,Mt=l[r+560>>2],b=l[r+556>>2];i:{if(Y>>>0>=Mt-b>>2>>>0)break i;for(Zt=Zt&786432,h=m(0);;){if(Mt-b>>2>>>0<=Y>>>0)break r;if(u=l[(Y<<2)+b>>2],ai=l[u+24>>2],!(ai&4194304|(ai&196608)==131072)){if(l[u+548>>2]=Ji,a=ce(u,mt,bt),Z=we(u,mt,bt),b=l[M+24>>2],lt=(Y|0)==(ot|0)?m(0):W,a=m(a+Z),Z=I[u+308>>2],$t=Xe(u,mt,Z,Us),!(!b||!(m(lt+m(a+m(h+$t)))>pe)|!Zt))break i;if(l[M+24>>2]=b+1,lt=m(lt+m(a+$t)),I[M+28>>2]=lt+I[M+28>>2],Gp(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[M+32>>2]=a+I[M+32>>2],qe=M,Qe=m(I[M+36>>2]-m(Gn(u)*Z)),I[qe+36>>2]=Qe}b=l[M+48>>2];e:{if((b|0)!=l[M+52>>2]){l[b>>2]=u,l[M+48>>2]=b+4;break e}if(b=b-l[M+44>>2]|0,ai=b>>2,Mt=ai+1|0,Mt>>>0>=1073741824)break r;if(Mi=b>>1,Mt=$a(M+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<Mi>>>0?Mi:Mt,ai,Fa),l[l[M+368>>2]>>2]=u,l[M+368>>2]=l[M+368>>2]+4,u=l[M+44>>2],b=l[M+48>>2]-u|0,b=Ps(l[M+364>>2]-b|0,u,b),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=b,ai=l[M+368>>2],Mi=l[M+372>>2],b=l[M+48>>2],l[M+368>>2]=b,Kr=l[M+52>>2],l[M+48>>2]=ai,l[M+52>>2]=Mi,l[M+372>>2]=Kr,l[Mt>>2]=u,(u|0)!=(b|0)&&(l[M+368>>2]=b+((u-b|0)+3&-4)),!u)break e;yi(u)}b=l[r+556>>2],Mt=l[r+560>>2],h=m(h+lt)}if(Y=Y+1|0,!(Y>>>0<Mt-b>>2>>>0))break}}_e=I[M+32>>2],!(_e>m(0))|!(_e<m(1))||(l[M+32>>2]=1065353216,_e=m(1)),Ai=I[M+36>>2],!(Ai>m(0))|!(Ai<m(1))||(l[M+36>>2]=1065353216,Ai=m(1)),l[M+40>>2]=Y,$t=I[M+28>>2],mt=l[M+24>>2],$i&&yi($i),Z=I[M+56>>2],ai=l[M+48>>2],$i=l[M+44>>2];i:{e:{s:{n:{if((cs|0)==1)break n;h=m(0),a=I[Fs>>2];a:{o:{u=l[Fs>>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=I[b>>2],a=m(Yt),l[b+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*k)*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;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(Yt),l[b+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*k)*m(.009999999776482582));break a}W=h}h=m(0),lt=I[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(lt==lt)break c;b=4344}switch(h=I[b>>2],lt=m(Yt),l[b+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}lt=m(m(h*S)*m(.009999999776482582));break a}lt=h}h=m(0),re=I[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=I[b>>2],re=m(Yt),l[b+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}re=m(m(h*S)*m(.009999999776482582));break a}re=h}if(u=Lt>>>0>1,h=m((u?a:lt)-Wr),h==h&h>$t||(h=m((u?W:re)-Wr),h==h&h<$t))break s;if(gt[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=pe;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=pe,a!=m(0)))break e;h=$t;break e}h=pe}if(h!=h)break e;Z=m(h-$t);break i}if(!($t<m(0)))break i;Z=m(-$t)}if(pe=h,!f2){i:{if((ai|0)==($i|0)){lt=m(0);break i}for(re=m(0),b=$i;;){u=l[b>>2],$t=I[u+308>>2],h=Xe(u,Lt,$t,Us);e:{if(Z<m(0)){if(a=m(h*m(-Gn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/Ai)*a)+h),a=Xe(u,Lt,W,pe),Mt=a!=a,lt=m(m(Ie(u,Lt,bt)+fe(u,Lt))+m(De(u,Lt,bt)+Se(u,Lt)));s:{if(!(Mt|lt!=lt)){a=ae(a,lt);break s}a=Mt?lt:a}if(W!=W|a!=a|a==W)break e;re=m(re+m(a-h)),Ai=m(m(Gn(u)*$t)+Ai);break e}if(!(Z>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;lt=m(m(m(Z/_e)*W)+h),a=Xe(u,Lt,lt,pe),Mt=a!=a,$t=m(m(Ie(u,Lt,bt)+fe(u,Lt))+m(De(u,Lt,bt)+Se(u,Lt)));s:{if(!(Mt|$t!=$t)){a=ae(a,$t);break s}a=Mt?$t:a}if(lt!=lt|a!=a|a==lt)break e;_e=m(_e-W),re=m(re+m(a-h))}if(b=b+4|0,(ai|0)==(b|0))break}for(re=m(Z-re),Ua=m(re/Ai),Ba=m(re/_e),Ga=Rr&(y2|!(Et[r+26|0]&12)),Kr=!Ga,Mi=l[Me>>2],lt=m(0),Mt=$i;;){u=l[Mt>>2],$t=Xe(u,Lt,I[u+308>>2],Us);e:{s:{if(re<m(0)){if(W=$t,a=m(W*m(-Gn(u))),a==m(0))break e;a=Ai==m(0)?m($t+a):m(m(Ua*a)+$t);break s}if(W=$t,!(re>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(Ba*a)+$t)}if(a=Xe(u,Lt,a,pe),b=a!=a,h=m(m(Ie(u,Lt,bt)+fe(u,Lt))+m(De(u,Lt,bt)+Se(u,Lt))),!(b|h!=h)){W=ae(a,h);break e}W=b?h:a}a=ce(u,Lt,bt),h=we(u,Lt,bt),_e=ce(u,et,bt),ol=we(u,et,bt),h=m(a+h),Hh=m(W+h),I[M+352>>2]=Hh,l[M+344>>2]=1,_e=m(_e+ol),a=I[u+224>>2];e:{if(a==a){l[M+348>>2]=1,h=m(Hh-h),I[M+356>>2]=_e+m(er?h*a:h/a);break e}s:{if(Bs=xe!=xe,Bs)break s;Zt=(Mi<<3)+u|0,a=I[Zt+572>>2];n:{a:{o:{l:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[Zt+572>>2],(b|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!Ga)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||(fn(M+24|0,u,et),l[M+28>>2]==3)||(un(M+360|0,u,et),l[M+364>>2]==3))break s;l[M+348>>2]=1,I[M+356>>2]=xe;break e}Zt=(Mi<<3)+u|0,h=I[Zt+572>>2];s:{n:{a:{o:{l:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[Zt+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(Bs)break o;if(!(h<m(0)))break n}l[M+348>>2]=v2,I[M+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(_e+a),I[M+356>>2]=a,l[M+348>>2]=(Rr|(b|0)!=2)&a==a}Nn(u,Lt,pe,bt,M+344|0,M+352|0),Nn(u,et,xe,bt,M+348|0,M+356|0),Zt=(Mi<<3)+u|0,a=I[Zt+572>>2];e:{s:{n:{a:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[Zt+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(Zt=0,hs)break e}if(Zt=0,b=l[u+24>>2]>>>13&7,b||(b=l[r+24>>2]>>>10&7),(b|0)!=4||(fn(M+24|0,u,et),l[M+28>>2]==3))break e;un(M+360|0,u,et),Zt=l[M+364>>2]!=3;break e}Zt=0}a=I[M+352>>2],h=I[M+356>>2],b=Lt>>>0>1,_e=b?a:h,a=b?h:a,Bs=l[M+344>>2],Wh=l[M+348>>2],b2=b?Bs:Wh,Bs=b?Wh:Bs,b=(Zt^1)&P,dn(u,_e,a,Et[r+300|0]&3,b2,Bs,bt,Ze,b,b?4:7,K,tt,ft,Q),lt=m(lt+m(W-$t)),b=Et[r+300|0];e:{s:{if(b&4){Zt=b&251;break s}if(Zt=b&251,b=0,!(Et[u+300|0]&4))break e}b=4}if(gt[r+300|0]=b|Zt,Mt=Mt+4|0,(ai|0)==(Mt|0))break}}Z=m(Z-lt)}u=Et[r+300|0],gt[r+300|0]=u&251|(Z<m(0)?4:u&4),re=m(Ie(r,Lt,k)+fe(r,Lt)),Ua=m(De(r,Lt,k)+Se(r,Lt)),$t=tl(r,Lt,k);i:{if(!(!(Z>m(0))|(cs|0)!=2)){lt=m(0),h=m(0);e:{s:{u=Fs+(l[Ns>>2]<<2)|0,a=I[u>>2],u=l[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(Zt=(u|0)==2141891242,Zt|a!=a)break i;if(Mt)break s;if(Zt)break i;if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Us*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=I[b>>2],W=m(Yt),l[b+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(Us*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-re)-Ua)-m(pe-Z)),a!=a)break i;lt=ae(a,m(0));break i}lt=Z}Zt=Y>>>0<=ot>>>0;i:{if(!Zt){for(ai=l[r+556>>2],u=l[r+560>>2]-ai>>2,Mi=u>>>0<ot>>>0?ot:u,Mt=0,u=ot;;){if((u|0)==(Mi|0))break r;if(b=l[ai+(u<<2)>>2],(l[b+24>>2]&196608)!=131072&&(Kr=M+24|0,fn(Kr,b,Lt),Ga=l[M+28>>2],un(Kr,b,Lt),Mt=(((Ga|0)==3)+Mt|0)+(l[M+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(_e=m(0),h=$t,Mt)break i}_e=m(0),Mt=0,h=$t;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:_e=m(lt*m(.5));break i;case 1:_e=lt;break i;case 2:if(mt>>>0<2)break i;h=m($t+m((Qe=m(0),Hn=ae(lt,m(0)),qe=lt!=lt,(qe?Qe:Hn)/m(mt-1>>>0))));break i;case 4:_e=m(lt/m(mt+1>>>0)),h=m($t+_e);break i;case 3:break e;default:break i}_e=m(m(lt*m(.5))/m(mt>>>0)),h=m(m(_e+_e)+$t)}if(a=m(re+_e),Z=m(0),ai=Op(r),Zt)h=m(0);else{for(Mi=Y-1|0,Ba=m(lt/m(Mt|0)),re=m(0),W=m(0),u=ot;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=u>>>0)break r;b=l[b+(u<<2)>>2],mt=b+228|0,Gi(M+24|0,mt,320),h=m(h-((u|0)==(Mi|0)?$t:m(0))),Mt=l[b+24>>2];i:{if(Mt&4194304)break i;e:{if((Mt&196608)==131072){if(!ar(b,Lt))break e;if(!P)break i;lt=Os(b,Lt,pe),Ai=fe(r,Lt),ol=ce(b,Lt,bt),I[mt+(l[Lr>>2]<<2)>>2]=ol+m(lt+Ai);break i}if(fn(M+360|0,b,Lt),a=m(a+(l[M+364>>2]==3?Ba:m(-0))),P&&(Mt=mt,mt=l[Lr>>2]<<2,I[Mt+mt>>2]=a+I[mt+(M+24|0)>>2]),un(M+360|0,b,Lt),a=m(a+(l[M+364>>2]==3?Ba:m(-0))),!m2){a=m(a+m(m(h+m(ce(b,Lt,bt)+we(b,Lt,bt)))+I[M+104>>2])),Z=xe;break i}if(mt=b+516|0,a=m(a+m(h+m(I[mt+(l[Ns>>2]<<2)>>2]+m(ce(b,Lt,bt)+we(b,Lt,bt))))),ai){lt=el(b),Ai=ce(b,0,bt),lt=m(lt+Ai),Ai=m(m(I[b+520>>2]+m(ce(b,0,bt)+we(b,0,bt)))-lt),b=re!=re;s:{if(!(b|lt!=lt)){re=ae(re,lt);break s}re=b?lt:re}if(b=W!=W,!(b|Ai!=Ai)){W=ae(W,Ai);break i}W=b?Ai:W;break i}if(lt=m(I[mt+(l[Me>>2]<<2)>>2]+m(ce(b,et,bt)+we(b,et,bt))),b=Z!=Z,!(lt!=lt|b)){Z=ae(Z,lt);break i}Z=b?lt:Z;break i}if(!P)break i;b=l[Lr>>2]<<2,lt=I[b+(M+24|0)>>2],qe=b+mt|0,Qe=m(_e+m(lt+fe(r,Lt))),I[qe>>2]=Qe}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+re)}if(Z=ai?h:Z,lt=xe,!p2){h=Xe(r,et,m(tr+Z),Na),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(De(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ae(h,W);break i}h=u?W:h}lt=m(h-tr)}h=Xe(r,et,m(tr+(g2?xe:Z)),Na),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(De(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ae(h,W);break i}h=u?W:h}if(W=m(h-tr),!(Zt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=ot>>>0)break r;mt=l[u+(ot<<2)>>2],u=l[mt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!ar(mt,et)){b=l[oi>>2];break e}if(h=Os(mt,et,xe),Z=fe(r,et),$t=ce(mt,et,bt),b=l[oi>>2],h=m($t+m(h+Z)),I[(mt+(b<<2)|0)+228>>2]=h,h==h)break i}qe=mt+(b<<2)|0,Qe=m(fe(r,et)+ce(mt,et,bt)),I[qe+228>>2]=Qe;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||(fn(M+24|0,mt,et),b=4,l[M+28>>2]==3)||(un(M+360|0,mt,et),l[M+364>>2]==3))break s;b=mt+(l[Me>>2]<<3)|0,Z=I[b+572>>2];n:{a:switch(u=l[b+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[b+572>>2],!((u|0)!=1|$t!=$t)){if(h=We,Z<m(0))break n;break e}if(h=We,hs&!(Z<m(0))|((u|0)!=2|$t!=$t))break e}Z=I[(mt+(l[Ns>>2]<<2)|0)+516>>2],h=W,$t=I[mt+224>>2],$t==$t&&(h=m(m(ce(mt,et,bt)+we(mt,et,bt))+m(er?Z*$t:Z/$t))),I[M+360>>2]=h,qe=M,Qe=m(Z+m(ce(mt,Lt,bt)+we(mt,Lt,bt))),I[qe+24>>2]=Qe,l[M+356>>2]=1,l[M+352>>2]=1,Nn(mt,Lt,pe,bt,M+356|0,M+24|0),Nn(mt,et,xe,bt,M+352|0,M+360|0),Z=I[M+360>>2],$t=I[M+24>>2],u=Lt>>>0>1,h=u?Z:$t,Z=u?$t:Z,u=(jr|0)!=0&(l[r+24>>2]&896)!=512,dn(mt,Z,h,Hi,!(u&er|Z!=Z),(!u|er)&h==h,bt,Ze,1,2,K,tt,ft,Q),h=We;break e}h=I[(mt+(l[Me>>2]<<2)|0)+516>>2],Z=ce(mt,et,bt),$t=we(mt,et,bt),fn(M+24|0,mt,et),Z=m(lt-m(h+m(Z+$t)));s:{if(l[M+28>>2]!=3||(un(M+360|0,mt,et),l[M+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(We+(Qe=m(0),Hn=ae(h,m(0)),qe=h!=h,qe?Qe:Hn));break e}if(un(M+24|0,mt,et),h=We,l[M+28>>2]==3)break e;if(fn(M+24|0,mt,et),l[M+28>>2]==3){h=m(We+(Qe=m(0),Hn=ae(Z,m(0)),qe=Z!=Z,qe?Qe:Hn));break e}s:switch(b-1|0){case 1:h=m(We+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(We+Z)}u=mt+(l[oi>>2]<<2)|0,I[u+228>>2]=h+m(ds+I[u+228>>2])}if(ot=ot+1|0,(ot|0)==(Y|0))break}h=m((Ji?Vh:m(0))+W),u=Gs!=Gs,a=m(Ua+a);i:{if(!(u|a!=a)){Gs=ae(Gs,a);break i}Gs=u?a:Gs}if(ds=m(ds+h),u=Ji+1|0,ot=Y,!(Hr>>>0>Y>>>0))break}i:{if(!P||!jr&&!Op(r))break i;re=m(0);e:{s:{if(xe!=xe)break s;a=m(xe-ds);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:We=m(We+m(a*m(.5)));break s;case 2:if(!(xe>ds))break s;re=m(a/m(u>>>0));break s;case 5:if(xe>ds){if(We=m(We+m(a/m(u<<1>>>0))),u>>>0<2)break s;re=m(a/m(u>>>0));break e}We=m(We+m(a*m(.5)));break s;case 4:if(!(xe>ds)|u>>>0<2)break s;re=m(a/m(Ji>>>0));break e;case 1:break n;default:break s}We=m(We+a)}if(!u)break i}for(Mt=0,u=0,b=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),Y=u,Hr>>>0>u>>>0){e:{for(;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=Y>>>0)break r;ot=l[b+(Y<<2)>>2],mt=l[ot+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(b=Y,l[ot+548>>2]!=(Mt|0))break e;a=I[(ot+(l[Me>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(ce(ot,et,bt)+we(ot,et,bt))),!(b|a!=a)){h=ae(h,a);break n}h=b?a:h}if(b=mt>>>13&7,b||(b=l[r+24>>2]>>>10&7),!(Et[r+24|0]&8)|(b|0)!=5)break s;a=el(ot),lt=ce(ot,0,bt),a=m(a+lt),lt=m(m(I[ot+520>>2]+m(ce(ot,0,bt)+we(ot,0,bt)))-a),b=h!=h,ot=W!=W;n:{if(!(ot|a!=a)){W=ae(W,a);break n}W=ot?a:W}ot=Z!=Z;n:{if(!(ot|lt!=lt)){Z=ae(Z,lt);break n}Z=ot?lt:Z}if(a=m(W+Z),!(b|a!=a)){h=ae(h,a);break s}h=b?a:h}if(Y=Y+1|0,(Hr|0)==(Y|0))break}b=Hr}a=h}if(lt=m(We+(Mt?Vh:m(0))),h=m(re+a),We=m(lt+h),u>>>0<b>>>0)for($t=m(lt+W);;){if(Y=l[r+556>>2],l[r+560>>2]-Y>>2>>>0<=u>>>0)break r;ot=l[Y+(u<<2)>>2],Y=l[ot+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(Et[r+24|0]&8)break s;case 0:a=ce(ot,et,bt),I[(ot+(l[oi>>2]<<2)|0)+228>>2]=lt+a;break e;case 2:a=we(ot,et,bt),Y=ot+228|0,I[Y+(l[oi>>2]<<2)>>2]=m(We-a)-I[(Y+(l[Me>>2]<<2)|0)+288>>2];break e;case 1:Y=ot+228|0,I[Y+(l[oi>>2]<<2)>>2]=lt+m(m(h-I[(Y+(l[Me>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=ce(ot,et,bt),I[(ot+(l[oi>>2]<<2)|0)+228>>2]=lt+a,mt=ot+(l[Me>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(Y=l[mt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(hs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(Lt>>>0>=2){Z=h,a=I[ot+516>>2],W=m(a+m(ce(ot,Lt,bt)+we(ot,Lt,bt)));break n}Z=m(I[ot+520>>2]+m(ce(ot,et,bt)+we(ot,et,bt))),a=I[ot+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ye(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[ot+520>>2],Y=a!=a,!(Y|Z!=Z)){if(!(m(Ye(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(Y)break e}dn(ot,W,Z,Hi,1,1,bt,Ze,1,3,K,tt,ft,Q);break e}qe=ot,Qe=m(m($t-el(ot))+Os(ot,0,xe)),I[qe+232>>2]=Qe}if(u=u+1|0,(b|0)==(u|0))break}if(Y=(Mt|0)!=(Ji|0),Mt=Mt+1|0,u=b,!Y)break}}mt=r+516|0,a=Xe(r,2,Bh,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(De(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ae(a,h);break i}a=u?h:a}I[mt>>2]=a,a=Xe(r,0,Gh,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(De(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ae(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(cs&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(cs|0)!=2))break s;if(a=Xe(r,Lt,Gs,Us),u=a!=a,h=m(m(Ie(r,Lt,k)+fe(r,Lt))+m(De(r,Lt,k)+Se(r,Lt))),!(u|h!=h)){a=ae(a,h);break e}a=u?h:a;break e}if((cs|0)!=2|(u|0)!=2)break i;h=m(Wr+pe),u=h!=h,a=Xe(r,Lt,Gs,Us);s:{if(!(u|a!=a)){a=Ph(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Wr!=Wr)){a=ae(a,Wr);break e}a=u?Wr:a}I[mt+(l[Ns>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(b=(Ht|0)!=2,u=l[r+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Xe(r,et,m(tr+ds),Na),u=a!=a,h=m(m(Ie(r,et,k)+fe(r,et))+m(De(r,et,k)+Se(r,et))),!(u|h!=h)){a=ae(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break i;h=m(tr+xe),u=h!=h,a=Xe(r,et,m(tr+ds),Na);s:{if(!(u|a!=a)){a=Ph(h,a);break s}a=u?a:h}if(u=a!=a,!(u|tr!=tr)){a=ae(a,tr);break e}a=u?tr:a}I[mt+(l[Me>>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],ot=l[r+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<ot>>>0?l[P+(u<<2)>>2]:Y,(l[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Mt=Y+(l[oi>>2]<<2)|0,Zt=l[Me>>2]<<2,I[Mt>>2]=m(I[Zt+mt>>2]-I[Mt>>2])-I[(Y+Zt|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(Mt=((Lt>>>0>1?cs:y)|0)!=0;;){y=l[b>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=bt,pe=Ze,Et[l[r+568>>2]+12|0]&2&&(pe=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Hi|0)==2){ot=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(ot=0,u>>>0<=1)break n;Y=u;break s}Y=u,ot=$s}S=m(ce(y,2,W)+we(y,2,W)),k=ce(y,0,W),Z=we(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(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),!ar(y,2)||!sl(y,2))break s;if(a=Xe(y,2,m(m(I[r+516>>2]-m(fe(r,2)+Se(r,2)))-m(Os(y,2,W)+Ma(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+fe(y,2))+m(De(y,2,W)+Se(y,2))),!(u|h!=h)){h=ae(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{Zt=h!=h,k=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=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(pe!=pe|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(pe*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(ar(y,0)&&sl(y,0))break d;if(a=m(Yt),h==h)break h;break a}if(a=Xe(y,0,m(m(I[r+520>>2]-m(fe(r,0)+Se(r,0)))-m(Os(y,0,pe)+Ma(y,0,pe))),pe),u=a!=a,k=m(m(Ie(y,0,W)+fe(y,0))+m(De(y,0,W)+Se(y,0))),!(u|k!=k)){a=ae(a,k);break f}a=u?k:a}if((Zt|0)==(a!=a|0)||(lt=I[y+224>>2],lt!=lt))break l;if(h!=h){h=m(m(m(a-Z)*lt)+S);break l}if(a==a)break l;break c}if(lt=I[y+224>>2],lt!=lt)break o}a=m(Z+m(m(h-S)/lt))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Zt=W>m(0),Ji=u&Mt&Y>>>0<2,h=Ji&&Zt?W:h,u=u^1,dn(y,h,a,Hi,Ji&&Zt?2:u,a==a,h,a,0,6,K,tt,ft,Q),h=m(I[y+516>>2]+r2(y,2,W)),a=m(I[y+520>>2]+r2(y,0,W))}dn(y,h,a,Hi,1,1,h,a,1,1,K,tt,ft,Q);s:{n:{a:{if(!sl(y,Y)||ar(y,Y))break a;u=l[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?pe:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,Y))-we(y,Y,a))-Ma(y,Y,a));break n}if(!(ar(y,Y)|(l[r+24>>2]&112)!=16)){u=l[(Y<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(ar(y,Y)|(l[r+24>>2]&112)!=32)){u=l[(Y<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Et[l[r+568>>2]+12|0]&2)||!ar(y,Y))break s;a=I[mt+(l[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,Y,a)+fe(r,Y))+ce(y,Y,a))}I[(y+(l[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!sl(y,ot)||ar(y,ot))break n;u=l[(ot<<2)+4320>>2]<<2,a=Y>>>0<2?W:pe,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,ot))-we(y,ot,a))-Ma(y,ot,a));break s}n:{if(ar(y,ot)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(ot<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(ar(y,ot))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[(ot<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Et[l[r+568>>2]+12|0]&2)||!ar(y,ot))break e;a=I[mt+(l[(ot<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,ot,a)+fe(r,ot))+ce(y,ot,a))}I[(y+(l[(ot<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((et|Lt)&1))break i;for(b=et&1,P=Lt&1,K=Hr>>>0<=1?1:Hr,tt=(et<<2)+4304|0,ft=(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(Et[u+26|0]&64||(P&&(y=u+228|0,Y=l[Ns>>2]<<2,I[y+(l[ft>>2]<<2)>>2]=m(I[Y+mt>>2]-I[(y+Y|0)+288>>2])-I[y+(l[Lr>>2]<<2)>>2]),!b))break e;u=u+228|0,y=l[Me>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(l[oi>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!$i)break t;yi($i);break t}xs(),le()}Tt=M+384|0}function yp(){var r=0,a=0;Fn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=dt(8),l[r>>2]=8,l[r+4>>2]=1,St(7032,2922,6,4368,4392,19,r|0,1),Fn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=dt(4),l[r>>2]=24,St(7036,2359,2,4400,4408,25,r|0,0),os(7032,1398,2,4412,4420,26,27),os(7032,3027,3,4500,4512,28,29),Fn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=dt(8),l[r>>2]=8,l[r+4>>2]=1,St(7056,3293,2,4520,4408,32,r|0,1),Fn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=dt(4),l[r>>2]=37,St(7059,2359,2,4528,4408,38,r|0,0),os(7056,1398,2,4536,4420,39,40),os(7056,3027,3,4500,4512,28,41),Fn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),gp(7062,1,4584,4352,44,45),os(7062,2915,1,4584,4352,44,45),os(7062,1129,2,4588,4408,46,47),r=dt(8),l[r+4>>2]=0,l[r>>2]=48,St(7062,3234,4,4608,4624,49,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=50,St(7062,1981,3,4632,4644,51,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=52,St(7062,1952,3,4652,4664,53,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=54,St(7062,3389,3,4672,4664,55,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=56,St(7062,1800,3,4652,4664,53,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=57,St(7062,3264,3,4684,4512,58,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=59,St(7062,1926,2,4696,4420,60,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=61,St(7062,3399,2,4704,4420,62,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=63,St(7062,1785,2,4696,4420,60,r|0,0),wh(7065,1271,4712,64,4357,65),Vn(1732,0),Vn(1612,8),Vn(2145,16),Vn(2455,24),Vn(2561,32),Vn(1618,40),kh(7065),wh(7035,2898,4712,66,4357,67),Yp(2561,0),Yp(1618,8),kh(7035),wh(7066,2909,4712,68,4357,69),r=dt(4),l[r>>2]=8,a=dt(4),l[a>>2]=8,Jo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=dt(4),l[r>>2]=0,a=dt(4),l[a>>2]=0,Jo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),kh(7066),Fn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),gp(7067,1,4724,4352,76,77),os(7067,1593,1,4724,4352,76,77),os(7067,2851,2,4728,4420,78,79),os(7067,1129,2,4736,4408,80,81),r=dt(8),l[r+4>>2]=0,l[r>>2]=82,St(7067,1753,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=84,St(7067,3005,3,4744,4664,85,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=86,St(7067,2930,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=88,St(7067,2335,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=90,St(7067,1485,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=91,St(7067,1356,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=92,St(7067,1818,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=93,St(7067,2872,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=94,St(7067,2379,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=95,St(7067,2164,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=96,St(7067,1320,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=97,St(7067,2413,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=98,St(7067,1504,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=99,St(7067,2236,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=100,St(7067,1220,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=101,St(7067,1137,3,4756,4664,87,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=102,St(7067,1159,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=104,St(7067,1846,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=105,St(7067,1465,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=106,St(7067,2219,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=107,St(7067,1196,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=108,St(7067,2501,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=109,St(7067,2591,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=110,St(7067,1540,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=111,St(7067,2250,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=112,St(7067,1651,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=113,St(7067,1428,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=114,St(7067,2205,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=115,St(7067,2609,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=116,St(7067,1556,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=117,St(7067,1671,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=118,St(7067,1445,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=119,St(7067,2567,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=120,St(7067,1521,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=121,St(7067,1625,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=122,St(7067,1408,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=123,St(7067,2305,3,4792,4718,103,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=124,St(7067,2093,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=125,St(7067,2719,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=126,St(7067,1575,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=127,St(7067,2188,4,4768,4784,89,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=128,St(7067,2946,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=130,St(7067,2347,3,4812,4512,131,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=132,St(7067,1372,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=133,St(7067,1832,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=134,St(7067,2885,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=135,St(7067,2396,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=136,St(7067,2176,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=137,St(7067,1338,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=138,St(7067,2423,3,4812,4512,131,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=139,St(7067,1859,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=141,St(7067,1208,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=143,St(7067,2515,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=144,St(7067,2600,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=145,St(7067,1661,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=146,St(7067,2621,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=147,St(7067,1684,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=148,St(7067,2579,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=149,St(7067,1638,2,4824,4420,140,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=150,St(7067,2320,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=151,St(7067,2103,3,4840,4852,152,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=153,St(7067,1232,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=154,St(7067,1148,2,4804,4420,129,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=155,St(7067,2730,3,4812,4512,131,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=156,St(7067,2195,3,4860,4872,157,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=158,St(7067,3034,4,4880,4624,159,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=160,St(7067,3055,3,4896,4664,161,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=162,St(7067,1293,2,4908,4420,163,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=164,St(7067,1388,2,4916,4420,165,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=166,St(7067,3046,3,4924,4512,167,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=168,St(7067,2962,2,4936,4420,169,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=170,St(7067,2982,3,4944,4664,171,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=172,St(7067,3357,3,4956,4664,173,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=174,St(7067,3355,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=175,St(7067,3374,3,4968,4664,176,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=177,St(7067,3372,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=178,St(7067,1119,2,4736,4408,83,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=179,St(7067,1111,2,4980,4420,180,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=181,St(7067,1244,5,4992,5012,182,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=183,St(7067,1737,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=184,St(7067,1715,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=185,St(7067,2149,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=186,St(7067,2462,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=187,St(7067,2633,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=188,St(7067,1697,2,4832,4714,142,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=189,St(7067,1260,2,5020,4420,190,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=191,St(7067,2433,3,4840,4852,152,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=192,St(7067,2113,3,4840,4852,152,r|0,0),r=dt(8),l[r+4>>2]=0,l[r>>2]=193,St(7067,2741,3,4840,4852,152,r|0,0)}function FE(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,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,mt=0,bt=0,Lt=0,Mt=0,$t=0;Q=Tt-560|0,Tt=Q,l[Q+44>>2]=0,vi(+a),k=Jt(1)|0,Jt(0)|0;t:{if((k|0)<0){ot=1,Mt=1177,a=-a,vi(+a),k=Jt(1)|0,Jt(0)|0;break t}if(y&2048){ot=1,Mt=1180;break t}ot=y&1,Mt=ot?1183:1178,$t=!ot}t:{if((k&2146435072)==2146435072){k=ot+3|0,bi(r,32,h,k,y&-65537),fi(r,Mt,ot),u=b&32,fi(r,a!=a?u?2451:3459:u?2868:3463,3),bi(r,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=Q+16|0;r:{i:{e:{if(a=Fp(a,Q+44|0),a=a+a,a!=0){if(k=l[Q+44>>2],l[Q+44>>2]=k-1,bt=b|32,(bt|0)!=97)break e;break r}if(bt=b|32,(bt|0)==97)break r;tt=l[Q+44>>2],ft=(u|0)<0?6:u;break i}tt=k-29|0,l[Q+44>>2]=tt,a=a*268435456,ft=(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,k=S,P=Y;break i}for(P=Y,u=tt;;){M=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],Lt=u,u=M&31,(M&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=wp(Lt,u>>>0>Lt>>>0?K+1|0:K,1e9),K=xh(u,Bi,-1e9,0)+Lt|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[Q+44>>2]-M|0,l[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(lt=((ft+25>>>0)/9|0)+1|0,W=(bt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(M=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=He(M,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=et+l[Q+44>>2]|0,l[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(lt|0)?S+(lt<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=He(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=He(S,10),K>>>0>=S>>>0;);}if(S=(ft-((bt|0)!=102?u:0)|0)-((bt|0)==103&(ft|0)!=0)|0,(S|0)<(He(k-Y>>2,9)-9|0)){if(M=S+9216|0,K=(M|0)/9|0,tt=((((tt|0)<0?4:292)+Q|0)+(K<<2)|0)-4048|0,S=10,et=M+He(K,-9)|0,(et|0)<=7)for(;S=He(S,10),et=et+1|0,(et|0)!=8;);M=l[tt>>2],lt=(M>>>0)/(S>>>0)|0,W=He(lt,S),K=tt+4|0;i:{if((M|0)==(W|0)&(K|0)==(k|0))break i;M=M-W|0;e:{if(!(lt&1)&&(a=9007199254740992,!(gt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(Z=(k|0)==(K|0)?1:1.5,K=S>>>1|0,Z=K>>>0>M>>>0?.5:(K|0)==(M|0)?Z:1.5,Et[Mt|0]!=45|$t||(Z=-Z,a=-a),l[tt>>2]=W,a+Z==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=He(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=He(S,10),K>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,M=k>>>0<=P>>>0,!M&&(k=K-4|0,!l[k>>2]););i:{if((bt|0)!=103){tt=y&8;break i}if(S=ft||1,k=(S|0)>(u|0)&(u|0)>-5,ft=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,tt=y&8,tt)break i;k=-9;e:{if(M||(tt=l[K-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=He(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=He(K-Y>>2,9),(b&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k;break i}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k}if(et=-1,M=tt|ft,((M?2147483645:2147483646)|0)<(ft|0))break t;W=(((M|0)!=0)+ft|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=Un((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,gt[k|0]=48,(mt-k|0)<2;);if(lt=k-2|0,gt[lt|0]=b,gt[k-1|0]=(u|0)<0?45:43,k=mt-lt|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(ot^2147483647))break t;W=u+ot|0,bi(r,32,h,W,y),fi(r,Mt,ot),bi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,tt=b|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=Un(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;gt[Q+24|0]=48,k=u}if(fi(r,k,tt-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if(M&&fi(r,4275,1),(ft|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Un(l[P>>2],0,tt),k>>>0>Q+16>>>0)for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);if(fi(r,k,(ft|0)>=9?9:ft),k=ft-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(ft|0)>9,ft=k,!u)break}break e}n:{if((ft|0)<0)break n;for(Y=P>>>0<K>>>0?K:P+4|0,b=Q+16|0,u=b|8,K=b|9,S=P;;){k=Un(l[S>>2],0,K),(K|0)==(k|0)&&(gt[Q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break a;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(fi(r,k,1),k=k+1|0,!(tt|ft))break a;fi(r,4275,1)}if(b=K-k|0,fi(r,k,(b|0)>(ft|0)?ft:b),ft=ft-b|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((ft|0)>=0))break}}bi(r,48,ft+18|0,18,0),fi(r,lt,mt-lt|0);break i}k=ft}bi(r,48,k+9|0,9,0)}bi(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(b<<26>>31&9)+Mt|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(Et[tt|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(Y=ot|2,P=b&32,S=l[Q+44>>2],k=S>>31,k=Un((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(gt[Q+15|0]=48,k=Q+15|0),ft=k-2|0,gt[ft|0]=b+15,gt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Ye(a)<2147483648?K=~~a:K=-2147483648,gt[S|0]=P|Et[K+5504|0],a=(a-+(K|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(gt[b+1|0]=46,S=b+2|0),a!=0;);if(et=-1,k=mt-ft|0,b=k+Y|0,(2147483645-b|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}b=u+b|0,bi(r,32,h,b,y),fi(r,tt,Y),bi(r,48,h,b,y^65536),fi(r,Q+16|0,P),bi(r,48,u-P|0,0,0),fi(r,ft,k),bi(r,32,h,b,y^8192),et=(h|0)<(b|0)?b:h}return Tt=Q+560|0,et|0}function bp(r,a,h,u,y,b,k){var S=0,P=0,K=0,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,mt=0,bt=0,Lt=0,Mt=0,$t=0,Ht=0,Zt=0;K=Tt-80|0,Tt=K,l[K+76>>2]=a,$t=K+55|0,lt=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=Et[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(Et[P+1|0]!=37){a=P;break c}if(S=S+1|0,ft=Et[P+2|0],a=P+2|0,P=a,(ft|0)!=37)break}}if(S=S-tt|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(r&&fi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,Z=-1,P=gt[a+1|0],!al(P)|Et[a+2|0]!=36||(Z=P-48|0,mt=1,S=a+3|0),l[K+76>>2]=S,M=0,P=gt[S|0],a=P-32|0;c:{if(a>>>0>31){ft=S;break c}if(ft=S,a=1<<a,!(a&75913))break c;for(;;){if(ft=S+1|0,l[K+76>>2]=ft,M=a|M,P=gt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=ft,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=gt[ft+1|0];h:{if(!(!al(a)|Et[ft+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=ft+3|0,mt=1,Y=l[((gt[ft+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=ft+1|0,!r){l[K+76>>2]=P,mt=0,Y=0;break c}a=l[h>>2],l[h>>2]=a+4,mt=0,Y=l[a>>2]}if(l[K+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,M=M|8192;break c}if(Y=Vp(K+76|0),(Y|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(Et[P|0]!=46){a=P,ot=0;break c}if(Et[P+1|0]==42){a=gt[P+2|0];h:{if(!(!al(a)|Et[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((gt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)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,ot=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Vp(K+76|0),a=l[K+76>>2],ot=1}for(;;){if(Q=S,ft=28,bt=a,S=gt[a|0],S-123>>>0<4294967238)break i;if(a=bt+1|0,S=Et[(S+He(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((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;_p(K- -64|0,S,h,k);break c}if((Z|0)>=0)break i}if(S=0,!r)continue s}P=M&-65537,M=M&8192?P:M,Z=0,Lt=1167,ft=lt;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=gt[bt|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 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],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:gt[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,M=M|8,S=120}if(tt=lt,P=l[K+64>>2],Q=l[K+68>>2],P|Q)for(Ht=S&32;tt=tt-1|0,gt[tt|0]=Ht|Et[(P&15)+5504|0],Zt=!Q&P>>>0>15|(Q|0)!=0,bt=Q,Q=Q>>>4|0,P=(bt&15)<<28|P>>>4,!!Zt;);if(!(M&8)|!(l[K+64>>2]|l[K+68>>2]))break u;Lt=(S>>>4|0)+1167|0,Z=2;break u}if(S=lt,tt=l[K+68>>2],Q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,gt[S|0]=P&7|48,bt=!Q&P>>>0>7|(Q|0)!=0,tt=Q,Q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!bt;);if(tt=S,!(M&8))break u;S=lt-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,Z=1,S=1167;break g}if(M&2048){Z=1,S=1168;break g}Z=M&1,S=Z?1169:1167}Lt=S,tt=Un(P,Q,lt)}if((et|0)<0&&ot)break e;if(M=ot?M&-65537:M,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=lt,et=0;break a}S=!(S|P)+(lt-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}M=0,ot=et>>>0>=2147483647?2147483647:et,Q=ot,ft=(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(M=Et[S|0],!M)break b;if(Q=Q-1|0,ft=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!ft)break u;m:{if(!(!Et[S|0]|Q>>>0<4))for(;;){if(ft=l[S>>2],(ft^-1)&ft-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}ft=0;break g}ft=1}for(;;){if(!ft){M=Et[S|0],ft=1;continue}if(!M)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;ft=0}}S=0}if(S=S?S-tt|0:ot,ft=S+tt|0,(et|0)>=0){M=P,et=S;break a}if(M=P,et=S,Et[ft|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,bi(r,32,Y,0,M);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=zp(K+4|0,tt),ft=(tt|0)<0,!(ft|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(ft)break r}if(ft=61,(S|0)<0)break i;if(bi(r,32,Y,S,M),!S){S=0;break f}for(ft=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=zp(K+4|0,tt),ft=tt+ft|0,ft>>>0>S>>>0))break f;if(fi(r,K+4|0,tt),P=P+4|0,!(S>>>0>ft>>>0))break}}bi(r,32,Y,S,M^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&ot)break e;if(ft=61,S=Pt[b|0](r,Ve[K+64>>3],Y,et,M,S)|0,(S|0)>=0)continue s;break i}gt[K+55|0]=l[K+64>>2],et=1,tt=$t,M=P;break a}P=Et[S+1|0],S=S+1|0}if(r)break t;if(!mt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(_p((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}ft=28;break i}if(Q=ft-tt|0,et=(et|0)>(Q|0)?et:Q,(et|0)>(Z^2147483647))break e;if(ft=61,P=et+Z|0,S=(P|0)<(Y|0)?Y:P,(Mt|0)<(S|0))break i;bi(r,32,S,P,M),fi(r,Lt,Z),bi(r,48,S,P,M^65536),bi(r,48,et,Q,0),fi(r,tt,Q),bi(r,32,S,P,M^8192);continue}break}W=0;break t}ft=61}l[1781]=ft}W=-1}return Tt=K+80|0,W}function NE(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),tt=0,ft=m(0),Q=0;Q=Tt+-64|0,Tt=Q,k=l[r>>2],Vi(Q+8|0,0,56),l[1755]=l[1755]+1,Ep(k),S=m(a),b=I[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[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))}ft=m(y+m(ce(k,2,S)+we(k,2,S))),tt=1;break t}y=m(0),b=I[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(b==b)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(b==b)break s;P=4344}switch(y=I[P>>2],ft=m(Yt),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}ft=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,ft=S;break t}tt=2,ft=y}K=m(h),b=I[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[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(ce(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),b=I[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=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(b==b)break s;P=4344}switch(y=I[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=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(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}dn(k,ft,b,u,tt,r,S,K,1,0,l[k+568>>2],Q+8|0,0,l[1755])&&(xp(k,Et[k+300|0]&3,S,K,S),Cp(k,+I[l[k+568>>2]+20>>2],0,0)),Tt=Q- -64|0}function UE(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,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(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=(xt(2,(h&-1073741825)+536870912|0),Bt()),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,tt!=tt)break i;u=(xt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Ye(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=I[P+28>>2],r=k!=k,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],r=k!=k,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&r))break t}for(Gi(a+24|0,P+24|0,204);;){if(r=Et[a+4|0],r&4)break t;if(gt[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 BE(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,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,M=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],Q=r,k=Tt-32|0,Tt=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=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,ft=h,b=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,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;tt=b,b=K&31,(K&63)>>>0>=32?(h=tt<<b,b=0):(h=(1<<b)-1&tt>>>32-b|y<<b,b=tt<<b),y=h,W=b,tt=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|tt>>>b),b=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[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=b,l[k+28>>2]=y,a=15361-et|0;r:{if(a&64){u=ft,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,ft=0,S=0;break r}if(!a)break r;y=ft,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=ft,h=a&31,(a&63)>>>0>=32?(r=0,ft=S>>>h|0):(r=S>>>h|0,ft=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=ft,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}Tt=k+32|0,xt(0,a|0),xt(1,Q&-2147483648|r),Y=M,Z=+Ae(),Ve[Y>>3]=Z}function dn(r,a,h,u,y,b,k,S,P,K,tt,ft,Q,et){var M=m(0),W=0,Y=0,Z=0,ot=0,lt=m(0),mt=0,bt=0,Lt=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&Et[r+4|0]&4)&&(ot=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,ot=1}mt=Q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(lt=ce(r,2,k),Lt=we(r,2,k),M=m(ce(r,0,k)+we(r,0,k)),Q=r+524|0,lt=m(lt+Lt),kp(y,a,b,h,l[r+532>>2],I[Q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],lt,M,tt))break i;if(Y=l[r+320>>2],!Y)break e;for(W=r+324|0;;){if(Q=W+He(Z,24)|0,kp(y,a,b,h,l[Q+8>>2],I[Q>>2],l[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],lt,M,tt))break i;if(Z=Z+1|0,(Y|0)==(Z|0))break}break e}if(!P){if(bt=l[r+320>>2],!bt)break e;for(Y=r+324|0;;){W=He(Z,24),Q=W+Y|0,M=I[Q>>2];s:{n:{if(!(M!=M|a!=a)){if(m(Ye(m(M-a)))<m(9999999747378752e-20))break n;break s}if(M==M|a==a)break s}W=Y+W|0,M=I[W+4>>2];n:{if(!(M!=M|h!=h)){if(m(Ye(m(M-h)))<m(9999999747378752e-20))break n;break s}if(M==M|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,(bt|0)==(Z|0))break}break e}Q=r+524|0,M=I[Q>>2];s:{if(!(M!=M|a!=a)){if(m(Ye(m(M-a)))<m(9999999747378752e-20))break s;break e}if(M==M|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(b|0)?Q:0,M=I[r+528>>2],Q=M!=M,Y=h!=h;s:{if(Q|Y){Q=Q&Y;break s}Q=m(Ye(m(M-h)))<m(9999999747378752e-20)}Q=Q?W:0;break i}vp(r,a,h,u,y,b,k,S,P,tt,ft,mt,et,K),l[r+316>>2]=u;break r}if(!(!Q|ot)){I[r+516>>2]=I[Q+16>>2],I[r+520>>2]=I[Q+20>>2],u=(P?12:16)+ft|0,l[u>>2]=l[u>>2]+1;break t}if(vp(r,a,h,u,y,b,k,S,P,tt,ft,mt,et,K),l[r+316>>2]=u,Q)break t}Q=l[r+320>>2],u=Q+1|0,u>>>0>hp[ft+8>>2]&&(l[ft+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=(He(Q,24)+r|0)+324|0),l[u+12>>2]=b,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=Et[r+4|0],y=u|1,gt[r+4|0]=y,!(u&4)))break t;gt[r+4|0]=y&251}return l[r+312>>2]=et,!Q|ot}function Sh(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=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=vr(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=vr(u^b),u=(u|0)==32?vr(a^h)+32|0:u,h=63-u|0,Bi=0-(u>>>0>63)|0;break i}Bi=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=_h(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),tt=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),ft=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|ft>>>h),a=a|tt,Bi=y|b,l[1750]=l[1750]&a,l[1751]=Bi&K,a=P^1}if(!(a|u))break}b=l[1751],y=l[1750]}i:{if(y|b){u=vr(b),h=63-((u|0)==32?vr(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=_h(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(Lh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=_h(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!Lh(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,b=0,k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0;S=Tt-80|0,Tt=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,Ps(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=$a(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=Ps(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=$a(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,tt=l[y+12>>2],l[y+12>>2]=l[b+12>>2],l[b+12>>2]=tt,(a|0)!=(u|0)&&(l[b+8>>2]=((u-a|0)+3&-4)+a),!K)break e;yi(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,ft=y,Q=Ps(l[y+4>>2]-h|0,a,h),l[ft+4>>2]=Q,u=l[r+560>>2]-k|0,k=Ps(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;yi(a)}for(l[P+552>>2]=r;a=Et[r+4|0],!!(!(a&4)&&(gt[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)););Tt=S+80|0;return}l[S+16>>2]=4075,nr(r,S+16|0),Qi(),le()}l[S>>2]=4208,nr(r,S),Qi(),le()}xs(),le()}function Ap(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,gt[r+4|0]=Et[r+4|0]&128,u=Vi(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(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,Vi(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Vi(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,Jp((a|0)!=0,2760),gt[r+4|0]=Et[r+4|0]|1,gt[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function Xe(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=I[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=I[k>>2],b=m(Yt),l[k+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}b=m(m(y*u)*m(.009999999776482582));break s}b=I[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=I[k>>2],b=m(Yt),l[k+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}b=m(m(y*u)*m(.009999999776482582));break a}b=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}b=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(!(b>=m(0)))return h;y=h<b?b:h}return y}function Ep(r){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0,et=0,M=0;for(k=Tt-16|0,l[k+8>>2]=0,l[k+12>>2]=1,tt=r+200|0,ft=r+572|0,Q=r+208|0,et=r+216|0,r=0;;){M=r,K=l[(k+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(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=(xt(2,(h&-1073741825)+536870912|0),Bt()),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=(xt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&b!=b|m(Ye(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+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)+ft|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(M&1))break}}function Gi(r,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return DE(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(gt[h|0]=Et[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;gt[h|0]=Et[a|0],gt[h+1|0]=Et[a+1|0],gt[h+2|0]=Et[a+2|0],gt[h+3|0]=Et[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;gt[h|0]=Et[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Tp(r,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),K=0,tt=0,ft=m(0),Q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+r|0,b=I[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=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(2,(k&-1073741825)+536870912|0),Bt()),!(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=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(b==b)break s;r=4344}switch(h=I[r>>2],b=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;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(ft=S,Q=Ph(S,b),et=b!=b|tt,et?ft:Q),r=h!=h,!(r|P!=P))return ae(h,P);S=r?P:h}return S}function kp(r,a,h,u,y,b,k,S,P,K,tt,ft,Q){var et=m(0),M=m(0),W=0,Y=0,Z=m(0),ot=m(0),lt=m(0),mt=0,bt=0;if(P<m(0)|K<m(0))r=0;else{Z=b,ot=a,lt=u,M=S;t:{if(!Q||(et=I[Q+20>>2],M=S,et==m(0)))break t;mt=+et,ot=Gr(+a,mt,0,0),lt=Gr(+u,mt,0,0),Z=Gr(+b,mt,0,0),M=Gr(+S,mt,0,0)}et=M,Q=0;t:{if((r|0)!=(y|0))break t;if(bt=Z!=Z,Q=ot!=ot,bt|Q){Q=Q&bt;break t}Q=m(Ye(m(Z-ot)))<m(9999999747378752e-20)}bt=Q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,Q=lt!=lt,W|Q){W=Q&W;break t}W=m(Ye(m(et-lt)))<m(9999999747378752e-20)}Y=1,Q=1;t:{if(bt)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<b)|(r|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){Q=r&y;break t}Q=m(Ye(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-ft);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(Y=0,!(a<S)|(r|(k|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(Ye(m(a-K)))<m(9999999747378752e-20)}r=Q&Y}return r}function Rh(r){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(vi(+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,xt(0,(h?S:u)|0),xt(1,(h?k:a)|P),+Ae()}function Lh(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>u2()<<16>>>0&&!(IE(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,!(gt[(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=vr(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 wp(r,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=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,Bi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;b=(vr(h)+33|0)-vr(a)|0,k=0-b|0;break e}r=(a>>>0)/0|0,Bi=0;break t}if(u=32-vr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;b=h?31-vr(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),Bi=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,ft=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=ft-(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=tt|r<<1,tt=y&1,b=b-1|0,!!b;);Bi=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Bi=a}return r}function tl(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(Yt),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 Sp(r,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=Tt-320|0,Tt=h,u=Vi(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Vi(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,Gi(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,gt[r+4|0]=Et[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=Dp(l[b>>2],Et[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););Tt=u+320|0}function _h(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=vr(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 VE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0;y=Tt-320|0,Tt=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!$p(r,u)))break t;if((r|0)==(a|0)){for(h=Vi(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Vi(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,Gi(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=Et[r+4|0],a&4)break t;if(gt[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}}Tt=y+320|0}function Rp(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(r){if(k=Tt-32|0,Tt=k,a=l[r>>2],u=l[a+552>>2],u&&($p(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=$a(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=Ps(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;yi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,yi(u)),yi(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),Tt=k+32|0,yi(r)}}function HE(r){r=r|0;var a=0,h=0,u=0;u=Tt-624|0,Tt=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=Ap(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,Gi(r+24|0,a+24|0,204),Gi(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,yi(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,Tt=u+624|0;return}l[u+16>>2]=3301,nr(r,u+16|0),Qi(),le()}l[u>>2]=2047,nr(r,u),Qi(),le()}function Lp(){$E(7084,3067),ME(7085,2480,1,1,0),ls(7086,2140,1,-128,127),ls(7087,2133,1,-128,127),ls(7088,2131,1,0,255),ls(7089,1287,2,-32768,32767),ls(7090,1278,2,0,65535),ls(7091,1316,4,-2147483648,2147483647),ls(7092,1307,4,0,-1),ls(7093,2659,4,-2147483648,2147483647),ls(7094,2650,4,0,-1),s2(7095,1777,-2147483648,2147483647),s2(7096,1776,0,-1),fp(7097,1770,4),fp(7098,3015,8),pp(7099,2677),pp(7100,3904),Th(7101,4,2664),Th(7102,2,2689),Th(7103,4,2704),OE(7104,2485),Ri(7105,0,3835),Ri(7106,0,3937),Ri(7107,1,3865),Ri(7108,2,3467),Ri(7109,3,3498),Ri(7110,4,3538),Ri(7111,5,3567),Ri(7112,4,3974),Ri(7113,5,4004),Ri(7106,0,3669),Ri(7107,1,3636),Ri(7108,2,3735),Ri(7109,3,3701),Ri(7110,4,3802),Ri(7111,5,3768),Ri(7114,6,3605),Ri(7115,7,4043)}function Ps(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 Gi(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(gt[u|0]=Et[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,gt[u|0]=Et[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,gt[h+r|0]=Et[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(;gt[u|0]=Et[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function _p(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]=$n[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=gt[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]=Et[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Ve[r>>3]=Ve[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 Cp(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0,et=m(0),M=m(0),W=m(0),Y=0,Z=m(0);t:{if(a==0||(et=I[r+248>>2],M=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=Et[r+4|0]&8,b=y>>>3|0,Y=r,Z=Gr(P,a,0,b),I[Y+228>>2]=Z,K=+W,Y=r,Z=Gr(K,a,0,b),I[Y+232>>2]=Z,tt=+M,k=Rh(tt*a),b=k==k&Ye(k)<1e-4,S=!(b|k!=k?b:Ye(k+-1)<1e-4),ft=+et,k=Rh(ft*a),b=k==k&Ye(k)<1e-4,Q=!(b|k!=k?b:Ye(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,Y=r,Z=m(Gr(h+tt,a,y&S,y&!S)-Gr(h,a,0,y)),I[Y+244>>2]=Z,u=K+u,Y=r,Z=m(Gr(u+ft,a,y&Q,y&!Q)-Gr(u,a,0,y)),I[Y+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,Cp(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Vi(r,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(gt[r|0]=a,u=r+h|0,gt[u-1|0]=a,h>>>0<3)||(gt[r+2|0]=a,gt[r+1|0]=a,gt[u-3|0]=a,gt[u-2|0]=a,h>>>0<7)||(gt[r+3|0]=a,gt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=He(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=xh(a,0,1,1),b=Bi,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 yi(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=vr(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 WE(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=Tt-32|0,Tt=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(!i2(xE(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 Tt=u+32|0,r|0}function jE(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;h=Tt-96|0,Tt=h,l[h>>2]=r,u=Tt-16|0,Tt=u,l[u+12>>2]=h,r=Tt-144|0,Tt=r,r=Gi(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,Ip(r,2202,h,0,0),y&&(a=l[r+20>>2],gt[a-((a|0)==l[r+16>>2])|0]=0),Tt=r+144|0,Tt=u+16|0,r=b;t:{if(r&3)for(;;){if(!Et[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,!!Et[r|0];);}return r=(r-b|0)+1|0,a=Sh(r),a?r=Gi(a,b,r):r=0,Tt=h+96|0,r|0}function Ip(r,a,h,u,y){var b=0,k=0,S=0,P=0;b=Tt-208|0,Tt=b,l[b+204>>2]=h,h=b+160|0,Vi(h,0,40),l[b+200>>2]=l[b+204>>2];t:{if((bp(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,Hp(r))break r}h=bp(r,a,b+200|0,b+80|0,b+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|k&32,y=r&32?-1:h,!P)break t}return Tt=b+208|0,y}function el(r){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),K=0;b=Tt-16|0,Tt=b,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(Et[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[b>>2]=3409,nr(r,b),Qi(),le()}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),Et[y+4|0]&2|(Et[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(el(u)+I[u+232>>2])}return Tt=b+16|0,h}function Nn(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=I[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=I[P>>2],S=m(Yt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(xt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(ce(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[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}I[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=Ur(r,4,b,2140081935);break t}a=Br(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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),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}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=Ur(r,5,b,2140081935);break t}a=Br(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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),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}k=y==y?y:m(0)}return k}function Dp(r,a,h,u,y,b){var k=0;t:{r:{if(r){i:{if(a&4){b=Pt[r|0](h,u,y,b)|0;break i}b=Pt[r|0](h,u,y)|0}if(b)break r}if(b=dt(588),a=Gi(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=dt(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}xs(),le()}function nr(r,a){var h=0,u=0,y=0;y=Tt-16|0,Tt=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],Et[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(!Et[7016]){h=dt(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,gt[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,gt[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(Et[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}Tt=y+16|0}function Ma(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=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],b=m(Yt),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}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Os(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=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],b=m(Yt),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}b=m(m(u*h)*m(.009999999776482582))}return b}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 KE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Tt-16|0,Tt=u,l[u+12>>2]=h;t:{if(r)break t;if(Et[7016]){r=l[1753];break t}r=dt(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,gt[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,gt[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(Et[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}Tt=u+16|0,Qi(),le()}I[r+20>>2]=a==m(0)?m(0):a,Tt=h+16|0}function xp(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=Qp(r,b,h),u=Qp(r,a,u),S=ce(r,b,y),k=r+228|0,P=b<<2,I[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,b,y),I[k+(l[P+4304>>2]<<2)>>2]=h+S,h=ce(r,a,y),b=a<<2,I[k+(l[b+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),I[k+(l[b+4304>>2]<<2)>>2]=u+h}function zE(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=Tt-48|0,Tt=k,P=l[a+8>>2];t:{if(gt[7052]&1){a=l[1762];break t}a=up(5,4480)|0,gt[7052]=1,l[1762]=a}l[k+40>>2]=b,I[k+32>>2]=y,l[k+24>>2]=u,I[k+16>>2]=h,S=+RE(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,SE(u|0),Tt=k+48|0}function YE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=Tt-32|0,Tt=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){b=(y|15)+1|0,k=dt(b),l[u+16>>2]=b|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,b=y+k|0;break r}if(gt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Gi(k,a+4|0,y)}return gt[b|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),wE(l[u+24>>2]),r=l[u+24>>2],Oa(r|0),Oa(l[u>>2]),gt[u+19|0]<0&&yi(l[u+8>>2]),Tt=u+32|0,r|0}xs(),le()}function fi(r,a,h){var u=0,y=0,b=0;if(!(Et[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Hp(a))break r;r=l[a+16>>2]}if(b=l[a+20>>2],r-b>>>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,Et[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,b=l[a+20>>2]}Gi(b,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function Ch(r,a,h){var u=0,y=0,b=0;u=Tt-16|0,Tt=u,y=r+24|0,Pt[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(Pt[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=Et[r+4|0],a&4)break t;if(gt[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}}Tt=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 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=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(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function ce(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(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function XE(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&&(Gi(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&&(Gi(b,a,u),b=u+l[y>>2]|0,l[y>>2]=b,l[y+4>>2]=l[y+4>>2]-u),gt[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=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(Yt)}return ae(h,m(0))}function fe(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(Yt)}return ae(h,m(0))}function ZE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function qE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function QE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function Gr(r,a,h,u){var y=0,b=0,k=0;r=r*a,y=Rh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Ye(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ye(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=Ye(y+-.5)<1e-4?1:0}r=r+b}return r!=r|a!=a?m(Yt):m(r/a)}function Pp(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 Op(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 JE(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function tT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function eT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function iT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function rT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function sT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function nT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(Et[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(Et[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,nr(r,h),Qi(),le()}function aT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(Et[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(Et[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,nr(r,h),Qi(),le()}function oT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(Et[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(Et[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,nr(r,h),Qi(),le()}function lT(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=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,Ve[r+8>>3]=u}function Vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ye(r))==m(dp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(qi(r),Jt(2)&-2147483648|1602224127)),Bt()),a=(qi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),Jt(2)-536870912|1073741824)}return a}function yr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ye(r))==m(dp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(qi(r),Jt(2)&-2147483648|1610612735)),Bt()),a=(qi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),Jt(2)-536870912|0)}return a}function cT(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(Yt),(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 hT(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=Tt-16|0,Tt=k,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](k,a,h,u,y,b),r=dt(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,Tt=k+16|0,r|0}function Mp(r,a){t:{if(a){a=e2(l[a>>2]);break t}r:{if(Et[7016]){a=l[1753];break r}a=dt(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,gt[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,gt[7016]=1,l[1752]=l[1752]+1}a=e2(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function dT(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=yr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=Et[r+4|0],a&4)break t;if(gt[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 uT(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=yr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=Et[r+4|0],a&4)break t;if(gt[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 fT(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=Yt,(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 pT(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=Et[r+4|0],a&4)break t;if(gt[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 Un(r,a,h){var u=0,y=0,b=0;t:{if(!a){u=r;break t}for(;u=wp(r,a,10),y=Bi,r=xh(u,y,246,0)+r|0,h=h-1|0,gt[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,gt[h|0]=He(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function gT(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=Et[r+4|0],a&4)break t;if(gt[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 mT(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=Et[r+4|0],a&4)break t;if(gt[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 vT(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=Et[r+4|0],a&4)break t;if(gt[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 yT(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=Et[r+4|0],h&4)break t;if(gt[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 bT(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=Et[r+4|0],h&4)break t;if(gt[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 AT(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=Et[r+4|0],h&4)break t;if(gt[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 ET(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=Et[r+4|0],h&4)break t;if(gt[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 TT(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=Et[r+4|0],a&4)break t;if(gt[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 kT(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=Et[r+4|0],a&4)break t;if(gt[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 wT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=Et[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(gt[r+4|0]=h&253|(a?2:0);;){if(a=Et[r+4|0],a&4)break t;if(gt[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 ST(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Tt-16|0,Tt=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=dt(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,Tt=u+16|0,r|0}function $p(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,Ps(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function RT(r){r=r|0;var a=0,h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],l[r+8>>2]){for(;a=Et[r+4|0],!!(!(a&4)&&(gt[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)););Tt=h+16|0;return}l[h>>2]=1024,nr(r,h),Qi(),le()}function Fp(r,a){var h=0,u=0,y=0;if(vi(+r),u=Jt(1)|0,y=Jt(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=Fp(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 LT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Tt-16|0,Tt=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=dt(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,Tt=h+16|0,r|0}function il(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=Et[r+4|0],a&4)break t;if(gt[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 rl(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=Et[r+4|0],a&4)break t;if(gt[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;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=Et[r+4|0],a&4)break t;if(gt[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 Ih(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=Et[r+4|0],a&4)break t;if(gt[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 Np(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=Et[r+4|0],a&4)break t;if(gt[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 Dh(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=Et[r+4|0],a&4)break t;if(gt[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 Up(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=Et[r+4|0],a&4)break t;if(gt[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 _T(){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;);Lh(48),l[1756]=16,l[1757]=0,yp(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,Lp(),l[1770]=l[1768],l[1768]=7076}function ar(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 sl(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 xh(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=He(y,b),k=h&65535,S=r&65535,P=He(k,S),b=(P>>>16|0)+He(b,k)|0,y=(b&65535)+He(y,S)|0,Bi=(He(a,h)+K|0)+He(r,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function Bp(r,a){var h=0,u=0,y=0;u=Tt-16|0,Tt=u,h=Et[r+4|0],y=h&-17,gt[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,gt[r+4|0]=h,Tt=u+16|0;return}l[u>>2]=4128,nr(r,u),Qi(),le()}function Gp(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=Gn(r)!=m(0)}return a}function bi(r,a,h,u,y){var b=0;if(b=Tt-256|0,Tt=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Vi(b,a&255,h?u:256),!h)for(;fi(r,b,256),u=u-256|0,u>>>0>255;);fi(r,b,u)}Tt=b+256|0}function un(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]}Pp(r,u)}function fn(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]}Pp(r,u)}function Gn(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),gt[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 Vp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=gt[u|0],al(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=He(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function $a(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=dt(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}Nh(),le()}function Hp(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 CT(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=Tt-16|0,Tt=k,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](k,a,h,u,y,b),I[r>>2]=Ve[k>>3],I[r+4>>2]=Ve[k+8>>3],Tt=k+16|0}function IT(){var r=0,a=0;return a=dt(4),r=dt(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,gt[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function DT(r,a){r=r|0,a=a|0,a=l[a>>2],Ve[r>>3]=I[a+228>>2],Ve[r+8>>3]=I[a+236>>2],Ve[r+16>>3]=I[a+232>>2],Ve[r+24>>3]=I[a+240>>2],Ve[r+32>>3]=I[a+244>>2],Ve[r+40>>3]=I[a+248>>2]}function xT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Tt-48|0,Tt=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=Gi(dt(48),h,48),Tt=h+48|0,r|0}function PT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Tt-16|0,Tt=y,r=i2(_E(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Tt=y+16|0,Bi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function OT(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 MT(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}xs(),le()}function $T(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]),Pt[b|0](a,h,u,y)}function FT(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 Wp(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 jp(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 NT(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 UT(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 dt(r){var a=0;r=r||1;t:{for(;;){if(a=Sh(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}xs(),le()}return a}function BT(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 Ms(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 pn(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 Ph(r,a){return qi(r),(Jt(2)&2147483647)>>>0<=2139095040?(qi(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(TE(r,a))):a}function ae(r,a){return qi(r),(Jt(2)&2147483647)>>>0<=2139095040?(qi(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(kE(r,a))):a}function Kp(r,a){r=r|0,a=a|0;var h=0;return h=Tt-16|0,Tt=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Oa(l[h+8>>2]),Tt=h+16|0,r|0}function GT(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 VT(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?a2(5816,u,y)|0:a2(5672,u,y)|0}function zp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}gt[r|0]=a,r=1}return r}function HT(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 Yp(r,a){var h=0,u=0;h=dt(4),l[h>>2]=a,u=dt(4),l[u>>2]=a,Jo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Vn(r,a){var h=0,u=0;h=dt(4),l[h>>2]=a,u=dt(4),l[u>>2]=a,Jo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Oh(r,a){var h=0;t:{if(gt[7044]&1){h=l[1760];break t}h=up(1,4464)|0,gt[7044]=1,l[1760]=h}LE(h|0,r|0,a|0,0)}function WT(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 jT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=mp((gt[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function KT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=mp((gt[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Xp(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 zT(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=gt[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function YT(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),Bp(l[r>>2],14)}function XT(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 ZT(r){r=r|0;var a=0;return a=dt(12),gt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function qT(r){r=r|0;var a=0;return a=dt(12),gt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function QT(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function JT(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),Bp(l[r>>2],0)}function Zp(r){return r=r|0,l[r>>2]=4572,Et[r+4|0]&&Oh(l[r+8>>2],1759),Oa(l[r+8>>2]),r|0}function qp(r){return r=r|0,l[r>>2]=4452,Et[r+4|0]&&Oh(l[r+8>>2],1759),Oa(l[r+8>>2]),r|0}function t3(){var r=0;return r=dt(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function Qp(r,a,h){return ar(r,a)?Os(r,a,h):(h=Ma(r,a,h),h==h&&(h=m(-h)),h)}function Jp(r,a){var h=0;h=Tt-16|0,Tt=h,r||(l[h>>2]=a,nr(0,h),Qi(),le()),Tt=h+16|0}function t2(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&yi(a),l[1752]=l[1752]-1,yi(r))}function e3(r,a){return r=r|0,a=a|0,a>>>0>=3&&(xs(),le()),l[l[r>>2]+12>>2]>>>a&1}function i3(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 r3(){var r=0;return r=dt(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function s3(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(Yt):a)}function n3(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function a3(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function e2(r){var a=0;return a=Ap(dt(588),r),Jp((r|0)!=0,2808),a}function o3(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function l3(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function c3(r,a){r=r|0,a=a|0,r=l[r>>2],gt[r+8|0]=Et[r+8|0]&254|a}function h3(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function d3(r,a,h){r=r|0,a=a|0,h=+h,Dh(l[r>>2],a,yr(m(h)))}function u3(r,a,h){r=r|0,a=a|0,h=+h,Dh(l[r>>2],a,Vr(m(h)))}function f3(r,a,h,u){return Bi=0,0}function p3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,yr(m(h)))}function g3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,Vr(m(h)))}function m3(r,a,h){r=r|0,a=a|0,h=+h,Up(l[r>>2],a,yr(m(h)))}function v3(r,a,h){r=r|0,a=a|0,h=+h,Up(l[r>>2],a,Vr(m(h)))}function y3(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function b3(r,a){r=r|0,a=a|0,Dh(l[r>>2],a,2141891242)}function Mh(r,a,h){r=r|0,a=a|0,h=+h,Ve[l[r>>2]+a>>3]=h}function A3(r){return r=r|0,(Et[l[r>>2]+4|0]&2)>>>1|0}function E3(r){return r=r|0,(Et[l[r>>2]+4|0]&4)>>>2|0}function T3(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function k3(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function w3(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function S3(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function $h(r,a){return r=r|0,a=a|0,+Ve[l[r>>2]+a>>3]}function R3(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function L3(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function _3(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function C3(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function I3(r,a){r=r|0,a=+a,Bn(l[r>>2],0,yr(m(a)))}function D3(r,a){r=r|0,a=+a,Bn(l[r>>2],0,Vr(m(a)))}function x3(r,a){r=r|0,a=+a,Bn(l[r>>2],1,yr(m(a)))}function P3(r,a){r=r|0,a=+a,Bn(l[r>>2],1,Vr(m(a)))}function O3(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function M3(r,a){r=r|0,a=+a,il(l[r>>2],0,yr(m(a)))}function $3(r,a){r=r|0,a=+a,il(l[r>>2],0,Vr(m(a)))}function F3(r,a){r=r|0,a=+a,il(l[r>>2],1,yr(m(a)))}function N3(r,a){r=r|0,a=+a,il(l[r>>2],1,Vr(m(a)))}function U3(r,a){r=r|0,a=+a,rl(l[r>>2],0,yr(m(a)))}function B3(r,a){r=r|0,a=+a,rl(l[r>>2],1,yr(m(a)))}function G3(r,a){r=r|0,a=+a,rl(l[r>>2],1,Vr(m(a)))}function V3(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function H3(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function W3(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function nl(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function j3(r,a){r=r|0,a=+a,rl(l[r>>2],0,Vr(m(a)))}function i2(r){return r?(l[1781]=r,-1):0}function K3(r,a){r=r|0,a=+a,Ih(l[r>>2],yr(m(a)))}function z3(r,a){r=r|0,a=+a,Ih(l[r>>2],Vr(m(a)))}function r2(r,a,h){return m(ce(r,a,h)+we(r,a,h))}function Y3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function s2(r,a,h,u){CE(r|0,a|0,8,0,h|0,-1,u|0)}function X3(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function Z3(r){return r=r|0,l[l[r>>2]+16>>2]&1}function q3(r){return r=r|0,$n[l[r>>2]+26>>1]&3}function Q3(r){r=r|0,Bn(l[r>>2],0,2141891242)}function J3(r){r=r|0,Bn(l[r>>2],1,2141891242)}function tk(r){return r=r|0,+I[l[r>>2]+228>>2]}function ek(r){return r=r|0,+I[l[r>>2]+236>>2]}function ik(r){return r=r|0,+I[l[r>>2]+232>>2]}function rk(r){return r=r|0,+I[l[r>>2]+240>>2]}function sk(r){return r=r|0,+I[l[r>>2]+244>>2]}function nk(r){return r=r|0,+I[l[r>>2]+248>>2]}function ak(r){return r=r|0,PE(l[r+60>>2])|0}function ok(r){return r=r|0,l[l[r>>2]+16>>2]}function lk(r){return r=r|0,gt[l[r>>2]+8|0]&1}function ck(r,a){r=r|0,a=a|0,Ch(l[r>>2],5,a)}function hk(r,a){r=r|0,a=a|0,Ch(l[r>>2],6,a)}function dk(r,a){r=r|0,a=a|0,Ch(l[r>>2],7,a)}function uk(r){r=r|0,Ih(l[r>>2],2141891242)}function n2(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function fk(r){return r=r|0,Mp(dt(12),r)|0}function pk(r){r=r|0,Oh(l[r+8>>2],3293)}function a2(r,a,h){return Ip(r,a,h,2,3)}function o2(r){return r=r|0,Pt[r|0]()|0}function l2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function gk(){return Vi(dt(48),0,48)|0}function Qi(){Pt[l[1490]](),Nh(),le()}function mk(){return Mp(dt(12),0)|0}function Fh(r){r=r|0,r&&yi(r)}function al(r){return r-48>>>0<10}function vk(r){return 7032}function yk(r){return 7036}function bk(r){return 7056}function Ak(r){return 7059}function Ek(r){return 7062}function Tk(r){return 7067}function Sr(r){return r=r|0,r|0}function c2(r){r=r|0,gt[r+4|0]=1}function kk(r){r=r|0,yi(Zp(r))}function wk(r){r=r|0,yi(qp(r))}function Sk(r){return 0}function h2(r){le()}function d2(){Nh(),le()}function Nh(){xs(),le()}H=Et,Rt();var Pt=G([null,VT,FE,BE,Sr,O3,T3,k3,Sr,Sr,Sr,Sr,Sr,Sr,CT,h3,yp,vk,nl,hT,yk,Sr,Sr,nl,c2,n2,Kp,ZT,YE,jT,bk,nl,Xp,Ak,Sr,Sr,nl,c2,n2,Kp,qT,KT,Ek,t2,o2,IT,l2,t2,MT,Wp,KE,BT,o3,Ms,X3,Ms,c3,e3,jp,Z3,pn,ok,pn,lk,gk,Fh,t3,Fh,r3,Fh,$h,Mh,C3,y3,Tk,Rp,o2,mk,Y3,fk,l2,Rp,HE,Xp,UE,Ms,vT,Ms,m3,NT,v3,ck,hk,dk,kT,mT,TT,d3,u3,b3,pT,gT,bT,GT,K3,z3,uk,AT,ET,I3,D3,Q3,x3,P3,J3,M3,$3,F3,N3,U3,j3,B3,G3,yT,dT,p3,g3,uT,q3,pn,qE,ST,V3,w3,S3,H3,R3,W3,QE,lT,LT,a3,HT,zT,tT,eT,iT,rT,sT,JE,s3,fT,UT,L3,_3,ZE,cT,FT,GE,Wp,VE,Ms,l3,pn,n3,pn,OT,jp,A3,pn,wT,Ms,YT,Ms,JT,WT,Ms,XT,RT,E3,pn,NE,$T,tk,ek,ik,rk,sk,nk,DT,xT,nT,aT,oT,$h,Mh,$h,Mh,Lp,qp,wk,zE,h2,d2,Zp,kk,pk,h2,ak,WE,PT,Sk,f3,XE,d2]);function u2(){return Ui.byteLength/65536|0}function Rk(r){r=r|0;var a=u2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(He(h,65536)),y=new Int8Array(u);y.set(gt),gt=new Int8Array(u),Nr=new Int16Array(u),l=new Int32Array(u),Et=new Uint8Array(u),$n=new Uint16Array(u),hp=new Uint32Array(u),I=new Float32Array(u),Ve=new Float64Array(u),Ui=u,sr.buffer=Ui,H=Et}return a}return{E:_T,F:jE,G:QT,H:Sh,I:Pt,J:yi,K:i3}}return Qo(_)}(L)}var C=Error,x={};A=[],typeof x!="object"&&_t("no native wasm support detected");var O,B=!1;function D(L,_,G){G=_+G;for(var H="";!(_>=G);){var rt=L[_++];if(!rt)break;if(rt&128){var yt=L[_++]&63;if((rt&224)==192)H+=String.fromCharCode((rt&31)<<6|yt);else{var ct=L[_++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|ct:(rt&7)<<18|yt<<12|ct<<6|L[_++]&63,65536>rt?H+=String.fromCharCode(rt):(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else H+=String.fromCharCode(rt)}return H}var V,$,z,it,at,J,wt,vt,Ot;function Gt(L){V=L,o.HEAP8=$=new Int8Array(L),o.HEAP16=it=new Int16Array(L),o.HEAP32=J=new Int32Array(L),o.HEAPU8=z=new Uint8Array(L),o.HEAPU16=at=new Uint16Array(L),o.HEAPU32=wt=new Uint32Array(L),o.HEAPF32=vt=new Float32Array(L),o.HEAPF64=Ot=new Float64Array(L)}var U=o.INITIAL_MEMORY||16777216;o.wasmMemory?O=o.wasmMemory:O=new E,O&&(V=O.buffer),U=V.byteLength,Gt(V);var q,At=[],F=[],N=[];function j(){var L=o.preRun.shift();At.unshift(L)}var nt=0,ut=null;function _t(L){throw o.onAbort&&o.onAbort(L),L="Aborted("+L+")",v(L),B=!0,L=new C(L+". Build with -sASSERTIONS for more info."),d(L),L}function Nt(L){return L.startsWith("data:application/octet-stream;base64,")}var jt;if(jt="<<< WASM_BINARY_FILE >>>",!Nt(jt)){var ue=jt;jt=o.locateFile?o.locateFile(ue,p):p+ue}function me(L){var _=jt;try{try{if(_==jt&&A)new Uint8Array(A);else{if(Nt(_)){try{var G=bE(_.slice(37)),H=new Uint8Array(G.length);for(_=0;_<G.length;++_)H[_]=G.charCodeAt(_);var rt=H}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)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(Ct){_t(Ct)}var ct=new T,Rt=new w(L)}catch(Ct){throw L=Ct.toString(),v("failed to compile wasm module: "+L),(L.includes("imported Memory")||L.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)."),Ct}return[Rt,ct]}function ge(L){for(;0<L.length;)L.shift()(o)}function je(L){if(L===void 0)return"_unknown";L=L.replace(/[^a-zA-Z0-9_]/g,"$");var _=L.charCodeAt(0);return 48<=_&&57>=_?"_"+L:L}function Re(L,_){return L=je(L),function(){return _.apply(this,arguments)}}var Kt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],be=[];function he(L){var _=Error,G=Re(L,function(H){this.name=L,this.message=H,H=Error(H).stack,H!==void 0&&(this.stack=this.toString()+`
|
90
|
-
`+H.replace(/^Error(:[^\n]*)?\n/,""))});return G.prototype=Object.create(_.prototype),G.prototype.constructor=G,G.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},G}var Pe=void 0;function Ut(L){throw new Pe(L)}var Ke=L=>(L||Ut("Cannot use deleted val. handle = "+L),Kt[L].value),Fe=L=>{switch(L){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var _=be.length?be.pop():Kt.length;return Kt[_]={fa:1,value:L},_}},Ge=void 0,ke=void 0;function de(L){for(var _="";z[L];)_+=ke[z[L++]];return _}var ze=[];function oe(){for(;ze.length;){var L=ze.pop();L.L.Z=!1,L.delete()}}var Ne=void 0,Ue={};function di(L,_){for(_===void 0&&Ut("ptr should not be undefined");L.P;)_=L.aa(_),L=L.P;return _}var Oe={};function xi(L){L=EE(L);var _=de(L);return Ds(L),_}function ss(L,_){var G=Oe[L];return G===void 0&&Ut(_+" has unknown type "+xi(L)),G}function ui(){}var kr=!1;function Ls(L){--L.count.value,L.count.value===0&&(L.S?L.T.V(L.S):L.O.M.V(L.N))}function _s(L,_,G){return _===G?L:G.P===void 0?null:(L=_s(L,_,G.P),L===null?null:G.ma(L))}var rr={};function ht(L,_){return _=di(L,_),Ue[_]}var Vt=void 0;function Xt(L){throw new Vt(L)}function ve(L,_){return _.O&&_.N||Xt("makeClassHandle requires ptr and ptrType"),!!_.T!=!!_.S&&Xt("Both smartPtrType and smartPtr must be specified"),_.count={value:1},se(Object.create(L,{L:{value:_}}))}function se(L){return typeof FinalizationRegistry>"u"?(se=_=>_,L):(kr=new FinalizationRegistry(_=>{Ls(_.L)}),se=_=>{var G=_.L;return G.S&&kr.register(_,{L:G},_),_},ui=_=>{kr.unregister(_)},se(L))}var li={};function Pi(L){for(;L.length;){var _=L.pop();L.pop()(_)}}function fr(L){return this.fromWireType(J[L>>2])}var ns={},pr={};function gr(L,_,G){function H(Rt){Rt=G(Rt),Rt.length!==L.length&&Xt("Mismatched type converter count");for(var Ct=0;Ct<L.length;++Ct)Oi(L[Ct],Rt[Ct])}L.forEach(function(Rt){pr[Rt]=_});var rt=Array(_.length),yt=[],ct=0;_.forEach((Rt,Ct)=>{Oe.hasOwnProperty(Rt)?rt[Ct]=Oe[Rt]:(yt.push(Rt),ns.hasOwnProperty(Rt)||(ns[Rt]=[]),ns[Rt].push(()=>{rt[Ct]=Oe[Rt],++ct,ct===yt.length&&H(rt)}))}),yt.length===0&&H(rt)}function Cs(L){switch(L){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+L)}}function Oi(L,_,G={}){if(!("argPackAdvance"in _))throw new TypeError("registerType registeredInstance requires argPackAdvance");var H=_.name;if(L||Ut('type "'+H+'" must have a positive integer typeid pointer'),Oe.hasOwnProperty(L)){if(G.ta)return;Ut("Cannot register type '"+H+"' twice")}Oe[L]=_,delete pr[L],ns.hasOwnProperty(L)&&(_=ns[L],delete ns[L],_.forEach(rt=>rt()))}function Pa(L){Ut(L.L.O.M.name+" instance already deleted")}function mr(){}function Is(L,_,G){if(L[_].R===void 0){var H=L[_];L[_]=function(){return L[_].R.hasOwnProperty(arguments.length)||Ut("Function '"+G+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+L[_].R+")!"),L[_].R[arguments.length].apply(this,arguments)},L[_].R=[],L[_].R[H.Y]=H}}function tE(L,_){o.hasOwnProperty(L)?(Ut("Cannot register public name '"+L+"' twice"),Is(o,L,L),o.hasOwnProperty(void 0)&&Ut("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[L].R[void 0]=_):o[L]=_}function eE(L,_,G,H,rt,yt,ct,Rt){this.name=L,this.constructor=_,this.W=G,this.V=H,this.P=rt,this.oa=yt,this.aa=ct,this.ma=Rt,this.ia=[]}function vh(L,_,G){for(;_!==G;)_.aa||Ut("Expected null or instance of "+G.name+", got an instance of "+_.name),L=_.aa(L),_=_.P;return L}function iE(L,_){return _===null?(this.da&&Ut("null is not a valid "+this.name),0):(_.L||Ut('Cannot pass "'+Eh(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),vh(_.L.N,_.L.O.M,this.M))}function rE(L,_){if(_===null){if(this.da&&Ut("null is not a valid "+this.name),this.ca){var G=this.ea();return L!==null&&L.push(this.V,G),G}return 0}if(_.L||Ut('Cannot pass "'+Eh(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&_.L.O.ba&&Ut("Cannot convert argument of type "+(_.L.T?_.L.T.name:_.L.O.name)+" to parameter type "+this.name),G=vh(_.L.N,_.L.O.M,this.M),this.ca)switch(_.L.S===void 0&&Ut("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:_.L.T===this?G=_.L.S:Ut("Cannot convert argument of type "+(_.L.T?_.L.T.name:_.L.O.name)+" to parameter type "+this.name);break;case 1:G=_.L.S;break;case 2:if(_.L.T===this)G=_.L.S;else{var H=_.clone();G=this.wa(G,Fe(function(){H.delete()})),L!==null&&L.push(this.V,G)}break;default:Ut("Unsupporting sharing policy")}return G}function sE(L,_){return _===null?(this.da&&Ut("null is not a valid "+this.name),0):(_.L||Ut('Cannot pass "'+Eh(_)+'" as a '+this.name),_.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),_.L.O.ba&&Ut("Cannot convert argument of type "+_.L.O.name+" to parameter type "+this.name),vh(_.L.N,_.L.O.M,this.M))}function as(L,_,G,H){this.name=L,this.M=_,this.da=G,this.ba=H,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,_.P!==void 0?this.toWireType=rE:(this.toWireType=H?iE:sE,this.U=null)}function nE(L,_){o.hasOwnProperty(L)||Xt("Replacing nonexistant public symbol"),o[L]=_,o[L].Y=void 0}function aE(L,_){var G=[];return function(){if(G.length=0,Object.assign(G,arguments),L.includes("j")){var H=o["dynCall_"+L];H=G&&G.length?H.apply(null,[_].concat(G)):H.call(null,_)}else H=q.get(_).apply(null,G);return H}}function wr(L,_){L=de(L);var G=L.includes("j")?aE(L,_):q.get(_);return typeof G!="function"&&Ut("unknown function pointer with signature "+L+": "+_),G}var sp=void 0;function Yo(L,_){function G(yt){rt[yt]||Oe[yt]||(pr[yt]?pr[yt].forEach(G):(H.push(yt),rt[yt]=!0))}var H=[],rt={};throw _.forEach(G),new sp(L+": "+H.map(xi).join([", "]))}function yh(L,_,G,H,rt){var yt=_.length;2>yt&&Ut("argTypes array size mismatch! Must at least get return value and 'this' types!");var ct=_[1]!==null&&G!==null,Rt=!1;for(G=1;G<_.length;++G)if(_[G]!==null&&_[G].U===void 0){Rt=!0;break}var Ct=_[0].name!=="void",It=yt-2,Ft=Array(It),zt=[],Jt=[];return function(){if(arguments.length!==It&&Ut("function "+L+" called with "+arguments.length+" arguments, expected "+It+" args!"),Jt.length=0,zt.length=ct?2:1,zt[0]=rt,ct){var xt=_[1].toWireType(Jt,this);zt[1]=xt}for(var Ae=0;Ae<It;++Ae)Ft[Ae]=_[Ae+2].toWireType(Jt,arguments[Ae]),zt.push(Ft[Ae]);if(Ae=H.apply(null,zt),Rt)Pi(Jt);else for(var vi=ct?1:2;vi<_.length;vi++){var le=vi===1?xt:Ft[vi-2];_[vi].U!==null&&_[vi].U(le)}return xt=Ct?_[0].fromWireType(Ae):void 0,xt}}function bh(L,_){for(var G=[],H=0;H<L;H++)G.push(wt[_+4*H>>2]);return G}function Ah(L){4<L&&--Kt[L].fa===0&&(Kt[L]=void 0,be.push(L))}function Eh(L){if(L===null)return"null";var _=typeof L;return _==="object"||_==="array"||_==="function"?L.toString():""+L}function oE(L,_){switch(_){case 2:return function(G){return this.fromWireType(vt[G>>2])};case 3:return function(G){return this.fromWireType(Ot[G>>3])};default:throw new TypeError("Unknown float type: "+L)}}function lE(L,_,G){switch(_){case 0:return G?function(H){return $[H]}:function(H){return z[H]};case 1:return G?function(H){return it[H>>1]}:function(H){return at[H>>1]};case 2:return G?function(H){return J[H>>2]}:function(H){return wt[H>>2]};default:throw new TypeError("Unknown integer type: "+L)}}function cE(L,_){for(var G="",H=0;!(H>=_/2);++H){var rt=it[L+2*H>>1];if(rt==0)break;G+=String.fromCharCode(rt)}return G}function hE(L,_,G){if(G===void 0&&(G=2147483647),2>G)return 0;G-=2;var H=_;G=G<2*L.length?G/2:L.length;for(var rt=0;rt<G;++rt)it[_>>1]=L.charCodeAt(rt),_+=2;return it[_>>1]=0,_-H}function dE(L){return 2*L.length}function uE(L,_){for(var G=0,H="";!(G>=_/4);){var rt=J[L+4*G>>2];if(rt==0)break;++G,65536<=rt?(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):H+=String.fromCharCode(rt)}return H}function fE(L,_,G){if(G===void 0&&(G=2147483647),4>G)return 0;var H=_;G=H+G-4;for(var rt=0;rt<L.length;++rt){var yt=L.charCodeAt(rt);if(55296<=yt&&57343>=yt){var ct=L.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|ct&1023}if(J[_>>2]=yt,_+=4,_+4>G)break}return J[_>>2]=0,_-H}function pE(L){for(var _=0,G=0;G<L.length;++G){var H=L.charCodeAt(G);55296<=H&&57343>=H&&++G,_+=4}return _}var gE={};function np(L){var _=gE[L];return _===void 0?de(L):_}var Xo=[];function mE(L){var _=Xo.length;return Xo.push(L),_}function vE(L,_){for(var G=Array(L),H=0;H<L;++H)G[H]=ss(wt[_+4*H>>2],"parameter "+H);return G}var ap=[],yE=[null,[],[]];Pe=o.BindingError=he("BindingError"),o.count_emval_handles=function(){for(var L=0,_=5;_<Kt.length;++_)Kt[_]!==void 0&&++L;return L},o.get_first_emval=function(){for(var L=5;L<Kt.length;++L)if(Kt[L]!==void 0)return Kt[L];return null},Ge=o.PureVirtualError=he("PureVirtualError");for(var op=Array(256),Zo=0;256>Zo;++Zo)op[Zo]=String.fromCharCode(Zo);ke=op,o.getInheritedInstanceCount=function(){return Object.keys(Ue).length},o.getLiveInheritedInstances=function(){var L=[],_;for(_ in Ue)Ue.hasOwnProperty(_)&&L.push(Ue[_]);return L},o.flushPendingDeletes=oe,o.setDelayFunction=function(L){Ne=L,ze.length&&Ne&&Ne(oe)},Vt=o.InternalError=he("InternalError"),mr.prototype.isAliasOf=function(L){if(!(this instanceof mr&&L instanceof mr))return!1;var _=this.L.O.M,G=this.L.N,H=L.L.O.M;for(L=L.L.N;_.P;)G=_.aa(G),_=_.P;for(;H.P;)L=H.aa(L),H=H.P;return _===H&&G===L},mr.prototype.clone=function(){if(this.L.N||Pa(this),this.L.$)return this.L.count.value+=1,this;var L=se,_=Object,G=_.create,H=Object.getPrototypeOf(this),rt=this.L;return L=L(G.call(_,H,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),L.L.count.value+=1,L.L.Z=!1,L},mr.prototype.delete=function(){this.L.N||Pa(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ui(this),Ls(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},mr.prototype.isDeleted=function(){return!this.L.N},mr.prototype.deleteLater=function(){return this.L.N||Pa(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ze.push(this),ze.length===1&&Ne&&Ne(oe),this.L.Z=!0,this},as.prototype.pa=function(L){return this.ja&&(L=this.ja(L)),L},as.prototype.ga=function(L){this.V&&this.V(L)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=fr,as.prototype.deleteObject=function(L){L!==null&&L.delete()},as.prototype.fromWireType=function(L){function _(){return this.ca?ve(this.M.W,{O:this.va,N:G,T:this,S:L}):ve(this.M.W,{O:this,N:L})}var G=this.pa(L);if(!G)return this.ga(L),null;var H=ht(this.M,G);if(H!==void 0)return H.L.count.value===0?(H.L.N=G,H.L.S=L,H.clone()):(H=H.clone(),this.ga(L),H);if(H=this.M.oa(G),H=rr[H],!H)return _.call(this);H=this.ba?H.ka:H.pointerType;var rt=_s(G,this.M,H.M);return rt===null?_.call(this):this.ca?ve(H.M.W,{O:H,N:rt,T:this,S:L}):ve(H.M.W,{O:H,N:rt})},sp=o.UnboundTypeError=he("UnboundTypeError");var bE=typeof atob=="function"?atob:function(L){var _="",G=0;L=L.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(G++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(G++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(G++)),ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(L.charAt(G++));H=H<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var Rt=(yt&3)<<6|ct;_+=String.fromCharCode(H),yt!==64&&(_+=String.fromCharCode(rt)),ct!==64&&(_+=String.fromCharCode(Rt))}while(G<L.length);return _},AE={q:function(L,_,G){L=de(L),_=ss(_,"wrapper"),G=Ke(G);var H=[].slice,rt=_.M,yt=rt.W,ct=rt.P.W,Rt=rt.P.constructor;L=Re(L,function(){rt.P.ia.forEach((function(It){if(this[It]===ct[It])throw new Ge("Pure virtual function "+It+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,H.call(arguments))}),yt.__construct=function(){this===yt&&Ut("Pass correct 'this' to __construct");var It=Rt.implement.apply(void 0,[this].concat(H.call(arguments)));ui(It);var Ft=It.L;It.notifyOnDestruction(),Ft.$=!0,Object.defineProperties(this,{L:{value:Ft}}),se(this),It=Ft.N,It=di(rt,It),Ue.hasOwnProperty(It)?Ut("Tried to register registered instance: "+It):Ue[It]=this},yt.__destruct=function(){this===yt&&Ut("Pass correct 'this' to __destruct"),ui(this);var It=this.L.N;It=di(rt,It),Ue.hasOwnProperty(It)?delete Ue[It]:Ut("Tried to unregister unregistered instance: "+It)},L.prototype=Object.create(yt);for(var Ct in G)L.prototype[Ct]=G[Ct];return Fe(L)},k:function(L){var _=li[L];delete li[L];var G=_.ea,H=_.V,rt=_.ha,yt=rt.map(ct=>ct.sa).concat(rt.map(ct=>ct.ya));gr([L],yt,ct=>{var Rt={};return rt.forEach((Ct,It)=>{var Ft=ct[It],zt=Ct.qa,Jt=Ct.ra,xt=ct[It+rt.length],Ae=Ct.xa,vi=Ct.za;Rt[Ct.na]={read:le=>Ft.fromWireType(zt(Jt,le)),write:(le,qi)=>{var Bt=[];Ae(vi,le,xt.toWireType(Bt,qi)),Pi(Bt)}}}),[{name:_.name,fromWireType:function(Ct){var It={},Ft;for(Ft in Rt)It[Ft]=Rt[Ft].read(Ct);return H(Ct),It},toWireType:function(Ct,It){for(var Ft in Rt)if(!(Ft in It))throw new TypeError('Missing field: "'+Ft+'"');var zt=G();for(Ft in Rt)Rt[Ft].write(zt,It[Ft]);return Ct!==null&&Ct.push(H,zt),zt},argPackAdvance:8,readValueFromPointer:fr,U:H}]})},w:function(){},C:function(L,_,G,H,rt){var yt=Cs(G);_=de(_),Oi(L,{name:_,fromWireType:function(ct){return!!ct},toWireType:function(ct,Rt){return Rt?H:rt},argPackAdvance:8,readValueFromPointer:function(ct){if(G===1)var Rt=$;else if(G===2)Rt=it;else if(G===4)Rt=J;else throw new TypeError("Unknown boolean type size: "+_);return this.fromWireType(Rt[ct>>yt])},U:null})},g:function(L,_,G,H,rt,yt,ct,Rt,Ct,It,Ft,zt,Jt){Ft=de(Ft),yt=wr(rt,yt),Rt&&(Rt=wr(ct,Rt)),It&&(It=wr(Ct,It)),Jt=wr(zt,Jt);var xt=je(Ft);tE(xt,function(){Yo("Cannot construct "+Ft+" due to unbound types",[H])}),gr([L,_,G],H?[H]:[],function(Ae){if(Ae=Ae[0],H)var vi=Ae.M,le=vi.W;else le=mr.prototype;Ae=Re(xt,function(){if(Object.getPrototypeOf(this)!==qi)throw new Pe("Use 'new' to construct "+Ft);if(Bt.X===void 0)throw new Pe(Ft+" has no accessible constructor");var ni=Bt.X[arguments.length];if(ni===void 0)throw new Pe("Tried to invoke ctor of "+Ft+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ni.apply(this,arguments)});var qi=Object.create(le,{constructor:{value:Ae}});Ae.prototype=qi;var Bt=new eE(Ft,Ae,qi,Jt,vi,yt,Rt,It);vi=new as(Ft,Bt,!0,!1),le=new as(Ft+"*",Bt,!1,!1);var Qo=new as(Ft+" const*",Bt,!1,!0);return rr[L]={pointerType:le,ka:Qo},nE(xt,Ae),[vi,le,Qo]})},d:function(L,_,G,H,rt,yt,ct){var Rt=bh(G,H);_=de(_),yt=wr(rt,yt),gr([],[L],function(Ct){function It(){Yo("Cannot call "+Ft+" due to unbound types",Rt)}Ct=Ct[0];var Ft=Ct.name+"."+_;_.startsWith("@@")&&(_=Symbol[_.substring(2)]);var zt=Ct.M.constructor;return zt[_]===void 0?(It.Y=G-1,zt[_]=It):(Is(zt,_,Ft),zt[_].R[G-1]=It),gr([],Rt,function(Jt){return Jt=yh(Ft,[Jt[0],null].concat(Jt.slice(1)),null,yt,ct),zt[_].R===void 0?(Jt.Y=G-1,zt[_]=Jt):zt[_].R[G-1]=Jt,[]}),[]})},p:function(L,_,G,H,rt,yt){0<_||_t();var ct=bh(_,G);rt=wr(H,rt),gr([],[L],function(Rt){Rt=Rt[0];var Ct="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[_-1]!==void 0)throw new Pe("Cannot register multiple constructors with identical number of parameters ("+(_-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[_-1]=()=>{Yo("Cannot construct "+Rt.name+" due to unbound types",ct)},gr([],ct,function(It){return It.splice(1,0,null),Rt.M.X[_-1]=yh(Ct,It,null,rt,yt),[]}),[]})},b:function(L,_,G,H,rt,yt,ct,Rt){var Ct=bh(G,H);_=de(_),yt=wr(rt,yt),gr([],[L],function(It){function Ft(){Yo("Cannot call "+zt+" due to unbound types",Ct)}It=It[0];var zt=It.name+"."+_;_.startsWith("@@")&&(_=Symbol[_.substring(2)]),Rt&&It.M.ia.push(_);var Jt=It.M.W,xt=Jt[_];return xt===void 0||xt.R===void 0&&xt.className!==It.name&&xt.Y===G-2?(Ft.Y=G-2,Ft.className=It.name,Jt[_]=Ft):(Is(Jt,_,zt),Jt[_].R[G-2]=Ft),gr([],Ct,function(Ae){return Ae=yh(zt,Ae,It,yt,ct),Jt[_].R===void 0?(Ae.Y=G-2,Jt[_]=Ae):Jt[_].R[G-2]=Ae,[]}),[]})},B:function(L,_){_=de(_),Oi(L,{name:_,fromWireType:function(G){var H=Ke(G);return Ah(G),H},toWireType:function(G,H){return Fe(H)},argPackAdvance:8,readValueFromPointer:fr,U:null})},n:function(L,_,G){G=Cs(G),_=de(_),Oi(L,{name:_,fromWireType:function(H){return H},toWireType:function(H,rt){return rt},argPackAdvance:8,readValueFromPointer:oE(_,G),U:null})},e:function(L,_,G,H,rt){_=de(_),rt===-1&&(rt=4294967295),rt=Cs(G);var yt=Rt=>Rt;if(H===0){var ct=32-8*G;yt=Rt=>Rt<<ct>>>ct}G=_.includes("unsigned")?function(Rt,Ct){return Ct>>>0}:function(Rt,Ct){return Ct},Oi(L,{name:_,fromWireType:yt,toWireType:G,argPackAdvance:8,readValueFromPointer:lE(_,rt,H!==0),U:null})},c:function(L,_,G){function H(yt){yt>>=2;var ct=wt;return new rt(V,ct[yt+1],ct[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][_];G=de(G),Oi(L,{name:G,fromWireType:H,argPackAdvance:8,readValueFromPointer:H},{ta:!0})},o:function(L,_){_=de(_);var G=_==="std::string";Oi(L,{name:_,fromWireType:function(H){var rt=wt[H>>2],yt=H+4;if(G)for(var ct=yt,Rt=0;Rt<=rt;++Rt){var Ct=yt+Rt;if(Rt==rt||z[Ct]==0){if(ct=ct?D(z,ct,Ct-ct):"",It===void 0)var It=ct;else It+=String.fromCharCode(0),It+=ct;ct=Ct+1}}else{for(It=Array(rt),Rt=0;Rt<rt;++Rt)It[Rt]=String.fromCharCode(z[yt+Rt]);It=It.join("")}return Ds(H),It},toWireType:function(H,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,ct=typeof rt=="string";if(ct||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Ut("Cannot pass non-string to std::string"),G&&ct){var Rt=0;for(yt=0;yt<rt.length;++yt){var Ct=rt.charCodeAt(yt);127>=Ct?Rt++:2047>=Ct?Rt+=2:55296<=Ct&&57343>=Ct?(Rt+=4,++yt):Rt+=3}yt=Rt}else yt=rt.length;if(Rt=lp(4+yt+1),Ct=Rt+4,wt[Rt>>2]=yt,G&&ct){if(ct=Ct,Ct=yt+1,yt=z,0<Ct){Ct=ct+Ct-1;for(var It=0;It<rt.length;++It){var Ft=rt.charCodeAt(It);if(55296<=Ft&&57343>=Ft){var zt=rt.charCodeAt(++It);Ft=65536+((Ft&1023)<<10)|zt&1023}if(127>=Ft){if(ct>=Ct)break;yt[ct++]=Ft}else{if(2047>=Ft){if(ct+1>=Ct)break;yt[ct++]=192|Ft>>6}else{if(65535>=Ft){if(ct+2>=Ct)break;yt[ct++]=224|Ft>>12}else{if(ct+3>=Ct)break;yt[ct++]=240|Ft>>18,yt[ct++]=128|Ft>>12&63}yt[ct++]=128|Ft>>6&63}yt[ct++]=128|Ft&63}}yt[ct]=0}}else if(ct)for(ct=0;ct<yt;++ct)It=rt.charCodeAt(ct),255<It&&(Ds(Ct),Ut("String has UTF-16 code units that do not fit in 8 bits")),z[Ct+ct]=It;else for(ct=0;ct<yt;++ct)z[Ct+ct]=rt[ct];return H!==null&&H.push(Ds,Rt),Rt},argPackAdvance:8,readValueFromPointer:fr,U:function(H){Ds(H)}})},j:function(L,_,G){if(G=de(G),_===2)var H=cE,rt=hE,yt=dE,ct=()=>at,Rt=1;else _===4&&(H=uE,rt=fE,yt=pE,ct=()=>wt,Rt=2);Oi(L,{name:G,fromWireType:function(Ct){for(var It=wt[Ct>>2],Ft=ct(),zt,Jt=Ct+4,xt=0;xt<=It;++xt){var Ae=Ct+4+xt*_;(xt==It||Ft[Ae>>Rt]==0)&&(Jt=H(Jt,Ae-Jt),zt===void 0?zt=Jt:(zt+=String.fromCharCode(0),zt+=Jt),Jt=Ae+_)}return Ds(Ct),zt},toWireType:function(Ct,It){typeof It!="string"&&Ut("Cannot pass non-string to C++ string type "+G);var Ft=yt(It),zt=lp(4+Ft+_);return wt[zt>>2]=Ft>>Rt,rt(It,zt+4,Ft+_),Ct!==null&&Ct.push(Ds,zt),zt},argPackAdvance:8,readValueFromPointer:fr,U:function(Ct){Ds(Ct)}})},l:function(L,_,G,H,rt,yt){li[L]={name:de(_),ea:wr(G,H),V:wr(rt,yt),ha:[]}},i:function(L,_,G,H,rt,yt,ct,Rt,Ct,It){li[L].ha.push({na:de(_),sa:G,qa:wr(H,rt),ra:yt,ya:ct,xa:wr(Rt,Ct),za:It})},D:function(L,_){_=de(_),Oi(L,{ua:!0,name:_,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(L,_,G,H,rt){L=Xo[L],_=Ke(_),G=np(G);var yt=[];return wt[H>>2]=Fe(yt),L(_,G,yt,rt)},u:function(L,_,G,H){L=Xo[L],_=Ke(_),G=np(G),L(_,G,null,H)},h:Ah,m:function(L,_){var G=vE(L,_),H=G[0];_=H.name+"_$"+G.slice(1).map(function(ct){return ct.name}).join("_")+"$";var rt=ap[_];if(rt!==void 0)return rt;var yt=Array(L-1);return rt=mE((ct,Rt,Ct,It)=>{for(var Ft=0,zt=0;zt<L-1;++zt)yt[zt]=G[zt+1].readValueFromPointer(It+Ft),Ft+=G[zt+1].argPackAdvance;for(ct=ct[Rt].apply(ct,yt),zt=0;zt<L-1;++zt)G[zt+1].la&&G[zt+1].la(yt[zt]);if(!H.ua)return H.toWireType(Ct,ct)}),ap[_]=rt},r:function(L){4<L&&(Kt[L].fa+=1)},s:function(L){var _=Ke(L);Pi(_),Ah(L)},f:function(){_t("")},y:function(L,_,G){z.copyWithin(L,_,_+G)},x:function(L){var _=z.length;if(L>>>=0,2147483648<L)return!1;for(var G=1;4>=G;G*=2){var H=_*(1+.2/G);H=Math.min(H,L+100663296);var rt=Math;H=Math.max(L,H),rt=rt.min.call(rt,2147483648,H+(65536-H%65536)%65536);t:{try{O.grow(rt-V.byteLength+65535>>>16),Gt(O.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(L,_,G,H){for(var rt=0,yt=0;yt<G;yt++){var ct=wt[_>>2],Rt=wt[_+4>>2];_+=8;for(var Ct=0;Ct<Rt;Ct++){var It=z[ct+Ct],Ft=yE[L];It===0||It===10?((L===1?g:v)(D(Ft,0)),Ft.length=0):Ft.push(It)}rt+=Rt}return wt[H>>2]=rt,0},a:O},Mn=function(){function L(G){o.asm=G.exports,q=o.asm.I,F.unshift(o.asm.E),nt--,o.monitorRunDependencies&&o.monitorRunDependencies(nt),nt==0&&ut&&(G=ut,ut=null,G())}var _={a:AE};if(nt++,o.monitorRunDependencies&&o.monitorRunDependencies(nt),o.instantiateWasm)try{return o.instantiateWasm(_,L)}catch(G){v("Module.instantiateWasm callback failed with error: "+G),d(G)}return _=me(_),L(_[0]),o.asm}();o.___wasm_call_ctors=Mn.E;var EE=o.___getTypeName=Mn.F;o.__embind_initialize_bindings=Mn.G;var lp=o._malloc=Mn.H,Ds=o._free=Mn.J;o.dynCall_jiji=Mn.K;var qo;ut=function L(){qo||cp(),qo||(ut=L)};function cp(){function L(){if(!qo&&(qo=!0,o.calledRun=!0,!B)){if(ge(F),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var _=o.postRun.shift();N.unshift(_)}ge(N)}}if(!(0<nt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)j();ge(At),0<nt||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),L()},1)):L())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return cp(),n}})();s.exports=e})(Kd);var dm=Kd.exports;(function(s){Object.defineProperty(s,"__esModule",{value:!0});var t={};s.default=void 0;var e=n($l),i=ie;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in s&&s[d]===i[d]||Object.defineProperty(s,d,{enumerable:!0,get:function(){return i[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=dm;var c=(0,e.default)(o());s.default=c})(Ee);const zd=om(Ee),Zr=1.8;function um(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:typeof s.top=="number"?s.top*t:s.top,right:typeof s.right=="number"?s.right*t:s.right,bottom:typeof s.bottom=="number"?s.bottom*t:s.bottom,left:typeof s.left=="number"?s.left*t:s.left}}function Yd(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:(typeof s.top=="number"?s.top*t:s.top)??0,right:(typeof s.right=="number"?s.right*t:s.right)??0,bottom:(typeof s.bottom=="number"?s.bottom*t:s.bottom)??0,left:(typeof s.left=="number"?s.left*t:s.left)??0}}function fm(s,t=1){return typeof s=="number"?{topLeft:s*t,topRight:s*t,bottomRight:s*t,bottomLeft:s*t}:{topLeft:((s==null?void 0:s.topLeft)??0)*t,topRight:((s==null?void 0:s.topRight)??0)*t,bottomRight:((s==null?void 0:s.bottomRight)??0)*t,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*t}}function Xd(s,{layout:t,scale:e=1}){const{position:i="static",inset:n,width:o,height:c,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:A,margin:E,padding:T,direction:w="column",align:C="start",alignSelf:x,justify:O="start"}=t,B={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(s.setPositionType(B[i]),n){const{top:z,right:it,bottom:at,left:J}=um(n,e);z&&s.setPosition(Ee.Edge.Top,z),it&&s.setPosition(Ee.Edge.Right,it),at&&s.setPosition(Ee.Edge.Bottom,at),J&&s.setPosition(Ee.Edge.Left,J)}const D={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};s.setFlexDirection(D[w]);const V={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};s.setAlignItems(V[C]),x&&s.setAlignSelf(V[x]);const $={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(s.setJustifyContent($[O]),E){const{top:z,right:it,bottom:at,left:J}=Yd(E,e);s.setMargin(Ee.Edge.Top,z),s.setMargin(Ee.Edge.Right,it),s.setMargin(Ee.Edge.Bottom,at),s.setMargin(Ee.Edge.Left,J)}if(T){const{top:z,right:it,bottom:at,left:J}=Yd(T,e);s.setPadding(Ee.Edge.Top,z),s.setPadding(Ee.Edge.Right,it),s.setPadding(Ee.Edge.Bottom,at),s.setPadding(Ee.Edge.Left,J)}v&&s.setFlex(v),s.setGap(Ee.Gutter.All,(A??0)*e),o&&s.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?s.setHeight("100%"):s.setHeight(typeof c=="number"?c*e:c)),d&&s.setMinWidth(typeof d=="number"?d*e:d),f&&s.setMinHeight(typeof f=="number"?f*e:f),p&&s.setMaxWidth(typeof p=="number"?p*e:p),g&&s.setMaxHeight(typeof g=="number"?g*e:g)}function Zd({canvas:s,debug:t=!1,scale:e=1,position:i=[]}){i.forEach(({x:n,y:o,width:c,height:d,childNodes:f,element:p})=>{const g=s.getContext("2d",{alpha:!1});if(g){const{radius:v,draw:A}=p;if(A){if(g.save(),v){const{topLeft:E,topRight:T,bottomRight:w,bottomLeft:C}=fm(v,e);g.beginPath(),g.moveTo(n+Math.min(d/Zr,E),o),g.lineTo(n+c-Math.min(d/Zr,T),o),g.quadraticCurveTo(n+c,o,n+c,o+Math.min(d/Zr,T)),g.lineTo(n+c,o+d-Math.min(d/Zr,w)),g.quadraticCurveTo(n+c,o+d,n+c-Math.min(d/Zr,w),o+d),g.lineTo(n+Math.min(d/Zr,C),o+d),g.quadraticCurveTo(n,o+d,n,o+d-Math.min(d/Zr,C)),g.lineTo(n,o+Math.min(d/Zr,E)),g.quadraticCurveTo(n,o,n+Math.min(d/Zr,E),o),g.closePath(),t&&(g.strokeStyle="blue",g.stroke()),g.clip()}A({scale:e,dx:n,dy:o,dw:c,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,c,d)),g.restore()}}Zd({canvas:s,debug:t,scale:e,position:f})})}function qd(s,t,e){const i=t.map((n,o)=>{const c=zd.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return Xd(c,{layout:g,scale:e}),s.insertChild(c,o),{node:c,element:n,childNodes:qd(c,f,e)}});return s.calculateLayout(),i}function Qd(s,t,e=0,i=0){const{top:n,left:o}=s.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:A}=c.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:n+T,width:v,height:A,element:d,childNodes:Qd(s,f,E,T)}})}function Jd(s,t){s.forEach(({node:e,element:i,childNodes:n})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:c,maxHeight:d,scale:t});e.setHeight(f)}Jd(n,t)})}function pm({canvas:s,origin:t,elements:e,...i}){const n={inset:{top:0,left:0},width:s.width,height:s.height,...t},o=zd.Node.create();Xd(o,{layout:n}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=qd(o,e,f);Jd(p,f),o.calculateLayout();const g=Qd(o,p);return Zd({...i,scale:f,canvas:s,position:g})}const tu=[{family:"Noto Arabic",regex:/\p{Script=Arabic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansArabic-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Chinese",regex:/\p{Script=Han}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansSC-VariableFont_wght.woff2",style:"normal"},{family:"Noto Hebrew",regex:/\p{Script=Hebrew}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansHebrew-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Hindi",regex:/\p{Script=Devanagari}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansDevanagari-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Japanese",regex:/\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansJP-VariableFont_wght.woff2",style:"normal"},{family:"Noto Korean",regex:/\p{Script=Hangul}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansKR-VariableFont_wght.woff2",style:"normal"},{family:"Noto Color Emoji",regex:/\p{Extended_Pictographic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoColorEmoji-Regular.woff2",style:"normal"}];function co({text:s,font:t}){let e=t;return tu.forEach(({family:i,regex:n})=>{n.exec(s)&&(e+=`, ${i}`)}),e}const ho=/(?<value>\d+\.?\d*)(?=px)/;function eu(s){const{visible:t=!0,node:e}=s,i=[...(e==null?void 0:e.elements)??[],...(s==null?void 0:s.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(n=>eu(n)):!1}function iu({debug:s=!1,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o=[],currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:A}){return o.map(E=>{var T,w,C,x,O,B,D,V;const{node:$,transient:z=[{from:0,duration:1/0}]}=E,it=t.getContext("2d"),at={total:c,content:d,scene:f},J={total:p,content:g,scene:v},wt=z.reduce((vt,{type:Ot="scene",from:Gt,duration:U,animation:q})=>{const At=Gt<0?J[Ot]+Gt:Gt;return at[Ot]>=At&&at[Ot]<=At+U&&(vt={type:Ot,animation:q,duration:U,from:At}),vt},null);if(it&&wt&&eu(E)){let vt=E.width,Ot=E.height,Gt=A??1;const{type:U="scene",from:q,duration:At,animation:F={type:"fade",duration:.3333333333333333}}=wt;if(F){const{type:N,duration:j}=F;N==="fade"&&(q>0&&at[U]<=q+j&&(Gt=Math.max(0,Math.min(1,(at[U]-q)/j))),q+At<J[U]&&q+At-j<=at[U]&&(Gt=Math.max(0,Math.min(1,(q+At-at[U])/j))))}if(($==null?void 0:$.type)==="text"&&$.value){const N=co({text:$.value,font:$.font});it.save(),$.wrap?Ot=({width:j,maxHeight:nt,scale:ut})=>{var _t,Nt;const jt=Wd({font:N,scale:ut,context:it,maxW:j,maxH:nt,text:$.value??"",minSize:(_t=$.fill)==null?void 0:_t.minSize,maxSize:(Nt=$.fill)==null?void 0:Nt.maxSize});return uo({context:it,font:N,fontSize:jt,text:$.value??"",maxW:j}).length*jt}:(it.font=N,vt=it.measureText($.value).width,Ot=parseFloat(((w=(T=N.match(ho))==null?void 0:T.groups)==null?void 0:w.value)??"0")),it.restore()}if(($==null?void 0:$.type)==="image"&&$.image&&$.size){const N=((C=$.image)==null?void 0:C.naturalWidth)??((x=$.image)==null?void 0:x.width),j=((O=$.image)==null?void 0:O.naturalHeight)??((B=$.image)==null?void 0:B.height),nt=N/j,ut=(D=$.size)==null?void 0:D.width,_t=(V=$.size)==null?void 0:V.height;vt=ut??(nt>=1?(_t??0)*nt:(_t??0)/nt),Ot=_t??(nt<1?(ut??0)*nt:(ut??0)/nt)}return{...E,width:vt,height:Ot,elements:iu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:E.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:Gt}),draw:({dx:N,dy:j,dw:nt,dh:ut,scale:_t})=>{var Nt,jt,ue,me,ge,je,Re,Kt,be,he,Pe,Ut,Ke;if(it.globalAlpha=Gt,$){const{type:Fe}=$;if(Fe==="box"&&(it.fillStyle=$.background,it.fillRect(N,j,nt,ut)),Fe==="text"&&$.value){const Ge=co({text:$.value,font:$.font}),ke=Wd({font:Ge,scale:_t,context:it,maxW:nt,maxH:ut,text:$.value??"",minSize:(Nt=$.fill)==null?void 0:Nt.minSize,maxSize:(jt=$.fill)==null?void 0:jt.maxSize});it.font=Ge.replace(ho,ke.toString()),it.textBaseline="top",it.fillStyle=$.color,$.wrap?uo({context:it,font:Ge,fontSize:ke,text:$.value,maxW:nt}).forEach((de,ze)=>{it.fillText(de.text,N,j+ke*ze)}):it.fillText($.value,N,j)}if(Fe==="image"&&$.image&&it.drawImage($.image,N,j,nt,ut),Fe==="video"&&((ue=$.video)!=null&&ue.node||(me=$.video)!=null&&me.getSource)){const Ge=$.format??"letterbox",ke=((je=(ge=$.video)==null?void 0:ge.getSource)==null?void 0:je.call(ge,f))??$.video.node,de=(ke==null?void 0:ke.videoWidth)??(ke==null?void 0:ke.naturalWidth)??(ke==null?void 0:ke.width),ze=(ke==null?void 0:ke.videoHeight)??(ke==null?void 0:ke.naturalHeight)??(ke==null?void 0:ke.height);if(de&&ze){const{dx:Ne,dy:Ue,dw:di,dh:Oe}=Bd({context:it,cropCanvas:e,letterboxCanvas:n,source:ke,format:Ge,crop:(Re=$==null?void 0:$.value)==null?void 0:Re.crop,sourceWidth:de,sourceHeight:ze,posX:N,posY:j,drawAreaWidth:nt,drawAreaHeight:ut});$.elements&&Bl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(j,j+Ue),left:Math.max(N,N+Ne)},width:Math.min(nt,di),height:Math.min(ut,Oe)}})}const oe=1/3;if($.poster&&c>=0&&c<=oe){it.save(),it.globalAlpha=1-c/oe;const Ne=((Kt=$.poster)==null?void 0:Kt.naturalWidth)??((be=$.poster)==null?void 0:be.width),Ue=((he=$.poster)==null?void 0:he.naturalHeight)??((Pe=$.poster)==null?void 0:Pe.height);i.width=i.height=0,i.width=nt,i.height=ut;const di=i.getContext("2d");di&&Ne&&Ue&&(Bd({context:di,cropCanvas:e,letterboxCanvas:n,source:$.poster,format:Ge,crop:(Ut=$==null?void 0:$.value)==null?void 0:Ut.crop,sourceWidth:Ne,sourceHeight:Ue,posX:0,posY:0,drawAreaWidth:nt,drawAreaHeight:ut}),$.elements&&Bl({debug:s,canvas:i,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v}),it.drawImage(i,N,j,nt,ut),it.restore())}}if(Fe==="gradient"&&$.value){const Ge=it.createLinearGradient(N+nt,j,N+nt,j+ut);(Ke=$.value)==null||Ke.forEach(ke=>{Ge.addColorStop(ke.percent,ke.color)}),it.fillStyle=Ge,it.fillRect(N,j,nt,ut)}}}}}}).filter(Boolean)}function Bl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...A}){return pm({...A,debug:s,canvas:t,elements:iu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const uo=Vd(({context:s,font:t,fontSize:e,text:i,maxW:n=1/0})=>{try{return s.save(),s.font=t.replace(ho,e.toString()),i.split(`
|
77
|
+
*/const wg=Symbol();class Za{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 n=typeof e=="object"?e:{task:e,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??Sg,this.m=n.onComplete,this.g=n.onError,this.autoRun=n.autoRun??!0,"initialValue"in n&&(this.l=n.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 n=++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===n){if(e===wg)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,n,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(n=t.complete)==null?void 0:n.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=(s,t)=>s===t||s.length===t.length&&s.every((e,i)=>!Il(e,t[i]));let qa;const Rg=new Uint8Array(16);function _g(){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(Rg)}const wi=[];for(let s=0;s<256;++s)wi.push((s+256).toString(16).slice(1));function Lg(s,t=0){return wi[s[t+0]]+wi[s[t+1]]+wi[s[t+2]]+wi[s[t+3]]+"-"+wi[s[t+4]]+wi[s[t+5]]+"-"+wi[s[t+6]]+wi[s[t+7]]+"-"+wi[s[t+8]]+wi[s[t+9]]+"-"+wi[s[t+10]]+wi[s[t+11]]+wi[s[t+12]]+wi[s[t+13]]+wi[s[t+14]]+wi[s[t+15]]}const Fd={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qs(s,t,e){if(Fd.randomUUID&&!t&&!s)return Fd.randomUUID();s=s||{};const i=s.random||(s.rng||_g)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let n=0;n<16;++n)t[e+n]=i[n];return t}return Lg(i)}const Nd="https://d2rxhdlm2q91uk.cloudfront.net",Cg="https://d1ix11aj5kfygl.cloudfront.net",Ig="https://d157jlwnudd93d.cloudfront.net",Ud="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Dg="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",xg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",Pg="http://localhost:6060/v2",Og="https://embed-dev.vouchfor.com/v2",Mg="https://embed-staging.vouchfor.com/v2",$g="https://embed.vouchfor.com/v2";function Qa(s){if(!["local","dev","staging","prod"].includes(s))throw new Error(`Unknown environment: ${s}`);if(s==="local")return{videoUrl:Nd,publicApiUrl:Ud,embedApiUrl:Pg};if(s==="dev")return{videoUrl:Nd,publicApiUrl:Ud,embedApiUrl:Og};if(s==="staging")return{videoUrl:Cg,publicApiUrl:Dg,embedApiUrl:Mg};if(s==="prod")return{videoUrl:Ig,publicApiUrl:xg,embedApiUrl:$g}}class Fg{constructor(t){this._fetching=!1,this.getVouch=async(e,i,n)=>{var g;const{embedApiUrl:o}=Qa(e),c=qs(),d=await fetch(`${o}/vouches/${n}`,{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/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,n)=>{var g;const{embedApiUrl:o}=Qa(e),c=qs(),d=await fetch(`${o}/templates/${n}`,{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/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new Za(this.host,async([e,i,n,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,n){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),this._vouch=n,t.template=v??((f=(d=n==null?void 0:n.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]);this._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]),new Za(this.host,([e,i])=>{t.vouch=e?{...e,questions:{items:e==null?void 0:e.questions.items.filter((n,o)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(o+1)))}}:void 0},()=>[this._vouch,t.questions])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const Ng=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!Ug(n,o)&&i||Object.defineProperty(s,e,o)},Ug=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},Bg=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},Gg=(s,t)=>`/* Wrapped ${s}*/
|
78
|
+
${t}`,Vg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Hg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Wg=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=Gg.bind(null,i,t.toString());Object.defineProperty(n,"name",Hg),Object.defineProperty(s,"toString",{...Vg,value:n})};function jg(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))Ng(s,t,n,e);return Bg(s,t),Wg(s,t,i),s}const Kg=new WeakMap;function ys(s,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,n=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 s.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return jg(n,s,{ignoreNonConfigurable:!0}),Kg.set(n,e),n}var Ja=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Dl(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var xl={exports:{}};(function(s,t){(function(e,i){i(t)})(Ja,function(e){function i(F){var N,j,nt=new Error(F);return N=nt,j=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(N,j):N.__proto__=j,nt}function n(F,N,j){var nt=N.slice(0,j).split(/\n/),ht=nt.length,Lt=nt[ht-1].length+1;throw i(F+=" at line "+ht+" col "+Lt+`:
|
79
|
+
|
80
|
+
`+N.split(/\n/)[ht-1]+`
|
81
|
+
`+Array(Lt).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(F){if(!(F instanceof SyntaxError))throw F}function d(F,N){return Object.prototype.hasOwnProperty.call(F,N)}function f(F,N,j){for(var nt in N)d(N,nt)&&(N[nt]==null||typeof N[nt]!="object"||nt!=="storage"&&nt!=="prefixes"||j?F[nt]=N[nt]:F[nt]=f({},N[nt]));return F}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function T(F){return E.test(F)?F.replace(E,"\\$&"):F}function w(F,N){N.rmWhitespace&&(F=F.replace(/[\r\n]+/g,`
|
82
|
+
`).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,A.lastIndex=0;var j=N.prefixes,nt=[j.h,j.b,j.i,j.r,j.c,j.e].reduce(function(Re,Kt){return Re&&Kt?Re+"|"+T(Kt):Kt?T(Kt):Re},""),ht=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(N.tags[1])+")","g"),Lt=new RegExp("([^]*?)"+T(N.tags[0])+"(-|_)?\\s*("+nt+")?\\s*","g"),Nt=0,jt=!1;function ue(Re,Kt){var be,he={f:[]},Oe=0,Ut="c";function Ke(Ue){var ui=F.slice(Nt,Ue),Le=ui.trim();if(Ut==="f")Le==="safe"?he.raw=!0:N.async&&p.test(Le)?(Le=Le.replace(p,""),he.f.push([Le,"",!0])):he.f.push([Le,""]);else if(Ut==="fp")he.f[he.f.length-1][1]+=Le;else if(Ut==="err"){if(Le){var vi=ui.search(/\S/);n("invalid syntax",F,Nt+vi)}}else he[Ut]=Le;Nt=Ue+1}for(Kt==="h"||Kt==="b"||Kt==="c"?Ut="n":Kt==="r"&&(he.raw=!0,Kt="i"),ht.lastIndex=Nt;(be=ht.exec(F))!==null;){var Fe=be[1],Ge=be[2],ke=be[3],de=be[4],ze=be[5],oe=be.index;if(Fe)Fe==="("?(Oe===0&&(Ut==="n"?(Ke(oe),Ut="p"):Ut==="f"&&(Ke(oe),Ut="fp")),Oe++):Fe===")"?--Oe===0&&Ut!=="c"&&(Ke(oe),Ut="err"):Oe===0&&Fe==="|"?(Ke(oe),Ut="f"):Fe==="=>"&&(Ke(oe),Nt+=1,Ut="res");else if(Ge)if(Ge==="/*"){var Ne=F.indexOf("*/",ht.lastIndex);Ne===-1&&n("unclosed comment",F,be.index),ht.lastIndex=Ne+2}else Ge==="'"?(v.lastIndex=be.index,v.exec(F)?ht.lastIndex=v.lastIndex:n("unclosed string",F,be.index)):Ge==='"'?(A.lastIndex=be.index,A.exec(F)?ht.lastIndex=A.lastIndex:n("unclosed string",F,be.index)):Ge==="`"&&(g.lastIndex=be.index,g.exec(F)?ht.lastIndex=g.lastIndex:n("unclosed string",F,be.index));else if(ke)return Ke(oe),Nt=oe+be[0].length,Lt.lastIndex=Nt,jt=ze,de&&Kt==="h"&&(Kt="s"),he.t=Kt,he}return n("unclosed tag",F,Re),he}var me=function Re(Kt,be){Kt.b=[],Kt.d=[];var he,Oe=!1,Ut=[];function Ke(vi,kr){vi&&(vi=function(ni,wr,_s,Ls){var rr,dt;return typeof wr.autoTrim=="string"?rr=dt=wr.autoTrim:Array.isArray(wr.autoTrim)&&(rr=wr.autoTrim[1],dt=wr.autoTrim[0]),(_s||_s===!1)&&(rr=_s),(Ls||Ls===!1)&&(dt=Ls),rr==="slurp"&&dt==="slurp"?ni.trim():(rr==="_"||rr==="slurp"?ni=String.prototype.trimLeft?ni.trimLeft():ni.replace(/^[\s\uFEFF\xA0]+/,""):rr!=="-"&&rr!=="nl"||(ni=ni.replace(/^(?:\n|\r|\r\n)/,"")),dt==="_"||dt==="slurp"?ni=String.prototype.trimRight?ni.trimRight():ni.replace(/[\s\uFEFF\xA0]+$/,""):dt!=="-"&&dt!=="nl"||(ni=ni.replace(/(?:\n|\r|\r\n)$/,"")),ni)}(vi,N,jt,kr))&&(vi=vi.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ut.push(vi))}for(;(he=Lt.exec(F))!==null;){var Fe,Ge=he[1],ke=he[2],de=he[3]||"";for(var ze in j)if(j[ze]===de){Fe=ze;break}Ke(Ge,ke),Nt=he.index+he[0].length,Fe||n("unrecognized tag type: "+de,F,Nt);var oe=ue(he.index,Fe),Ne=oe.t;if(Ne==="h"){var Ue=oe.n||"";N.async&&p.test(Ue)&&(oe.a=!0,oe.n=Ue.replace(p,"")),oe=Re(oe),Ut.push(oe)}else if(Ne==="c"){if(Kt.n===oe.n)return Oe?(Oe.d=Ut,Kt.b.push(Oe)):Kt.d=Ut,Kt;n("Helper start and end don't match",F,he.index+he[0].length)}else if(Ne==="b"){Oe?(Oe.d=Ut,Kt.b.push(Oe)):Kt.d=Ut;var ui=oe.n||"";N.async&&p.test(ui)&&(oe.a=!0,oe.n=ui.replace(p,"")),Oe=oe,Ut=[]}else if(Ne==="s"){var Le=oe.n||"";N.async&&p.test(Le)&&(oe.a=!0,oe.n=Le.replace(p,"")),Ut.push(oe)}else Ut.push(oe)}if(!be)throw i('unclosed helper "'+Kt.n+'"');return Ke(F.slice(Nt,F.length),!1),Kt.d=Ut,Kt}({f:[]},!0);if(N.plugins)for(var ge=0;ge<N.plugins.length;ge++){var je=N.plugins[ge];je.processAST&&(me.d=je.processAST(me.d,N))}return me.d}function C(F,N){var j=w(F,N),nt="var tR='';"+(N.useWith?"with("+N.varName+"||{}){":"")+V(j,N)+"if(cb){cb(null,tR)} return tR"+(N.useWith?"}":"");if(N.plugins)for(var ht=0;ht<N.plugins.length;ht++){var Lt=N.plugins[ht];Lt.processFnString&&(nt=Lt.processFnString(nt,N))}return nt}function x(F,N){for(var j=0;j<N.length;j++){var nt=N[j][0],ht=N[j][1];F=(N[j][2]?"await ":"")+"c.l('F','"+nt+"')("+F,ht&&(F+=","+ht),F+=")"}return F}function O(F,N,j,nt,ht,Lt){var Nt="{exec:"+(ht?"async ":"")+D(j,N,F)+",params:["+nt+"]";return Lt&&(Nt+=",name:'"+Lt+"'"),ht&&(Nt+=",async:true"),Nt+="}"}function B(F,N){for(var j="[",nt=0;nt<F.length;nt++){var ht=F[nt];j+=O(N,ht.res||"",ht.d,ht.p||"",ht.a,ht.n),nt<F.length&&(j+=",")}return j+="]"}function D(F,N,j){return"function("+N+"){var tR='';"+V(F,j)+"return tR}"}function V(F,N){for(var j=0,nt=F.length,ht="";j<nt;j++){var Lt=F[j];if(typeof Lt=="string")ht+="tR+='"+Lt+"';";else{var Nt=Lt.t,jt=Lt.c||"",ue=Lt.f,me=Lt.n||"",ge=Lt.p||"",je=Lt.res||"",Re=Lt.b,Kt=!!Lt.a;if(Nt==="i"){N.defaultFilter&&(jt="c.l('F','"+N.defaultFilter+"')("+jt+")");var be=x(jt,ue);!Lt.raw&&N.autoEscape&&(be="c.l('F','e')("+be+")"),ht+="tR+="+be+";"}else if(Nt==="h")if(N.storage.nativeHelpers.get(me))ht+=N.storage.nativeHelpers.get(me)(Lt,N);else{var he=(Kt?"await ":"")+"c.l('H','"+me+"')("+O(N,je,Lt.d,ge,Kt);he+=Re?","+B(Re,N):",[]",ht+="tR+="+x(he+=",c)",ue)+";"}else Nt==="s"?ht+="tR+="+x((Kt?"await ":"")+"c.l('H','"+me+"')({params:["+ge+"]},[],c)",ue)+";":Nt==="e"&&(ht+=jt+`
|
83
|
+
`)}}return ht}var $=function(){function F(N){this.cache=N}return F.prototype.define=function(N,j){this.cache[N]=j},F.prototype.get=function(N){return this.cache[N]},F.prototype.remove=function(N){delete this.cache[N]},F.prototype.reset=function(){this.cache={}},F.prototype.load=function(N){f(this.cache,N,!0)},F}();function z(F,N,j,nt){if(N&&N.length>0)throw i((nt?"Native":"")+"Helper '"+F+"' doesn't accept blocks");if(j&&j.length>0)throw i((nt?"Native":"")+"Helper '"+F+"' doesn't accept filters")}var it={"&":"&","<":"<",">":">",'"':""","'":"'"};function at(F){return it[F]}var J=new $({}),wt=new $({each:function(F,N){var j="",nt=F.params[0];if(z("each",N,!1),F.async)return new Promise(function(Lt){(function Nt(jt,ue,me,ge,je){me(jt[ue],ue).then(function(Re){ge+=Re,ue===jt.length-1?je(ge):Nt(jt,ue+1,me,ge,je)})})(nt,0,F.exec,j,Lt)});for(var ht=0;ht<nt.length;ht++)j+=F.exec(nt[ht],ht);return j},foreach:function(F,N){var j=F.params[0];if(z("foreach",N,!1),F.async)return new Promise(function(Lt){(function Nt(jt,ue,me,ge,je,Re){ge(ue[me],jt[ue[me]]).then(function(Kt){je+=Kt,me===ue.length-1?Re(je):Nt(jt,ue,me+1,ge,je,Re)})})(j,Object.keys(j),0,F.exec,"",Lt)});var nt="";for(var ht in j)d(j,ht)&&(nt+=F.exec(ht,j[ht]));return nt},include:function(F,N,j){z("include",N,!1);var nt=j.storage.templates.get(F.params[0]);if(!nt)throw i('Could not fetch template "'+F.params[0]+'"');return nt(F.params[1],j)},extends:function(F,N,j){var nt=F.params[1]||{};nt.content=F.exec();for(var ht=0;ht<N.length;ht++){var Lt=N[ht];nt[Lt.name]=Lt.exec()}var Nt=j.storage.templates.get(F.params[0]);if(!Nt)throw i('Could not fetch template "'+F.params[0]+'"');return Nt(nt,j)},useScope:function(F,N){return z("useScope",N,!1),F.exec(F.params[0])}}),vt=new $({if:function(F,N){z("if",!1,F.f,!0);var j="if("+F.p+"){"+V(F.d,N)+"}";if(F.b)for(var nt=0;nt<F.b.length;nt++){var ht=F.b[nt];ht.n==="else"?j+="else{"+V(ht.d,N)+"}":ht.n==="elif"&&(j+="else if("+ht.p+"){"+V(ht.d,N)+"}")}return j},try:function(F,N){if(z("try",!1,F.f,!0),!F.b||F.b.length!==1||F.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var j="try{"+V(F.d,N)+"}",nt=F.b[0];return j+="catch"+(nt.res?"("+nt.res+")":"")+"{"+V(nt.d,N)+"}"},block:function(F,N){return z("block",F.b,F.f,!0),"if(!"+N.varName+"["+F.p+"]){tR+=("+D(F.d,"",N)+")()}else{tR+="+N.varName+"["+F.p+"]}"}}),Ot=new $({e:function(F){var N=String(F);return/[&<>"']/.test(N)?N.replace(/[&<>"']/g,at):N}}),Gt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(F,N){if(F==="H"){var j=this.storage.helpers.get(N);if(j)return j;throw i("Can't find helper '"+N+"'")}if(F==="F"){var nt=this.storage.filters.get(N);if(nt)return nt;throw i("Can't find filter '"+N+"'")}},async:!1,storage:{helpers:wt,nativeHelpers:vt,filters:Ot,templates:J},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function U(F,N){var j={};return f(j,Gt),N&&f(j,N),F&&f(j,F),j.l.bind(j),j}function q(F,N){var j=U(N||{}),nt=Function;if(j.async){if(!c)throw i("This environment doesn't support async/await");nt=c}try{return new nt(j.varName,"c","cb",C(F,j))}catch(ht){throw ht instanceof SyntaxError?i(`Bad template syntax
|
84
|
+
|
85
|
+
`+ht.message+`
|
86
|
+
`+Array(ht.message.length+1).join("=")+`
|
87
|
+
`+C(F,j)):ht}}function At(F,N){var j;return N.cache&&N.name&&N.storage.templates.get(N.name)?N.storage.templates.get(N.name):(j=typeof F=="function"?F:q(F,N),N.cache&&N.name&&N.storage.templates.define(N.name,j),j)}Gt.l.bind(Gt),e.compile=q,e.compileScope=V,e.compileScopeIntoFunction=D,e.compileToString=C,e.defaultConfig=Gt,e.filters=Ot,e.getConfig=U,e.helpers=wt,e.nativeHelpers=vt,e.parse=w,e.render=function(F,N,j,nt){var ht=U(j||{});if(!ht.async)return At(F,ht)(N,ht);if(!nt){if(typeof o=="function")return new o(function(Lt,Nt){try{Lt(At(F,ht)(N,ht))}catch(jt){Nt(jt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{At(F,ht)(N,ht,nt)}catch(Lt){return nt(Lt)}},e.templates=J,Object.defineProperty(e,"__esModule",{value:!0})})})(xl,xl.exports);var to=xl.exports,Pl={exports:{}};(function(s,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(U){return U&&DataView.prototype.isPrototypeOf(U)}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(U){return U&&g.indexOf(Object.prototype.toString.call(U))>-1};function A(U){if(typeof U!="string"&&(U=String(U)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(U)||U==="")throw new TypeError('Invalid character in header field name: "'+U+'"');return U.toLowerCase()}function E(U){return typeof U!="string"&&(U=String(U)),U}function T(U){var q={next:function(){var At=U.shift();return{done:At===void 0,value:At}}};return f.iterable&&(q[Symbol.iterator]=function(){return q}),q}function w(U){this.map={},U instanceof w?U.forEach(function(q,At){this.append(At,q)},this):Array.isArray(U)?U.forEach(function(q){this.append(q[0],q[1])},this):U&&Object.getOwnPropertyNames(U).forEach(function(q){this.append(q,U[q])},this)}w.prototype.append=function(U,q){U=A(U),q=E(q);var At=this.map[U];this.map[U]=At?At+", "+q:q},w.prototype.delete=function(U){delete this.map[A(U)]},w.prototype.get=function(U){return U=A(U),this.has(U)?this.map[U]:null},w.prototype.has=function(U){return this.map.hasOwnProperty(A(U))},w.prototype.set=function(U,q){this.map[A(U)]=E(q)},w.prototype.forEach=function(U,q){for(var At in this.map)this.map.hasOwnProperty(At)&&U.call(q,this.map[At],At,this)},w.prototype.keys=function(){var U=[];return this.forEach(function(q,At){U.push(At)}),T(U)},w.prototype.values=function(){var U=[];return this.forEach(function(q){U.push(q)}),T(U)},w.prototype.entries=function(){var U=[];return this.forEach(function(q,At){U.push([At,q])}),T(U)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function C(U){if(U.bodyUsed)return Promise.reject(new TypeError("Already read"));U.bodyUsed=!0}function x(U){return new Promise(function(q,At){U.onload=function(){q(U.result)},U.onerror=function(){At(U.error)}})}function O(U){var q=new FileReader,At=x(q);return q.readAsArrayBuffer(U),At}function B(U){var q=new FileReader,At=x(q);return q.readAsText(U),At}function D(U){for(var q=new Uint8Array(U),At=new Array(q.length),F=0;F<q.length;F++)At[F]=String.fromCharCode(q[F]);return At.join("")}function V(U){if(U.slice)return U.slice(0);var q=new Uint8Array(U.byteLength);return q.set(new Uint8Array(U)),q.buffer}function $(){return this.bodyUsed=!1,this._initBody=function(U){this.bodyUsed=this.bodyUsed,this._bodyInit=U,U?typeof U=="string"?this._bodyText=U:f.blob&&Blob.prototype.isPrototypeOf(U)?this._bodyBlob=U:f.formData&&FormData.prototype.isPrototypeOf(U)?this._bodyFormData=U:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(U)?this._bodyText=U.toString():f.arrayBuffer&&f.blob&&p(U)?(this._bodyArrayBuffer=V(U.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(U)||v(U))?this._bodyArrayBuffer=V(U):this._bodyText=U=Object.prototype.toString.call(U):this._bodyText="",this.headers.get("content-type")||(typeof U=="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(U)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var U=C(this);if(U)return U;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 U=C(this);return U||(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(O)}),this.text=function(){var U=C(this);if(U)return U;if(this._bodyBlob)return B(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(J)}),this.json=function(){return this.text().then(JSON.parse)},this}var z=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function it(U){var q=U.toUpperCase();return z.indexOf(q)>-1?q:U}function at(U,q){if(!(this instanceof at))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q=q||{};var At=q.body;if(U instanceof at){if(U.bodyUsed)throw new TypeError("Already read");this.url=U.url,this.credentials=U.credentials,q.headers||(this.headers=new w(U.headers)),this.method=U.method,this.mode=U.mode,this.signal=U.signal,!At&&U._bodyInit!=null&&(At=U._bodyInit,U.bodyUsed=!0)}else this.url=String(U);if(this.credentials=q.credentials||this.credentials||"same-origin",(q.headers||!this.headers)&&(this.headers=new w(q.headers)),this.method=it(q.method||this.method||"GET"),this.mode=q.mode||this.mode||null,this.signal=q.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&At)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(At),(this.method==="GET"||this.method==="HEAD")&&(q.cache==="no-store"||q.cache==="no-cache")){var F=/([?&])_=[^&]*/;if(F.test(this.url))this.url=this.url.replace(F,"$1_="+new Date().getTime());else{var N=/\?/;this.url+=(N.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}at.prototype.clone=function(){return new at(this,{body:this._bodyInit})};function J(U){var q=new FormData;return U.trim().split("&").forEach(function(At){if(At){var F=At.split("="),N=F.shift().replace(/\+/g," "),j=F.join("=").replace(/\+/g," ");q.append(decodeURIComponent(N),decodeURIComponent(j))}}),q}function wt(U){var q=new w,At=U.replace(/\r?\n[\t ]+/g," ");return At.split("\r").map(function(F){return F.indexOf(`
|
88
|
+
`)===0?F.substr(1,F.length):F}).forEach(function(F){var N=F.split(":"),j=N.shift().trim();if(j){var nt=N.join(":").trim();q.append(j,nt)}}),q}$.call(at.prototype);function vt(U,q){if(!(this instanceof vt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');q||(q={}),this.type="default",this.status=q.status===void 0?200:q.status,this.ok=this.status>=200&&this.status<300,this.statusText=q.statusText===void 0?"":""+q.statusText,this.headers=new w(q.headers),this.url=q.url||"",this._initBody(U)}$.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 U=new vt(null,{status:0,statusText:""});return U.type="error",U};var Ot=[301,302,303,307,308];vt.redirect=function(U,q){if(Ot.indexOf(q)===-1)throw new RangeError("Invalid status code");return new vt(null,{status:q,headers:{location:U}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(q,At){this.message=q,this.name=At;var F=Error(q);this.stack=F.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Gt(U,q){return new Promise(function(At,F){var N=new at(U,q);if(N.signal&&N.signal.aborted)return F(new c.DOMException("Aborted","AbortError"));var j=new XMLHttpRequest;function nt(){j.abort()}j.onload=function(){var Lt={status:j.status,statusText:j.statusText,headers:wt(j.getAllResponseHeaders()||"")};Lt.url="responseURL"in j?j.responseURL:Lt.headers.get("X-Request-URL");var Nt="response"in j?j.response:j.responseText;setTimeout(function(){At(new vt(Nt,Lt))},0)},j.onerror=function(){setTimeout(function(){F(new TypeError("Network request failed"))},0)},j.ontimeout=function(){setTimeout(function(){F(new TypeError("Network request failed"))},0)},j.onabort=function(){setTimeout(function(){F(new c.DOMException("Aborted","AbortError"))},0)};function ht(Lt){try{return Lt===""&&d.location.href?d.location.href:Lt}catch{return Lt}}j.open(N.method,ht(N.url),!0),N.credentials==="include"?j.withCredentials=!0:N.credentials==="omit"&&(j.withCredentials=!1),"responseType"in j&&(f.blob?j.responseType="blob":f.arrayBuffer&&N.headers.get("Content-Type")&&N.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(j.responseType="arraybuffer")),q&&typeof q.headers=="object"&&!(q.headers instanceof w)?Object.getOwnPropertyNames(q.headers).forEach(function(Lt){j.setRequestHeader(Lt,E(q.headers[Lt]))}):N.headers.forEach(function(Lt,Nt){j.setRequestHeader(Nt,Lt)}),N.signal&&(N.signal.addEventListener("abort",nt),j.onreadystatechange=function(){j.readyState===4&&N.signal.removeEventListener("abort",nt)}),j.send(typeof N._bodyInit>"u"?null:N._bodyInit)})}return Gt.polyfill=!0,d.fetch||(d.fetch=Gt,d.Headers=w,d.Request=at,d.Response=vt),c.Headers=w,c.Request=at,c.Response=vt,c.fetch=Gt,c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=e.fetch?e:i;t=n.fetch,t.default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,s.exports=t})(Pl,Pl.exports);var zg=Pl.exports;const Yg=Dl(zg);function Ol({canvas:s,scenes:t,currentTime:e}){if(t&&s){const i=t.scenes.filter(({start:o,duration:c})=>e>=o&&e<=o+c);if(i.length<=0)return;const n=s.getContext("2d");if(n){const o=t.transitionDuration,c=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));n.globalCompositeOperation="lighter",n.clearRect(0,0,s.width,s.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{if(n.globalAlpha=1,g.width=g.height=0,g.width=s.width,g.height=s.height,g.getContext("2d")){const v=d+f,A=d===0,E=v===c;p({currentTime:e,canvas:g}),!A&&e>=d&&e<=d+o/2?n.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!E&&e>=v-o/2&&e<=v&&(n.globalAlpha=Math.max(0,Math.min(1,(v-e)/(o/2)))),n.drawImage(g,0,0,s.width,s.height)}})}}}function Xg(s){if(typeof s=="string"){const[t,e]=s.split(":");return Math.min(parseFloat(t),parseFloat(e))}return s}function Zg(s){if(typeof s=="string"){const[t,e]=s.split(":"),i=parseFloat(t),n=parseFloat(e);return i/n}return s}function Ml({resolution:s,aspectRatio:t}){const e=Xg(s),i=Zg(t),n=i>=1,o=Math.min(n?e*i:e/i,e),c=Math.max(n?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:n?o:c,width:n?c:o}}function qg({format:s,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:n}){const{width:o,height:c}=Ml({resolution:t,aspectRatio:e}),d=i/n,f=e>d;let p=1;if(s==="letterbox"||s==="letterbox-video")p=f?c/n:o/i;else if(s==="squarebox"){const T=Math.min(c,o);p=i>=n?T/n:T/i}else s==="crop"&&(p=f?o/i:c/n);const g=o/p,v=c/p,A=(i-g)/2,E=(n-v)/2;return{sx:A,sy:E,sWidth:g,sHeight:v,scale:p}}function la({source:s,sx:t,sy:e,sw:i,sh:n,dx:o,dy:c,dw:d,dh:f}){const p=(s==null?void 0:s.naturalWidth)??(s==null?void 0:s.videoWidth)??(s==null?void 0:s.width),g=(s==null?void 0:s.naturalHeight)??(s==null?void 0:s.videoHeight)??(s==null?void 0:s.height);t=t??0,e=e??0,i=i??p,n=n??g,i<0&&(t+=i,i=Math.abs(i)),n<0&&(e+=n,n=Math.abs(n)),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),E=Math.max(e,0),T=Math.min(e+n,g),w=d/i,C=f/n;return[s,v,E,A-v,T-E,t<0?o-t*w:o,e<0?c-e*C:c,(A-v)*w,(T-E)*C]}function Bd({context:s,source:t,crop:e,format:i="letterbox",posX:n,posY:o,drawAreaWidth:c,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:A,y:E,width:T,height:w}=e??{},C=f*(A??0),x=p*(E??0),O=f*Math.min(1-(A??0),T??1),B=p*Math.min(1-(E??0),w??1),D=g.getContext("2d");if(D){g.width=O,g.height=B;const q=la({source:t,sx:C,sy:x,sw:O,sh:B,dx:0,dy:0,dw:O,dh:B});D.drawImage(...q)}const V=O/B,{sx:$,sy:z,sWidth:it,sHeight:at,scale:J}=qg({resolution:Math.min(c,d),aspectRatio:c/d,format:i,sourceWidth:O,sourceHeight:B}),wt=g&&typeof s.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!wt){if($<0){const q=Math.abs($)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,q,d),s.rect(n+c-q,o,q,d),s.fill(),s.closePath()}if(z<0){const q=Math.abs(z)*J;s.fillStyle="black",s.beginPath(),s.rect(n,o,c,q),s.rect(n,o+d-q,c,q),s.fill(),s.closePath()}}if(i==="letterbox-video"&&wt){const q=v.getContext("2d");if(q){v.width=O,v.height=B,s.save(),s.globalCompositeOperation="destination-out",s.fillRect(n,o,c,d);const At=la({source:g,sx:$,sy:z,sw:it,sh:at,dx:n,dy:o,dw:c,dh:d});s.globalCompositeOperation="source-over",s.drawImage(...At),q.save();const F=1.2,N=-(O*F-O)/2,j=-(B*F-B)/2,nt=Math.min(O/20,B/20);if(q.filter=`blur(${nt}px) brightness(20%)`,q.translate(N,j),q.scale(F,F),q.drawImage(g,0,0,O,B),q.restore(),s.globalCompositeOperation="destination-over",$<0){const ht=c/V,Lt=d/ht,Nt=la({source:v,sy:(1-Lt)*B/2,sh:Lt*B,dx:n,dy:o,dw:c,dh:d});s.drawImage(...Nt)}if(z<0){const ht=d*V,Lt=c/ht,Nt=la({source:v,sx:(1-Lt)*O/2,sw:Lt*O,dx:n,dy:o,dw:c,dh:d});s.drawImage(...Nt)}s.restore()}}else{const q=la({source:g,sx:$,sy:z,sw:it,sh:at,dx:n,dy:o,dw:c,dh:d});s.drawImage(...q)}const vt=$*-1*J,Ot=z*-1*J,Gt=c-vt*2,U=d-Ot*2;return{dx:vt,dy:Ot,dw:Gt,dh:U}}const Qg=(s,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const n=Object.getOwnPropertyDescriptor(s,e),o=Object.getOwnPropertyDescriptor(t,e);!Jg(n,o)&&i||Object.defineProperty(s,e,o)},Jg=function(s,t){return s===void 0||s.configurable||s.writable===t.writable&&s.enumerable===t.enumerable&&s.configurable===t.configurable&&(s.writable||s.value===t.value)},tm=(s,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(s)&&Object.setPrototypeOf(s,e)},em=(s,t)=>`/* Wrapped ${s}*/
|
89
|
+
${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),sm=(s,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,n=em.bind(null,i,t.toString());Object.defineProperty(n,"name",rm),Object.defineProperty(s,"toString",{...im,value:n})};function nm(s,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=s;for(const n of Reflect.ownKeys(t))Qg(s,t,n,e);return tm(s,t),sm(s,t,i),s}const am=new WeakMap,Gd=new WeakMap;function Vd(s,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return s;if(typeof i=="number"){if(i>2147483647)throw new TypeError("The `maxAge` option cannot exceed 2147483647.");if(i<0)throw new TypeError("The `maxAge` option should not be a negative number.")}const n=function(...o){var c;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=s.apply(this,o);if(e.set(d,{data:p,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},i);(c=g.unref)==null||c.call(g);const v=Gd.get(s)??new Set;v.add(g),Gd.set(s,v)}return p};return nm(n,s,{ignoreNonConfigurable:!0}),am.set(n,e),n}function Hd({context:s,word:t,maxW:e=1/0}){const i=[],n=s.measureText(t);if(n.width<e)return[{text:t,metrics:n}];for(let o=0;o<t.length;o++){const c=i[i.length-1],d=((c==null?void 0:c.text)??"")+t[o],f=s.measureText(d);f.width<e?i[c?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:s.measureText(t[o])})}return i}const Wd=Vd(({font:s,scale:t,context:e,maxW:i,maxH:n,text:o,minSize:c,maxSize:d})=>{var f,p;let g=0;if(d){g=(c??0)*t;let v=0;for(;d*t>g+1;){g+=1;const A=uo({context:e,font:s,fontSize:g,text:o,maxW:i});if(v=A.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||A.length*g>n){g-=1;break}}}else g=parseFloat(((p=(f=s.match(ho))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:s,text:t,minSize:e,maxSize:i,scale:n,maxW:o,maxH:c}])=>`${s}_${t}_${e}_${i}_${n}_${o}_${c}`});function om(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ee={},$l={},ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.default=ie.Wrap=ie.Unit=ie.PrintOptions=ie.PositionType=ie.Overflow=ie.NodeType=ie.MeasureMode=ie.LogLevel=ie.Justify=ie.Gutter=ie.FlexDirection=ie.ExperimentalFeature=ie.Errata=ie.Edge=ie.Display=ie.Direction=ie.Dimension=ie.Align=void 0;let Zr=function(s){return s[s.Auto=0]="Auto",s[s.FlexStart=1]="FlexStart",s[s.Center=2]="Center",s[s.FlexEnd=3]="FlexEnd",s[s.Stretch=4]="Stretch",s[s.Baseline=5]="Baseline",s[s.SpaceBetween=6]="SpaceBetween",s[s.SpaceAround=7]="SpaceAround",s}({});ie.Align=Zr;let Fl=function(s){return s[s.Width=0]="Width",s[s.Height=1]="Height",s}({});ie.Dimension=Fl;let eo=function(s){return s[s.Inherit=0]="Inherit",s[s.LTR=1]="LTR",s[s.RTL=2]="RTL",s}({});ie.Direction=eo;let Nl=function(s){return s[s.Flex=0]="Flex",s[s.None=1]="None",s}({});ie.Display=Nl;let Ir=function(s){return s[s.Left=0]="Left",s[s.Top=1]="Top",s[s.Right=2]="Right",s[s.Bottom=3]="Bottom",s[s.Start=4]="Start",s[s.End=5]="End",s[s.Horizontal=6]="Horizontal",s[s.Vertical=7]="Vertical",s[s.All=8]="All",s}({});ie.Edge=Ir;let ca=function(s){return s[s.None=0]="None",s[s.StretchFlexBasis=1]="StretchFlexBasis",s[s.All=2147483647]="All",s[s.Classic=2147483646]="Classic",s}({});ie.Errata=ca;let io=function(s){return s[s.WebFlexBasis=0]="WebFlexBasis",s[s.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",s[s.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",s}({});ie.ExperimentalFeature=io;let ha=function(s){return s[s.Column=0]="Column",s[s.ColumnReverse=1]="ColumnReverse",s[s.Row=2]="Row",s[s.RowReverse=3]="RowReverse",s}({});ie.FlexDirection=ha;let ro=function(s){return s[s.Column=0]="Column",s[s.Row=1]="Row",s[s.All=2]="All",s}({});ie.Gutter=ro;let Qs=function(s){return s[s.FlexStart=0]="FlexStart",s[s.Center=1]="Center",s[s.FlexEnd=2]="FlexEnd",s[s.SpaceBetween=3]="SpaceBetween",s[s.SpaceAround=4]="SpaceAround",s[s.SpaceEvenly=5]="SpaceEvenly",s}({});ie.Justify=Qs;let Js=function(s){return s[s.Error=0]="Error",s[s.Warn=1]="Warn",s[s.Info=2]="Info",s[s.Debug=3]="Debug",s[s.Verbose=4]="Verbose",s[s.Fatal=5]="Fatal",s}({});ie.LogLevel=Js;let so=function(s){return s[s.Undefined=0]="Undefined",s[s.Exactly=1]="Exactly",s[s.AtMost=2]="AtMost",s}({});ie.MeasureMode=so;let Ul=function(s){return s[s.Default=0]="Default",s[s.Text=1]="Text",s}({});ie.NodeType=Ul;let no=function(s){return s[s.Visible=0]="Visible",s[s.Hidden=1]="Hidden",s[s.Scroll=2]="Scroll",s}({});ie.Overflow=no;let ao=function(s){return s[s.Static=0]="Static",s[s.Relative=1]="Relative",s[s.Absolute=2]="Absolute",s}({});ie.PositionType=ao;let oo=function(s){return s[s.Layout=1]="Layout",s[s.Style=2]="Style",s[s.Children=4]="Children",s}({});ie.PrintOptions=oo;let da=function(s){return s[s.Undefined=0]="Undefined",s[s.Point=1]="Point",s[s.Percent=2]="Percent",s[s.Auto=3]="Auto",s}({});ie.Unit=da;let lo=function(s){return s[s.NoWrap=0]="NoWrap",s[s.Wrap=1]="Wrap",s[s.WrapReverse=2]="WrapReverse",s}({});ie.Wrap=lo;var lm={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:Fl.Width,DIMENSION_HEIGHT:Fl.Height,DIRECTION_INHERIT:eo.Inherit,DIRECTION_LTR:eo.LTR,DIRECTION_RTL:eo.RTL,DISPLAY_FLEX:Nl.Flex,DISPLAY_NONE:Nl.None,EDGE_LEFT:Ir.Left,EDGE_TOP:Ir.Top,EDGE_RIGHT:Ir.Right,EDGE_BOTTOM:Ir.Bottom,EDGE_START:Ir.Start,EDGE_END:Ir.End,EDGE_HORIZONTAL:Ir.Horizontal,EDGE_VERTICAL:Ir.Vertical,EDGE_ALL:Ir.All,ERRATA_NONE:ca.None,ERRATA_STRETCH_FLEX_BASIS:ca.StretchFlexBasis,ERRATA_ALL:ca.All,ERRATA_CLASSIC:ca.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:ha.Column,FLEX_DIRECTION_COLUMN_REVERSE:ha.ColumnReverse,FLEX_DIRECTION_ROW:ha.Row,FLEX_DIRECTION_ROW_REVERSE:ha.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:Ul.Default,NODE_TYPE_TEXT:Ul.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:da.Undefined,UNIT_POINT:da.Point,UNIT_PERCENT:da.Percent,UNIT_AUTO:da.Auto,WRAP_NO_WRAP:lo.NoWrap,WRAP_WRAP:lo.Wrap,WRAP_WRAP_REVERSE:lo.WrapReverse};ie.default=lm,Object.defineProperty($l,"__esModule",{value:!0}),$l.default=hm;var bs=cm(ie);function jd(s){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(jd=function(i){return i?e:t})(s)}function cm(s,t){if(!t&&s&&s.__esModule)return s;if(s===null||typeof s!="object"&&typeof s!="function")return{default:s};var e=jd(t);if(e&&e.has(s))return e.get(s);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in s)if(o!=="default"&&Object.prototype.hasOwnProperty.call(s,o)){var c=n?Object.getOwnPropertyDescriptor(s,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=s[o]}return i.default=s,e&&e.set(s,i),i}function hm(s){function t(n,o,c){const d=n[o];n[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 n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[bs.Unit.Point]:s.Node.prototype[n],[bs.Unit.Percent]:s.Node.prototype[`${n}Percent`],[bs.Unit.Auto]:s.Node.prototype[`${n}Auto`]};t(s.Node.prototype,n,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=bs.Unit.Auto,A=void 0;else if(typeof g=="object")v=g.unit,A=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?bs.Unit.Percent:bs.Unit.Point,A=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(A))throw new Error(`Invalid value ${g} for ${n}`);if(!o[v])throw new Error(`Failed to execute "${n}": Unsupported unit '${g}'`);return A!==void 0?o[v].call(this,...f,A):o[v].call(this,...f)})}function e(n){return s.MeasureCallback.implement({measure:function(){const{width:o,height:c}=n(...arguments);return{width:o??NaN,height:c??NaN}}})}t(s.Node.prototype,"setMeasureFunc",function(n,o){return o?n.call(this,e(o)):this.unsetMeasureFunc()});function i(n){return s.DirtiedCallback.implement({dirtied:n})}return t(s.Node.prototype,"setDirtiedFunc",function(n,o){n.call(this,i(o))}),t(s.Config.prototype,"free",function(){s.Config.destroy(this)}),t(s.Node,"create",(n,o)=>o?s.Node.createWithConfig(o):s.Node.createDefault()),t(s.Node.prototype,"free",function(){s.Node.destroy(this)}),t(s.Node.prototype,"freeRecursive",function(){for(let n=0,o=this.getChildCount();n<o;++n)this.getChild(0).freeRecursive();this.free()}),t(s.Node.prototype,"calculateLayout",function(n){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]:bs.Direction.LTR;return n.call(this,o,c,d)}),{Config:s.Config,Node:s.Node,...bs.default}}var Kd={exports:{}};(function(s,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var o;o||(o=typeof n<"u"?n:{});var c,d;o.ready=new Promise(function(_,L){c=_,d=L});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 E(){this.buffer=new ArrayBuffer(U/65536*65536)}function T(){}function w(_){this.exports=function(L){function G(ai){return ai.set=function(ne,sr){this[ne]=sr},ai.get=function(ne){return this[ne]},ai}for(var H,rt=new Uint8Array(123),yt=25;yt>=0;--yt)rt[48+yt]=52+yt,rt[65+yt]=yt,rt[97+yt]=26+yt;rt[43]=62,rt[47]=63;function ct(ai,ne,sr){for(var Ui,gt,Ur=0,l=ne,Et=sr.length,$n=ne+(Et*3>>2)-(sr[Et-2]=="=")-(sr[Et-1]=="=");Ur<Et;Ur+=4)Ui=rt[sr.charCodeAt(Ur+1)],gt=rt[sr.charCodeAt(Ur+2)],ai[l++]=rt[sr.charCodeAt(Ur)]<<2|Ui>>4,l<$n&&(ai[l++]=Ui<<4|gt>>2),l<$n&&(ai[l++]=gt<<6|rt[sr.charCodeAt(Ur+3)])}function Rt(ai){ct(H,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),ct(H,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),ct(H,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),ct(H,4432,"xwAAAMgAAADJ"),ct(H,4452,"xwAAAMoAAADLAAAArBs="),ct(H,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),ct(H,4552,"zAAAAM0AAADO"),ct(H,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),ct(H,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),ct(H,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),ct(H,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),ct(H,5179,"DA=="),ct(H,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),ct(H,5237,"EA=="),ct(H,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),ct(H,5295,"Eg=="),ct(H,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),ct(H,5362,"GgAAABoaGgAAAAAAAAk="),ct(H,5411,"FA=="),ct(H,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),ct(H,5469,"Fg=="),ct(H,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),ct(H,5556,"1Q=="),ct(H,5596,"//////////8="),ct(H,5664,"8B8BAAAAAAAF"),ct(H,5684,"0A=="),ct(H,5708,"0QAAANIAAADUGw=="),ct(H,5732,"Ag=="),ct(H,5748,"//////////8="),ct(H,5816,"BQ=="),ct(H,5828,"0w=="),ct(H,5852,"0QAAANQAAADoGwAAAAQ="),ct(H,5876,"AQ=="),ct(H,5892,"/////wo="),ct(H,5960,"1g==")}var Ct=new ArrayBuffer(16),It=new Int32Array(Ct),Ft=new Float32Array(Ct),zt=new Float64Array(Ct);function Jt(ai){return It[ai]}function xt(ai,ne){It[ai]=ne}function Ae(){return zt[0]}function yi(ai){zt[0]=ai}function le(){throw new Error("abort")}function qi(ai){Ft[2]=ai}function Bt(){return Ft[2]}function Qo(ai){var ne=ai.a,sr=ne.a,Ui=sr.buffer;sr.grow=Rk;var gt=new Int8Array(Ui),Ur=new Int16Array(Ui),l=new Int32Array(Ui),Et=new Uint8Array(Ui),$n=new Uint16Array(Ui),hp=new Uint32Array(Ui),I=new Float32Array(Ui),Ve=new Float64Array(Ui),He=Math.imul,m=Math.fround,Ye=Math.abs,vr=Math.clz32,TE=Math.min,kE=Math.max,Yt=NaN,dp=1/0,St=ne.b,_i=ne.c,os=ne.d,ls=ne.e,xs=ne.f,Fn=ne.g,Oa=ne.h,Jo=ne.i,Th=ne.j,kh=ne.k,wh=ne.l,up=ne.m,fp=ne.n,pp=ne.o,gp=ne.p,mp=ne.q,wE=ne.r,SE=ne.s,RE=ne.t,_E=ne.u,LE=ne.v,CE=ne.w,IE=ne.x,DE=ne.y,xE=ne.z,PE=ne.A,OE=ne.B,ME=ne.C,$E=ne.D,Tt=73712,Bi=0;function vp(r,a,h,u,y,b,k,S,P,K,tt,ft,Q,et){var M=0,W=m(0),Y=0,Z=m(0),ot=0,lt=m(0),mt=0,bt=m(0),_t=0,Mt=0,$t=m(0),Ht=0,Zt=0,re=m(0),pe=m(0),Ce=m(0),Pe=m(0),Me=0,We=m(0),Ze=m(0),oi=0,li=0,Ei=m(0),Mi=0,Ji=0,$i=0,Hi=0,tr=m(0),er=0,_r=0,Lr=0,Wr=0,jr=m(0),Kr=0,zr=0,cs=0,hs=0,ds=m(0),$s=0,Fs=0,Ns=0,Us=m(0),Bs=0,Gs=m(0),Fa=0,Na=m(0),Ua=m(0),Ba=m(0),Ga=0,ol=m(0),Uh=0,Bh=m(0),Gh=m(0),Vh=m(0),Hh=m(0),Wh=0,f2=0,p2=0,g2=0,m2=0,v2=0,y2=0,b2=0,qe=0,Qe=m(0),Hn=m(0);M=Tt-384|0,Tt=M;t:{r:{i:{if(!(y&&a!=a)){if(!(b&&h!=h)){if(Y=(P?0:4)+tt|0,l[Y>>2]=l[Y>>2]+1,Y=l[r+24>>2]&3,Uh=(u|0)<=1?1:u,Hi=Y||Uh,gt[r+300|0]=Et[r+300|0]&252|Hi&3,Y=r+252|0,u=((Hi|0)!=1)<<3,$s=(Hi|0)==2?3:2,lt=ce(r,$s,k),I[Y+u>>2]=lt,ot=Y,Y=((Hi|0)==1)<<3,pe=we(r,$s,k),I[ot+Y>>2]=pe,bt=ce(r,0,k),I[r+256>>2]=bt,Pe=we(r,0,k),I[r+264>>2]=Pe,ot=r+268|0,qe=ot+u|0,Qe=fe(r,$s),I[qe>>2]=Qe,qe=Y+ot|0,Qe=Se(r,$s),I[qe>>2]=Qe,W=fe(r,0),I[r+272>>2]=W,We=Se(r,0),I[r+280>>2]=We,ot=u,u=r+284|0,qe=ot+u|0,Qe=De(r,$s,k),I[qe>>2]=Qe,qe=u+Y|0,Qe=xe(r,$s,k),I[qe>>2]=Qe,Z=De(r,0,k),I[r+288>>2]=Z,$t=xe(r,0,k),I[r+296>>2]=$t,lt=m(lt+pe),pe=m(bt+Pe),u=l[r+8>>2],u){bt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(b?h-pe:Yt),W=m(m(Z+$t)+W),Z=m(y?a-lt:Yt),a=Z;e:{if(a!=a)break e;if(a=m(Z-bt),a!=a){a=m(0);break e}a=ae(a,m(0))}lt=m(W+We),W=h;e:{if(h!=h)break e;if(W=m(h-lt),W!=W){W=m(0);break e}W=ae(W,m(0))}if(!((y|0)!=1|(b|0)!=1)){a=Xe(r,2,Z,k),u=a!=a,W=m(m(De(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ae(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=Xe(r,0,h,S),u=a!=a,h=m(m(De(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(Et[r+4|0]&16){Pt[u|0](M+24|0,r,a,y,W,b,0);break e}Pt[u|0](M+24|0,r,a,y,W,b)}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(bt+I[M+24>>2]),a=Xe(r,2,y?(y|0)==2?a:Z:a,k),u=a!=a,W=m(m(De(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ae(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(lt+I[M+28>>2]),a=Xe(r,0,b?(b|0)==2?a:h:a,S),u=a!=a,h=m(m(De(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(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)){pe=m(h-pe),a=Xe(r,2,y&-3?m(a-lt):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),k),u=a!=a,h=m(m(De(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=Xe(r,0,b&-3?pe:m(m(m(Z+$t)+W)+We),S),u=a!=a,h=m(m(De(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ae(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-lt),Z=m(h-pe),!(!(!(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=Xe(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(De(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ae(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=Xe(r,0,Z!=Z||(b|0)==2&&Z<m(0)?m(0):Z,S),u=a!=a,h=m(m(De(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ae(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(oi=et-u|0,Wr=oi>>2;Y=l[u>>2],l[Y+552>>2]!=(r|0)&&(ot=l[r+568>>2],Y=Dp(l[ot>>2],Et[ot+8|0],Y,r,_t,0),l[u>>2]=Y,l[Y+552>>2]=r),_t=_t+1|0,u=u+4|0,(et|0)!=(u|0););gt[r+300|0]=Et[r+300|0]&251,_t=3,Mi=l[r+24>>2],u=Mi>>>2&3;e:{s:{n:{if((Hi|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}_t=2;break e}if(_t=2,et=0,u>>>0>1)break s}et=_t}_t=u}Bh=m(a-lt),jr=m(m(De(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),We=m(De(r,et,k)+fe(r,et)),tr=m(We+m(xe(r,et,k)+Se(r,et))),er=_t>>>0>1,bt=Tp(r,0,Bh,er?jr:tr,k),Gh=m(h-pe),Ze=Tp(r,1,Gh,er?tr:jr,S),Pe=er?Ze:bt,pe=er?bt:Ze,Kr=l[r+560>>2],Y=l[r+556>>2],Ji=er?y:b;e:{if((Ji|0)!=1)break e;if((Y|0)==(Kr|0))break i;for(u=Y;;){ot=l[u>>2];s:{if(!Gp(ot))break s;if(Zt=0,mt)break e;n:{a:{if(!l[ot+552>>2]){W=m(0);break a}if(h=I[ot+32>>2],h!=h&&(W=m(0),h=I[ot+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ye(W))<m(9999999747378752e-20))break e}if(a=Gn(ot),a!=a){mt=ot;break s}if(mt=ot,m(Ye(a))<m(9999999747378752e-20))break e}if(Zt=mt,u=u+4|0,(Kr|0)==(u|0))break}}if((Y|0)==(Kr|0))break i;for(Fa=(Hi|0)<=1?1:Hi,Fs=bt!=bt,zr=Fs|(y|0)!=1,cs=Ze==Ze,Ns=bt==bt,W=m(0);;){Ht=l[Y>>2],Ep(Ht),ot=l[Ht+24>>2];e:{if(ot&4194304){if(Sp(Ht,0),u=Et[Ht+4|0],ot=u|1,gt[Ht+4|0]=ot,!(u&4))break e;gt[Ht+4|0]=ot&251;break e}if(P&&(u=ot&3,xp(Ht,u||Fa,pe,Pe,bt),ot=l[Ht+24>>2]),(ot&196608)==131072)break e;s:{if((Ht|0)==(Zt|0)){l[Zt+308>>2]=0,l[Zt+304>>2]=Q,h=m(0);break s}hs=l[r+24>>2],u=hs>>>2&3;n:{a:{if((Hi|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}_r=mt>>>0>1,lt=_r?bt:Ze,h=m(0),a=I[Ht+40>>2];n:{a:{Mt=l[Ht+40>>2];o:{if((Mt|0)==2139156720)break o;if((Mt|0)==2140081935)break a;u=4336;l:{if((Mt|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Mt=l[u+4>>2],Mt|0){case 0:case 3:break h;default:break c}if(a=m(Yt),!(I[Ht+28>>2]>m(0)))break n;Mt=gt[l[Ht+568>>2]+8|0]&1,u=Mt?2143289344:0,Mt=Mt?3:1,h=(xt(2,u),Bt())}switch(a=m(Yt),Mt-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(xt(2,(Mt&-1073741825)+536870912|0),Bt()),!(Mt&1073741824))break a}a=m(m(lt*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Mt=0;n:{a:switch(Me=l[Ht+576>>2],Me|0){case 0:case 3:break n;default:break a}if(Z=I[Ht+572>>2],!((Me|0)!=1|Z!=Z)){if(h<m(0))break n;Mt=1;break n}if(Mt=1,(Me|0)!=2|Z!=Z||(Mt=0,h<m(0)))break n;Mt=Ns}Z=I[Ht+580>>2],u=0;n:{a:switch(li=l[Ht+584>>2],li|0){case 0:case 3:break n;default:break a}if($t=I[Ht+580>>2],!((li|0)!=1|$t!=$t)){if(Z<m(0))break n;u=1;break n}if(u=1,(li|0)!=2|$t!=$t||(u=0,Z<m(0)))break n;u=cs}n:{a:{if(!(a!=a|lt!=lt)){if(h=I[Ht+308>>2],(!(gt[l[Ht+568>>2]+12|0]&1)|l[Ht+304>>2]==(Q|0))&h==h)break n;if(h=m(m(De(Ht,mt,bt)+fe(Ht,mt))+m(xe(Ht,mt,bt)+Se(Ht,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Mt&_r){Z=m(m(De(Ht,2,bt)+fe(Ht,2))+m(xe(Ht,2,bt)+Se(Ht,2))),a=m(Yt);o:switch(Me-1|0){case 1:h=m(m(bt*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(!(_r|u^1)){a=m(m(De(Ht,0,bt)+fe(Ht,0))+m(xe(Ht,0,bt)+Se(Ht,0))),h=m(Yt);o:switch(li-1|0){case 1:Z=m(m(Ze*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[M+360>>2]=2143289344,l[M+24>>2]=2143289344,$i=0,l[M+356>>2]=0,l[M+352>>2]=0,$t=m(ce(Ht,2,bt)+we(Ht,2,bt)),re=ce(Ht,0,bt),Ce=we(Ht,0,bt),lt=m(Yt),Lr=0,a=m(Yt),Mt){o:{l:switch(Me-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(bt*h)*m(.009999999776482582))}l[M+356>>2]=1,a=m($t+a),I[M+24>>2]=a,Lr=1}if(re=m(re+Ce),u){h=m(Yt);o:{l:switch(li-1|0){case 0:h=Z;break o;case 1:break l;default:break o}h=m(m(Ze*Z)*m(.009999999776482582))}l[M+352>>2]=1,lt=m(re+h),I[M+360>>2]=lt,$i=1}Me=(hs&3145728)==2097152,li=mt>>>0<2;o:{l:{c:{if(!(Me&li)){if(Me|Fs)break l;if(a!=a)break c;break l}if(Fs|a==a)break o}Lr=2,l[M+356>>2]=2,I[M+24>>2]=bt,a=bt}l:{if(!Me||li){if(Me|Ze!=Ze)break o;if(lt!=lt)break l;break o}if(lt==lt|Ze!=Ze)break o}$i=2,l[M+352>>2]=2,I[M+360>>2]=Ze,lt=Ze}h=I[Ht+224>>2],Me=h!=h;o:{if(Me)break o;l:{if(!(_r|(Lr|0)!=1)){l[M+352>>2]=1,I[M+360>>2]=re+m(m(a-$t)/h);break l}if(li|($i|0)!=1)break o;l[M+356>>2]=1,I[M+24>>2]=m(m(lt-re)*h)+$t}$i=1,Lr=1}ot=ot>>>13&7,ot=ot||hs>>>10&7;o:{if((ot|0)==5|(Lr|0)==1|(_r|(Mt|zr))|(ot|0)!=4||(l[M+356>>2]=1,I[M+24>>2]=bt,Me))break o;$i=1,l[M+352>>2]=1,I[M+360>>2]=m(bt-$t)/h}o:{if(li|(b|0)!=1|Ze!=Ze|u|(ot|0)!=4|($i|0)==1||(l[M+352>>2]=1,I[M+360>>2]=Ze,Me))break o;l[M+356>>2]=1,I[M+24>>2]=m(Ze-re)*h}if(Nn(Ht,2,bt,bt,M+356|0,M+24|0),Nn(Ht,0,Ze,bt,M+352|0,M+360|0),dn(Ht,I[M+24>>2],I[M+360>>2],Hi,l[M+356>>2],l[M+352>>2],bt,Ze,0,5,K,tt,ft,Q),a=I[(Ht+(l[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(De(Ht,mt,bt)+fe(Ht,mt))+m(xe(Ht,mt,bt)+Se(Ht,mt))),!(u|h!=h)){h=ae(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}l[Ht+304>>2]=Q}W=m(W+m(h+m(ce(Ht,_t,bt)+we(Ht,_t,bt))))}if(Y=Y+4|0,(Kr|0)==(Y|0))break}break r}l[M>>2]=3072,nr(r,M),Qi(),le()}l[M+16>>2]=3154,nr(r,M+16|0),Qi(),le()}W=m(0)}a=m(W+m(0)),Na=er?S:k,Us=er?k:S,oi>>>0>=5&&(a=m(m(tl(r,_t,Pe)*m(Wr-1>>>0))+a)),u=a>pe,Kr=Mi&786432,cs=(Ji|0)==2&&Kr&&u?1:Ji,Ht=er?b:y,_r=(Ht|0)==1,f2=_r&(P^1),er=_t>>>0<2,p2=Ht&-3,Fs=r+208|0,b=et<<2,li=b+4288|0,g2=_r&!Kr,m2=(Ht|0)!=1|P,Y=_t<<2,Lr=Y+4288|0,Ns=Y+4320|0,hs=Pe==Pe,v2=hs<<1,Me=b+4320|0,y2=!Ji|!u,Fa=M+52|0,Vh=tl(r,et,Pe),ot=0,u=0,$i=0;r:{for(;;){Ji=u,Vi(M+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(Y=$a(M+360|0,u>>2,0,Fa),u=l[M+44>>2],b=l[M+48>>2]-u|0,b=Ps(l[M+364>>2]-b|0,u,b),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=b,mt=l[M+368>>2],Mt=l[M+372>>2],b=l[M+48>>2],l[M+368>>2]=b,Zt=l[M+52>>2],l[M+48>>2]=mt,l[M+52>>2]=Mt,l[M+372>>2]=Zt,l[Y>>2]=u,(u|0)!=(b|0)&&(l[M+368>>2]=b+((u-b|0)+3&-4)),!u)break i;bi(u)}Zt=l[r+24>>2],u=Zt>>>2&3;i:{e:{if(b=Zt&3,((b||Uh)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}mt=2;break i}mt=u}W=tl(r,mt,bt),Y=ot,Mt=l[r+560>>2],b=l[r+556>>2];i:{if(Y>>>0>=Mt-b>>2>>>0)break i;for(Zt=Zt&786432,h=m(0);;){if(Mt-b>>2>>>0<=Y>>>0)break r;if(u=l[(Y<<2)+b>>2],oi=l[u+24>>2],!(oi&4194304|(oi&196608)==131072)){if(l[u+548>>2]=Ji,a=ce(u,mt,bt),Z=we(u,mt,bt),b=l[M+24>>2],lt=(Y|0)==(ot|0)?m(0):W,a=m(a+Z),Z=I[u+308>>2],$t=Xe(u,mt,Z,Us),!(!b||!(m(lt+m(a+m(h+$t)))>pe)|!Zt))break i;if(l[M+24>>2]=b+1,lt=m(lt+m(a+$t)),I[M+28>>2]=lt+I[M+28>>2],Gp(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[M+32>>2]=a+I[M+32>>2],qe=M,Qe=m(I[M+36>>2]-m(Gn(u)*Z)),I[qe+36>>2]=Qe}b=l[M+48>>2];e:{if((b|0)!=l[M+52>>2]){l[b>>2]=u,l[M+48>>2]=b+4;break e}if(b=b-l[M+44>>2]|0,oi=b>>2,Mt=oi+1|0,Mt>>>0>=1073741824)break r;if(Mi=b>>1,Mt=$a(M+360|0,b>>>0>=2147483644?1073741823:Mt>>>0<Mi>>>0?Mi:Mt,oi,Fa),l[l[M+368>>2]>>2]=u,l[M+368>>2]=l[M+368>>2]+4,u=l[M+44>>2],b=l[M+48>>2]-u|0,b=Ps(l[M+364>>2]-b|0,u,b),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=b,oi=l[M+368>>2],Mi=l[M+372>>2],b=l[M+48>>2],l[M+368>>2]=b,zr=l[M+52>>2],l[M+48>>2]=oi,l[M+52>>2]=Mi,l[M+372>>2]=zr,l[Mt>>2]=u,(u|0)!=(b|0)&&(l[M+368>>2]=b+((u-b|0)+3&-4)),!u)break e;bi(u)}b=l[r+556>>2],Mt=l[r+560>>2],h=m(h+lt)}if(Y=Y+1|0,!(Y>>>0<Mt-b>>2>>>0))break}}Ce=I[M+32>>2],!(Ce>m(0))|!(Ce<m(1))||(l[M+32>>2]=1065353216,Ce=m(1)),Ei=I[M+36>>2],!(Ei>m(0))|!(Ei<m(1))||(l[M+36>>2]=1065353216,Ei=m(1)),l[M+40>>2]=Y,$t=I[M+28>>2],mt=l[M+24>>2],$i&&bi($i),Z=I[M+56>>2],oi=l[M+48>>2],$i=l[M+44>>2];i:{e:{s:{n:{if((cs|0)==1)break n;h=m(0),a=I[Fs>>2];a:{o:{u=l[Fs>>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=I[b>>2],a=m(Yt),l[b+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*k)*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;b=4336;c:{if((u|0)!=2141891242){if(W==W)break c;b=4344}switch(h=I[b>>2],W=m(Yt),l[b+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*k)*m(.009999999776482582));break a}W=h}h=m(0),lt=I[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(lt==lt)break c;b=4344}switch(h=I[b>>2],lt=m(Yt),l[b+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}lt=m(m(h*S)*m(.009999999776482582));break a}lt=h}h=m(0),re=I[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=I[b>>2],re=m(Yt),l[b+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}re=m(m(h*S)*m(.009999999776482582));break a}re=h}if(u=_t>>>0>1,h=m((u?a:lt)-jr),h==h&h>$t||(h=m((u?W:re)-jr),h==h&h<$t))break s;if(gt[l[r+568>>2]+16|0]&1)break n;if(h=$t,!l[r+552>>2]|Ce==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=pe;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=pe,a!=m(0)))break e;h=$t;break e}h=pe}if(h!=h)break e;Z=m(h-$t);break i}if(!($t<m(0)))break i;Z=m(-$t)}if(pe=h,!f2){i:{if((oi|0)==($i|0)){lt=m(0);break i}for(re=m(0),b=$i;;){u=l[b>>2],$t=I[u+308>>2],h=Xe(u,_t,$t,Us);e:{if(Z<m(0)){if(a=m(h*m(-Gn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(Z/Ei)*a)+h),a=Xe(u,_t,W,pe),Mt=a!=a,lt=m(m(De(u,_t,bt)+fe(u,_t))+m(xe(u,_t,bt)+Se(u,_t)));s:{if(!(Mt|lt!=lt)){a=ae(a,lt);break s}a=Mt?lt:a}if(W!=W|a!=a|a==W)break e;re=m(re+m(a-h)),Ei=m(m(Gn(u)*$t)+Ei);break e}if(!(Z>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;lt=m(m(m(Z/Ce)*W)+h),a=Xe(u,_t,lt,pe),Mt=a!=a,$t=m(m(De(u,_t,bt)+fe(u,_t))+m(xe(u,_t,bt)+Se(u,_t)));s:{if(!(Mt|$t!=$t)){a=ae(a,$t);break s}a=Mt?$t:a}if(lt!=lt|a!=a|a==lt)break e;Ce=m(Ce-W),re=m(re+m(a-h))}if(b=b+4|0,(oi|0)==(b|0))break}for(re=m(Z-re),Ua=m(re/Ei),Ba=m(re/Ce),Ga=_r&(y2|!(Et[r+26|0]&12)),zr=!Ga,Mi=l[Me>>2],lt=m(0),Mt=$i;;){u=l[Mt>>2],$t=Xe(u,_t,I[u+308>>2],Us);e:{s:{if(re<m(0)){if(W=$t,a=m(W*m(-Gn(u))),a==m(0))break e;a=Ei==m(0)?m($t+a):m(m(Ua*a)+$t);break s}if(W=$t,!(re>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(Ba*a)+$t)}if(a=Xe(u,_t,a,pe),b=a!=a,h=m(m(De(u,_t,bt)+fe(u,_t))+m(xe(u,_t,bt)+Se(u,_t))),!(b|h!=h)){W=ae(a,h);break e}W=b?h:a}a=ce(u,_t,bt),h=we(u,_t,bt),Ce=ce(u,et,bt),ol=we(u,et,bt),h=m(a+h),Hh=m(W+h),I[M+352>>2]=Hh,l[M+344>>2]=1,Ce=m(Ce+ol),a=I[u+224>>2];e:{if(a==a){l[M+348>>2]=1,h=m(Hh-h),I[M+356>>2]=Ce+m(er?h*a:h/a);break e}s:{if(Bs=Pe!=Pe,Bs)break s;Zt=(Mi<<3)+u|0,a=I[Zt+572>>2];n:{a:{o:{l:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break o;default:break l}if(h=I[Zt+572>>2],(b|0)!=1|h!=h)break a;if(!(zr|!(a<m(0))))break n;break s}if(!Ga)break s;break n}if(zr|(!(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||(fn(M+24|0,u,et),l[M+28>>2]==3)||(un(M+360|0,u,et),l[M+364>>2]==3))break s;l[M+348>>2]=1,I[M+356>>2]=Pe;break e}Zt=(Mi<<3)+u|0,h=I[Zt+572>>2];s:{n:{a:{o:{l:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break o;default:break l}if(a=I[Zt+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(Bs)break o;if(!(h<m(0)))break n}l[M+348>>2]=v2,I[M+356>>2]=Pe;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(Pe*h)*m(.009999999776482582))}a=m(Ce+a),I[M+356>>2]=a,l[M+348>>2]=(_r|(b|0)!=2)&a==a}Nn(u,_t,pe,bt,M+344|0,M+352|0),Nn(u,et,Pe,bt,M+348|0,M+356|0),Zt=(Mi<<3)+u|0,a=I[Zt+572>>2];e:{s:{n:{a:switch(b=l[Zt+576>>2],b|0){case 0:case 3:break n;default:break a}if(h=I[Zt+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(Zt=0,hs)break e}if(Zt=0,b=l[u+24>>2]>>>13&7,b||(b=l[r+24>>2]>>>10&7),(b|0)!=4||(fn(M+24|0,u,et),l[M+28>>2]==3))break e;un(M+360|0,u,et),Zt=l[M+364>>2]!=3;break e}Zt=0}a=I[M+352>>2],h=I[M+356>>2],b=_t>>>0>1,Ce=b?a:h,a=b?h:a,Bs=l[M+344>>2],Wh=l[M+348>>2],b2=b?Bs:Wh,Bs=b?Wh:Bs,b=(Zt^1)&P,dn(u,Ce,a,Et[r+300|0]&3,b2,Bs,bt,Ze,b,b?4:7,K,tt,ft,Q),lt=m(lt+m(W-$t)),b=Et[r+300|0];e:{s:{if(b&4){Zt=b&251;break s}if(Zt=b&251,b=0,!(Et[u+300|0]&4))break e}b=4}if(gt[r+300|0]=b|Zt,Mt=Mt+4|0,(oi|0)==(Mt|0))break}}Z=m(Z-lt)}u=Et[r+300|0],gt[r+300|0]=u&251|(Z<m(0)?4:u&4),re=m(De(r,_t,k)+fe(r,_t)),Ua=m(xe(r,_t,k)+Se(r,_t)),$t=tl(r,_t,k);i:{if(!(!(Z>m(0))|(cs|0)!=2)){lt=m(0),h=m(0);e:{s:{u=Fs+(l[Ns>>2]<<2)|0,a=I[u>>2],u=l[u>>2],b=(u|0)==2139156720;n:{if(!b){if(Mt=(u|0)==2140081935,Mt)break s;if(Zt=(u|0)==2141891242,Zt|a!=a)break i;if(Mt)break s;if(Zt)break i;if(h=(xt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Us*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=I[b>>2],W=m(Yt),l[b+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(Us*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-re)-Ua)-m(pe-Z)),a!=a)break i;lt=ae(a,m(0));break i}lt=Z}Zt=Y>>>0<=ot>>>0;i:{if(!Zt){for(oi=l[r+556>>2],u=l[r+560>>2]-oi>>2,Mi=u>>>0<ot>>>0?ot:u,Mt=0,u=ot;;){if((u|0)==(Mi|0))break r;if(b=l[oi+(u<<2)>>2],(l[b+24>>2]&196608)!=131072&&(zr=M+24|0,fn(zr,b,_t),Ga=l[M+28>>2],un(zr,b,_t),Mt=(((Ga|0)==3)+Mt|0)+(l[M+28>>2]==3)|0),u=u+1|0,(Y|0)==(u|0))break}if(Ce=m(0),h=$t,Mt)break i}Ce=m(0),Mt=0,h=$t;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:Ce=m(lt*m(.5));break i;case 1:Ce=lt;break i;case 2:if(mt>>>0<2)break i;h=m($t+m((Qe=m(0),Hn=ae(lt,m(0)),qe=lt!=lt,(qe?Qe:Hn)/m(mt-1>>>0))));break i;case 4:Ce=m(lt/m(mt+1>>>0)),h=m($t+Ce);break i;case 3:break e;default:break i}Ce=m(m(lt*m(.5))/m(mt>>>0)),h=m(m(Ce+Ce)+$t)}if(a=m(re+Ce),Z=m(0),oi=Op(r),Zt)h=m(0);else{for(Mi=Y-1|0,Ba=m(lt/m(Mt|0)),re=m(0),W=m(0),u=ot;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=u>>>0)break r;b=l[b+(u<<2)>>2],mt=b+228|0,Gi(M+24|0,mt,320),h=m(h-((u|0)==(Mi|0)?$t:m(0))),Mt=l[b+24>>2];i:{if(Mt&4194304)break i;e:{if((Mt&196608)==131072){if(!ar(b,_t))break e;if(!P)break i;lt=Os(b,_t,pe),Ei=fe(r,_t),ol=ce(b,_t,bt),I[mt+(l[Lr>>2]<<2)>>2]=ol+m(lt+Ei);break i}if(fn(M+360|0,b,_t),a=m(a+(l[M+364>>2]==3?Ba:m(-0))),P&&(Mt=mt,mt=l[Lr>>2]<<2,I[Mt+mt>>2]=a+I[mt+(M+24|0)>>2]),un(M+360|0,b,_t),a=m(a+(l[M+364>>2]==3?Ba:m(-0))),!m2){a=m(a+m(m(h+m(ce(b,_t,bt)+we(b,_t,bt)))+I[M+104>>2])),Z=Pe;break i}if(mt=b+516|0,a=m(a+m(h+m(I[mt+(l[Ns>>2]<<2)>>2]+m(ce(b,_t,bt)+we(b,_t,bt))))),oi){lt=el(b),Ei=ce(b,0,bt),lt=m(lt+Ei),Ei=m(m(I[b+520>>2]+m(ce(b,0,bt)+we(b,0,bt)))-lt),b=re!=re;s:{if(!(b|lt!=lt)){re=ae(re,lt);break s}re=b?lt:re}if(b=W!=W,!(b|Ei!=Ei)){W=ae(W,Ei);break i}W=b?Ei:W;break i}if(lt=m(I[mt+(l[Me>>2]<<2)>>2]+m(ce(b,et,bt)+we(b,et,bt))),b=Z!=Z,!(lt!=lt|b)){Z=ae(Z,lt);break i}Z=b?lt:Z;break i}if(!P)break i;b=l[Lr>>2]<<2,lt=I[b+(M+24|0)>>2],qe=b+mt|0,Qe=m(Ce+m(lt+fe(r,_t))),I[qe>>2]=Qe}if(u=u+1|0,(Y|0)==(u|0))break}h=m(W+re)}if(Z=oi?h:Z,lt=Pe,!p2){h=Xe(r,et,m(tr+Z),Na),u=h!=h,W=m(m(De(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ae(h,W);break i}h=u?W:h}lt=m(h-tr)}h=Xe(r,et,m(tr+(g2?Pe:Z)),Na),u=h!=h,W=m(m(De(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ae(h,W);break i}h=u?W:h}if(W=m(h-tr),!(Zt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=ot>>>0)break r;mt=l[u+(ot<<2)>>2],u=l[mt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!ar(mt,et)){b=l[li>>2];break e}if(h=Os(mt,et,Pe),Z=fe(r,et),$t=ce(mt,et,bt),b=l[li>>2],h=m($t+m(h+Z)),I[(mt+(b<<2)|0)+228>>2]=h,h==h)break i}qe=mt+(b<<2)|0,Qe=m(fe(r,et)+ce(mt,et,bt)),I[qe+228>>2]=Qe;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||(fn(M+24|0,mt,et),b=4,l[M+28>>2]==3)||(un(M+360|0,mt,et),l[M+364>>2]==3))break s;b=mt+(l[Me>>2]<<3)|0,Z=I[b+572>>2];n:{a:switch(u=l[b+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[b+572>>2],!((u|0)!=1|$t!=$t)){if(h=We,Z<m(0))break n;break e}if(h=We,hs&!(Z<m(0))|((u|0)!=2|$t!=$t))break e}Z=I[(mt+(l[Ns>>2]<<2)|0)+516>>2],h=W,$t=I[mt+224>>2],$t==$t&&(h=m(m(ce(mt,et,bt)+we(mt,et,bt))+m(er?Z*$t:Z/$t))),I[M+360>>2]=h,qe=M,Qe=m(Z+m(ce(mt,_t,bt)+we(mt,_t,bt))),I[qe+24>>2]=Qe,l[M+356>>2]=1,l[M+352>>2]=1,Nn(mt,_t,pe,bt,M+356|0,M+24|0),Nn(mt,et,Pe,bt,M+352|0,M+360|0),Z=I[M+360>>2],$t=I[M+24>>2],u=_t>>>0>1,h=u?Z:$t,Z=u?$t:Z,u=(Kr|0)!=0&(l[r+24>>2]&896)!=512,dn(mt,Z,h,Hi,!(u&er|Z!=Z),(!u|er)&h==h,bt,Ze,1,2,K,tt,ft,Q),h=We;break e}h=I[(mt+(l[Me>>2]<<2)|0)+516>>2],Z=ce(mt,et,bt),$t=we(mt,et,bt),fn(M+24|0,mt,et),Z=m(lt-m(h+m(Z+$t)));s:{if(l[M+28>>2]!=3||(un(M+360|0,mt,et),l[M+364>>2]!=3))break s;h=m(Z*m(.5)),h=m(We+(Qe=m(0),Hn=ae(h,m(0)),qe=h!=h,qe?Qe:Hn));break e}if(un(M+24|0,mt,et),h=We,l[M+28>>2]==3)break e;if(fn(M+24|0,mt,et),l[M+28>>2]==3){h=m(We+(Qe=m(0),Hn=ae(Z,m(0)),qe=Z!=Z,qe?Qe:Hn));break e}s:switch(b-1|0){case 1:h=m(We+m(Z*m(.5)));break e;case 0:break e;default:break s}h=m(We+Z)}u=mt+(l[li>>2]<<2)|0,I[u+228>>2]=h+m(ds+I[u+228>>2])}if(ot=ot+1|0,(ot|0)==(Y|0))break}h=m((Ji?Vh:m(0))+W),u=Gs!=Gs,a=m(Ua+a);i:{if(!(u|a!=a)){Gs=ae(Gs,a);break i}Gs=u?a:Gs}if(ds=m(ds+h),u=Ji+1|0,ot=Y,!(Wr>>>0>Y>>>0))break}i:{if(!P||!Kr&&!Op(r))break i;re=m(0);e:{s:{if(Pe!=Pe)break s;a=m(Pe-ds);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:We=m(We+m(a*m(.5)));break s;case 2:if(!(Pe>ds))break s;re=m(a/m(u>>>0));break s;case 5:if(Pe>ds){if(We=m(We+m(a/m(u<<1>>>0))),u>>>0<2)break s;re=m(a/m(u>>>0));break e}We=m(We+m(a*m(.5)));break s;case 4:if(!(Pe>ds)|u>>>0<2)break s;re=m(a/m(Ji>>>0));break e;case 1:break n;default:break s}We=m(We+a)}if(!u)break i}for(Mt=0,u=0,b=0;;){if(Z=m(0),h=m(0),a=m(0),W=m(0),Y=u,Wr>>>0>u>>>0){e:{for(;;){if(b=l[r+556>>2],l[r+560>>2]-b>>2>>>0<=Y>>>0)break r;ot=l[b+(Y<<2)>>2],mt=l[ot+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(b=Y,l[ot+548>>2]!=(Mt|0))break e;a=I[(ot+(l[Me>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(b=h!=h,a=m(a+m(ce(ot,et,bt)+we(ot,et,bt))),!(b|a!=a)){h=ae(h,a);break n}h=b?a:h}if(b=mt>>>13&7,b||(b=l[r+24>>2]>>>10&7),!(Et[r+24|0]&8)|(b|0)!=5)break s;a=el(ot),lt=ce(ot,0,bt),a=m(a+lt),lt=m(m(I[ot+520>>2]+m(ce(ot,0,bt)+we(ot,0,bt)))-a),b=h!=h,ot=W!=W;n:{if(!(ot|a!=a)){W=ae(W,a);break n}W=ot?a:W}ot=Z!=Z;n:{if(!(ot|lt!=lt)){Z=ae(Z,lt);break n}Z=ot?lt:Z}if(a=m(W+Z),!(b|a!=a)){h=ae(h,a);break s}h=b?a:h}if(Y=Y+1|0,(Wr|0)==(Y|0))break}b=Wr}a=h}if(lt=m(We+(Mt?Vh:m(0))),h=m(re+a),We=m(lt+h),u>>>0<b>>>0)for($t=m(lt+W);;){if(Y=l[r+556>>2],l[r+560>>2]-Y>>2>>>0<=u>>>0)break r;ot=l[Y+(u<<2)>>2],Y=l[ot+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(Et[r+24|0]&8)break s;case 0:a=ce(ot,et,bt),I[(ot+(l[li>>2]<<2)|0)+228>>2]=lt+a;break e;case 2:a=we(ot,et,bt),Y=ot+228|0,I[Y+(l[li>>2]<<2)>>2]=m(We-a)-I[(Y+(l[Me>>2]<<2)|0)+288>>2];break e;case 1:Y=ot+228|0,I[Y+(l[li>>2]<<2)>>2]=lt+m(m(h-I[(Y+(l[Me>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=ce(ot,et,bt),I[(ot+(l[li>>2]<<2)|0)+228>>2]=lt+a,mt=ot+(l[Me>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(Y=l[mt+576>>2],Y|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((Y|0)!=1|W!=W)){if(a<m(0))break n;break e}if(hs&!(a<m(0))|((Y|0)!=2|W!=W))break e}n:{if(_t>>>0>=2){Z=h,a=I[ot+516>>2],W=m(a+m(ce(ot,_t,bt)+we(ot,_t,bt)));break n}Z=m(I[ot+520>>2]+m(ce(ot,et,bt)+we(ot,et,bt))),a=I[ot+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ye(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[ot+520>>2],Y=a!=a,!(Y|Z!=Z)){if(!(m(Ye(m(Z-a)))<m(9999999747378752e-20)))break n;break e}if(Z==Z)break n;if(Y)break e}dn(ot,W,Z,Hi,1,1,bt,Ze,1,3,K,tt,ft,Q);break e}qe=ot,Qe=m(m($t-el(ot))+Os(ot,0,Pe)),I[qe+232>>2]=Qe}if(u=u+1|0,(b|0)==(u|0))break}if(Y=(Mt|0)!=(Ji|0),Mt=Mt+1|0,u=b,!Y)break}}mt=r+516|0,a=Xe(r,2,Bh,k),u=a!=a,h=m(m(De(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ae(a,h);break i}a=u?h:a}I[mt>>2]=a,a=Xe(r,0,Gh,S),u=a!=a,h=m(m(De(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ae(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(cs&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(cs|0)!=2))break s;if(a=Xe(r,_t,Gs,Us),u=a!=a,h=m(m(De(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),!(u|h!=h)){a=ae(a,h);break e}a=u?h:a;break e}if((cs|0)!=2|(u|0)!=2)break i;h=m(jr+pe),u=h!=h,a=Xe(r,_t,Gs,Us);s:{if(!(u|a!=a)){a=Ph(h,a);break s}a=u?a:h}if(u=a!=a,!(u|jr!=jr)){a=ae(a,jr);break e}a=u?jr:a}I[mt+(l[Ns>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(b=(Ht|0)!=2,u=l[r+24>>2]>>>20&3,b|(u|0)==2))break s;if(a=Xe(r,et,m(tr+ds),Na),u=a!=a,h=m(m(De(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et))),!(u|h!=h)){a=ae(a,h);break e}a=u?h:a;break e}if(b|(u|0)!=2)break i;h=m(tr+Pe),u=h!=h,a=Xe(r,et,m(tr+ds),Na);s:{if(!(u|a!=a)){a=Ph(h,a);break s}a=u?a:h}if(u=a!=a,!(u|tr!=tr)){a=ae(a,tr);break e}a=u?tr:a}I[mt+(l[Me>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(b=Wr>>>0<=1?1:Wr,P=l[r+556>>2],ot=l[r+560>>2]-P>>2,u=0;Y=0,Y=u>>>0<ot>>>0?l[P+(u<<2)>>2]:Y,(l[Y+24>>2]&196608)!=131072&&(Y=Y+228|0,Mt=Y+(l[li>>2]<<2)|0,Zt=l[Me>>2]<<2,I[Mt>>2]=m(I[Zt+mt>>2]-I[Mt>>2])-I[(Y+Zt|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(Mt=((_t>>>0>1?cs:y)|0)!=0;;){y=l[b>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=bt,pe=Ze,Et[l[r+568>>2]+12|0]&2&&(pe=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Hi|0)==2){ot=0,Y=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}Y=2;break s}if(ot=0,u>>>0<=1)break n;Y=u;break s}Y=u,ot=$s}S=m(ce(y,2,W)+we(y,2,W)),k=ce(y,0,W),Z=we(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(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),!ar(y,2)||!sl(y,2))break s;if(a=Xe(y,2,m(m(I[r+516>>2]-m(fe(r,2)+Se(r,2)))-m(Os(y,2,W)+Ma(y,2,W))),W),u=a!=a,h=m(m(De(y,2,W)+fe(y,2))+m(xe(y,2,W)+Se(y,2))),!(u|h!=h)){h=ae(a,h);break s}h=u?h:a}Z=m(k+Z);s:{n:{a:{o:{l:{c:{h:{Zt=h!=h,k=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=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(pe!=pe|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(pe*k)*m(.009999999776482582))}a=m(Z+a);break f}d:{if(ar(y,0)&&sl(y,0))break d;if(a=m(Yt),h==h)break h;break a}if(a=Xe(y,0,m(m(I[r+520>>2]-m(fe(r,0)+Se(r,0)))-m(Os(y,0,pe)+Ma(y,0,pe))),pe),u=a!=a,k=m(m(De(y,0,W)+fe(y,0))+m(xe(y,0,W)+Se(y,0))),!(u|k!=k)){a=ae(a,k);break f}a=u?k:a}if((Zt|0)==(a!=a|0)||(lt=I[y+224>>2],lt!=lt))break l;if(h!=h){h=m(m(m(a-Z)*lt)+S);break l}if(a==a)break l;break c}if(lt=I[y+224>>2],lt!=lt)break o}a=m(Z+m(m(h-S)/lt))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Zt=W>m(0),Ji=u&Mt&Y>>>0<2,h=Ji&&Zt?W:h,u=u^1,dn(y,h,a,Hi,Ji&&Zt?2:u,a==a,h,a,0,6,K,tt,ft,Q),h=m(I[y+516>>2]+r2(y,2,W)),a=m(I[y+520>>2]+r2(y,0,W))}dn(y,h,a,Hi,1,1,h,a,1,1,K,tt,ft,Q);s:{n:{a:{if(!sl(y,Y)||ar(y,Y))break a;u=l[(Y<<2)+4320>>2]<<2,a=Y>>>0<2?pe:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,Y))-we(y,Y,a))-Ma(y,Y,a));break n}if(!(ar(y,Y)|(l[r+24>>2]&112)!=16)){u=l[(Y<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(ar(y,Y)|(l[r+24>>2]&112)!=32)){u=l[(Y<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(Et[l[r+568>>2]+12|0]&2)||!ar(y,Y))break s;a=I[mt+(l[(Y<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,Y,a)+fe(r,Y))+ce(y,Y,a))}I[(y+(l[(Y<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!sl(y,ot)||ar(y,ot))break n;u=l[(ot<<2)+4320>>2]<<2,a=Y>>>0<2?W:pe,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,ot))-we(y,ot,a))-Ma(y,ot,a));break s}n:{if(ar(y,ot)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(ot<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(ar(y,ot))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[(ot<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(Et[l[r+568>>2]+12|0]&2)||!ar(y,ot))break e;a=I[mt+(l[(ot<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,ot,a)+fe(r,ot))+ce(y,ot,a))}I[(y+(l[(ot<<2)+4288>>2]<<2)|0)+228>>2]=a}if(b=b+4|0,(P|0)==(b|0))break}if(!((et|_t)&1))break i;for(b=et&1,P=_t&1,K=Wr>>>0<=1?1:Wr,tt=(et<<2)+4304|0,ft=(_t<<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(Et[u+26|0]&64||(P&&(y=u+228|0,Y=l[Ns>>2]<<2,I[y+(l[ft>>2]<<2)>>2]=m(I[Y+mt>>2]-I[(y+Y|0)+288>>2])-I[y+(l[Lr>>2]<<2)>>2]),!b))break e;u=u+228|0,y=l[Me>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(l[li>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!$i)break t;bi($i);break t}xs(),le()}Tt=M+384|0}function yp(){var r=0,a=0;Fn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ut(8),l[r>>2]=8,l[r+4>>2]=1,St(7032,2922,6,4368,4392,19,r|0,1),Fn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ut(4),l[r>>2]=24,St(7036,2359,2,4400,4408,25,r|0,0),os(7032,1398,2,4412,4420,26,27),os(7032,3027,3,4500,4512,28,29),Fn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ut(8),l[r>>2]=8,l[r+4>>2]=1,St(7056,3293,2,4520,4408,32,r|0,1),Fn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ut(4),l[r>>2]=37,St(7059,2359,2,4528,4408,38,r|0,0),os(7056,1398,2,4536,4420,39,40),os(7056,3027,3,4500,4512,28,41),Fn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),gp(7062,1,4584,4352,44,45),os(7062,2915,1,4584,4352,44,45),os(7062,1129,2,4588,4408,46,47),r=ut(8),l[r+4>>2]=0,l[r>>2]=48,St(7062,3234,4,4608,4624,49,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=50,St(7062,1981,3,4632,4644,51,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=52,St(7062,1952,3,4652,4664,53,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=54,St(7062,3389,3,4672,4664,55,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=56,St(7062,1800,3,4652,4664,53,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=57,St(7062,3264,3,4684,4512,58,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=59,St(7062,1926,2,4696,4420,60,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=61,St(7062,3399,2,4704,4420,62,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=63,St(7062,1785,2,4696,4420,60,r|0,0),wh(7065,1271,4712,64,4357,65),Vn(1732,0),Vn(1612,8),Vn(2145,16),Vn(2455,24),Vn(2561,32),Vn(1618,40),kh(7065),wh(7035,2898,4712,66,4357,67),Yp(2561,0),Yp(1618,8),kh(7035),wh(7066,2909,4712,68,4357,69),r=ut(4),l[r>>2]=8,a=ut(4),l[a>>2]=8,Jo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ut(4),l[r>>2]=0,a=ut(4),l[a>>2]=0,Jo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),kh(7066),Fn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),gp(7067,1,4724,4352,76,77),os(7067,1593,1,4724,4352,76,77),os(7067,2851,2,4728,4420,78,79),os(7067,1129,2,4736,4408,80,81),r=ut(8),l[r+4>>2]=0,l[r>>2]=82,St(7067,1753,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=84,St(7067,3005,3,4744,4664,85,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=86,St(7067,2930,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=88,St(7067,2335,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=90,St(7067,1485,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=91,St(7067,1356,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=92,St(7067,1818,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=93,St(7067,2872,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=94,St(7067,2379,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=95,St(7067,2164,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=96,St(7067,1320,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=97,St(7067,2413,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=98,St(7067,1504,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=99,St(7067,2236,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=100,St(7067,1220,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=101,St(7067,1137,3,4756,4664,87,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=102,St(7067,1159,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=104,St(7067,1846,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=105,St(7067,1465,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=106,St(7067,2219,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=107,St(7067,1196,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=108,St(7067,2501,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=109,St(7067,2591,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=110,St(7067,1540,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=111,St(7067,2250,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=112,St(7067,1651,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=113,St(7067,1428,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=114,St(7067,2205,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=115,St(7067,2609,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=116,St(7067,1556,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=117,St(7067,1671,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=118,St(7067,1445,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=119,St(7067,2567,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=120,St(7067,1521,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=121,St(7067,1625,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=122,St(7067,1408,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=123,St(7067,2305,3,4792,4718,103,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=124,St(7067,2093,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=125,St(7067,2719,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=126,St(7067,1575,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=127,St(7067,2188,4,4768,4784,89,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=128,St(7067,2946,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=130,St(7067,2347,3,4812,4512,131,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=132,St(7067,1372,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=133,St(7067,1832,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=134,St(7067,2885,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=135,St(7067,2396,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=136,St(7067,2176,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=137,St(7067,1338,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=138,St(7067,2423,3,4812,4512,131,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=139,St(7067,1859,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=141,St(7067,1208,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=143,St(7067,2515,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=144,St(7067,2600,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=145,St(7067,1661,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=146,St(7067,2621,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=147,St(7067,1684,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=148,St(7067,2579,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=149,St(7067,1638,2,4824,4420,140,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=150,St(7067,2320,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=151,St(7067,2103,3,4840,4852,152,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=153,St(7067,1232,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=154,St(7067,1148,2,4804,4420,129,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=155,St(7067,2730,3,4812,4512,131,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=156,St(7067,2195,3,4860,4872,157,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=158,St(7067,3034,4,4880,4624,159,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=160,St(7067,3055,3,4896,4664,161,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=162,St(7067,1293,2,4908,4420,163,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=164,St(7067,1388,2,4916,4420,165,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=166,St(7067,3046,3,4924,4512,167,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=168,St(7067,2962,2,4936,4420,169,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=170,St(7067,2982,3,4944,4664,171,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=172,St(7067,3357,3,4956,4664,173,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=174,St(7067,3355,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=175,St(7067,3374,3,4968,4664,176,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=177,St(7067,3372,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=178,St(7067,1119,2,4736,4408,83,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=179,St(7067,1111,2,4980,4420,180,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=181,St(7067,1244,5,4992,5012,182,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=183,St(7067,1737,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=184,St(7067,1715,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=185,St(7067,2149,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=186,St(7067,2462,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=187,St(7067,2633,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=188,St(7067,1697,2,4832,4714,142,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=189,St(7067,1260,2,5020,4420,190,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=191,St(7067,2433,3,4840,4852,152,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=192,St(7067,2113,3,4840,4852,152,r|0,0),r=ut(8),l[r+4>>2]=0,l[r>>2]=193,St(7067,2741,3,4840,4852,152,r|0,0)}function FE(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,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,mt=0,bt=0,_t=0,Mt=0,$t=0;Q=Tt-560|0,Tt=Q,l[Q+44>>2]=0,yi(+a),k=Jt(1)|0,Jt(0)|0;t:{if((k|0)<0){ot=1,Mt=1177,a=-a,yi(+a),k=Jt(1)|0,Jt(0)|0;break t}if(y&2048){ot=1,Mt=1180;break t}ot=y&1,Mt=ot?1183:1178,$t=!ot}t:{if((k&2146435072)==2146435072){k=ot+3|0,Ai(r,32,h,k,y&-65537),fi(r,Mt,ot),u=b&32,fi(r,a!=a?u?2451:3459:u?2868:3463,3),Ai(r,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=Q+16|0;r:{i:{e:{if(a=Fp(a,Q+44|0),a=a+a,a!=0){if(k=l[Q+44>>2],l[Q+44>>2]=k-1,bt=b|32,(bt|0)!=97)break e;break r}if(bt=b|32,(bt|0)==97)break r;tt=l[Q+44>>2],ft=(u|0)<0?6:u;break i}tt=k-29|0,l[Q+44>>2]=tt,a=a*268435456,ft=(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,k=S,P=Y;break i}for(P=Y,u=tt;;){M=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],_t=u,u=M&31,(M&63)>>>0>=32?(et=K<<u,u=0):(et=(1<<u)-1&K>>>32-u,u=K<<u),_t=_t+u|0,K=et+W|0,u=wp(_t,u>>>0>_t>>>0?K+1|0:K,1e9),K=xh(u,Bi,-1e9,0)+_t|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[Q+44>>2]-M|0,l[Q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(lt=((ft+25>>>0)/9|0)+1|0,W=(bt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(M=1e9>>>et|0,K=-1<<et^-1,u=0,S=P;_t=u,u=l[S>>2],l[S>>2]=_t+(u>>>et|0),u=He(M,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=et+l[Q+44>>2]|0,l[Q+44>>2]=u,P=(!S<<2)+P|0,S=W?Y:P,k=k-S>>2>(lt|0)?S+(lt<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=He(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=He(S,10),K>>>0>=S>>>0;);}if(S=(ft-((bt|0)!=102?u:0)|0)-((bt|0)==103&(ft|0)!=0)|0,(S|0)<(He(k-Y>>2,9)-9|0)){if(M=S+9216|0,K=(M|0)/9|0,tt=((((tt|0)<0?4:292)+Q|0)+(K<<2)|0)-4048|0,S=10,et=M+He(K,-9)|0,(et|0)<=7)for(;S=He(S,10),et=et+1|0,(et|0)!=8;);M=l[tt>>2],lt=(M>>>0)/(S>>>0)|0,W=He(lt,S),K=tt+4|0;i:{if((M|0)==(W|0)&(K|0)==(k|0))break i;M=M-W|0;e:{if(!(lt&1)&&(a=9007199254740992,!(gt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(Z=(k|0)==(K|0)?1:1.5,K=S>>>1|0,Z=K>>>0>M>>>0?.5:(K|0)==(M|0)?Z:1.5,Et[Mt|0]!=45|$t||(Z=-Z,a=-a),l[tt>>2]=W,a+Z==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=He(Y-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=He(S,10),K>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,M=k>>>0<=P>>>0,!M&&(k=K-4|0,!l[k>>2]););i:{if((bt|0)!=103){tt=y&8;break i}if(S=ft||1,k=(S|0)>(u|0)&(u|0)>-5,ft=(k?u^-1:-1)+S|0,b=(k?-1:-2)+b|0,tt=y&8,tt)break i;k=-9;e:{if(M||(tt=l[K-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=He(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=He(K-Y>>2,9),(b&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k;break i}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,ft=(k|0)>(ft|0)?ft:k}if(et=-1,M=tt|ft,((M?2147483645:2147483646)|0)<(ft|0))break t;W=(((M|0)!=0)+ft|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=Un((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,gt[k|0]=48,(mt-k|0)<2;);if(lt=k-2|0,gt[lt|0]=b,gt[k-1|0]=(u|0)<0?45:43,k=mt-lt|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(ot^2147483647))break t;W=u+ot|0,Ai(r,32,h,W,y),fi(r,Mt,ot),Ai(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(b=Q+16|0,u=b|8,tt=b|9,S=P>>>0>Y>>>0?Y:P,P=S;;){k=Un(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break n;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;gt[Q+24|0]=48,k=u}if(fi(r,k,tt-k|0),P=P+4|0,!(Y>>>0>=P>>>0))break}if(M&&fi(r,4275,1),(ft|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Un(l[P>>2],0,tt),k>>>0>Q+16>>>0)for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);if(fi(r,k,(ft|0)>=9?9:ft),k=ft-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(ft|0)>9,ft=k,!u)break}break e}n:{if((ft|0)<0)break n;for(Y=P>>>0<K>>>0?K:P+4|0,b=Q+16|0,u=b|8,K=b|9,S=P;;){k=Un(l[S>>2],0,K),(K|0)==(k|0)&&(gt[Q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(Q+16>>>0>=k>>>0)break a;for(;k=k-1|0,gt[k|0]=48,Q+16>>>0<k>>>0;);break a}if(fi(r,k,1),k=k+1|0,!(tt|ft))break a;fi(r,4275,1)}if(b=K-k|0,fi(r,k,(b|0)>(ft|0)?ft:b),ft=ft-b|0,S=S+4|0,Y>>>0<=S>>>0)break n;if(!((ft|0)>=0))break}}Ai(r,48,ft+18|0,18,0),fi(r,lt,mt-lt|0);break i}k=ft}Ai(r,48,k+9|0,9,0)}Ai(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(b<<26>>31&9)+Mt|0;r:{if(u>>>0>11)break r;for(k=12-u|0,Z=16;Z=Z*16,k=k-1|0,!!k;);if(Et[tt|0]==45){a=-(Z+(-a-Z));break r}a=a+Z-Z}for(Y=ot|2,P=b&32,S=l[Q+44>>2],k=S>>31,k=Un((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(gt[Q+15|0]=48,k=Q+15|0),ft=k-2|0,gt[ft|0]=b+15,gt[k-1|0]=(S|0)<0?45:43,k=y&8,S=Q+16|0;b=S,Ye(a)<2147483648?K=~~a:K=-2147483648,gt[S|0]=P|Et[K+5504|0],a=(a-+(K|0))*16,S=b+1|0,!(k|(u|0)>0)&a==0|(S-(Q+16|0)|0)!=1||(gt[b+1|0]=46,S=b+2|0),a!=0;);if(et=-1,k=mt-ft|0,b=k+Y|0,(2147483645-b|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}b=u+b|0,Ai(r,32,h,b,y),fi(r,tt,Y),Ai(r,48,h,b,y^65536),fi(r,Q+16|0,P),Ai(r,48,u-P|0,0,0),fi(r,ft,k),Ai(r,32,h,b,y^8192),et=(h|0)<(b|0)?b:h}return Tt=Q+560|0,et|0}function bp(r,a,h,u,y,b,k){var S=0,P=0,K=0,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0,ot=0,lt=0,mt=0,bt=0,_t=0,Mt=0,$t=0,Ht=0,Zt=0;K=Tt-80|0,Tt=K,l[K+76>>2]=a,$t=K+55|0,lt=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=Et[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(Et[P+1|0]!=37){a=P;break c}if(S=S+1|0,ft=Et[P+2|0],a=P+2|0,P=a,(ft|0)!=37)break}}if(S=S-tt|0,Mt=W^2147483647,(S|0)>(Mt|0))break e;if(r&&fi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,Z=-1,P=gt[a+1|0],!al(P)|Et[a+2|0]!=36||(Z=P-48|0,mt=1,S=a+3|0),l[K+76>>2]=S,M=0,P=gt[S|0],a=P-32|0;c:{if(a>>>0>31){ft=S;break c}if(ft=S,a=1<<a,!(a&75913))break c;for(;;){if(ft=S+1|0,l[K+76>>2]=ft,M=a|M,P=gt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=ft,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=gt[ft+1|0];h:{if(!(!al(a)|Et[ft+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=ft+3|0,mt=1,Y=l[((gt[ft+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=ft+1|0,!r){l[K+76>>2]=P,mt=0,Y=0;break c}a=l[h>>2],l[h>>2]=a+4,mt=0,Y=l[a>>2]}if(l[K+76>>2]=P,(Y|0)>=0)break c;Y=0-Y|0,M=M|8192;break c}if(Y=Vp(K+76|0),(Y|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(Et[P|0]!=46){a=P,ot=0;break c}if(Et[P+1|0]==42){a=gt[P+2|0];h:{if(!(!al(a)|Et[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((gt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)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,ot=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Vp(K+76|0),a=l[K+76>>2],ot=1}for(;;){if(Q=S,ft=28,bt=a,S=gt[a|0],S-123>>>0<4294967238)break i;if(a=bt+1|0,S=Et[(S+He(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((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;Lp(K- -64|0,S,h,k);break c}if((Z|0)>=0)break i}if(S=0,!r)continue s}P=M&-65537,M=M&8192?P:M,Z=0,_t=1167,ft=lt;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=gt[bt|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 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],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:Ur[l[K+64>>2]>>1]=W;continue s;case 4:gt[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,M=M|8,S=120}if(tt=lt,P=l[K+64>>2],Q=l[K+68>>2],P|Q)for(Ht=S&32;tt=tt-1|0,gt[tt|0]=Ht|Et[(P&15)+5504|0],Zt=!Q&P>>>0>15|(Q|0)!=0,bt=Q,Q=Q>>>4|0,P=(bt&15)<<28|P>>>4,!!Zt;);if(!(M&8)|!(l[K+64>>2]|l[K+68>>2]))break u;_t=(S>>>4|0)+1167|0,Z=2;break u}if(S=lt,tt=l[K+68>>2],Q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,gt[S|0]=P&7|48,bt=!Q&P>>>0>7|(Q|0)!=0,tt=Q,Q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!bt;);if(tt=S,!(M&8))break u;S=lt-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,Z=1,S=1167;break g}if(M&2048){Z=1,S=1168;break g}Z=M&1,S=Z?1169:1167}_t=S,tt=Un(P,Q,lt)}if((et|0)<0&&ot)break e;if(M=ot?M&-65537:M,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=lt,et=0;break a}S=!(S|P)+(lt-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}M=0,ot=et>>>0>=2147483647?2147483647:et,Q=ot,ft=(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(M=Et[S|0],!M)break b;if(Q=Q-1|0,ft=(Q|0)!=0,S=S+1|0,!(S&3))break m;if(!Q)break}}if(!ft)break u;m:{if(!(!Et[S|0]|Q>>>0<4))for(;;){if(ft=l[S>>2],(ft^-1)&ft-16843009&-2139062144)break m;if(S=S+4|0,Q=Q-4|0,!(Q>>>0>3))break}if(!Q)break u}ft=0;break g}ft=1}for(;;){if(!ft){M=Et[S|0],ft=1;continue}if(!M)break y;if(S=S+1|0,Q=Q-1|0,!Q)break u;ft=0}}S=0}if(S=S?S-tt|0:ot,ft=S+tt|0,(et|0)>=0){M=P,et=S;break a}if(M=P,et=S,Et[ft|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,Ai(r,32,Y,0,M);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=zp(K+4|0,tt),ft=(tt|0)<0,!(ft|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(ft)break r}if(ft=61,(S|0)<0)break i;if(Ai(r,32,Y,S,M),!S){S=0;break f}for(ft=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=zp(K+4|0,tt),ft=tt+ft|0,ft>>>0>S>>>0))break f;if(fi(r,K+4|0,tt),P=P+4|0,!(S>>>0>ft>>>0))break}}Ai(r,32,Y,S,M^8192),S=(S|0)<(Y|0)?Y:S;continue s}if((et|0)<0&&ot)break e;if(ft=61,S=Pt[b|0](r,Ve[K+64>>3],Y,et,M,S)|0,(S|0)>=0)continue s;break i}gt[K+55|0]=l[K+64>>2],et=1,tt=$t,M=P;break a}P=Et[S+1|0],S=S+1|0}if(r)break t;if(!mt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(Lp((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}ft=28;break i}if(Q=ft-tt|0,et=(et|0)>(Q|0)?et:Q,(et|0)>(Z^2147483647))break e;if(ft=61,P=et+Z|0,S=(P|0)<(Y|0)?Y:P,(Mt|0)<(S|0))break i;Ai(r,32,S,P,M),fi(r,_t,Z),Ai(r,48,S,P,M^65536),Ai(r,48,et,Q,0),fi(r,tt,Q),Ai(r,32,S,P,M^8192);continue}break}W=0;break t}ft=61}l[1781]=ft}W=-1}return Tt=K+80|0,W}function NE(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),tt=0,ft=m(0),Q=0;Q=Tt+-64|0,Tt=Q,k=l[r>>2],Vi(Q+8|0,0,56),l[1755]=l[1755]+1,Ep(k),S=m(a),b=I[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[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))}ft=m(y+m(ce(k,2,S)+we(k,2,S))),tt=1;break t}y=m(0),b=I[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(b==b)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(b==b)break s;P=4344}switch(y=I[P>>2],ft=m(Yt),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}ft=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,ft=S;break t}tt=2,ft=y}K=m(h),b=I[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[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(ce(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),b=I[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=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(b==b)break s;P=4344}switch(y=I[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=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(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}dn(k,ft,b,u,tt,r,S,K,1,0,l[k+568>>2],Q+8|0,0,l[1755])&&(xp(k,Et[k+300|0]&3,S,K,S),Cp(k,+I[l[k+568>>2]+20>>2],0,0)),Tt=Q- -64|0}function UE(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,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(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=(xt(2,(h&-1073741825)+536870912|0),Bt()),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,tt!=tt)break i;u=(xt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Ye(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=I[P+28>>2],r=k!=k,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],r=k!=k,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&r))break t}for(Gi(a+24|0,P+24|0,204);;){if(r=Et[a+4|0],r&4)break t;if(gt[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 BE(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,tt=0,ft=0,Q=0,et=0,M=0,W=0,Y=0,Z=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,M=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],Q=r,k=Tt-32|0,Tt=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=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,ft=h,b=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,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;tt=b,b=K&31,(K&63)>>>0>=32?(h=tt<<b,b=0):(h=(1<<b)-1&tt>>>32-b|y<<b,b=tt<<b),y=h,W=b,tt=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|tt>>>b),b=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[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=b,l[k+28>>2]=y,a=15361-et|0;r:{if(a&64){u=ft,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,ft=0,S=0;break r}if(!a)break r;y=ft,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=ft,h=a&31,(a&63)>>>0>=32?(r=0,ft=S>>>h|0):(r=S>>>h|0,ft=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=ft,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}Tt=k+32|0,xt(0,a|0),xt(1,Q&-2147483648|r),Y=M,Z=+Ae(),Ve[Y>>3]=Z}function dn(r,a,h,u,y,b,k,S,P,K,tt,ft,Q,et){var M=m(0),W=0,Y=0,Z=0,ot=0,lt=m(0),mt=0,bt=0,_t=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&Et[r+4|0]&4)&&(ot=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,ot=1}mt=Q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(lt=ce(r,2,k),_t=we(r,2,k),M=m(ce(r,0,k)+we(r,0,k)),Q=r+524|0,lt=m(lt+_t),kp(y,a,b,h,l[r+532>>2],I[Q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],lt,M,tt))break i;if(Y=l[r+320>>2],!Y)break e;for(W=r+324|0;;){if(Q=W+He(Z,24)|0,kp(y,a,b,h,l[Q+8>>2],I[Q>>2],l[Q+12>>2],I[Q+4>>2],I[Q+16>>2],I[Q+20>>2],lt,M,tt))break i;if(Z=Z+1|0,(Y|0)==(Z|0))break}break e}if(!P){if(bt=l[r+320>>2],!bt)break e;for(Y=r+324|0;;){W=He(Z,24),Q=W+Y|0,M=I[Q>>2];s:{n:{if(!(M!=M|a!=a)){if(m(Ye(m(M-a)))<m(9999999747378752e-20))break n;break s}if(M==M|a==a)break s}W=Y+W|0,M=I[W+4>>2];n:{if(!(M!=M|h!=h)){if(m(Ye(m(M-h)))<m(9999999747378752e-20))break n;break s}if(M==M|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,(bt|0)==(Z|0))break}break e}Q=r+524|0,M=I[Q>>2];s:{if(!(M!=M|a!=a)){if(m(Ye(m(M-a)))<m(9999999747378752e-20))break s;break e}if(M==M|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(b|0)?Q:0,M=I[r+528>>2],Q=M!=M,Y=h!=h;s:{if(Q|Y){Q=Q&Y;break s}Q=m(Ye(m(M-h)))<m(9999999747378752e-20)}Q=Q?W:0;break i}vp(r,a,h,u,y,b,k,S,P,tt,ft,mt,et,K),l[r+316>>2]=u;break r}if(!(!Q|ot)){I[r+516>>2]=I[Q+16>>2],I[r+520>>2]=I[Q+20>>2],u=(P?12:16)+ft|0,l[u>>2]=l[u>>2]+1;break t}if(vp(r,a,h,u,y,b,k,S,P,tt,ft,mt,et,K),l[r+316>>2]=u,Q)break t}Q=l[r+320>>2],u=Q+1|0,u>>>0>hp[ft+8>>2]&&(l[ft+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=(He(Q,24)+r|0)+324|0),l[u+12>>2]=b,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=Et[r+4|0],y=u|1,gt[r+4|0]=y,!(u&4)))break t;gt[r+4|0]=y&251}return l[r+312>>2]=et,!Q|ot}function Sh(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=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=vr(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=vr(u^b),u=(u|0)==32?vr(a^h)+32|0:u,h=63-u|0,Bi=0-(u>>>0>63)|0;break i}Bi=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=Lh(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),tt=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),ft=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|ft>>>h),a=a|tt,Bi=y|b,l[1750]=l[1750]&a,l[1751]=Bi&K,a=P^1}if(!(a|u))break}b=l[1751],y=l[1750]}i:{if(y|b){u=vr(b),h=63-((u|0)==32?vr(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=Lh(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(_h(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=Lh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!_h(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,b=0,k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0;S=Tt-80|0,Tt=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,Ps(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=$a(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=Ps(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=$a(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,tt=l[y+12>>2],l[y+12>>2]=l[b+12>>2],l[b+12>>2]=tt,(a|0)!=(u|0)&&(l[b+8>>2]=((u-a|0)+3&-4)+a),!K)break e;bi(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,ft=y,Q=Ps(l[y+4>>2]-h|0,a,h),l[ft+4>>2]=Q,u=l[r+560>>2]-k|0,k=Ps(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;bi(a)}for(l[P+552>>2]=r;a=Et[r+4|0],!!(!(a&4)&&(gt[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)););Tt=S+80|0;return}l[S+16>>2]=4075,nr(r,S+16|0),Qi(),le()}l[S>>2]=4208,nr(r,S),Qi(),le()}xs(),le()}function Ap(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,gt[r+4|0]=Et[r+4|0]&128,u=Vi(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Vi(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,Vi(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Vi(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,Jp((a|0)!=0,2760),gt[r+4|0]=Et[r+4|0]|1,gt[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function Xe(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=I[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=I[k>>2],b=m(Yt),l[k+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}b=m(m(y*u)*m(.009999999776482582));break s}b=I[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=I[k>>2],b=m(Yt),l[k+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}b=m(m(y*u)*m(.009999999776482582));break a}b=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}b=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(!(b>=m(0)))return h;y=h<b?b:h}return y}function Ep(r){var a=0,h=0,u=m(0),y=m(0),b=m(0),k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0,et=0,M=0;for(k=Tt-16|0,l[k+8>>2]=0,l[k+12>>2]=1,tt=r+200|0,ft=r+572|0,Q=r+208|0,et=r+216|0,r=0;;){M=r,K=l[(k+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(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=(xt(2,(h&-1073741825)+536870912|0),Bt()),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=(xt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&b!=b|m(Ye(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+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)+ft|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(M&1))break}}function Gi(r,a,h){var u=0,y=0,b=0;if(h>>>0>=512)return DE(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(gt[h|0]=Et[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;gt[h|0]=Et[a|0],gt[h+1|0]=Et[a+1|0],gt[h+2|0]=Et[a+2|0],gt[h+3|0]=Et[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;gt[h|0]=Et[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Tp(r,a,h,u,y){var b=m(0),k=0,S=m(0),P=m(0),K=0,tt=0,ft=m(0),Q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+r|0,b=I[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=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(xt(2,(k&-1073741825)+536870912|0),Bt()),!(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=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(b==b)break s;r=4344}switch(h=I[r>>2],b=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;b=m(34028234663852886e22);break t}b=m(h-u)}if(h=(ft=S,Q=Ph(S,b),et=b!=b|tt,et?ft:Q),r=h!=h,!(r|P!=P))return ae(h,P);S=r?P:h}return S}function kp(r,a,h,u,y,b,k,S,P,K,tt,ft,Q){var et=m(0),M=m(0),W=0,Y=0,Z=m(0),ot=m(0),lt=m(0),mt=0,bt=0;if(P<m(0)|K<m(0))r=0;else{Z=b,ot=a,lt=u,M=S;t:{if(!Q||(et=I[Q+20>>2],M=S,et==m(0)))break t;mt=+et,ot=Vr(+a,mt,0,0),lt=Vr(+u,mt,0,0),Z=Vr(+b,mt,0,0),M=Vr(+S,mt,0,0)}et=M,Q=0;t:{if((r|0)!=(y|0))break t;if(bt=Z!=Z,Q=ot!=ot,bt|Q){Q=Q&bt;break t}Q=m(Ye(m(Z-ot)))<m(9999999747378752e-20)}bt=Q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,Q=lt!=lt,W|Q){W=Q&W;break t}W=m(Ye(m(et-lt)))<m(9999999747378752e-20)}Y=1,Q=1;t:{if(bt)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<b)|(r|(y|0)!=2|(a!=a|b!=b|P!=P))||(Q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){Q=r&y;break t}Q=m(Ye(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-ft);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(Y=0,!(a<S)|(r|(k|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(Ye(m(a-K)))<m(9999999747378752e-20)}r=Q&Y}return r}function Rh(r){var a=0,h=0,u=0,y=0,b=0,k=0,S=0,P=0;if(yi(+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,xt(0,(h?S:u)|0),xt(1,(h?k:a)|P),+Ae()}function _h(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>u2()<<16>>>0&&!(IE(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,!(gt[(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=vr(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 wp(r,a,h){var u=0,y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=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,Bi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;b=(vr(h)+33|0)-vr(a)|0,k=0-b|0;break e}r=(a>>>0)/0|0,Bi=0;break t}if(u=32-vr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;b=h?31-vr(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),Bi=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,ft=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=ft-(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=tt|r<<1,tt=y&1,b=b-1|0,!!b;);Bi=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Bi=a}return r}function tl(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(Yt),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 Sp(r,a){var h=0,u=0,y=0,b=0,k=0,S=0;for(h=Tt-320|0,Tt=h,u=Vi(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Vi(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,Gi(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,gt[r+4|0]=Et[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=Dp(l[b>>2],Et[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););Tt=u+320|0}function Lh(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=vr(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 VE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,b=0;y=Tt-320|0,Tt=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!$p(r,u)))break t;if((r|0)==(a|0)){for(h=Vi(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Vi(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,Gi(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=Et[r+4|0],a&4)break t;if(gt[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}}Tt=y+320|0}function Rp(r){r=r|0;var a=0,h=0,u=0,y=0,b=0,k=0,S=0;if(r){if(k=Tt-32|0,Tt=k,a=l[r>>2],u=l[a+552>>2],u&&($p(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=$a(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=Ps(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;bi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,bi(u)),bi(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),Tt=k+32|0,bi(r)}}function HE(r){r=r|0;var a=0,h=0,u=0;u=Tt-624|0,Tt=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=Ap(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,Gi(r+24|0,a+24|0,204),Gi(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,bi(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,Tt=u+624|0;return}l[u+16>>2]=3301,nr(r,u+16|0),Qi(),le()}l[u>>2]=2047,nr(r,u),Qi(),le()}function _p(){$E(7084,3067),ME(7085,2480,1,1,0),ls(7086,2140,1,-128,127),ls(7087,2133,1,-128,127),ls(7088,2131,1,0,255),ls(7089,1287,2,-32768,32767),ls(7090,1278,2,0,65535),ls(7091,1316,4,-2147483648,2147483647),ls(7092,1307,4,0,-1),ls(7093,2659,4,-2147483648,2147483647),ls(7094,2650,4,0,-1),s2(7095,1777,-2147483648,2147483647),s2(7096,1776,0,-1),fp(7097,1770,4),fp(7098,3015,8),pp(7099,2677),pp(7100,3904),Th(7101,4,2664),Th(7102,2,2689),Th(7103,4,2704),OE(7104,2485),_i(7105,0,3835),_i(7106,0,3937),_i(7107,1,3865),_i(7108,2,3467),_i(7109,3,3498),_i(7110,4,3538),_i(7111,5,3567),_i(7112,4,3974),_i(7113,5,4004),_i(7106,0,3669),_i(7107,1,3636),_i(7108,2,3735),_i(7109,3,3701),_i(7110,4,3802),_i(7111,5,3768),_i(7114,6,3605),_i(7115,7,4043)}function Ps(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 Gi(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(gt[u|0]=Et[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,gt[u|0]=Et[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,gt[h+r|0]=Et[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(;gt[u|0]=Et[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function Lp(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=Ur[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]=$n[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=gt[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]=Et[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Ve[r>>3]=Ve[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 Cp(r,a,h,u){var y=0,b=0,k=0,S=0,P=0,K=0,tt=0,ft=0,Q=0,et=m(0),M=m(0),W=m(0),Y=0,Z=m(0);t:{if(a==0||(et=I[r+248>>2],M=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=Et[r+4|0]&8,b=y>>>3|0,Y=r,Z=Vr(P,a,0,b),I[Y+228>>2]=Z,K=+W,Y=r,Z=Vr(K,a,0,b),I[Y+232>>2]=Z,tt=+M,k=Rh(tt*a),b=k==k&Ye(k)<1e-4,S=!(b|k!=k?b:Ye(k+-1)<1e-4),ft=+et,k=Rh(ft*a),b=k==k&Ye(k)<1e-4,Q=!(b|k!=k?b:Ye(k+-1)<1e-4),b=0,h=P+h,y=(y|0)!=0,Y=r,Z=m(Vr(h+tt,a,y&S,y&!S)-Vr(h,a,0,y)),I[Y+244>>2]=Z,u=K+u,Y=r,Z=m(Vr(u+ft,a,y&Q,y&!Q)-Vr(u,a,0,y)),I[Y+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,Cp(y,a,h,u),b=b+1|0,(S|0)!=(b|0););}}function Vi(r,a,h){var u=0,y=0,b=0,k=0;t:{if(!h||(gt[r|0]=a,u=r+h|0,gt[u-1|0]=a,h>>>0<3)||(gt[r+2|0]=a,gt[r+1|0]=a,gt[u-3|0]=a,gt[u-2|0]=a,h>>>0<7)||(gt[r+3|0]=a,gt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=He(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=xh(a,0,1,1),b=Bi,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 bi(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=vr(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 WE(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=Tt-32|0,Tt=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(!i2(xE(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 Tt=u+32|0,r|0}function jE(r){r=r|0;var a=0,h=0,u=0,y=0,b=0;h=Tt-96|0,Tt=h,l[h>>2]=r,u=Tt-16|0,Tt=u,l[u+12>>2]=h,r=Tt-144|0,Tt=r,r=Gi(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,Ip(r,2202,h,0,0),y&&(a=l[r+20>>2],gt[a-((a|0)==l[r+16>>2])|0]=0),Tt=r+144|0,Tt=u+16|0,r=b;t:{if(r&3)for(;;){if(!Et[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,!!Et[r|0];);}return r=(r-b|0)+1|0,a=Sh(r),a?r=Gi(a,b,r):r=0,Tt=h+96|0,r|0}function Ip(r,a,h,u,y){var b=0,k=0,S=0,P=0;b=Tt-208|0,Tt=b,l[b+204>>2]=h,h=b+160|0,Vi(h,0,40),l[b+200>>2]=l[b+204>>2];t:{if((bp(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,Hp(r))break r}h=bp(r,a,b+200|0,b+80|0,b+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|k&32,y=r&32?-1:h,!P)break t}return Tt=b+208|0,y}function el(r){var a=0,h=m(0),u=0,y=0,b=0,k=0,S=0,P=m(0),K=0;b=Tt-16|0,Tt=b,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(Et[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[b>>2]=3409,nr(r,b),Qi(),le()}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),Et[y+4|0]&2|(Et[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(el(u)+I[u+232>>2])}return Tt=b+16|0,h}function Nn(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=I[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=I[P>>2],S=m(Yt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(xt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(ce(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[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}I[b>>2]=u}}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)+4288>>2];t:{if((a&-2)==2){a=Br(r,4,b,2140081935);break t}a=Gr(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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),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}k=y==y?y:m(0)}return k}function xe(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=Br(r,5,b,2140081935);break t}a=Gr(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=(xt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(Yt),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}k=y==y?y:m(0)}return k}function Dp(r,a,h,u,y,b){var k=0;t:{r:{if(r){i:{if(a&4){b=Pt[r|0](h,u,y,b)|0;break i}b=Pt[r|0](h,u,y)|0}if(b)break r}if(b=ut(588),a=Gi(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=ut(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}xs(),le()}function nr(r,a){var h=0,u=0,y=0;y=Tt-16|0,Tt=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],Et[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(!Et[7016]){h=ut(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,gt[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,gt[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(Et[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}Tt=y+16|0}function Ma(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=Br(r,5,y,2140081935);break r}a=Gr(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],b=m(Yt),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}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Os(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=Br(r,4,y,2140081935);break r}a=Gr(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],b=m(Yt),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}b=m(m(u*h)*m(.009999999776482582))}return b}return u}function Br(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 KE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Tt-16|0,Tt=u,l[u+12>>2]=h;t:{if(r)break t;if(Et[7016]){r=l[1753];break t}r=ut(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,gt[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,gt[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(Et[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}Tt=u+16|0,Qi(),le()}I[r+20>>2]=a==m(0)?m(0):a,Tt=h+16|0}function xp(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=Qp(r,b,h),u=Qp(r,a,u),S=ce(r,b,y),k=r+228|0,P=b<<2,I[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,b,y),I[k+(l[P+4304>>2]<<2)>>2]=h+S,h=ce(r,a,y),b=a<<2,I[k+(l[b+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),I[k+(l[b+4304>>2]<<2)>>2]=u+h}function zE(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=Tt-48|0,Tt=k,P=l[a+8>>2];t:{if(gt[7052]&1){a=l[1762];break t}a=up(5,4480)|0,gt[7052]=1,l[1762]=a}l[k+40>>2]=b,I[k+32>>2]=y,l[k+24>>2]=u,I[k+16>>2]=h,S=+RE(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,SE(u|0),Tt=k+48|0}function YE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,b=0,k=0;if(u=Tt-32|0,Tt=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){b=(y|15)+1|0,k=ut(b),l[u+16>>2]=b|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,b=y+k|0;break r}if(gt[u+19|0]=y,k=u+8|0,b=k+y|0,!y)break t}Gi(k,a+4|0,y)}return gt[b|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),wE(l[u+24>>2]),r=l[u+24>>2],Oa(r|0),Oa(l[u>>2]),gt[u+19|0]<0&&bi(l[u+8>>2]),Tt=u+32|0,r|0}xs(),le()}function fi(r,a,h){var u=0,y=0,b=0;if(!(Et[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Hp(a))break r;r=l[a+16>>2]}if(b=l[a+20>>2],r-b>>>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,Et[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,b=l[a+20>>2]}Gi(b,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function Ch(r,a,h){var u=0,y=0,b=0;u=Tt-16|0,Tt=u,y=r+24|0,Pt[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(Pt[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=Et[r+4|0],a&4)break t;if(gt[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}}Tt=u+16|0}function Gr(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 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=Br(r,5,y,2140081935);break t}r=Gr(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(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function ce(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=Br(r,4,y,2140081935);break t}r=Gr(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(Yt);if(u=(xt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function XE(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&&(Gi(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&&(Gi(b,a,u),b=u+l[y>>2]|0,l[y>>2]=b,l[y+4>>2]=l[y+4>>2]-u),gt[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=Br(r,5,u,2140081935);break t}r=Gr(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(Yt)}return ae(h,m(0))}function fe(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Br(r,4,u,2140081935);break t}r=Gr(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(Yt)}return ae(h,m(0))}function ZE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function qE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function QE(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=I[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=(xt(2,(a&-1073741825)+536870912|0),+Bt())}Ve[r+8>>3]=y,l[r>>2]=u}function Vr(r,a,h,u){var y=0,b=0,k=0;r=r*a,y=Rh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Ye(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ye(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=Ye(y+-.5)<1e-4?1:0}r=r+b}return r!=r|a!=a?m(Yt):m(r/a)}function Pp(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 Op(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 JE(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function tT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function eT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function iT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function rT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function sT(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=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=(xt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Ve[r+8>>3]=u,l[r>>2]=a}function nT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(Et[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(Et[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,nr(r,h),Qi(),le()}function aT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(Et[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(Et[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,nr(r,h),Qi(),le()}function oT(r,a){r=r|0,a=a|0;var h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],(a|0)<6){Tt=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(Et[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(Et[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,nr(r,h),Qi(),le()}function lT(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=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,Ve[r+8>>3]=u}function Hr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ye(r))==m(dp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(qi(r),Jt(2)&-2147483648|1602224127)),Bt()),a=(qi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),Jt(2)-536870912|1073741824)}return a}function yr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ye(r))==m(dp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(xt(2,(qi(r),Jt(2)&-2147483648|1610612735)),Bt()),a=(qi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),Jt(2)-536870912|0)}return a}function cT(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(Yt),(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 hT(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=Tt-16|0,Tt=k,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](k,a,h,u,y,b),r=ut(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,Tt=k+16|0,r|0}function Mp(r,a){t:{if(a){a=e2(l[a>>2]);break t}r:{if(Et[7016]){a=l[1753];break r}a=ut(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,gt[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,gt[7016]=1,l[1752]=l[1752]+1}a=e2(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function dT(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=yr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=Et[r+4|0],a&4)break t;if(gt[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 uT(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=yr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=Et[r+4|0],a&4)break t;if(gt[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 fT(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=Yt,(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 pT(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=Et[r+4|0],a&4)break t;if(gt[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 Un(r,a,h){var u=0,y=0,b=0;t:{if(!a){u=r;break t}for(;u=wp(r,a,10),y=Bi,r=xh(u,y,246,0)+r|0,h=h-1|0,gt[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,gt[h|0]=He(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function gT(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=Et[r+4|0],a&4)break t;if(gt[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 mT(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=Et[r+4|0],a&4)break t;if(gt[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 vT(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=Et[r+4|0],a&4)break t;if(gt[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 yT(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=Et[r+4|0],h&4)break t;if(gt[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 bT(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=Et[r+4|0],h&4)break t;if(gt[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 AT(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=Et[r+4|0],h&4)break t;if(gt[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 ET(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=Et[r+4|0],h&4)break t;if(gt[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 TT(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=Et[r+4|0],a&4)break t;if(gt[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 kT(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=Et[r+4|0],a&4)break t;if(gt[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 wT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=Et[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(gt[r+4|0]=h&253|(a?2:0);;){if(a=Et[r+4|0],a&4)break t;if(gt[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 ST(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Tt-16|0,Tt=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=ut(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,Tt=u+16|0,r|0}function $p(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,Ps(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function RT(r){r=r|0;var a=0,h=0;if(h=Tt-16|0,Tt=h,r=l[r>>2],l[r+8>>2]){for(;a=Et[r+4|0],!!(!(a&4)&&(gt[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)););Tt=h+16|0;return}l[h>>2]=1024,nr(r,h),Qi(),le()}function Fp(r,a){var h=0,u=0,y=0;if(yi(+r),u=Jt(1)|0,y=Jt(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=Fp(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 _T(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Tt-16|0,Tt=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=ut(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,Tt=h+16|0,r|0}function il(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=Et[r+4|0],a&4)break t;if(gt[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 rl(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=Et[r+4|0],a&4)break t;if(gt[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;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=Et[r+4|0],a&4)break t;if(gt[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 Ih(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=Et[r+4|0],a&4)break t;if(gt[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 Np(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=Et[r+4|0],a&4)break t;if(gt[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 Dh(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=Et[r+4|0],a&4)break t;if(gt[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 Up(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=Et[r+4|0],a&4)break t;if(gt[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 LT(){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;);_h(48),l[1756]=16,l[1757]=0,yp(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,_p(),l[1770]=l[1768],l[1768]=7076}function ar(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Br(r,4,h,2143289344);break t}r=Gr(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 sl(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Br(r,5,h,2143289344);break t}r=Gr(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 xh(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=He(y,b),k=h&65535,S=r&65535,P=He(k,S),b=(P>>>16|0)+He(b,k)|0,y=(b&65535)+He(y,S)|0,Bi=(He(a,h)+K|0)+He(r,u)+(b>>>16)+(y>>>16)|0,P&65535|y<<16}function Bp(r,a){var h=0,u=0,y=0;u=Tt-16|0,Tt=u,h=Et[r+4|0],y=h&-17,gt[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,gt[r+4|0]=h,Tt=u+16|0;return}l[u>>2]=4128,nr(r,u),Qi(),le()}function Gp(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=Gn(r)!=m(0)}return a}function Ai(r,a,h,u,y){var b=0;if(b=Tt-256|0,Tt=b,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Vi(b,a&255,h?u:256),!h)for(;fi(r,b,256),u=u-256|0,u>>>0>255;);fi(r,b,u)}Tt=b+256|0}function un(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]}Pp(r,u)}function fn(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]}Pp(r,u)}function Gn(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),gt[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 Vp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=gt[u|0],al(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=He(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function $a(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=ut(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}Nh(),le()}function Hp(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 CT(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=Tt-16|0,Tt=k,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](k,a,h,u,y,b),I[r>>2]=Ve[k>>3],I[r+4>>2]=Ve[k+8>>3],Tt=k+16|0}function IT(){var r=0,a=0;return a=ut(4),r=ut(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,gt[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function DT(r,a){r=r|0,a=a|0,a=l[a>>2],Ve[r>>3]=I[a+228>>2],Ve[r+8>>3]=I[a+236>>2],Ve[r+16>>3]=I[a+232>>2],Ve[r+24>>3]=I[a+240>>2],Ve[r+32>>3]=I[a+244>>2],Ve[r+40>>3]=I[a+248>>2]}function xT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Tt-48|0,Tt=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=Gi(ut(48),h,48),Tt=h+48|0,r|0}function PT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Tt-16|0,Tt=y,r=i2(LE(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Tt=y+16|0,Bi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function OT(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 MT(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}xs(),le()}function $T(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]),Pt[b|0](a,h,u,y)}function FT(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 Wp(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 jp(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 NT(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 UT(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 ut(r){var a=0;r=r||1;t:{for(;;){if(a=Sh(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}xs(),le()}return a}function BT(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 Ms(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 pn(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 Ph(r,a){return qi(r),(Jt(2)&2147483647)>>>0<=2139095040?(qi(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(TE(r,a))):a}function ae(r,a){return qi(r),(Jt(2)&2147483647)>>>0<=2139095040?(qi(a),(Jt(2)&2147483647)>>>0>2139095040?r:m(kE(r,a))):a}function Kp(r,a){r=r|0,a=a|0;var h=0;return h=Tt-16|0,Tt=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Oa(l[h+8>>2]),Tt=h+16|0,r|0}function GT(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 VT(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?a2(5816,u,y)|0:a2(5672,u,y)|0}function zp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}gt[r|0]=a,r=1}return r}function HT(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 Yp(r,a){var h=0,u=0;h=ut(4),l[h>>2]=a,u=ut(4),l[u>>2]=a,Jo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Vn(r,a){var h=0,u=0;h=ut(4),l[h>>2]=a,u=ut(4),l[u>>2]=a,Jo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Oh(r,a){var h=0;t:{if(gt[7044]&1){h=l[1760];break t}h=up(1,4464)|0,gt[7044]=1,l[1760]=h}_E(h|0,r|0,a|0,0)}function WT(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 jT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=mp((gt[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function KT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=mp((gt[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Xp(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 zT(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=gt[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function YT(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),Bp(l[r>>2],14)}function XT(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 ZT(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function qT(r){r=r|0;var a=0;return a=ut(12),gt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function QT(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function JT(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),Bp(l[r>>2],0)}function Zp(r){return r=r|0,l[r>>2]=4572,Et[r+4|0]&&Oh(l[r+8>>2],1759),Oa(l[r+8>>2]),r|0}function qp(r){return r=r|0,l[r>>2]=4452,Et[r+4|0]&&Oh(l[r+8>>2],1759),Oa(l[r+8>>2]),r|0}function t3(){var r=0;return r=ut(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function Qp(r,a,h){return ar(r,a)?Os(r,a,h):(h=Ma(r,a,h),h==h&&(h=m(-h)),h)}function Jp(r,a){var h=0;h=Tt-16|0,Tt=h,r||(l[h>>2]=a,nr(0,h),Qi(),le()),Tt=h+16|0}function t2(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&bi(a),l[1752]=l[1752]-1,bi(r))}function e3(r,a){return r=r|0,a=a|0,a>>>0>=3&&(xs(),le()),l[l[r>>2]+12>>2]>>>a&1}function i3(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 r3(){var r=0;return r=ut(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function s3(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(Yt):a)}function n3(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function a3(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function e2(r){var a=0;return a=Ap(ut(588),r),Jp((r|0)!=0,2808),a}function o3(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function l3(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function c3(r,a){r=r|0,a=a|0,r=l[r>>2],gt[r+8|0]=Et[r+8|0]&254|a}function h3(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function d3(r,a,h){r=r|0,a=a|0,h=+h,Dh(l[r>>2],a,yr(m(h)))}function u3(r,a,h){r=r|0,a=a|0,h=+h,Dh(l[r>>2],a,Hr(m(h)))}function f3(r,a,h,u){return Bi=0,0}function p3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,yr(m(h)))}function g3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,Hr(m(h)))}function m3(r,a,h){r=r|0,a=a|0,h=+h,Up(l[r>>2],a,yr(m(h)))}function v3(r,a,h){r=r|0,a=a|0,h=+h,Up(l[r>>2],a,Hr(m(h)))}function y3(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function b3(r,a){r=r|0,a=a|0,Dh(l[r>>2],a,2141891242)}function Mh(r,a,h){r=r|0,a=a|0,h=+h,Ve[l[r>>2]+a>>3]=h}function A3(r){return r=r|0,(Et[l[r>>2]+4|0]&2)>>>1|0}function E3(r){return r=r|0,(Et[l[r>>2]+4|0]&4)>>>2|0}function T3(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function k3(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function w3(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function S3(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function $h(r,a){return r=r|0,a=a|0,+Ve[l[r>>2]+a>>3]}function R3(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function _3(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function L3(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function C3(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function I3(r,a){r=r|0,a=+a,Bn(l[r>>2],0,yr(m(a)))}function D3(r,a){r=r|0,a=+a,Bn(l[r>>2],0,Hr(m(a)))}function x3(r,a){r=r|0,a=+a,Bn(l[r>>2],1,yr(m(a)))}function P3(r,a){r=r|0,a=+a,Bn(l[r>>2],1,Hr(m(a)))}function O3(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function M3(r,a){r=r|0,a=+a,il(l[r>>2],0,yr(m(a)))}function $3(r,a){r=r|0,a=+a,il(l[r>>2],0,Hr(m(a)))}function F3(r,a){r=r|0,a=+a,il(l[r>>2],1,yr(m(a)))}function N3(r,a){r=r|0,a=+a,il(l[r>>2],1,Hr(m(a)))}function U3(r,a){r=r|0,a=+a,rl(l[r>>2],0,yr(m(a)))}function B3(r,a){r=r|0,a=+a,rl(l[r>>2],1,yr(m(a)))}function G3(r,a){r=r|0,a=+a,rl(l[r>>2],1,Hr(m(a)))}function V3(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function H3(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function W3(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function nl(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function j3(r,a){r=r|0,a=+a,rl(l[r>>2],0,Hr(m(a)))}function i2(r){return r?(l[1781]=r,-1):0}function K3(r,a){r=r|0,a=+a,Ih(l[r>>2],yr(m(a)))}function z3(r,a){r=r|0,a=+a,Ih(l[r>>2],Hr(m(a)))}function r2(r,a,h){return m(ce(r,a,h)+we(r,a,h))}function Y3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function s2(r,a,h,u){CE(r|0,a|0,8,0,h|0,-1,u|0)}function X3(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function Z3(r){return r=r|0,l[l[r>>2]+16>>2]&1}function q3(r){return r=r|0,$n[l[r>>2]+26>>1]&3}function Q3(r){r=r|0,Bn(l[r>>2],0,2141891242)}function J3(r){r=r|0,Bn(l[r>>2],1,2141891242)}function tk(r){return r=r|0,+I[l[r>>2]+228>>2]}function ek(r){return r=r|0,+I[l[r>>2]+236>>2]}function ik(r){return r=r|0,+I[l[r>>2]+232>>2]}function rk(r){return r=r|0,+I[l[r>>2]+240>>2]}function sk(r){return r=r|0,+I[l[r>>2]+244>>2]}function nk(r){return r=r|0,+I[l[r>>2]+248>>2]}function ak(r){return r=r|0,PE(l[r+60>>2])|0}function ok(r){return r=r|0,l[l[r>>2]+16>>2]}function lk(r){return r=r|0,gt[l[r>>2]+8|0]&1}function ck(r,a){r=r|0,a=a|0,Ch(l[r>>2],5,a)}function hk(r,a){r=r|0,a=a|0,Ch(l[r>>2],6,a)}function dk(r,a){r=r|0,a=a|0,Ch(l[r>>2],7,a)}function uk(r){r=r|0,Ih(l[r>>2],2141891242)}function n2(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function fk(r){return r=r|0,Mp(ut(12),r)|0}function pk(r){r=r|0,Oh(l[r+8>>2],3293)}function a2(r,a,h){return Ip(r,a,h,2,3)}function o2(r){return r=r|0,Pt[r|0]()|0}function l2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function gk(){return Vi(ut(48),0,48)|0}function Qi(){Pt[l[1490]](),Nh(),le()}function mk(){return Mp(ut(12),0)|0}function Fh(r){r=r|0,r&&bi(r)}function al(r){return r-48>>>0<10}function vk(r){return 7032}function yk(r){return 7036}function bk(r){return 7056}function Ak(r){return 7059}function Ek(r){return 7062}function Tk(r){return 7067}function Rr(r){return r=r|0,r|0}function c2(r){r=r|0,gt[r+4|0]=1}function kk(r){r=r|0,bi(Zp(r))}function wk(r){r=r|0,bi(qp(r))}function Sk(r){return 0}function h2(r){le()}function d2(){Nh(),le()}function Nh(){xs(),le()}H=Et,Rt();var Pt=G([null,VT,FE,BE,Rr,O3,T3,k3,Rr,Rr,Rr,Rr,Rr,Rr,CT,h3,yp,vk,nl,hT,yk,Rr,Rr,nl,c2,n2,Kp,ZT,YE,jT,bk,nl,Xp,Ak,Rr,Rr,nl,c2,n2,Kp,qT,KT,Ek,t2,o2,IT,l2,t2,MT,Wp,KE,BT,o3,Ms,X3,Ms,c3,e3,jp,Z3,pn,ok,pn,lk,gk,Fh,t3,Fh,r3,Fh,$h,Mh,C3,y3,Tk,Rp,o2,mk,Y3,fk,l2,Rp,HE,Xp,UE,Ms,vT,Ms,m3,NT,v3,ck,hk,dk,kT,mT,TT,d3,u3,b3,pT,gT,bT,GT,K3,z3,uk,AT,ET,I3,D3,Q3,x3,P3,J3,M3,$3,F3,N3,U3,j3,B3,G3,yT,dT,p3,g3,uT,q3,pn,qE,ST,V3,w3,S3,H3,R3,W3,QE,lT,_T,a3,HT,zT,tT,eT,iT,rT,sT,JE,s3,fT,UT,_3,L3,ZE,cT,FT,GE,Wp,VE,Ms,l3,pn,n3,pn,OT,jp,A3,pn,wT,Ms,YT,Ms,JT,WT,Ms,XT,RT,E3,pn,NE,$T,tk,ek,ik,rk,sk,nk,DT,xT,nT,aT,oT,$h,Mh,$h,Mh,_p,qp,wk,zE,h2,d2,Zp,kk,pk,h2,ak,WE,PT,Sk,f3,XE,d2]);function u2(){return Ui.byteLength/65536|0}function Rk(r){r=r|0;var a=u2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(He(h,65536)),y=new Int8Array(u);y.set(gt),gt=new Int8Array(u),Ur=new Int16Array(u),l=new Int32Array(u),Et=new Uint8Array(u),$n=new Uint16Array(u),hp=new Uint32Array(u),I=new Float32Array(u),Ve=new Float64Array(u),Ui=u,sr.buffer=Ui,H=Et}return a}return{E:LT,F:jE,G:QT,H:Sh,I:Pt,J:bi,K:i3}}return Qo(L)}(_)}var C=Error,x={};A=[],typeof x!="object"&&Lt("no native wasm support detected");var O,B=!1;function D(_,L,G){G=L+G;for(var H="";!(L>=G);){var rt=_[L++];if(!rt)break;if(rt&128){var yt=_[L++]&63;if((rt&224)==192)H+=String.fromCharCode((rt&31)<<6|yt);else{var ct=_[L++]&63;rt=(rt&240)==224?(rt&15)<<12|yt<<6|ct:(rt&7)<<18|yt<<12|ct<<6|_[L++]&63,65536>rt?H+=String.fromCharCode(rt):(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023))}}else H+=String.fromCharCode(rt)}return H}var V,$,z,it,at,J,wt,vt,Ot;function Gt(_){V=_,o.HEAP8=$=new Int8Array(_),o.HEAP16=it=new Int16Array(_),o.HEAP32=J=new Int32Array(_),o.HEAPU8=z=new Uint8Array(_),o.HEAPU16=at=new Uint16Array(_),o.HEAPU32=wt=new Uint32Array(_),o.HEAPF32=vt=new Float32Array(_),o.HEAPF64=Ot=new Float64Array(_)}var U=o.INITIAL_MEMORY||16777216;o.wasmMemory?O=o.wasmMemory:O=new E,O&&(V=O.buffer),U=V.byteLength,Gt(V);var q,At=[],F=[],N=[];function j(){var _=o.preRun.shift();At.unshift(_)}var nt=0,ht=null;function Lt(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),B=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Nt(_){return _.startsWith("data:application/octet-stream;base64,")}var jt;if(jt="<<< WASM_BINARY_FILE >>>",!Nt(jt)){var ue=jt;jt=o.locateFile?o.locateFile(ue,p):p+ue}function me(_){var L=jt;try{try{if(L==jt&&A)new Uint8Array(A);else{if(Nt(L)){try{var G=bE(L.slice(37)),H=new Uint8Array(G.length);for(L=0;L<G.length;++L)H[L]=G.charCodeAt(L);var rt=H}catch{throw Error("Converting base64 string to bytes failed.")}var yt=rt}else yt=void 0;if(!yt)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(Ct){Lt(Ct)}var ct=new T,Rt=new w(_)}catch(Ct){throw _=Ct.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)."),Ct}return[Rt,ct]}function ge(_){for(;0<_.length;)_.shift()(o)}function je(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function Re(_,L){return _=je(_),function(){return L.apply(this,arguments)}}var Kt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],be=[];function he(_){var L=Error,G=Re(_,function(H){this.name=_,this.message=H,H=Error(H).stack,H!==void 0&&(this.stack=this.toString()+`
|
90
|
+
`+H.replace(/^Error(:[^\n]*)?\n/,""))});return G.prototype=Object.create(L.prototype),G.prototype.constructor=G,G.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},G}var Oe=void 0;function Ut(_){throw new Oe(_)}var Ke=_=>(_||Ut("Cannot use deleted val. handle = "+_),Kt[_].value),Fe=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=be.length?be.pop():Kt.length;return Kt[L]={fa:1,value:_},L}},Ge=void 0,ke=void 0;function de(_){for(var L="";z[_];)L+=ke[z[_++]];return L}var ze=[];function oe(){for(;ze.length;){var _=ze.pop();_.L.Z=!1,_.delete()}}var Ne=void 0,Ue={};function ui(_,L){for(L===void 0&&Ut("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Le={};function vi(_){_=EE(_);var L=de(_);return Ds(_),L}function kr(_,L){var G=Le[_];return G===void 0&&Ut(L+" has unknown type "+vi(_)),G}function ni(){}var wr=!1;function _s(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function Ls(_,L,G){return L===G?_:G.P===void 0?null:(_=Ls(_,L,G.P),_===null?null:G.ma(_))}var rr={};function dt(_,L){return L=ui(_,L),Ue[L]}var Vt=void 0;function Xt(_){throw new Vt(_)}function ve(_,L){return L.O&&L.N||Xt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Xt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},se(Object.create(_,{L:{value:L}}))}function se(_){return typeof FinalizationRegistry>"u"?(se=L=>L,_):(wr=new FinalizationRegistry(L=>{_s(L.L)}),se=L=>{var G=L.L;return G.S&&wr.register(L,{L:G},L),L},ni=L=>{wr.unregister(L)},se(_))}var ci={};function Pi(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function fr(_){return this.fromWireType(J[_>>2])}var ns={},pr={};function gr(_,L,G){function H(Rt){Rt=G(Rt),Rt.length!==_.length&&Xt("Mismatched type converter count");for(var Ct=0;Ct<_.length;++Ct)Oi(_[Ct],Rt[Ct])}_.forEach(function(Rt){pr[Rt]=L});var rt=Array(L.length),yt=[],ct=0;L.forEach((Rt,Ct)=>{Le.hasOwnProperty(Rt)?rt[Ct]=Le[Rt]:(yt.push(Rt),ns.hasOwnProperty(Rt)||(ns[Rt]=[]),ns[Rt].push(()=>{rt[Ct]=Le[Rt],++ct,ct===yt.length&&H(rt)}))}),yt.length===0&&H(rt)}function Cs(_){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 Oi(_,L,G={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var H=L.name;if(_||Ut('type "'+H+'" must have a positive integer typeid pointer'),Le.hasOwnProperty(_)){if(G.ta)return;Ut("Cannot register type '"+H+"' twice")}Le[_]=L,delete pr[_],ns.hasOwnProperty(_)&&(L=ns[_],delete ns[_],L.forEach(rt=>rt()))}function Pa(_){Ut(_.L.O.M.name+" instance already deleted")}function mr(){}function Is(_,L,G){if(_[L].R===void 0){var H=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Ut("Function '"+G+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[H.Y]=H}}function tE(_,L){o.hasOwnProperty(_)?(Ut("Cannot register public name '"+_+"' twice"),Is(o,_,_),o.hasOwnProperty(void 0)&&Ut("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function eE(_,L,G,H,rt,yt,ct,Rt){this.name=_,this.constructor=L,this.W=G,this.V=H,this.P=rt,this.oa=yt,this.aa=ct,this.ma=Rt,this.ia=[]}function vh(_,L,G){for(;L!==G;)L.aa||Ut("Expected null or instance of "+G.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function iE(_,L){return L===null?(this.da&&Ut("null is not a valid "+this.name),0):(L.L||Ut('Cannot pass "'+Eh(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),vh(L.L.N,L.L.O.M,this.M))}function rE(_,L){if(L===null){if(this.da&&Ut("null is not a valid "+this.name),this.ca){var G=this.ea();return _!==null&&_.push(this.V,G),G}return 0}if(L.L||Ut('Cannot pass "'+Eh(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Ut("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),G=vh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Ut("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?G=L.L.S:Ut("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:G=L.L.S;break;case 2:if(L.L.T===this)G=L.L.S;else{var H=L.clone();G=this.wa(G,Fe(function(){H.delete()})),_!==null&&_.push(this.V,G)}break;default:Ut("Unsupporting sharing policy")}return G}function sE(_,L){return L===null?(this.da&&Ut("null is not a valid "+this.name),0):(L.L||Ut('Cannot pass "'+Eh(L)+'" as a '+this.name),L.L.N||Ut("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Ut("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),vh(L.L.N,L.L.O.M,this.M))}function as(_,L,G,H){this.name=_,this.M=L,this.da=G,this.ba=H,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=rE:(this.toWireType=H?iE:sE,this.U=null)}function nE(_,L){o.hasOwnProperty(_)||Xt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function aE(_,L){var G=[];return function(){if(G.length=0,Object.assign(G,arguments),_.includes("j")){var H=o["dynCall_"+_];H=G&&G.length?H.apply(null,[L].concat(G)):H.call(null,L)}else H=q.get(L).apply(null,G);return H}}function Sr(_,L){_=de(_);var G=_.includes("j")?aE(_,L):q.get(L);return typeof G!="function"&&Ut("unknown function pointer with signature "+_+": "+L),G}var sp=void 0;function Yo(_,L){function G(yt){rt[yt]||Le[yt]||(pr[yt]?pr[yt].forEach(G):(H.push(yt),rt[yt]=!0))}var H=[],rt={};throw L.forEach(G),new sp(_+": "+H.map(vi).join([", "]))}function yh(_,L,G,H,rt){var yt=L.length;2>yt&&Ut("argTypes array size mismatch! Must at least get return value and 'this' types!");var ct=L[1]!==null&&G!==null,Rt=!1;for(G=1;G<L.length;++G)if(L[G]!==null&&L[G].U===void 0){Rt=!0;break}var Ct=L[0].name!=="void",It=yt-2,Ft=Array(It),zt=[],Jt=[];return function(){if(arguments.length!==It&&Ut("function "+_+" called with "+arguments.length+" arguments, expected "+It+" args!"),Jt.length=0,zt.length=ct?2:1,zt[0]=rt,ct){var xt=L[1].toWireType(Jt,this);zt[1]=xt}for(var Ae=0;Ae<It;++Ae)Ft[Ae]=L[Ae+2].toWireType(Jt,arguments[Ae]),zt.push(Ft[Ae]);if(Ae=H.apply(null,zt),Rt)Pi(Jt);else for(var yi=ct?1:2;yi<L.length;yi++){var le=yi===1?xt:Ft[yi-2];L[yi].U!==null&&L[yi].U(le)}return xt=Ct?L[0].fromWireType(Ae):void 0,xt}}function bh(_,L){for(var G=[],H=0;H<_;H++)G.push(wt[L+4*H>>2]);return G}function Ah(_){4<_&&--Kt[_].fa===0&&(Kt[_]=void 0,be.push(_))}function Eh(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function oE(_,L){switch(L){case 2:return function(G){return this.fromWireType(vt[G>>2])};case 3:return function(G){return this.fromWireType(Ot[G>>3])};default:throw new TypeError("Unknown float type: "+_)}}function lE(_,L,G){switch(L){case 0:return G?function(H){return $[H]}:function(H){return z[H]};case 1:return G?function(H){return it[H>>1]}:function(H){return at[H>>1]};case 2:return G?function(H){return J[H>>2]}:function(H){return wt[H>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function cE(_,L){for(var G="",H=0;!(H>=L/2);++H){var rt=it[_+2*H>>1];if(rt==0)break;G+=String.fromCharCode(rt)}return G}function hE(_,L,G){if(G===void 0&&(G=2147483647),2>G)return 0;G-=2;var H=L;G=G<2*_.length?G/2:_.length;for(var rt=0;rt<G;++rt)it[L>>1]=_.charCodeAt(rt),L+=2;return it[L>>1]=0,L-H}function dE(_){return 2*_.length}function uE(_,L){for(var G=0,H="";!(G>=L/4);){var rt=J[_+4*G>>2];if(rt==0)break;++G,65536<=rt?(rt-=65536,H+=String.fromCharCode(55296|rt>>10,56320|rt&1023)):H+=String.fromCharCode(rt)}return H}function fE(_,L,G){if(G===void 0&&(G=2147483647),4>G)return 0;var H=L;G=H+G-4;for(var rt=0;rt<_.length;++rt){var yt=_.charCodeAt(rt);if(55296<=yt&&57343>=yt){var ct=_.charCodeAt(++rt);yt=65536+((yt&1023)<<10)|ct&1023}if(J[L>>2]=yt,L+=4,L+4>G)break}return J[L>>2]=0,L-H}function pE(_){for(var L=0,G=0;G<_.length;++G){var H=_.charCodeAt(G);55296<=H&&57343>=H&&++G,L+=4}return L}var gE={};function np(_){var L=gE[_];return L===void 0?de(_):L}var Xo=[];function mE(_){var L=Xo.length;return Xo.push(_),L}function vE(_,L){for(var G=Array(_),H=0;H<_;++H)G[H]=kr(wt[L+4*H>>2],"parameter "+H);return G}var ap=[],yE=[null,[],[]];Oe=o.BindingError=he("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<Kt.length;++L)Kt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<Kt.length;++_)if(Kt[_]!==void 0)return Kt[_];return null},Ge=o.PureVirtualError=he("PureVirtualError");for(var op=Array(256),Zo=0;256>Zo;++Zo)op[Zo]=String.fromCharCode(Zo);ke=op,o.getInheritedInstanceCount=function(){return Object.keys(Ue).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in Ue)Ue.hasOwnProperty(L)&&_.push(Ue[L]);return _},o.flushPendingDeletes=oe,o.setDelayFunction=function(_){Ne=_,ze.length&&Ne&&Ne(oe)},Vt=o.InternalError=he("InternalError"),mr.prototype.isAliasOf=function(_){if(!(this instanceof mr&&_ instanceof mr))return!1;var L=this.L.O.M,G=this.L.N,H=_.L.O.M;for(_=_.L.N;L.P;)G=L.aa(G),L=L.P;for(;H.P;)_=H.aa(_),H=H.P;return L===H&&G===_},mr.prototype.clone=function(){if(this.L.N||Pa(this),this.L.$)return this.L.count.value+=1,this;var _=se,L=Object,G=L.create,H=Object.getPrototypeOf(this),rt=this.L;return _=_(G.call(L,H,{L:{value:{count:rt.count,Z:rt.Z,$:rt.$,N:rt.N,O:rt.O,S:rt.S,T:rt.T}}})),_.L.count.value+=1,_.L.Z=!1,_},mr.prototype.delete=function(){this.L.N||Pa(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ni(this),_s(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},mr.prototype.isDeleted=function(){return!this.L.N},mr.prototype.deleteLater=function(){return this.L.N||Pa(this),this.L.Z&&!this.L.$&&Ut("Object already scheduled for deletion"),ze.push(this),ze.length===1&&Ne&&Ne(oe),this.L.Z=!0,this},as.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},as.prototype.ga=function(_){this.V&&this.V(_)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=fr,as.prototype.deleteObject=function(_){_!==null&&_.delete()},as.prototype.fromWireType=function(_){function L(){return this.ca?ve(this.M.W,{O:this.va,N:G,T:this,S:_}):ve(this.M.W,{O:this,N:_})}var G=this.pa(_);if(!G)return this.ga(_),null;var H=dt(this.M,G);if(H!==void 0)return H.L.count.value===0?(H.L.N=G,H.L.S=_,H.clone()):(H=H.clone(),this.ga(_),H);if(H=this.M.oa(G),H=rr[H],!H)return L.call(this);H=this.ba?H.ka:H.pointerType;var rt=Ls(G,this.M,H.M);return rt===null?L.call(this):this.ca?ve(H.M.W,{O:H,N:rt,T:this,S:_}):ve(H.M.W,{O:H,N:rt})},sp=o.UnboundTypeError=he("UnboundTypeError");var bE=typeof atob=="function"?atob:function(_){var L="",G=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var H="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(G++)),rt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(G++)),yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(G++)),ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(G++));H=H<<2|rt>>4,rt=(rt&15)<<4|yt>>2;var Rt=(yt&3)<<6|ct;L+=String.fromCharCode(H),yt!==64&&(L+=String.fromCharCode(rt)),ct!==64&&(L+=String.fromCharCode(Rt))}while(G<_.length);return L},AE={q:function(_,L,G){_=de(_),L=kr(L,"wrapper"),G=Ke(G);var H=[].slice,rt=L.M,yt=rt.W,ct=rt.P.W,Rt=rt.P.constructor;_=Re(_,function(){rt.P.ia.forEach((function(It){if(this[It]===ct[It])throw new Ge("Pure virtual function "+It+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:yt}),this.__construct.apply(this,H.call(arguments))}),yt.__construct=function(){this===yt&&Ut("Pass correct 'this' to __construct");var It=Rt.implement.apply(void 0,[this].concat(H.call(arguments)));ni(It);var Ft=It.L;It.notifyOnDestruction(),Ft.$=!0,Object.defineProperties(this,{L:{value:Ft}}),se(this),It=Ft.N,It=ui(rt,It),Ue.hasOwnProperty(It)?Ut("Tried to register registered instance: "+It):Ue[It]=this},yt.__destruct=function(){this===yt&&Ut("Pass correct 'this' to __destruct"),ni(this);var It=this.L.N;It=ui(rt,It),Ue.hasOwnProperty(It)?delete Ue[It]:Ut("Tried to unregister unregistered instance: "+It)},_.prototype=Object.create(yt);for(var Ct in G)_.prototype[Ct]=G[Ct];return Fe(_)},k:function(_){var L=ci[_];delete ci[_];var G=L.ea,H=L.V,rt=L.ha,yt=rt.map(ct=>ct.sa).concat(rt.map(ct=>ct.ya));gr([_],yt,ct=>{var Rt={};return rt.forEach((Ct,It)=>{var Ft=ct[It],zt=Ct.qa,Jt=Ct.ra,xt=ct[It+rt.length],Ae=Ct.xa,yi=Ct.za;Rt[Ct.na]={read:le=>Ft.fromWireType(zt(Jt,le)),write:(le,qi)=>{var Bt=[];Ae(yi,le,xt.toWireType(Bt,qi)),Pi(Bt)}}}),[{name:L.name,fromWireType:function(Ct){var It={},Ft;for(Ft in Rt)It[Ft]=Rt[Ft].read(Ct);return H(Ct),It},toWireType:function(Ct,It){for(var Ft in Rt)if(!(Ft in It))throw new TypeError('Missing field: "'+Ft+'"');var zt=G();for(Ft in Rt)Rt[Ft].write(zt,It[Ft]);return Ct!==null&&Ct.push(H,zt),zt},argPackAdvance:8,readValueFromPointer:fr,U:H}]})},w:function(){},C:function(_,L,G,H,rt){var yt=Cs(G);L=de(L),Oi(_,{name:L,fromWireType:function(ct){return!!ct},toWireType:function(ct,Rt){return Rt?H:rt},argPackAdvance:8,readValueFromPointer:function(ct){if(G===1)var Rt=$;else if(G===2)Rt=it;else if(G===4)Rt=J;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(Rt[ct>>yt])},U:null})},g:function(_,L,G,H,rt,yt,ct,Rt,Ct,It,Ft,zt,Jt){Ft=de(Ft),yt=Sr(rt,yt),Rt&&(Rt=Sr(ct,Rt)),It&&(It=Sr(Ct,It)),Jt=Sr(zt,Jt);var xt=je(Ft);tE(xt,function(){Yo("Cannot construct "+Ft+" due to unbound types",[H])}),gr([_,L,G],H?[H]:[],function(Ae){if(Ae=Ae[0],H)var yi=Ae.M,le=yi.W;else le=mr.prototype;Ae=Re(xt,function(){if(Object.getPrototypeOf(this)!==qi)throw new Oe("Use 'new' to construct "+Ft);if(Bt.X===void 0)throw new Oe(Ft+" has no accessible constructor");var ai=Bt.X[arguments.length];if(ai===void 0)throw new Oe("Tried to invoke ctor of "+Ft+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ai.apply(this,arguments)});var qi=Object.create(le,{constructor:{value:Ae}});Ae.prototype=qi;var Bt=new eE(Ft,Ae,qi,Jt,yi,yt,Rt,It);yi=new as(Ft,Bt,!0,!1),le=new as(Ft+"*",Bt,!1,!1);var Qo=new as(Ft+" const*",Bt,!1,!0);return rr[_]={pointerType:le,ka:Qo},nE(xt,Ae),[yi,le,Qo]})},d:function(_,L,G,H,rt,yt,ct){var Rt=bh(G,H);L=de(L),yt=Sr(rt,yt),gr([],[_],function(Ct){function It(){Yo("Cannot call "+Ft+" due to unbound types",Rt)}Ct=Ct[0];var Ft=Ct.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var zt=Ct.M.constructor;return zt[L]===void 0?(It.Y=G-1,zt[L]=It):(Is(zt,L,Ft),zt[L].R[G-1]=It),gr([],Rt,function(Jt){return Jt=yh(Ft,[Jt[0],null].concat(Jt.slice(1)),null,yt,ct),zt[L].R===void 0?(Jt.Y=G-1,zt[L]=Jt):zt[L].R[G-1]=Jt,[]}),[]})},p:function(_,L,G,H,rt,yt){0<L||Lt();var ct=bh(L,G);rt=Sr(H,rt),gr([],[_],function(Rt){Rt=Rt[0];var Ct="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[L-1]!==void 0)throw new Oe("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[L-1]=()=>{Yo("Cannot construct "+Rt.name+" due to unbound types",ct)},gr([],ct,function(It){return It.splice(1,0,null),Rt.M.X[L-1]=yh(Ct,It,null,rt,yt),[]}),[]})},b:function(_,L,G,H,rt,yt,ct,Rt){var Ct=bh(G,H);L=de(L),yt=Sr(rt,yt),gr([],[_],function(It){function Ft(){Yo("Cannot call "+zt+" due to unbound types",Ct)}It=It[0];var zt=It.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),Rt&&It.M.ia.push(L);var Jt=It.M.W,xt=Jt[L];return xt===void 0||xt.R===void 0&&xt.className!==It.name&&xt.Y===G-2?(Ft.Y=G-2,Ft.className=It.name,Jt[L]=Ft):(Is(Jt,L,zt),Jt[L].R[G-2]=Ft),gr([],Ct,function(Ae){return Ae=yh(zt,Ae,It,yt,ct),Jt[L].R===void 0?(Ae.Y=G-2,Jt[L]=Ae):Jt[L].R[G-2]=Ae,[]}),[]})},B:function(_,L){L=de(L),Oi(_,{name:L,fromWireType:function(G){var H=Ke(G);return Ah(G),H},toWireType:function(G,H){return Fe(H)},argPackAdvance:8,readValueFromPointer:fr,U:null})},n:function(_,L,G){G=Cs(G),L=de(L),Oi(_,{name:L,fromWireType:function(H){return H},toWireType:function(H,rt){return rt},argPackAdvance:8,readValueFromPointer:oE(L,G),U:null})},e:function(_,L,G,H,rt){L=de(L),rt===-1&&(rt=4294967295),rt=Cs(G);var yt=Rt=>Rt;if(H===0){var ct=32-8*G;yt=Rt=>Rt<<ct>>>ct}G=L.includes("unsigned")?function(Rt,Ct){return Ct>>>0}:function(Rt,Ct){return Ct},Oi(_,{name:L,fromWireType:yt,toWireType:G,argPackAdvance:8,readValueFromPointer:lE(L,rt,H!==0),U:null})},c:function(_,L,G){function H(yt){yt>>=2;var ct=wt;return new rt(V,ct[yt+1],ct[yt])}var rt=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];G=de(G),Oi(_,{name:G,fromWireType:H,argPackAdvance:8,readValueFromPointer:H},{ta:!0})},o:function(_,L){L=de(L);var G=L==="std::string";Oi(_,{name:L,fromWireType:function(H){var rt=wt[H>>2],yt=H+4;if(G)for(var ct=yt,Rt=0;Rt<=rt;++Rt){var Ct=yt+Rt;if(Rt==rt||z[Ct]==0){if(ct=ct?D(z,ct,Ct-ct):"",It===void 0)var It=ct;else It+=String.fromCharCode(0),It+=ct;ct=Ct+1}}else{for(It=Array(rt),Rt=0;Rt<rt;++Rt)It[Rt]=String.fromCharCode(z[yt+Rt]);It=It.join("")}return Ds(H),It},toWireType:function(H,rt){rt instanceof ArrayBuffer&&(rt=new Uint8Array(rt));var yt,ct=typeof rt=="string";if(ct||rt instanceof Uint8Array||rt instanceof Uint8ClampedArray||rt instanceof Int8Array||Ut("Cannot pass non-string to std::string"),G&&ct){var Rt=0;for(yt=0;yt<rt.length;++yt){var Ct=rt.charCodeAt(yt);127>=Ct?Rt++:2047>=Ct?Rt+=2:55296<=Ct&&57343>=Ct?(Rt+=4,++yt):Rt+=3}yt=Rt}else yt=rt.length;if(Rt=lp(4+yt+1),Ct=Rt+4,wt[Rt>>2]=yt,G&&ct){if(ct=Ct,Ct=yt+1,yt=z,0<Ct){Ct=ct+Ct-1;for(var It=0;It<rt.length;++It){var Ft=rt.charCodeAt(It);if(55296<=Ft&&57343>=Ft){var zt=rt.charCodeAt(++It);Ft=65536+((Ft&1023)<<10)|zt&1023}if(127>=Ft){if(ct>=Ct)break;yt[ct++]=Ft}else{if(2047>=Ft){if(ct+1>=Ct)break;yt[ct++]=192|Ft>>6}else{if(65535>=Ft){if(ct+2>=Ct)break;yt[ct++]=224|Ft>>12}else{if(ct+3>=Ct)break;yt[ct++]=240|Ft>>18,yt[ct++]=128|Ft>>12&63}yt[ct++]=128|Ft>>6&63}yt[ct++]=128|Ft&63}}yt[ct]=0}}else if(ct)for(ct=0;ct<yt;++ct)It=rt.charCodeAt(ct),255<It&&(Ds(Ct),Ut("String has UTF-16 code units that do not fit in 8 bits")),z[Ct+ct]=It;else for(ct=0;ct<yt;++ct)z[Ct+ct]=rt[ct];return H!==null&&H.push(Ds,Rt),Rt},argPackAdvance:8,readValueFromPointer:fr,U:function(H){Ds(H)}})},j:function(_,L,G){if(G=de(G),L===2)var H=cE,rt=hE,yt=dE,ct=()=>at,Rt=1;else L===4&&(H=uE,rt=fE,yt=pE,ct=()=>wt,Rt=2);Oi(_,{name:G,fromWireType:function(Ct){for(var It=wt[Ct>>2],Ft=ct(),zt,Jt=Ct+4,xt=0;xt<=It;++xt){var Ae=Ct+4+xt*L;(xt==It||Ft[Ae>>Rt]==0)&&(Jt=H(Jt,Ae-Jt),zt===void 0?zt=Jt:(zt+=String.fromCharCode(0),zt+=Jt),Jt=Ae+L)}return Ds(Ct),zt},toWireType:function(Ct,It){typeof It!="string"&&Ut("Cannot pass non-string to C++ string type "+G);var Ft=yt(It),zt=lp(4+Ft+L);return wt[zt>>2]=Ft>>Rt,rt(It,zt+4,Ft+L),Ct!==null&&Ct.push(Ds,zt),zt},argPackAdvance:8,readValueFromPointer:fr,U:function(Ct){Ds(Ct)}})},l:function(_,L,G,H,rt,yt){ci[_]={name:de(L),ea:Sr(G,H),V:Sr(rt,yt),ha:[]}},i:function(_,L,G,H,rt,yt,ct,Rt,Ct,It){ci[_].ha.push({na:de(L),sa:G,qa:Sr(H,rt),ra:yt,ya:ct,xa:Sr(Rt,Ct),za:It})},D:function(_,L){L=de(L),Oi(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,G,H,rt){_=Xo[_],L=Ke(L),G=np(G);var yt=[];return wt[H>>2]=Fe(yt),_(L,G,yt,rt)},u:function(_,L,G,H){_=Xo[_],L=Ke(L),G=np(G),_(L,G,null,H)},h:Ah,m:function(_,L){var G=vE(_,L),H=G[0];L=H.name+"_$"+G.slice(1).map(function(ct){return ct.name}).join("_")+"$";var rt=ap[L];if(rt!==void 0)return rt;var yt=Array(_-1);return rt=mE((ct,Rt,Ct,It)=>{for(var Ft=0,zt=0;zt<_-1;++zt)yt[zt]=G[zt+1].readValueFromPointer(It+Ft),Ft+=G[zt+1].argPackAdvance;for(ct=ct[Rt].apply(ct,yt),zt=0;zt<_-1;++zt)G[zt+1].la&&G[zt+1].la(yt[zt]);if(!H.ua)return H.toWireType(Ct,ct)}),ap[L]=rt},r:function(_){4<_&&(Kt[_].fa+=1)},s:function(_){var L=Ke(_);Pi(L),Ah(_)},f:function(){Lt("")},y:function(_,L,G){z.copyWithin(_,L,L+G)},x:function(_){var L=z.length;if(_>>>=0,2147483648<_)return!1;for(var G=1;4>=G;G*=2){var H=L*(1+.2/G);H=Math.min(H,_+100663296);var rt=Math;H=Math.max(_,H),rt=rt.min.call(rt,2147483648,H+(65536-H%65536)%65536);t:{try{O.grow(rt-V.byteLength+65535>>>16),Gt(O.buffer);var yt=1;break t}catch{}yt=void 0}if(yt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,G,H){for(var rt=0,yt=0;yt<G;yt++){var ct=wt[L>>2],Rt=wt[L+4>>2];L+=8;for(var Ct=0;Ct<Rt;Ct++){var It=z[ct+Ct],Ft=yE[_];It===0||It===10?((_===1?g:v)(D(Ft,0)),Ft.length=0):Ft.push(It)}rt+=Rt}return wt[H>>2]=rt,0},a:O},Mn=function(){function _(G){o.asm=G.exports,q=o.asm.I,F.unshift(o.asm.E),nt--,o.monitorRunDependencies&&o.monitorRunDependencies(nt),nt==0&&ht&&(G=ht,ht=null,G())}var L={a:AE};if(nt++,o.monitorRunDependencies&&o.monitorRunDependencies(nt),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(G){v("Module.instantiateWasm callback failed with error: "+G),d(G)}return L=me(L),_(L[0]),o.asm}();o.___wasm_call_ctors=Mn.E;var EE=o.___getTypeName=Mn.F;o.__embind_initialize_bindings=Mn.G;var lp=o._malloc=Mn.H,Ds=o._free=Mn.J;o.dynCall_jiji=Mn.K;var qo;ht=function _(){qo||cp(),qo||(ht=_)};function cp(){function _(){if(!qo&&(qo=!0,o.calledRun=!0,!B)){if(ge(F),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();N.unshift(L)}ge(N)}}if(!(0<nt)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)j();ge(At),0<nt||(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 cp(),n}})();s.exports=e})(Kd);var dm=Kd.exports;(function(s){Object.defineProperty(s,"__esModule",{value:!0});var t={};s.default=void 0;var e=n($l),i=ie;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in s&&s[d]===i[d]||Object.defineProperty(s,d,{enumerable:!0,get:function(){return i[d]}})});function n(d){return d&&d.__esModule?d:{default:d}}const o=dm;var c=(0,e.default)(o());s.default=c})(Ee);const zd=om(Ee),qr=1.8;function um(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:typeof s.top=="number"?s.top*t:s.top,right:typeof s.right=="number"?s.right*t:s.right,bottom:typeof s.bottom=="number"?s.bottom*t:s.bottom,left:typeof s.left=="number"?s.left*t:s.left}}function Yd(s,t){return typeof s=="number"?{top:s*t,right:s*t,bottom:s*t,left:s*t}:{top:(typeof s.top=="number"?s.top*t:s.top)??0,right:(typeof s.right=="number"?s.right*t:s.right)??0,bottom:(typeof s.bottom=="number"?s.bottom*t:s.bottom)??0,left:(typeof s.left=="number"?s.left*t:s.left)??0}}function fm(s,t=1){return typeof s=="number"?{topLeft:s*t,topRight:s*t,bottomRight:s*t,bottomLeft:s*t}:{topLeft:((s==null?void 0:s.topLeft)??0)*t,topRight:((s==null?void 0:s.topRight)??0)*t,bottomRight:((s==null?void 0:s.bottomRight)??0)*t,bottomLeft:((s==null?void 0:s.bottomLeft)??0)*t}}function Xd(s,{layout:t,scale:e=1}){const{position:i="static",inset:n,width:o,height:c,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:A,margin:E,padding:T,direction:w="column",align:C="start",alignSelf:x,justify:O="start"}=t,B={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(s.setPositionType(B[i]),n){const{top:z,right:it,bottom:at,left:J}=um(n,e);z&&s.setPosition(Ee.Edge.Top,z),it&&s.setPosition(Ee.Edge.Right,it),at&&s.setPosition(Ee.Edge.Bottom,at),J&&s.setPosition(Ee.Edge.Left,J)}const D={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};s.setFlexDirection(D[w]);const V={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};s.setAlignItems(V[C]),x&&s.setAlignSelf(V[x]);const $={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(s.setJustifyContent($[O]),E){const{top:z,right:it,bottom:at,left:J}=Yd(E,e);s.setMargin(Ee.Edge.Top,z),s.setMargin(Ee.Edge.Right,it),s.setMargin(Ee.Edge.Bottom,at),s.setMargin(Ee.Edge.Left,J)}if(T){const{top:z,right:it,bottom:at,left:J}=Yd(T,e);s.setPadding(Ee.Edge.Top,z),s.setPadding(Ee.Edge.Right,it),s.setPadding(Ee.Edge.Bottom,at),s.setPadding(Ee.Edge.Left,J)}v&&s.setFlex(v),s.setGap(Ee.Gutter.All,(A??0)*e),o&&s.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?s.setHeight("100%"):s.setHeight(typeof c=="number"?c*e:c)),d&&s.setMinWidth(typeof d=="number"?d*e:d),f&&s.setMinHeight(typeof f=="number"?f*e:f),p&&s.setMaxWidth(typeof p=="number"?p*e:p),g&&s.setMaxHeight(typeof g=="number"?g*e:g)}function Zd({canvas:s,debug:t=!1,scale:e=1,position:i=[]}){i.forEach(({x:n,y:o,width:c,height:d,childNodes:f,element:p})=>{const g=s.getContext("2d",{alpha:!1});if(g){const{radius:v,draw:A}=p;if(A){if(g.save(),v){const{topLeft:E,topRight:T,bottomRight:w,bottomLeft:C}=fm(v,e);g.beginPath(),g.moveTo(n+Math.min(d/qr,E),o),g.lineTo(n+c-Math.min(d/qr,T),o),g.quadraticCurveTo(n+c,o,n+c,o+Math.min(d/qr,T)),g.lineTo(n+c,o+d-Math.min(d/qr,w)),g.quadraticCurveTo(n+c,o+d,n+c-Math.min(d/qr,w),o+d),g.lineTo(n+Math.min(d/qr,C),o+d),g.quadraticCurveTo(n,o+d,n,o+d-Math.min(d/qr,C)),g.lineTo(n,o+Math.min(d/qr,E)),g.quadraticCurveTo(n,o,n+Math.min(d/qr,E),o),g.closePath(),t&&(g.strokeStyle="blue",g.stroke()),g.clip()}A({scale:e,dx:n,dy:o,dw:c,dh:d}),t&&(g.strokeStyle="red",g.strokeRect(n,o,c,d)),g.restore()}}Zd({canvas:s,debug:t,scale:e,position:f})})}function qd(s,t,e){const i=t.map((n,o)=>{const c=zd.Node.create(),{radius:d,elements:f=[],draw:p,...g}=n;return Xd(c,{layout:g,scale:e}),s.insertChild(c,o),{node:c,element:n,childNodes:qd(c,f,e)}});return s.calculateLayout(),i}function Qd(s,t,e=0,i=0){const{top:n,left:o}=s.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:A}=c.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:n+T,width:v,height:A,element:d,childNodes:Qd(s,f,E,T)}})}function Jd(s,t){s.forEach(({node:e,element:i,childNodes:n})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:c,maxHeight:d,scale:t});e.setHeight(f)}Jd(n,t)})}function pm({canvas:s,origin:t,elements:e,...i}){const n={inset:{top:0,left:0},width:s.width,height:s.height,...t},o=zd.Node.create();Xd(o,{layout:n}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=qd(o,e,f);Jd(p,f),o.calculateLayout();const g=Qd(o,p);return Zd({...i,scale:f,canvas:s,position:g})}const tu=[{family:"Noto Arabic",regex:/\p{Script=Arabic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansArabic-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Chinese",regex:/\p{Script=Han}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansSC-VariableFont_wght.woff2",style:"normal"},{family:"Noto Hebrew",regex:/\p{Script=Hebrew}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansHebrew-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Hindi",regex:/\p{Script=Devanagari}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansDevanagari-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Japanese",regex:/\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansJP-VariableFont_wght.woff2",style:"normal"},{family:"Noto Korean",regex:/\p{Script=Hangul}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansKR-VariableFont_wght.woff2",style:"normal"},{family:"Noto Color Emoji",regex:/\p{Extended_Pictographic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoColorEmoji-Regular.woff2",style:"normal"}];function co({text:s,font:t}){let e=t;return tu.forEach(({family:i,regex:n})=>{n.exec(s)&&(e+=`, ${i}`)}),e}const ho=/(?<value>\d+\.?\d*)(?=px)/;function eu(s){const{visible:t=!0,node:e}=s,i=[...(e==null?void 0:e.elements)??[],...(s==null?void 0:s.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(n=>eu(n)):!1}function iu({debug:s=!1,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o=[],currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:A}){return o.map(E=>{var T,w,C,x,O,B,D,V;const{node:$,transient:z=[{from:0,duration:1/0}]}=E,it=t.getContext("2d"),at={total:c,content:d,scene:f},J={total:p,content:g,scene:v},wt=z.reduce((vt,{type:Ot="scene",from:Gt,duration:U,animation:q})=>{const At=Gt<0?J[Ot]+Gt:Gt;return at[Ot]>=At&&at[Ot]<=At+U&&(vt={type:Ot,animation:q,duration:U,from:At}),vt},null);if(it&&wt&&eu(E)){let vt=E.width,Ot=E.height,Gt=A??1;const{type:U="scene",from:q,duration:At,animation:F={type:"fade",duration:.3333333333333333}}=wt;if(F){const{type:N,duration:j}=F;N==="fade"&&(q>0&&at[U]<=q+j&&(Gt=Math.max(0,Math.min(1,(at[U]-q)/j))),q+At<J[U]&&q+At-j<=at[U]&&(Gt=Math.max(0,Math.min(1,(q+At-at[U])/j))))}if(($==null?void 0:$.type)==="text"&&$.value){const N=co({text:$.value,font:$.font});it.save(),$.wrap?Ot=({width:j,maxHeight:nt,scale:ht})=>{var Lt,Nt;const jt=Wd({font:N,scale:ht,context:it,maxW:j,maxH:nt,text:$.value??"",minSize:(Lt=$.fill)==null?void 0:Lt.minSize,maxSize:(Nt=$.fill)==null?void 0:Nt.maxSize});return uo({context:it,font:N,fontSize:jt,text:$.value??"",maxW:j}).length*jt}:(it.font=N,vt=it.measureText($.value).width,Ot=parseFloat(((w=(T=N.match(ho))==null?void 0:T.groups)==null?void 0:w.value)??"0")),it.restore()}if(($==null?void 0:$.type)==="image"&&$.image&&$.size){const N=((C=$.image)==null?void 0:C.naturalWidth)??((x=$.image)==null?void 0:x.width),j=((O=$.image)==null?void 0:O.naturalHeight)??((B=$.image)==null?void 0:B.height),nt=N/j,ht=(D=$.size)==null?void 0:D.width,Lt=(V=$.size)==null?void 0:V.height;vt=ht??(nt>=1?(Lt??0)*nt:(Lt??0)/nt),Ot=Lt??(nt<1?(ht??0)*nt:(ht??0)/nt)}return{...E,width:vt,height:Ot,elements:iu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:E.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,parentAlpha:Gt}),draw:({dx:N,dy:j,dw:nt,dh:ht,scale:Lt})=>{var Nt,jt,ue,me,ge,je,Re,Kt,be,he,Oe,Ut,Ke;if(it.globalAlpha=Gt,$){const{type:Fe}=$;if(Fe==="box"&&(it.fillStyle=$.background,it.fillRect(N,j,nt,ht)),Fe==="text"&&$.value){const Ge=co({text:$.value,font:$.font}),ke=Wd({font:Ge,scale:Lt,context:it,maxW:nt,maxH:ht,text:$.value??"",minSize:(Nt=$.fill)==null?void 0:Nt.minSize,maxSize:(jt=$.fill)==null?void 0:jt.maxSize});it.font=Ge.replace(ho,ke.toString()),it.textBaseline="top",it.fillStyle=$.color,$.wrap?uo({context:it,font:Ge,fontSize:ke,text:$.value,maxW:nt}).forEach((de,ze)=>{it.fillText(de.text,N,j+ke*ze)}):it.fillText($.value,N,j)}if(Fe==="image"&&$.image&&it.drawImage($.image,N,j,nt,ht),Fe==="video"&&((ue=$.video)!=null&&ue.node||(me=$.video)!=null&&me.getSource)){const Ge=$.format??"letterbox",ke=((je=(ge=$.video)==null?void 0:ge.getSource)==null?void 0:je.call(ge,f))??$.video.node,de=(ke==null?void 0:ke.videoWidth)??(ke==null?void 0:ke.naturalWidth)??(ke==null?void 0:ke.width),ze=(ke==null?void 0:ke.videoHeight)??(ke==null?void 0:ke.naturalHeight)??(ke==null?void 0:ke.height);if(de&&ze){const{dx:Ne,dy:Ue,dw:ui,dh:Le}=Bd({context:it,cropCanvas:e,letterboxCanvas:n,source:ke,format:Ge,crop:(Re=$==null?void 0:$.value)==null?void 0:Re.crop,sourceWidth:de,sourceHeight:ze,posX:N,posY:j,drawAreaWidth:nt,drawAreaHeight:ht});$.elements&&Bl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(j,j+Ue),left:Math.max(N,N+Ne)},width:Math.min(nt,ui),height:Math.min(ht,Le)}})}const oe=1/3;if($.poster&&c>=0&&c<=oe){it.save(),it.globalAlpha=1-c/oe;const Ne=((Kt=$.poster)==null?void 0:Kt.naturalWidth)??((be=$.poster)==null?void 0:be.width),Ue=((he=$.poster)==null?void 0:he.naturalHeight)??((Oe=$.poster)==null?void 0:Oe.height);i.width=i.height=0,i.width=nt,i.height=ht;const ui=i.getContext("2d");if(ui&&Ne&&Ue){const{dx:Le,dy:vi,dw:kr,dh:ni}=Bd({context:ui,cropCanvas:e,letterboxCanvas:n,source:$.poster,format:Ge,crop:(Ut=$==null?void 0:$.value)==null?void 0:Ut.crop,sourceWidth:Ne,sourceHeight:Ue,posX:0,posY:0,drawAreaWidth:nt,drawAreaHeight:ht});$.elements&&Bl({debug:s,canvas:i,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:$.elements,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,origin:{inset:{top:Math.max(0,vi),left:Math.max(0,Le)},width:Math.min(nt,kr),height:Math.min(ht,ni)}}),it.drawImage(i,N,j,nt,ht),it.restore()}}}if(Fe==="gradient"&&$.value){const Ge=it.createLinearGradient(N+nt,j,N+nt,j+ht);(Ke=$.value)==null||Ke.forEach(ke=>{Ge.addColorStop(ke.percent,ke.color)}),it.fillStyle=Ge,it.fillRect(N,j,nt,ht)}}}}}}).filter(Boolean)}function Bl({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v,...A}){return pm({...A,debug:s,canvas:t,elements:iu({debug:s,canvas:t,cropCanvas:e,posterCanvas:i,letterboxCanvas:n,elements:o,currentTime:c,contentTime:d,sceneTime:f,totalDuration:p,contentDuration:g,sceneDuration:v})})}const uo=Vd(({context:s,font:t,fontSize:e,text:i,maxW:n=1/0})=>{try{return s.save(),s.font=t.replace(ho,e.toString()),i.split(`
|
91
91
|
`).flatMap(o=>{const c=o.split(" ").filter(Boolean);return c.length?c.slice(1).reduce((d,f)=>{const p=`${d[d.length-1].text} ${f}`.trim(),g=s.measureText(p);return g.width>n?d=[...d,...Hd({context:s,word:f,maxW:n})]:d[d.length-1]={text:p,metrics:g},d},Hd({context:s,word:c[0],maxW:n})):{text:"",metrics:s.measureText("")}})}finally{s.restore()}},{cacheKey:([{font:s,fontSize:t,text:e,maxW:i}])=>`${s}_${t}_${e}_${i}`}),gm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,mm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function ru(s){if(!s)return[];const t=s.match(gm);return t?t==null?void 0:t.map(e=>{const[i,n]=e.replace(`\r
|
92
92
|
`,`
|
93
93
|
`).split(`
|
@@ -168,7 +168,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
168
168
|
"width": {{ it.root?.answer?.settings?.crop?.width }},
|
169
169
|
"height": {{ it.root?.answer?.settings?.crop?.height }}
|
170
170
|
}
|
171
|
-
}`}],root:"{{ it.outro?.questions?.items }}"}]}],meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function bm(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ip);return new s.Image}return new Image}const su=ys(async function(s){return s?new Promise((t,e)=>{bm().then(i=>{i.onload=()=>{t(i)},i.onerror=n=>{e(n)},i.src=s})}):null});async function Gl({element:s},t,e){var i,n,o;let c={...s};const{node:d}=s;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(n=d==null?void 0:d.value)!=null&&n.playlist)){const f=await t(d.value);let p;try{p=await su(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 su(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=s.node)!=null&&o.elements&&(c.node.elements=await Promise.all(s.node.elements.map(f=>Gl({element:f},t,e)))),s.elements&&(c.elements=await Promise.all(s.elements.map(f=>Gl({element:f},t,e)))),c}async function po(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ip),t=new s.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Am(s){var t;try{if((t=await Yg(s,{method:"HEAD"}))!=null&&t.ok)return s}catch{return}}async function Em({sources:s}){let t=null;if(s){const e=s.filter(Boolean).map(i=>Am(i));t=(await Promise.all(e)).find(Boolean)}return t}function Vl(s=[]){var t;for(const e of s){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Vl(e==null?void 0:e.elements);if(i)return i}}function Hl(s,t){return s.reduce((e,{duration:i})=>e+=i-t/2,-t/2)}function Tm(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}to.filters.define("parse",s=>{if(typeof s>"u")return null;if(typeof s=="string"){let t=s;return t=t.replace(/\n/g,"\\n"),t=t.replace(/\r/g,"\\r"),t=t.replace(/"/g,'\\"'),`"${t}"`}return Tm(s)||Array.isArray(s)?JSON.stringify(s):s}),to.helpers.define("resolve-source",ys(async s=>{const{sources:t}=s.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),n=e==null?void 0:e.find(c=>!c.includes("http")),o=i??n??await Em({sources:t});return o?`"${o}"`:"null"},{cacheKey:([s])=>JSON.stringify(s.params[0]??{})}));const ua=(s,t,e)=>to.render(s,t,to.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function go({data:s,template:t,burnCaptions:e=!1,debug:i=!1},n,o){var c,d,f,p;const g=t??ym;if(!((c=g.templates)!=null&&c.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:x})=>x===Wl);if(!v){const x=g.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Wl}" but got ${x}`),v=g.templates[g.templates.length-1]}const A=(await Promise.all(v.content.map(async({scenes:x,root:O})=>{const B={...g.options,...s,intro:g.intro,outro:g.outro};async function D(V,$){return Promise.all(x.map(async({layout:z,duration:it,data:at,options:J})=>{var wt,vt,Ot;const Gt={...B,index:$,root:V},U=at?JSON.parse(await ua(at,Gt)):{},q=J?JSON.parse(await ua(J,Gt)):{},At=it?parseFloat(await ua(it,Gt)):NaN,F=(wt=v.layouts.find(ut=>ut.name===z))==null?void 0:wt.tree;if(!F)throw new Error(`Layout tree "${z}" not found in template "${v.id}" layouts.`);const N=JSON.parse(await ua(F,{...U,...q})),j=await Promise.all(N.flatMap(ut=>Gl({element:ut},n,o))),nt=Vl(j);return{duration:(isNaN(At)?null:At)??((vt=nt==null?void 0:nt.meta)==null?void 0:vt.duration)??0,captions:(Ot=nt==null?void 0:nt.meta)==null?void 0:Ot.captions,elements:j}}))}if(O){const V=JSON.parse(await ua(O,B));return Array.isArray(V)?(await Promise.all(V.map(async($,z)=>D($,z)))).flatMap($=>$):D(V,null)}return D(s,null)}))).reduce((x,O)=>{const B=O.filter(D=>D.duration>0);return B.length>0&&(x=[...x,B]),x},[]),E=((d=g.meta)==null?void 0:d.frameRate)??30,T=((f=g.meta)==null?void 0:f.resolution)??720,w=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,C=Math.floor(A.reduce((x,O)=>x+=Hl(O,w),0)*100)/100;return{scenes:(await Promise.all(A.map((x,O)=>{const B=Hl(x,w),D=A.reduce((V,$,z)=>(z<O&&(V+=Hl($,w)),V),0);return Promise.all(x.map(async({duration:V,captions:$,elements:z},it)=>{var at,J;const wt=await po(),vt=await po(),Ot=await po(),Gt=await po(),U=Vl(z),q=x.reduce((At,{duration:F},N)=>(N<it&&(At+=F-w/2),At),D);return{draw:({canvas:At,currentTime:F})=>{const N=Math.max(0,F-D),j=Math.max(0,F-q);Bl({debug:i,canvas:At,cropCanvas:wt,posterCanvas:Gt,letterboxCanvas:vt,elements:z,currentTime:F,contentTime:N,sceneTime:j,totalDuration:C,contentDuration:B,sceneDuration:V}),$&&e&&vm({canvas:At,dx:0,dy:0,dw:At.width,dh:At.height,vttCaptions:$,sceneTime:j+((U==null?void 0:U.meta.start)??0)})},duration:V,transitionCanvas:Ot,start:q,video:U==null?void 0:U.video,videoMeta:U==null?void 0:U.meta,audio:{duration:V,src:(at=U==null?void 0:U.value)==null?void 0:at.src,start:(J=U==null?void 0:U.meta)==null?void 0:J.start}}}))}))).flatMap(x=>x),frameRate:E,resolution:T,transitionDuration:w,fonts:v.fonts??[],duration:C}}const Wl="2",km={name:"@vouchfor/embeds",version:"1.0.0",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",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:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"^2.0.0",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",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function wm(s){const{publicApiUrl:t}=Qa(s),e=qs();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function Sm(s){var o,c,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:qs()};let t=(c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),i=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=qs();return t||(t=wm(s),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=qs(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i||(i=qs(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:n,visitor:t}}function Rm(s,t){return s&&"vouchId"in s?s.vouchId:(t==null?void 0:t.id)??null}function Lm(s="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([c,d])=>{if(/utm/.test(c)){const f=c.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[f]=d}}),{source:s,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:km.version,templateVersion:Wl,...i}}const nu=1;class _m{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,i)=>{const n=Rm(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=Qa(this.host.env),{client:i,tab:n,request:o,visitor:c}=Sm(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":c,"x-reporting-metadata":Lm(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+nu&&this._createTrackingEvent("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._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:n}})=>{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:n},this._streamLatestTime[i]=n.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=n.currentTime,this._streamLatestTime[i]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+nu&&this._createTrackingEvent("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._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,i,n;"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),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,n;this._pageUnloading(),"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),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}/**
|
171
|
+
}`}],root:"{{ it.outro?.questions?.items }}"}]}],meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function bm(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ip);return new s.Image}return new Image}const su=ys(async function(s){return s?new Promise((t,e)=>{bm().then(i=>{i.onload=()=>{t(i)},i.onerror=n=>{e(n)},i.src=s})}):null});async function Gl({element:s},t,e){var i,n,o;let c={...s};const{node:d}=s;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(n=d==null?void 0:d.value)!=null&&n.playlist)){const f=await t(d.value);let p;try{p=await su(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 su(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=s.node)!=null&&o.elements&&(c.node.elements=await Promise.all(s.node.elements.map(f=>Gl({element:f},t,e)))),s.elements&&(c.elements=await Promise.all(s.elements.map(f=>Gl({element:f},t,e)))),c}async function po(){if(typeof window>"u"){const s=await Promise.resolve().then(()=>ip),t=new s.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function Am(s){var t;try{if((t=await Yg(s,{method:"HEAD"}))!=null&&t.ok)return s}catch{return}}async function Em({sources:s}){let t=null;if(s){const e=s.filter(Boolean).map(i=>Am(i));t=(await Promise.all(e)).find(Boolean)}return t}function Vl(s=[]){var t;for(const e of s){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Vl(e==null?void 0:e.elements);if(i)return i}}function Hl(s,t){return s.reduce((e,{duration:i})=>e+=i-t/2,-t/2)}function Tm(s){if(s===null||typeof s!="object")return!1;if(Object.getPrototypeOf(s)===null)return!0;let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}to.filters.define("parse",s=>{if(typeof s>"u")return null;if(typeof s=="string"){let t=s;return t=t.replace(/\n/g,"\\n"),t=t.replace(/\r/g,"\\r"),t=t.replace(/"/g,'\\"'),`"${t}"`}return Tm(s)||Array.isArray(s)?JSON.stringify(s):s}),to.helpers.define("resolve-source",ys(async s=>{const{sources:t}=s.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),n=e==null?void 0:e.find(c=>!c.includes("http")),o=i??n??await Em({sources:t});return o?`"${o}"`:"null"},{cacheKey:([s])=>JSON.stringify(s.params[0]??{})}));const ua=(s,t,e)=>to.render(s,t,to.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...e}));async function go({data:s,template:t,burnCaptions:e=!1,debug:i=!1},n,o){var c,d,f,p;const g=t??ym;if(!((c=g.templates)!=null&&c.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:x})=>x===Wl);if(!v){const x=g.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Wl}" but got ${x}`),v=g.templates[g.templates.length-1]}const A=(await Promise.all(v.content.map(async({scenes:x,root:O})=>{const B={...g.options,...s,intro:g.intro,outro:g.outro};async function D(V,$){return Promise.all(x.map(async({layout:z,duration:it,data:at,options:J})=>{var wt,vt,Ot;const Gt={...B,index:$,root:V},U=at?JSON.parse(await ua(at,Gt)):{},q=J?JSON.parse(await ua(J,Gt)):{},At=it?parseFloat(await ua(it,Gt)):NaN,F=(wt=v.layouts.find(ht=>ht.name===z))==null?void 0:wt.tree;if(!F)throw new Error(`Layout tree "${z}" not found in template "${v.id}" layouts.`);const N=JSON.parse(await ua(F,{...U,...q})),j=await Promise.all(N.flatMap(ht=>Gl({element:ht},n,o))),nt=Vl(j);return{duration:(isNaN(At)?null:At)??((vt=nt==null?void 0:nt.meta)==null?void 0:vt.duration)??0,captions:(Ot=nt==null?void 0:nt.meta)==null?void 0:Ot.captions,elements:j}}))}if(O){const V=JSON.parse(await ua(O,B));return Array.isArray(V)?(await Promise.all(V.map(async($,z)=>D($,z)))).flatMap($=>$):D(V,null)}return D(s,null)}))).reduce((x,O)=>{const B=O.filter(D=>D.duration>0);return B.length>0&&(x=[...x,B]),x},[]),E=((d=g.meta)==null?void 0:d.frameRate)??30,T=((f=g.meta)==null?void 0:f.resolution)??720,w=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,C=Math.floor(A.reduce((x,O)=>x+=Hl(O,w),0)*100)/100;return{scenes:(await Promise.all(A.map((x,O)=>{const B=Hl(x,w),D=A.reduce((V,$,z)=>(z<O&&(V+=Hl($,w)),V),0);return Promise.all(x.map(async({duration:V,captions:$,elements:z},it)=>{var at,J;const wt=await po(),vt=await po(),Ot=await po(),Gt=await po(),U=Vl(z),q=x.reduce((At,{duration:F},N)=>(N<it&&(At+=F-w/2),At),D);return{draw:({canvas:At,currentTime:F})=>{const N=Math.max(0,F-D),j=Math.max(0,F-q);Bl({debug:i,canvas:At,cropCanvas:wt,posterCanvas:Gt,letterboxCanvas:vt,elements:z,currentTime:F,contentTime:N,sceneTime:j,totalDuration:C,contentDuration:B,sceneDuration:V}),$&&e&&vm({canvas:At,dx:0,dy:0,dw:At.width,dh:At.height,vttCaptions:$,sceneTime:j+((U==null?void 0:U.meta.start)??0)})},duration:V,transitionCanvas:Ot,start:q,video:U==null?void 0:U.video,videoMeta:U==null?void 0:U.meta,audio:{duration:V,src:(at=U==null?void 0:U.value)==null?void 0:at.src,start:(J=U==null?void 0:U.meta)==null?void 0:J.start}}}))}))).flatMap(x=>x),frameRate:E,resolution:T,transitionDuration:w,fonts:v.fonts??[],duration:C}}const Wl="2",km={name:"@vouchfor/embeds",version:"1.0.1",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/src/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"latest",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:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test --config web-test-runner.ci.config.js"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"^2.0.1",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",sinon:"^17.0.1",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}};function wm(s){const{publicApiUrl:t}=Qa(s),e=qs();return navigator.sendBeacon(`${t}/api/visitor`,JSON.stringify({visitorId:e})),e}function Sm(s){var o,c,d,f,p,g,v,A,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:qs()};let t=(c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"),e=(f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"),i=(g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab");const n=qs();return t||(t=wm(s),(A=(v=window.localStorage)==null?void 0:v.setItem)==null||A.call(v,"vouch-uid-visitor",t)),e||(e=qs(),(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i||(i=qs(),(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:n,visitor:t}}function Rm(s,t){return s&&"vouchId"in s?s.vouchId:(t==null?void 0:t.id)??null}function _m(s="embedded_player"){var n,o;const[t,e]=((o=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:o.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([c,d])=>{if(/utm/.test(c)){const f=c.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[f]=d}}),{source:s,time:new Date,region:e,country:t,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:km.version,templateVersion:Wl,...i}}const nu=1;class Lm{constructor(t){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(e,i)=>{const n=Rm(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:e,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:e}=Qa(this.host.env),{client:i,tab:n,request:o,visitor:c}=Sm(this.host.env);navigator.sendBeacon(`${e}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":o,"x-uid-visitor":c,"x-reporting-metadata":_m(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+nu&&this._createTrackingEvent("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._createTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:n}})=>{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:n},this._streamLatestTime[i]=n.currentTime,this._streamStartTime[i]||(this._streamStartTime[i]=n.currentTime,this._streamLatestTime[i]=n.currentTime))},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+nu&&this._createTrackingEvent("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._sendTrackingEvent()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}hostConnected(){requestAnimationFrame(()=>{var t,e,i,n;"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),(n=this.host.mediaPlayer)==null||n.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,n;this._pageUnloading(),"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),(n=this.host.mediaPlayer)==null||n.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}/**
|
172
172
|
* @license
|
173
173
|
* Copyright 2018 Google LLC
|
174
174
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -180,39 +180,39 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
180
180
|
* @license
|
181
181
|
* Copyright 2017 Google LLC
|
182
182
|
* SPDX-License-Identifier: BSD-3-Clause
|
183
|
-
*/const hu=(s,t,e)=>{const i=new Map;for(let n=t;n<=e;n++)i.set(s[n],n);return i},du=bn(class extends sa{constructor(s){if(super(s),s.type!==yn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(s,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const n=[],o=[];let c=0;for(const d of s)n[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:n}}render(s,t,e){return this.ht(s,t,e).values}update(s,[t,e,i]){const n=og(s),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(n))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,A=n.length-1,E=0,T=o.length-1;for(;v<=A&&E<=T;)if(n[v]===null)v++;else if(n[A]===null)A--;else if(d[v]===c[E])f[E]=Zs(n[v],o[E]),v++,E++;else if(d[A]===c[T])f[T]=Zs(n[A],o[T]),A--,T--;else if(d[v]===c[T])f[T]=Zs(n[v],o[T]),ra(s,f[T+1],n[v]),v++,T--;else if(d[A]===c[E])f[E]=Zs(n[A],o[E]),ra(s,n[v],n[A]),A--,E++;else if(p===void 0&&(p=hu(c,E,T),g=hu(d,v,A)),p.has(d[v]))if(p.has(d[A])){const w=g.get(c[E]),C=w!==void 0?n[w]:null;if(C===null){const x=ra(s,n[v]);Zs(x,o[E]),f[E]=x}else f[E]=Zs(C,o[E]),ra(s,n[v],C),n[w]=null;E++}else Sl(n[A]),A--;else Sl(n[v]),v++;for(;E<=T;){const w=ra(s,f[T+1]);Zs(w,o[E]),f[E++]=w}for(;v<=A;){const w=n[v++];w!==null&&Sl(w)}return this.dt=c,ag(s,f),fs}});var Wi="top",or="bottom",lr="right",ji="left",Kl="auto",pa=[Wi,or,lr,ji],An="start",ga="end",xm="clippingParents",uu="viewport",ma="popper",Pm="reference",fu=pa.reduce(function(s,t){return s.concat([t+"-"+An,t+"-"+ga])},[]),pu=[].concat(pa,[Kl]).reduce(function(s,t){return s.concat([t,t+"-"+An,t+"-"+ga])},[]),Om="beforeRead",Mm="read",$m="afterRead",Fm="beforeMain",Nm="main",Um="afterMain",Bm="beforeWrite",Gm="write",Vm="afterWrite",Hm=[Om,Mm,$m,Fm,Nm,Um,Bm,Gm,Vm];function Ir(s){return s?(s.nodeName||"").toLowerCase():null}function ir(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var t=s.ownerDocument;return t&&t.defaultView||window}return s}function tn(s){var t=ir(s).Element;return s instanceof t||s instanceof Element}function cr(s){var t=ir(s).HTMLElement;return s instanceof t||s instanceof HTMLElement}function zl(s){if(typeof ShadowRoot>"u")return!1;var t=ir(s).ShadowRoot;return s instanceof t||s instanceof ShadowRoot}function Wm(s){var t=s.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!cr(o)||!Ir(o)||(Object.assign(o.style,i),Object.keys(n).forEach(function(c){var d=n[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function jm(s){var t=s.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 n=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},{});!cr(n)||!Ir(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const gu={name:"applyStyles",enabled:!0,phase:"write",fn:Wm,effect:jm,requires:["computeStyles"]};function Dr(s){return s.split("-")[0]}var en=Math.max,mo=Math.min,En=Math.round;function Yl(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function mu(){return!/^((?!chrome|android).)*safari/i.test(Yl())}function Tn(s,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=s.getBoundingClientRect(),n=1,o=1;t&&cr(s)&&(n=s.offsetWidth>0&&En(i.width)/s.offsetWidth||1,o=s.offsetHeight>0&&En(i.height)/s.offsetHeight||1);var c=tn(s)?ir(s):window,d=c.visualViewport,f=!mu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/n,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/n,A=i.height/o;return{width:v,height:A,top:g,right:p+v,bottom:g+A,left:p,x:p,y:g}}function Xl(s){var t=Tn(s),e=s.offsetWidth,i=s.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:s.offsetLeft,y:s.offsetTop,width:e,height:i}}function vu(s,t){var e=t.getRootNode&&t.getRootNode();if(s.contains(t))return!0;if(e&&zl(e)){var i=t;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function qr(s){return ir(s).getComputedStyle(s)}function Km(s){return["table","td","th"].indexOf(Ir(s))>=0}function As(s){return((tn(s)?s.ownerDocument:s.document)||window.document).documentElement}function vo(s){return Ir(s)==="html"?s:s.assignedSlot||s.parentNode||(zl(s)?s.host:null)||As(s)}function yu(s){return!cr(s)||qr(s).position==="fixed"?null:s.offsetParent}function zm(s){var t=/firefox/i.test(Yl()),e=/Trident/i.test(Yl());if(e&&cr(s)){var i=qr(s);if(i.position==="fixed")return null}var n=vo(s);for(zl(n)&&(n=n.host);cr(n)&&["html","body"].indexOf(Ir(n))<0;){var o=qr(n);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 n;n=n.parentNode}return null}function va(s){for(var t=ir(s),e=yu(s);e&&Km(e)&&qr(e).position==="static";)e=yu(e);return e&&(Ir(e)==="html"||Ir(e)==="body"&&qr(e).position==="static")?t:e||zm(s)||t}function Zl(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function ya(s,t,e){return en(s,mo(t,e))}function Ym(s,t,e){var i=ya(s,t,e);return i>e?e:i}function bu(){return{top:0,right:0,bottom:0,left:0}}function Au(s){return Object.assign({},bu(),s)}function Eu(s,t){return t.reduce(function(e,i){return e[i]=s,e},{})}var Xm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,Au(typeof t!="number"?t:Eu(t,pa))};function Zm(s){var t,e=s.state,i=s.name,n=s.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=Dr(e.placement),f=Zl(d),p=[ji,lr].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Xm(n.padding,e),A=Xl(o),E=f==="y"?Wi:ji,T=f==="y"?or:lr,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],C=c[f]-e.rects.reference[f],x=va(o),O=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,B=w/2-C/2,D=v[E],V=O-A[g]-v[T],$=O/2-A[g]/2+B,z=ya(D,$,V),it=f;e.modifiersData[i]=(t={},t[it]=z,t.centerOffset=z-$,t)}}function qm(s){var t=s.state,e=s.options,i=e.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||vu(t.elements.popper,n)&&(t.elements.arrow=n))}const Qm={name:"arrow",enabled:!0,phase:"main",fn:Zm,effect:qm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function kn(s){return s.split("-")[1]}var Jm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function t1(s,t){var e=s.x,i=s.y,n=t.devicePixelRatio||1;return{x:En(e*n)/n||0,y:En(i*n)/n||0}}function Tu(s){var t,e=s.popper,i=s.popperRect,n=s.placement,o=s.variation,c=s.offsets,d=s.position,f=s.gpuAcceleration,p=s.adaptive,g=s.roundOffsets,v=s.isFixed,A=c.x,E=A===void 0?0:A,T=c.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var x=c.hasOwnProperty("x"),O=c.hasOwnProperty("y"),B=ji,D=Wi,V=window;if(p){var $=va(e),z="clientHeight",it="clientWidth";if($===ir(e)&&($=As(e),qr($).position!=="static"&&d==="absolute"&&(z="scrollHeight",it="scrollWidth")),$=$,n===Wi||(n===ji||n===lr)&&o===ga){D=or;var at=v&&$===V&&V.visualViewport?V.visualViewport.height:$[z];w-=at-i.height,w*=f?1:-1}if(n===ji||(n===Wi||n===or)&&o===ga){B=lr;var J=v&&$===V&&V.visualViewport?V.visualViewport.width:$[it];E-=J-i.width,E*=f?1:-1}}var wt=Object.assign({position:d},p&&Jm),vt=g===!0?t1({x:E,y:w},ir(e)):{x:E,y:w};if(E=vt.x,w=vt.y,f){var Ot;return Object.assign({},wt,(Ot={},Ot[D]=O?"0":"",Ot[B]=x?"0":"",Ot.transform=(V.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Ot))}return Object.assign({},wt,(t={},t[D]=O?w+"px":"",t[B]=x?E+"px":"",t.transform="",t))}function e1(s){var t=s.state,e=s.options,i=e.gpuAcceleration,n=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:kn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Tu(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,Tu(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 i1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:e1,data:{}};var yo={passive:!0};function r1(s){var t=s.state,e=s.instance,i=s.options,n=i.scroll,o=n===void 0?!0:n,c=i.resize,d=c===void 0?!0:c,f=ir(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,yo)}),d&&f.addEventListener("resize",e.update,yo),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,yo)}),d&&f.removeEventListener("resize",e.update,yo)}}const s1={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:r1,data:{}};var n1={left:"right",right:"left",bottom:"top",top:"bottom"};function bo(s){return s.replace(/left|right|bottom|top/g,function(t){return n1[t]})}var a1={start:"end",end:"start"};function ku(s){return s.replace(/start|end/g,function(t){return a1[t]})}function ql(s){var t=ir(s),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function Ql(s){return Tn(As(s)).left+ql(s).scrollLeft}function o1(s,t){var e=ir(s),i=As(s),n=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(n){o=n.width,c=n.height;var p=mu();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:c,x:d+Ql(s),y:f}}function l1(s){var t,e=As(s),i=ql(s),n=(t=s.ownerDocument)==null?void 0:t.body,o=en(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),c=en(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-i.scrollLeft+Ql(s),f=-i.scrollTop;return qr(n||e).direction==="rtl"&&(d+=en(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Jl(s){var t=qr(s),e=t.overflow,i=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+i)}function wu(s){return["html","body","#document"].indexOf(Ir(s))>=0?s.ownerDocument.body:cr(s)&&Jl(s)?s:wu(vo(s))}function ba(s,t){var e;t===void 0&&(t=[]);var i=wu(s),n=i===((e=s.ownerDocument)==null?void 0:e.body),o=ir(i),c=n?[o].concat(o.visualViewport||[],Jl(i)?i:[]):i,d=t.concat(c);return n?d:d.concat(ba(vo(c)))}function tc(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function c1(s,t){var e=Tn(s,!1,t==="fixed");return e.top=e.top+s.clientTop,e.left=e.left+s.clientLeft,e.bottom=e.top+s.clientHeight,e.right=e.left+s.clientWidth,e.width=s.clientWidth,e.height=s.clientHeight,e.x=e.left,e.y=e.top,e}function Su(s,t,e){return t===uu?tc(o1(s,e)):tn(t)?c1(t,e):tc(l1(As(s)))}function h1(s){var t=ba(vo(s)),e=["absolute","fixed"].indexOf(qr(s).position)>=0,i=e&&cr(s)?va(s):s;return tn(i)?t.filter(function(n){return tn(n)&&vu(n,i)&&Ir(n)!=="body"}):[]}function d1(s,t,e,i){var n=t==="clippingParents"?h1(s):[].concat(t),o=[].concat(n,[e]),c=o[0],d=o.reduce(function(f,p){var g=Su(s,p,i);return f.top=en(g.top,f.top),f.right=mo(g.right,f.right),f.bottom=mo(g.bottom,f.bottom),f.left=en(g.left,f.left),f},Su(s,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 Ru(s){var t=s.reference,e=s.element,i=s.placement,n=i?Dr(i):null,o=i?kn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case Wi:f={x:c,y:t.y-e.height};break;case or:f={x:c,y:t.y+t.height};break;case lr:f={x:t.x+t.width,y:d};break;case ji:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?Zl(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case An:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ga:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Aa(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=i===void 0?s.placement:i,o=e.strategy,c=o===void 0?s.strategy:o,d=e.boundary,f=d===void 0?xm:d,p=e.rootBoundary,g=p===void 0?uu:p,v=e.elementContext,A=v===void 0?ma:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,x=Au(typeof C!="number"?C:Eu(C,pa)),O=A===ma?Pm:ma,B=s.rects.popper,D=s.elements[T?O:A],V=d1(tn(D)?D:D.contextElement||As(s.elements.popper),f,g,c),$=Tn(s.elements.reference),z=Ru({reference:$,element:B,strategy:"absolute",placement:n}),it=tc(Object.assign({},B,z)),at=A===ma?it:$,J={top:V.top-at.top+x.top,bottom:at.bottom-V.bottom+x.bottom,left:V.left-at.left+x.left,right:at.right-V.right+x.right},wt=s.modifiersData.offset;if(A===ma&&wt){var vt=wt[n];Object.keys(J).forEach(function(Ot){var Gt=[lr,or].indexOf(Ot)>=0?1:-1,U=[Wi,or].indexOf(Ot)>=0?"y":"x";J[Ot]+=vt[U]*Gt})}return J}function u1(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?pu:f,g=kn(i),v=g?d?fu:fu.filter(function(T){return kn(T)===g}):pa,A=v.filter(function(T){return p.indexOf(T)>=0});A.length===0&&(A=v);var E=A.reduce(function(T,w){return T[w]=Aa(s,{placement:w,boundary:n,rootBoundary:o,padding:c})[Dr(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function f1(s){if(Dr(s)===Kl)return[];var t=bo(s);return[ku(s),t,ku(t)]}function p1(s){var t=s.state,e=s.options,i=s.name;if(!t.modifiersData[i]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,A=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,x=Dr(C),O=x===C,B=f||(O||!T?[bo(C)]:f1(C)),D=[C].concat(B).reduce(function(Nt,jt){return Nt.concat(Dr(jt)===Kl?u1(t,{placement:jt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):jt)},[]),V=t.rects.reference,$=t.rects.popper,z=new Map,it=!0,at=D[0],J=0;J<D.length;J++){var wt=D[J],vt=Dr(wt),Ot=kn(wt)===An,Gt=[Wi,or].indexOf(vt)>=0,U=Gt?"width":"height",q=Aa(t,{placement:wt,boundary:g,rootBoundary:v,altBoundary:A,padding:p}),At=Gt?Ot?lr:ji:Ot?or:Wi;V[U]>$[U]&&(At=bo(At));var F=bo(At),N=[];if(o&&N.push(q[vt]<=0),d&&N.push(q[At]<=0,q[F]<=0),N.every(function(Nt){return Nt})){at=wt,it=!1;break}z.set(wt,N)}if(it)for(var j=T?3:1,nt=function(jt){var ue=D.find(function(me){var ge=z.get(me);if(ge)return ge.slice(0,jt).every(function(je){return je})});if(ue)return at=ue,"break"},ut=j;ut>0;ut--){var _t=nt(ut);if(_t==="break")break}t.placement!==at&&(t.modifiersData[i]._skip=!0,t.placement=at,t.reset=!0)}}const g1={name:"flip",enabled:!0,phase:"main",fn:p1,requiresIfExists:["offset"],data:{_skip:!1}};function Lu(s,t,e){return e===void 0&&(e={x:0,y:0}),{top:s.top-t.height-e.y,right:s.right-t.width+e.x,bottom:s.bottom-t.height+e.y,left:s.left-t.width-e.x}}function _u(s){return[Wi,lr,or,ji].some(function(t){return s[t]>=0})}function m1(s){var t=s.state,e=s.name,i=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,c=Aa(t,{elementContext:"reference"}),d=Aa(t,{altBoundary:!0}),f=Lu(c,i),p=Lu(d,n,o),g=_u(f),v=_u(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 v1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:m1};function y1(s,t,e){var i=Dr(s),n=[ji,Wi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:s})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*n,[ji,lr].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function b1(s){var t=s.state,e=s.options,i=s.name,n=e.offset,o=n===void 0?[0,0]:n,c=pu.reduce(function(g,v){return g[v]=y1(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 A1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:b1};function E1(s){var t=s.state,e=s.name;t.modifiersData[e]=Ru({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const T1={name:"popperOffsets",enabled:!0,phase:"read",fn:E1,data:{}};function k1(s){return s==="x"?"y":"x"}function w1(s){var t=s.state,e=s.options,i=s.name,n=e.mainAxis,o=n===void 0?!0:n,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,A=e.tether,E=A===void 0?!0:A,T=e.tetherOffset,w=T===void 0?0:T,C=Aa(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),x=Dr(t.placement),O=kn(t.placement),B=!O,D=Zl(x),V=k1(D),$=t.modifiersData.popperOffsets,z=t.rects.reference,it=t.rects.popper,at=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof at=="number"?{mainAxis:at,altAxis:at}:Object.assign({mainAxis:0,altAxis:0},at),wt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,vt={x:0,y:0};if($){if(o){var Ot,Gt=D==="y"?Wi:ji,U=D==="y"?or:lr,q=D==="y"?"height":"width",At=$[D],F=At+C[Gt],N=At-C[U],j=E?-it[q]/2:0,nt=O===An?z[q]:it[q],ut=O===An?-it[q]:-z[q],_t=t.elements.arrow,Nt=E&&_t?Xl(_t):{width:0,height:0},jt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:bu(),ue=jt[Gt],me=jt[U],ge=ya(0,z[q],Nt[q]),je=B?z[q]/2-j-ge-ue-J.mainAxis:nt-ge-ue-J.mainAxis,Re=B?-z[q]/2+j+ge+me+J.mainAxis:ut+ge+me+J.mainAxis,Kt=t.elements.arrow&&va(t.elements.arrow),be=Kt?D==="y"?Kt.clientTop||0:Kt.clientLeft||0:0,he=(Ot=wt==null?void 0:wt[D])!=null?Ot:0,Pe=At+je-he-be,Ut=At+Re-he,Ke=ya(E?mo(F,Pe):F,At,E?en(N,Ut):N);$[D]=Ke,vt[D]=Ke-At}if(d){var Fe,Ge=D==="x"?Wi:ji,ke=D==="x"?or:lr,de=$[V],ze=V==="y"?"height":"width",oe=de+C[Ge],Ne=de-C[ke],Ue=[Wi,ji].indexOf(x)!==-1,di=(Fe=wt==null?void 0:wt[V])!=null?Fe:0,Oe=Ue?oe:de-z[ze]-it[ze]-di+J.altAxis,xi=Ue?de+z[ze]+it[ze]-di-J.altAxis:Ne,ss=E&&Ue?Ym(Oe,de,xi):ya(E?Oe:oe,de,E?xi:Ne);$[V]=ss,vt[V]=ss-de}t.modifiersData[i]=vt}}const S1={name:"preventOverflow",enabled:!0,phase:"main",fn:w1,requiresIfExists:["offset"]};function R1(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function L1(s){return s===ir(s)||!cr(s)?ql(s):R1(s)}function _1(s){var t=s.getBoundingClientRect(),e=En(t.width)/s.offsetWidth||1,i=En(t.height)/s.offsetHeight||1;return e!==1||i!==1}function C1(s,t,e){e===void 0&&(e=!1);var i=cr(t),n=cr(t)&&_1(t),o=As(t),c=Tn(s,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Ir(t)!=="body"||Jl(o))&&(d=L1(t)),cr(t)?(f=Tn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=Ql(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function I1(s){var t=new Map,e=new Set,i=[];s.forEach(function(o){t.set(o.name,o)});function n(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&&n(f)}}),i.push(o)}return s.forEach(function(o){e.has(o.name)||n(o)}),i}function D1(s){var t=I1(s);return Hm.reduce(function(e,i){return e.concat(t.filter(function(n){return n.phase===i}))},[])}function x1(s){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(s())})})),t}}function P1(s){var t=s.reduce(function(e,i){var n=e[i.name];return e[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var Cu={placement:"bottom",modifiers:[],strategy:"absolute"};function Iu(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function O1(s){s===void 0&&(s={});var t=s,e=t.defaultModifiers,i=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?Cu:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},Cu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],A=!1,E={state:g,setOptions:function(x){var O=typeof x=="function"?x(g.options):x;w(),g.options=Object.assign({},o,g.options,O),g.scrollParents={reference:tn(d)?ba(d):d.contextElement?ba(d.contextElement):[],popper:ba(f)};var B=D1(P1([].concat(i,g.options.modifiers)));return g.orderedModifiers=B.filter(function(D){return D.enabled}),T(),E.update()},forceUpdate:function(){if(!A){var x=g.elements,O=x.reference,B=x.popper;if(Iu(O,B)){g.rects={reference:C1(O,va(B),g.options.strategy==="fixed"),popper:Xl(B)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var D=0;D<g.orderedModifiers.length;D++){if(g.reset===!0){g.reset=!1,D=-1;continue}var V=g.orderedModifiers[D],$=V.fn,z=V.options,it=z===void 0?{}:z,at=V.name;typeof $=="function"&&(g=$({state:g,options:it,name:at,instance:E})||g)}}}},update:x1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),A=!0}};if(!Iu(d,f))return E;E.setOptions(p).then(function(C){!A&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var x=C.name,O=C.options,B=O===void 0?{}:O,D=C.effect;if(typeof D=="function"){var V=D({state:g,name:x,instance:E,options:B}),$=function(){};v.push(V||$)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var M1=[s1,T1,i1,gu,A1,g1,S1,Qm,v1],$1=O1({defaultModifiers:M1}),F1="tippy-box",Du="tippy-content",N1="tippy-backdrop",xu="tippy-arrow",Pu="tippy-svg-arrow",rn={passive:!0,capture:!0},Ou=function(){return document.body};function ec(s,t,e){if(Array.isArray(s)){var i=s[t];return i??(Array.isArray(e)?e[t]:e)}return s}function ic(s,t){var e={}.toString.call(s);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Mu(s,t){return typeof s=="function"?s.apply(void 0,t):s}function $u(s,t){if(t===0)return s;var e;return function(i){clearTimeout(e),e=setTimeout(function(){s(i)},t)}}function U1(s){return s.split(/\s+/).filter(Boolean)}function wn(s){return[].concat(s)}function Fu(s,t){s.indexOf(t)===-1&&s.push(t)}function B1(s){return s.filter(function(t,e){return s.indexOf(t)===e})}function G1(s){return s.split("-")[0]}function Ao(s){return[].slice.call(s)}function Nu(s){return Object.keys(s).reduce(function(t,e){return s[e]!==void 0&&(t[e]=s[e]),t},{})}function Ea(){return document.createElement("div")}function Eo(s){return["Element","Fragment"].some(function(t){return ic(s,t)})}function V1(s){return ic(s,"NodeList")}function H1(s){return ic(s,"MouseEvent")}function W1(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function j1(s){return Eo(s)?[s]:V1(s)?Ao(s):Array.isArray(s)?s:Ao(document.querySelectorAll(s))}function rc(s,t){s.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Uu(s,t){s.forEach(function(e){e&&e.setAttribute("data-state",t)})}function K1(s){var t,e=wn(s),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function z1(s,t){var e=t.clientX,i=t.clientY;return s.every(function(n){var o=n.popperRect,c=n.popperState,d=n.props,f=d.interactiveBorder,p=G1(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,E=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-i+v>f,C=i-o.bottom-A>f,x=o.left-e+E>f,O=e-o.right-T>f;return w||C||x||O})}function sc(s,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){s[i](n,e)})}function Bu(s,t){for(var e=t;e;){var i;if(s.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var xr={isTouch:!1},Gu=0;function Y1(){xr.isTouch||(xr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Vu))}function Vu(){var s=performance.now();s-Gu<20&&(xr.isTouch=!1,document.removeEventListener("mousemove",Vu)),Gu=s}function X1(){var s=document.activeElement;if(W1(s)){var t=s._tippy;s.blur&&!t.state.isVisible&&s.blur()}}function Z1(){document.addEventListener("touchstart",Y1,rn),window.addEventListener("blur",X1)}var q1=typeof window<"u"&&typeof document<"u",Q1=q1?!!window.msCrypto:!1,J1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},tv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},br=Object.assign({appendTo:Ou,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},J1,tv),ev=Object.keys(br),iv=function(t){var e=Object.keys(t);e.forEach(function(i){br[i]=t[i]})};function Hu(s){var t=s.plugins||[],e=t.reduce(function(i,n){var o=n.name,c=n.defaultValue;if(o){var d;i[o]=s[o]!==void 0?s[o]:(d=br[o])!=null?d:c}return i},{});return Object.assign({},s,e)}function rv(s,t){var e=t?Object.keys(Hu(Object.assign({},br,{plugins:t}))):ev,i=e.reduce(function(n,o){var c=(s.getAttribute("data-tippy-"+o)||"").trim();if(!c)return n;if(o==="content")n[o]=c;else try{n[o]=JSON.parse(c)}catch{n[o]=c}return n},{});return i}function Wu(s,t){var e=Object.assign({},t,{content:Mu(t.content,[s])},t.ignoreAttributes?{}:rv(s,t.plugins));return e.aria=Object.assign({},br.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 sv=function(){return"innerHTML"};function nc(s,t){s[sv()]=t}function ju(s){var t=Ea();return s===!0?t.className=xu:(t.className=Pu,Eo(s)?t.appendChild(s):nc(t,s)),t}function Ku(s,t){Eo(t.content)?(nc(s,""),s.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?nc(s,t.content):s.textContent=t.content)}function ac(s){var t=s.firstElementChild,e=Ao(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Du)}),arrow:e.find(function(i){return i.classList.contains(xu)||i.classList.contains(Pu)}),backdrop:e.find(function(i){return i.classList.contains(N1)})}}function zu(s){var t=Ea(),e=Ea();e.className=F1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ea();i.className=Du,i.setAttribute("data-state","hidden"),Ku(i,s.props),t.appendChild(e),e.appendChild(i),n(s.props,s.props);function n(o,c){var d=ac(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)&&Ku(p,s.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(ju(c.arrow))):f.appendChild(ju(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}zu.$$tippy=!0;var nv=1,To=[],oc=[];function av(s,t){var e=Wu(s,Object.assign({},br,Hu(Nu(t)))),i,n,o,c=!1,d=!1,f=!1,p=!1,g,v,A,E=[],T=$u(Pe,e.interactiveDebounce),w,C=nv++,x=null,O=B1(e.plugins),B={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},D={id:C,reference:s,popper:Ea(),popperInstance:x,props:e,state:B,plugins:O,clearDelayTimeouts:Oe,setProps:xi,setContent:ss,show:ui,hide:kr,hideWithInteractivity:Ls,enable:Ue,disable:di,unmount:_s,destroy:rr};if(!e.render)return D;var V=e.render(D),$=V.popper,z=V.onUpdate;$.setAttribute("data-tippy-root",""),$.id="tippy-"+D.id,D.popper=$,s._tippy=D,$._tippy=D;var it=O.map(function(ht){return ht.fn(D)}),at=s.hasAttribute("aria-expanded");return Kt(),j(),At(),F("onCreate",[D]),e.showOnCreate&&oe(),$.addEventListener("mouseenter",function(){D.props.interactive&&D.state.isVisible&&D.clearDelayTimeouts()}),$.addEventListener("mouseleave",function(){D.props.interactive&&D.props.trigger.indexOf("mouseenter")>=0&&Gt().addEventListener("mousemove",T)}),D;function J(){var ht=D.props.touch;return Array.isArray(ht)?ht:[ht,0]}function wt(){return J()[0]==="hold"}function vt(){var ht;return!!((ht=D.props.render)!=null&&ht.$$tippy)}function Ot(){return w||s}function Gt(){var ht=Ot().parentNode;return ht?K1(ht):document}function U(){return ac($)}function q(ht){return D.state.isMounted&&!D.state.isVisible||xr.isTouch||g&&g.type==="focus"?0:ec(D.props.delay,ht?0:1,br.delay)}function At(ht){ht===void 0&&(ht=!1),$.style.pointerEvents=D.props.interactive&&!ht?"":"none",$.style.zIndex=""+D.props.zIndex}function F(ht,Vt,Xt){if(Xt===void 0&&(Xt=!0),it.forEach(function(se){se[ht]&&se[ht].apply(se,Vt)}),Xt){var ve;(ve=D.props)[ht].apply(ve,Vt)}}function N(){var ht=D.props.aria;if(ht.content){var Vt="aria-"+ht.content,Xt=$.id,ve=wn(D.props.triggerTarget||s);ve.forEach(function(se){var li=se.getAttribute(Vt);if(D.state.isVisible)se.setAttribute(Vt,li?li+" "+Xt:Xt);else{var Pi=li&&li.replace(Xt,"").trim();Pi?se.setAttribute(Vt,Pi):se.removeAttribute(Vt)}})}}function j(){if(!(at||!D.props.aria.expanded)){var ht=wn(D.props.triggerTarget||s);ht.forEach(function(Vt){D.props.interactive?Vt.setAttribute("aria-expanded",D.state.isVisible&&Vt===Ot()?"true":"false"):Vt.removeAttribute("aria-expanded")})}}function nt(){Gt().removeEventListener("mousemove",T),To=To.filter(function(ht){return ht!==T})}function ut(ht){if(!(xr.isTouch&&(f||ht.type==="mousedown"))){var Vt=ht.composedPath&&ht.composedPath()[0]||ht.target;if(!(D.props.interactive&&Bu($,Vt))){if(wn(D.props.triggerTarget||s).some(function(Xt){return Bu(Xt,Vt)})){if(xr.isTouch||D.state.isVisible&&D.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[D,ht]);D.props.hideOnClick===!0&&(D.clearDelayTimeouts(),D.hide(),d=!0,setTimeout(function(){d=!1}),D.state.isMounted||ue())}}}function _t(){f=!0}function Nt(){f=!1}function jt(){var ht=Gt();ht.addEventListener("mousedown",ut,!0),ht.addEventListener("touchend",ut,rn),ht.addEventListener("touchstart",Nt,rn),ht.addEventListener("touchmove",_t,rn)}function ue(){var ht=Gt();ht.removeEventListener("mousedown",ut,!0),ht.removeEventListener("touchend",ut,rn),ht.removeEventListener("touchstart",Nt,rn),ht.removeEventListener("touchmove",_t,rn)}function me(ht,Vt){je(ht,function(){!D.state.isVisible&&$.parentNode&&$.parentNode.contains($)&&Vt()})}function ge(ht,Vt){je(ht,Vt)}function je(ht,Vt){var Xt=U().box;function ve(se){se.target===Xt&&(sc(Xt,"remove",ve),Vt())}if(ht===0)return Vt();sc(Xt,"remove",v),sc(Xt,"add",ve),v=ve}function Re(ht,Vt,Xt){Xt===void 0&&(Xt=!1);var ve=wn(D.props.triggerTarget||s);ve.forEach(function(se){se.addEventListener(ht,Vt,Xt),E.push({node:se,eventType:ht,handler:Vt,options:Xt})})}function Kt(){wt()&&(Re("touchstart",he,{passive:!0}),Re("touchend",Ut,{passive:!0})),U1(D.props.trigger).forEach(function(ht){if(ht!=="manual")switch(Re(ht,he),ht){case"mouseenter":Re("mouseleave",Ut);break;case"focus":Re(Q1?"focusout":"blur",Ke);break;case"focusin":Re("focusout",Ke);break}})}function be(){E.forEach(function(ht){var Vt=ht.node,Xt=ht.eventType,ve=ht.handler,se=ht.options;Vt.removeEventListener(Xt,ve,se)}),E=[]}function he(ht){var Vt,Xt=!1;if(!(!D.state.isEnabled||Fe(ht)||d)){var ve=((Vt=g)==null?void 0:Vt.type)==="focus";g=ht,w=ht.currentTarget,j(),!D.state.isVisible&&H1(ht)&&To.forEach(function(se){return se(ht)}),ht.type==="click"&&(D.props.trigger.indexOf("mouseenter")<0||c)&&D.props.hideOnClick!==!1&&D.state.isVisible?Xt=!0:oe(ht),ht.type==="click"&&(c=!Xt),Xt&&!ve&&Ne(ht)}}function Pe(ht){var Vt=ht.target,Xt=Ot().contains(Vt)||$.contains(Vt);if(!(ht.type==="mousemove"&&Xt)){var ve=ze().concat($).map(function(se){var li,Pi=se._tippy,fr=(li=Pi.popperInstance)==null?void 0:li.state;return fr?{popperRect:se.getBoundingClientRect(),popperState:fr,props:e}:null}).filter(Boolean);z1(ve,ht)&&(nt(),Ne(ht))}}function Ut(ht){var Vt=Fe(ht)||D.props.trigger.indexOf("click")>=0&&c;if(!Vt){if(D.props.interactive){D.hideWithInteractivity(ht);return}Ne(ht)}}function Ke(ht){D.props.trigger.indexOf("focusin")<0&&ht.target!==Ot()||D.props.interactive&&ht.relatedTarget&&$.contains(ht.relatedTarget)||Ne(ht)}function Fe(ht){return xr.isTouch?wt()!==ht.type.indexOf("touch")>=0:!1}function Ge(){ke();var ht=D.props,Vt=ht.popperOptions,Xt=ht.placement,ve=ht.offset,se=ht.getReferenceClientRect,li=ht.moveTransition,Pi=vt()?ac($).arrow:null,fr=se?{getBoundingClientRect:se,contextElement:se.contextElement||Ot()}:s,ns={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Cs){var Oi=Cs.state;if(vt()){var Pa=U(),mr=Pa.box;["placement","reference-hidden","escaped"].forEach(function(Is){Is==="placement"?mr.setAttribute("data-placement",Oi.placement):Oi.attributes.popper["data-popper-"+Is]?mr.setAttribute("data-"+Is,""):mr.removeAttribute("data-"+Is)}),Oi.attributes.popper={}}}},pr=[{name:"offset",options:{offset:ve}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!li}},ns];vt()&&Pi&&pr.push({name:"arrow",options:{element:Pi,padding:3}}),pr.push.apply(pr,(Vt==null?void 0:Vt.modifiers)||[]),D.popperInstance=$1(fr,$,Object.assign({},Vt,{placement:Xt,onFirstUpdate:A,modifiers:pr}))}function ke(){D.popperInstance&&(D.popperInstance.destroy(),D.popperInstance=null)}function de(){var ht=D.props.appendTo,Vt,Xt=Ot();D.props.interactive&&ht===Ou||ht==="parent"?Vt=Xt.parentNode:Vt=Mu(ht,[Xt]),Vt.contains($)||Vt.appendChild($),D.state.isMounted=!0,Ge()}function ze(){return Ao($.querySelectorAll("[data-tippy-root]"))}function oe(ht){D.clearDelayTimeouts(),ht&&F("onTrigger",[D,ht]),jt();var Vt=q(!0),Xt=J(),ve=Xt[0],se=Xt[1];xr.isTouch&&ve==="hold"&&se&&(Vt=se),Vt?i=setTimeout(function(){D.show()},Vt):D.show()}function Ne(ht){if(D.clearDelayTimeouts(),F("onUntrigger",[D,ht]),!D.state.isVisible){ue();return}if(!(D.props.trigger.indexOf("mouseenter")>=0&&D.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ht.type)>=0&&c)){var Vt=q(!1);Vt?n=setTimeout(function(){D.state.isVisible&&D.hide()},Vt):o=requestAnimationFrame(function(){D.hide()})}}function Ue(){D.state.isEnabled=!0}function di(){D.hide(),D.state.isEnabled=!1}function Oe(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(o)}function xi(ht){if(!D.state.isDestroyed){F("onBeforeUpdate",[D,ht]),be();var Vt=D.props,Xt=Wu(s,Object.assign({},Vt,Nu(ht),{ignoreAttributes:!0}));D.props=Xt,Kt(),Vt.interactiveDebounce!==Xt.interactiveDebounce&&(nt(),T=$u(Pe,Xt.interactiveDebounce)),Vt.triggerTarget&&!Xt.triggerTarget?wn(Vt.triggerTarget).forEach(function(ve){ve.removeAttribute("aria-expanded")}):Xt.triggerTarget&&s.removeAttribute("aria-expanded"),j(),At(),z&&z(Vt,Xt),D.popperInstance&&(Ge(),ze().forEach(function(ve){requestAnimationFrame(ve._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[D,ht])}}function ss(ht){D.setProps({content:ht})}function ui(){var ht=D.state.isVisible,Vt=D.state.isDestroyed,Xt=!D.state.isEnabled,ve=xr.isTouch&&!D.props.touch,se=ec(D.props.duration,0,br.duration);if(!(ht||Vt||Xt||ve)&&!Ot().hasAttribute("disabled")&&(F("onShow",[D],!1),D.props.onShow(D)!==!1)){if(D.state.isVisible=!0,vt()&&($.style.visibility="visible"),At(),jt(),D.state.isMounted||($.style.transition="none"),vt()){var li=U(),Pi=li.box,fr=li.content;rc([Pi,fr],0)}A=function(){var pr;if(!(!D.state.isVisible||p)){if(p=!0,$.offsetHeight,$.style.transition=D.props.moveTransition,vt()&&D.props.animation){var gr=U(),Cs=gr.box,Oi=gr.content;rc([Cs,Oi],se),Uu([Cs,Oi],"visible")}N(),j(),Fu(oc,D),(pr=D.popperInstance)==null||pr.forceUpdate(),F("onMount",[D]),D.props.animation&&vt()&&ge(se,function(){D.state.isShown=!0,F("onShown",[D])})}},de()}}function kr(){var ht=!D.state.isVisible,Vt=D.state.isDestroyed,Xt=!D.state.isEnabled,ve=ec(D.props.duration,1,br.duration);if(!(ht||Vt||Xt)&&(F("onHide",[D],!1),D.props.onHide(D)!==!1)){if(D.state.isVisible=!1,D.state.isShown=!1,p=!1,c=!1,vt()&&($.style.visibility="hidden"),nt(),ue(),At(!0),vt()){var se=U(),li=se.box,Pi=se.content;D.props.animation&&(rc([li,Pi],ve),Uu([li,Pi],"hidden"))}N(),j(),D.props.animation?vt()&&me(ve,D.unmount):D.unmount()}}function Ls(ht){Gt().addEventListener("mousemove",T),Fu(To,T),T(ht)}function _s(){D.state.isVisible&&D.hide(),D.state.isMounted&&(ke(),ze().forEach(function(ht){ht._tippy.unmount()}),$.parentNode&&$.parentNode.removeChild($),oc=oc.filter(function(ht){return ht!==D}),D.state.isMounted=!1,F("onHidden",[D]))}function rr(){D.state.isDestroyed||(D.clearDelayTimeouts(),D.unmount(),be(),delete s._tippy,D.state.isDestroyed=!0,F("onDestroy",[D]))}}function sn(s,t){t===void 0&&(t={});var e=br.plugins.concat(t.plugins||[]);Z1();var i=Object.assign({},t,{plugins:e}),n=j1(s),o=n.reduce(function(c,d){var f=d&&av(d,i);return f&&c.push(f),c},[]);return Eo(s)?o[0]:o}sn.defaultProps=br,sn.setDefaultProps=iv,sn.currentInput=xr,Object.assign({},gu,{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:zu});class Qr extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const ov=5;class lv{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=Li(),this._controls=Li(),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,n,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-ov&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=ru((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var A;const E=d-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return g&&v&&E>=fo(g)&&E<=fo(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 _i(this._canvas)}controls(){return _i(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,n;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:A}=d,{start:E,duration:T}=f,w=this.host.videoState[g];A&&w&&(A.currentTime>=E+T||A.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,A.currentTime):w.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.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:n}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(n&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new Qr(`Video play error: ${d.message}`,!0)}}else n.paused||n.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 cv(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Yu={exports:{}};(function(s,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\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 E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var T=n.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(w.netLoc=E.netLoc,A.path[0]!=="/"))if(!A.path)w.path=E.path,A.params||(w.params=E.params,A.query||(w.query=E.query));else{var C=E.path,x=C.substring(0,C.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}};s.exports=d})()})(Yu);var lc=Yu.exports;function Xu(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Ki(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Xu(Object(e),!0).forEach(function(i){hv(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):Xu(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function hv(s,t,e){return t=uv(t),t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function ci(){return ci=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},ci.apply(this,arguments)}function dv(s,t){if(typeof s!="object"||s===null)return s;var e=s[Symbol.toPrimitive];if(e!==void 0){var i=e.call(s,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function uv(s){var t=dv(s,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),qt=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),pt=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({});const nn=function(){},cc={trace:nn,debug:nn,log:nn,warn:nn,info:nn,error:nn};let Ta=cc;function fv(s){const t=self.console[s];return t?t.bind(self.console,`[${s}] >`):nn}function pv(s,...t){t.forEach(function(e){Ta[e]=s[e]?s[e].bind(s):fv(e)})}function gv(s,t){if(self.console&&s===!0||typeof s=="object"){pv(s,"debug","log","info","warn","error");try{Ta.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{Ta=cc}}else Ta=cc}const X=Ta,mv=/^(\d+)x(\d+)$/,Zu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ti{constructor(t){typeof t=="string"&&(t=ti.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 n=0;n<e.length/2;n++)i[n]=parseInt(e.slice(n*2,n*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=mv.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},n='"';for(Zu.lastIndex=0;(e=Zu.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function vv(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function yv(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class qu{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 n in i)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==i[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=ci(new ti({}),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"]);Wt(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(Wt(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&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class ko{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 Qu{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),n=[];i.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n}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=lc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class hc extends Qu{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 ko,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||!Wt(this.programDateTime))return null;const t=Wt(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,n,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:n,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,n),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 bv extends Qu{constructor(t,e,i,n,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 ko,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=n;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 Av=10;class Ev{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?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Av}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 dc(s){return Uint8Array.from(atob(s),t=>t.charCodeAt(0))}function Tv(s){const t=Ju(s).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function kv(s){const t=function(e,i,n){const o=e[i];e[i]=e[n],e[n]=o};t(s,0,3),t(s,1,2),t(s,4,5),t(s,6,7)}function wv(s){const t=s.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const o=n[0]==="base64",c=n[1];o?(i.splice(-1,1),e=dc(c)):e=Tv(c)}}return e}function Ju(s){return Uint8Array.from(unescape(encodeURIComponent(s)),t=>t.charCodeAt(0))}var ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},zi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function t0(s){switch(s){case zi.FAIRPLAY:return ei.FAIRPLAY;case zi.PLAYREADY:return ei.PLAYREADY;case zi.WIDEVINE:return ei.WIDEVINE;case zi.CLEARKEY:return ei.CLEARKEY}}var e0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Sv(s){if(s===e0.WIDEVINE)return ei.WIDEVINE}function i0(s){switch(s){case ei.FAIRPLAY:return zi.FAIRPLAY;case ei.PLAYREADY:return zi.PLAYREADY;case ei.WIDEVINE:return zi.WIDEVINE;case ei.CLEARKEY:return zi.CLEARKEY}}function uc(s){const{drmSystems:t,widevineLicenseUrl:e}=s,i=t?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!t[n]):[];return!i[ei.WIDEVINE]&&e&&i.push(ei.WIDEVINE),i}const r0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Rv(s,t,e,i){let n;switch(s){case ei.FAIRPLAY:n=["cenc","sinf"];break;case ei.WIDEVINE:case ei.PLAYREADY:n=["cenc"];break;case ei.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return Lv(n,t,e,i)}function Lv(s,t,e,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function an(s,t,e){return Uint8Array.prototype.slice?s.slice(t,e):new Uint8Array(Array.prototype.slice.call(s,t,e))}const fc=(s,t)=>t+10<=s.length&&s[t]===73&&s[t+1]===68&&s[t+2]===51&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,s0=(s,t)=>t+10<=s.length&&s[t]===51&&s[t+1]===68&&s[t+2]===73&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,wo=(s,t)=>{const e=t;let i=0;for(;fc(s,t);){i+=10;const n=So(s,t+6);i+=n,s0(s,t+10)&&(i+=10),t+=i}if(i>0)return s.subarray(e,e+i)},So=(s,t)=>{let e=0;return e=(s[t]&127)<<21,e|=(s[t+1]&127)<<14,e|=(s[t+2]&127)<<7,e|=s[t+3]&127,e},_v=(s,t)=>fc(s,t)&&So(s,t+6)+10<=s.length-t,Cv=s=>{const t=a0(s);for(let e=0;e<t.length;e++){const i=t[e];if(n0(i))return Mv(i)}},n0=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Iv=s=>{const t=String.fromCharCode(s[0],s[1],s[2],s[3]),e=So(s,4),i=10;return{type:t,size:e,data:s.subarray(i,i+e)}},a0=s=>{let t=0;const e=[];for(;fc(s,t);){const i=So(s,t+6);t+=10;const n=t+i;for(;t+8<n;){const o=Iv(s.subarray(t)),c=Dv(o);c&&e.push(c),t+=o.size+10}s0(s,t)&&(t+=10)}return e},Dv=s=>s.type==="PRIV"?xv(s):s.type[0]==="W"?Ov(s):Pv(s),xv=s=>{if(s.size<2)return;const t=Pr(s.data,!0),e=new Uint8Array(s.data.subarray(t.length+1));return{key:s.type,info:t,data:e.buffer}},Pv=s=>{if(s.size<2)return;if(s.type==="TXXX"){let e=1;const i=Pr(s.data.subarray(e),!0);e+=i.length+1;const n=Pr(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Pr(s.data.subarray(1));return{key:s.type,data:t}},Ov=s=>{if(s.type==="WXXX"){if(s.size<2)return;let e=1;const i=Pr(s.data.subarray(e),!0);e+=i.length+1;const n=Pr(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Pr(s.data);return{key:s.type,data:t}},Mv=s=>{if(s.data.byteLength===8){const t=new Uint8Array(s.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=(s,t=!1)=>{const e=$v();if(e){const p=e.decode(s);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=s.length;let n,o,c,d="",f=0;for(;f<i;){if(n=s[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=s[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=s[f++],c=s[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let pc;function $v(){return!pc&&typeof self.TextDecoder<"u"&&(pc=new self.TextDecoder("utf-8")),pc}const Or={hexDump:function(s){let t="";for(let e=0;e<s.length;e++){let i=s[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},Ro=Math.pow(2,32)-1,Fv=[].push,o0={video:1,audio:2,id3:3,text:4};function wi(s){return String.fromCharCode.apply(null,s)}function l0(s,t){const e=s[t]<<8|s[t+1];return e<0?65536+e:e}function ee(s,t){const e=c0(s,t);return e<0?4294967296+e:e}function c0(s,t){return s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3]}function gc(s,t,e){s[t]=e>>24,s[t+1]=e>>16&255,s[t+2]=e>>8&255,s[t+3]=e&255}function ye(s,t){const e=[];if(!t.length)return e;const i=s.byteLength;for(let n=0;n<i;){const o=ee(s,n),c=wi(s.subarray(n+4,n+8)),d=o>1?n+o:i;if(c===t[0])if(t.length===1)e.push(s.subarray(n+8,d));else{const f=ye(s.subarray(n+8,d),t.slice(1));f.length&&Fv.apply(e,f)}n=d}return e}function Nv(s){const t=[],e=s[0];let i=8;const n=ee(s,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=s.length+c;const f=l0(s,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(s,g);g+=4;const A=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(s,g);g+=4,t.push({referenceSize:A,subsegmentDuration:E,info:{duration:E/n,start:d,end:d+A-1}}),d+=A,g+=4,i=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function h0(s){const t=[],e=ye(s,["moov","trak"]);for(let i=0;i<e.length;i++){const n=e[i],o=ye(n,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ee(o,d),p=ye(n,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ee(p,d),v=ye(n,["mdia","hdlr"])[0];if(v){const A=wi(v.subarray(8,12)),E={soun:Ce.AUDIO,vide:Ce.VIDEO}[A];if(E){const T=ye(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=wi(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return ye(s,["moov","mvex","trex"]).forEach(i=>{const n=ee(i,4),o=t[n];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function Uv(s,t){if(!s||!t)return s;const e=t.keyId;return e&&t.isCommonEncryption&&ye(s,["moov","trak"]).forEach(i=>{const n=ye(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=ye(n,["enca"]);const c=o.length>0;c||(o=ye(n,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);ye(f,["sinf"]).forEach(p=>{const g=d0(p);if(g){const v=g.subarray(8,24);v.some(A=>A!==0)||(X.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Or.hexDump(v)} -> ${Or.hexDump(e)}`),g.set(e,8))}})})}),s}function d0(s){const t=ye(s,["schm"])[0];if(t){const e=wi(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ye(s,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function Bv(s,t){return ye(t,["moof","traf"]).reduce((e,i)=>{const n=ye(i,["tfdt"])[0],o=n[0],c=ye(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=s[p];if(g){let v=ee(n,4);if(o===1){if(v===Ro)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=Ro+1,v+=ee(n,8)}const A=g.timescale||9e4,E=v/A;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 Gv(s,t){let e=0,i=0,n=0;const o=ye(s,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=ye(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,A=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;A&8&&(A&2?E=ee(f,12):E=ee(f,8));const T=g.timescale||9e4,w=ye(d,["trun"]);for(let C=0;C<w.length;C++){if(e=Vv(w[C]),!e&&E){const x=ee(w[C],4);e=E*x}g.type===Ce.VIDEO?i+=e/T:g.type===Ce.AUDIO&&(n+=e/T)}}if(i===0&&n===0){let c=0;const d=ye(s,["sidx"]);for(let f=0;f<d.length;f++){const p=Nv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||n}function Vv(s){const t=ee(s,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const n=ee(s,4);for(let o=0;o<n;o++){if(t&256){const c=ee(s,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function Hv(s,t,e){ye(t,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(n=>{const o=ee(n,4),c=s[o];if(!c)return;const d=c.timescale||9e4;ye(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),gc(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/(Ro+1)),A=Math.floor(g%(Ro+1));gc(f,4,v),gc(f,8,A)}})})})}function Wv(s){const t={valid:null,remainder:null},e=ye(s,["moof"]);if(e){if(e.length<2)return t.remainder=s,t}else return t;const i=e[e.length-1];return t.valid=an(s,0,i.byteOffset-8),t.remainder=an(s,i.byteOffset-8),t}function on(s,t){const e=new Uint8Array(s.length+t.length);return e.set(s),e.set(t,s.length),e}function u0(s,t){const e=[],i=t.samples,n=t.timescale,o=t.id;let c=!1;return ye(i,["moof"]).map(d=>{const f=d.byteOffset-8;ye(d,["traf"]).map(p=>{const g=ye(p,["tfdt"]).map(v=>{const A=v[0];let E=ee(v,4);return A===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/n})[0];return g!==void 0&&(s=g),ye(p,["tfhd"]).map(v=>{const A=ee(v,4),E=ee(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let x=0;const O=(E&16)!==0;let B=0;const D=(E&32)!==0;let V=8;A===o&&(T&&(V+=8),w&&(V+=4),C&&(x=ee(v,V),V+=4),O&&(B=ee(v,V),V+=4),D&&(V+=4),t.type==="video"&&(c=jv(t.codec)),ye(p,["trun"]).map($=>{const z=$[0],it=ee($,0)&16777215,at=(it&1)!==0;let J=0;const wt=(it&4)!==0,vt=(it&256)!==0;let Ot=0;const Gt=(it&512)!==0;let U=0;const q=(it&1024)!==0,At=(it&2048)!==0;let F=0;const N=ee($,4);let j=8;at&&(J=ee($,j),j+=4),wt&&(j+=4);let nt=J+f;for(let ut=0;ut<N;ut++){if(vt?(Ot=ee($,j),j+=4):Ot=x,Gt?(U=ee($,j),j+=4):U=B,q&&(j+=4),At&&(z===0?F=ee($,j):F=c0($,j),j+=4),t.type===Ce.VIDEO){let _t=0;for(;_t<U;){const Nt=ee(i,nt);if(nt+=4,Kv(c,i[nt])){const jt=i.subarray(nt,nt+Nt);f0(jt,c?2:1,s+F/n,e)}nt+=Nt,_t+=Nt+4}}s+=Ot/n}}))})})}),e}function jv(s){if(!s)return!1;const t=s.indexOf("."),e=t<0?s:s.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Kv(s,t){if(s){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function f0(s,t,e,i){const n=p0(s);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<n.length;){c=0;do{if(o>=n.length)break;p=n[o++],c+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&c===4&&o<n.length){if(f=!0,n[o++]===181){const v=l0(n,o);if(o+=2,v===49){const A=ee(n,o);if(o+=4,A===1195456820){const E=n[o++];if(E===3){const T=n[o++],w=31&T,C=64&T,x=C?2+w*3:0,O=new Uint8Array(x);if(C){O[0]=T;for(let B=1;B<x;B++)O[B]=n[o++]}i.push({type:E,payloadType:c,pts:e,bytes:O})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const A=d-16,E=new Uint8Array(A);for(let T=0;T<A;T++)E[T]=n[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 p0(s){const t=s.byteLength,e=[];let i=1;for(;i<t-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return s;const n=t-e.length,o=new Uint8Array(n);let c=0;for(i=0;i<n;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=s[c];return o}function zv(s){const t=s[0];let e="",i="",n=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;wi(s.subarray(p,p+1))!=="\0";)e+=wi(s.subarray(p,p+1)),p+=1;for(e+=wi(s.subarray(p,p+1)),p+=1;wi(s.subarray(p,p+1))!=="\0";)i+=wi(s.subarray(p,p+1)),p+=1;i+=wi(s.subarray(p,p+1)),p+=1,n=ee(s,12),o=ee(s,16),d=ee(s,20),f=ee(s,24),p=28}else if(t===1){p+=4,n=ee(s,p),p+=4;const v=ee(s,p);p+=4;const A=ee(s,p);for(p+=4,c=4294967296*v+A,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(s,p),p+=4,f=ee(s,p),p+=4;wi(s.subarray(p,p+1))!=="\0";)e+=wi(s.subarray(p,p+1)),p+=1;for(e+=wi(s.subarray(p,p+1)),p+=1;wi(s.subarray(p,p+1))!=="\0";)i+=wi(s.subarray(p,p+1)),p+=1;i+=wi(s.subarray(p,p+1)),p+=1}const g=s.subarray(p,s.byteLength);return{schemeIdUri:e,value:i,timeScale:n,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Yv(s,...t){const e=t.length;let i=8,n=e;for(;n--;)i+=t[n].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(s,4),n=0,i=8;n<e;n++)o.set(t[n],i),i+=t[n].byteLength;return o}function Xv(s,t,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(t){i=1,n=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");n.set(f,d*16)}}else i=0,n=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),Yv([112,115,115,104],new Uint8Array([i,0,0,0]),s,o,n,c,e||new Uint8Array)}function Zv(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(s),i=e.getUint32(0);if(s.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(s,12,16));const n=e.getUint32(28);if(t.version===0){if(i-32<n)return null;t.data=new Uint8Array(s,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(s,32+o*16,16))}return t}let Lo={};class ka{static clearKeyUriToKeyIdMap(){Lo={}}constructor(t,e,i,n=[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=n,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 zi.FAIRPLAY:case zi.WIDEVINE:case zi.PLAYREADY:case zi.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&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=qv(t);return new ka(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=wv(this.uri);if(e)switch(this.keyFormat){case zi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case zi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Xv(i,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),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=dc(f).subarray(0,16);kv(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const n=new Uint8Array(16);n.set(i,16-i.length),i=n}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Lo[this.uri];if(!i){const n=Object.keys(Lo).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),Lo[this.uri]=i}this.keyId=i}return this}}function qv(s){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=s>>8*(15-e)&255;return t}const g0=/\{\$([a-zA-Z0-9-_]+)\}/g;function m0(s){return g0.test(s)}function Yi(s,t,e){if(s.variableList!==null||s.hasVariableRefs)for(let i=e.length;i--;){const n=e[i],o=t[n];o&&(t[n]=mc(s,o))}}function mc(s,t){if(s.variableList!==null||s.hasVariableRefs){const e=s.variableList;return t.replace(g0,i=>{const n=i.substring(2,i.length-1),o=e==null?void 0:e[n];return o===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):o})}return t}function v0(s,t,e){let i=s.variableList;i||(s.variableList=i={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(n))o=c.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(c){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else n=t.NAME,o=t.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=o||""}function Qv(s,t,e){const i=t.IMPORT;if(e&&i in e){let n=s.variableList;n||(s.variableList=n={}),n[i]=e[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function _o(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Jv={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}},y0=_o();function ty(s,t){const e=Jv[t];return!!e&&e[s.slice(0,4)]===!0}function vc(s,t){var e;return(e=y0==null?void 0:y0.isTypeSupported(`${t||"video"}/mp4;codecs="${s}"`))!=null?e:!1}const b0=/#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,A0=/#EXT-X-MEDIA:(.*)/g,ey=/^#EXT(?:INF|-X-TARGETDURATION):/m,E0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),iy=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 Ar{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}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 lc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return ey.test(t)}static parseMasterPlaylist(t,e){const i=m0(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];b0.lastIndex=0;let c;for(;(c=b0.exec(t))!=null;)if(c[1]){var d;const p=new ti(c[1]);Yi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=mc(n,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:Ar.resolve(g,e)},A=p.decimalResolution("RESOLUTION");A&&(v.width=A.width,v.height=A.height),ry((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=Ar.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ti(g);Yi(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=v["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=v);break}case"SESSION-KEY":{const v=T0(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ti(g);Yi(n,v,["NAME","VALUE","QUERYPARAM"]),v0(n,v,e)}break}case"CONTENT-STEERING":{const v=new ti(g);Yi(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Ar.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=k0(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,i){let n;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(A0.lastIndex=0;(n=A0.exec(t))!==null;){const p=new ti(n[1]),g=p.TYPE;if(g){const v=d[g],A=o[g]||[];o[g]=A,Yi(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?Ar.resolve(p.URI,e):""};if(v!=null&&v.length){const T=Ar.findGroup(v,E.groupId)||v[0];w0(E,T,"audioCodec"),w0(E,T,"textCodec")}A.push(E)}}return o}static parseLevelPlaylist(t,e,i,n,o,c){const d=new Ev(e),f=d.fragments;let p=null,g=0,v=0,A=0,E=0,T=null,w=new hc(n,e),C,x,O,B=-1,D=!1;for(E0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=m0(t);(C=E0.exec(t))!==null;){D&&(D=!1,w=new hc(n,e),w.start=A,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const it=C[1];if(it){w.duration=parseFloat(it);const at=(" "+C[2]).slice(1);w.title=at||null,w.tagList.push(at?["INF",it,at]:["INF",it])}else if(C[3]){if(Wt(w.duration)){w.start=A,O&&L0(w,O,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const at=(" "+C[3]).slice(1);w.relurl=mc(d,at),S0(w,T),T=w,A+=w.duration,g++,v=0,D=!0}}else if(C[4]){const at=(" "+C[4]).slice(1);T?w.setByteRange(at,T):w.setByteRange(at)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),B===-1&&(B=f.length);else{if(C=C[0].match(iy),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<C.length&&!(typeof C[x]<"u");x++);const at=(" "+C[x]).slice(1),J=(" "+C[x+1]).slice(1),wt=C[x+2]?(" "+C[x+2]).slice(1):"";switch(at){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const vt=new ti(J);Yi(d,vt,["RECENTLY-REMOVED-DATERANGES"]);const Ot=vt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Ot)){d.skippedSegments=Ot;for(let U=Ot;U--;)f.unshift(null);g+=Ot}const Gt=vt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Gt&&(d.recentlyRemovedDateranges=Gt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||wt)&&w.tagList.push(wt?[J,wt]:[J]);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,J]);break;case"DATERANGE":{const vt=new ti(J);Yi(d,vt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Yi(d,vt,vt.clientAttrs);const Ot=new qu(vt,d.dateRanges[vt.ID]);Ot.isValid||d.skippedSegments?d.dateRanges[Ot.id]=Ot:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const vt=new ti(J);Yi(d,vt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in vt?Qv(d,vt,c):v0(d,vt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(J);break;case"KEY":{const vt=T0(J,e,d);if(vt.isSupported()){if(vt.method==="NONE"){O=void 0;break}O||(O={}),O[vt.keyFormat]&&(O=ci({},O)),O[vt.keyFormat]=vt}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=k0(J);break;case"MAP":{const vt=new ti(J);if(Yi(d,vt,["BYTERANGE","URI"]),w.duration){const Ot=new hc(n,e);R0(Ot,vt,i,O),p=Ot,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else R0(w,vt,i,O),p=w,D=!0;break}case"SERVER-CONTROL":{const vt=new ti(J);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 ti(J);d.partTarget=vt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let vt=d.partList;vt||(vt=d.partList=[]);const Ot=v>0?vt[vt.length-1]:void 0,Gt=v++,U=new ti(J);Yi(d,U,["BYTERANGE","URI"]);const q=new bv(U,w,e,Gt,Ot);vt.push(q),w.duration+=q.duration;break}case"PRELOAD-HINT":{const vt=new ti(J);Yi(d,vt,["URI"]),d.preloadHint=vt;break}case"RENDITION-REPORT":{const vt=new ti(J);Yi(d,vt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(vt);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),A-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(S0(w,T),w.cc=E,d.fragmentHint=w,O&&L0(w,O,d));const V=f.length,$=f[0],z=f[V-1];if(A+=d.skippedSegments*d.targetduration,A>0&&V&&z){d.averagetargetduration=A/V;const it=z.sn;d.endSN=it!=="initSegment"?it:0,d.live||(z.endList=!0),$&&(d.startCC=$.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(A+=d.fragmentHint.duration),d.totalduration=A,d.endCC=E,B>0&&sy(f,B),d}}function T0(s,t,e){var i,n;const o=new ti(s);Yi(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=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?Ar.resolve(d,t):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new ka(c,v,g,A,f)}function k0(s){const t=new ti(s).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function ry(s,t){["video","audio","text"].forEach(e=>{const i=s.filter(n=>ty(n,e));if(i.length){const n=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:i[0],s=s.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=s}function w0(s,t,e){const i=t[e];i&&(s[e]=i)}function sy(s,t){let e=s[t];for(let i=t;i--;){const n=s[i];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function S0(s,t){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):t!=null&&t.programDateTime&&(s.programDateTime=t.endProgramDateTime),Wt(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function R0(s,t,e,i){s.relurl=t.URI,t.BYTERANGE&&s.setByteRange(t.BYTERANGE),s.level=e,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function L0(s,t,e){s.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&i.push(s)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Qt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function _0(s){const{type:t}=s;switch(t){case Te.AUDIO_TRACK:return Qt.AUDIO;case Te.SUBTITLE_TRACK:return Qt.SUBTITLE;default:return Qt.MAIN}}function yc(s,t){let e=s.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class ny{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,n=e.loader,o=i||n,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:Te.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,url:o,deliveryDirectives:c}=e;this.load({id:i,level:n,responseType:"text",type:Te.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===Te.MANIFEST?o=i.manifestLoadPolicy.default:o=ci({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Te.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Te.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=ci({},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 E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),A||null,g);return}g.parsing.start=performance.now(),Ar.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,A||null,E):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)}};n.load(t,d,f)}handleMasterPlaylist(t,e,i,n){const o=this.hls,c=t.data,d=yc(t,i),f=Ar.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":x}=Ar.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(O=>!O.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.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 ti({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:x,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,n,o){const c=this.hls,{id:d,level:f,type:p}=i,g=yc(t,i),v=Wt(d)?d:0,A=Wt(f)?f:v,E=_0(i),T=Ar.parseLevelPlaylist(t.data,g,A,E,v,this.variableList);if(p===Te.MANIFEST){const w={attrs:new ti({}),bitrate:0,details:T,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,n,o)}handleManifestParsingError(t,e,i,n,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:pt.MANIFEST_PARSING_ERROR,fatal:e.type===Te.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,i=!1,n,o){let c=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);X.warn(`[playlist-loader]: ${c}`);let f=pt.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:f=i?pt.MANIFEST_LOAD_TIMEOUT:pt.MANIFEST_LOAD_ERROR,p=!0;break;case Te.LEVEL:f=i?pt.LEVEL_LOAD_TIMEOUT:pt.LEVEL_LOAD_ERROR,p=!1;break;case Te.AUDIO_TRACK:f=i?pt.AUDIO_TRACK_LOAD_TIMEOUT:pt.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Te.SUBTITLE_TRACK:f=i?pt.SUBTITLE_TRACK_LOAD_TIMEOUT:pt.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(n){const A=(e==null?void 0:e.url)||t.url;v.response=Ki({url:A,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,n,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:A}=n,E=yc(e,n),T=_0(n),w=typeof n.level=="number"&&T===Qt.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:pt.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:x,reason:x.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:pt.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:n,level:w,parent:T,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 Te.MANIFEST:case Te.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:A});break;case Te.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break;case Te.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break}}}function C0(s,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=s,t.dispatchEvent(e)}function I0(s,t){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(t.id))try{if(s.addCue(t),!s.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){X.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,s.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(s.mode=e)}function Sn(s){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let e=s.cues.length;e--;)s.removeCue(s.cues[e]);t==="disabled"&&(s.mode=t)}function bc(s,t,e,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const o=oy(s.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&s.removeCue(o[c])}n==="disabled"&&(s.mode=n)}function ay(s,t){if(t<s[0].startTime)return 0;const e=s.length-1;if(t>s[e].endTime)return-1;let i=0,n=e;for(;i<=n;){const o=Math.floor((n+i)/2);if(t<s[o].startTime)n=o-1;else if(t>s[o].startTime&&i<e)i=o+1;else return o}return s[i].startTime-t<t-s[n].startTime?i:n}function oy(s,t,e){const i=[],n=ay(s,t);if(n>-1)for(let o=n,c=s.length;o<c;o++){const d=s[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Er={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const ly=.25;function Ac(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Co=(()=>{const s=Ac();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ec(s,t){return s.getTime()/1e3-t}function cy(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class hy{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&&(Sn(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 C0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=Ac();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Er.emsg&&!i||!n)continue;const p=a0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Co&&(v=Co),v-g<=0&&(v=g+ly);for(let A=0;A<p.length;A++){const E=p[A];if(!n0(E)){this.updateId3CueEnds(g,f);const T=new c(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let o=n.length;o--;){const c=n[o];c.type===e&&c.startTime<t&&c.endTime===Co&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Er.audioId3&&f:n==="video"?p=g=>g.type===Er.emsg&&d:p=g=>g.type===Er.audioId3&&f||g.type===Er.emsg&&d,bc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:o}=e,c=Object.keys(o);if(n){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(E=>{n.removeCue(i[A].cues[E])}),delete i[A]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=Ac();for(let g=0;g<c.length;g++){const v=c[g],A=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=Ec(A.startDate,f);let x=Co;const O=A.endDate;if(O)x=Ec(O,f),w=!0;else if(A.endOnNext&&!w){const D=c.reduce((V,$)=>{const z=o[$];return z.class===A.class&&z.id!==$&&z.startDate>A.startDate&&V.push(z),V},[]).sort((V,$)=>V.startDate.getTime()-$.startDate.getTime())[0];D&&(x=Ec(D.startDate,f),w=!0)}const B=Object.keys(A.attr);for(let D=0;D<B.length;D++){const V=B[D];if(!vv(V))continue;let $=T[V];if($)w&&!E.durationKnown&&($.endTime=x);else{let z=A.attr[V];$=new p(C,x,""),yv(V)&&(z=cy(z)),$.value={key:V,data:z},$.type=Er.dateRange,$.id=v,this.id3Track.addCue($),T[V]=$}}i[v]={cues:T,dateRange:A,durationKnown:w}}}}class dy{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:n}=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*n);const g=n,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 n=i.edge,o=t-e-this.edgeStalled,c=n-i.totalduration,d=n-(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===pt.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&X.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:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||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 Tc=["NONE","TYPE-0","TYPE-1",null];var wa={No:"",Yes:"YES",v2:"v2"};function uy(s,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:n}=s,o=t!==void 0?t-n:0;return e&&o<e?i?wa.v2:wa.Yes:wa.No}class D0{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 Sa{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 kc(s,t){const e=t.startPTS;if(Wt(e)){let i=0,n;t.sn>s.sn?(i=e-s.start,n=s):(i=s.start-e,n=t),n.duration!==i&&(n.duration=i)}else t.sn>s.sn?s.cc===t.cc&&s.minEndPTS?t.start=s.start+(s.minEndPTS-s.start):t.start=s.start+s.duration:t.start=Math.max(s.start-t.duration,0)}function x0(s,t,e,i,n,o){i-e<=0&&(X.warn("Fragment should have a positive duration",t),i=e+t.duration,o=n+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,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=n,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let A;const E=v-s.startSN,T=s.fragments;for(T[E]=t,A=E;A>0;A--)kc(T[A],T[A-1]);for(A=E;A<T.length-1;A++)kc(T[A],T[A+1]);return s.fragmentHint&&kc(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function fy(s,t){let e=null;const i=s.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n=0,o;if(my(s,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),Wt(f.startPTS)&&Wt(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){X.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=py(s.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),gy(s.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?x0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):P0(s,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=s.driftStartTime,t.driftStart=s.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=s.driftEndTime,t.driftEnd=s.driftEnd,t.advancedDateTime=s.advancedDateTime}function py(s,t,e){const i=ci({},s);return e&&e.forEach(n=>{delete i[n]}),Object.keys(t).forEach(n=>{const o=new qu(t[n].attr,i[n]);o.isValid?i[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),i}function gy(s,t,e){if(s&&t){let i=0;for(let n=0,o=s.length;n<=o;n++){const c=s[n],d=t[n+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function my(s,t,e){const i=t.skippedSegments,n=Math.max(s.startSN,t.startSN)-t.startSN,o=(s.fragmentHint?1:0)+(i?t.endSN:Math.min(s.endSN,t.endSN))-t.startSN,c=t.startSN-s.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let p=n;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(s,t){const e=t.startSN+t.skippedSegments-s.startSN,i=s.fragments;e<0||e>=i.length||wc(t,i[e].start)}function wc(s,t){if(t){const e=s.fragments;for(let i=s.skippedSegments;i<e.length;i++)e[i].start+=t;s.fragmentHint&&(s.fragmentHint.start+=t)}}function vy(s,t=1/0){let e=1e3*s.targetduration;if(s.updated){const i=s.fragments,n=4;if(i.length&&e*n>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function yy(s,t,e){if(!(s!=null&&s.details))return null;const i=s.details;let n=i.fragments[t-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===t)?n:t<i.startSN&&e&&e.sn===t?e:null}function O0(s,t,e){var i;return s!=null&&s.details?M0((i=s.details)==null?void 0:i.partList,t,e):null}function M0(s,t,e){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===e&&n.fragment.sn===t)return n}return null}function Io(s){switch(s.details){case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_TIMEOUT:case pt.LEVEL_LOAD_TIMEOUT:case pt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function $0(s,t){const e=Io(t);return s.default[`${e?"timeout":"error"}Retry`]}function Sc(s,t){const e=s.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function F0(s){return Ki(Ki({},s),{errorRetry:null,timeoutRetry:null})}function Do(s,t,e,i){return!!s&&t<s.maxNumRetry&&(by(i)||!!e)}function by(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const N0={search:function(s,t){let e=0,i=s.length-1,n=null,o=null;for(;e<=i;){n=(e+i)/2|0,o=s[n];const c=t(o);if(c>0)e=n+1;else if(c<0)i=n-1;else return o}return null}};function Ay(s,t,e){if(t===null||!Array.isArray(s)||!s.length||!Wt(t))return null;const i=s[0].programDateTime;if(t<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<s.length;++o){const c=s[o];if(Ey(t,e,c))return c}return null}function Ra(s,t,e=0,i=0){let n=null;if(s?n=t[s.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&Rc(e,i,n)===0)return n;const o=N0.search(t,Rc.bind(null,e,i));return o&&(o!==s||!n)?o:n}function Rc(s=0,t=0,e){if(e.start<=s&&e.start+e.duration>s)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=s?1:e.start-i>s&&e.start?-1:0}function Ey(s,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>s}function Ty(s,t){return N0.search(s,e=>e.cc<t?1:e.cc>t?-1:0)}const ky=3e5;var Ci={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},hr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class wy{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=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[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)===Qt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,n;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case pt.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ci.DoNothing,flags:hr.None};return}case pt.FRAG_GAP:case pt.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ci.SendAlternateToPenaltyBox;return}case pt.LEVEL_EMPTY_ERROR:case pt.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Qt.MAIN?e.level:o.loadLevel;e.details===pt.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 pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.SUBTITLE_LOAD_ERROR:case pt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Te.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Te.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ci.SendAlternateToPenaltyBox,e.errorAction.flags=hr.MoveAllAlternatesMatchingHost;return}}return;case pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ci.SendAlternateToPenaltyBox,flags:hr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case pt.BUFFER_ADD_CODEC_ERROR:case pt.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case pt.INTERNAL_EXCEPTION:case pt.BUFFER_APPENDING_ERROR:case pt.BUFFER_APPEND_ERROR:case pt.BUFFER_FULL_ERROR:case pt.LEVEL_SWITCH_ERROR:case pt.BUFFER_STALLED_ERROR:case pt.BUFFER_SEEK_OVER_HOLE:case pt.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ci.DoNothing,flags:hr.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 n=this.hls,o=$0(n.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Do(o,c,Io(t),d))return{action:Ci.RetryRequest,flags:hr.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),n=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=$0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,A)=>v+A.fragmentError,0);if(n){var p;t.details!==pt.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Do(d,f,Io(t),v))return{action:Ci.RetryRequest,flags:hr.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 n=this.hls.levels[e];if(n&&(n.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:E,groupId:T}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const x=f[C];if(t.details===pt.FRAG_GAP&&t.frag){const O=f[C].details;if(O){const B=Ra(t.frag,O.fragments,t.frag.start);if(B!=null&&B.gap)continue}}else if(E===Te.AUDIO_TRACK&&T===x.audioGroupId||E===Te.SUBTITLE_TRACK&&T===x.textGroupId||A===Qt.AUDIO&&n.audioGroupId===x.audioGroupId||A===Qt.SUBTITLE&&n.textGroupId===x.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ci.SendAlternateToPenaltyBox,flags:hr.None,nextAutoLevel:d}}return{action:Ci.SendAlternateToPenaltyBox,flags:hr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ci.DoNothing:break;case Ci.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==pt.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:n,hdcpLevel:o,nextAutoLevel:c}=i;switch(n){case hr.None:this.switchLevel(t,c);break;case hr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case hr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Tc[Tc.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,n=t.parent===Qt.MAIN?t.level:e.loadLevel,o=e.levels[n],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||Sy(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=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,n=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,i[t.urlId]=n}}function Sy(s,t,e){if(performance.now()-s.lastErrorPerfMs>ky)return!0;const i=s.details;if(t.details===pt.FRAG_GAP&&i&&t.frag){const n=t.frag.start,o=Ra(null,i.fragments,n);if(o&&!o.gap)return!0}if(e&&s.errors.length<e.errors.length){const n=s.errors[s.errors.length-1];if(i&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Lc{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=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${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 n=-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){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=i[n],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 D0(c,d>=0?d:void 0,wa.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:n,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&fy(i,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,x=n.lastPartSn,O=n.endSN,B=n.lastPartIndex,D=B!==-1,V=x===O,$=C?0:B;D?(p=V?O+1:x,g=V?$:B+1):p=O+1;const z=n.age,it=z+n.ageHeader;let at=Math.min(it-n.partTarget,n.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: ${n.age}`),at=0;else{const J=Math.floor(at/n.targetduration);if(p+=J,g!==void 0){const wt=Math.round(at%n.targetduration/n.partTarget);g+=wt}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${z.toFixed(2)}s goal: ${at} skip sn ${J} to part ${g}`)}n.tuneInGoal=at}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!V){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,A=v?v.end-v.len:0,E=(n.edge-A)*1e3,T=vy(n,E);n.updated&&c>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=T);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,n){let o=uy(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,o=wa.No),new D0(i,n,o)}checkRetry(t){const e=t.details,i=Io(t),n=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===Ci.RetryRequest||!n.resolved&&o===Ci.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=Sc(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,n.resolved=!0}return f}}let _c;class Ry extends Lc{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=[],n={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(_c||(_c=/chrome|firefox/i.test(navigator.userAgent)),_c&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":A,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${A||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=n[w],o?o.addFallback(c):(o=new Sa(c),n[w]=o,i.push(o)),xo(o,"audio",p),xo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],n=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:x})=>(o||(o=!!(w&&C)),c||(c=!!T),d||(d=!!E),!(x!=null&&x.length)&&(!E||vc(E,"audio"))&&(!T||vc(T,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:T,height:w})=>!!E||!!(T&&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:pt.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||vc(E.audioCodec,"audio")),U0(i)),e.subtitles&&(n=e.subtitles,U0(n));const p=f.slice(0);f.sort((E,T)=>E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==T.bitrate?E.bitrate-T.bitrate:E.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==T.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==T.height?E.height-T.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,A={levels:f,audioTracks:i,subtitleTracks:n,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,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(R.ERROR,{type:qt.OTHER_ERROR,details:pt.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,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ci({},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,n==null?void 0:n.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===Te.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:n,details:o}=e,c=this._levels[n];if(!c){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(n,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===n){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 n=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 ${n+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,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,n=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:n})}onLevelsUpdated(t,{levels:e}){e.forEach((i,n)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=n})}),this._levels=e}}function xo(s,t,e){e&&(t==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):t==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function U0(s){const t={};s.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var gi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ly{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 n=i.length;n--;){const o=i[n];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,n=Object.keys(i);for(let o=n.length;o--;){const c=i[n[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,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.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:n}=t;if(!e||i.sn==="initSegment")return;const o=Rn(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,n,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),Po(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(n=>n.fragment.sn>=t))}fragBuffered(t,e){const i=Rn(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,i,n){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,A=n.end(g)+this.bufferPadding;if(p>=v&&f<=A){o.time.push({startPTS:Math.max(c,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(c<A&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,n,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Po(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(i=Math.min(t-n,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Po(e))}getState(t){const e=Rn(t),i=this.fragments[e];return i?i.buffered?Po(i)?gi.PARTIAL:gi.OK:gi.APPENDING:gi.NOT_LOADED}isTimeBuffered(t,e,i){let n,o;for(let c=0;c<i.length;c++){if(n=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=n?null:e,c=Rn(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(n){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Rn(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=Rn(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const n=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==n)}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 Po(s){var t,e,i;return s.buffered&&(s.body.gap||((t=s.range.video)==null?void 0:t.partial)||((e=s.range.audio)==null?void 0:e.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function Rn(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const B0=Math.pow(2,17);class _y{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 Jr({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,c=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(V0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new c(n),g=G0(t),v=F0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:B0};t.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{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:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Ki({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const n=this.config,o=n.fLoader,c=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(V0(t,e));return}const p=this.loader=t.loader=o?new o(n):new c(n),g=G0(t,e),v=F0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:B0};e.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const x={frag:t,part:e,payload:E.data,networkDetails:C};i(x),d(x)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Ki({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,o=n.total;if(i.loaded+=n.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=n.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 G0(s,t=null){const e=t||s,i={frag:s,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(n)&&Wt(o)){var c;let d=n,f=o;if(s.sn==="initSegment"&&((c=s.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(i.resetIV=!0,d=n-16)}i.rangeStart=d,i.rangeEnd=f}return i}function V0(s,t){const e=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:pt.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return t&&(i.part=t),(t||s).stats.aborted=!0,new Jr(i)}class Jr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Cy{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=pt.KEY_LOAD_ERROR,i,n,o){return new Jr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let o=0;o<e.length;o++){const c=e[o];if(n<=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,n;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,pt.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,pt.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((n=d)!=null&&n.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,pt.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 n=this.emeController.loadKey(i);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=i.loader,o=new n(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,E,T,w)=>{const{frag:C,keyInfo:x,url:O}=T;if(!C.decryptdata||x!==this.keyUriToKeyInfo[O])return d(this.createKeyLoadError(C,pt.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));x.decryptdata.key=C.decryptdata.key=new Uint8Array(A.data),C.keyLoader=null,x.loader=null,c({frag:C,keyInfo:x})},onError:(A,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),T,Ki({url:f.url,data:void 0},A)))},onTimeout:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class Iy{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 Dy={length:0,start:()=>0,end:()=>0};class Be{static isBuffered(t,e){try{if(t){const i=Be.getBuffered(t);for(let n=0;n<i.length;n++)if(e>=i.start(n)&&e<=i.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const n=Be.getBuffered(t),o=[];let c;for(c=0;c<n.length;c++)o.push({start:n.start(c),end:n.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 n=[];if(i)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<i?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,c,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[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 X.log("failed to get media.buffered",e),Dy}}}class Cc{constructor(t,e,i,n=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=Oo(),this.buffering={audio:Oo(),video:Oo(),audiovideo:Oo()},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=o,this.partial=c}}function Oo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function H0(s,t){let e=null;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o&&o.cc===t){e=o;break}}return e}function xy(s,t,e){return!!(t.details&&(e.endCC>e.startCC||s&&s.cc<e.startCC))}function Py(s,t,e=0){const i=s.fragments,n=t.fragments;if(!n.length||!i.length){X.log("No fragments to align");return}const o=H0(i,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function W0(s,t){if(s){const e=s.start+t;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function Ic(s,t){const e=t.fragments;for(let i=0,n=e.length;i<n;i++)W0(e[i],s);t.fragmentHint&&W0(t.fragmentHint,s),t.alignedSliding=!0}function Oy(s,t,e){t&&(My(s,e,t),!e.alignedSliding&&t.details&&$y(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&P0(t.details,e))}function My(s,t,e){if(xy(s,e,t)){const i=Py(e.details,t);i&&Wt(i.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Ic(i.start,t))}}function $y(s,t){if(!t.fragments.length||!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=s.fragments[0].programDateTime,n=(i-e)/1e3+t.fragments[0].start;n&&Wt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${n.toFixed(3)} ${s.url} `),Ic(n,s))}function j0(s,t){if(!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=s.fragments,i=t.fragments;if(!e.length||!i.length)return;const n=Math.round(i.length/2)-1,o=i[n],c=H0(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);Ic(p,s)}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 Ny{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 Uy(s){const t=s.byteLength,e=t&&new DataView(s.buffer).getUint8(t-1);return e?an(s,0,t-e):s}class By{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 n=0;n<4;n++)i[n]=e.getUint32(n*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=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],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){let x=w^w<<1^w<<2^w<<3^w<<4;x=x>>>8^x&255^99,t[T]=x,e[x]=T;const O=E[T],B=E[O],D=E[B];let V=E[x]*257^x*16843008;n[T]=V<<24|V>>>8,o[T]=V<<16|V>>>16,c[T]=V<<8|V>>>24,d[T]=V,V=D*16843009^B*65537^O*257^T*16843008,p[x]=V<<24|V>>>8,g[x]=V<<16|V>>>16,v[x]=V<<8|V>>>24,A[x]=V,T?(T=O^E[E[E[D^O]]],w^=E[E[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;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,E=this.invSubMix,T=E[0],w=E[1],C=E[2],x=E[3];let O,B;for(d=0;d<c;d++){if(d<o){O=p[d]=e[d];continue}B=O,d%o===0?(B=B<<8|B>>>24,B=v[B>>>24]<<24|v[B>>>16&255]<<16|v[B>>>8&255]<<8|v[B&255],B^=A[d/o|0]<<24):o>6&&d%o===4&&(B=v[B>>>24]<<24|v[B>>>16&255]<<16|v[B>>>8&255]<<8|v[B&255]),p[d]=O=(p[d-o]^B)>>>0}for(f=0;f<c;f++)d=c-f,f&3?B=p[d]:B=p[d-4],f<4||d<=4?g[f]=B:g[f]=T[v[B>>>24]]^w[v[B>>>16&255]]^C[v[B>>>8&255]]^x[v[B&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const n=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 E=A[0],T=A[1],w=A[2],C=A[3];const x=new Int32Array(t),O=new Int32Array(x.length);let B,D,V,$,z,it,at,J,wt,vt,Ot,Gt,U,q;const At=this.networkToHostOrderSwap;for(;e<x.length;){for(wt=At(x[e]),vt=At(x[e+1]),Ot=At(x[e+2]),Gt=At(x[e+3]),z=wt^o[0],it=Gt^o[1],at=Ot^o[2],J=vt^o[3],U=4,q=1;q<n;q++)B=f[z>>>24]^p[it>>16&255]^g[at>>8&255]^v[J&255]^o[U],D=f[it>>>24]^p[at>>16&255]^g[J>>8&255]^v[z&255]^o[U+1],V=f[at>>>24]^p[J>>16&255]^g[z>>8&255]^v[it&255]^o[U+2],$=f[J>>>24]^p[z>>16&255]^g[it>>8&255]^v[at&255]^o[U+3],z=B,it=D,at=V,J=$,U=U+4;B=c[z>>>24]<<24^c[it>>16&255]<<16^c[at>>8&255]<<8^c[J&255]^o[U],D=c[it>>>24]<<24^c[at>>16&255]<<16^c[J>>8&255]<<8^c[z&255]^o[U+1],V=c[at>>>24]<<24^c[J>>16&255]<<16^c[z>>8&255]<<8^c[it&255]^o[U+2],$=c[J>>>24]<<24^c[z>>16&255]<<16^c[it>>8&255]<<8^c[at&255]^o[U+3],O[e]=At(B^E),O[e+1]=At($^T),O[e+2]=At(V^w),O[e+3]=At(D^C),E=wt,T=vt,w=Ot,C=Gt,e=e+4}return O.buffer}}const Gy=16;class Dc{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?Uy(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((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?n(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=on(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(i=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new By),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=an(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new Ny(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new Fy(n,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.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 n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%Gy;return i!==t.length&&(e=an(t,0,i),this.remainderData=an(t,i)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Vy={toString:function(s){let t="";const e=s.length;for(let i=0;i<e;i++)t+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return t}},kt={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 xc extends Iy{constructor(t,e,i,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=kt.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=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new _y(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Dc(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=kt.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 Be.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}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 n=this.config;this.levels&&n.autoStartLoad&&this.state===kt.STOPPED&&this.startLoad(n.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:n,state:o}=this,c=i?i.currentTime:0,d=Be.bufferInfo(n||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Wt(c)?c.toFixed(3):c}, state: ${o}`),this.state===kt.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=kt.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 n=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,n).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===kt.FRAG_LOADING||!this.fragCurrent&&c===kt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=kt.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===kt.STOPPED||this.state===kt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===gi.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),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)===gi.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 n={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,n)}_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:n}=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 n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:n,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=kt.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===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===kt.STOPPED||this.state===kt.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,n,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)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?Vy.toString(Be.getBuffered(d)):"(detached)"})`),this.state=kt.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:n,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Cc(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){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=kt.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===kt.KEY_LOADING&&(this.state=kt.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&&n){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=kt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,A,e,n)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,A,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:A,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))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=kt.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,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(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,n){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,n).then(A=>{f[v.index]=A;const E=A.part;this.hls.trigger(R.FRAG_LOADED,A);const T=O0(i,t.sn,v.index+1)||M0(p,t.sn,v.index+1);if(T)g(T);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===pt.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:pt.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==kt.PARSING){!this.fragCurrent&&this.state!==kt.STOPPED&&this.state!==kt.ERROR&&(this.state=kt.IDLE);return}const{frag:i,part:n,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,n&&(n.stats.parsing.end=c),this.updateLevelTiming(i,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:o,part:c}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=c>-1?O0(d,o,c):null,p=f?f.fragment:yy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,n,o){var c;if(!t||this.state!==kt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=on(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:n,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(!Be.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,n=Be.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,n.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,o=Be.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return Be.bufferInfo(t,e,Math.max(o.nextStart,n))}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,n=i.length;if(!n)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, 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===gi.OK||i===gi.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,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,n);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" 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 n=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,n>-1&&i<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||c)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=Ay(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(n=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=Ty(e,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,i){const{config:n}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=n.maxFragLookUpTolerance,g=i.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let A;if(t<e){const E=t>e-p?0:p;A=Ra(o,c,t,E)}else A=c[c.length-1];if(A){const E=A.sn-i.startSN,T=this.fragmentTracker.getState(A);if((T===gi.OK||T===gi.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[E+1];A.sn<d&&this.fragmentTracker.getState(w)!==gi.OK?A=w:A=null}}return A}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&i.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:n,fragPrevious:o}=this,c=n!==null?i[n]: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&&Wt(f);if(p||!g&&!f){Oy(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 n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(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 ${n?"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!==kt.FRAG_LOADING_WAITING_RETRY)&&(this.state=kt.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 n;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===pt.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ci.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=Sc(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=kt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ci.SendAlternateToPenaltyBox?this.state=kt.WAITING_LEVEL:this.state=kt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===kt.PARSING||this.state===kt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const o=!n;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!==kt.STOPPED&&(this.state=kt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const n=Be.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===kt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=kt.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,n){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=n?0:x0(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:pt.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=kt.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,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.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 K0(){return self.SourceBuffer||self.WebKitSourceBuffer}function Hy(){const s=_o();if(!s)return!1;const t=K0(),e=s&&typeof s.isTypeSupported=="function"&&s.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 Wy(){var s;const t=K0();return typeof(t==null||(s=t.prototype)==null?void 0:s.changeType)=="function"}function jy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Ky(){const s=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(s);return{worker:new self.Worker(t),objectURL:t}}function zy(s){const t=new self.URL(s,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Mr(s="",t=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class z0{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,n){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=on(this.cachedData,t),this.cachedData=null);let i=wo(t,0),n=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?Cv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=Yy(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:Er.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(c,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else _v(t,n)?(i=wo(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Er.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,o=n):n++;if(n===p&&o!==p){const g=an(t,o);this.cachedData?this.cachedData=on(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 Yy=(s,t,e)=>{if(Wt(s))return s*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Xy(s,t,e,i){let n,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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,X.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=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)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,n===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."+n,manifestCodec:p}}function Y0(s,t){return s[t]===255&&(s[t+1]&246)===240}function X0(s,t){return s[t+1]&1?7:9}function Pc(s,t){return(s[t+3]&3)<<11|s[t+4]<<3|(s[t+5]&224)>>>5}function Zy(s,t){return t+5<s.length}function Mo(s,t){return t+1<s.length&&Y0(s,t)}function qy(s,t){return Zy(s,t)&&Y0(s,t)&&Pc(s,t)<=s.length-t}function Qy(s,t){if(Mo(s,t)){const e=X0(s,t);if(t+e>=s.length)return!1;const i=Pc(s,t);if(i<=e)return!1;const n=t+i;return n===s.length||Mo(s,n)}return!1}function Z0(s,t,e,i,n){if(!s.samplerate){const o=Xy(t,e,i,n);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,X.log(`parsed codec:${s.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function q0(s){return 9216e4/s}function Jy(s,t){const e=X0(s,t);if(t+e<=s.length){const i=Pc(s,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Q0(s,t,e,i,n){const o=q0(s.samplerate),c=i+n*o,d=Jy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,A=v+g,E=Math.max(0,e+A-t.length);E?(f=new Uint8Array(A-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+A);const T={unit:f,pts:c};return E||s.samples.push(T),{sample:T,length:A,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 tb extends z0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(wo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Qy(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return qy(t,e)}appendFrame(t,e,i){Z0(t,this.observer,e,i,t.manifestCodec);const n=Q0(t,e,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const eb=/\/emsg[-/]ID3/i;class ib{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,n){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=h0(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=o0.text,o.sampleDuration=0,o.duration=c.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,ye(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=on(this.remainderData,t));const d=Wv(i);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=i;const c=this.extractID3Track(n,e);return o.samples=u0(e,n),{videoTrack:n,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 n=this.extractID3Track(e,this.timeOffset);return i.samples=u0(t,e),{videoTrack:e,audioTrack:Mr(),id3Track:n,textTrack:Mr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=ye(t.samples,["emsg"]);n&&n.forEach(o=>{const c=zv(o);if(eb.test(c.schemeIdUri)){const d=Wt(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:Er.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 rb=[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],sb=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],nb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ab=[0,1,1,4];function J0(s,t,e,i,n){if(e+24>t.length)return;const o=tf(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+n*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return s.config=[],s.channelCount=o.channelCount,s.samplerate=o.sampleRate,s.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function tf(s,t){const e=s[t+1]>>3&3,i=s[t+1]>>1&3,n=s[t+2]>>4&15,o=s[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const c=s[t+2]>>1&1,d=s[t+3]>>6,f=e===3?3-i:i===3?3:4,p=rb[f*14+n-1]*1e3,g=sb[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,A=nb[e][i],E=ab[i],T=A*8*E,w=Math.floor(A*p/g+c)*E;if($o===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$o=C?parseInt(C[1]):0}return $o&&$o<=87&&i===2&&p>=224e3&&d===0&&(s[t+3]=s[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Oc(s,t){return s[t]===255&&(s[t+1]&224)===224&&(s[t+1]&6)!==0}function ef(s,t){return t+1<s.length&&Oc(s,t)}function ob(s,t){return Oc(s,t)&&4<=s.length-t}function lb(s,t){if(t+1<s.length&&Oc(s,t)){const e=tf(s,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const n=t+i;return n===s.length||ef(s,n)}return!1}class rf{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,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(i,i+o)),this.word=new DataView(n.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&&X.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,n;for(let o=0;o<t;o++)i!==0&&(n=this.readEG(),i=(e+n+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,n=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),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),A(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const $=g();if($===3&&A(1),T(),T(),A(1),v())for(c=$!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}T();const x=g();if(x===0)g();else if(x===1)for(A(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),A(1);const O=g(),B=g(),D=p(1);D===0&&A(1),A(1),v()&&(t=g(),e=g(),i=g(),n=g());let V=[1,1];if(v()&&v())switch(f()){case 1:V=[1,1];break;case 2:V=[12,11];break;case 3:V=[10,11];break;case 4:V=[16,11];break;case 5:V=[40,33];break;case 6:V=[24,11];break;case 7:V=[20,11];break;case 8:V=[32,11];break;case 9:V=[80,33];break;case 10:V=[18,11];break;case 11:V=[15,11];break;case 12:V=[64,33];break;case 13:V=[160,99];break;case 14:V=[4,3];break;case 15:V=[3,2];break;case 16:V=[2,1];break;case 255:{V=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((O+1)*16-t*2-e*2),height:(2-D)*(B+1)*16-(D?2:4)*(i+n),pixelRatio:V}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class cb{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Dc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);n.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 n=0;for(let o=32;o<t.length-16;o+=160,n+=16)i.set(t.subarray(o,o+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(i.subarray(n,n+16),o);return t}decryptAvcSample(t,e,i,n,o){const c=p0(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,n)})}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){n();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,n,c),!this.decrypter.isSync()))return}}}}const Ii=188;class Es{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=Es.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Ii*5,t.length-Ii)+1,n=0;for(;n<i;){let o=!1,c=-1,d=0;for(let f=n;f<e;f+=Ii)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+Ii*99,t.length-Ii)+1)),o||(o=Mc(t,f)===0),o&&d>1&&(c===0&&d>2||f+Ii>i))return c}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:o0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Es.createTrack("video"),this._audioTrack=Es.createTrack("audio",n),this._id3Track=Es.createTrack("id3"),this._txtTrack=Es.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}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,n=!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,E=f.pid,T=d.pesData,w=f.pesData,C=null,x=this.pmtParsed,O=this._pmtId,B=t.length;if(this.remainderData&&(t=on(this.remainderData,t),B=t.length,this.remainderData=null),B<Ii&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const D=Math.max(0,Es.syncOffset(t));B-=(B-D)%Ii,B<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,B,t.buffer.byteLength-B));let V=0;for(let z=D;z<B;z+=Ii)if(t[z]===71){const it=!!(t[z+1]&64),at=Mc(t,z),J=(t[z+3]&48)>>4;let wt;if(J>1){if(wt=z+5+t[z+4],wt===z+Ii)continue}else wt=z+4;switch(at){case g:it&&(v&&(o=Ln(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(wt,z+Ii)),v.size+=z+Ii-wt);break;case A:if(it){if(T&&(o=Ln(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(wt,z+Ii)),T.size+=z+Ii-wt);break;case E:it&&(w&&(o=Ln(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(wt,z+Ii)),w.size+=z+Ii-wt);break;case 0:it&&(wt+=t[wt]+1),O=this._pmtId=hb(t,wt);break;case O:{it&&(wt+=t[wt]+1);const vt=db(t,wt,this.typeSupported,i);g=vt.avc,g>0&&(c.pid=g),A=vt.audio,A>0&&(d.pid=A,d.segmentCodec=vt.segmentCodec),E=vt.id3,E>0&&(f.pid=E),C!==null&&!x&&(X.warn(`MPEG-TS PMT found at ${z} after unknown PID '${C}'. Backtracking to sync byte @${D} to parse all TS packets.`),C=null,z=D-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=at;break}}else V++;if(V>0){const z=new Error(`Found ${V} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:z,reason:z.message})}c.pesData=v,d.pesData=T,f.pesData=w;const $={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples($),$}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:n,textTrack:o}=t,c=i.pesData,d=e.pesData,f=n.pesData;let p;if(c&&(p=Ln(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=Ln(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&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Ln(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new cb(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.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,n){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(La(c,t),c=this.avcSample=Fo(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let A=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new rf(E).readSliceType();(T===2||T===4||T===7||T===9)&&(A=!0)}if(A){var v;(v=c)!=null&&v.frame&&!c.key&&(La(c,t),c=this.avcSample=null)}c||(c=this.avcSample=Fo(!0,i.pts,i.dts,"")),c.frame=!0,c.key=A;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(La(c,t),c=this.avcSample=null),c||(c=this.avcSample=Fo(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,f0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const A=p.data,E=new rf(A).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[A],t.duration=this._duration;const T=A.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let x=T[C].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&&La(c,t),c=this.avcSample=Fo(!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)}),n&&c&&(La(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const i=e.byteLength;let n=t.naluState||0;const o=n,c=[];let d=0,f,p,g,v=-1,A=0;for(n===-1&&(v=0,A=e[0]&31,n=0,d=1);d<i;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-n-1),type:A};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-n-1,p>0)){const T=new Uint8Array(E.data.byteLength+p);T.set(E.data,0),T.set(e.subarray(0,p),E.data.byteLength),E.data=T,E.state=0}}d<i?(g=e[d]&31,v=d,A=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const E={data:e.subarray(v,i),type:A,state:n};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const T=new Uint8Array(E.data.byteLength+e.byteLength);T.set(E.data,0),T.set(e,E.data.byteLength),E.data=T}}return t.naluState=n,c}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,A=n.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(A+o.byteLength);E.set(n.sample.unit,0),E.set(o,A),o=E}else{const E=A-v;n.sample.unit.set(o.subarray(0,v),E),t.samples.push(n.sample),i=n.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Mo(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 E=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:E,reason:v}),!A)return}Z0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=q0(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=Q0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Mo(o,c);c++);}parseMPEGPES(t,e){const i=e.data,n=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<n;)if(ef(i,c)){const f=J0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ci({},e,{type:this._avcTrack?Er.emsg:Er.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Fo(s,t,e,i){return{key:s,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Mc(s,t){return((s[t+1]&31)<<8)+s[t+2]}function hb(s,t){return(s[t+10]&31)<<8|s[t+11]}function db(s,t,e,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(s[t+1]&15)<<8|s[t+2],c=t+3+o-4,d=(s[t+10]&15)<<8|s[t+11];for(t+=12+d;t<c;){const f=Mc(s,t);switch(s[t]){case 207:if(!i){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!i){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((s[t+3]&15)<<8|s[t+4])+5}return n}function Ln(s){let t=0,e,i,n,o,c;const d=s.data;if(!s||s.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>s.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&&(X.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),n=e[8];let p=n+9;if(s.size<=p)return null;s.size-=p;const g=new Uint8Array(s.size);for(let v=0,A=d.length;v<A;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-=n+3),{data:g,pts:o,dts:c,len:i}}return null}function La(s,t){if(s.units.length&&s.frame){if(s.pts===void 0){const e=t.samples,i=e.length;if(i){const n=e[i-1];s.pts=n.pts,s.dts=n.dts}else{t.dropped++;return}}t.samples.push(s)}s.debug.length&&X.log(s.pts+"/"+s.dts+":"+s.debug)}class ub extends z0{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(wo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(lb(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return ob(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return J0(t,e,i,this.basePTS,this.frameIndex)}}class sf{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 Ts=Math.pow(2,32)-1;class st{static init(){st.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 st.types)st.types.hasOwnProperty(t)&&(st.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]);st.HDLR_TYPES={video:e,audio:i};const n=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]);st.STTS=st.STSC=st.STCO=o,st.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),st.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),st.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),st.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]);st.FTYP=st.box(st.types.ftyp,c,f,c,d),st.DINF=st.box(st.types.dinf,st.box(st.types.dref,n))}static box(t,...e){let i=8,n=e.length;const o=n;for(;n--;)i+=e[n].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),n=0,i=8;n<o;n++)c.set(e[n],i),i+=e[n].byteLength;return c}static hdlr(t){return st.box(st.types.hdlr,st.HDLR_TYPES[t])}static mdat(t){return st.box(st.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),n=Math.floor(e%(Ts+1));return st.box(st.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,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(t){return st.box(st.types.mdia,st.mdhd(t.timescale,t.duration),st.hdlr(t.type),st.minf(t))}static mfhd(t){return st.box(st.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"?st.box(st.types.minf,st.box(st.types.smhd,st.SMHD),st.DINF,st.stbl(t)):st.box(st.types.minf,st.box(st.types.vmhd,st.VMHD),st.DINF,st.stbl(t))}static moof(t,e,i){return st.box(st.types.moof,st.mfhd(t),st.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trak(t[e]);return st.box.apply(null,[st.types.moov,st.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(st.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trex(t[e]);return st.box.apply(null,[st.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),n=Math.floor(e%(Ts+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,n>>24,n>>16&255,n>>8&255,n&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 st.box(st.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let n,o;for(n=0;n<e.length;n++)o=e[n].flags,i[n+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return st.box(st.types.sdtp,i)}static stbl(t){return st.box(st.types.stbl,st.stsd(t),st.box(st.types.stts,st.STTS),st.box(st.types.stsc,st.STSC),st.box(st.types.stsz,st.STSZ),st.box(st.types.stco,st.STCO))}static avc1(t){let e=[],i=[],n,o,c;for(n=0;n<t.sps.length;n++)o=t.sps[n],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=st.box(st.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 st.box(st.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,st.box(st.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),st.box(st.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 st.box(st.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]),st.box(st.types.esds,st.esds(t)))}static mp3(t){const e=t.samplerate;return st.box(st.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"?st.box(st.types.stsd,st.STSD,st.mp3(t)):st.box(st.types.stsd,st.STSD,st.mp4a(t)):st.box(st.types.stsd,st.STSD,st.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,n=t.width,o=t.height,c=Math.floor(i/(Ts+1)),d=Math.floor(i%(Ts+1));return st.box(st.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,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=st.sdtp(t),n=t.id,o=Math.floor(e/(Ts+1)),c=Math.floor(e%(Ts+1));return st.box(st.types.traf,st.box(st.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),st.box(st.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])),st.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,st.box(st.types.trak,st.tkhd(t),st.mdia(t))}static trex(t){const e=t.id;return st.box(st.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||[],n=i.length,o=12+16*n,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,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;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 st.box(st.types.trun,c)}static initSegment(t){st.types||st.init();const e=st.moov(t),i=new Uint8Array(st.FTYP.byteLength+e.byteLength);return i.set(st.FTYP),i.set(e,st.FTYP.byteLength),i}}st.types=void 0,st.HDLR_TYPES=void 0,st.STTS=void 0,st.STSC=void 0,st.STCO=void 0,st.STSZ=void 0,st.VMHD=void 0,st.SMHD=void 0,st.STSD=void 0,st.FTYP=void 0,st.DINF=void 0;const nf=9e4;function $c(s,t,e=1,i=!1){const n=s*t*e;return i?Math.round(n):n}function fb(s,t,e=1,i=!1){return $c(s,t,1/e,i)}function _a(s,t=!1){return $c(s,1e3,1/nf,t)}function pb(s,t=1){return $c(s,nf,1/t)}const gb=10*1e3,af=1024,mb=1152;let No=null,Fc=null;class Nc{constructor(t,e,i,n=""){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,No===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);No=o?parseInt(o[1]):0}if(Fc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);Fc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((n,o)=>{const c=o.pts-n;return c<-4294967296?(e=!0,dr(n,o.pts)):c>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),i}remux(t,e,i,n,o,c,d,f){let p,g,v,A,E,T,w=o,C=o;const x=t.pid>-1,O=e.pid>-1,B=e.samples.length,D=t.samples.length>0,V=d&&B>0||B>1;if((!x||D)&&(!O||V)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const $=this.isVideoContiguous;let z=-1,it;if(V&&(z=vb(e.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,z>0){X.warn(`[mp4-remuxer]: Dropped ${z} out of ${B} video samples due to a missing keyframe`);const at=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(z),e.dropped+=z,C+=(e.samples[0].pts-at)/e.inputTimeScale,it=C}else z===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${B} video samples`),T=!1);if(this.ISGenerated){if(D&&V){const at=this.getVideoStartPts(e.samples),J=(dr(t.samples[0].pts,at)-at)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(D){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,O||V||f===Qt.AUDIO?C:void 0),V){const at=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,C,$,at)}}else V&&(p=this.remuxVideo(e,C,$,0));p&&(p.firstKeyFrame=z,p.independent=z!==-1,p.firstKeyFramePTS=it)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=of(i,o,this._initPTS,this._initDTS)),n.samples.length&&(A=lf(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:A,id3:E}}generateIS(t,e,i,n){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",A,E,T;if(g&&(A=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):st.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?A=E=o[0].pts-Math.round(T*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:st.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(c),C=Math.round(T*i);E=Math.min(E,dr(c[0].dts,w)-C),A=Math.min(A,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:A,timescale:T},this._initDTS={baseTime:E,timescale:T}):A=T=void 0,{tracks:f,initPTS:A,timescale:T}}remuxVideo(t,e,i,n){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,A=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,x=!1;if(!i||g===null){const F=e*o,N=c[0].pts-dr(c[0].dts,c[0].pts);g=F-N}const O=p.baseTime*o/p.timescale;for(let F=0;F<f;F++){const N=c[F];N.pts=dr(N.pts-O,g),N.dts=dr(N.dts-O,g),N.dts<c[F>0?F-1:F].dts&&(x=!0)}x&&c.sort(function(F,N){const j=F.dts-N.dts,nt=F.pts-N.pts;return j||nt}),E=c[0].dts,T=c[c.length-1].dts;const B=T-E,D=B?Math.round(B/(f-1)):A||t.inputTimeScale/30;if(i){const F=E-g,N=F>D,j=F<-1;if((N||j)&&(N?X.warn(`AVC: ${_a(F,!0)} ms (${F}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${_a(-F,!0)} ms (${F}dts) overlapping between fragments detected`),!j||g>=c[0].pts)){E=g;const nt=c[0].pts-F;c[0].dts=E,c[0].pts=nt,X.log(`Video: First PTS/DTS adjusted: ${_a(nt,!0)}/${_a(E,!0)}, delta: ${_a(F,!0)} ms`)}}E=Math.max(0,E);let V=0,$=0;for(let F=0;F<f;F++){const N=c[F],j=N.units,nt=j.length;let ut=0;for(let _t=0;_t<nt;_t++)ut+=j[_t].data.length;$+=ut,V+=nt,N.length=ut,N.dts=Math.max(N.dts,E),w=Math.min(N.pts,w),C=Math.max(N.pts,C)}T=c[f-1].dts;const z=$+4*V+8;let it;try{it=new Uint8Array(z)}catch(F){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:z,reason:`fail allocating video mdat ${z}`});return}const at=new DataView(it.buffer);at.setUint32(0,z),it.set(st.types.mdat,4);let J=!1,wt=Number.POSITIVE_INFINITY,vt=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Gt=Number.NEGATIVE_INFINITY;for(let F=0;F<f;F++){const N=c[F],j=N.units;let nt=0;for(let Nt=0,jt=j.length;Nt<jt;Nt++){const ue=j[Nt],me=ue.data,ge=ue.data.byteLength;at.setUint32(v,ge),v+=4,it.set(me,v),v+=ge,nt+=4+ge}let ut;if(F<f-1)A=c[F+1].dts-N.dts,ut=c[F+1].pts-N.pts;else{const Nt=this.config,jt=F>0?N.dts-c[F-1].dts:D;if(ut=F>0?N.pts-c[F-1].pts:D,Nt.stretchShortVideoTrack&&this.nextAudioPts!==null){const ue=Math.floor(Nt.maxBufferHole*o),me=(n?w+n*o:this.nextAudioPts)-N.pts;me>ue?(A=me-jt,A<0?A=jt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${me/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=jt}else A=jt}const _t=Math.round(N.pts-N.dts);wt=Math.min(wt,A),Ot=Math.max(Ot,A),vt=Math.min(vt,ut),Gt=Math.max(Gt,ut),d.push(new cf(N.key,A,nt,_t))}if(d.length){if(No){if(No<70){const F=d[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(Fc&&Gt-vt<Ot-wt&&D/Ot<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let F=E;for(let N=0,j=d.length;N<j;N++){const nt=F+d[N].duration,ut=F+d[N].cts;if(N<j-1){const _t=nt+d[N+1].cts;d[N].duration=_t-ut}else d[N].duration=N?d[N-1].duration:D;d[N].cts=0,F=nt}}}A=J||!A?D:A,this.nextAvcDts=g=T+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const U=st.moof(t.sequenceNumber++,E,ci({},t,{samples:d})),q="video",At={data1:U,data2:it,startPTS:w/o,endPTS:(C+A)/o,startDTS:E/o,endDTS:g/o,type:q,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,At}remuxAudio(t,e,i,n,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?af:mb,g=p*f,v=this._initPTS,A=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=A?0:8,x=this.nextAudioPts||-1;const O=e*c,B=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&x>0&&(n&&Math.abs(O-x)<9e3||Math.abs(dr(w[0].pts-B,O)-x)<20*g),w.forEach(function(U){U.pts=dr(U.pts-B,O)}),!i||x<0){if(w=w.filter(U=>U.pts>=0),!w.length)return;o===0?x=0:n&&!T?x=Math.max(0,O):x=w[0].pts}if(t.segmentCodec==="aac"){const U=this.config.maxAudioFramesDrift;for(let q=0,At=x;q<w.length;q++){const F=w[q],N=F.pts,j=N-At,nt=Math.abs(1e3*j/c);if(j<=-U*g&&T)q===0&&(X.warn(`Audio frame @ ${(N/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*j/c)} ms.`),this.nextAudioPts=x=At=N);else if(j>=U*g&&nt<gb&&T){let ut=Math.round(j/g);At=N-ut*g,At<0&&(ut--,At+=g),q===0&&(this.nextAudioPts=x=At),X.warn(`[mp4-remuxer]: Injecting ${ut} audio frame @ ${(At/c).toFixed(3)}s due to ${Math.round(1e3*j/c)} ms gap.`);for(let _t=0;_t<ut;_t++){const Nt=Math.max(At,0);let jt=sf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);jt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),jt=F.unit.subarray()),w.splice(q,0,{unit:jt,pts:Nt}),At+=g,q++}}F.pts=At,At+=g}}let D=null,V=null,$,z=0,it=w.length;for(;it--;)z+=w[it].unit.byteLength;for(let U=0,q=w.length;U<q;U++){const At=w[U],F=At.unit;let N=At.pts;if(V!==null){const nt=E[U-1];nt.duration=Math.round((N-V)/f)}else if(i&&t.segmentCodec==="aac"&&(N=x),D=N,z>0){z+=C;try{$=new Uint8Array(z)}catch(nt){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:nt,bytes:z,reason:`fail allocating audio mdat ${z}`});return}A||(new DataView($.buffer).setUint32(0,z),$.set(st.types.mdat,4))}else return;$.set(F,C);const j=F.byteLength;C+=j,E.push(new cf(!0,p,j,0)),V=N}const at=E.length;if(!at)return;const J=E[E.length-1];this.nextAudioPts=x=V+f*J.duration;const wt=A?new Uint8Array(0):st.moof(t.sequenceNumber++,D/f,ci({},t,{samples:E}));t.samples=[];const vt=D/c,Ot=x/c,Gt={data1:wt,data2:$,startPTS:vt,endPTS:Ot,startDTS:vt,endDTS:Ot,type:"audio",hasAudio:!0,hasVideo:!1,nb:at};return this.isAudioContiguous=!0,Gt}remuxEmptyAudio(t,e,i,n){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:n.startDTS*o)+g,A=n.endDTS*o+g,E=d*af,T=Math.ceil((A-v)/E),w=sf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let x=0;x<T;x++){const O=v+x*E;C.push({unit:w,pts:O,dts:O})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function dr(s,t){let e;if(t===null)return s;for(t<s?e=-8589934592:e=8589934592;Math.abs(s-t)>4294967296;)s+=e;return s}function vb(s){for(let t=0;t<s.length;t++)if(s[t].key)return t;return-1}function of(s,t,e,i){const n=s.samples.length;if(!n)return;const o=s.inputTimeScale;for(let d=0;d<n;d++){const f=s.samples[d];f.pts=dr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=dr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=s.samples;return s.samples=[],{samples:c}}function lf(s,t,e){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let c=0;c<i;c++){const d=s.samples[c];d.pts=dr(d.pts-e.baseTime*n/e.timescale,t*n)/n}s.samples.sort((c,d)=>c.pts-d.pts);const o=s.samples;return s.samples=[],{samples:o}}class cf{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags=new yb(t)}}class yb{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 bb{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,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Uv(t,n)),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 n=this.initData=h0(t);e||(e=hf(n.audio,Ce.AUDIO)),i||(i=hf(n.video,Ce.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,n,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const A=e.samples;if(!(A!=null&&A.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(A),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Gv(A,T),C=Bv(T,A),x=C===null?o:C;(Ab(p,x,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=x-o,p&&p.timescale===1&&X.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const O=t?x-p.baseTime/p.timescale:g,B=O+w;Hv(T,A,p.baseTime/p.timescale),w>0?this.lastEndTime=B:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const D=!!T.audio,V=!!T.video;let $="";D&&($+="audio"),V&&($+="video");const z={data1:A,startPTS:O,startDTS:O,endPTS:B,endDTS:B,type:$,hasAudio:D,hasVideo:V,nb:1,dropped:0};return v.audio=z.type==="audio"?z:void 0,v.video=z.type!=="audio"?z:void 0,v.initSegment=E,v.id3=of(i,o,p,p),n.samples.length&&(v.text=lf(n,o,p)),v}}function Ab(s,t,e,i){if(s===null)return!0;const n=Math.max(i,1),o=t-s.baseTime/s.timescale;return Math.abs(o-e)>n}function hf(s,t){const e=s==null?void 0:s.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 ts;try{ts=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),ts=typeof self<"u"&&self.Date.now}const Uc=[{demux:ib,remux:bb},{demux:Es,remux:Nc},{demux:tb,remux:Nc},{demux:ub,remux:Nc}];class df{constructor(t,e,i,n,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=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const o=i.transmuxing;o.executeStart=ts();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:A,timeOffset:E,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:x,duration:O,initSegmentData:B}=f,D=Eb(c,e);if(D&&D.method==="AES-128"){const it=this.getDecrypter();if(it.isSync()){let at=it.softwareDecrypt(c,D.key.buffer,D.iv.buffer);if(i.part>-1&&(at=it.flush()),!at)return o.executeEnd=ts(),Bc(i);c=new Uint8Array(at)}else return this.decryptionPromise=it.webCryptoDecrypt(c,D.key.buffer,D.iv.buffer).then(at=>{const J=this.push(at,null,i);return this.decryptionPromise=null,J}),this.decryptionPromise}const V=this.needsProbing(g,v);if(V){const it=this.configureTransmuxer(c);if(it)return X.warn(`[transmuxer] ${it.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:it,reason:it.message}),o.executeEnd=ts(),Bc(i)}(g||v||T||V)&&this.resetInitSegment(B,w,C,O,e),(g||T||V)&&this.resetInitialTimestamp(x),p||this.resetContiguity();const $=this.transmux(c,D,E,A,i),z=this.currentTransmuxState;return z.contiguous=!0,z.discontinuity=!1,z.trackSwitch=!1,o.executeEnd=ts(),$}flush(t){const e=t.transmuxing;e.executeStart=ts();const{decrypter:i,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=n;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=ts(),[Bc(t)];const g=f.flush(d);return Uo(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(n,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=ts()}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,n,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,n),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,n,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,n,o):c=this.transmuxUnencrypted(t,i,n,o),c}transmuxUnencrypted(t,e,i,n){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:n}}transmuxSampleAes(t,e,i,n,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:o}=this;let c;for(let v=0,A=Uc.length;v<A;v++)if(Uc[v].demux.probe(t)){c=Uc[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,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,n),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 Dc(this.config)),t}}function Eb(s,t){let e=null;return s.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Bc=s=>({remuxResult:{},chunkMeta:s});function Uo(s){return"then"in s&&s.then instanceof Function}class Tb{constructor(t,e,i,n,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=n,this.defaultInitPts=o||null}}class kb{constructor(t,e,i,n,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=n,this.timeOffset=o,this.initSegmentChange=c}}var uf={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(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 E=new n(g,v||f,A),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],E]:f._events[T].push(E):(f._events[T]=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,A=g.length,E=new Array(A);v<A;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,A,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,x,O;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){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,E),!0}for(O=1,x=new Array(C-1);O<C;O++)x[O-1]=arguments[O];w.fn.apply(w.context,x)}else{var B=w.length,D;for(O=0;O<B;O++)switch(w[O].once&&this.removeListener(f,w[O].fn,void 0,!0),C){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,p);break;case 3:w[O].fn.call(w[O].context,p,g);break;case 4:w[O].fn.call(w[O].context,p,g,v);break;default:if(!x)for(D=1,x=new Array(C-1);D<C;D++)x[D-1]=arguments[D];w[O].fn.apply(w[O].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 E=this._events[A];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,A);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);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,s.exports=d})(uf);var wb=uf.exports,Gc=cv(wb);const Vc=_o()||{isTypeSupported:()=>!1};class ff{constructor(t,e,i,n){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=n;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 Gc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Vc.isTypeSupported("video/mp4"),mpeg:Vc.isTypeSupported("audio/mpeg"),mp3:Vc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||jy())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=zy(o.workerPath)):(X.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,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:pt.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new df(this.observer,d,o,f,e)}return}this.transmuxer=new df(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,n,o,c,d,f,p,g){var v,A;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=c?c.start:o.start,w=o.decryptdata,C=this.frag,x=!(C&&o.cc===C.cc),O=!(C&&p.level===C.level),B=C?p.sn-C.sn:-1,D=this.part?p.part-this.part.index:-1,V=B===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),$=!O&&(B===1||B===0&&(D===1||V&&D<=0)),z=self.performance.now();(O||B||o.stats.parsing.start===0)&&(o.stats.parsing.start=z),c&&(D||!$)&&(c.stats.parsing.start=z);const it=!(C&&((v=o.initSegment)==null?void 0:v.url)===((A=C.initSegment)==null?void 0:A.url)),at=new kb(x,$,f,O,T,it);if(!$||x||it){X.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
|
183
|
+
*/const hu=(s,t,e)=>{const i=new Map;for(let n=t;n<=e;n++)i.set(s[n],n);return i},du=bn(class extends sa{constructor(s){if(super(s),s.type!==yn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(s,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const n=[],o=[];let c=0;for(const d of s)n[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:n}}render(s,t,e){return this.ht(s,t,e).values}update(s,[t,e,i]){const n=og(s),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(n))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,A=n.length-1,E=0,T=o.length-1;for(;v<=A&&E<=T;)if(n[v]===null)v++;else if(n[A]===null)A--;else if(d[v]===c[E])f[E]=Zs(n[v],o[E]),v++,E++;else if(d[A]===c[T])f[T]=Zs(n[A],o[T]),A--,T--;else if(d[v]===c[T])f[T]=Zs(n[v],o[T]),ra(s,f[T+1],n[v]),v++,T--;else if(d[A]===c[E])f[E]=Zs(n[A],o[E]),ra(s,n[v],n[A]),A--,E++;else if(p===void 0&&(p=hu(c,E,T),g=hu(d,v,A)),p.has(d[v]))if(p.has(d[A])){const w=g.get(c[E]),C=w!==void 0?n[w]:null;if(C===null){const x=ra(s,n[v]);Zs(x,o[E]),f[E]=x}else f[E]=Zs(C,o[E]),ra(s,n[v],C),n[w]=null;E++}else Sl(n[A]),A--;else Sl(n[v]),v++;for(;E<=T;){const w=ra(s,f[T+1]);Zs(w,o[E]),f[E++]=w}for(;v<=A;){const w=n[v++];w!==null&&Sl(w)}return this.dt=c,ag(s,f),fs}});var Wi="top",or="bottom",lr="right",ji="left",Kl="auto",pa=[Wi,or,lr,ji],An="start",ga="end",xm="clippingParents",uu="viewport",ma="popper",Pm="reference",fu=pa.reduce(function(s,t){return s.concat([t+"-"+An,t+"-"+ga])},[]),pu=[].concat(pa,[Kl]).reduce(function(s,t){return s.concat([t,t+"-"+An,t+"-"+ga])},[]),Om="beforeRead",Mm="read",$m="afterRead",Fm="beforeMain",Nm="main",Um="afterMain",Bm="beforeWrite",Gm="write",Vm="afterWrite",Hm=[Om,Mm,$m,Fm,Nm,Um,Bm,Gm,Vm];function Dr(s){return s?(s.nodeName||"").toLowerCase():null}function ir(s){if(s==null)return window;if(s.toString()!=="[object Window]"){var t=s.ownerDocument;return t&&t.defaultView||window}return s}function tn(s){var t=ir(s).Element;return s instanceof t||s instanceof Element}function cr(s){var t=ir(s).HTMLElement;return s instanceof t||s instanceof HTMLElement}function zl(s){if(typeof ShadowRoot>"u")return!1;var t=ir(s).ShadowRoot;return s instanceof t||s instanceof ShadowRoot}function Wm(s){var t=s.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},n=t.attributes[e]||{},o=t.elements[e];!cr(o)||!Dr(o)||(Object.assign(o.style,i),Object.keys(n).forEach(function(c){var d=n[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function jm(s){var t=s.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 n=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},{});!cr(n)||!Dr(n)||(Object.assign(n.style,d),Object.keys(o).forEach(function(f){n.removeAttribute(f)}))})}}const gu={name:"applyStyles",enabled:!0,phase:"write",fn:Wm,effect:jm,requires:["computeStyles"]};function xr(s){return s.split("-")[0]}var en=Math.max,mo=Math.min,En=Math.round;function Yl(){var s=navigator.userAgentData;return s!=null&&s.brands&&Array.isArray(s.brands)?s.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function mu(){return!/^((?!chrome|android).)*safari/i.test(Yl())}function Tn(s,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=s.getBoundingClientRect(),n=1,o=1;t&&cr(s)&&(n=s.offsetWidth>0&&En(i.width)/s.offsetWidth||1,o=s.offsetHeight>0&&En(i.height)/s.offsetHeight||1);var c=tn(s)?ir(s):window,d=c.visualViewport,f=!mu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/n,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/n,A=i.height/o;return{width:v,height:A,top:g,right:p+v,bottom:g+A,left:p,x:p,y:g}}function Xl(s){var t=Tn(s),e=s.offsetWidth,i=s.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:s.offsetLeft,y:s.offsetTop,width:e,height:i}}function vu(s,t){var e=t.getRootNode&&t.getRootNode();if(s.contains(t))return!0;if(e&&zl(e)){var i=t;do{if(i&&s.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function Qr(s){return ir(s).getComputedStyle(s)}function Km(s){return["table","td","th"].indexOf(Dr(s))>=0}function As(s){return((tn(s)?s.ownerDocument:s.document)||window.document).documentElement}function vo(s){return Dr(s)==="html"?s:s.assignedSlot||s.parentNode||(zl(s)?s.host:null)||As(s)}function yu(s){return!cr(s)||Qr(s).position==="fixed"?null:s.offsetParent}function zm(s){var t=/firefox/i.test(Yl()),e=/Trident/i.test(Yl());if(e&&cr(s)){var i=Qr(s);if(i.position==="fixed")return null}var n=vo(s);for(zl(n)&&(n=n.host);cr(n)&&["html","body"].indexOf(Dr(n))<0;){var o=Qr(n);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 n;n=n.parentNode}return null}function va(s){for(var t=ir(s),e=yu(s);e&&Km(e)&&Qr(e).position==="static";)e=yu(e);return e&&(Dr(e)==="html"||Dr(e)==="body"&&Qr(e).position==="static")?t:e||zm(s)||t}function Zl(s){return["top","bottom"].indexOf(s)>=0?"x":"y"}function ya(s,t,e){return en(s,mo(t,e))}function Ym(s,t,e){var i=ya(s,t,e);return i>e?e:i}function bu(){return{top:0,right:0,bottom:0,left:0}}function Au(s){return Object.assign({},bu(),s)}function Eu(s,t){return t.reduce(function(e,i){return e[i]=s,e},{})}var Xm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,Au(typeof t!="number"?t:Eu(t,pa))};function Zm(s){var t,e=s.state,i=s.name,n=s.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=xr(e.placement),f=Zl(d),p=[ji,lr].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Xm(n.padding,e),A=Xl(o),E=f==="y"?Wi:ji,T=f==="y"?or:lr,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],C=c[f]-e.rects.reference[f],x=va(o),O=x?f==="y"?x.clientHeight||0:x.clientWidth||0:0,B=w/2-C/2,D=v[E],V=O-A[g]-v[T],$=O/2-A[g]/2+B,z=ya(D,$,V),it=f;e.modifiersData[i]=(t={},t[it]=z,t.centerOffset=z-$,t)}}function qm(s){var t=s.state,e=s.options,i=e.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=t.elements.popper.querySelector(n),!n)||vu(t.elements.popper,n)&&(t.elements.arrow=n))}const Qm={name:"arrow",enabled:!0,phase:"main",fn:Zm,effect:qm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function kn(s){return s.split("-")[1]}var Jm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function t1(s,t){var e=s.x,i=s.y,n=t.devicePixelRatio||1;return{x:En(e*n)/n||0,y:En(i*n)/n||0}}function Tu(s){var t,e=s.popper,i=s.popperRect,n=s.placement,o=s.variation,c=s.offsets,d=s.position,f=s.gpuAcceleration,p=s.adaptive,g=s.roundOffsets,v=s.isFixed,A=c.x,E=A===void 0?0:A,T=c.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var x=c.hasOwnProperty("x"),O=c.hasOwnProperty("y"),B=ji,D=Wi,V=window;if(p){var $=va(e),z="clientHeight",it="clientWidth";if($===ir(e)&&($=As(e),Qr($).position!=="static"&&d==="absolute"&&(z="scrollHeight",it="scrollWidth")),$=$,n===Wi||(n===ji||n===lr)&&o===ga){D=or;var at=v&&$===V&&V.visualViewport?V.visualViewport.height:$[z];w-=at-i.height,w*=f?1:-1}if(n===ji||(n===Wi||n===or)&&o===ga){B=lr;var J=v&&$===V&&V.visualViewport?V.visualViewport.width:$[it];E-=J-i.width,E*=f?1:-1}}var wt=Object.assign({position:d},p&&Jm),vt=g===!0?t1({x:E,y:w},ir(e)):{x:E,y:w};if(E=vt.x,w=vt.y,f){var Ot;return Object.assign({},wt,(Ot={},Ot[D]=O?"0":"",Ot[B]=x?"0":"",Ot.transform=(V.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Ot))}return Object.assign({},wt,(t={},t[D]=O?w+"px":"",t[B]=x?E+"px":"",t.transform="",t))}function e1(s){var t=s.state,e=s.options,i=e.gpuAcceleration,n=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:xr(t.placement),variation:kn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:n,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Tu(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,Tu(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 i1={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:e1,data:{}};var yo={passive:!0};function r1(s){var t=s.state,e=s.instance,i=s.options,n=i.scroll,o=n===void 0?!0:n,c=i.resize,d=c===void 0?!0:c,f=ir(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,yo)}),d&&f.addEventListener("resize",e.update,yo),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,yo)}),d&&f.removeEventListener("resize",e.update,yo)}}const s1={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:r1,data:{}};var n1={left:"right",right:"left",bottom:"top",top:"bottom"};function bo(s){return s.replace(/left|right|bottom|top/g,function(t){return n1[t]})}var a1={start:"end",end:"start"};function ku(s){return s.replace(/start|end/g,function(t){return a1[t]})}function ql(s){var t=ir(s),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function Ql(s){return Tn(As(s)).left+ql(s).scrollLeft}function o1(s,t){var e=ir(s),i=As(s),n=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(n){o=n.width,c=n.height;var p=mu();(p||!p&&t==="fixed")&&(d=n.offsetLeft,f=n.offsetTop)}return{width:o,height:c,x:d+Ql(s),y:f}}function l1(s){var t,e=As(s),i=ql(s),n=(t=s.ownerDocument)==null?void 0:t.body,o=en(e.scrollWidth,e.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),c=en(e.scrollHeight,e.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),d=-i.scrollLeft+Ql(s),f=-i.scrollTop;return Qr(n||e).direction==="rtl"&&(d+=en(e.clientWidth,n?n.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Jl(s){var t=Qr(s),e=t.overflow,i=t.overflowX,n=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+n+i)}function wu(s){return["html","body","#document"].indexOf(Dr(s))>=0?s.ownerDocument.body:cr(s)&&Jl(s)?s:wu(vo(s))}function ba(s,t){var e;t===void 0&&(t=[]);var i=wu(s),n=i===((e=s.ownerDocument)==null?void 0:e.body),o=ir(i),c=n?[o].concat(o.visualViewport||[],Jl(i)?i:[]):i,d=t.concat(c);return n?d:d.concat(ba(vo(c)))}function tc(s){return Object.assign({},s,{left:s.x,top:s.y,right:s.x+s.width,bottom:s.y+s.height})}function c1(s,t){var e=Tn(s,!1,t==="fixed");return e.top=e.top+s.clientTop,e.left=e.left+s.clientLeft,e.bottom=e.top+s.clientHeight,e.right=e.left+s.clientWidth,e.width=s.clientWidth,e.height=s.clientHeight,e.x=e.left,e.y=e.top,e}function Su(s,t,e){return t===uu?tc(o1(s,e)):tn(t)?c1(t,e):tc(l1(As(s)))}function h1(s){var t=ba(vo(s)),e=["absolute","fixed"].indexOf(Qr(s).position)>=0,i=e&&cr(s)?va(s):s;return tn(i)?t.filter(function(n){return tn(n)&&vu(n,i)&&Dr(n)!=="body"}):[]}function d1(s,t,e,i){var n=t==="clippingParents"?h1(s):[].concat(t),o=[].concat(n,[e]),c=o[0],d=o.reduce(function(f,p){var g=Su(s,p,i);return f.top=en(g.top,f.top),f.right=mo(g.right,f.right),f.bottom=mo(g.bottom,f.bottom),f.left=en(g.left,f.left),f},Su(s,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 Ru(s){var t=s.reference,e=s.element,i=s.placement,n=i?xr(i):null,o=i?kn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(n){case Wi:f={x:c,y:t.y-e.height};break;case or:f={x:c,y:t.y+t.height};break;case lr:f={x:t.x+t.width,y:d};break;case ji:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=n?Zl(n):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case An:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ga:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Aa(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=i===void 0?s.placement:i,o=e.strategy,c=o===void 0?s.strategy:o,d=e.boundary,f=d===void 0?xm:d,p=e.rootBoundary,g=p===void 0?uu:p,v=e.elementContext,A=v===void 0?ma:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,x=Au(typeof C!="number"?C:Eu(C,pa)),O=A===ma?Pm:ma,B=s.rects.popper,D=s.elements[T?O:A],V=d1(tn(D)?D:D.contextElement||As(s.elements.popper),f,g,c),$=Tn(s.elements.reference),z=Ru({reference:$,element:B,strategy:"absolute",placement:n}),it=tc(Object.assign({},B,z)),at=A===ma?it:$,J={top:V.top-at.top+x.top,bottom:at.bottom-V.bottom+x.bottom,left:V.left-at.left+x.left,right:at.right-V.right+x.right},wt=s.modifiersData.offset;if(A===ma&&wt){var vt=wt[n];Object.keys(J).forEach(function(Ot){var Gt=[lr,or].indexOf(Ot)>=0?1:-1,U=[Wi,or].indexOf(Ot)>=0?"y":"x";J[Ot]+=vt[U]*Gt})}return J}function u1(s,t){t===void 0&&(t={});var e=t,i=e.placement,n=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?pu:f,g=kn(i),v=g?d?fu:fu.filter(function(T){return kn(T)===g}):pa,A=v.filter(function(T){return p.indexOf(T)>=0});A.length===0&&(A=v);var E=A.reduce(function(T,w){return T[w]=Aa(s,{placement:w,boundary:n,rootBoundary:o,padding:c})[xr(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function f1(s){if(xr(s)===Kl)return[];var t=bo(s);return[ku(s),t,ku(t)]}function p1(s){var t=s.state,e=s.options,i=s.name;if(!t.modifiersData[i]._skip){for(var n=e.mainAxis,o=n===void 0?!0:n,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,A=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,x=xr(C),O=x===C,B=f||(O||!T?[bo(C)]:f1(C)),D=[C].concat(B).reduce(function(Nt,jt){return Nt.concat(xr(jt)===Kl?u1(t,{placement:jt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):jt)},[]),V=t.rects.reference,$=t.rects.popper,z=new Map,it=!0,at=D[0],J=0;J<D.length;J++){var wt=D[J],vt=xr(wt),Ot=kn(wt)===An,Gt=[Wi,or].indexOf(vt)>=0,U=Gt?"width":"height",q=Aa(t,{placement:wt,boundary:g,rootBoundary:v,altBoundary:A,padding:p}),At=Gt?Ot?lr:ji:Ot?or:Wi;V[U]>$[U]&&(At=bo(At));var F=bo(At),N=[];if(o&&N.push(q[vt]<=0),d&&N.push(q[At]<=0,q[F]<=0),N.every(function(Nt){return Nt})){at=wt,it=!1;break}z.set(wt,N)}if(it)for(var j=T?3:1,nt=function(jt){var ue=D.find(function(me){var ge=z.get(me);if(ge)return ge.slice(0,jt).every(function(je){return je})});if(ue)return at=ue,"break"},ht=j;ht>0;ht--){var Lt=nt(ht);if(Lt==="break")break}t.placement!==at&&(t.modifiersData[i]._skip=!0,t.placement=at,t.reset=!0)}}const g1={name:"flip",enabled:!0,phase:"main",fn:p1,requiresIfExists:["offset"],data:{_skip:!1}};function _u(s,t,e){return e===void 0&&(e={x:0,y:0}),{top:s.top-t.height-e.y,right:s.right-t.width+e.x,bottom:s.bottom-t.height+e.y,left:s.left-t.width-e.x}}function Lu(s){return[Wi,lr,or,ji].some(function(t){return s[t]>=0})}function m1(s){var t=s.state,e=s.name,i=t.rects.reference,n=t.rects.popper,o=t.modifiersData.preventOverflow,c=Aa(t,{elementContext:"reference"}),d=Aa(t,{altBoundary:!0}),f=_u(c,i),p=_u(d,n,o),g=Lu(f),v=Lu(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 v1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:m1};function y1(s,t,e){var i=xr(s),n=[ji,Wi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:s})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*n,[ji,lr].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function b1(s){var t=s.state,e=s.options,i=s.name,n=e.offset,o=n===void 0?[0,0]:n,c=pu.reduce(function(g,v){return g[v]=y1(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 A1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:b1};function E1(s){var t=s.state,e=s.name;t.modifiersData[e]=Ru({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const T1={name:"popperOffsets",enabled:!0,phase:"read",fn:E1,data:{}};function k1(s){return s==="x"?"y":"x"}function w1(s){var t=s.state,e=s.options,i=s.name,n=e.mainAxis,o=n===void 0?!0:n,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,A=e.tether,E=A===void 0?!0:A,T=e.tetherOffset,w=T===void 0?0:T,C=Aa(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),x=xr(t.placement),O=kn(t.placement),B=!O,D=Zl(x),V=k1(D),$=t.modifiersData.popperOffsets,z=t.rects.reference,it=t.rects.popper,at=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,J=typeof at=="number"?{mainAxis:at,altAxis:at}:Object.assign({mainAxis:0,altAxis:0},at),wt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,vt={x:0,y:0};if($){if(o){var Ot,Gt=D==="y"?Wi:ji,U=D==="y"?or:lr,q=D==="y"?"height":"width",At=$[D],F=At+C[Gt],N=At-C[U],j=E?-it[q]/2:0,nt=O===An?z[q]:it[q],ht=O===An?-it[q]:-z[q],Lt=t.elements.arrow,Nt=E&&Lt?Xl(Lt):{width:0,height:0},jt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:bu(),ue=jt[Gt],me=jt[U],ge=ya(0,z[q],Nt[q]),je=B?z[q]/2-j-ge-ue-J.mainAxis:nt-ge-ue-J.mainAxis,Re=B?-z[q]/2+j+ge+me+J.mainAxis:ht+ge+me+J.mainAxis,Kt=t.elements.arrow&&va(t.elements.arrow),be=Kt?D==="y"?Kt.clientTop||0:Kt.clientLeft||0:0,he=(Ot=wt==null?void 0:wt[D])!=null?Ot:0,Oe=At+je-he-be,Ut=At+Re-he,Ke=ya(E?mo(F,Oe):F,At,E?en(N,Ut):N);$[D]=Ke,vt[D]=Ke-At}if(d){var Fe,Ge=D==="x"?Wi:ji,ke=D==="x"?or:lr,de=$[V],ze=V==="y"?"height":"width",oe=de+C[Ge],Ne=de-C[ke],Ue=[Wi,ji].indexOf(x)!==-1,ui=(Fe=wt==null?void 0:wt[V])!=null?Fe:0,Le=Ue?oe:de-z[ze]-it[ze]-ui+J.altAxis,vi=Ue?de+z[ze]+it[ze]-ui-J.altAxis:Ne,kr=E&&Ue?Ym(Le,de,vi):ya(E?Le:oe,de,E?vi:Ne);$[V]=kr,vt[V]=kr-de}t.modifiersData[i]=vt}}const S1={name:"preventOverflow",enabled:!0,phase:"main",fn:w1,requiresIfExists:["offset"]};function R1(s){return{scrollLeft:s.scrollLeft,scrollTop:s.scrollTop}}function _1(s){return s===ir(s)||!cr(s)?ql(s):R1(s)}function L1(s){var t=s.getBoundingClientRect(),e=En(t.width)/s.offsetWidth||1,i=En(t.height)/s.offsetHeight||1;return e!==1||i!==1}function C1(s,t,e){e===void 0&&(e=!1);var i=cr(t),n=cr(t)&&L1(t),o=As(t),c=Tn(s,n,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Dr(t)!=="body"||Jl(o))&&(d=_1(t)),cr(t)?(f=Tn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=Ql(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function I1(s){var t=new Map,e=new Set,i=[];s.forEach(function(o){t.set(o.name,o)});function n(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&&n(f)}}),i.push(o)}return s.forEach(function(o){e.has(o.name)||n(o)}),i}function D1(s){var t=I1(s);return Hm.reduce(function(e,i){return e.concat(t.filter(function(n){return n.phase===i}))},[])}function x1(s){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(s())})})),t}}function P1(s){var t=s.reduce(function(e,i){var n=e[i.name];return e[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var Cu={placement:"bottom",modifiers:[],strategy:"absolute"};function Iu(){for(var s=arguments.length,t=new Array(s),e=0;e<s;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function O1(s){s===void 0&&(s={});var t=s,e=t.defaultModifiers,i=e===void 0?[]:e,n=t.defaultOptions,o=n===void 0?Cu:n;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},Cu,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],A=!1,E={state:g,setOptions:function(x){var O=typeof x=="function"?x(g.options):x;w(),g.options=Object.assign({},o,g.options,O),g.scrollParents={reference:tn(d)?ba(d):d.contextElement?ba(d.contextElement):[],popper:ba(f)};var B=D1(P1([].concat(i,g.options.modifiers)));return g.orderedModifiers=B.filter(function(D){return D.enabled}),T(),E.update()},forceUpdate:function(){if(!A){var x=g.elements,O=x.reference,B=x.popper;if(Iu(O,B)){g.rects={reference:C1(O,va(B),g.options.strategy==="fixed"),popper:Xl(B)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(J){return g.modifiersData[J.name]=Object.assign({},J.data)});for(var D=0;D<g.orderedModifiers.length;D++){if(g.reset===!0){g.reset=!1,D=-1;continue}var V=g.orderedModifiers[D],$=V.fn,z=V.options,it=z===void 0?{}:z,at=V.name;typeof $=="function"&&(g=$({state:g,options:it,name:at,instance:E})||g)}}}},update:x1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),A=!0}};if(!Iu(d,f))return E;E.setOptions(p).then(function(C){!A&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var x=C.name,O=C.options,B=O===void 0?{}:O,D=C.effect;if(typeof D=="function"){var V=D({state:g,name:x,instance:E,options:B}),$=function(){};v.push(V||$)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var M1=[s1,T1,i1,gu,A1,g1,S1,Qm,v1],$1=O1({defaultModifiers:M1}),F1="tippy-box",Du="tippy-content",N1="tippy-backdrop",xu="tippy-arrow",Pu="tippy-svg-arrow",rn={passive:!0,capture:!0},Ou=function(){return document.body};function ec(s,t,e){if(Array.isArray(s)){var i=s[t];return i??(Array.isArray(e)?e[t]:e)}return s}function ic(s,t){var e={}.toString.call(s);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Mu(s,t){return typeof s=="function"?s.apply(void 0,t):s}function $u(s,t){if(t===0)return s;var e;return function(i){clearTimeout(e),e=setTimeout(function(){s(i)},t)}}function U1(s){return s.split(/\s+/).filter(Boolean)}function wn(s){return[].concat(s)}function Fu(s,t){s.indexOf(t)===-1&&s.push(t)}function B1(s){return s.filter(function(t,e){return s.indexOf(t)===e})}function G1(s){return s.split("-")[0]}function Ao(s){return[].slice.call(s)}function Nu(s){return Object.keys(s).reduce(function(t,e){return s[e]!==void 0&&(t[e]=s[e]),t},{})}function Ea(){return document.createElement("div")}function Eo(s){return["Element","Fragment"].some(function(t){return ic(s,t)})}function V1(s){return ic(s,"NodeList")}function H1(s){return ic(s,"MouseEvent")}function W1(s){return!!(s&&s._tippy&&s._tippy.reference===s)}function j1(s){return Eo(s)?[s]:V1(s)?Ao(s):Array.isArray(s)?s:Ao(document.querySelectorAll(s))}function rc(s,t){s.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Uu(s,t){s.forEach(function(e){e&&e.setAttribute("data-state",t)})}function K1(s){var t,e=wn(s),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function z1(s,t){var e=t.clientX,i=t.clientY;return s.every(function(n){var o=n.popperRect,c=n.popperState,d=n.props,f=d.interactiveBorder,p=G1(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,E=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-i+v>f,C=i-o.bottom-A>f,x=o.left-e+E>f,O=e-o.right-T>f;return w||C||x||O})}function sc(s,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){s[i](n,e)})}function Bu(s,t){for(var e=t;e;){var i;if(s.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Pr={isTouch:!1},Gu=0;function Y1(){Pr.isTouch||(Pr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Vu))}function Vu(){var s=performance.now();s-Gu<20&&(Pr.isTouch=!1,document.removeEventListener("mousemove",Vu)),Gu=s}function X1(){var s=document.activeElement;if(W1(s)){var t=s._tippy;s.blur&&!t.state.isVisible&&s.blur()}}function Z1(){document.addEventListener("touchstart",Y1,rn),window.addEventListener("blur",X1)}var q1=typeof window<"u"&&typeof document<"u",Q1=q1?!!window.msCrypto:!1,J1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},tv={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},br=Object.assign({appendTo:Ou,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},J1,tv),ev=Object.keys(br),iv=function(t){var e=Object.keys(t);e.forEach(function(i){br[i]=t[i]})};function Hu(s){var t=s.plugins||[],e=t.reduce(function(i,n){var o=n.name,c=n.defaultValue;if(o){var d;i[o]=s[o]!==void 0?s[o]:(d=br[o])!=null?d:c}return i},{});return Object.assign({},s,e)}function rv(s,t){var e=t?Object.keys(Hu(Object.assign({},br,{plugins:t}))):ev,i=e.reduce(function(n,o){var c=(s.getAttribute("data-tippy-"+o)||"").trim();if(!c)return n;if(o==="content")n[o]=c;else try{n[o]=JSON.parse(c)}catch{n[o]=c}return n},{});return i}function Wu(s,t){var e=Object.assign({},t,{content:Mu(t.content,[s])},t.ignoreAttributes?{}:rv(s,t.plugins));return e.aria=Object.assign({},br.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 sv=function(){return"innerHTML"};function nc(s,t){s[sv()]=t}function ju(s){var t=Ea();return s===!0?t.className=xu:(t.className=Pu,Eo(s)?t.appendChild(s):nc(t,s)),t}function Ku(s,t){Eo(t.content)?(nc(s,""),s.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?nc(s,t.content):s.textContent=t.content)}function ac(s){var t=s.firstElementChild,e=Ao(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Du)}),arrow:e.find(function(i){return i.classList.contains(xu)||i.classList.contains(Pu)}),backdrop:e.find(function(i){return i.classList.contains(N1)})}}function zu(s){var t=Ea(),e=Ea();e.className=F1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ea();i.className=Du,i.setAttribute("data-state","hidden"),Ku(i,s.props),t.appendChild(e),e.appendChild(i),n(s.props,s.props);function n(o,c){var d=ac(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)&&Ku(p,s.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(ju(c.arrow))):f.appendChild(ju(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:n}}zu.$$tippy=!0;var nv=1,To=[],oc=[];function av(s,t){var e=Wu(s,Object.assign({},br,Hu(Nu(t)))),i,n,o,c=!1,d=!1,f=!1,p=!1,g,v,A,E=[],T=$u(Oe,e.interactiveDebounce),w,C=nv++,x=null,O=B1(e.plugins),B={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},D={id:C,reference:s,popper:Ea(),popperInstance:x,props:e,state:B,plugins:O,clearDelayTimeouts:Le,setProps:vi,setContent:kr,show:ni,hide:wr,hideWithInteractivity:_s,enable:Ue,disable:ui,unmount:Ls,destroy:rr};if(!e.render)return D;var V=e.render(D),$=V.popper,z=V.onUpdate;$.setAttribute("data-tippy-root",""),$.id="tippy-"+D.id,D.popper=$,s._tippy=D,$._tippy=D;var it=O.map(function(dt){return dt.fn(D)}),at=s.hasAttribute("aria-expanded");return Kt(),j(),At(),F("onCreate",[D]),e.showOnCreate&&oe(),$.addEventListener("mouseenter",function(){D.props.interactive&&D.state.isVisible&&D.clearDelayTimeouts()}),$.addEventListener("mouseleave",function(){D.props.interactive&&D.props.trigger.indexOf("mouseenter")>=0&&Gt().addEventListener("mousemove",T)}),D;function J(){var dt=D.props.touch;return Array.isArray(dt)?dt:[dt,0]}function wt(){return J()[0]==="hold"}function vt(){var dt;return!!((dt=D.props.render)!=null&&dt.$$tippy)}function Ot(){return w||s}function Gt(){var dt=Ot().parentNode;return dt?K1(dt):document}function U(){return ac($)}function q(dt){return D.state.isMounted&&!D.state.isVisible||Pr.isTouch||g&&g.type==="focus"?0:ec(D.props.delay,dt?0:1,br.delay)}function At(dt){dt===void 0&&(dt=!1),$.style.pointerEvents=D.props.interactive&&!dt?"":"none",$.style.zIndex=""+D.props.zIndex}function F(dt,Vt,Xt){if(Xt===void 0&&(Xt=!0),it.forEach(function(se){se[dt]&&se[dt].apply(se,Vt)}),Xt){var ve;(ve=D.props)[dt].apply(ve,Vt)}}function N(){var dt=D.props.aria;if(dt.content){var Vt="aria-"+dt.content,Xt=$.id,ve=wn(D.props.triggerTarget||s);ve.forEach(function(se){var ci=se.getAttribute(Vt);if(D.state.isVisible)se.setAttribute(Vt,ci?ci+" "+Xt:Xt);else{var Pi=ci&&ci.replace(Xt,"").trim();Pi?se.setAttribute(Vt,Pi):se.removeAttribute(Vt)}})}}function j(){if(!(at||!D.props.aria.expanded)){var dt=wn(D.props.triggerTarget||s);dt.forEach(function(Vt){D.props.interactive?Vt.setAttribute("aria-expanded",D.state.isVisible&&Vt===Ot()?"true":"false"):Vt.removeAttribute("aria-expanded")})}}function nt(){Gt().removeEventListener("mousemove",T),To=To.filter(function(dt){return dt!==T})}function ht(dt){if(!(Pr.isTouch&&(f||dt.type==="mousedown"))){var Vt=dt.composedPath&&dt.composedPath()[0]||dt.target;if(!(D.props.interactive&&Bu($,Vt))){if(wn(D.props.triggerTarget||s).some(function(Xt){return Bu(Xt,Vt)})){if(Pr.isTouch||D.state.isVisible&&D.props.trigger.indexOf("click")>=0)return}else F("onClickOutside",[D,dt]);D.props.hideOnClick===!0&&(D.clearDelayTimeouts(),D.hide(),d=!0,setTimeout(function(){d=!1}),D.state.isMounted||ue())}}}function Lt(){f=!0}function Nt(){f=!1}function jt(){var dt=Gt();dt.addEventListener("mousedown",ht,!0),dt.addEventListener("touchend",ht,rn),dt.addEventListener("touchstart",Nt,rn),dt.addEventListener("touchmove",Lt,rn)}function ue(){var dt=Gt();dt.removeEventListener("mousedown",ht,!0),dt.removeEventListener("touchend",ht,rn),dt.removeEventListener("touchstart",Nt,rn),dt.removeEventListener("touchmove",Lt,rn)}function me(dt,Vt){je(dt,function(){!D.state.isVisible&&$.parentNode&&$.parentNode.contains($)&&Vt()})}function ge(dt,Vt){je(dt,Vt)}function je(dt,Vt){var Xt=U().box;function ve(se){se.target===Xt&&(sc(Xt,"remove",ve),Vt())}if(dt===0)return Vt();sc(Xt,"remove",v),sc(Xt,"add",ve),v=ve}function Re(dt,Vt,Xt){Xt===void 0&&(Xt=!1);var ve=wn(D.props.triggerTarget||s);ve.forEach(function(se){se.addEventListener(dt,Vt,Xt),E.push({node:se,eventType:dt,handler:Vt,options:Xt})})}function Kt(){wt()&&(Re("touchstart",he,{passive:!0}),Re("touchend",Ut,{passive:!0})),U1(D.props.trigger).forEach(function(dt){if(dt!=="manual")switch(Re(dt,he),dt){case"mouseenter":Re("mouseleave",Ut);break;case"focus":Re(Q1?"focusout":"blur",Ke);break;case"focusin":Re("focusout",Ke);break}})}function be(){E.forEach(function(dt){var Vt=dt.node,Xt=dt.eventType,ve=dt.handler,se=dt.options;Vt.removeEventListener(Xt,ve,se)}),E=[]}function he(dt){var Vt,Xt=!1;if(!(!D.state.isEnabled||Fe(dt)||d)){var ve=((Vt=g)==null?void 0:Vt.type)==="focus";g=dt,w=dt.currentTarget,j(),!D.state.isVisible&&H1(dt)&&To.forEach(function(se){return se(dt)}),dt.type==="click"&&(D.props.trigger.indexOf("mouseenter")<0||c)&&D.props.hideOnClick!==!1&&D.state.isVisible?Xt=!0:oe(dt),dt.type==="click"&&(c=!Xt),Xt&&!ve&&Ne(dt)}}function Oe(dt){var Vt=dt.target,Xt=Ot().contains(Vt)||$.contains(Vt);if(!(dt.type==="mousemove"&&Xt)){var ve=ze().concat($).map(function(se){var ci,Pi=se._tippy,fr=(ci=Pi.popperInstance)==null?void 0:ci.state;return fr?{popperRect:se.getBoundingClientRect(),popperState:fr,props:e}:null}).filter(Boolean);z1(ve,dt)&&(nt(),Ne(dt))}}function Ut(dt){var Vt=Fe(dt)||D.props.trigger.indexOf("click")>=0&&c;if(!Vt){if(D.props.interactive){D.hideWithInteractivity(dt);return}Ne(dt)}}function Ke(dt){D.props.trigger.indexOf("focusin")<0&&dt.target!==Ot()||D.props.interactive&&dt.relatedTarget&&$.contains(dt.relatedTarget)||Ne(dt)}function Fe(dt){return Pr.isTouch?wt()!==dt.type.indexOf("touch")>=0:!1}function Ge(){ke();var dt=D.props,Vt=dt.popperOptions,Xt=dt.placement,ve=dt.offset,se=dt.getReferenceClientRect,ci=dt.moveTransition,Pi=vt()?ac($).arrow:null,fr=se?{getBoundingClientRect:se,contextElement:se.contextElement||Ot()}:s,ns={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Cs){var Oi=Cs.state;if(vt()){var Pa=U(),mr=Pa.box;["placement","reference-hidden","escaped"].forEach(function(Is){Is==="placement"?mr.setAttribute("data-placement",Oi.placement):Oi.attributes.popper["data-popper-"+Is]?mr.setAttribute("data-"+Is,""):mr.removeAttribute("data-"+Is)}),Oi.attributes.popper={}}}},pr=[{name:"offset",options:{offset:ve}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ci}},ns];vt()&&Pi&&pr.push({name:"arrow",options:{element:Pi,padding:3}}),pr.push.apply(pr,(Vt==null?void 0:Vt.modifiers)||[]),D.popperInstance=$1(fr,$,Object.assign({},Vt,{placement:Xt,onFirstUpdate:A,modifiers:pr}))}function ke(){D.popperInstance&&(D.popperInstance.destroy(),D.popperInstance=null)}function de(){var dt=D.props.appendTo,Vt,Xt=Ot();D.props.interactive&&dt===Ou||dt==="parent"?Vt=Xt.parentNode:Vt=Mu(dt,[Xt]),Vt.contains($)||Vt.appendChild($),D.state.isMounted=!0,Ge()}function ze(){return Ao($.querySelectorAll("[data-tippy-root]"))}function oe(dt){D.clearDelayTimeouts(),dt&&F("onTrigger",[D,dt]),jt();var Vt=q(!0),Xt=J(),ve=Xt[0],se=Xt[1];Pr.isTouch&&ve==="hold"&&se&&(Vt=se),Vt?i=setTimeout(function(){D.show()},Vt):D.show()}function Ne(dt){if(D.clearDelayTimeouts(),F("onUntrigger",[D,dt]),!D.state.isVisible){ue();return}if(!(D.props.trigger.indexOf("mouseenter")>=0&&D.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(dt.type)>=0&&c)){var Vt=q(!1);Vt?n=setTimeout(function(){D.state.isVisible&&D.hide()},Vt):o=requestAnimationFrame(function(){D.hide()})}}function Ue(){D.state.isEnabled=!0}function ui(){D.hide(),D.state.isEnabled=!1}function Le(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(o)}function vi(dt){if(!D.state.isDestroyed){F("onBeforeUpdate",[D,dt]),be();var Vt=D.props,Xt=Wu(s,Object.assign({},Vt,Nu(dt),{ignoreAttributes:!0}));D.props=Xt,Kt(),Vt.interactiveDebounce!==Xt.interactiveDebounce&&(nt(),T=$u(Oe,Xt.interactiveDebounce)),Vt.triggerTarget&&!Xt.triggerTarget?wn(Vt.triggerTarget).forEach(function(ve){ve.removeAttribute("aria-expanded")}):Xt.triggerTarget&&s.removeAttribute("aria-expanded"),j(),At(),z&&z(Vt,Xt),D.popperInstance&&(Ge(),ze().forEach(function(ve){requestAnimationFrame(ve._tippy.popperInstance.forceUpdate)})),F("onAfterUpdate",[D,dt])}}function kr(dt){D.setProps({content:dt})}function ni(){var dt=D.state.isVisible,Vt=D.state.isDestroyed,Xt=!D.state.isEnabled,ve=Pr.isTouch&&!D.props.touch,se=ec(D.props.duration,0,br.duration);if(!(dt||Vt||Xt||ve)&&!Ot().hasAttribute("disabled")&&(F("onShow",[D],!1),D.props.onShow(D)!==!1)){if(D.state.isVisible=!0,vt()&&($.style.visibility="visible"),At(),jt(),D.state.isMounted||($.style.transition="none"),vt()){var ci=U(),Pi=ci.box,fr=ci.content;rc([Pi,fr],0)}A=function(){var pr;if(!(!D.state.isVisible||p)){if(p=!0,$.offsetHeight,$.style.transition=D.props.moveTransition,vt()&&D.props.animation){var gr=U(),Cs=gr.box,Oi=gr.content;rc([Cs,Oi],se),Uu([Cs,Oi],"visible")}N(),j(),Fu(oc,D),(pr=D.popperInstance)==null||pr.forceUpdate(),F("onMount",[D]),D.props.animation&&vt()&&ge(se,function(){D.state.isShown=!0,F("onShown",[D])})}},de()}}function wr(){var dt=!D.state.isVisible,Vt=D.state.isDestroyed,Xt=!D.state.isEnabled,ve=ec(D.props.duration,1,br.duration);if(!(dt||Vt||Xt)&&(F("onHide",[D],!1),D.props.onHide(D)!==!1)){if(D.state.isVisible=!1,D.state.isShown=!1,p=!1,c=!1,vt()&&($.style.visibility="hidden"),nt(),ue(),At(!0),vt()){var se=U(),ci=se.box,Pi=se.content;D.props.animation&&(rc([ci,Pi],ve),Uu([ci,Pi],"hidden"))}N(),j(),D.props.animation?vt()&&me(ve,D.unmount):D.unmount()}}function _s(dt){Gt().addEventListener("mousemove",T),Fu(To,T),T(dt)}function Ls(){D.state.isVisible&&D.hide(),D.state.isMounted&&(ke(),ze().forEach(function(dt){dt._tippy.unmount()}),$.parentNode&&$.parentNode.removeChild($),oc=oc.filter(function(dt){return dt!==D}),D.state.isMounted=!1,F("onHidden",[D]))}function rr(){D.state.isDestroyed||(D.clearDelayTimeouts(),D.unmount(),be(),delete s._tippy,D.state.isDestroyed=!0,F("onDestroy",[D]))}}function sn(s,t){t===void 0&&(t={});var e=br.plugins.concat(t.plugins||[]);Z1();var i=Object.assign({},t,{plugins:e}),n=j1(s),o=n.reduce(function(c,d){var f=d&&av(d,i);return f&&c.push(f),c},[]);return Eo(s)?o[0]:o}sn.defaultProps=br,sn.setDefaultProps=iv,sn.currentInput=Pr,Object.assign({},gu,{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:zu});class Jr extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const ov=5;class lv{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=Li(),this._controls=Li(),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,n,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-ov&&d<g))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=ru((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var A;const E=d-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return g&&v&&E>=fo(g)&&E<=fo(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 Ci(this._canvas)}controls(){return Ci(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,n;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:A}=d,{start:E,duration:T}=f,w=this.host.videoState[g];A&&w&&(A.currentTime>=E+T||A.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,A.currentTime):w.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((n=v==null?void 0:v.buffered)!=null&&n.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:n}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(n&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&o.initialised)try{return n.play()}catch(d){throw new Jr(`Video play error: ${d.message}`,!0)}}else n.paused||n.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 cv(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Yu={exports:{}};(function(s,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\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 E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var T=n.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(w.netLoc=E.netLoc,A.path[0]!=="/"))if(!A.path)w.path=E.path,A.params||(w.params=E.params,A.query||(w.query=E.query));else{var C=E.path,x=C.substring(0,C.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}};s.exports=d})()})(Yu);var lc=Yu.exports;function Xu(s,t){var e=Object.keys(s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(s);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(s,n).enumerable})),e.push.apply(e,i)}return e}function Ki(s){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Xu(Object(e),!0).forEach(function(i){hv(s,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(e)):Xu(Object(e)).forEach(function(i){Object.defineProperty(s,i,Object.getOwnPropertyDescriptor(e,i))})}return s}function hv(s,t,e){return t=uv(t),t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}function hi(){return hi=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(s[i]=e[i])}return s},hi.apply(this,arguments)}function dv(s,t){if(typeof s!="object"||s===null)return s;var e=s[Symbol.toPrimitive];if(e!==void 0){var i=e.call(s,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(s)}function uv(s){var t=dv(s,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(s){return typeof s=="number"&&isFinite(s)};let R=function(s){return s.MEDIA_ATTACHING="hlsMediaAttaching",s.MEDIA_ATTACHED="hlsMediaAttached",s.MEDIA_DETACHING="hlsMediaDetaching",s.MEDIA_DETACHED="hlsMediaDetached",s.BUFFER_RESET="hlsBufferReset",s.BUFFER_CODECS="hlsBufferCodecs",s.BUFFER_CREATED="hlsBufferCreated",s.BUFFER_APPENDING="hlsBufferAppending",s.BUFFER_APPENDED="hlsBufferAppended",s.BUFFER_EOS="hlsBufferEos",s.BUFFER_FLUSHING="hlsBufferFlushing",s.BUFFER_FLUSHED="hlsBufferFlushed",s.MANIFEST_LOADING="hlsManifestLoading",s.MANIFEST_LOADED="hlsManifestLoaded",s.MANIFEST_PARSED="hlsManifestParsed",s.LEVEL_SWITCHING="hlsLevelSwitching",s.LEVEL_SWITCHED="hlsLevelSwitched",s.LEVEL_LOADING="hlsLevelLoading",s.LEVEL_LOADED="hlsLevelLoaded",s.LEVEL_UPDATED="hlsLevelUpdated",s.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",s.LEVELS_UPDATED="hlsLevelsUpdated",s.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",s.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",s.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",s.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",s.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",s.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",s.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",s.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",s.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",s.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",s.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",s.CUES_PARSED="hlsCuesParsed",s.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",s.INIT_PTS_FOUND="hlsInitPtsFound",s.FRAG_LOADING="hlsFragLoading",s.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",s.FRAG_LOADED="hlsFragLoaded",s.FRAG_DECRYPTED="hlsFragDecrypted",s.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",s.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",s.FRAG_PARSING_METADATA="hlsFragParsingMetadata",s.FRAG_PARSED="hlsFragParsed",s.FRAG_BUFFERED="hlsFragBuffered",s.FRAG_CHANGED="hlsFragChanged",s.FPS_DROP="hlsFpsDrop",s.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",s.ERROR="hlsError",s.DESTROYING="hlsDestroying",s.KEY_LOADING="hlsKeyLoading",s.KEY_LOADED="hlsKeyLoaded",s.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",s.BACK_BUFFER_REACHED="hlsBackBufferReached",s}({}),qt=function(s){return s.NETWORK_ERROR="networkError",s.MEDIA_ERROR="mediaError",s.KEY_SYSTEM_ERROR="keySystemError",s.MUX_ERROR="muxError",s.OTHER_ERROR="otherError",s}({}),pt=function(s){return s.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",s.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",s.KEY_SYSTEM_NO_SESSION="keySystemNoSession",s.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",s.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",s.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",s.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",s.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",s.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",s.MANIFEST_LOAD_ERROR="manifestLoadError",s.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",s.MANIFEST_PARSING_ERROR="manifestParsingError",s.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",s.LEVEL_EMPTY_ERROR="levelEmptyError",s.LEVEL_LOAD_ERROR="levelLoadError",s.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",s.LEVEL_PARSING_ERROR="levelParsingError",s.LEVEL_SWITCH_ERROR="levelSwitchError",s.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",s.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",s.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",s.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",s.FRAG_LOAD_ERROR="fragLoadError",s.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",s.FRAG_DECRYPT_ERROR="fragDecryptError",s.FRAG_PARSING_ERROR="fragParsingError",s.FRAG_GAP="fragGap",s.REMUX_ALLOC_ERROR="remuxAllocError",s.KEY_LOAD_ERROR="keyLoadError",s.KEY_LOAD_TIMEOUT="keyLoadTimeOut",s.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",s.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",s.BUFFER_APPEND_ERROR="bufferAppendError",s.BUFFER_APPENDING_ERROR="bufferAppendingError",s.BUFFER_STALLED_ERROR="bufferStalledError",s.BUFFER_FULL_ERROR="bufferFullError",s.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",s.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",s.INTERNAL_EXCEPTION="internalException",s.INTERNAL_ABORTED="aborted",s.UNKNOWN="unknown",s}({});const nn=function(){},cc={trace:nn,debug:nn,log:nn,warn:nn,info:nn,error:nn};let Ta=cc;function fv(s){const t=self.console[s];return t?t.bind(self.console,`[${s}] >`):nn}function pv(s,...t){t.forEach(function(e){Ta[e]=s[e]?s[e].bind(s):fv(e)})}function gv(s,t){if(self.console&&s===!0||typeof s=="object"){pv(s,"debug","log","info","warn","error");try{Ta.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{Ta=cc}}else Ta=cc}const X=Ta,mv=/^(\d+)x(\d+)$/,Zu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ti{constructor(t){typeof t=="string"&&(t=ti.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 n=0;n<e.length/2;n++)i[n]=parseInt(e.slice(n*2,n*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=mv.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},n='"';for(Zu.lastIndex=0;(e=Zu.exec(t))!==null;){let o=e[2];o.indexOf(n)===0&&o.lastIndexOf(n)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function vv(s){return s!=="ID"&&s!=="CLASS"&&s!=="START-DATE"&&s!=="DURATION"&&s!=="END-DATE"&&s!=="END-ON-NEXT"}function yv(s){return s==="SCTE35-OUT"||s==="SCTE35-IN"}class qu{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 n in i)if(Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==i[n]){X.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=n;break}t=hi(new ti({}),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"]);Wt(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(Wt(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&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class ko{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 Ie={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Qu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ie.AUDIO]:null,[Ie.VIDEO]:null,[Ie.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),n=[];i.length===1?n[0]=e?e.byteRangeEndOffset:0:n[0]=parseInt(i[1]),n[1]=parseInt(i[0])+n[0],this._byteRange=n}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=lc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class hc extends Qu{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 ko,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||!Wt(this.programDateTime))return null;const t=Wt(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,n,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:n,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,n),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Ie.AUDIO]=null,t[Ie.VIDEO]=null,t[Ie.AUDIOVIDEO]=null}}class bv extends Qu{constructor(t,e,i,n,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 ko,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=n;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 Av=10;class Ev{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?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Av}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 dc(s){return Uint8Array.from(atob(s),t=>t.charCodeAt(0))}function Tv(s){const t=Ju(s).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function kv(s){const t=function(e,i,n){const o=e[i];e[i]=e[n],e[n]=o};t(s,0,3),t(s,1,2),t(s,4,5),t(s,6,7)}function wv(s){const t=s.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const o=n[0]==="base64",c=n[1];o?(i.splice(-1,1),e=dc(c)):e=Tv(c)}}return e}function Ju(s){return Uint8Array.from(unescape(encodeURIComponent(s)),t=>t.charCodeAt(0))}var ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},zi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function t0(s){switch(s){case zi.FAIRPLAY:return ei.FAIRPLAY;case zi.PLAYREADY:return ei.PLAYREADY;case zi.WIDEVINE:return ei.WIDEVINE;case zi.CLEARKEY:return ei.CLEARKEY}}var e0={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Sv(s){if(s===e0.WIDEVINE)return ei.WIDEVINE}function i0(s){switch(s){case ei.FAIRPLAY:return zi.FAIRPLAY;case ei.PLAYREADY:return zi.PLAYREADY;case ei.WIDEVINE:return zi.WIDEVINE;case ei.CLEARKEY:return zi.CLEARKEY}}function uc(s){const{drmSystems:t,widevineLicenseUrl:e}=s,i=t?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!t[n]):[];return!i[ei.WIDEVINE]&&e&&i.push(ei.WIDEVINE),i}const r0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Rv(s,t,e,i){let n;switch(s){case ei.FAIRPLAY:n=["cenc","sinf"];break;case ei.WIDEVINE:case ei.PLAYREADY:n=["cenc"];break;case ei.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${s}`)}return _v(n,t,e,i)}function _v(s,t,e,i){return[{initDataTypes:s,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function an(s,t,e){return Uint8Array.prototype.slice?s.slice(t,e):new Uint8Array(Array.prototype.slice.call(s,t,e))}const fc=(s,t)=>t+10<=s.length&&s[t]===73&&s[t+1]===68&&s[t+2]===51&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,s0=(s,t)=>t+10<=s.length&&s[t]===51&&s[t+1]===68&&s[t+2]===73&&s[t+3]<255&&s[t+4]<255&&s[t+6]<128&&s[t+7]<128&&s[t+8]<128&&s[t+9]<128,wo=(s,t)=>{const e=t;let i=0;for(;fc(s,t);){i+=10;const n=So(s,t+6);i+=n,s0(s,t+10)&&(i+=10),t+=i}if(i>0)return s.subarray(e,e+i)},So=(s,t)=>{let e=0;return e=(s[t]&127)<<21,e|=(s[t+1]&127)<<14,e|=(s[t+2]&127)<<7,e|=s[t+3]&127,e},Lv=(s,t)=>fc(s,t)&&So(s,t+6)+10<=s.length-t,Cv=s=>{const t=a0(s);for(let e=0;e<t.length;e++){const i=t[e];if(n0(i))return Mv(i)}},n0=s=>s&&s.key==="PRIV"&&s.info==="com.apple.streaming.transportStreamTimestamp",Iv=s=>{const t=String.fromCharCode(s[0],s[1],s[2],s[3]),e=So(s,4),i=10;return{type:t,size:e,data:s.subarray(i,i+e)}},a0=s=>{let t=0;const e=[];for(;fc(s,t);){const i=So(s,t+6);t+=10;const n=t+i;for(;t+8<n;){const o=Iv(s.subarray(t)),c=Dv(o);c&&e.push(c),t+=o.size+10}s0(s,t)&&(t+=10)}return e},Dv=s=>s.type==="PRIV"?xv(s):s.type[0]==="W"?Ov(s):Pv(s),xv=s=>{if(s.size<2)return;const t=Or(s.data,!0),e=new Uint8Array(s.data.subarray(t.length+1));return{key:s.type,info:t,data:e.buffer}},Pv=s=>{if(s.size<2)return;if(s.type==="TXXX"){let e=1;const i=Or(s.data.subarray(e),!0);e+=i.length+1;const n=Or(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Or(s.data.subarray(1));return{key:s.type,data:t}},Ov=s=>{if(s.type==="WXXX"){if(s.size<2)return;let e=1;const i=Or(s.data.subarray(e),!0);e+=i.length+1;const n=Or(s.data.subarray(e));return{key:s.type,info:i,data:n}}const t=Or(s.data);return{key:s.type,data:t}},Mv=s=>{if(s.data.byteLength===8){const t=new Uint8Array(s.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)}},Or=(s,t=!1)=>{const e=$v();if(e){const p=e.decode(s);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=s.length;let n,o,c,d="",f=0;for(;f<i;){if(n=s[f++],n===0&&t)return d;if(!(n===0||n===3))switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(n);break;case 12:case 13:o=s[f++],d+=String.fromCharCode((n&31)<<6|o&63);break;case 14:o=s[f++],c=s[f++],d+=String.fromCharCode((n&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let pc;function $v(){return!pc&&typeof self.TextDecoder<"u"&&(pc=new self.TextDecoder("utf-8")),pc}const Mr={hexDump:function(s){let t="";for(let e=0;e<s.length;e++){let i=s[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},Ro=Math.pow(2,32)-1,Fv=[].push,o0={video:1,audio:2,id3:3,text:4};function Si(s){return String.fromCharCode.apply(null,s)}function l0(s,t){const e=s[t]<<8|s[t+1];return e<0?65536+e:e}function ee(s,t){const e=c0(s,t);return e<0?4294967296+e:e}function c0(s,t){return s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3]}function gc(s,t,e){s[t]=e>>24,s[t+1]=e>>16&255,s[t+2]=e>>8&255,s[t+3]=e&255}function ye(s,t){const e=[];if(!t.length)return e;const i=s.byteLength;for(let n=0;n<i;){const o=ee(s,n),c=Si(s.subarray(n+4,n+8)),d=o>1?n+o:i;if(c===t[0])if(t.length===1)e.push(s.subarray(n+8,d));else{const f=ye(s.subarray(n+8,d),t.slice(1));f.length&&Fv.apply(e,f)}n=d}return e}function Nv(s){const t=[],e=s[0];let i=8;const n=ee(s,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=s.length+c;const f=l0(s,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ee(s,g);g+=4;const A=v&2147483647;if((v&2147483648)>>>31===1)return X.warn("SIDX has hierarchical references (not supported)"),null;const E=ee(s,g);g+=4,t.push({referenceSize:A,subsegmentDuration:E,info:{duration:E/n,start:d,end:d+A-1}}),d+=A,g+=4,i=g}return{earliestPresentationTime:o,timescale:n,version:e,referencesCount:f,references:t}}function h0(s){const t=[],e=ye(s,["moov","trak"]);for(let i=0;i<e.length;i++){const n=e[i],o=ye(n,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ee(o,d),p=ye(n,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ee(p,d),v=ye(n,["mdia","hdlr"])[0];if(v){const A=Si(v.subarray(8,12)),E={soun:Ie.AUDIO,vide:Ie.VIDEO}[A];if(E){const T=ye(n,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=Si(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return ye(s,["moov","mvex","trex"]).forEach(i=>{const n=ee(i,4),o=t[n];o&&(o.default={duration:ee(i,12),flags:ee(i,20)})}),t}function Uv(s,t){if(!s||!t)return s;const e=t.keyId;return e&&t.isCommonEncryption&&ye(s,["moov","trak"]).forEach(i=>{const n=ye(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=ye(n,["enca"]);const c=o.length>0;c||(o=ye(n,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);ye(f,["sinf"]).forEach(p=>{const g=d0(p);if(g){const v=g.subarray(8,24);v.some(A=>A!==0)||(X.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Mr.hexDump(v)} -> ${Mr.hexDump(e)}`),g.set(e,8))}})})}),s}function d0(s){const t=ye(s,["schm"])[0];if(t){const e=Si(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ye(s,["schi","tenc"])[0]}return X.error("[eme] missing 'schm' box"),null}function Bv(s,t){return ye(t,["moof","traf"]).reduce((e,i)=>{const n=ye(i,["tfdt"])[0],o=n[0],c=ye(i,["tfhd"]).reduce((d,f)=>{const p=ee(f,4),g=s[p];if(g){let v=ee(n,4);if(o===1){if(v===Ro)return X.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=Ro+1,v+=ee(n,8)}const A=g.timescale||9e4,E=v/A;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 Gv(s,t){let e=0,i=0,n=0;const o=ye(s,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=ye(d,["tfhd"])[0],p=ee(f,4),g=t[p];if(!g)continue;const v=g.default,A=ee(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;A&8&&(A&2?E=ee(f,12):E=ee(f,8));const T=g.timescale||9e4,w=ye(d,["trun"]);for(let C=0;C<w.length;C++){if(e=Vv(w[C]),!e&&E){const x=ee(w[C],4);e=E*x}g.type===Ie.VIDEO?i+=e/T:g.type===Ie.AUDIO&&(n+=e/T)}}if(i===0&&n===0){let c=0;const d=ye(s,["sidx"]);for(let f=0;f<d.length;f++){const p=Nv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||n}function Vv(s){const t=ee(s,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const n=ee(s,4);for(let o=0;o<n;o++){if(t&256){const c=ee(s,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function Hv(s,t,e){ye(t,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(n=>{const o=ee(n,4),c=s[o];if(!c)return;const d=c.timescale||9e4;ye(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ee(f,4);if(p===0)g-=e*d,g=Math.max(g,0),gc(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/(Ro+1)),A=Math.floor(g%(Ro+1));gc(f,4,v),gc(f,8,A)}})})})}function Wv(s){const t={valid:null,remainder:null},e=ye(s,["moof"]);if(e){if(e.length<2)return t.remainder=s,t}else return t;const i=e[e.length-1];return t.valid=an(s,0,i.byteOffset-8),t.remainder=an(s,i.byteOffset-8),t}function on(s,t){const e=new Uint8Array(s.length+t.length);return e.set(s),e.set(t,s.length),e}function u0(s,t){const e=[],i=t.samples,n=t.timescale,o=t.id;let c=!1;return ye(i,["moof"]).map(d=>{const f=d.byteOffset-8;ye(d,["traf"]).map(p=>{const g=ye(p,["tfdt"]).map(v=>{const A=v[0];let E=ee(v,4);return A===1&&(E*=Math.pow(2,32),E+=ee(v,8)),E/n})[0];return g!==void 0&&(s=g),ye(p,["tfhd"]).map(v=>{const A=ee(v,4),E=ee(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let x=0;const O=(E&16)!==0;let B=0;const D=(E&32)!==0;let V=8;A===o&&(T&&(V+=8),w&&(V+=4),C&&(x=ee(v,V),V+=4),O&&(B=ee(v,V),V+=4),D&&(V+=4),t.type==="video"&&(c=jv(t.codec)),ye(p,["trun"]).map($=>{const z=$[0],it=ee($,0)&16777215,at=(it&1)!==0;let J=0;const wt=(it&4)!==0,vt=(it&256)!==0;let Ot=0;const Gt=(it&512)!==0;let U=0;const q=(it&1024)!==0,At=(it&2048)!==0;let F=0;const N=ee($,4);let j=8;at&&(J=ee($,j),j+=4),wt&&(j+=4);let nt=J+f;for(let ht=0;ht<N;ht++){if(vt?(Ot=ee($,j),j+=4):Ot=x,Gt?(U=ee($,j),j+=4):U=B,q&&(j+=4),At&&(z===0?F=ee($,j):F=c0($,j),j+=4),t.type===Ie.VIDEO){let Lt=0;for(;Lt<U;){const Nt=ee(i,nt);if(nt+=4,Kv(c,i[nt])){const jt=i.subarray(nt,nt+Nt);f0(jt,c?2:1,s+F/n,e)}nt+=Nt,Lt+=Nt+4}}s+=Ot/n}}))})})}),e}function jv(s){if(!s)return!1;const t=s.indexOf("."),e=t<0?s:s.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Kv(s,t){if(s){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function f0(s,t,e,i){const n=p0(s);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<n.length;){c=0;do{if(o>=n.length)break;p=n[o++],c+=p}while(p===255);d=0;do{if(o>=n.length)break;p=n[o++],d+=p}while(p===255);const g=n.length-o;if(!f&&c===4&&o<n.length){if(f=!0,n[o++]===181){const v=l0(n,o);if(o+=2,v===49){const A=ee(n,o);if(o+=4,A===1195456820){const E=n[o++];if(E===3){const T=n[o++],w=31&T,C=64&T,x=C?2+w*3:0,O=new Uint8Array(x);if(C){O[0]=T;for(let B=1;B<x;B++)O[B]=n[o++]}i.push({type:E,payloadType:c,pts:e,bytes:O})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=n[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const A=d-16,E=new Uint8Array(A);for(let T=0;T<A;T++)E[T]=n[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:Or(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function p0(s){const t=s.byteLength,e=[];let i=1;for(;i<t-2;)s[i]===0&&s[i+1]===0&&s[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return s;const n=t-e.length,o=new Uint8Array(n);let c=0;for(i=0;i<n;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=s[c];return o}function zv(s){const t=s[0];let e="",i="",n=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;Si(s.subarray(p,p+1))!=="\0";)e+=Si(s.subarray(p,p+1)),p+=1;for(e+=Si(s.subarray(p,p+1)),p+=1;Si(s.subarray(p,p+1))!=="\0";)i+=Si(s.subarray(p,p+1)),p+=1;i+=Si(s.subarray(p,p+1)),p+=1,n=ee(s,12),o=ee(s,16),d=ee(s,20),f=ee(s,24),p=28}else if(t===1){p+=4,n=ee(s,p),p+=4;const v=ee(s,p);p+=4;const A=ee(s,p);for(p+=4,c=4294967296*v+A,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,X.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ee(s,p),p+=4,f=ee(s,p),p+=4;Si(s.subarray(p,p+1))!=="\0";)e+=Si(s.subarray(p,p+1)),p+=1;for(e+=Si(s.subarray(p,p+1)),p+=1;Si(s.subarray(p,p+1))!=="\0";)i+=Si(s.subarray(p,p+1)),p+=1;i+=Si(s.subarray(p,p+1)),p+=1}const g=s.subarray(p,s.byteLength);return{schemeIdUri:e,value:i,timeScale:n,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Yv(s,...t){const e=t.length;let i=8,n=e;for(;n--;)i+=t[n].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(s,4),n=0,i=8;n<e;n++)o.set(t[n],i),i+=t[n].byteLength;return o}function Xv(s,t,e){if(s.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(t){i=1,n=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");n.set(f,d*16)}}else i=0,n=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),Yv([112,115,115,104],new Uint8Array([i,0,0,0]),s,o,n,c,e||new Uint8Array)}function Zv(s){if(!(s instanceof ArrayBuffer)||s.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(s),i=e.getUint32(0);if(s.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Mr.hexDump(new Uint8Array(s,12,16));const n=e.getUint32(28);if(t.version===0){if(i-32<n)return null;t.data=new Uint8Array(s,32,n)}else if(t.version===1){t.kids=[];for(let o=0;o<n;o++)t.kids.push(new Uint8Array(s,32+o*16,16))}return t}let _o={};class ka{static clearKeyUriToKeyIdMap(){_o={}}constructor(t,e,i,n=[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=n,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 zi.FAIRPLAY:case zi.WIDEVINE:case zi.PLAYREADY:case zi.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&&X.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=qv(t);return new ka(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=wv(this.uri);if(e)switch(this.keyFormat){case zi.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case zi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Xv(i,null,e);const n=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(n)),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=dc(f).subarray(0,16);kv(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const n=new Uint8Array(16);n.set(i,16-i.length),i=n}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=_o[this.uri];if(!i){const n=Object.keys(_o).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),_o[this.uri]=i}this.keyId=i}return this}}function qv(s){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=s>>8*(15-e)&255;return t}const g0=/\{\$([a-zA-Z0-9-_]+)\}/g;function m0(s){return g0.test(s)}function Yi(s,t,e){if(s.variableList!==null||s.hasVariableRefs)for(let i=e.length;i--;){const n=e[i],o=t[n];o&&(t[n]=mc(s,o))}}function mc(s,t){if(s.variableList!==null||s.hasVariableRefs){const e=s.variableList;return t.replace(g0,i=>{const n=i.substring(2,i.length-1),o=e==null?void 0:e[n];return o===void 0?(s.playlistParsingError||(s.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):o})}return t}function v0(s,t,e){let i=s.variableList;i||(s.variableList=i={});let n,o;if("QUERYPARAM"in t){n=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(n))o=c.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${e}"`)}catch(c){s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else n=t.NAME,o=t.VALUE;n in i?s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=o||""}function Qv(s,t,e){const i=t.IMPORT;if(e&&i in e){let n=s.variableList;n||(s.variableList=n={}),n[i]=e[i]}else s.playlistParsingError||(s.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Lo(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Jv={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}},y0=Lo();function ty(s,t){const e=Jv[t];return!!e&&e[s.slice(0,4)]===!0}function vc(s,t){var e;return(e=y0==null?void 0:y0.isTypeSupported(`${t||"video"}/mp4;codecs="${s}"`))!=null?e:!1}const b0=/#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,A0=/#EXT-X-MEDIA:(.*)/g,ey=/^#EXT(?:INF|-X-TARGETDURATION):/m,E0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),iy=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 Ar{static findGroup(t,e){for(let i=0;i<t.length;i++){const n=t[i];if(n.id===e)return n}}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 lc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return ey.test(t)}static parseMasterPlaylist(t,e){const i=m0(t),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];b0.lastIndex=0;let c;for(;(c=b0.exec(t))!=null;)if(c[1]){var d;const p=new ti(c[1]);Yi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=mc(n,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:Ar.resolve(g,e)},A=p.decimalResolution("RESOLUTION");A&&(v.width=A.width,v.height=A.height),ry((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=Ar.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),n.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ti(g);Yi(n,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=v["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=v);break}case"SESSION-KEY":{const v=T0(g,e,n);v.encrypted&&v.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(v)):X.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ti(g);Yi(n,v,["NAME","VALUE","QUERYPARAM"]),v0(n,v,e)}break}case"CONTENT-STEERING":{const v=new ti(g);Yi(n,v,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Ar.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=k0(g);break}}}const f=o.length>0&&o.length<n.levels.length;return n.levels=f?o:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(t,e,i){let n;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(A0.lastIndex=0;(n=A0.exec(t))!==null;){const p=new ti(n[1]),g=p.TYPE;if(g){const v=d[g],A=o[g]||[];o[g]=A,Yi(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?Ar.resolve(p.URI,e):""};if(v!=null&&v.length){const T=Ar.findGroup(v,E.groupId)||v[0];w0(E,T,"audioCodec"),w0(E,T,"textCodec")}A.push(E)}}return o}static parseLevelPlaylist(t,e,i,n,o,c){const d=new Ev(e),f=d.fragments;let p=null,g=0,v=0,A=0,E=0,T=null,w=new hc(n,e),C,x,O,B=-1,D=!1;for(E0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=m0(t);(C=E0.exec(t))!==null;){D&&(D=!1,w=new hc(n,e),w.start=A,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const it=C[1];if(it){w.duration=parseFloat(it);const at=(" "+C[2]).slice(1);w.title=at||null,w.tagList.push(at?["INF",it,at]:["INF",it])}else if(C[3]){if(Wt(w.duration)){w.start=A,O&&_0(w,O,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const at=(" "+C[3]).slice(1);w.relurl=mc(d,at),S0(w,T),T=w,A+=w.duration,g++,v=0,D=!0}}else if(C[4]){const at=(" "+C[4]).slice(1);T?w.setByteRange(at,T):w.setByteRange(at)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),B===-1&&(B=f.length);else{if(C=C[0].match(iy),!C){X.warn("No matches on slow regex match for level playlist!");continue}for(x=1;x<C.length&&!(typeof C[x]<"u");x++);const at=(" "+C[x]).slice(1),J=(" "+C[x+1]).slice(1),wt=C[x+2]?(" "+C[x+2]).slice(1):"";switch(at){case"PLAYLIST-TYPE":d.type=J.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(J);break;case"SKIP":{const vt=new ti(J);Yi(d,vt,["RECENTLY-REMOVED-DATERANGES"]);const Ot=vt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Ot)){d.skippedSegments=Ot;for(let U=Ot;U--;)f.unshift(null);g+=Ot}const Gt=vt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Gt&&(d.recentlyRemovedDateranges=Gt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(J),1);break;case"VERSION":d.version=parseInt(J);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(J||wt)&&w.tagList.push(wt?[J,wt]:[J]);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,J]);break;case"DATERANGE":{const vt=new ti(J);Yi(d,vt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Yi(d,vt,vt.clientAttrs);const Ot=new qu(vt,d.dateRanges[vt.ID]);Ot.isValid||d.skippedSegments?d.dateRanges[Ot.id]=Ot:X.warn(`Ignoring invalid DATERANGE tag: "${J}"`),w.tagList.push(["EXT-X-DATERANGE",J]);break}case"DEFINE":{{const vt=new ti(J);Yi(d,vt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in vt?Qv(d,vt,c):v0(d,vt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(J);break;case"KEY":{const vt=T0(J,e,d);if(vt.isSupported()){if(vt.method==="NONE"){O=void 0;break}O||(O={}),O[vt.keyFormat]&&(O=hi({},O)),O[vt.keyFormat]=vt}else X.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${J}"`);break}case"START":d.startTimeOffset=k0(J);break;case"MAP":{const vt=new ti(J);if(Yi(d,vt,["BYTERANGE","URI"]),w.duration){const Ot=new hc(n,e);R0(Ot,vt,i,O),p=Ot,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else R0(w,vt,i,O),p=w,D=!0;break}case"SERVER-CONTROL":{const vt=new ti(J);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 ti(J);d.partTarget=vt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let vt=d.partList;vt||(vt=d.partList=[]);const Ot=v>0?vt[vt.length-1]:void 0,Gt=v++,U=new ti(J);Yi(d,U,["BYTERANGE","URI"]);const q=new bv(U,w,e,Gt,Ot);vt.push(q),w.duration+=q.duration;break}case"PRELOAD-HINT":{const vt=new ti(J);Yi(d,vt,["URI"]),d.preloadHint=vt;break}case"RENDITION-REPORT":{const vt=new ti(J);Yi(d,vt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(vt);break}default:X.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),A-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(S0(w,T),w.cc=E,d.fragmentHint=w,O&&_0(w,O,d));const V=f.length,$=f[0],z=f[V-1];if(A+=d.skippedSegments*d.targetduration,A>0&&V&&z){d.averagetargetduration=A/V;const it=z.sn;d.endSN=it!=="initSegment"?it:0,d.live||(z.endList=!0),$&&(d.startCC=$.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(A+=d.fragmentHint.duration),d.totalduration=A,d.endCC=E,B>0&&sy(f,B),d}}function T0(s,t,e){var i,n;const o=new ti(s);Yi(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=(n=o.KEYFORMAT)!=null?n:"identity";d&&o.IV&&!f&&X.error(`Invalid IV: ${o.IV}`);const v=d?Ar.resolve(d,t):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new ka(c,v,g,A,f)}function k0(s){const t=new ti(s).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function ry(s,t){["video","audio","text"].forEach(e=>{const i=s.filter(n=>ty(n,e));if(i.length){const n=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=n.length>0?n[0]:i[0],s=s.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=s}function w0(s,t,e){const i=t[e];i&&(s[e]=i)}function sy(s,t){let e=s[t];for(let i=t;i--;){const n=s[i];if(!n)return;n.programDateTime=e.programDateTime-n.duration*1e3,e=n}}function S0(s,t){s.rawProgramDateTime?s.programDateTime=Date.parse(s.rawProgramDateTime):t!=null&&t.programDateTime&&(s.programDateTime=t.endProgramDateTime),Wt(s.programDateTime)||(s.programDateTime=null,s.rawProgramDateTime=null)}function R0(s,t,e,i){s.relurl=t.URI,t.BYTERANGE&&s.setByteRange(t.BYTERANGE),s.level=e,s.sn="initSegment",i&&(s.levelkeys=i),s.initSegment=null}function _0(s,t,e){s.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(n=>t[n].isCommonEncryption)&&i.push(s)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Qt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function L0(s){const{type:t}=s;switch(t){case Te.AUDIO_TRACK:return Qt.AUDIO;case Te.SUBTITLE_TRACK:return Qt.SUBTITLE;default:return Qt.MAIN}}function yc(s,t){let e=s.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class ny{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,n=e.loader,o=i||n,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:Te.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:n,url:o,deliveryDirectives:c}=e;this.load({id:i,level:n,responseType:"text",type:Te.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:n,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:n,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let n=this.getInternalLoader(t);if(n){const p=n.context;if(p&&p.url===t.url){X.trace("[playlist-loader]: playlist request ongoing");return}X.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}let o;if(t.type===Te.MANIFEST?o=i.manifestLoadPolicy.default:o=hi({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Te.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Te.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=hi({},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 E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),A||null,g);return}g.parsing.start=performance.now(),Ar.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,A||null,E):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)}};n.load(t,d,f)}handleMasterPlaylist(t,e,i,n){const o=this.hls,c=t.data,d=yc(t,i),f=Ar.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,n,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":x}=Ar.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(O=>!O.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(X.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 ti({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:x,contentSteering:p,url:d,stats:e,networkDetails:n,sessionData:v,sessionKeys:A,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,n,o){const c=this.hls,{id:d,level:f,type:p}=i,g=yc(t,i),v=Wt(d)?d:0,A=Wt(f)?f:v,E=L0(i),T=Ar.parseLevelPlaylist(t.data,g,A,E,v,this.variableList);if(p===Te.MANIFEST){const w={attrs:new ti({}),bitrate:0,details:T,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,n,o)}handleManifestParsingError(t,e,i,n,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:pt.MANIFEST_PARSING_ERROR,fatal:e.type===Te.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:n,stats:o})}handleNetworkError(t,e,i=!1,n,o){let c=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);X.warn(`[playlist-loader]: ${c}`);let f=pt.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:f=i?pt.MANIFEST_LOAD_TIMEOUT:pt.MANIFEST_LOAD_ERROR,p=!0;break;case Te.LEVEL:f=i?pt.LEVEL_LOAD_TIMEOUT:pt.LEVEL_LOAD_ERROR,p=!1;break;case Te.AUDIO_TRACK:f=i?pt.AUDIO_TRACK_LOAD_TIMEOUT:pt.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Te.SUBTITLE_TRACK:f=i?pt.SUBTITLE_TRACK_LOAD_TIMEOUT:pt.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(n){const A=(e==null?void 0:e.url)||t.url;v.response=Ki({url:A,data:void 0},n)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,n,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:A}=n,E=yc(e,n),T=L0(n),w=typeof n.level=="number"&&T===Qt.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:pt.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:x,reason:x.message,response:e,context:n,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:pt.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:n,level:w,parent:T,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 Te.MANIFEST:case Te.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:A});break;case Te.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break;case Te.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:A});break}}}function C0(s,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=s,t.dispatchEvent(e)}function I0(s,t){const e=s.mode;if(e==="disabled"&&(s.mode="hidden"),s.cues&&!s.cues.getCueById(t.id))try{if(s.addCue(t),!s.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){X.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(t.startTime,t.endTime,t.text);n.id=t.id,s.addCue(n)}catch(n){X.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}e==="disabled"&&(s.mode=e)}function Sn(s){const t=s.mode;if(t==="disabled"&&(s.mode="hidden"),s.cues)for(let e=s.cues.length;e--;)s.removeCue(s.cues[e]);t==="disabled"&&(s.mode=t)}function bc(s,t,e,i){const n=s.mode;if(n==="disabled"&&(s.mode="hidden"),s.cues&&s.cues.length>0){const o=oy(s.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&s.removeCue(o[c])}n==="disabled"&&(s.mode=n)}function ay(s,t){if(t<s[0].startTime)return 0;const e=s.length-1;if(t>s[e].endTime)return-1;let i=0,n=e;for(;i<=n;){const o=Math.floor((n+i)/2);if(t<s[o].startTime)n=o-1;else if(t>s[o].startTime&&i<e)i=o+1;else return o}return s[i].startTime-t<t-s[n].startTime?i:n}function oy(s,t,e){const i=[],n=ay(s,t);if(n>-1)for(let o=n,c=s.length;o<c;o++){const d=s[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Er={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const ly=.25;function Ac(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Co=(()=>{const s=Ac();try{new s(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ec(s,t){return s.getTime()/1e3-t}function cy(s){return Uint8Array.from(s.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class hy{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&&(Sn(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 C0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=Ac();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Er.emsg&&!i||!n)continue;const p=a0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Co&&(v=Co),v-g<=0&&(v=g+ly);for(let A=0;A<p.length;A++){const E=p[A];if(!n0(E)){this.updateId3CueEnds(g,f);const T=new c(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let o=n.length;o--;){const c=n[o];c.type===e&&c.startTime<t&&c.endTime===Co&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:n}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;n==="audio"?p=g=>g.type===Er.audioId3&&f:n==="video"?p=g=>g.type===Er.emsg&&d:p=g=>g.type===Er.audioId3&&f||g.type===Er.emsg&&d,bc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:o}=e,c=Object.keys(o);if(n){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(E=>{n.removeCue(i[A].cues[E])}),delete i[A]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=Ac();for(let g=0;g<c.length;g++){const v=c[g],A=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=Ec(A.startDate,f);let x=Co;const O=A.endDate;if(O)x=Ec(O,f),w=!0;else if(A.endOnNext&&!w){const D=c.reduce((V,$)=>{const z=o[$];return z.class===A.class&&z.id!==$&&z.startDate>A.startDate&&V.push(z),V},[]).sort((V,$)=>V.startDate.getTime()-$.startDate.getTime())[0];D&&(x=Ec(D.startDate,f),w=!0)}const B=Object.keys(A.attr);for(let D=0;D<B.length;D++){const V=B[D];if(!vv(V))continue;let $=T[V];if($)w&&!E.durationKnown&&($.endTime=x);else{let z=A.attr[V];$=new p(C,x,""),yv(V)&&(z=cy(z)),$.value={key:V,data:z},$.type=Er.dateRange,$.id=v,this.id3Track.addCue($),T[V]=$}}i[v]={cues:T,dateRange:A,durationKnown:w}}}}class dy{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:n}=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*n);const g=n,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 n=i.edge,o=t-e-this.edgeStalled,c=n-i.totalduration,d=n-(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===pt.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&X.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:n,maxLiveSyncPlaybackRate:o}=this.config;if(!n||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 Tc=["NONE","TYPE-0","TYPE-1",null];var wa={No:"",Yes:"YES",v2:"v2"};function uy(s,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:n}=s,o=t!==void 0?t-n:0;return e&&o<e?i?wa.v2:wa.Yes:wa.No}class D0{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 Sa{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 kc(s,t){const e=t.startPTS;if(Wt(e)){let i=0,n;t.sn>s.sn?(i=e-s.start,n=s):(i=s.start-e,n=t),n.duration!==i&&(n.duration=i)}else t.sn>s.sn?s.cc===t.cc&&s.minEndPTS?t.start=s.start+(s.minEndPTS-s.start):t.start=s.start+s.duration:t.start=Math.max(s.start-t.duration,0)}function x0(s,t,e,i,n,o){i-e<=0&&(X.warn("Fragment should have a positive duration",t),i=e+t.duration,o=n+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),n=Math.min(n,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=n,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!s||v<s.startSN||v>s.endSN)return 0;let A;const E=v-s.startSN,T=s.fragments;for(T[E]=t,A=E;A>0;A--)kc(T[A],T[A-1]);for(A=E;A<T.length-1;A++)kc(T[A],T[A+1]);return s.fragmentHint&&kc(T[T.length-1],s.fragmentHint),s.PTSKnown=s.alignedSliding=!0,g}function fy(s,t){let e=null;const i=s.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}s.fragmentHint&&delete s.fragmentHint.endPTS;let n=0,o;if(my(s,t,(f,p)=>{f.relurl&&(n=f.cc-p.cc),Wt(f.startPTS)&&Wt(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){X.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=py(s.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(n){X.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=n}t.skippedSegments&&(t.startCC=t.fragments[0].cc),gy(s.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?x0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):P0(s,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=s.driftStartTime,t.driftStart=s.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=s.driftEndTime,t.driftEnd=s.driftEnd,t.advancedDateTime=s.advancedDateTime}function py(s,t,e){const i=hi({},s);return e&&e.forEach(n=>{delete i[n]}),Object.keys(t).forEach(n=>{const o=new qu(t[n].attr,i[n]);o.isValid?i[n]=o:X.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[n].attr)}"`)}),i}function gy(s,t,e){if(s&&t){let i=0;for(let n=0,o=s.length;n<=o;n++){const c=s[n],d=t[n+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function my(s,t,e){const i=t.skippedSegments,n=Math.max(s.startSN,t.startSN)-t.startSN,o=(s.fragmentHint?1:0)+(i?t.endSN:Math.min(s.endSN,t.endSN))-t.startSN,c=t.startSN-s.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=s.fragmentHint?s.fragments.concat(s.fragmentHint):s.fragments;for(let p=n;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(s,t){const e=t.startSN+t.skippedSegments-s.startSN,i=s.fragments;e<0||e>=i.length||wc(t,i[e].start)}function wc(s,t){if(t){const e=s.fragments;for(let i=s.skippedSegments;i<e.length;i++)e[i].start+=t;s.fragmentHint&&(s.fragmentHint.start+=t)}}function vy(s,t=1/0){let e=1e3*s.targetduration;if(s.updated){const i=s.fragments,n=4;if(i.length&&e*n>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function yy(s,t,e){if(!(s!=null&&s.details))return null;const i=s.details;let n=i.fragments[t-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===t)?n:t<i.startSN&&e&&e.sn===t?e:null}function O0(s,t,e){var i;return s!=null&&s.details?M0((i=s.details)==null?void 0:i.partList,t,e):null}function M0(s,t,e){if(s)for(let i=s.length;i--;){const n=s[i];if(n.index===e&&n.fragment.sn===t)return n}return null}function Io(s){switch(s.details){case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_TIMEOUT:case pt.LEVEL_LOAD_TIMEOUT:case pt.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function $0(s,t){const e=Io(t);return s.default[`${e?"timeout":"error"}Retry`]}function Sc(s,t){const e=s.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*s.retryDelayMs,s.maxRetryDelayMs)}function F0(s){return Ki(Ki({},s),{errorRetry:null,timeoutRetry:null})}function Do(s,t,e,i){return!!s&&t<s.maxNumRetry&&(by(i)||!!e)}function by(s){return s===0&&navigator.onLine===!1||!!s&&(s<400||s>499)}const N0={search:function(s,t){let e=0,i=s.length-1,n=null,o=null;for(;e<=i;){n=(e+i)/2|0,o=s[n];const c=t(o);if(c>0)e=n+1;else if(c<0)i=n-1;else return o}return null}};function Ay(s,t,e){if(t===null||!Array.isArray(s)||!s.length||!Wt(t))return null;const i=s[0].programDateTime;if(t<(i||0))return null;const n=s[s.length-1].endProgramDateTime;if(t>=(n||0))return null;e=e||0;for(let o=0;o<s.length;++o){const c=s[o];if(Ey(t,e,c))return c}return null}function Ra(s,t,e=0,i=0){let n=null;if(s?n=t[s.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(n=t[0]),n&&Rc(e,i,n)===0)return n;const o=N0.search(t,Rc.bind(null,e,i));return o&&(o!==s||!n)?o:n}function Rc(s=0,t=0,e){if(e.start<=s&&e.start+e.duration>s)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=s?1:e.start-i>s&&e.start?-1:0}function Ey(s,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>s}function Ty(s,t){return N0.search(s,e=>e.cc<t?1:e.cc>t?-1:0)}const ky=3e5;var Ii={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},hr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class wy{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=X.log.bind(X,"[info]:"),this.warn=X.warn.bind(X,"[warning]:"),this.error=X.error.bind(X,"[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)===Qt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,n;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case pt.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ii.DoNothing,flags:hr.None};return}case pt.FRAG_GAP:case pt.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ii.SendAlternateToPenaltyBox;return}case pt.LEVEL_EMPTY_ERROR:case pt.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Qt.MAIN?e.level:o.loadLevel;e.details===pt.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 pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.SUBTITLE_LOAD_ERROR:case pt.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Te.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Te.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ii.SendAlternateToPenaltyBox,e.errorAction.flags=hr.MoveAllAlternatesMatchingHost;return}}return;case pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ii.SendAlternateToPenaltyBox,flags:hr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case pt.BUFFER_ADD_CODEC_ERROR:case pt.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(n=e.level)!=null?n:o.loadLevel);return;case pt.INTERNAL_EXCEPTION:case pt.BUFFER_APPENDING_ERROR:case pt.BUFFER_APPEND_ERROR:case pt.BUFFER_FULL_ERROR:case pt.LEVEL_SWITCH_ERROR:case pt.BUFFER_STALLED_ERROR:case pt.BUFFER_SEEK_OVER_HOLE:case pt.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ii.DoNothing,flags:hr.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 n=this.hls,o=$0(n.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Do(o,c,Io(t),d))return{action:Ii.RetryRequest,flags:hr.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),n=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=$0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,A)=>v+A.fragmentError,0);if(n){var p;t.details!==pt.FRAG_GAP&&n.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Do(d,f,Io(t),v))return{action:Ii.RetryRequest,flags:hr.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 n=this.hls.levels[e];if(n&&(n.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:E,groupId:T}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const x=f[C];if(t.details===pt.FRAG_GAP&&t.frag){const O=f[C].details;if(O){const B=Ra(t.frag,O.fragments,t.frag.start);if(B!=null&&B.gap)continue}}else if(E===Te.AUDIO_TRACK&&T===x.audioGroupId||E===Te.SUBTITLE_TRACK&&T===x.textGroupId||A===Qt.AUDIO&&n.audioGroupId===x.audioGroupId||A===Qt.SUBTITLE&&n.textGroupId===x.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ii.SendAlternateToPenaltyBox,flags:hr.None,nextAutoLevel:d}}return{action:Ii.SendAlternateToPenaltyBox,flags:hr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ii.DoNothing:break;case Ii.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==pt.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:n,hdcpLevel:o,nextAutoLevel:c}=i;switch(n){case hr.None:this.switchLevel(t,c);break;case hr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case hr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Tc[Tc.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,n=t.parent===Qt.MAIN?t.level:e.loadLevel,o=e.levels[n],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||Sy(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=n,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,n=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(e),n.details=t.details,i[t.urlId]=n}}function Sy(s,t,e){if(performance.now()-s.lastErrorPerfMs>ky)return!0;const i=s.details;if(t.details===pt.FRAG_GAP&&i&&t.frag){const n=t.frag.start,o=Ra(null,i.fragments,n);if(o&&!o.gap)return!0}if(e&&s.errors.length<e.errors.length){const n=s.errors[s.errors.length-1];if(i&&n.frag&&t.frag&&Math.abs(n.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class _c{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=X.log.bind(X,`${e}:`),this.warn=X.warn.bind(X,`${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 n=-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){X.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){n=o;break}else d===t.substring(0,d.length)&&(n=o)}if(n!==-1){const o=i[n],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 D0(c,d>=0?d:void 0,wa.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:n,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(n.advancedDateTime=Date.now()-d,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${t} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&fy(i,n),!this.canLoad||!n.live)return;let f,p,g;if(n.canBlockReload&&n.endSN&&n.advanced){const C=this.hls.config.lowLatencyMode,x=n.lastPartSn,O=n.endSN,B=n.lastPartIndex,D=B!==-1,V=x===O,$=C?0:B;D?(p=V?O+1:x,g=V?$:B+1):p=O+1;const z=n.age,it=z+n.ageHeader;let at=Math.min(it-n.partTarget,n.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: ${n.age}`),at=0;else{const J=Math.floor(at/n.targetduration);if(p+=J,g!==void 0){const wt=Math.round(at%n.targetduration/n.partTarget);g+=wt}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${z.toFixed(2)}s goal: ${at} skip sn ${J} to part ${g}`)}n.tuneInGoal=at}if(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g),C||!V){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,A=v?v.end-v.len:0,E=(n.edge-A)*1e3,T=vy(n,E);n.updated&&c>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=o.loading.first+T-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=T);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,n){let o=uy(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,n=e.part,o=wa.No),new D0(i,n,o)}checkRetry(t){const e=t.details,i=Io(t),n=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=n||{},f=!!n&&!!d&&(o===Ii.RetryRequest||!n.resolved&&o===Ii.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=Sc(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,n.resolved=!0}return f}}let Lc;class Ry extends _c{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=[],n={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(Lc||(Lc=/chrome|firefox/i.test(navigator.userAgent)),Lc&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":A,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${A||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=n[w],o?o.addFallback(c):(o=new Sa(c),n[w]=o,i.push(o)),xo(o,"audio",p),xo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],n=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:x})=>(o||(o=!!(w&&C)),c||(c=!!T),d||(d=!!E),!(x!=null&&x.length)&&(!E||vc(E,"audio"))&&(!T||vc(T,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:T,height:w})=>!!E||!!(T&&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:pt.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||vc(E.audioCodec,"audio")),U0(i)),e.subtitles&&(n=e.subtitles,U0(n));const p=f.slice(0);f.sort((E,T)=>E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==T.bitrate?E.bitrate-T.bitrate:E.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==T.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==T.height?E.height-T.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,A={levels:f,audioTracks:i,subtitleTracks:n,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,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(R.ERROR,{type:qt.OTHER_ERROR,details:pt.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,n=this.currentLevel,o=n?n.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&n&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=hi({},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,n==null?void 0:n.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===Te.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:n,details:o}=e,c=this._levels[n];if(!c){var d;this.warn(`Invalid level index ${n}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(n,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===n){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 n=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 ${n+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:n,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,n=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:n})}onLevelsUpdated(t,{levels:e}){e.forEach((i,n)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=n})}),this._levels=e}}function xo(s,t,e){e&&(t==="audio"?(s.audioGroupIds||(s.audioGroupIds=[]),s.audioGroupIds[s.url.length-1]=e):t==="text"&&(s.textGroupIds||(s.textGroupIds=[]),s.textGroupIds[s.url.length-1]=e))}function U0(s){const t={};s.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var gi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class _y{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 n=i.length;n--;){const o=i[n];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,n=Object.keys(i);for(let o=n.length;o--;){const c=i[n[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,n){this.timeRanges&&(this.timeRanges[t]=e);const o=(n==null?void 0:n.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:n}=t;if(!e||i.sn==="initSegment")return;const o=Rn(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,n,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),Po(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(n=>n.fragment.sn>=t))}fragBuffered(t,e){const i=Rn(t);let n=this.fragments[i];!n&&e&&(n=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(t,e,i,n){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<n.length;g++){const v=n.start(g)-this.bufferPadding,A=n.end(g)+this.bufferPadding;if(p>=v&&f<=A){o.time.push({startPTS:Math.max(c,n.start(g)),endPTS:Math.min(d,n.end(g))});break}else if(c<A&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,n.start(g)),endPTS:Math.min(d,n.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,n,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Po(g)&&(n=g.body.start-d,o=g.body.end+d,t>=n&&t<=o&&(i=Math.min(t-n,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Po(e))}getState(t){const e=Rn(t),i=this.fragments[e];return i?i.buffered?Po(i)?gi.PARTIAL:gi.OK:gi.APPENDING:gi.NOT_LOADED}isTimeBuffered(t,e,i){let n,o;for(let c=0;c<i.length;c++){if(n=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=n&&e<=o)return!0;if(e<=n)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:n}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=n?null:e,c=Rn(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:n,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(n){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(n)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,n)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Rn(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,n,o){n&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||n&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=Rn(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const n=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==n)}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 Po(s){var t,e,i;return s.buffered&&(s.body.gap||((t=s.range.video)==null?void 0:t.partial)||((e=s.range.audio)==null?void 0:e.partial)||((i=s.range.audiovideo)==null?void 0:i.partial))}function Rn(s){return`${s.type}_${s.level}_${s.urlId}_${s.sn}`}const B0=Math.pow(2,17);class Ly{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 ts({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,o=n.fLoader,c=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(V0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(n):new c(n),g=G0(t),v=F0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:B0};t.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{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:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Ki({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const n=this.config,o=n.fLoader,c=n.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(V0(t,e));return}const p=this.loader=t.loader=o?new o(n):new c(n),g=G0(t,e),v=F0(n.fragLoadPolicy.default),A={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:B0};e.stats=p.stats,p.load(g,A,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const x={frag:t,part:e,payload:E.data,networkDetails:C};i(x),d(x)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Ki({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new ts({type:qt.NETWORK_ERROR,details:pt.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,n=e.stats,o=n.total;if(i.loaded+=n.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=n.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 G0(s,t=null){const e=t||s,i={frag:s,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},n=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(n)&&Wt(o)){var c;let d=n,f=o;if(s.sn==="initSegment"&&((c=s.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-n;p%16&&(f=o+(16-p%16)),n!==0&&(i.resetIV=!0,d=n-16)}i.rangeStart=d,i.rangeEnd=f}return i}function V0(s,t){const e=new Error(`GAP ${s.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:pt.FRAG_GAP,fatal:!1,frag:s,error:e,networkDetails:null};return t&&(i.part=t),(t||s).stats.aborted=!0,new ts(i)}class ts extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class Cy{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=pt.KEY_LOAD_ERROR,i,n,o){return new ts({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:n})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=t;for(let o=0;o<e.length;o++){const c=e[o];if(n<=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,n;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,pt.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,pt.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((n=d)!=null&&n.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,pt.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 n=this.emeController.loadKey(i);if(n)return(t.keyLoadPromise=n.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,n=i.loader,o=new n(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,E,T,w)=>{const{frag:C,keyInfo:x,url:O}=T;if(!C.decryptdata||x!==this.keyUriToKeyInfo[O])return d(this.createKeyLoadError(C,pt.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));x.decryptdata.key=C.decryptdata.key=new Uint8Array(A.data),C.keyLoader=null,x.loader=null,c({frag:C,keyInfo:x})},onError:(A,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),T,Ki({url:f.url,data:void 0},A)))},onTimeout:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(A,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,pt.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:n}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],o&&o.destroy()}}class Iy{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 Dy={length:0,start:()=>0,end:()=>0};class Be{static isBuffered(t,e){try{if(t){const i=Be.getBuffered(t);for(let n=0;n<i.length;n++)if(e>=i.start(n)&&e<=i.end(n))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const n=Be.getBuffered(t),o=[];let c;for(c=0;c<n.length;c++)o.push({start:n.start(c),end:n.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 n=[];if(i)for(let p=0;p<t.length;p++){const g=n.length;if(g){const v=n[g-1].end;t[p].start-v<i?t[p].end>v&&(n[g-1].end=t[p].end):n.push(t[p])}else n.push(t[p])}else n=t;let o=0,c,d=e,f=e;for(let p=0;p<n.length;p++){const g=n[p].start,v=n[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 X.log("failed to get media.buffered",e),Dy}}}class Cc{constructor(t,e,i,n=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=Oo(),this.buffering={audio:Oo(),video:Oo(),audiovideo:Oo()},this.level=t,this.sn=e,this.id=i,this.size=n,this.part=o,this.partial=c}}function Oo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function H0(s,t){let e=null;for(let i=0,n=s.length;i<n;i++){const o=s[i];if(o&&o.cc===t){e=o;break}}return e}function xy(s,t,e){return!!(t.details&&(e.endCC>e.startCC||s&&s.cc<e.startCC))}function Py(s,t,e=0){const i=s.fragments,n=t.fragments;if(!n.length||!i.length){X.log("No fragments to align");return}const o=H0(i,n[0].cc);if(!o||o&&!o.startPTS){X.log("No frag in previous level to align on");return}return o}function W0(s,t){if(s){const e=s.start+t;s.start=s.startPTS=e,s.endPTS=e+s.duration}}function Ic(s,t){const e=t.fragments;for(let i=0,n=e.length;i<n;i++)W0(e[i],s);t.fragmentHint&&W0(t.fragmentHint,s),t.alignedSliding=!0}function Oy(s,t,e){t&&(My(s,e,t),!e.alignedSliding&&t.details&&$y(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&P0(t.details,e))}function My(s,t,e){if(xy(s,e,t)){const i=Py(e.details,t);i&&Wt(i.start)&&(X.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Ic(i.start,t))}}function $y(s,t){if(!t.fragments.length||!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=s.fragments[0].programDateTime,n=(i-e)/1e3+t.fragments[0].start;n&&Wt(n)&&(X.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${n.toFixed(3)} ${s.url} `),Ic(n,s))}function j0(s,t){if(!s.hasProgramDateTime||!t.hasProgramDateTime)return;const e=s.fragments,i=t.fragments;if(!e.length||!i.length)return;const n=Math.round(i.length/2)-1,o=i[n],c=H0(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);Ic(p,s)}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 Ny{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 Uy(s){const t=s.byteLength,e=t&&new DataView(s.buffer).getUint8(t-1);return e?an(s,0,t-e):s}class By{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 n=0;n<4;n++)i[n]=e.getUint32(n*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,n=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],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){let x=w^w<<1^w<<2^w<<3^w<<4;x=x>>>8^x&255^99,t[T]=x,e[x]=T;const O=E[T],B=E[O],D=E[B];let V=E[x]*257^x*16843008;n[T]=V<<24|V>>>8,o[T]=V<<16|V>>>16,c[T]=V<<8|V>>>24,d[T]=V,V=D*16843009^B*65537^O*257^T*16843008,p[x]=V<<24|V>>>8,g[x]=V<<16|V>>>16,v[x]=V<<8|V>>>24,A[x]=V,T?(T=O^E[E[E[D^O]]],w^=E[E[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,n=0;for(;n<e.length&&i;)i=e[n]===this.key[n],n++;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,E=this.invSubMix,T=E[0],w=E[1],C=E[2],x=E[3];let O,B;for(d=0;d<c;d++){if(d<o){O=p[d]=e[d];continue}B=O,d%o===0?(B=B<<8|B>>>24,B=v[B>>>24]<<24|v[B>>>16&255]<<16|v[B>>>8&255]<<8|v[B&255],B^=A[d/o|0]<<24):o>6&&d%o===4&&(B=v[B>>>24]<<24|v[B>>>16&255]<<16|v[B>>>8&255]<<8|v[B&255]),p[d]=O=(p[d-o]^B)>>>0}for(f=0;f<c;f++)d=c-f,f&3?B=p[d]:B=p[d-4],f<4||d<=4?g[f]=B:g[f]=T[v[B>>>24]]^w[v[B>>>16&255]]^C[v[B>>>8&255]]^x[v[B&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const n=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 E=A[0],T=A[1],w=A[2],C=A[3];const x=new Int32Array(t),O=new Int32Array(x.length);let B,D,V,$,z,it,at,J,wt,vt,Ot,Gt,U,q;const At=this.networkToHostOrderSwap;for(;e<x.length;){for(wt=At(x[e]),vt=At(x[e+1]),Ot=At(x[e+2]),Gt=At(x[e+3]),z=wt^o[0],it=Gt^o[1],at=Ot^o[2],J=vt^o[3],U=4,q=1;q<n;q++)B=f[z>>>24]^p[it>>16&255]^g[at>>8&255]^v[J&255]^o[U],D=f[it>>>24]^p[at>>16&255]^g[J>>8&255]^v[z&255]^o[U+1],V=f[at>>>24]^p[J>>16&255]^g[z>>8&255]^v[it&255]^o[U+2],$=f[J>>>24]^p[z>>16&255]^g[it>>8&255]^v[at&255]^o[U+3],z=B,it=D,at=V,J=$,U=U+4;B=c[z>>>24]<<24^c[it>>16&255]<<16^c[at>>8&255]<<8^c[J&255]^o[U],D=c[it>>>24]<<24^c[at>>16&255]<<16^c[J>>8&255]<<8^c[z&255]^o[U+1],V=c[at>>>24]<<24^c[J>>16&255]<<16^c[z>>8&255]<<8^c[it&255]^o[U+2],$=c[J>>>24]<<24^c[z>>16&255]<<16^c[it>>8&255]<<8^c[at&255]^o[U+3],O[e]=At(B^E),O[e+1]=At($^T),O[e+2]=At(V^w),O[e+3]=At(D^C),E=wt,T=vt,w=Ot,C=Gt,e=e+4}return O.buffer}}const Gy=16;class Dc{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?Uy(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((n,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?n(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:n,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=on(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;n&&(i=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new By),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=an(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const n=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new Ny(n,e)),this.fastAesKey.expandKey().then(o=>n?(this.logOnce("WebCrypto AES decrypt"),new Fy(n,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(X.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 n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%Gy;return i!==t.length&&(e=an(t,0,i),this.remainderData=an(t,i)),e}logOnce(t){this.logEnabled&&(X.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Vy={toString:function(s){let t="";const e=s.length;for(let i=0;i<e;i++)t+=`[${s.start(i).toFixed(3)}-${s.end(i).toFixed(3)}]`;return t}},kt={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 xc extends Iy{constructor(t,e,i,n,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=kt.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=n,this.log=X.log.bind(X,`${n}:`),this.warn=X.warn.bind(X,`${n}:`),this.hls=t,this.fragmentLoader=new Ly(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Dc(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=kt.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 Be.isBuffered(this.media,o.start+o.duration/2)}const n=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}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 n=this.config;this.levels&&n.autoStartLoad&&this.state===kt.STOPPED&&this.startLoad(n.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:n,state:o}=this,c=i?i.currentTime:0,d=Be.bufferInfo(n||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Wt(c)?c.toFixed(3):c}, state: ${o}`),this.state===kt.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=kt.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 n=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,n).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===kt.FRAG_LOADING||!this.fragCurrent&&c===kt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=kt.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===kt.STOPPED||this.state===kt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===gi.APPENDING){const n=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),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)===gi.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 n={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,n)}_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:n}=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 n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return n.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:n,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=kt.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===n&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:n,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===kt.STOPPED||this.state===kt.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,n,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)}-${((n=t.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${d?Vy.toString(Be.getBuffered(d)):"(detached)"})`),this.state=kt.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:n,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Cc(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,n){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=kt.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===kt.KEY_LOADING&&(this.state=kt.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&&n){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=kt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,A,e,n)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,A,e,n).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:A,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))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=kt.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,n)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?n:void 0),d]).then(([g])=>(!f&&g&&n&&n(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,n){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,n).then(A=>{f[v.index]=A;const E=A.part;this.hls.trigger(R.FRAG_LOADED,A);const T=O0(i,t.sn,v.index+1)||M0(p,t.sn,v.index+1);if(T)g(T);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===pt.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:pt.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==kt.PARSING){!this.fragCurrent&&this.state!==kt.STOPPED&&this.state!==kt.ERROR&&(this.state=kt.IDLE);return}const{frag:i,part:n,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,n&&(n.stats.parsing.end=c),this.updateLevelTiming(i,n,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:n,sn:o,part:c}=t;if(!(e!=null&&e[n]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${n}. The current chunk will not be buffered.`),null;const d=e[n],f=c>-1?O0(d,o,c):null,p=f?f.fragment:yy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,n,o){var c;if(!t||this.state!==kt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=on(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:n,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(!Be.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,n=Be.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,n.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:n}}=this,o=Be.bufferInfo(t,e,n);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return Be.bufferInfo(t,e,Math.max(o.nextStart,n))}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,n=i.length;if(!n)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, 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===gi.OK||i===gi.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,n,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,n);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${n}" 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 n=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,n>-1&&i<p.start)break;const g=p.loaded;g?n=-1:(o||p.independent||c)&&p.fragment===e&&(n=d),o=g}return n}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let n=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=Ay(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(n=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=Ty(e,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(n=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return n}getFragmentAtPosition(t,e,i){const{config:n}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=n.maxFragLookUpTolerance,g=i.partList,v=!!(n.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let A;if(t<e){const E=t>e-p?0:p;A=Ra(o,c,t,E)}else A=c[c.length-1];if(A){const E=A.sn-i.startSN,T=this.fragmentTracker.getState(A);if((T===gi.OK||T===gi.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[E+1];A.sn<d&&this.fragmentTracker.getState(w)!==gi.OK?A=w:A=null}}return A}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(n!==null&&i.duration>n&&(o<n||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:n,fragPrevious:o}=this,c=n!==null?i[n]: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&&Wt(f);if(p||!g&&!f){Oy(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 n=this.startTimeOffset!==null,o=n?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(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 ${n?"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!==kt.FRAG_LOADING_WAITING_RETRY)&&(this.state=kt.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 n;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(n=this.fragCurrent)==null?void 0:n.url}`);return}const o=e.details===pt.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ii.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=Sc(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=kt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):X.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ii.SendAlternateToPenaltyBox?this.state=kt.WAITING_LEVEL:this.state=kt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===kt.PARSING||this.state===kt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const o=!n;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!==kt.STOPPED&&(this.state=kt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const n=Be.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,n,i),this.state===kt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=kt.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,n){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=n?0:x0(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:pt.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=kt.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,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.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 K0(){return self.SourceBuffer||self.WebKitSourceBuffer}function Hy(){const s=Lo();if(!s)return!1;const t=K0(),e=s&&typeof s.isTypeSupported=="function"&&s.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 Wy(){var s;const t=K0();return typeof(t==null||(s=t.prototype)==null?void 0:s.changeType)=="function"}function jy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Ky(){const s=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(s);return{worker:new self.Worker(t),objectURL:t}}function zy(s){const t=new self.URL(s,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function $r(s="",t=9e4){return{type:s,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class z0{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,n){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=on(this.cachedData,t),this.cachedData=null);let i=wo(t,0),n=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?Cv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=Yy(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:Er.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(t,n)){const g=this.appendFrame(c,t,n);g?(this.frameIndex++,this.lastPTS=g.sample.pts,n+=g.length,o=n):n=p}else Lv(t,n)?(i=wo(t,n),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Er.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,o=n):n++;if(n===p&&o!==p){const g=an(t,o);this.cachedData?this.cachedData=on(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:$r(),id3Track:d,textTrack:$r()}}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:$r(),id3Track:this._id3Track,textTrack:$r()}}destroy(){}}const Yy=(s,t,e)=>{if(Wt(s))return s*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Xy(s,t,e,i){let n,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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,X.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(n=5,d=new Array(4),o=v-3):(n=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(n=2,d=new Array(2),o=v):(n=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)&&(n=2,d=new Array(2)),o=v)),d[0]=n<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,n===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."+n,manifestCodec:p}}function Y0(s,t){return s[t]===255&&(s[t+1]&246)===240}function X0(s,t){return s[t+1]&1?7:9}function Pc(s,t){return(s[t+3]&3)<<11|s[t+4]<<3|(s[t+5]&224)>>>5}function Zy(s,t){return t+5<s.length}function Mo(s,t){return t+1<s.length&&Y0(s,t)}function qy(s,t){return Zy(s,t)&&Y0(s,t)&&Pc(s,t)<=s.length-t}function Qy(s,t){if(Mo(s,t)){const e=X0(s,t);if(t+e>=s.length)return!1;const i=Pc(s,t);if(i<=e)return!1;const n=t+i;return n===s.length||Mo(s,n)}return!1}function Z0(s,t,e,i,n){if(!s.samplerate){const o=Xy(t,e,i,n);if(!o)return;s.config=o.config,s.samplerate=o.samplerate,s.channelCount=o.channelCount,s.codec=o.codec,s.manifestCodec=o.manifestCodec,X.log(`parsed codec:${s.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function q0(s){return 9216e4/s}function Jy(s,t){const e=X0(s,t);if(t+e<=s.length){const i=Pc(s,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Q0(s,t,e,i,n){const o=q0(s.samplerate),c=i+n*o,d=Jy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,A=v+g,E=Math.max(0,e+A-t.length);E?(f=new Uint8Array(A-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+A);const T={unit:f,pts:c};return E||s.samples.push(T),{sample:T,length:A,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 tb extends z0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(wo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Qy(t,e))return X.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return qy(t,e)}appendFrame(t,e,i){Z0(t,this.observer,e,i,t.manifestCodec);const n=Q0(t,e,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const eb=/\/emsg[-/]ID3/i;class ib{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,n){const o=this.videoTrack=$r("video",1),c=this.audioTrack=$r("audio",1),d=this.txtTrack=$r("text",1);if(this.id3Track=$r("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=h0(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=o0.text,o.sampleDuration=0,o.duration=c.duration=n}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,ye(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const n=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=on(this.remainderData,t));const d=Wv(i);this.remainderData=d.remainder,n.samples=d.valid||new Uint8Array}else n.samples=i;const c=this.extractID3Track(n,e);return o.samples=u0(e,n),{videoTrack:n,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 n=this.extractID3Track(e,this.timeOffset);return i.samples=u0(t,e),{videoTrack:e,audioTrack:$r(),id3Track:n,textTrack:$r()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const n=ye(t.samples,["emsg"]);n&&n.forEach(o=>{const c=zv(o);if(eb.test(c.schemeIdUri)){const d=Wt(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:Er.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 rb=[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],sb=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],nb=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],ab=[0,1,1,4];function J0(s,t,e,i,n){if(e+24>t.length)return;const o=tf(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+n*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return s.config=[],s.channelCount=o.channelCount,s.samplerate=o.sampleRate,s.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function tf(s,t){const e=s[t+1]>>3&3,i=s[t+1]>>1&3,n=s[t+2]>>4&15,o=s[t+2]>>2&3;if(e!==1&&n!==0&&n!==15&&o!==3){const c=s[t+2]>>1&1,d=s[t+3]>>6,f=e===3?3-i:i===3?3:4,p=rb[f*14+n-1]*1e3,g=sb[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,A=nb[e][i],E=ab[i],T=A*8*E,w=Math.floor(A*p/g+c)*E;if($o===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);$o=C?parseInt(C[1]):0}return $o&&$o<=87&&i===2&&p>=224e3&&d===0&&(s[t+3]=s[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Oc(s,t){return s[t]===255&&(s[t+1]&224)===224&&(s[t+1]&6)!==0}function ef(s,t){return t+1<s.length&&Oc(s,t)}function ob(s,t){return Oc(s,t)&&4<=s.length-t}function lb(s,t){if(t+1<s.length&&Oc(s,t)){const e=tf(s,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const n=t+i;return n===s.length||ef(s,n)}return!1}class rf{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,n=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");n.set(t.subarray(i,i+o)),this.word=new DataView(n.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&&X.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,n;for(let o=0;o<t;o++)i!==0&&(n=this.readEG(),i=(e+n+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,n=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),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),A(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const $=g();if($===3&&A(1),T(),T(),A(1),v())for(c=$!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}T();const x=g();if(x===0)g();else if(x===1)for(A(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),A(1);const O=g(),B=g(),D=p(1);D===0&&A(1),A(1),v()&&(t=g(),e=g(),i=g(),n=g());let V=[1,1];if(v()&&v())switch(f()){case 1:V=[1,1];break;case 2:V=[12,11];break;case 3:V=[10,11];break;case 4:V=[16,11];break;case 5:V=[40,33];break;case 6:V=[24,11];break;case 7:V=[20,11];break;case 8:V=[32,11];break;case 9:V=[80,33];break;case 10:V=[18,11];break;case 11:V=[15,11];break;case 12:V=[64,33];break;case 13:V=[160,99];break;case 14:V=[4,3];break;case 15:V=[3,2];break;case 16:V=[2,1];break;case 255:{V=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((O+1)*16-t*2-e*2),height:(2-D)*(B+1)*16-(D?2:4)*(i+n),pixelRatio:V}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class cb{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Dc(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const n=t[e].unit;if(n.length<=16)return;const o=n.subarray(16,n.length-n.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);n.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 n=0;for(let o=32;o<t.length-16;o+=160,n+=16)i.set(t.subarray(o,o+16),n);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let n=0;for(let o=32;o<t.length-16;o+=160,n+=16)t.set(i.subarray(n,n+16),o);return t}decryptAvcSample(t,e,i,n,o){const c=p0(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,n)})}decryptAvcSamples(t,e,i,n){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){n();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,n,c),!this.decrypter.isSync()))return}}}}const Di=188;class Es{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=Es.syncOffset(t);return e>0&&X.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(Di*5,t.length-Di)+1,n=0;for(;n<i;){let o=!1,c=-1,d=0;for(let f=n;f<e;f+=Di)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+Di*99,t.length-Di)+1)),o||(o=Mc(t,f)===0),o&&d>1&&(c===0&&d>2||f+Di>i))return c}else{if(d)return-1;break}n++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:o0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Es.createTrack("video"),this._audioTrack=Es.createTrack("audio",n),this._id3Track=Es.createTrack("id3"),this._txtTrack=Es.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=n}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,n=!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,E=f.pid,T=d.pesData,w=f.pesData,C=null,x=this.pmtParsed,O=this._pmtId,B=t.length;if(this.remainderData&&(t=on(this.remainderData,t),B=t.length,this.remainderData=null),B<Di&&!n)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const D=Math.max(0,Es.syncOffset(t));B-=(B-D)%Di,B<t.byteLength&&!n&&(this.remainderData=new Uint8Array(t.buffer,B,t.buffer.byteLength-B));let V=0;for(let z=D;z<B;z+=Di)if(t[z]===71){const it=!!(t[z+1]&64),at=Mc(t,z),J=(t[z+3]&48)>>4;let wt;if(J>1){if(wt=z+5+t[z+4],wt===z+Di)continue}else wt=z+4;switch(at){case g:it&&(v&&(o=_n(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(wt,z+Di)),v.size+=z+Di-wt);break;case A:if(it){if(T&&(o=_n(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(wt,z+Di)),T.size+=z+Di-wt);break;case E:it&&(w&&(o=_n(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(wt,z+Di)),w.size+=z+Di-wt);break;case 0:it&&(wt+=t[wt]+1),O=this._pmtId=hb(t,wt);break;case O:{it&&(wt+=t[wt]+1);const vt=db(t,wt,this.typeSupported,i);g=vt.avc,g>0&&(c.pid=g),A=vt.audio,A>0&&(d.pid=A,d.segmentCodec=vt.segmentCodec),E=vt.id3,E>0&&(f.pid=E),C!==null&&!x&&(X.warn(`MPEG-TS PMT found at ${z} after unknown PID '${C}'. Backtracking to sync byte @${D} to parse all TS packets.`),C=null,z=D-188),x=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=at;break}}else V++;if(V>0){const z=new Error(`Found ${V} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:z,reason:z.message})}c.pesData=v,d.pesData=T,f.pesData=w;const $={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples($),$}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:n,textTrack:o}=t,c=i.pesData,d=e.pesData,f=n.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&&X.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=_n(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(t,e,i){const n=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new cb(this.observer,this.config,e);return this.decrypt(n,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:n,videoTrack:o}=t;n.samples&&n.segmentCodec==="aac"?e.decryptAacSamples(n.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,n){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=Fo(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let A=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new rf(E).readSliceType();(T===2||T===4||T===7||T===9)&&(A=!0)}if(A){var v;(v=c)!=null&&v.frame&&!c.key&&(_a(c,t),c=this.avcSample=null)}c||(c=this.avcSample=Fo(!0,i.pts,i.dts,"")),c.frame=!0,c.key=A;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(_a(c,t),c=this.avcSample=null),c||(c=this.avcSample=Fo(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,f0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const A=p.data,E=new rf(A).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[A],t.duration=this._duration;const T=A.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let x=T[C].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=Fo(!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)}),n&&c&&(_a(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;n=o[o.length-1]}return n}parseAVCNALu(t,e){const i=e.byteLength;let n=t.naluState||0;const o=n,c=[];let d=0,f,p,g,v=-1,A=0;for(n===-1&&(v=0,A=e[0]&31,n=0,d=1);d<i;){if(f=e[d++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-n-1),type:A};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-n-1,p>0)){const T=new Uint8Array(E.data.byteLength+p);T.set(E.data,0),T.set(e.subarray(0,p),E.data.byteLength),E.data=T,E.state=0}}d<i?(g=e[d]&31,v=d,A=g,n=0):n=-1}else n=0}if(v>=0&&n>=0){const E={data:e.subarray(v,i),type:A,state:n};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const T=new Uint8Array(E.data.byteLength+e.byteLength);T.set(E.data,0),T.set(e,E.data.byteLength),E.data=T}}return t.naluState=n,c}parseAACPES(t,e){let i=0;const n=this.aacOverFlow;let o=e.data;if(n){this.aacOverFlow=null;const v=n.missing,A=n.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(A+o.byteLength);E.set(n.sample.unit,0),E.set(o,A),o=E}else{const E=A-v;n.sample.unit.set(o.subarray(0,v),E),t.samples.push(n.sample),i=n.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Mo(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 E=new Error(v);if(X.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:E,reason:v}),!A)return}Z0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(n){const v=q0(t.samplerate);f=n.sample.pts+v}else{X.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=Q0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Mo(o,c);c++);}parseMPEGPES(t,e){const i=e.data,n=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){X.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<n;)if(ef(i,c)){const f=J0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){X.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=hi({},e,{type:this._avcTrack?Er.emsg:Er.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function Fo(s,t,e,i){return{key:s,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Mc(s,t){return((s[t+1]&31)<<8)+s[t+2]}function hb(s,t){return(s[t+10]&31)<<8|s[t+11]}function db(s,t,e,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(s[t+1]&15)<<8|s[t+2],c=t+3+o-4,d=(s[t+10]&15)<<8|s[t+11];for(t+=12+d;t<c;){const f=Mc(s,t);switch(s[t]){case 207:if(!i){X.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:n.audio===-1&&(n.audio=f);break;case 21:n.id3===-1&&(n.id3=f);break;case 219:if(!i){X.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:n.avc===-1&&(n.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?X.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:X.warn("Unsupported HEVC stream type found");break}t+=((s[t+3]&15)<<8|s[t+4])+5}return n}function _n(s){let t=0,e,i,n,o,c;const d=s.data;if(!s||s.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>s.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&&(X.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),n=e[8];let p=n+9;if(s.size<=p)return null;s.size-=p;const g=new Uint8Array(s.size);for(let v=0,A=d.length;v<A;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-=n+3),{data:g,pts:o,dts:c,len:i}}return null}function _a(s,t){if(s.units.length&&s.frame){if(s.pts===void 0){const e=t.samples,i=e.length;if(i){const n=e[i-1];s.pts=n.pts,s.dts=n.dts}else{t.dropped++;return}}t.samples.push(s)}s.debug.length&&X.log(s.pts+"/"+s.dts+":"+s.debug)}class ub extends z0{resetInitSegment(t,e,i,n){super.resetInitSegment(t,e,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(wo(t,0)||[]).length;for(let i=t.length;e<i;e++)if(lb(t,e))return X.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return ob(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return J0(t,e,i,this.basePTS,this.frameIndex)}}class sf{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 Ts=Math.pow(2,32)-1;class st{static init(){st.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 st.types)st.types.hasOwnProperty(t)&&(st.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]);st.HDLR_TYPES={video:e,audio:i};const n=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]);st.STTS=st.STSC=st.STCO=o,st.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),st.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),st.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),st.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]);st.FTYP=st.box(st.types.ftyp,c,f,c,d),st.DINF=st.box(st.types.dinf,st.box(st.types.dref,n))}static box(t,...e){let i=8,n=e.length;const o=n;for(;n--;)i+=e[n].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),n=0,i=8;n<o;n++)c.set(e[n],i),i+=e[n].byteLength;return c}static hdlr(t){return st.box(st.types.hdlr,st.HDLR_TYPES[t])}static mdat(t){return st.box(st.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),n=Math.floor(e%(Ts+1));return st.box(st.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,n>>24,n>>16&255,n>>8&255,n&255,85,196,0,0]))}static mdia(t){return st.box(st.types.mdia,st.mdhd(t.timescale,t.duration),st.hdlr(t.type),st.minf(t))}static mfhd(t){return st.box(st.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"?st.box(st.types.minf,st.box(st.types.smhd,st.SMHD),st.DINF,st.stbl(t)):st.box(st.types.minf,st.box(st.types.vmhd,st.VMHD),st.DINF,st.stbl(t))}static moof(t,e,i){return st.box(st.types.moof,st.mfhd(t),st.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trak(t[e]);return st.box.apply(null,[st.types.moov,st.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(st.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=st.trex(t[e]);return st.box.apply(null,[st.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),n=Math.floor(e%(Ts+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,n>>24,n>>16&255,n>>8&255,n&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 st.box(st.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let n,o;for(n=0;n<e.length;n++)o=e[n].flags,i[n+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return st.box(st.types.sdtp,i)}static stbl(t){return st.box(st.types.stbl,st.stsd(t),st.box(st.types.stts,st.STTS),st.box(st.types.stsc,st.STSC),st.box(st.types.stsz,st.STSZ),st.box(st.types.stco,st.STCO))}static avc1(t){let e=[],i=[],n,o,c;for(n=0;n<t.sps.length;n++)o=t.sps[n],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(n=0;n<t.pps.length;n++)o=t.pps[n],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=st.box(st.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 st.box(st.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,st.box(st.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),st.box(st.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 st.box(st.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]),st.box(st.types.esds,st.esds(t)))}static mp3(t){const e=t.samplerate;return st.box(st.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"?st.box(st.types.stsd,st.STSD,st.mp3(t)):st.box(st.types.stsd,st.STSD,st.mp4a(t)):st.box(st.types.stsd,st.STSD,st.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,n=t.width,o=t.height,c=Math.floor(i/(Ts+1)),d=Math.floor(i%(Ts+1));return st.box(st.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,n>>8&255,n&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=st.sdtp(t),n=t.id,o=Math.floor(e/(Ts+1)),c=Math.floor(e%(Ts+1));return st.box(st.types.traf,st.box(st.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),st.box(st.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])),st.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,st.box(st.types.trak,st.tkhd(t),st.mdia(t))}static trex(t){const e=t.id;return st.box(st.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||[],n=i.length,o=12+16*n,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,n>>>24&255,n>>>16&255,n>>>8&255,n&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<n;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 st.box(st.types.trun,c)}static initSegment(t){st.types||st.init();const e=st.moov(t),i=new Uint8Array(st.FTYP.byteLength+e.byteLength);return i.set(st.FTYP),i.set(e,st.FTYP.byteLength),i}}st.types=void 0,st.HDLR_TYPES=void 0,st.STTS=void 0,st.STSC=void 0,st.STCO=void 0,st.STSZ=void 0,st.VMHD=void 0,st.SMHD=void 0,st.STSD=void 0,st.FTYP=void 0,st.DINF=void 0;const nf=9e4;function $c(s,t,e=1,i=!1){const n=s*t*e;return i?Math.round(n):n}function fb(s,t,e=1,i=!1){return $c(s,t,1/e,i)}function La(s,t=!1){return $c(s,1e3,1/nf,t)}function pb(s,t=1){return $c(s,nf,1/t)}const gb=10*1e3,af=1024,mb=1152;let No=null,Fc=null;class Nc{constructor(t,e,i,n=""){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,No===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);No=o?parseInt(o[1]):0}if(Fc===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);Fc=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){X.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){X.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){X.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((n,o)=>{const c=o.pts-n;return c<-4294967296?(e=!0,dr(n,o.pts)):c>0?n:o.pts},t[0].pts);return e&&X.debug("PTS rollover detected"),i}remux(t,e,i,n,o,c,d,f){let p,g,v,A,E,T,w=o,C=o;const x=t.pid>-1,O=e.pid>-1,B=e.samples.length,D=t.samples.length>0,V=d&&B>0||B>1;if((!x||D)&&(!O||V)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const $=this.isVideoContiguous;let z=-1,it;if(V&&(z=vb(e.samples),!$&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,z>0){X.warn(`[mp4-remuxer]: Dropped ${z} out of ${B} video samples due to a missing keyframe`);const at=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(z),e.dropped+=z,C+=(e.samples[0].pts-at)/e.inputTimeScale,it=C}else z===-1&&(X.warn(`[mp4-remuxer]: No keyframe found out of ${B} video samples`),T=!1);if(this.ISGenerated){if(D&&V){const at=this.getVideoStartPts(e.samples),J=(dr(t.samples[0].pts,at)-at)/e.inputTimeScale;w+=Math.max(0,J),C+=Math.max(0,-J)}if(D){if(t.samplerate||(X.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,O||V||f===Qt.AUDIO?C:void 0),V){const at=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(X.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,C,$,at)}}else V&&(p=this.remuxVideo(e,C,$,0));p&&(p.firstKeyFrame=z,p.independent=z!==-1,p.firstKeyFramePTS=it)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=of(i,o,this._initPTS,this._initDTS)),n.samples.length&&(A=lf(n,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:A,id3:E}}generateIS(t,e,i,n){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||n,v="audio/mp4",A,E,T;if(g&&(A=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):st.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?A=E=o[0].pts-Math.round(T*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:st.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(c),C=Math.round(T*i);E=Math.min(E,dr(c[0].dts,w)-C),A=Math.min(A,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:A,timescale:T},this._initDTS={baseTime:E,timescale:T}):A=T=void 0,{tracks:f,initPTS:A,timescale:T}}remuxVideo(t,e,i,n){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,A=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,x=!1;if(!i||g===null){const F=e*o,N=c[0].pts-dr(c[0].dts,c[0].pts);g=F-N}const O=p.baseTime*o/p.timescale;for(let F=0;F<f;F++){const N=c[F];N.pts=dr(N.pts-O,g),N.dts=dr(N.dts-O,g),N.dts<c[F>0?F-1:F].dts&&(x=!0)}x&&c.sort(function(F,N){const j=F.dts-N.dts,nt=F.pts-N.pts;return j||nt}),E=c[0].dts,T=c[c.length-1].dts;const B=T-E,D=B?Math.round(B/(f-1)):A||t.inputTimeScale/30;if(i){const F=E-g,N=F>D,j=F<-1;if((N||j)&&(N?X.warn(`AVC: ${La(F,!0)} ms (${F}dts) hole between fragments detected, filling it`):X.warn(`AVC: ${La(-F,!0)} ms (${F}dts) overlapping between fragments detected`),!j||g>=c[0].pts)){E=g;const nt=c[0].pts-F;c[0].dts=E,c[0].pts=nt,X.log(`Video: First PTS/DTS adjusted: ${La(nt,!0)}/${La(E,!0)}, delta: ${La(F,!0)} ms`)}}E=Math.max(0,E);let V=0,$=0;for(let F=0;F<f;F++){const N=c[F],j=N.units,nt=j.length;let ht=0;for(let Lt=0;Lt<nt;Lt++)ht+=j[Lt].data.length;$+=ht,V+=nt,N.length=ht,N.dts=Math.max(N.dts,E),w=Math.min(N.pts,w),C=Math.max(N.pts,C)}T=c[f-1].dts;const z=$+4*V+8;let it;try{it=new Uint8Array(z)}catch(F){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:F,bytes:z,reason:`fail allocating video mdat ${z}`});return}const at=new DataView(it.buffer);at.setUint32(0,z),it.set(st.types.mdat,4);let J=!1,wt=Number.POSITIVE_INFINITY,vt=Number.POSITIVE_INFINITY,Ot=Number.NEGATIVE_INFINITY,Gt=Number.NEGATIVE_INFINITY;for(let F=0;F<f;F++){const N=c[F],j=N.units;let nt=0;for(let Nt=0,jt=j.length;Nt<jt;Nt++){const ue=j[Nt],me=ue.data,ge=ue.data.byteLength;at.setUint32(v,ge),v+=4,it.set(me,v),v+=ge,nt+=4+ge}let ht;if(F<f-1)A=c[F+1].dts-N.dts,ht=c[F+1].pts-N.pts;else{const Nt=this.config,jt=F>0?N.dts-c[F-1].dts:D;if(ht=F>0?N.pts-c[F-1].pts:D,Nt.stretchShortVideoTrack&&this.nextAudioPts!==null){const ue=Math.floor(Nt.maxBufferHole*o),me=(n?w+n*o:this.nextAudioPts)-N.pts;me>ue?(A=me-jt,A<0?A=jt:J=!0,X.log(`[mp4-remuxer]: It is approximately ${me/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=jt}else A=jt}const Lt=Math.round(N.pts-N.dts);wt=Math.min(wt,A),Ot=Math.max(Ot,A),vt=Math.min(vt,ht),Gt=Math.max(Gt,ht),d.push(new cf(N.key,A,nt,Lt))}if(d.length){if(No){if(No<70){const F=d[0].flags;F.dependsOn=2,F.isNonSync=0}}else if(Fc&&Gt-vt<Ot-wt&&D/Ot<.025&&d[0].cts===0){X.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let F=E;for(let N=0,j=d.length;N<j;N++){const nt=F+d[N].duration,ht=F+d[N].cts;if(N<j-1){const Lt=nt+d[N+1].cts;d[N].duration=Lt-ht}else d[N].duration=N?d[N-1].duration:D;d[N].cts=0,F=nt}}}A=J||!A?D:A,this.nextAvcDts=g=T+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const U=st.moof(t.sequenceNumber++,E,hi({},t,{samples:d})),q="video",At={data1:U,data2:it,startPTS:w/o,endPTS:(C+A)/o,startDTS:E/o,endDTS:g/o,type:q,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,At}remuxAudio(t,e,i,n,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?af:mb,g=p*f,v=this._initPTS,A=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=A?0:8,x=this.nextAudioPts||-1;const O=e*c,B=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&x>0&&(n&&Math.abs(O-x)<9e3||Math.abs(dr(w[0].pts-B,O)-x)<20*g),w.forEach(function(U){U.pts=dr(U.pts-B,O)}),!i||x<0){if(w=w.filter(U=>U.pts>=0),!w.length)return;o===0?x=0:n&&!T?x=Math.max(0,O):x=w[0].pts}if(t.segmentCodec==="aac"){const U=this.config.maxAudioFramesDrift;for(let q=0,At=x;q<w.length;q++){const F=w[q],N=F.pts,j=N-At,nt=Math.abs(1e3*j/c);if(j<=-U*g&&T)q===0&&(X.warn(`Audio frame @ ${(N/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*j/c)} ms.`),this.nextAudioPts=x=At=N);else if(j>=U*g&&nt<gb&&T){let ht=Math.round(j/g);At=N-ht*g,At<0&&(ht--,At+=g),q===0&&(this.nextAudioPts=x=At),X.warn(`[mp4-remuxer]: Injecting ${ht} audio frame @ ${(At/c).toFixed(3)}s due to ${Math.round(1e3*j/c)} ms gap.`);for(let Lt=0;Lt<ht;Lt++){const Nt=Math.max(At,0);let jt=sf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);jt||(X.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),jt=F.unit.subarray()),w.splice(q,0,{unit:jt,pts:Nt}),At+=g,q++}}F.pts=At,At+=g}}let D=null,V=null,$,z=0,it=w.length;for(;it--;)z+=w[it].unit.byteLength;for(let U=0,q=w.length;U<q;U++){const At=w[U],F=At.unit;let N=At.pts;if(V!==null){const nt=E[U-1];nt.duration=Math.round((N-V)/f)}else if(i&&t.segmentCodec==="aac"&&(N=x),D=N,z>0){z+=C;try{$=new Uint8Array(z)}catch(nt){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:pt.REMUX_ALLOC_ERROR,fatal:!1,error:nt,bytes:z,reason:`fail allocating audio mdat ${z}`});return}A||(new DataView($.buffer).setUint32(0,z),$.set(st.types.mdat,4))}else return;$.set(F,C);const j=F.byteLength;C+=j,E.push(new cf(!0,p,j,0)),V=N}const at=E.length;if(!at)return;const J=E[E.length-1];this.nextAudioPts=x=V+f*J.duration;const wt=A?new Uint8Array(0):st.moof(t.sequenceNumber++,D/f,hi({},t,{samples:E}));t.samples=[];const vt=D/c,Ot=x/c,Gt={data1:wt,data2:$,startPTS:vt,endPTS:Ot,startDTS:vt,endDTS:Ot,type:"audio",hasAudio:!0,hasVideo:!1,nb:at};return this.isAudioContiguous=!0,Gt}remuxEmptyAudio(t,e,i,n){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:n.startDTS*o)+g,A=n.endDTS*o+g,E=d*af,T=Math.ceil((A-v)/E),w=sf.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(X.warn("[mp4-remuxer]: remux empty Audio"),!w){X.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let x=0;x<T;x++){const O=v+x*E;C.push({unit:w,pts:O,dts:O})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function dr(s,t){let e;if(t===null)return s;for(t<s?e=-8589934592:e=8589934592;Math.abs(s-t)>4294967296;)s+=e;return s}function vb(s){for(let t=0;t<s.length;t++)if(s[t].key)return t;return-1}function of(s,t,e,i){const n=s.samples.length;if(!n)return;const o=s.inputTimeScale;for(let d=0;d<n;d++){const f=s.samples[d];f.pts=dr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=dr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=s.samples;return s.samples=[],{samples:c}}function lf(s,t,e){const i=s.samples.length;if(!i)return;const n=s.inputTimeScale;for(let c=0;c<i;c++){const d=s.samples[c];d.pts=dr(d.pts-e.baseTime*n/e.timescale,t*n)/n}s.samples.sort((c,d)=>c.pts-d.pts);const o=s.samples;return s.samples=[],{samples:o}}class cf{constructor(t,e,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=n,this.flags=new yb(t)}}class yb{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 bb{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,n){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Uv(t,n)),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 n=this.initData=h0(t);e||(e=hf(n.audio,Ie.AUDIO)),i||(i=hf(n.video,Ie.VIDEO));const o={};n.audio&&n.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:n.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:n.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:X.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,n,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const A=e.samples;if(!(A!=null&&A.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(A),T=this.initData),!((f=T)!=null&&f.length))return X.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Gv(A,T),C=Bv(T,A),x=C===null?o:C;(Ab(p,x,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=x-o,p&&p.timescale===1&&X.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const O=t?x-p.baseTime/p.timescale:g,B=O+w;Hv(T,A,p.baseTime/p.timescale),w>0?this.lastEndTime=B:(X.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const D=!!T.audio,V=!!T.video;let $="";D&&($+="audio"),V&&($+="video");const z={data1:A,startPTS:O,startDTS:O,endPTS:B,endDTS:B,type:$,hasAudio:D,hasVideo:V,nb:1,dropped:0};return v.audio=z.type==="audio"?z:void 0,v.video=z.type!=="audio"?z:void 0,v.initSegment=E,v.id3=of(i,o,p,p),n.samples.length&&(v.text=lf(n,o,p)),v}}function Ab(s,t,e,i){if(s===null)return!0;const n=Math.max(i,1),o=t-s.baseTime/s.timescale;return Math.abs(o-e)>n}function hf(s,t){const e=s==null?void 0:s.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===Ie.VIDEO?"avc1.42e01e":"mp4a.40.5"}let es;try{es=self.performance.now.bind(self.performance)}catch{X.debug("Unable to use Performance API on this environment"),es=typeof self<"u"&&self.Date.now}const Uc=[{demux:ib,remux:bb},{demux:Es,remux:Nc},{demux:tb,remux:Nc},{demux:ub,remux:Nc}];class df{constructor(t,e,i,n,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=n,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,n){const o=i.transmuxing;o.executeStart=es();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:A,timeOffset:E,initSegmentChange:T}=n||d,{audioCodec:w,videoCodec:C,defaultInitPts:x,duration:O,initSegmentData:B}=f,D=Eb(c,e);if(D&&D.method==="AES-128"){const it=this.getDecrypter();if(it.isSync()){let at=it.softwareDecrypt(c,D.key.buffer,D.iv.buffer);if(i.part>-1&&(at=it.flush()),!at)return o.executeEnd=es(),Bc(i);c=new Uint8Array(at)}else return this.decryptionPromise=it.webCryptoDecrypt(c,D.key.buffer,D.iv.buffer).then(at=>{const J=this.push(at,null,i);return this.decryptionPromise=null,J}),this.decryptionPromise}const V=this.needsProbing(g,v);if(V){const it=this.configureTransmuxer(c);if(it)return X.warn(`[transmuxer] ${it.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:pt.FRAG_PARSING_ERROR,fatal:!1,error:it,reason:it.message}),o.executeEnd=es(),Bc(i)}(g||v||T||V)&&this.resetInitSegment(B,w,C,O,e),(g||T||V)&&this.resetInitialTimestamp(x),p||this.resetContiguity();const $=this.transmux(c,D,E,A,i),z=this.currentTransmuxState;return z.contiguous=!0,z.discontinuity=!1,z.trackSwitch=!1,o.executeEnd=es(),$}flush(t){const e=t.transmuxing;e.executeStart=es();const{decrypter:i,currentTransmuxState:n,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=n;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=es(),[Bc(t)];const g=f.flush(d);return Uo(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:n,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;X.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(n,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=es()}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,n,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,n),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,n,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,n,o):c=this.transmuxUnencrypted(t,i,n,o),c}transmuxUnencrypted(t,e,i,n){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:n}}transmuxSampleAes(t,e,i,n,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,n,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:n,vendor:o}=this;let c;for(let v=0,A=Uc.length;v<A;v++)if(Uc[v].demux.probe(t)){c=Uc[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,n,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,n),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 Dc(this.config)),t}}function Eb(s,t){let e=null;return s.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Bc=s=>({remuxResult:{},chunkMeta:s});function Uo(s){return"then"in s&&s.then instanceof Function}class Tb{constructor(t,e,i,n,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=n,this.defaultInitPts=o||null}}class kb{constructor(t,e,i,n,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=n,this.timeOffset=o,this.initSegmentChange=c}}var uf={exports:{}};(function(s){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(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 E=new n(g,v||f,A),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],E]:f._events[T].push(E):(f._events[T]=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,A=g.length,E=new Array(A);v<A;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,A,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,x,O;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){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,E),!0}for(O=1,x=new Array(C-1);O<C;O++)x[O-1]=arguments[O];w.fn.apply(w.context,x)}else{var B=w.length,D;for(O=0;O<B;O++)switch(w[O].once&&this.removeListener(f,w[O].fn,void 0,!0),C){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,p);break;case 3:w[O].fn.call(w[O].context,p,g);break;case 4:w[O].fn.call(w[O].context,p,g,v);break;default:if(!x)for(D=1,x=new Array(C-1);D<C;D++)x[D-1]=arguments[D];w[O].fn.apply(w[O].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 E=this._events[A];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,A);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);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,s.exports=d})(uf);var wb=uf.exports,Gc=cv(wb);const Vc=Lo()||{isTypeSupported:()=>!1};class ff{constructor(t,e,i,n){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=n;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 Gc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Vc.isTypeSupported("video/mp4"),mpeg:Vc.isTypeSupported("audio/mpeg"),mp3:Vc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||jy())){try{o.workerPath?(X.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=zy(o.workerPath)):(X.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,X.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:pt.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){X.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new df(this.observer,d,o,f,e)}return}this.transmuxer=new df(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,n,o,c,d,f,p,g){var v,A;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=c?c.start:o.start,w=o.decryptdata,C=this.frag,x=!(C&&o.cc===C.cc),O=!(C&&p.level===C.level),B=C?p.sn-C.sn:-1,D=this.part?p.part-this.part.index:-1,V=B===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),$=!O&&(B===1||B===0&&(D===1||V&&D<=0)),z=self.performance.now();(O||B||o.stats.parsing.start===0)&&(o.stats.parsing.start=z),c&&(D||!$)&&(c.stats.parsing.start=z);const it=!(C&&((v=o.initSegment)==null?void 0:v.url)===((A=C.initSegment)==null?void 0:A.url)),at=new kb(x,$,f,O,T,it);if(!$||x||it){X.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
|
184
184
|
discontinuity: ${x}
|
185
185
|
trackSwitch: ${O}
|
186
186
|
contiguous: ${$}
|
187
187
|
accurateTimeOffset: ${f}
|
188
188
|
timeOffset: ${T}
|
189
|
-
initSegmentChange: ${it}`);const J=new Tb(i,n,e,d,g);this.configureTransmuxer(J)}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 J=E.push(t,w,p,at);Uo(J)?(E.async=!0,J.then(wt=>{this.handleTransmuxComplete(wt)}).catch(wt=>{this.transmuxerError(wt,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(J))}}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);Uo(i)||e.async?(Uo(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,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:pt.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 n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[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 Sb=250,Hc=2,Rb=.1,Lb=.05;class _b{constructor(t,e,i,n){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=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:o}=this;if(n===null)return;const{currentTime:c,seeking:d}=n,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;X.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(n.paused&&!d||n.ended||n.playbackRate===0||!Be.getBuffered(n).length)return;const g=Be.bufferInfo(n,c,0),v=g.len>0,A=g.nextStart||0;if(!v&&!A)return;if(d){const x=g.len>Hc,O=!A||e&&e.start<=c||A-c>Hc&&!this.fragmentTracker.getPartialFragment(c);if(x||O)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const x=Math.max(A,g.start||0)-c,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,B=!(O==null||(E=O.details)==null)&&E.live?O.details.targetduration*2:Hc,D=this.fragmentTracker.getPartialFragment(c);if(x>0&&(x<=B||D)){this._trySkipBufferHole(D);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=Sb&&(this._reportStall(g),!this.media))return;const C=Be.bufferInfo(n,c,i.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:o}=this;if(o===null)return;const c=o.currentTime,d=n.getPartialFragment(c);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-c<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(n===null)return 0;const o=n.currentTime,c=Be.bufferInfo(n,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&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:A}=this;let E=!1;if(o===0){const T=A.getAppendedFrag(0,Qt.MAIN);T&&d<T.end&&(E=!0)}if(!E){const T=t||A.getAppendedFrag(o,Qt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const x=A.getPartialFragment(C);if(x)C+=x.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+Lb,o+Rb);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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:n}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const c=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${c}`);X.warn(d.message),i.currentTime=c,e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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`);X.error(c.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}const Cb=100;class Ib extends xc{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(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(Cb),this.level=-1,!this.startFragRequested){let n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=kt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=kt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case kt.WAITING_LEVEL:{var t;const{levels:i,level:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=kt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=kt.IDLE;break}break}case kt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=kt.IDLE)}break}this.state===kt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this,{config:o,nextLoadLevel:c}=t;if(e===null||!n&&(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 C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=kt.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===kt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==c){this.level=c,this.state=kt.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 E=this.backtrackFragment?this.backtrackFragment.start:f.end;let T=this.getNextFragment(E,g);if(this.couldBacktrack&&!this.fragPrevious&&T&&T.sn!=="initSegment"&&this.fragmentTracker.getState(T)!==gi.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,x=g.fragments[C-1];x&&T.cc===x.cc&&(T=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,E)){if(!T.gap){const C=this.audioOnly&&!this.altAudio?Ce.AUDIO:Ce.VIDEO,x=(C===Ce.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,C,Qt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Qt.MAIN,A)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,E))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===gi.NOT_LOADED||n===gi.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 n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.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 kt.KEY_LOADING:case kt.FRAG_LOADING:case kt.FRAG_LOADING_WAITING_RETRY:case kt.PARSING:case kt.PARSED:this.state=kt.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 _b(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;Wt(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,n=!1,o;e.levels.forEach(c=>{o=c.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!Wy(),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!==kt.IDLE)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=kt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:n}=this,o=e.level,c=e.details,d=c.totalduration;if(!n){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=n[o],p=this.fragCurrent;p&&(this.state===kt.FRAG_LOADING||this.state===kt.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===kt.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=kt.IDLE}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,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),E=this.transmuxer=this.transmuxer||new ff(this.hls,Qt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new Cc(i.level,i.sn,i.stats.chunkCount,o.byteLength,T,w),x=this.initPTS[i.cc];E.push(o,v,A,p,i,n,f.totalduration,g,C,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 n=this.hls;i&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].url;if(n){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=n,this.tick()}onBufferCreated(t,e){const i=e.tracks;let n,o,c=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==Qt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===kt.PARSED&&(this.state=kt.IDLE);return}const o=n?n.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,n)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.MAIN,e);break;case pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===Te.LEVEL&&(this.state=kt.IDLE);break;case pt.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Be.getBuffered(t).length){const i=this.state!==kt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=kt.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,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 n=Be.getBuffered(t),o=(n.length?n.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:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=kt.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(),n.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=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:E,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,T){if(T!=null&&T.tracks){const B=f.initSegment||f;this._bufferInitSegment(g,T.tracks,B,c),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:B,id:i,tracks:T.tracks})}const x=T.initPTS,O=T.timescale;Wt(x)&&(this.initPTS[f.cc]={baseTime:x,timescale:O},n.trigger(R.INIT_PTS_FOUND,{frag:f,id:i,initPTS:x,timescale:O}))}if(v&&w&&f.sn!=="initSegment"){const x=w.fragments[f.sn-1-w.startSN],O=f.sn===w.startSN,B=!x||f.cc>x.cc;if(o.independent!==!1){const{startPTS:D,endPTS:V,startDTS:$,endDTS:z}=v;if(p)p.elementaryStreams[v.type]={startPTS:D,endPTS:V,startDTS:$,endDTS:z};else if(v.firstKeyFrame&&v.independent&&c.id===1&&!B&&(this.couldBacktrack=!0),v.dropped&&v.independent){const it=this.getMainFwdBufferInfo(),at=(it?it.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:D;if(!O&&at<J-this.config.maxBufferHole&&!B){this.backtrack(f);return}else B&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,V,f.start,z,!0)}f.setElementaryStreamInfo(v.type,D,V,$,z),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,c,O||B)}else if(O||B)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:x,endPTS:O,startDTS:B,endDTS:D}=C;p&&(p.elementaryStreams[Ce.AUDIO]={startPTS:x,endPTS:O,startDTS:B,endDTS:D}),f.setElementaryStreamInfo(Ce.AUDIO,x,O,B,D),this.bufferFragmentData(C,f,p,c)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const x={id:i,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_METADATA,x)}if(w&&A){const x={id:i,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_USERDATA,x)}}_bufferInitSegment(t,e,i,n){if(this.state!==kt.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:n,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=kt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Be.isBuffered(t,i)?e=this.getAppendedFrag(i):Be.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.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&&Wt(e)&&Wt(i.programDateTime)){const n=i.programDateTime+(e-i.start)*1e3;return new Date(n)}}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 _n{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 Db{constructor(t,e,i,n=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 _n(t),this.fast_=new _n(e),this.defaultTTFB_=n,this.ttfb_=new _n(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new _n(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new _n(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new _n(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,n=t/1e3,o=i/n;this.fast_.sample(n,o),this.slow_.sample(n,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 xb{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 Db(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 n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,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,n){const o=t+i/e,c=n?this.lastLevelLoadSec:0;return o+c}onLevelLoaded(t,e){const i=this.hls.config,{total:n,bwEstimate:o}=e.stats;Wt(n)&&Wt(o)&&(this.lastLevelLoadSec=8*n/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:n,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(!n||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 E=g.len/A;if(E>=2*f/A)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:x,minAutoLevel:O}=i,B=x[t.level],D=d.total||Math.max(d.loaded,Math.round(f*B.maxBitrate/8));let V=p-T;V<1&&w&&(V=Math.min(p,d.loaded*8/C));const $=w?d.loaded*1e3/V:0,z=$?(D-d.loaded)/$:D*8/C+v/1e3;if(z<=E)return;const it=$?$*8:C;let at=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>O;J--){const wt=x[J].maxBitrate;if(at=this.getTimeToLoadFrag(v/1e3,it,f*wt,!x[J].details),at<E)break}at>=z||at>f*10||(i.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
|
189
|
+
initSegmentChange: ${it}`);const J=new Tb(i,n,e,d,g);this.configureTransmuxer(J)}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 J=E.push(t,w,p,at);Uo(J)?(E.async=!0,J.then(wt=>{this.handleTransmuxComplete(wt)}).catch(wt=>{this.transmuxerError(wt,p,"transmuxer-interface push error")})):(E.async=!1,this.handleTransmuxComplete(J))}}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);Uo(i)||e.async?(Uo(i)||(i=Promise.resolve(i)),i.then(n=>{this.handleFlushResult(n,t)}).catch(n=>{this.transmuxerError(n,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:pt.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 n;const o=(n=this.workerContext)==null?void 0:n.objectURL;o&&self.URL.revokeObjectURL(o);break}case"transmuxComplete":{this.handleTransmuxComplete(e.data);break}case"flush":{this.onFlush(e.data);break}case"workerLog":X[e.data.logType]&&X[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 Sb=250,Hc=2,Rb=.1,_b=.05;class Lb{constructor(t,e,i,n){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=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(t,e){const{config:i,media:n,stalled:o}=this;if(n===null)return;const{currentTime:c,seeking:d}=n,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;X.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(n.paused&&!d||n.ended||n.playbackRate===0||!Be.getBuffered(n).length)return;const g=Be.bufferInfo(n,c,0),v=g.len>0,A=g.nextStart||0;if(!v&&!A)return;if(d){const x=g.len>Hc,O=!A||e&&e.start<=c||A-c>Hc&&!this.fragmentTracker.getPartialFragment(c);if(x||O)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var E;const x=Math.max(A,g.start||0)-c,O=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,B=!(O==null||(E=O.details)==null)&&E.live?O.details.targetduration*2:Hc,D=this.fragmentTracker.getPartialFragment(c);if(x>0&&(x<=B||D)){this._trySkipBufferHole(D);return}}const T=self.performance.now();if(o===null){this.stalled=T;return}const w=T-o;if(!d&&w>=Sb&&(this._reportStall(g),!this.media))return;const C=Be.bufferInfo(n,c,i.maxBufferHole);this._tryFixBufferStall(C,w)}_tryFixBufferStall(t,e){const{config:i,fragmentTracker:n,media:o}=this;if(o===null)return;const c=o.currentTime,d=n.getPartialFragment(c);d&&(this._trySkipBufferHole(d)||!this.media)||(t.len>i.maxBufferHole||t.nextStart&&t.nextStart-c<i.maxBufferHole)&&e>i.highBufferWatchdogPeriod*1e3&&(X.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(t){const{hls:e,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const o=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(t)})`);X.warn(o.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,fatal:!1,error:o,buffer:t.len})}}_trySkipBufferHole(t){const{config:e,hls:i,media:n}=this;if(n===null)return 0;const o=n.currentTime,c=Be.bufferInfo(n,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&&n.readyState<3,g=d-o;if(g>0&&(f||p)){if(g>e.maxBufferHole){const{fragmentTracker:A}=this;let E=!1;if(o===0){const T=A.getAppendedFrag(0,Qt.MAIN);T&&d<T.end&&(E=!0)}if(!E){const T=t||A.getAppendedFrag(o,Qt.MAIN);if(T){let w=!1,C=T.end;for(;C<d;){const x=A.getPartialFragment(C);if(x)C+=x.duration;else{w=!0;break}}if(w)return 0}}}const v=Math.max(d+_b,o+Rb);if(X.warn(`skipping hole, adjusting currentTime from ${o} to ${v}`),this.moved=!0,this.stalled=null,n.currentTime=v,t&&!t.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${o} to ${v}`);i.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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:n}=this;if(i===null)return;const o=i.currentTime;if(this.nudgeRetry++,n<t.nudgeMaxRetry){const c=o+(n+1)*t.nudgeOffset,d=new Error(`Nudging 'currentTime' from ${o} to ${c}`);X.warn(d.message),i.currentTime=c,e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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`);X.error(c.message),e.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_STALLED_ERROR,error:c,fatal:!0})}}}const Cb=100;class Ib extends xc{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(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(Cb),this.level=-1,!this.startFragRequested){let n=i.startLevel;n===-1&&(i.config.testBandwidth&&this.levels.length>1?(n=0,this.bitrateTest=!0):n=i.nextAutoLevel),this.level=i.nextLoadLevel=n,this.loadedmetadata=!1}e>0&&t===-1&&(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e),this.state=kt.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=kt.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case kt.WAITING_LEVEL:{var t;const{levels:i,level:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o&&(!o.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(o))break;this.state=kt.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=kt.IDLE;break}break}case kt.FRAG_LOADING_WAITING_RETRY:{var e;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=kt.IDLE)}break}this.state===kt.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:i,media:n}=this,{config:o,nextLoadLevel:c}=t;if(e===null||!n&&(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 C={};this.altAudio&&(C.type="video"),this.hls.trigger(R.BUFFER_EOS,C),this.state=kt.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===kt.WAITING_LEVEL||g.live&&this.levelLastLoaded!==c){this.level=c,this.state=kt.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 E=this.backtrackFragment?this.backtrackFragment.start:f.end;let T=this.getNextFragment(E,g);if(this.couldBacktrack&&!this.fragPrevious&&T&&T.sn!=="initSegment"&&this.fragmentTracker.getState(T)!==gi.OK){var w;const C=((w=this.backtrackFragment)!=null?w:T).sn-g.startSN,x=g.fragments[C-1];x&&T.cc===x.cc&&(T=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(T&&this.isLoopLoading(T,E)){if(!T.gap){const C=this.audioOnly&&!this.altAudio?Ie.AUDIO:Ie.VIDEO,x=(C===Ie.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,C,Qt.MAIN)}T=this.getNextFragmentLoopLoading(T,g,f,Qt.MAIN,A)}T&&(T.initSegment&&!T.initSegment.data&&!this.bitrateTest&&(T=T.initSegment),this.loadFragment(T,d,E))}loadFragment(t,e,i){const n=this.fragmentTracker.getState(t);this.fragCurrent=t,n===gi.NOT_LOADED||n===gi.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 n=this.getAppendedFrag(e.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.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 kt.KEY_LOADING:case kt.FRAG_LOADING:case kt.FRAG_LOADING_WAITING_RETRY:case kt.PARSING:case kt.PARSED:this.state=kt.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 Lb(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;Wt(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,n=!1,o;e.levels.forEach(c=>{o=c.audioCodec,o&&(o.indexOf("mp4a.40.2")!==-1&&(i=!0),o.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!Wy(),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!==kt.IDLE)return;const n=i[e.level];(!n.details||n.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(n.details))&&(this.state=kt.WAITING_LEVEL)}onLevelLoaded(t,e){var i;const{levels:n}=this,o=e.level,c=e.details,d=c.totalduration;if(!n){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=n[o],p=this.fragCurrent;p&&(this.state===kt.FRAG_LOADING||this.state===kt.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===kt.WAITING_LEVEL){if(this.waitForCdnTuneIn(c))return;this.state=kt.IDLE}this.startFragRequested?c.live&&this.synchronizeToLiveEdge(c):this.setStartPosition(c,g),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,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),E=this.transmuxer=this.transmuxer||new ff(this.hls,Qt.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),T=n?n.index:-1,w=T!==-1,C=new Cc(i.level,i.sn,i.stats.chunkCount,o.byteLength,T,w),x=this.initPTS[i.cc];E.push(o,v,A,p,i,n,f.totalduration,g,C,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 n=this.hls;i&&(n.trigger(R.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(R.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const i=e.id,n=!!this.hls.audioTracks[i].url;if(n){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=n,this.tick()}onBufferCreated(t,e){const i=e.tracks;let n,o,c=!1;for(const d in i){const f=i[d];if(f.id==="main"){if(o=d,n=f,d==="video"){const p=i[d];p&&(this.videoBuffer=p.buffer)}}else c=!0}c&&n?(this.log(`Alternate track found, use ${o}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:i,part:n}=e;if(i&&i.type!==Qt.MAIN)return;if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}`),this.state===kt.PARSED&&(this.state=kt.IDLE);return}const o=n?n.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,n)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.MAIN,e);break;case pt.LEVEL_LOAD_ERROR:case pt.LEVEL_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_LEVEL&&((i=e.context)==null?void 0:i.type)===Te.LEVEL&&(this.state=kt.IDLE);break;case pt.BUFFER_FULL_ERROR:if(!e.parent||e.parent!=="main")return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}checkBuffer(){const{media:t,gapController:e}=this;if(!(!t||!e||!t.readyState)){if(this.loadedmetadata||!Be.getBuffered(t).length){const i=this.state!==kt.IDLE?this.fragCurrent:null;e.poll(this.lastCurrentTime,i)}this.lastCurrentTime=t.currentTime}}onFragLoadEmergencyAborted(){this.state=kt.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==Ie.AUDIO||this.audioOnly&&!this.altAudio){const i=(e===Ie.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 n=Be.getBuffered(t),o=(n.length?n.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:n}=this;if(!i||this.fragContextChanged(t))return;e.fragmentError=0,this.state=kt.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(),n.trigger(R.FRAG_LOADED,i),t.bitrateTest=!1})}_handleTransmuxComplete(t){var e;const i="main",{hls:n}=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:E,initSegment:T}=o,{details:w}=g,C=this.altAudio?void 0:o.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,T){if(T!=null&&T.tracks){const B=f.initSegment||f;this._bufferInitSegment(g,T.tracks,B,c),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:B,id:i,tracks:T.tracks})}const x=T.initPTS,O=T.timescale;Wt(x)&&(this.initPTS[f.cc]={baseTime:x,timescale:O},n.trigger(R.INIT_PTS_FOUND,{frag:f,id:i,initPTS:x,timescale:O}))}if(v&&w&&f.sn!=="initSegment"){const x=w.fragments[f.sn-1-w.startSN],O=f.sn===w.startSN,B=!x||f.cc>x.cc;if(o.independent!==!1){const{startPTS:D,endPTS:V,startDTS:$,endDTS:z}=v;if(p)p.elementaryStreams[v.type]={startPTS:D,endPTS:V,startDTS:$,endDTS:z};else if(v.firstKeyFrame&&v.independent&&c.id===1&&!B&&(this.couldBacktrack=!0),v.dropped&&v.independent){const it=this.getMainFwdBufferInfo(),at=(it?it.end:this.getLoadPosition())+this.config.maxBufferHole,J=v.firstKeyFramePTS?v.firstKeyFramePTS:D;if(!O&&at<J-this.config.maxBufferHole&&!B){this.backtrack(f);return}else B&&(f.gap=!0);f.setElementaryStreamInfo(v.type,f.start,V,f.start,z,!0)}f.setElementaryStreamInfo(v.type,D,V,$,z),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(v,f,p,c,O||B)}else if(O||B)f.gap=!0;else{this.backtrack(f);return}}if(C){const{startPTS:x,endPTS:O,startDTS:B,endDTS:D}=C;p&&(p.elementaryStreams[Ie.AUDIO]={startPTS:x,endPTS:O,startDTS:B,endDTS:D}),f.setElementaryStreamInfo(Ie.AUDIO,x,O,B,D),this.bufferFragmentData(C,f,p,c)}if(w&&E!=null&&(e=E.samples)!=null&&e.length){const x={id:i,frag:f,details:w,samples:E.samples};n.trigger(R.FRAG_PARSING_METADATA,x)}if(w&&A){const x={id:i,frag:f,details:w,samples:A.samples};n.trigger(R.FRAG_PARSING_USERDATA,x)}}_bufferInitSegment(t,e,i,n){if(this.state!==kt.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:n,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=kt.IDLE}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&t.seeking===!1){const i=t.currentTime;if(Be.isBuffered(t,i)?e=this.getAppendedFrag(i):Be.isBuffered(t,i+.1)&&(e=this.getAppendedFrag(i+.1)),e){this.backtrackFragment=null;const n=this.fragPlaying,o=e.level;(!n||e.sn!==n.sn||n.level!==o||e.urlId!==n.urlId)&&(this.fragPlaying=e,this.hls.trigger(R.FRAG_CHANGED,{frag:e}),(!n||n.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&&Wt(e)&&Wt(i.programDateTime)){const n=i.programDateTime+(e-i.start)*1e3;return new Date(n)}}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 Ln{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 Db{constructor(t,e,i,n=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 Ln(t),this.fast_=new Ln(e),this.defaultTTFB_=n,this.ttfb_=new Ln(t)}update(t,e){const{slow_:i,fast_:n,ttfb_:o}=this;i.halfLife!==t&&(this.slow_=new Ln(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.fast_=new Ln(e,n.getEstimate(),n.getTotalWeight())),o.halfLife!==t&&(this.ttfb_=new Ln(t,o.getEstimate(),o.getTotalWeight()))}sample(t,e){t=Math.max(t,this.minDelayMs_);const i=8*e,n=t/1e3,o=i/n;this.fast_.sample(n,o),this.slow_.sample(n,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 xb{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 Db(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 n=e.frag;this.ignoreFragment(n)||(this.fragCurrent=n,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,n){const o=t+i/e,c=n?this.lastLevelLoadSec:0;return o+c}onLevelLoaded(t,e){const i=this.hls.config,{total:n,bwEstimate:o}=e.stats;Wt(n)&&Wt(o)&&(this.lastLevelLoadSec=8*n/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:n,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(!n||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 E=g.len/A;if(E>=2*f/A)return;const T=d.loading.first?d.loading.first-d.loading.start:-1,w=d.loaded&&T>-1,C=this.bwEstimator.getEstimate(),{levels:x,minAutoLevel:O}=i,B=x[t.level],D=d.total||Math.max(d.loaded,Math.round(f*B.maxBitrate/8));let V=p-T;V<1&&w&&(V=Math.min(p,d.loaded*8/C));const $=w?d.loaded*1e3/V:0,z=$?(D-d.loaded)/$:D*8/C+v/1e3;if(z<=E)return;const it=$?$*8:C;let at=Number.POSITIVE_INFINITY,J;for(J=t.level-1;J>O;J--){const wt=x[J].maxBitrate;if(at=this.getTimeToLoadFrag(v/1e3,it,f*wt,!x[J].details),at<E)break}at>=z||at>f*10||(i.nextLoadLevel=J,w?this.bwEstimator.sample(p-Math.min(v,T),d.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),X.warn(`[abr] Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} is loading too slowly;
|
190
190
|
Time to underbuffer: ${E.toFixed(3)} s
|
191
191
|
Estimated load time for current fragment: ${z.toFixed(3)} s
|
192
192
|
Estimated load time for down switch fragment: ${at.toFixed(3)} s
|
193
193
|
TTFB estimate: ${T}
|
194
194
|
Current BW estimate: ${Wt(C)?(C/1024).toFixed(3):"Unknown"} Kb/s
|
195
195
|
New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
|
196
|
-
Aborting and switching to level ${J}`),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 n=i?i.stats:e.stats;if(e.type===Qt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.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)+n.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:n,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:n}=e,o=n!=null&&n.stats.loaded?n.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 n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:n,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 E=this.findBestLevel(g,c,n,A,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;X.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!A){const x=this.bitrateTestDelay;x&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-x,X.trace(`[abr] bitrate test took ${Math.round(1e3*x)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return E=this.findBestLevel(g,c,n,A+T,w,C),Math.max(E,0)}findBestLevel(t,e,i,n,o,c){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,A=v[g],E=!!(A!=null&&(d=A.details)!=null&&d.live),T=A==null?void 0:A.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let x=e,O=-1;for(let B=i;B>=e;B--){const D=v[B];if(!D||T&&D.codecSet!==T){D&&(x=Math.min(B,x),O=Math.max(B,O));continue}O!==-1&&X.trace(`[abr] Skipped level(s) ${x}-${O} with CODECS:"${v[O].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const V=D.details,$=(p?V==null?void 0:V.partTarget:V==null?void 0:V.averagetargetduration)||w;let z;B<=g?z=o*t:z=c*t;const it=v[B].maxBitrate,at=this.getTimeToLoadFrag(C,z,it*$,V===void 0);if(X.trace(`[abr] level:${B} adjustedbw-bitrate:${Math.round(z-it)} avgDuration:${$.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${at.toFixed(1)}`),z>it&&(at===0||!Wt(at)||E&&!this.bitrateTestDelay||at<n))return B}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class pf{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=Pb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Pb(s,t){const e=new Uint8Array(t);let i=0;for(let n=0;n<s.length;n++){const o=s[n];e.set(o,i),i+=o.length}return e}const gf=100;class Ob extends xc{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(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:n,timescale:o}){if(i==="main"){const c=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${c} found from main: ${n}`),this.videoTrackCC=c,this.state===kt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=kt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(gf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=kt.IDLE):(this.loadedmetadata=!1,this.state=kt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case kt.IDLE:this.doTickIdle();break;case kt.WAITING_TRACK:{var t;const{levels:i,trackId:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=kt.WAITING_INIT_PTS}break}case kt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=kt.IDLE);break}case kt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:o,cache:c,complete:d}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.FRAG_LOADING;const f=c.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Be.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Rc(p.end,this.config.maxFragLookUpTolerance,n)<0&&(this.log(`Waiting fragment cc (${n.cc}) @ ${n.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=kt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.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:n}=this,o=t.config;if(!(e!=null&&e[n])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const c=e[n],d=c.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=kt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Ce.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(R.BUFFER_EOS,{type:"audio"}),this.state=kt.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Qt.MAIN),E=p.len,T=this.getMaxBufferLength(A==null?void 0:A.len);if(E>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&i){const D=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=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(C,d),O=!1;if(x&&this.isLoopLoading(x,C)&&(O=!!x.gap,x=this.getNextFragmentLoopLoading(x,d,p,Qt.MAIN,T)),!x){this.bufferFlushed=!0;return}const B=A&&x.start>A.end+d.targetduration;if(B||!(A!=null&&A.len)&&p.len){const D=this.getAppendedFrag(x.start,Qt.MAIN);if(D===null||(O||(O=!!D.gap||!!B&&A.len===0),B&&!O||O&&p.nextStart&&p.nextStart<D.end))return}this.loadFragment(x,c,C)}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 Sa(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(gf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=kt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=kt.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:n}=this,{details:o,id:c}=e;if(!n){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=n[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?(j0(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===kt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=kt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,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 ff(this.hls,Qt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const E=this.initPTS[i.cc],T=(e=i.initSegment)==null?void 0:e.data;if(E!==void 0){const w=n?n.index:-1,C=w!==-1,x=new Cc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,C);A.push(o,T,v,"",i,n,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:n,cache:new pf,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=kt.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:n}=e;if(i.type!==Qt.AUDIO){if(!this.loadedmetadata&&i.type===Qt.MAIN){const o=this.videoBuffer||this.media;o&&Be.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);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,Ki({},o)))}this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.AUDIO,e);break;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===Te.AUDIO_TRACK&&(this.state=kt.IDLE);break;case pt.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 pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Ce.AUDIO&&(this.bufferFlushed=!0,this.state===kt.ENDED&&(this.state=kt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=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:E,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,c),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:w.tracks})}if(A){const{startPTS:C,endPTS:x,startDTS:O,endDTS:B}=A;p&&(p.elementaryStreams[Ce.AUDIO]={startPTS:C,endPTS:x,startDTS:O,endDTS:B}),f.setElementaryStreamInfo(Ce.AUDIO,C,x,O,B),this.bufferFragmentData(A,f,p,c)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=ci({id:i,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(E){const C=ci({id:i,frag:f,details:v},E);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,i){if(this.state!==kt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.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 n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===gi.NOT_LOADED||n===gi.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=kt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:n}=this,o=n==null?void 0:n.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,Ki({},t))}}class Mb extends Lc{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:n,details:o}=e,c=this.tracksInGroup[i];if(!c||c.groupId!==n){this.warn(`Track with id:${i} and group:${n} 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:${n} 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 n=this.tracks.filter(c=>!i||c.groupId===i);this.selectDefaultTrack&&!n.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.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===Te.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 n=e[t],{groupId:o,name:c}=n;if(this.log(`Switching to audio-track ${t} "${c}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,Ki({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.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:pt.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,n=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:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}}function mf(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!$b(s[e].attrs,t[e].attrs))return!1;return!0}function $b(s,t){const e=s["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==t[i])}const vf=500;class Fb extends xc{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(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=kt.IDLE,this.setInterval(vf),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:n}=e;if(this.fragPrevious=i,this.state=kt.IDLE,!n)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:n}=e;if(i===0&&n!==Number.POSITIVE_INFINITY){const o=n-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!==kt.STOPPED&&(this.state=kt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(mf(this.levels,e)){this.levels=e.map(i=>new Sa(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const n=new Sa(i);return this.tracksBuffered[n.id]=[],n}),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(vf)}onSubtitleTrackLoaded(t,e){var i;const{details:n,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(n.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,wc(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(j0(n,g),p=n.fragments[0].start):v&&(p=v.start,wc(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===kt.IDLE&&(Ra(null,n.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,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const c=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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=kt.IDLE})}}doTick(){if(!this.media){this.state=kt.IDLE;return}if(this.state===kt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:n}=this,o=this.getLoadPosition(),c=Be.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.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,E=A.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const x=n.maxFragLookUpTolerance,O=d>T-x?0:x;w=Ra(C,A,Math.max(A[0].start,d),O),!w&&C&&C.start<A[0].start&&(w=A[0])}else w=A[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const x=w.sn-g.startSN,O=A[x-1];O&&O.cc===w.cc&&this.fragmentTracker.getState(O)===gi.NOT_LOADED&&(w=O)}this.fragmentTracker.getState(w)===gi.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 Nb(this.tracksBuffered[this.currentTrackId]||[])}}class Nb{constructor(t){this.buffered=void 0;const e=(i,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][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 Ub extends Lc{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),Wc(this.media.textTracks).forEach(t=>{Sn(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:n}=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 [${n.startSN}-${n.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],n=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(n==null?void 0:n.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,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===Te.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,n=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:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const n=Wc(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).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 n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=n[t])!=null&&i.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[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=Wc(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 Wc(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(s[e])}return t}class Bb{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}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const{buffers:e,queues:i}=this,n=e[t],o=i[t];if(o.length){const c=o[0];try{c.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),c.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const yf=_o(),bf=/([ha]vc.)(?:\.[^.,]+)+/;class Gb{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;X.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=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&X.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 Bb(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,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&yf){const n=this.mediaSource=new yf;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.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()):X.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){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(i){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:c,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(bf,"$1"),A=(f||d).replace(bf,"$1");if(v!==A){const E=`${p};codecs=${f||d}`;this.appendChangeType(n,E),X.log(`[buffer-controller]: switching codec ${v} to ${A}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:c}}}}else this.pendingTracks[n]=e[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(n,t)}onBufferAppending(t,e){const{hls:i,operationQueue:n,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 E=f.stats.buffering,T=p?p.stats.buffering:null;E.start===0&&(E.start=A),T&&T.start===0&&(T.start=A);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const x=f.start,O={execute:()=>{if(v.executeStart=self.performance.now(),C){const B=this.sourceBuffer[d];if(B){const D=x-B.timestampOffset;Math.abs(D)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${x} (delta: ${D}) sn: ${f.sn})`),B.timestampOffset=x)}}this.appendExecutor(c,d)},onStart:()=>{},onComplete:()=>{const B=self.performance.now();v.executeEnd=v.end=B,E.first===0&&(E.first=B),T&&T.first===0&&(T.first=B);const{sourceBuffer:D}=this,V={};for(const $ in D)V[$]=Be.getBuffered(D[$]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:V})},onError:B=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,B);const D={type:qt.MEDIA_ERROR,parent:f.type,details:pt.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:B,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?D.details=pt.BUFFER_FULL_ERROR:(this.appendError++,D.details=pt.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),D.fatal=!0)),i.trigger(R.ERROR,D)}};n.append(O,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:c=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,c)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(n(o),o)})}onFragParsed(t,e){const{frag:i,part:n}=e,o=[],c=n?n.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,n&&(n.stats.buffering.end=f);const p=n?n.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};o.length===0&&X.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,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}X.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:n}=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(!Wt(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=n[v];if(A){const E=Be.getBuffered(A);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(A.ended&&E.end(E.length-1)-d<f*2){X.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:n}=this,o=t.fragments[0].start+t.totalduration,c=i.duration,d=Wt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>c||!Wt(c))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!t||n===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:pt.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 n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const c=o.levelCodec||o.codec,d=`${o.container};codecs=${c}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=i.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:c,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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`);X.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,i){const{media:n,mediaSource:o,operationQueue:c,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),c.shiftAndExecuteNext(t);return}const p=Wt(n.duration)?n.duration:1/0,g=Wt(o.duration)?o.duration:1/0,v=Math.max(0,e),A=Math.min(i,p,g);A>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${A}] from the ${t} SourceBuffer`),f.remove(v,A)):c.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:n}=this,o=n[e];if(!o){X.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){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,n=e.map(o=>i.appendBlocker(o));Promise.all(n).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 n=this.sourceBuffer[t];if(!n)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const Af={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(s){let t=s;return Af.hasOwnProperty(s)&&(t=Af[s]),String.fromCharCode(t)},Tr=15,es=100,Vb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Hb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Wb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},jb={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 zb{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${i}`)}}}const ln=function(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].toString(16));return t};class Tf{constructor(t,e,i,n,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=n||"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 n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}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 Yb{constructor(t,e,i,n,o,c){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Tf(e,i,n,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 Xb{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<es;e++)this.chars.push(new Yb);this.logger=t,this.pos=0,this.currPenState=new Tf}equals(t){let e=!0;for(let i=0;i<es;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<es;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<es;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>es&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=es)}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>=es){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<es;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<es;i++){const n=this.chars[i].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class jc{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<Tr;e++)this.rows.push(new Xb(t));this.logger=t,this.currRow=Tr-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Tr;t++)this.rows[t].clear();this.currRow=Tr-1}equals(t){let e=!0;for(let i=0;i<Tr;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Tr;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Tr;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<Tr;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 n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}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="",n=-1;for(let o=0;o<Tr;o++){const c=this.rows[o].getTextString();c&&(n=o+1,t?e.push("Row "+n+": '"+c+"'"):e.push(c.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
|
197
|
-
`)),i}getTextAndFormat(){return this.rows}}class kf{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 jc(i),this.nonDisplayedMemory=new jc(i),this.lastOutputScreen=new jc(i),this.currRollUpRow=this.displayedMemory.rows[Tr-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[Tr-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,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[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 wf{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new zb;this.channels=[null,new kf(t,e,n),new kf(t+1,i,n)],this.cmdHistory=Rf(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,n,o,c=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+ln([e[d],e[d+1]])+"] -> ("+ln([n,o])+")"),i=this.parseCmd(n,o),i||(i=this.parseMidrow(n,o)),i||(i=this.parsePAC(n,o)),i||(i=this.parseBackgroundAttributes(n,o)),!i&&(c=this.parseChars(n,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 "+ln([n,o])+" orig: "+ln([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Sf(t,e,i))return Cn(null,null,i),this.logger.log(3,"Repeated command ("+ln([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),Cn(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 n=this.channels[i];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+ln([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const n=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(Sf(t,e,n))return Cn(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?Vb[t]:Wb[t]:i=d===1?Hb[t]:jb[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),Cn(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(t,e){let i,n=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),n=[c]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const c=ln(n);this.logger.log(3,"Char codes = "+c.join(",")),Cn(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(i||n))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),Cn(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=Rf()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Cn(s,t,e){e.a=s,e.b=t}function Sf(s,t,e){return e.a===s&&e.b===t}function Rf(){return{a:null,b:null}}class Bo{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 Kc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","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(s,d)}function n(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="",E=!1,T=d,w=f,C=p,x=null,O="",B=!0,D="auto",V="start",$=50,z="middle",it=50,at="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return A},set:function(J){A=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(J){E=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return x},set:function(J){x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return O},set:function(J){const wt=i(J);if(wt===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return B},set:function(J){B=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return D},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return V},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");V=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return $},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");$=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return z},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");z=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return it},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");it=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return at},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");at=wt,this.hasBeenReset=!0}})),g.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class Zb{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Lf(s){function t(i,n,o,c){return(i|0)*3600+(n|0)*60+(o|0)+parseFloat(c||0)}const e=s.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 qb{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 n=0;n<i.length;++n)if(e===i[n]){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 _f(s,t,e,i){const n=i?s.split(i):[s];for(const o in n){if(typeof n[o]!="string")continue;const c=n[o].split(e);if(c.length!==2)continue;const d=c[0],f=c[1];t(d,f)}}const zc=new Kc(0,0,""),Go=zc.align==="middle"?"middle":"center";function Qb(s,t,e){const i=s;function n(){const d=Lf(s);if(d===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new qb;_f(d,function(A,E){let T;switch(A){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(A,e[w].region);break}break;case"vertical":p.alt(A,E,["rl","lr"]);break;case"line":T=E.split(","),p.integer(A,T[0]),p.percent(A,T[0])&&p.set("snapToLines",!1),p.alt(A,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",Go,"end"]);break;case"position":T=E.split(","),p.percent(A,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",Go,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,E);break;case"align":p.alt(A,E,["start",Go,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&zc.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",Go);let v=p.get("position","auto");v==="auto"&&zc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function c(){s=s.replace(/^\s+/,"")}if(c(),t.startTime=n(),c(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),c(),t.endTime=n(),c(),o(s,t)}function Cf(s){return s.replace(/<br(?: \/)?>/gi,`
|
196
|
+
Aborting and switching to level ${J}`),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 n=i?i.stats:e.stats;if(e.type===Qt.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.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)+n.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:n,frag:e,part:i,id:e.type};this.onFragBuffered(R.FRAG_BUFFERED,o),e.bitrateTest=!1}}}onFragBuffered(t,e){const{frag:i,part:n}=e,o=n!=null&&n.stats.loaded?n.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 n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return t!==-1&&(i=Math.min(t,i)),i}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:i}=this,{maxAutoLevel:n,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 E=this.findBestLevel(g,c,n,A,o.abrBandWidthFactor,o.abrBandWidthUpFactor);if(E>=0)return E;X.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let T=f?Math.min(f,o.maxStarvationDelay):o.maxStarvationDelay,w=o.abrBandWidthFactor,C=o.abrBandWidthUpFactor;if(!A){const x=this.bitrateTestDelay;x&&(T=(f?Math.min(f,o.maxLoadingDelay):o.maxLoadingDelay)-x,X.trace(`[abr] bitrate test took ${Math.round(1e3*x)}ms, set first fragment max fetchDuration to ${Math.round(1e3*T)} ms`),w=C=1)}return E=this.findBestLevel(g,c,n,A+T,w,C),Math.max(E,0)}findBestLevel(t,e,i,n,o,c){var d;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:g}=this,{levels:v}=this.hls,A=v[g],E=!!(A!=null&&(d=A.details)!=null&&d.live),T=A==null?void 0:A.codecSet,w=p?p.duration:f?f.duration:0,C=this.bwEstimator.getEstimateTTFB()/1e3;let x=e,O=-1;for(let B=i;B>=e;B--){const D=v[B];if(!D||T&&D.codecSet!==T){D&&(x=Math.min(B,x),O=Math.max(B,O));continue}O!==-1&&X.trace(`[abr] Skipped level(s) ${x}-${O} with CODECS:"${v[O].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const V=D.details,$=(p?V==null?void 0:V.partTarget:V==null?void 0:V.averagetargetduration)||w;let z;B<=g?z=o*t:z=c*t;const it=v[B].maxBitrate,at=this.getTimeToLoadFrag(C,z,it*$,V===void 0);if(X.trace(`[abr] level:${B} adjustedbw-bitrate:${Math.round(z-it)} avgDuration:${$.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${at.toFixed(1)}`),z>it&&(at===0||!Wt(at)||E&&!this.bitrateTestDelay||at<n))return B}return-1}set nextAutoLevel(t){this._nextAutoLevel=t}}class pf{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=Pb(t,e);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function Pb(s,t){const e=new Uint8Array(t);let i=0;for(let n=0;n<s.length;n++){const o=s[n];e.set(o,i),i+=o.length}return e}const gf=100;class Ob extends xc{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(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:n,timescale:o}){if(i==="main"){const c=e.cc;this.initPTS[e.cc]={baseTime:n,timescale:o},this.log(`InitPTS for cc: ${c} found from main: ${n}`),this.videoTrackCC=c,this.state===kt.WAITING_INIT_PTS&&this.tick()}}startLoad(t){if(!this.levels){this.startPosition=t,this.state=kt.STOPPED;return}const e=this.lastCurrentTime;this.stopLoad(),this.setInterval(gf),e>0&&t===-1?(this.log(`Override startPosition with lastCurrentTime @${e.toFixed(3)}`),t=e,this.state=kt.IDLE):(this.loadedmetadata=!1,this.state=kt.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}doTick(){switch(this.state){case kt.IDLE:this.doTickIdle();break;case kt.WAITING_TRACK:{var t;const{levels:i,trackId:n}=this,o=i==null||(t=i[n])==null?void 0:t.details;if(o){if(this.waitForCdnTuneIn(o))break;this.state=kt.WAITING_INIT_PTS}break}case kt.FRAG_LOADING_WAITING_RETRY:{var e;const i=performance.now(),n=this.retryDate;(!n||i>=n||(e=this.media)!=null&&e.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=kt.IDLE);break}case kt.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:o,cache:c,complete:d}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.FRAG_LOADING;const f=c.flush(),p={frag:n,part:o,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),d&&super._handleFragmentLoadComplete(p)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${n.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const f=this.getLoadPosition(),p=Be.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Rc(p.end,this.config.maxFragLookUpTolerance,n)<0&&(this.log(`Waiting fragment cc (${n.cc}) @ ${n.start} cancelled because another fragment at ${p.end} is needed`),this.clearWaitingFragment())}}else this.state=kt.IDLE}}this.onTickEnd()}clearWaitingFragment(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=kt.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:n}=this,o=t.config;if(!(e!=null&&e[n])||!i&&(this.startFragRequested||!o.startFragPrefetch))return;const c=e[n],d=c.details;if(!d||d.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(d)){this.state=kt.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Ie.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(R.BUFFER_EOS,{type:"audio"}),this.state=kt.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,Qt.MAIN),E=p.len,T=this.getMaxBufferLength(A==null?void 0:A.len);if(E>=T&&!v)return;const w=d.fragments[0].start;let C=p.end;if(v&&i){const D=this.getLoadPosition();g&&v.attrs!==g.attrs&&(C=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(C,d),O=!1;if(x&&this.isLoopLoading(x,C)&&(O=!!x.gap,x=this.getNextFragmentLoopLoading(x,d,p,Qt.MAIN,T)),!x){this.bufferFlushed=!0;return}const B=A&&x.start>A.end+d.targetduration;if(B||!(A!=null&&A.len)&&p.len){const D=this.getAppendedFrag(x.start,Qt.MAIN);if(D===null||(O||(O=!!D.gap||!!B&&A.len===0),B&&!O||O&&p.nextStart&&p.nextStart<D.end))return}this.loadFragment(x,c,C)}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 Sa(i))}onAudioTrackSwitching(t,e){const i=!!e.url;this.trackId=e.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(gf):this.resetTransmuxer(),i?(this.switchingTrack=e,this.state=kt.IDLE):(this.switchingTrack=null,this.bufferedTrack=e,this.state=kt.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:n}=this,{details:o,id:c}=e;if(!n){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=n[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?(j0(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===kt.WAITING_TRACK&&!this.waitForCdnTuneIn(o)&&(this.state=kt.IDLE),this.tick()}_handleFragmentLoadProgress(t){var e;const{frag:i,part:n,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 ff(this.hls,Qt.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const E=this.initPTS[i.cc],T=(e=i.initSegment)==null?void 0:e.data;if(E!==void 0){const w=n?n.index:-1,C=w!==-1,x=new Cc(i.level,i.sn,i.stats.chunkCount,o.byteLength,w,C);A.push(o,T,v,"",i,n,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:n,cache:new pf,complete:!1};w.push(new Uint8Array(o)),this.waitingVideoCC=this.videoTrackCC,this.state=kt.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:n}=e;if(i.type!==Qt.AUDIO){if(!this.loadedmetadata&&i.type===Qt.MAIN){const o=this.videoBuffer||this.media;o&&Be.getBuffered(o).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(i)){this.warn(`Fragment ${i.sn}${n?" p: "+n.index:""} of level ${i.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);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,Ki({},o)))}this.fragBufferedComplete(i,n)}onError(t,e){var i;if(e.fatal){this.state=kt.ERROR;return}switch(e.details){case pt.FRAG_GAP:case pt.FRAG_PARSING_ERROR:case pt.FRAG_DECRYPT_ERROR:case pt.FRAG_LOAD_ERROR:case pt.FRAG_LOAD_TIMEOUT:case pt.KEY_LOAD_ERROR:case pt.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Qt.AUDIO,e);break;case pt.AUDIO_TRACK_LOAD_ERROR:case pt.AUDIO_TRACK_LOAD_TIMEOUT:case pt.LEVEL_PARSING_ERROR:!e.levelRetry&&this.state===kt.WAITING_TRACK&&((i=e.context)==null?void 0:i.type)===Te.AUDIO_TRACK&&(this.state=kt.IDLE);break;case pt.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 pt.INTERNAL_EXCEPTION:this.recoverWorkerError(e);break}}onBufferFlushed(t,{type:e}){e===Ie.AUDIO&&(this.bufferFlushed=!0,this.state===kt.ENDED&&(this.state=kt.IDLE))}_handleTransmuxComplete(t){var e;const i="audio",{hls:n}=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:E,id3:T,initSegment:w}=o;if(this.fragContextChanged(f)||!v){this.fragmentTracker.removeFragment(f);return}if(this.state=kt.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),w!=null&&w.tracks){const C=f.initSegment||f;this._bufferInitSegment(w.tracks,C,c),n.trigger(R.FRAG_PARSING_INIT_SEGMENT,{frag:C,id:i,tracks:w.tracks})}if(A){const{startPTS:C,endPTS:x,startDTS:O,endDTS:B}=A;p&&(p.elementaryStreams[Ie.AUDIO]={startPTS:C,endPTS:x,startDTS:O,endDTS:B}),f.setElementaryStreamInfo(Ie.AUDIO,C,x,O,B),this.bufferFragmentData(A,f,p,c)}if(T!=null&&(e=T.samples)!=null&&e.length){const C=hi({id:i,frag:f,details:v},T);n.trigger(R.FRAG_PARSING_METADATA,C)}if(E){const C=hi({id:i,frag:f,details:v},E);n.trigger(R.FRAG_PARSING_USERDATA,C)}}_bufferInitSegment(t,e,i){if(this.state!==kt.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(R.BUFFER_CODECS,t);const o=n.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 n=this.fragmentTracker.getState(t);if(this.fragCurrent=t,this.switchingTrack||n===gi.NOT_LOADED||n===gi.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=kt.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(t,e,i))}else this.clearTrackerIfNeeded(t)}completeAudioSwitch(t){const{hls:e,media:i,bufferedTrack:n}=this,o=n==null?void 0:n.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,Ki({},t))}}class Mb extends _c{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:n,details:o}=e,c=this.tracksInGroup[i];if(!c||c.groupId!==n){this.warn(`Track with id:${i} and group:${n} 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:${n} 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 n=this.tracks.filter(c=>!i||c.groupId===i);this.selectDefaultTrack&&!n.some(c=>c.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const o={audioTracks:n};this.log(`Updating audio tracks, ${n.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===Te.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 n=e[t],{groupId:o,name:c}=n;if(this.log(`Switching to audio-track ${t} "${c}" lang:${n.lang} group:${o}`),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(R.AUDIO_TRACK_SWITCHING,Ki({},n)),n.details&&!n.details.live)return;const d=this.switchParams(n.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:pt.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t.attrs["STABLE-RENDITION-ID"]!==void 0&&t.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||t.name===n.name&&t.lang===n.lang))return n.id}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(e)){const i=e.id,n=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:${n}`),this.clearTimer(),this.hls.trigger(R.AUDIO_TRACK_LOADING,{url:o,id:i,groupId:n,deliveryDirectives:t||null})}}}function mf(s,t){if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(!$b(s[e].attrs,t[e].attrs))return!1;return!0}function $b(s,t){const e=s["STABLE-RENDITION-ID"];return e?e===t["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>s[i]!==t[i])}const vf=500;class Fb extends xc{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(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=kt.IDLE,this.setInterval(vf),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:n}=e;if(this.fragPrevious=i,this.state=kt.IDLE,!n)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:n}=e;if(i===0&&n!==Number.POSITIVE_INFINITY){const o=n-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!==kt.STOPPED&&(this.state=kt.IDLE))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){if(mf(this.levels,e)){this.levels=e.map(i=>new Sa(i));return}this.tracksBuffered=[],this.levels=e.map(i=>{const n=new Sa(i);return this.tracksBuffered[n.id]=[],n}),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(vf)}onSubtitleTrackLoaded(t,e){var i;const{details:n,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(n.live||(i=f.details)!=null&&i.live){const g=this.mainDetails;if(n.deltaUpdateFailed||!g)return;const v=g.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&v&&(p=v.start,wc(n,p))):n.hasProgramDateTime&&g.hasProgramDateTime?(j0(n,g),p=n.fragments[0].start):v&&(p=v.start,wc(n,p))}f.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===kt.IDLE&&(Ra(null,n.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,n=e.decryptdata,o=this.hls;if(!this.fragContextChanged(e)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const c=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(d=>{throw o.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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=kt.IDLE})}}doTick(){if(!this.media){this.state=kt.IDLE;return}if(this.state===kt.IDLE){const{currentTrackId:t,levels:e}=this,i=e[t];if(!e.length||!i||!i.details)return;const{config:n}=this,o=this.getLoadPosition(),c=Be.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],o,n.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,E=A.length,T=g.edge;let w=null;const C=this.fragPrevious;if(d<T){const x=n.maxFragLookUpTolerance,O=d>T-x?0:x;w=Ra(C,A,Math.max(A[0].start,d),O),!w&&C&&C.start<A[0].start&&(w=A[0])}else w=A[E-1];if(!w)return;if(w=this.mapToInitFragWhenRequired(w),w.sn!=="initSegment"){const x=w.sn-g.startSN,O=A[x-1];O&&O.cc===w.cc&&this.fragmentTracker.getState(O)===gi.NOT_LOADED&&(w=O)}this.fragmentTracker.getState(w)===gi.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 Nb(this.tracksBuffered[this.currentTrackId]||[])}}class Nb{constructor(t){this.buffered=void 0;const e=(i,n,o)=>{if(n=n>>>0,n>o-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${o})`);return t[n][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 Ub extends _c{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),Wc(this.media.textTracks).forEach(t=>{Sn(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:n}=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 [${n.startSN}-${n.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],n=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(n==null?void 0:n.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,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(t){const e=this.tracksInGroup;for(let i=0;i<e.length;i++){const n=e[i];if((!this.selectDefaultTrack||n.default)&&(!t||t===n.name))return n.id}return-1}onError(t,e){e.fatal||!e.context||e.context.type===Te.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,n=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:n,deliveryDirectives:t||null})}}toggleTrackModes(t){const{media:e,trackId:i}=this;if(!e)return;const n=Wc(e.textTracks),o=n.filter(d=>d.groupId===this.groupId);if(t===-1)[].slice.call(n).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 n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=t;return}if(this.trackId!==t&&this.toggleTrackModes(t),this.trackId===t&&(t===-1||(i=n[t])!=null&&i.details)||t<-1||t>=n.length)return;this.clearTimer();const o=n[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=Wc(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 Wc(s){const t=[];for(let e=0;e<s.length;e++){const i=s[e];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&t.push(s[e])}return t}class Bb{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}),n={execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,t),i}executeNext(t){const{buffers:e,queues:i}=this,n=e[t],o=i[t];if(o.length){const c=o[0];try{c.execute()}catch(d){X.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),c.onError(d),n!=null&&n.updating||(o.shift(),this.executeNext(t))}}}shiftAndExecuteNext(t){this.queues[t].shift(),this.executeNext(t)}current(t){return this.queues[t][0]}}const yf=Lo(),bf=/([ha]vc.)(?:\.[^.,]+)+/;class Gb{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;X.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=()=>{X.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{X.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:i}=this;e&&e.src!==i&&X.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 Bb(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,X.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(t,e){const i=this.media=e.media;if(i&&yf){const n=this.mediaSource=new yf;n.addEventListener("sourceopen",this._onMediaSourceOpen),n.addEventListener("sourceended",this._onMediaSourceEnded),n.addEventListener("sourceclose",this._onMediaSourceClose),i.src=self.URL.createObjectURL(n),this._objectUrl=i.src,i.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:t,mediaSource:e,_objectUrl:i}=this;if(e){if(X.log("[buffer-controller]: media source detaching"),e.readyState==="open")try{e.endOfStream()}catch(n){X.warn(`[buffer-controller]: onMediaDetaching: ${n.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()):X.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){X.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(t,e){const i=this.getSourceBufferTypes().length;Object.keys(e).forEach(n=>{if(i){const o=this.tracks[n];if(o&&typeof o.buffer.changeType=="function"){const{id:c,codec:d,levelCodec:f,container:p,metadata:g}=e[n],v=(o.levelCodec||o.codec).replace(bf,"$1"),A=(f||d).replace(bf,"$1");if(v!==A){const E=`${p};codecs=${f||d}`;this.appendChangeType(n,E),X.log(`[buffer-controller]: switching codec ${v} to ${A}`),this.tracks[n]={buffer:o.buffer,codec:d,container:p,levelCodec:f,metadata:g,id:c}}}}else this.pendingTracks[n]=e[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(t,e){const{operationQueue:i}=this,n={execute:()=>{const o=this.sourceBuffer[t];o&&(X.log(`[buffer-controller]: changing ${t} sourceBuffer type to ${e}`),o.changeType(e)),i.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:o=>{X.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,o)}};i.append(n,t)}onBufferAppending(t,e){const{hls:i,operationQueue:n,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 E=f.stats.buffering,T=p?p.stats.buffering:null;E.start===0&&(E.start=A),T&&T.start===0&&(T.start=A);const w=o.audio;let C=!1;d==="audio"&&(w==null?void 0:w.container)==="audio/mpeg"&&(C=!this.lastMpegAudioChunk||g.id===1||this.lastMpegAudioChunk.sn!==g.sn,this.lastMpegAudioChunk=g);const x=f.start,O={execute:()=>{if(v.executeStart=self.performance.now(),C){const B=this.sourceBuffer[d];if(B){const D=x-B.timestampOffset;Math.abs(D)>=.1&&(X.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${x} (delta: ${D}) sn: ${f.sn})`),B.timestampOffset=x)}}this.appendExecutor(c,d)},onStart:()=>{},onComplete:()=>{const B=self.performance.now();v.executeEnd=v.end=B,E.first===0&&(E.first=B),T&&T.first===0&&(T.first=B);const{sourceBuffer:D}=this,V={};for(const $ in D)V[$]=Be.getBuffered(D[$]);this.appendError=0,this.hls.trigger(R.BUFFER_APPENDED,{type:d,frag:f,part:p,chunkMeta:g,parent:f.type,timeRanges:V})},onError:B=>{X.error(`[buffer-controller]: Error encountered while trying to append to the ${d} SourceBuffer`,B);const D={type:qt.MEDIA_ERROR,parent:f.type,details:pt.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:g,error:B,err:B,fatal:!1};B.code===DOMException.QUOTA_EXCEEDED_ERR?D.details=pt.BUFFER_FULL_ERROR:(this.appendError++,D.details=pt.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(X.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),D.fatal=!0)),i.trigger(R.ERROR,D)}};n.append(O,d)}onBufferFlushing(t,e){const{operationQueue:i}=this,n=o=>({execute:this.removeExecutor.bind(this,o,e.startOffset,e.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(R.BUFFER_FLUSHED,{type:o})},onError:c=>{X.warn(`[buffer-controller]: Failed to remove from ${o} SourceBuffer`,c)}});e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach(o=>{i.append(n(o),o)})}onFragParsed(t,e){const{frag:i,part:n}=e,o=[],c=n?n.elementaryStreams:i.elementaryStreams;c[Ie.AUDIOVIDEO]?o.push("audiovideo"):(c[Ie.AUDIO]&&o.push("audio"),c[Ie.VIDEO]&&o.push("video"));const d=()=>{const f=self.performance.now();i.stats.buffering.end=f,n&&(n.stats.buffering.end=f);const p=n?n.stats:i.stats;this.hls.trigger(R.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};o.length===0&&X.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,n)=>{const o=this.sourceBuffer[n];return o&&(!e.type||e.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,X.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),i&&!!(!o||o.ended)},!0)&&(X.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:i}=this;if(!i||i.readyState!=="open"){i&&X.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${i.readyState}`);return}X.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:n}=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(!Wt(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=n[v];if(A){const E=Be.getBuffered(A);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(A.ended&&E.end(E.length-1)-d<f*2){X.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:n}=this,o=t.fragments[0].start+t.totalduration,c=i.duration,d=Wt(n.duration)?n.duration:0;t.live&&e.config.liveDurationInfinity?(X.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(o>d&&o>c||!Wt(c))&&(X.log(`[buffer-controller]: Updating Media Source duration to ${o.toFixed(3)}`),n.duration=o)}updateSeekableRange(t){const e=this.mediaSource,i=t.fragments;if(i.length&&t.live&&e!=null&&e.setLiveSeekableRange){const n=Math.max(0,i[0].start),o=Math.max(n,n+t.totalduration);e.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:t,operationQueue:e,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!t||n===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:pt.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 n in t)if(!e[n]){const o=t[n];if(!o)throw Error(`source buffer exists for track ${n}, however track does not`);const c=o.levelCodec||o.codec,d=`${o.container};codecs=${c}`;X.log(`[buffer-controller]: creating sourceBuffer(${d})`);try{const f=e[n]=i.addSourceBuffer(d),p=n;this.addBufferListener(p,"updatestart",this._onSBUpdateStart),this.addBufferListener(p,"updateend",this._onSBUpdateEnd),this.addBufferListener(p,"error",this._onSBUpdateError),this.tracks[n]={buffer:f,codec:c,container:o.container,levelCodec:o.levelCodec,metadata:o.metadata,id:o.id}}catch(f){X.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.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`);X.error(`[buffer-controller]: ${i}`,e),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:pt.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(t);n&&n.onError(e)}removeExecutor(t,e,i){const{media:n,mediaSource:o,operationQueue:c,sourceBuffer:d}=this,f=d[t];if(!n||!o||!f){X.warn(`[buffer-controller]: Attempting to remove from the ${t} SourceBuffer, but it does not exist`),c.shiftAndExecuteNext(t);return}const p=Wt(n.duration)?n.duration:1/0,g=Wt(o.duration)?o.duration:1/0,v=Math.max(0,e),A=Math.min(i,p,g);A>v&&!f.ending?(f.ended=!1,X.log(`[buffer-controller]: Removing [${v},${A}] from the ${t} SourceBuffer`),f.remove(v,A)):c.shiftAndExecuteNext(t)}appendExecutor(t,e){const{operationQueue:i,sourceBuffer:n}=this,o=n[e];if(!o){X.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){X.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);return}const{operationQueue:i}=this,n=e.map(o=>i.appendBlocker(o));Promise.all(n).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 n=this.sourceBuffer[t];if(!n)return;const o=i.bind(this,t);this.listeners[t].push({event:e,listener:o}),n.addEventListener(e,o)}removeBufferListeners(t){const e=this.sourceBuffer[t];e&&this.listeners[t].forEach(i=>{e.removeEventListener(i.event,i.listener)})}}const Af={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(s){let t=s;return Af.hasOwnProperty(s)&&(t=Af[s]),String.fromCharCode(t)},Tr=15,is=100,Vb={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Hb={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Wb={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},jb={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 zb{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const i=typeof e=="function"?e():e;X.log(`${this.time} [${t}] ${i}`)}}}const ln=function(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].toString(16));return t};class Tf{constructor(t,e,i,n,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=n||"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 n=e[i];t.hasOwnProperty(n)&&(this[n]=t[n])}}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 Yb{constructor(t,e,i,n,o,c){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new Tf(e,i,n,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 Xb{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<is;e++)this.chars.push(new Yb);this.logger=t,this.pos=0,this.currPenState=new Tf}equals(t){let e=!0;for(let i=0;i<is;i++)if(!this.chars[i].equals(t.chars[i])){e=!1;break}return e}copy(t){for(let e=0;e<is;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<is;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>is&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=is)}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>=is){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<is;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<is;i++){const n=this.chars[i].uchar;n!==" "&&(e=!1),t.push(n)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class jc{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<Tr;e++)this.rows.push(new Xb(t));this.logger=t,this.currRow=Tr-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let t=0;t<Tr;t++)this.rows[t].clear();this.currRow=Tr-1}equals(t){let e=!0;for(let i=0;i<Tr;i++)if(!this.rows[i].equals(t.rows[i])){e=!1;break}return e}copy(t){for(let e=0;e<Tr;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Tr;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<Tr;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 n={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(n)}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="",n=-1;for(let o=0;o<Tr;o++){const c=this.rows[o].getTextString();c&&(n=o+1,t?e.push("Row "+n+": '"+c+"'"):e.push(c.trim()))}return e.length>0&&(t?i="["+e.join(" | ")+"]":i=e.join(`
|
197
|
+
`)),i}getTextAndFormat(){return this.rows}}class kf{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 jc(i),this.nonDisplayedMemory=new jc(i),this.lastOutputScreen=new jc(i),this.currRollUpRow=this.displayedMemory.rows[Tr-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[Tr-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,n=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=n[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 wf{constructor(t,e,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new zb;this.channels=[null,new kf(t,e,n),new kf(t+1,i,n)],this.cmdHistory=Rf(),this.logger=n}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){let i,n,o,c=!1;this.logger.time=t;for(let d=0;d<e.length;d+=2)if(n=e[d]&127,o=e[d+1]&127,!(n===0&&o===0)){if(this.logger.log(3,"["+ln([e[d],e[d+1]])+"] -> ("+ln([n,o])+")"),i=this.parseCmd(n,o),i||(i=this.parseMidrow(n,o)),i||(i=this.parsePAC(n,o)),i||(i=this.parseBackgroundAttributes(n,o)),!i&&(c=this.parseChars(n,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 "+ln([n,o])+" orig: "+ln([e[d],e[d+1]]))}}parseCmd(t,e){const{cmdHistory:i}=this,n=(t===20||t===28||t===21||t===29)&&e>=32&&e<=47,o=(t===23||t===31)&&e>=33&&e<=35;if(!(n||o))return!1;if(Sf(t,e,i))return Cn(null,null,i),this.logger.log(3,"Repeated command ("+ln([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),Cn(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 n=this.channels[i];return n?(n.ccMIDROW(e),this.logger.log(3,"MIDROW ("+ln([t,e])+")"),!0):!1}return!1}parsePAC(t,e){let i;const n=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(Sf(t,e,n))return Cn(null,null,n),!0;const d=t<=23?1:2;e>=64&&e<=95?i=d===1?Vb[t]:Wb[t]:i=d===1?Hb[t]:jb[t];const f=this.channels[d];return f?(f.setPAC(this.interpretPAC(i,e)),Cn(t,e,n),this.currentChannel=d,!0):!1}interpretPAC(t,e){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:t};return e>95?i=e-96:i=e-64,n.underline=(i&1)===1,i<=13?n.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(i/2)]:i<=15?(n.italics=!0,n.color="white"):n.indent=Math.floor((i-16)/2)*4,n}parseChars(t,e){let i,n=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),n=[c]}else t>=32&&t<=127&&(n=e===0?[t]:[t,e]);if(n){const c=ln(n);this.logger.log(3,"Char codes = "+c.join(",")),Cn(t,e,this.cmdHistory)}return n}parseBackgroundAttributes(t,e){const i=(t===16||t===24)&&e>=32&&e<=47,n=(t===23||t===31)&&e>=45&&e<=47;if(!(i||n))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),Cn(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=Rf()}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const i=this.channels[e];i&&i.cueSplitAtTime(t)}}}function Cn(s,t,e){e.a=s,e.b=t}function Sf(s,t,e){return e.a===s&&e.b===t}function Rf(){return{a:null,b:null}}class Bo{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 Kc=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const s=["","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(s,d)}function n(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="",E=!1,T=d,w=f,C=p,x=null,O="",B=!0,D="auto",V="start",$=50,z="middle",it=50,at="middle";Object.defineProperty(g,"id",o({},v,{get:function(){return A},set:function(J){A=""+J}})),Object.defineProperty(g,"pauseOnExit",o({},v,{get:function(){return E},set:function(J){E=!!J}})),Object.defineProperty(g,"startTime",o({},v,{get:function(){return T},set:function(J){if(typeof J!="number")throw new TypeError("Start time must be set to a number.");T=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"endTime",o({},v,{get:function(){return w},set:function(J){if(typeof J!="number")throw new TypeError("End time must be set to a number.");w=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"text",o({},v,{get:function(){return C},set:function(J){C=""+J,this.hasBeenReset=!0}})),Object.defineProperty(g,"region",o({},v,{get:function(){return x},set:function(J){x=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"vertical",o({},v,{get:function(){return O},set:function(J){const wt=i(J);if(wt===!1)throw new SyntaxError("An invalid or illegal string was specified.");O=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"snapToLines",o({},v,{get:function(){return B},set:function(J){B=!!J,this.hasBeenReset=!0}})),Object.defineProperty(g,"line",o({},v,{get:function(){return D},set:function(J){if(typeof J!="number"&&J!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");D=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"lineAlign",o({},v,{get:function(){return V},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");V=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"position",o({},v,{get:function(){return $},set:function(J){if(J<0||J>100)throw new Error("Position must be between 0 and 100.");$=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"positionAlign",o({},v,{get:function(){return z},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");z=wt,this.hasBeenReset=!0}})),Object.defineProperty(g,"size",o({},v,{get:function(){return it},set:function(J){if(J<0||J>100)throw new Error("Size must be between 0 and 100.");it=J,this.hasBeenReset=!0}})),Object.defineProperty(g,"align",o({},v,{get:function(){return at},set:function(J){const wt=n(J);if(!wt)throw new SyntaxError("An invalid or illegal string was specified.");at=wt,this.hasBeenReset=!0}})),g.displayState=void 0}return c.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},c}();class Zb{decode(t,e){if(!t)return"";if(typeof t!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function _f(s){function t(i,n,o,c){return(i|0)*3600+(n|0)*60+(o|0)+parseFloat(c||0)}const e=s.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 qb{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 n=0;n<i.length;++n)if(e===i[n]){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 Lf(s,t,e,i){const n=i?s.split(i):[s];for(const o in n){if(typeof n[o]!="string")continue;const c=n[o].split(e);if(c.length!==2)continue;const d=c[0],f=c[1];t(d,f)}}const zc=new Kc(0,0,""),Go=zc.align==="middle"?"middle":"center";function Qb(s,t,e){const i=s;function n(){const d=_f(s);if(d===null)throw new Error("Malformed timestamp: "+i);return s=s.replace(/^[^\sa-zA-Z-]+/,""),d}function o(d,f){const p=new qb;Lf(d,function(A,E){let T;switch(A){case"region":for(let w=e.length-1;w>=0;w--)if(e[w].id===E){p.set(A,e[w].region);break}break;case"vertical":p.alt(A,E,["rl","lr"]);break;case"line":T=E.split(","),p.integer(A,T[0]),p.percent(A,T[0])&&p.set("snapToLines",!1),p.alt(A,T[0],["auto"]),T.length===2&&p.alt("lineAlign",T[1],["start",Go,"end"]);break;case"position":T=E.split(","),p.percent(A,T[0]),T.length===2&&p.alt("positionAlign",T[1],["start",Go,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,E);break;case"align":p.alt(A,E,["start",Go,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let g=p.get("line","auto");g==="auto"&&zc.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",Go);let v=p.get("position","auto");v==="auto"&&zc.position===50&&(v=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=v}function c(){s=s.replace(/^\s+/,"")}if(c(),t.startTime=n(),c(),s.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);s=s.slice(3),c(),t.endTime=n(),c(),o(s,t)}function Cf(s){return s.replace(/<br(?: \/)?>/gi,`
|
198
198
|
`)}class Jb{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Zb,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=Cf(o);c<o.length&&o[c]!=="\r"&&o[c]!==`
|
199
199
|
`;)++c;const d=o.slice(0,c);return o[c]==="\r"&&++c,o[c]===`
|
200
|
-
`&&++c,e.buffer=o.slice(c),d}function n(o){
|
200
|
+
`&&++c,e.buffer=o.slice(c),d}function n(o){Lf(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)?n(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 Kc(0,0,""),e.state="CUE",o.indexOf("-->")===-1){e.cue.id=o;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{Qb(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+=`
|
201
201
|
`),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+=`
|
202
202
|
|
203
|
-
`,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 t4=/\r\n|\n\r|\n|\r/g,Yc=function(s,t,e=0){return s.slice(e,e+t.length)===t},e4=function(s){let t=parseInt(s.slice(-3));const e=parseInt(s.slice(-6,-4)),i=parseInt(s.slice(-9,-7)),n=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Wt(t)||!Wt(e)||!Wt(i)||!Wt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${s}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*n,t},Xc=function(s){let t=5381,e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return(t>>>0).toString()};function Zc(s,t,e){return Xc(s.toString())+Xc(t.toString())+Xc(e)}const i4=function(s,t,e){let i=s[t],n=s[i.prevCC];if(!n||!n.new&&i.new){s.ccOffset=s.presentationOffset=i.start,i.new=!1;return}for(;(o=n)!=null&&o.new;){var o;s.ccOffset+=i.start-n.start,i.new=!1,i=n,n=s[i.prevCC]}s.presentationOffset=e};function r4(s,t,e,i,n,o,c){const d=new Jb,f=
|
203
|
+
`,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 t4=/\r\n|\n\r|\n|\r/g,Yc=function(s,t,e=0){return s.slice(e,e+t.length)===t},e4=function(s){let t=parseInt(s.slice(-3));const e=parseInt(s.slice(-6,-4)),i=parseInt(s.slice(-9,-7)),n=s.length>9?parseInt(s.substring(0,s.indexOf(":"))):0;if(!Wt(t)||!Wt(e)||!Wt(i)||!Wt(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${s}`);return t+=1e3*e,t+=60*1e3*i,t+=60*60*1e3*n,t},Xc=function(s){let t=5381,e=s.length;for(;e;)t=t*33^s.charCodeAt(--e);return(t>>>0).toString()};function Zc(s,t,e){return Xc(s.toString())+Xc(t.toString())+Xc(e)}const i4=function(s,t,e){let i=s[t],n=s[i.prevCC];if(!n||!n.new&&i.new){s.ccOffset=s.presentationOffset=i.start,i.new=!1;return}for(;(o=n)!=null&&o.new;){var o;s.ccOffset+=i.start-n.start,i.new=!1,i=n,n=s[i.prevCC]}s.presentationOffset=e};function r4(s,t,e,i,n,o,c){const d=new Jb,f=Or(new Uint8Array(s)).trim().replace(t4,`
|
204
204
|
`).split(`
|
205
205
|
`),p=[],g=t?pb(t.baseTime,t.timescale):0;let v="00:00.000",A=0,E=0,T,w=!0;d.oncue=function(C){const x=e[i];let O=e.ccOffset;const B=(A-g)/9e4;if(x!=null&&x.new&&(E!==void 0?O=e.ccOffset=x.start:i4(e,i,B)),B){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}O=B-e.presentationOffset}const D=C.endTime-C.startTime,V=dr((C.startTime+O-E)*9e4,n*9e4)/9e4;C.startTime=Math.max(V,0),C.endTime=Math.max(V+D,0);const $=C.text.trim();C.text=decodeURIComponent(encodeURIComponent($)),C.id||(C.id=Zc(C.startTime,C.endTime,$)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){c(T);return}o(p)},f.forEach(C=>{if(w)if(Yc(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(x=>{Yc(x,"LOCAL:")?v=x.slice(6):Yc(x,"MPEGTS:")&&(A=parseInt(x.slice(7)))});try{E=e4(v)/1e3}catch(x){T=x}return}else C===""&&(w=!1);d.parse(C+`
|
206
|
-
`)}),d.flush()}const qc="stpp.ttml.im1t",If=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Df=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,s4={left:"start",center:"center",right:"end",start:"start",end:"end"};function xf(s,t,e,i){const n=ye(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>
|
207
|
-
`:(o=i.childNodes)!=null&&o.length?Of(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function a4(s,t,e){const i="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(n=e[c]),o.reduce((d,f)=>{const p=Jc(t,i,f)||Jc(s,i,f)||Jc(n,i,f);return p&&(d[f]=p),d},{})}function Jc(s,t,e){return s&&s.hasAttributeNS(t,e)?s.getAttributeNS(t,e):null}function Mf(s){return new Error(`Could not parse ttml timestamp ${s}`)}function th(s,t){if(!s)return null;let e=Lf(s);return e===null&&(If.test(s)?e=o4(s,t):Df.test(s)&&(e=l4(s,t))),e}function o4(s,t){const e=If.exec(s),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 l4(s,t){const e=Df.exec(s),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 c4{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=$f(),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 Bo(this,"textTrack1"),i=new Bo(this,"textTrack2"),n=new Bo(this,"textTrack3"),o=new Bo(this,"textTrack4");this.cea608Parser1=new wf(1,e,i),this.cea608Parser2=new wf(3,n,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,n,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=d4(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,n)}else{const d=this.Cues.newCue(null,e,i,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:n,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 n=e.textTracks[i];if(n[t])return n}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:n}=this,{label:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Sn(i[t]),C0(i[t],n);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,n={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Sn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=$f(),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++)Sn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some(o=>o.textCodec===qc);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(mf(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(h4(o[g],c)){p=o[g];break}p&&(f=p)}if(f)Sn(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 n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const o=`textTrack${n[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:n,lastSn:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&n))&&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(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Qt.SUBTITLE)if(n.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===qc?this._parseIMSC1(i,n):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;xf(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:i,payload:n}=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?on(i.initSegment.data,new Uint8Array(n)):n;r4(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,n),X.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||xf(e,this.initPTS[t.cc],()=>{i.textCodec=qc,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>I0(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.default?"default":"subtitles"+e;i.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Qt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!(i&&n))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]),n.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>bc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>bc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let n=2;for(let o=0;o<i;o++){const c=t[n++],d=127&t[n++],f=127&t[n++];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 h4(s,t){return!!s&&s.label===t.name&&!(s.textTrack1||s.textTrack2)}function d4(s,t,e,i){return Math.min(t,i)-Math.max(s,e)}function $f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class eh{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((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,eh.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 n=(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)&&n(d,t[c+1])){o=c;break}}return o}}class u4{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 n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const o=n-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;X.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=n,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 Vo="[eme]";class In{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=In.CDMCleanupPromise?[In.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,Vo),this.log=X.log.bind(X,Vo),this.warn=X.warn.bind(X,Vo),this.error=X.error.bind(X,Vo),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,n=e[t];if(n)return n.licenseUrl;if(t===ei.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,n=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof ur?d(v):d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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 n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return r0===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=Rv(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(n)}`),c=this.requestMediaKeySystemAccess(t,n);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 n=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=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 n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Or.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
|
208
|
-
} (data length: ${e&&e.byteLength})`),n.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 n=uc(this.config),o=t.map(t0).filter(c=>!!c&&n.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=i0(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),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);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 ${n}`),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 ur?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const n=t0(t.keyFormat),o=n?[n]:uc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=uc(this.config)),t.length===0)throw new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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 n,o;if(e==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const g=wi(new Uint8Array(i));try{const v=dc(JSON.parse(g).sinf),A=d0(new Uint8Array(v));if(!A)return;n=A.subarray(8,24),o=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Zv(i);if(g===null)return;g.version===0&&g.systemId===e0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=Sv(g.systemId)}if(!o||!n)return;const c=Or.hexDump(n),{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 E=Or.hexDump(A.keyId);if(c===E||A.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],A.pssh=new Uint8Array(i),A.keyId=n,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 E=new ka("ISO-23001-7",c,(A=i0(g))!=null?A:"");return E.pssh=new Uint8Array(i),E.keyId=n,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,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 n=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(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,n){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 "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Gc;t.mediaKeysSession.onmessage=A=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=A;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===ei.FAIRPLAY&&(this.updateKeySession(t,Ju("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=A=>{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((A,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?A():T==="output-restricted"?E(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});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 ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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: ${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,n=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,E,T,w)=>{c(A.data)},onError:(A,E,T,w)=>{d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Ki({url:f.url,data:void 0},A)},`"${t}" certificate request failed (${o}). Status: ${A.code} (${A.text})`))},onTimeout:(A,E,T)=>{d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(A,E,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((n,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),n(t)}).catch(c=>{o(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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(n=>{throw new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,i,n){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,n)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,n)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((n,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)}n(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 ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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(n,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={},ka.clearKeyUriToKeyIdMap();const i=e.length;In.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. 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((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);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 n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}In.CDMCleanupPromise=void 0;class ur 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 f4=1;var Xi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const p4="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=n=>{try{this.apply(n,{ot:Xi.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Xi.VIDEO||d===Xi.AUDIO||d==Xi.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.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,n;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:f4,sf:p4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ci(e,this.createData());const i=e.ot===Xi.INIT||e.ot===Xi.VIDEO||e.ot===Xi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=ks.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),ci(t.headers,n)}else{const n=ks.toQuery(e);if(!n)return;t.url=ks.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Xi.TIMED_TEXT;if(t.sn==="initSegment")return Xi.INIT;if(e==="audio")return Xi.AUDIO;if(e==="main")return this.hls.audioTracks.length?Xi.VIDEO:Xi.MUXED}getTopBandwidth(t){let e=0,i;const n=this.hls;if(t===Xi.AUDIO)i=n.audioTracks;else{const o=n.maxAutoLevel,c=o>-1?o+1:n.levels.length;i=n.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===Xi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Be.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(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,c){e(n),this.loader.load(n,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,c){e(n),this.loader.load(n,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,n=f=>Math.round(f),o=f=>n(f/100)*100,c={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},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={},n=["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-${n[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 g4=3e5;class m4{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=X.log.bind(X,"[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)===Ci.SendAlternateToPenaltyBox&&i.flags===hr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),n&&n.length>1&&(this.updatePathwayPriority(n),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,n=performance.now();Object.keys(i).forEach(o=>{n-i[o]>g4&&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={},n={};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=ci({},g);v.details=void 0,v.url=Nf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new ti(g.attrs);A["PATHWAY-ID"]=c;const E=A.AUDIO&&`${A.AUDIO}_clone_${c}`,T=A.SUBTITLES&&`${A.SUBTITLES}_clone_${c}`;E&&(i[A.AUDIO]=E,A.AUDIO=E),T&&(n[A.SUBTITLES]=T,A.SUBTITLES=T),v.attrs=A;const w=new Sa(v);return xo(w,"audio",E),xo(w,"text",T),w});e.push(...p),Ff(this.audioTracks,i,f,c),Ff(this.subtitleTracks,n,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.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,E)=>{this.log(`Loaded steering manifest: "${n}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":x}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||A.url),C&&this.clonePathways(C),x&&this.updatePathwayPriority(x)},onError:(g,v,A,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 T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,A)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),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 Ff(s,t,e,i){s&&Object.keys(t).forEach(n=>{const o=s.filter(c=>c.groupId===n).map(c=>{const d=ci({},c);return d.details=void 0,d.attrs=new ti(d.attrs),d.url=d.attrs.URI=Nf(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=i,d});s.push(...o)})}function Nf(s,t,e,i){const{HOST:n,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(s=d));const f=new self.URL(s);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const v4=/^age:\s*[\d.]+\s*$/im;class Uf{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 ko,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,n=this.stats;n.loading.first=0,n.loaded=0,n.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,n)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[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&&Wt(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 n=e.readyState,o=this.config;if(!i.aborted&&n>=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)))),n===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;Do(f,p,!1,c)?this.retry(f):(X.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(Do(e,i,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=Sc(t,i.retry),i.retry++,X.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&&v4.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 y4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const b4=/(\d+)-(\d+)\/(\d+)/;class Bf{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||k4,this.controller=new self.AbortController,this.stats=new ko}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 n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=A4(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&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},g-(A-n.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new w4(T||"fetch, bad network response",E,v)}return n.loading.first=A,n.total=T4(v.headers)||n.total,c&&Wt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const E=v[f];E&&(n.loaded=n.total=E);const T={url:A.url,data:v,code:A.status};c&&!Wt(e.highWaterMark)&&c(n,t,v,A),i.onSuccess(T,n,t,A)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=v&&v.code||0,E=v?v.message:null;i.onError({code:A,text:E},t,v?v.details:null,n)})}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,n=0,o){const c=new pf,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<n||c.dataLength?(c.push(g),c.dataLength>=n&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function A4(s,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ci({},s.headers))};return s.rangeEnd&&e.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),e}function E4(s){const t=b4.exec(s);if(t)return parseInt(t[2])-parseInt(t[1])+1}function T4(s){const t=s.get("Content-Range");if(t){const i=E4(t);if(Wt(i))return i}const e=s.get("Content-Length");if(e)return parseInt(e)}function k4(s,t){return new self.Request(s.url,t)}class w4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const S4=/\s/,R4={newCue(s,t,e,i){const n=[];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++)S4.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=Cf(p.trim()),T=Zc(t,e,E);s!=null&&(v=s.cues)!=null&&v.getCueById(T)||(c=new g(t,e,E),c.id=T,c.line=A+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(c))}return s&&n.length&&(n.sort((A,E)=>A.line==="auto"||E.line==="auto"?0:A.line>8&&E.line>8?E.line-A.line:A.line-E.line),n.forEach(A=>I0(s,A))),n}},L4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},_4=Ki(Ki({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:Uf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:xb,bufferController:Gb,capLevelController:eh,errorController:wy,fpsController:u4,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:r0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:L4},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},C4()),{},{subtitleStreamController:Fb,subtitleTrackController:Ub,timelineController:c4,audioStreamController:Ob,audioTrackController:Mb,emeController:In,cmcdController:ks,contentSteeringController:m4});function C4(){return{cueHandler:R4,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 I4(s,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=ih(s),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];n.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&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Ki(Ki({},e),t)}function ih(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(ih):Object.keys(s).reduce((t,e)=>(t[e]=ih(s[e]),t),{}):s}function D4(s){const t=s.loader;t!==Bf&&t!==Uf?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):y4()&&(s.loader=Bf,s.progressive=!0,s.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class is{static get version(){return"1.4.12"}static isSupported(){return Hy()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return pt}static get DefaultConfig(){return is.defaultConfig?is.defaultConfig:_4}static set DefaultConfig(t){is.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gc,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,gv(t.debug||!1,"Hls instance");const e=this.config=I4(is.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&D4(e);const{abrController:i,bufferController:n,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),A=new d(this),E=new ny(this),T=new hy(this),w=e.contentSteeringController,C=w?new w(this):null,x=this.levelController=new Ry(this,C),O=new Ly(this),B=new Cy(this.config),D=this.streamController=new Ib(this,O,B);v.setStreamController(D),A.setStreamController(D);const V=[E,x,D];C&&V.splice(1,0,C),this.networkControllers=V;const $=[p,g,v,A,T,O];this.audioTrackController=this.createController(e.audioTrackController,V);const z=e.audioStreamController;z&&V.push(new z(this,O,B)),this.subtitleTrackController=this.createController(e.subtitleTrackController,V);const it=e.subtitleStreamController;it&&V.push(new it(this,O,B)),this.createController(e.timelineController,$),B.emeController=this.emeController=this.createController(e.emeController,$),this.cmcdController=this.createController(e.cmcdController,$),this.latencyController=this.createController(dy,$),this.coreComponents=$,V.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,n){this._emitter.off(t,e,i,n)}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){X.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:pt.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.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){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=lc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.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){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.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){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.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&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Tc.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 n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,i)for(let o=n;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return n}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}}is.defaultConfig=void 0;function x4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function P4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function rh(s){const{id:t,key:e,src:i,playlist:n,duration:o}=s;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!x4()&&is.isSupported()){let p=!1;d=new is({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,A=n.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+A),v.apply(this,[E,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const A=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=A!==-1?A:d.firstLevel}},d.on(is.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:s,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:s,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:s,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Gf(s){return s.duration===1/0?new Promise(t=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,t(s.duration),s.currentTime=0}}):s.duration}const O4=ys(async function(s){return new FontFace(s.name,`url(${s.woff2??s.url})`,{style:s.style,weight:s.weight}).load()},{cacheKey:([s])=>JSON.stringify(s)});let M4=class{constructor(s){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ys(async t=>{const{id:e,key:i}=t,n=await rh(t);n.node.volume=this.host.volume,n.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:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:n}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ys(async(t,e)=>{const{id:i,captions:n,duration:o,startOffset:c,endOffset:d}=t,f=o??await Gf(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var n,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=(n=this.scenes)==null?void 0:n.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],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:n}}},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 n=this.videoState[e];n!=null&&n.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})=>()=>{const n=new Qr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.message})),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(n=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[n];d&&i.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=s,this.host.addController(this)}set hasPlayed(s){s!==this._hasPlayed&&(this._hasPlayed=s,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(s){!isNaN(s)&&s!==this._duration&&(this._duration=s,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(s){s!==this._scenes&&(this._scenes=s,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(s){s!==this._videos&&(this._videos=s,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(s){s!==this._videoMeta&&(this._videoMeta=s,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(s){s!==this._videoState&&(this._videoState=s,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:s,node:t,duration:e}){var i;const n=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>s===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof c<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.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 Za(this.host,async([s,t,e,i,n,o])=>{try{if(this.host._errors=[],e||s){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new Qr("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 go({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new Qr(`Source template error - ${f.message}`,!0)}}else try{this.scenes=await go({data:s,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Qr(`Data template error - ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new Qr("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 A=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:A,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[A]={initialised:!f,waiting:!!f,...this.videoState[A],buffered:f?E:(v=this.videoState[A])==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=>O4(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 s=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===s)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=s,this._lastDeps=t,t})}_setVideoCurrentTime({time:s,scene:t}){const{start:e,video:i,videoMeta:n}=t;if(i&&i.node&&n&&typeof e<"u"){const o=s-e;i.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(s){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:s,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(s=>{this._cleanupVideo(s)}),this.videos={}}};function $4(s){s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen&&s.msRequestFullscreen()}function F4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const sh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],N4={id:"captions",event:"captions:click",label:"Closed Captions"},U4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Vf={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}]},B4={id:"playbackRate",label:"Playback playbackRate",subItems:Vf};class G4 extends Dd{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==yn.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)),ms}}const nh=bn(G4);var Hf=Number.isNaN||function(s){return typeof s=="number"&&s!==s};function V4(s,t){return!!(s===t||Hf(s)&&Hf(t))}function H4(s,t){if(s.length!==t.length)return!1;for(var e=0;e<s.length;e++)if(!V4(s[e],t[e]))return!1;return!0}function W4(s,t){t===void 0&&(t=H4);var e=null;function i(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var c=s.apply(this,n);return e={lastResult:c,lastArgs:n,lastThis:this},c}return i.clear=function(){e=null},i}const j4=W4(()=>{const s=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=tu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:s},{load:!0,font:t},{load:!0,font:e},...i]}),$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"},K4={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, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", "Noto Color Emoji", sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Apple 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"}},Wf=Dm.flatten(K4,{delimiter:"-"}),z4=Object.keys(Wf).map(s=>Zn(`:host { --${s}: ${Wf[s]}; }`)),Y4=s=>{class t extends s{firstUpdated(){j4().forEach(({load:i,font:n})=>{document.fonts.add(n),i&&n.load()})}}return t.styles=[(s==null?void 0:s.styles)??[],z4,Ei`
|
206
|
+
`)}),d.flush()}const qc="stpp.ttml.im1t",If=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Df=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,s4={left:"start",center:"center",right:"end",start:"start",end:"end"};function xf(s,t,e,i){const n=ye(new Uint8Array(s),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=n.map(d=>Or(d)),c=fb(t.baseTime,1,t.timescale);try{o.forEach(d=>e(n4(d,c)))}catch(d){i(d)}}function n4(s,t){const e=new DOMParser().parseFromString(s,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",c=Pf(Qc(e,"styling","style")),d=Pf(Qc(e,"layout","region")),f=Qc(e,"body","[begin]");return[].map.call(f,p=>{const g=Of(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=th(p.getAttribute("begin"),n),A=th(p.getAttribute("dur"),n);let E=th(p.getAttribute("end"),n);if(v===null)throw Mf(p);if(E===null){if(A===null)throw Mf(p);E=v+A}const T=new Kc(v-t,E-t,g);T.id=Zc(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=c[p.getAttribute("style")],x=a4(w,C,c),{textAlign:O}=x;if(O){const B=s4[O];B&&(T.lineAlign=B),T.align=O}return hi(T,x),T}).filter(p=>p!==null)}function Qc(s,t,e){const i=s.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function Pf(s){return s.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Of(s,t){return[].slice.call(s.childNodes).reduce((e,i,n)=>{var o;return i.nodeName==="br"&&n?e+`
|
207
|
+
`:(o=i.childNodes)!=null&&o.length?Of(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function a4(s,t,e){const i="http://www.w3.org/ns/ttml#styling";let n=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=s!=null&&s.hasAttribute("style")?s.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(n=e[c]),o.reduce((d,f)=>{const p=Jc(t,i,f)||Jc(s,i,f)||Jc(n,i,f);return p&&(d[f]=p),d},{})}function Jc(s,t,e){return s&&s.hasAttributeNS(t,e)?s.getAttributeNS(t,e):null}function Mf(s){return new Error(`Could not parse ttml timestamp ${s}`)}function th(s,t){if(!s)return null;let e=_f(s);return e===null&&(If.test(s)?e=o4(s,t):Df.test(s)&&(e=l4(s,t))),e}function o4(s,t){const e=If.exec(s),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 l4(s,t){const e=Df.exec(s),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 c4{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=$f(),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 Bo(this,"textTrack1"),i=new Bo(this,"textTrack2"),n=new Bo(this,"textTrack3"),o=new Bo(this,"textTrack4");this.cea608Parser1=new wf(1,e,i),this.cea608Parser2=new wf(3,n,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,n,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=d4(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,n)}else{const d=this.Cues.newCue(null,e,i,n);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:n,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:n,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 n=e.textTracks[i];if(n[t])return n}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:n}=this,{label:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Sn(i[t]),C0(i[t],n);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,n={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(t,e,i){const n=this.media;if(n)return n.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Sn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=$f(),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++)Sn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],n=i.some(o=>o.textCodec===qc);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(mf(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(h4(o[g],c)){p=o[g];break}p&&(f=p)}if(f)Sn(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 n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const o=`textTrack${n[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:n,lastSn:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&n))&&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(),n.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:n}=e;if(i.type===Qt.SUBTITLE)if(n.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===qc?this._parseIMSC1(i,n):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;xf(e,this.initPTS[t.cc],n=>{this._appendCues(n,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},n=>{X.log(`Failed to parse IMSC1: ${n}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})})}_parseVTTs(t){var e;const{frag:i,payload:n}=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?on(i.initSegment.data,new Uint8Array(n)):n;r4(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,n),X.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||xf(e,this.initPTS[t.cc],()=>{i.textCodec=qc,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[e];if(!n||n.mode==="disabled")return;t.forEach(o=>I0(n,o))}else{const n=this.tracks[e];if(!n)return;const o=n.default?"default":"subtitles"+e;i.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Qt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!(i&&n))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]),n.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:n,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>bc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&n!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>bc(d[f],e,n))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let n=2;for(let o=0;o<i;o++){const c=t[n++],d=127&t[n++],f=127&t[n++];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 h4(s,t){return!!s&&s.label===t.name&&!(s.textTrack1||s.textTrack2)}function d4(s,t,e,i){return Math.min(t,i)-Math.max(s,e)}function $f(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class eh{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((n,o)=>this.isLevelAllowed(n)&&o<=t);return this.clientRect=null,eh.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 n=(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)&&n(d,t[c+1])){o=c;break}}return o}}class u4{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 n=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=n,n&&typeof n.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const n=performance.now();if(e){if(this.lastTime){const o=n-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;X.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=n,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 Vo="[eme]";class In{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=In.CDMCleanupPromise?[In.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=X.debug.bind(X,Vo),this.log=X.log.bind(X,Vo),this.warn=X.warn.bind(X,Vo),this.error=X.error.bind(X,Vo),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,n=e[t];if(n)return n.licenseUrl;if(t===ei.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,n=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return n.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,n,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof ur?d(v):d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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 n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return r0===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(t,e)}getMediaKeysPromise(t,e,i){const n=Rv(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(n)}`),c=this.requestMediaKeySystemAccess(t,n);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: ${Mr.hexDump(t.keyId||[])}`);const n=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),n=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[n]=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 Mr.hexDump(t.keyId)}updateKeySession(t,e){var i;const n=t.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Mr.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
|
208
|
+
} (data length: ${e&&e.byteLength})`),n.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 n=uc(this.config),o=t.map(t0).filter(c=>!!c&&n.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=i0(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),n=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${n}`);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 ${n}`),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 ur?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const n=t0(t.keyFormat),o=n?[n]:uc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=uc(this.config)),t.length===0)throw new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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 n,o;if(e==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const g=Si(new Uint8Array(i));try{const v=dc(JSON.parse(g).sinf),A=d0(new Uint8Array(v));if(!A)return;n=A.subarray(8,24),o=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Zv(i);if(g===null)return;g.version===0&&g.systemId===e0.WIDEVINE&&g.data&&(n=g.data.subarray(8,24)),o=Sv(g.systemId)}if(!o||!n)return;const c=Mr.hexDump(n),{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 E=Mr.hexDump(A.keyId);if(c===E||A.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],A.pssh=new Uint8Array(i),A.keyId=n,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 E=new ka("ISO-23001-7",c,(A=i0(g))!=null?A:"");return E.pssh=new Uint8Array(i),E.keyId=n,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,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 n=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(n),n.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,n){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 "${n}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Gc;t.mediaKeysSession.onmessage=A=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=A;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===ei.FAIRPLAY&&(this.updateKeySession(t,Ju("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=A=>{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((A,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?A():T==="output-restricted"?E(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});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 ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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: ${Mr.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Mr.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,n=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,E,T,w)=>{c(A.data)},onError:(A,E,T,w)=>{d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Ki({url:f.url,data:void 0},A)},`"${t}" certificate request failed (${o}). Status: ${A.code} (${A.text})`))},onTimeout:(A,E,T)=>{d(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(A,E,T)=>{d(new Error("aborted"))}};n.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((n,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),n(t)}).catch(c=>{o(new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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(n=>{throw new ur({type:qt.KEY_SYSTEM_ERROR,details:pt.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(t,e,i,n){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,n)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,n)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||n})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:n}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((n,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)}n(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 ur({type:qt.KEY_SYSTEM_ERROR,details:pt.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(n,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={},ka.clearKeyUriToKeyIdMap();const i=e.length;In.CDMCleanupPromise=Promise.all(e.map(n=>this.removeSession(n)).concat(t==null?void 0:t.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. 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((n,o)=>(n.indexOf(o.keyFormat)===-1&&n.push(o.keyFormat),n),[]);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 n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}In.CDMCleanupPromise=void 0;class ur 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 f4=1;var Xi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const p4="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=n=>{try{this.apply(n,{ot:Xi.MANIFEST,su:!this.initialized})}catch(o){X.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=n=>{try{const o=n.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===Xi.VIDEO||d===Xi.AUDIO||d==Xi.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(n,f)}catch(o){X.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,n;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=e.tracks.video)==null?void 0:n.buffer}createData(){var t;return{v:f4,sf:p4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){hi(e,this.createData());const i=e.ot===Xi.INIT||e.ot===Xi.VIDEO||e.ot===Xi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const n=ks.toHeaders(e);if(!Object.keys(n).length)return;t.headers||(t.headers={}),hi(t.headers,n)}else{const n=ks.toQuery(e);if(!n)return;t.url=ks.appendQueryToUri(t.url,n)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return Xi.TIMED_TEXT;if(t.sn==="initSegment")return Xi.INIT;if(e==="audio")return Xi.AUDIO;if(e==="main")return this.hls.audioTracks.length?Xi.VIDEO:Xi.MUXED}getTopBandwidth(t){let e=0,i;const n=this.hls;if(t===Xi.AUDIO)i=n.audioTracks;else{const o=n.maxAutoLevel,c=o>-1?o+1:n.levels.length;i=n.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===Xi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:Be.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(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,c){e(n),this.loader.load(n,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new i(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,c){e(n),this.loader.load(n,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,n=f=>Math.round(f),o=f=>n(f/100)*100,c={br:n,d:n,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:n},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={},n=["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-${n[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 g4=3e5;class m4{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=X.log.bind(X,"[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)===Ii.SendAlternateToPenaltyBox&&i.flags===hr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),n&&n.length>1&&(this.updatePathwayPriority(n),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,n=performance.now();Object.keys(i).forEach(o=>{n-i[o]>g4&&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={},n={};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=hi({},g);v.details=void 0,v.url=Nf(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new ti(g.attrs);A["PATHWAY-ID"]=c;const E=A.AUDIO&&`${A.AUDIO}_clone_${c}`,T=A.SUBTITLES&&`${A.SUBTITLES}_clone_${c}`;E&&(i[A.AUDIO]=E,A.AUDIO=E),T&&(n[A.SUBTITLES]=T,A.SUBTITLES=T),v.attrs=A;const w=new Sa(v);return xo(w,"audio",E),xo(w,"text",T),w});e.push(...p),Ff(this.audioTracks,i,f,c),Ff(this.subtitleTracks,n,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let n;try{n=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(n.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:n.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,E)=>{this.log(`Loaded steering manifest: "${n}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":x}=T;if(w)try{this.uri=new self.URL(w,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||A.url),C&&this.clonePathways(C),x&&this.updatePathwayPriority(x)},onError:(g,v,A,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 T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,A)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${n}`),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 Ff(s,t,e,i){s&&Object.keys(t).forEach(n=>{const o=s.filter(c=>c.groupId===n).map(c=>{const d=hi({},c);return d.details=void 0,d.attrs=new ti(d.attrs),d.url=d.attrs.URI=Nf(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[n],d.attrs["PATHWAY-ID"]=i,d});s.push(...o)})}function Nf(s,t,e,i){const{HOST:n,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(s=d));const f=new self.URL(s);return n&&!d&&(f.host=n),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const v4=/^age:\s*[\d.]+\s*$/im;class Uf{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 ko,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,n=this.stats;n.loading.first=0,n.loaded=0,n.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,n)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(n)for(const d in n)t.setRequestHeader(d,n[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&&Wt(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 n=e.readyState,o=this.config;if(!i.aborted&&n>=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)))),n===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;Do(f,p,!1,c)?this.retry(f):(X.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(Do(e,i,!0))this.retry(e);else{X.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=Sc(t,i.retry),i.retry++,X.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&&v4.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 y4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const b4=/(\d+)-(\d+)\/(\d+)/;class Bf{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||k4,this.controller=new self.AbortController,this.stats=new ko}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 n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();const o=A4(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&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,t,this.response)},g-(A-n.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new w4(T||"fetch, bad network response",E,v)}return n.loading.first=A,n.total=T4(v.headers)||n.total,c&&Wt(e.highWaterMark)?this.loadProgressively(v,n,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const E=v[f];E&&(n.loaded=n.total=E);const T={url:A.url,data:v,code:A.status};c&&!Wt(e.highWaterMark)&&c(n,t,v,A),i.onSuccess(T,n,t,A)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=v&&v.code||0,E=v?v.message:null;i.onError({code:A,text:E},t,v?v.details:null,n)})}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,n=0,o){const c=new pf,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<n||c.dataLength?(c.push(g),c.dataLength>=n&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function A4(s,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(hi({},s.headers))};return s.rangeEnd&&e.headers.set("Range","bytes="+s.rangeStart+"-"+String(s.rangeEnd-1)),e}function E4(s){const t=b4.exec(s);if(t)return parseInt(t[2])-parseInt(t[1])+1}function T4(s){const t=s.get("Content-Range");if(t){const i=E4(t);if(Wt(i))return i}const e=s.get("Content-Length");if(e)return parseInt(e)}function k4(s,t){return new self.Request(s.url,t)}class w4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const S4=/\s/,R4={newCue(s,t,e,i){const n=[];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++)S4.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=Cf(p.trim()),T=Zc(t,e,E);s!=null&&(v=s.cues)!=null&&v.getCueById(T)||(c=new g(t,e,E),c.id=T,c.line=A+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(c))}return s&&n.length&&(n.sort((A,E)=>A.line==="auto"||E.line==="auto"?0:A.line>8&&E.line>8?E.line-A.line:A.line-E.line),n.forEach(A=>I0(s,A))),n}},_4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},L4=Ki(Ki({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:Uf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:xb,bufferController:Gb,capLevelController:eh,errorController:wy,fpsController:u4,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:r0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:_4},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},C4()),{},{subtitleStreamController:Fb,subtitleTrackController:Ub,timelineController:c4,audioStreamController:Ob,audioTrackController:Mb,emeController:In,cmcdController:ks,contentSteeringController:m4});function C4(){return{cueHandler:R4,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 I4(s,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=ih(s),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];n.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&&X.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Ki(Ki({},e),t)}function ih(s){return s&&typeof s=="object"?Array.isArray(s)?s.map(ih):Object.keys(s).reduce((t,e)=>(t[e]=ih(s[e]),t),{}):s}function D4(s){const t=s.loader;t!==Bf&&t!==Uf?(X.log("[config]: Custom loader detected, cannot enable progressive streaming"),s.progressive=!1):y4()&&(s.loader=Bf,s.progressive=!0,s.enableSoftwareAES=!0,X.log("[config]: Progressive streaming enabled, using FetchLoader"))}class rs{static get version(){return"1.4.12"}static isSupported(){return Hy()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return pt}static get DefaultConfig(){return rs.defaultConfig?rs.defaultConfig:L4}static set DefaultConfig(t){rs.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Gc,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,gv(t.debug||!1,"Hls instance");const e=this.config=I4(rs.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&D4(e);const{abrController:i,bufferController:n,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new n(this),v=this.capLevelController=new o(this),A=new d(this),E=new ny(this),T=new hy(this),w=e.contentSteeringController,C=w?new w(this):null,x=this.levelController=new Ry(this,C),O=new _y(this),B=new Cy(this.config),D=this.streamController=new Ib(this,O,B);v.setStreamController(D),A.setStreamController(D);const V=[E,x,D];C&&V.splice(1,0,C),this.networkControllers=V;const $=[p,g,v,A,T,O];this.audioTrackController=this.createController(e.audioTrackController,V);const z=e.audioStreamController;z&&V.push(new z(this,O,B)),this.subtitleTrackController=this.createController(e.subtitleTrackController,V);const it=e.subtitleStreamController;it&&V.push(new it(this,O,B)),this.createController(e.timelineController,$),B.emeController=this.emeController=this.createController(e.emeController,$),this.cmcdController=this.createController(e.cmcdController,$),this.latencyController=this.createController(dy,$),this.coreComponents=$,V.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,n){this._emitter.off(t,e,i,n)}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){X.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:pt.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){X.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){X.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){X.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,n=this.url=lc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});X.log(`loadSource:${n}`),e&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){X.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){X.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){X.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){X.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){X.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){X.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){X.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){X.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){X.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&&(X.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Tc.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 n=0;n<i;n++)if(t[n].maxBitrate>=e)return n;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(e===-1&&t&&t.length?n=t.length-1:n=e,i)for(let o=n;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return n}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}}rs.defaultConfig=void 0;function x4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function P4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function rh(s){const{id:t,key:e,src:i,playlist:n,duration:o}=s;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!x4()&&rs.isSupported()){let p=!1;d=new rs({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,A=n.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+A),v.apply(this,[E,T,w])}}}),d.loadSource(n),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const A=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=A!==-1?A:d.firstLevel}},d.on(rs.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:s,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:s,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:s,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Gf(s){return s.duration===1/0?new Promise(t=>{s.currentTime=Number.MAX_SAFE_INTEGER,s.ontimeupdate=()=>{s.ontimeupdate=null,t(s.duration),s.currentTime=0}}):s.duration}const O4=ys(async function(s){return new FontFace(s.name,`url(${s.woff2??s.url})`,{style:s.style,weight:s.weight}).load()},{cacheKey:([s])=>JSON.stringify(s)});let M4=class{constructor(s){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ys(async t=>{const{id:e,key:i}=t,n=await rh(t);n.node.volume=this.host.volume,n.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:n.node});return d[p]=g,n.node.addEventListener(f,g),d},{});return{...n,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:n}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveVideoMeta=ys(async(t,e)=>{const{id:i,captions:n,duration:o,startOffset:c,endOffset:d}=t,f=o??await Gf(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:n,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:n,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var n,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=(n=this.scenes)==null?void 0:n.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],n=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:n}}},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 n=this.videoState[e];n!=null&&n.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})=>()=>{const n=new Jr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:n,message:n.message})),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(n=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[n];d&&i.node.removeEventListener(n,d)}}),delete this.videos[t])},this.host=s,this.host.addController(this)}set hasPlayed(s){s!==this._hasPlayed&&(this._hasPlayed=s,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(s){!isNaN(s)&&s!==this._duration&&(this._duration=s,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(s){s!==this._scenes&&(this._scenes=s,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(s){s!==this._videos&&(this._videos=s,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(s){s!==this._videoMeta&&(this._videoMeta=s,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(s){s!==this._videoState&&(this._videoState=s,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:s,node:t,duration:e}){var i;const n=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>s===(p==null?void 0:p.key)))??{};if(t&&n&&d&&f&&typeof c<"u")for(let p=0;p<n.length;p++){const g=n.start(p),v=n.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 Za(this.host,async([s,t,e,i,n,o])=>{try{if(this.host._errors=[],e||s){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new Jr("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 go({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new Jr(`Source template error - ${f.message}`,!0)}}else try{this.scenes=await go({data:s,template:t,burnCaptions:n,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Jr(`Data template error - ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new Jr("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 A=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:A,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[A]={initialised:!f,waiting:!!f,...this.videoState[A],buffered:f?E:(v=this.videoState[A])==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=>O4(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 s=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===s)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=s,this._lastDeps=t,t})}_setVideoCurrentTime({time:s,scene:t}){const{start:e,video:i,videoMeta:n}=t;if(i&&i.node&&n&&typeof e<"u"){const o=s-e;i.node.currentTime=Math.max(n.start,Math.min(n.start+n.duration,o+n.start))}}setVideosCurrentTime(s){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:s,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(s=>{this._cleanupVideo(s)}),this.videos={}}};function $4(s){s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen&&s.msRequestFullscreen()}function F4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const sh=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],N4={id:"captions",event:"captions:click",label:"Closed Captions"},U4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Vf={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}]},B4={id:"playbackRate",label:"Playback playbackRate",subItems:Vf};class G4 extends Dd{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==yn.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)),ms}}const nh=bn(G4);var Hf=Number.isNaN||function(s){return typeof s=="number"&&s!==s};function V4(s,t){return!!(s===t||Hf(s)&&Hf(t))}function H4(s,t){if(s.length!==t.length)return!1;for(var e=0;e<s.length;e++)if(!V4(s[e],t[e]))return!1;return!0}function W4(s,t){t===void 0&&(t=H4);var e=null;function i(){for(var n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];if(e&&e.lastThis===this&&t(n,e.lastArgs))return e.lastResult;var c=s.apply(this,n);return e={lastResult:c,lastArgs:n,lastThis:this},c}return i.clear=function(){e=null},i}const j4=W4(()=>{const s=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=tu.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:s},{load:!0,font:t},{load:!0,font:e},...i]}),Fr={"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"},K4={colors:Fr,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, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", "Noto Color Emoji", sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Apple 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 ${Fr["dark-100"]}`,medium:`0 .125rem .625rem ${Fr["dark-100"]}`,large:`0 .25rem 1rem ${Fr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Fr["dark-250"]}`,xxl:`0 .25rem 2rem ${Fr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Fr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Fr["dark-50"]}`,text:`0 0 .25rem ${Fr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Fr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Wf=Dm.flatten(K4,{delimiter:"-"}),z4=Object.keys(Wf).map(s=>Zn(`:host { --${s}: ${Wf[s]}; }`)),Y4=s=>{class t extends s{firstUpdated(){j4().forEach(({load:i,font:n})=>{document.fonts.add(n),i&&n.load()})}}return t.styles=[(s==null?void 0:s.styles)??[],z4,Ti`
|
209
209
|
:host {
|
210
210
|
font-family: var(--fontFamilies-sans);
|
211
211
|
font-size: var(--fontSizes-medium);
|
212
212
|
line-height: var(--lineHeights-medium);
|
213
213
|
font-weight: var(--fontWeights-regular);
|
214
214
|
}
|
215
|
-
`,
|
215
|
+
`,Ti`
|
216
216
|
*,
|
217
217
|
*::before,
|
218
218
|
*::after,
|
@@ -286,12 +286,12 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
286
286
|
scroll-behavior: auto !important;
|
287
287
|
}
|
288
288
|
}
|
289
|
-
`],t},
|
289
|
+
`],t},_e=Y4(vn),X4=(s,t)=>(typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,t)),t),Z4=(s,t)=>{const{kind:e,elements:i}=t;return{kind:e,elements:i,finisher(n){typeof window<"u"&&(window.customElements.get(s)??window.customElements.define(s,n))}}},Fi=s=>t=>typeof t=="function"?X4(s,t):Z4(s,t);class q4{constructor(t){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=ys(async e=>{const i=await rh(e);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:e,src:i,playlist:n}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=ys(async e=>{const{id:i,key:n,poster:o}=e,{node:c}=await rh(e),d=new Image;return{id:i,key:n,config:e,node:c,getSource:()=>(o&&d.src!==o&&(d.onload=()=>{this.host._draw()},d.src=o),d)}},{cacheKey:([{id:e,src:i,playlist:n,poster:o}])=>JSON.stringify({id:e,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:o==null?void 0:o.split("?")[0]})}),this._resolveVideoMeta=ys(async(e,i)=>{const{id:n,duration:o,startOffset:c,endOffset:d}=e,f=o??await Gf(i),p=(c??0)*f,g=(1-(d??0))*f;return{id:n,start:p,duration:g-p}},{cacheKey:([{id:e,duration:i,startOffset:n,endOffset:o}])=>JSON.stringify({id:e,duration:i,startOffset:n,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 Za(this.host,async([t,e,i])=>{var n,o;try{if(t){const c=t.includes(".m3u8")?"playlist":"video";try{this.scenes=await go({data:{questions:{items:[{answer:{id:"source",media:{[c]:t}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Jr(`Video preview source template error: ${d.message}`)}this._video=((o=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:o.node)??null}else if(e)try{this.scenes=await go({data:e,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(c){throw new Jr(`Video preview data template error: ${c.message}`)}}catch(c){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.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 jf(s,t,e){return Math.min(Math.max(t,s),e)}function ah(s,t={}){const e=Math.max(0,s||0),i=Math.floor(e/3600),n=Math.floor(e%3600/60),o=Math.floor(e%3600%60),c=Math.floor(e%1*1e3);let d=i?`${i}:${`${n}`.padStart(2,"0")}:${`${o}`.padStart(2,"0")}`:`${n}:${`${o}`.padStart(2,"0")}`;return t.includeMs&&(d+=`:${`${c}`.padStart(3,"0")}`),d}var Q4=Object.defineProperty,J4=Object.getOwnPropertyDescriptor,Dn=(s,t,e,i)=>{for(var n=i>1?void 0:i?J4(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&Q4(t,e,n),n};let ws=class extends _e{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return te`<button
|
290
290
|
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"})}
|
291
291
|
>
|
292
292
|
<slot></slot>
|
293
293
|
${this.icon&&te`<vmp-icon icon=${this.icon}></vmp-icon>`}
|
294
|
-
</button>`}};ws.styles=[
|
294
|
+
</button>`}};ws.styles=[_e.styles??[],Ti`
|
295
295
|
:host {
|
296
296
|
--button-color: var(--vu-button-color, var(--colors-dark-640));
|
297
297
|
--button-background: var(--vu-button-background, var(--colors-light-1000));
|
@@ -528,14 +528,14 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
528
528
|
<path
|
529
529
|
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"
|
530
530
|
/>
|
531
|
-
</svg>`};var tA=Object.defineProperty,eA=Object.getOwnPropertyDescriptor,zf=(s,t,e,i)=>{for(var n=i>1?void 0:i?eA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&tA(t,e,n),n};let Ho=class extends
|
531
|
+
</svg>`};var tA=Object.defineProperty,eA=Object.getOwnPropertyDescriptor,zf=(s,t,e,i)=>{for(var n=i>1?void 0:i?eA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&tA(t,e,n),n};let Ho=class extends _e{render(){return!this.icon||!Object.keys(Kf).includes(this.icon)?null:Kf[this.icon]()}};Ho.styles=[_e.styles??[],Ti`
|
532
532
|
:host {
|
533
533
|
display: flex;
|
534
534
|
align-items: center;
|
535
535
|
justify-content: center;
|
536
536
|
flex-shrink: 0;
|
537
537
|
}
|
538
|
-
`],zf([Dt({type:String})],Ho.prototype,"icon",2),Ho=zf([Fi("vmp-icon")],Ho);var iA=Object.defineProperty,rA=Object.getOwnPropertyDescriptor,xn=(s,t,e,i)=>{for(var n=i>1?void 0:i?rA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&iA(t,e,n),n};let Ss=class extends
|
538
|
+
`],zf([Dt({type:String})],Ho.prototype,"icon",2),Ho=zf([Fi("vmp-icon")],Ho);var iA=Object.defineProperty,rA=Object.getOwnPropertyDescriptor,xn=(s,t,e,i)=>{for(var n=i>1?void 0:i?rA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&iA(t,e,n),n};let Ss=class extends _e{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return te`
|
539
539
|
<vmp-button
|
540
540
|
?active=${this.active}
|
541
541
|
size=${Xs(this.size)}
|
@@ -547,7 +547,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
547
547
|
icon=${Xs(this.icon)}
|
548
548
|
></vmp-icon>
|
549
549
|
</vmp-button>
|
550
|
-
`}};Ss.styles=[
|
550
|
+
`}};Ss.styles=[_e.styles??[],Ti`
|
551
551
|
.tiny::part(svg) {
|
552
552
|
height: 12px;
|
553
553
|
width: 12px;
|
@@ -562,16 +562,16 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
562
562
|
height: 32px;
|
563
563
|
width: 32px;
|
564
564
|
}
|
565
|
-
`],xn([Dt({type:Boolean})],Ss.prototype,"active",2),xn([Dt({type:String})],Ss.prototype,"size",2),xn([Dt({type:String})],Ss.prototype,"rounded",2),xn([Dt({type:String})],Ss.prototype,"weight",2),xn([Dt({type:String})],Ss.prototype,"icon",2),Ss=xn([Fi("vmp-icon-button")],Ss);var sA=Object.defineProperty,nA=Object.getOwnPropertyDescriptor,Zi=(s,t,e,i)=>{for(var n=i>1?void 0:i?nA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&sA(t,e,n),n};let
|
565
|
+
`],xn([Dt({type:Boolean})],Ss.prototype,"active",2),xn([Dt({type:String})],Ss.prototype,"size",2),xn([Dt({type:String})],Ss.prototype,"rounded",2),xn([Dt({type:String})],Ss.prototype,"weight",2),xn([Dt({type:String})],Ss.prototype,"icon",2),Ss=xn([Fi("vmp-icon-button")],Ss);var sA=Object.defineProperty,nA=Object.getOwnPropertyDescriptor,Zi=(s,t,e,i)=>{for(var n=i>1?void 0:i?nA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&sA(t,e,n),n};let ss=class extends _e{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Ol,this._currentTime=0,this._sceneController=new q4(this),this._canvasRef=Li(),this._previewRef=Li(),this._previewTimeRef=Li(),this._handleScrubberMouseEnter=({detail:{x:s,y:t,elementLeft:e,elementRight:i}})=>{var n,o;if((n=this._previewRef)!=null&&n.value){const c=this._previewRef.value.getBoundingClientRect(),d=(o=this._previewRef.value.getRootNode().host)==null?void 0:o.getBoundingClientRect();c&&d&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${jf(e-d.left,s-d.left-c.width/2,i-d.left-c.width)}px, ${t-d.top-c.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:s,x:t,elementLeft:e,elementRight:i}})=>{var n,o,c,d,f,p,g,v;if(this._currentTime=s,(n=this._sceneController.scenes)!=null&&n.scenes.length){const A=(f=(d=(c=(o=this._sceneController.scenes)==null?void 0:o.scenes)==null?void 0:c.find(({start:E,duration:T,video:w})=>w&&s>=E&&s<=E+T))==null?void 0:d.video)==null?void 0:f.node;if(A&&(A.currentTime=s),this._draw(),(p=this._previewRef)!=null&&p.value){const E=this._previewRef.value.getBoundingClientRect(),T=(g=this._previewRef.value.getRootNode().host)==null?void 0:g.getBoundingClientRect();if(E&&T){const w=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,C]=Array.from(w.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${jf(e-T.left,t-T.left-E.width/2,i-T.left-E.width)}px, ${C[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",ah(Math.max(0,Math.min(this._currentTime,(v=this._sceneController.scenes)==null?void 0:v.duration)),{includeMs:!0}))}},this._handleScrubberMouseLeave=()=>{var s;(s=this._previewRef)!=null&&s.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:s}})=>{var t,e;if((t=this._previewRef)!=null&&t.value){const i=this._previewRef.value.getBoundingClientRect(),n=(e=this._previewRef.value.getRootNode().host)==null?void 0:e.getBoundingClientRect();if(i&&n){const o=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[c]=Array.from(o.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${c[1]}px, ${s-n.top-i.height-28}px, 0)`}}}}_draw(s=this._currentTime){var t,e;this._sceneController.scenes&&this._canvasRef.value&&((e=this.compilation)==null||e.call(this,{currentTime:Math.max(0,Math.min(s,(t=this._sceneController.scenes)==null?void 0:t.duration)),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 s;const{height:t,width:e}=Ml({resolution:180,aspectRatio:this.aspectRatio}),i=((s=this._sceneController.scenes)==null?void 0:s.scenes.length)??0;return!this.disabled&&(this.src||i>1)?te`
|
566
566
|
<div
|
567
|
-
${
|
567
|
+
${Ci(this._previewRef)}
|
568
568
|
class="preview"
|
569
569
|
style=${jl({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
|
570
570
|
>
|
571
|
-
<canvas ${
|
572
|
-
<vmp-text ${
|
571
|
+
<canvas ${Ci(this._canvasRef)} class="preview-canvas" width=${e} height=${t}></canvas>
|
572
|
+
<vmp-text ${Ci(this._previewTimeRef)} class="preview-text"></vmp-text>
|
573
573
|
</div>
|
574
|
-
`:null}};
|
574
|
+
`:null}};ss.styles=[_e.styles??[],Ti`
|
575
575
|
.preview {
|
576
576
|
position: absolute;
|
577
577
|
display: flex;
|
@@ -601,7 +601,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
601
601
|
transform: translate3d(0, calc(100% + 5px), 0);
|
602
602
|
color: var(--colors-light-1000);
|
603
603
|
}
|
604
|
-
`],Zi([Dt({type:String})],
|
604
|
+
`],Zi([Dt({type:String})],ss.prototype,"src",2),Zi([Dt({type:Object})],ss.prototype,"data",2),Zi([Dt({type:Object})],ss.prototype,"template",2),Zi([Dt({type:Boolean})],ss.prototype,"disabled",2),Zi([Dt({type:Number})],ss.prototype,"aspectRatio",2),Zi([Dt({attribute:!1})],ss.prototype,"compilation",2),ss=Zi([Fi("vmp-video-preview-content")],ss);let Rs=class extends _e{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=Ol}render(){return te`
|
605
605
|
<vmp-video-preview-content
|
606
606
|
?disabled=${this.disabled}
|
607
607
|
.src=${this.src}
|
@@ -610,8 +610,8 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
610
610
|
.aspectRatio=${this.aspectRatio}
|
611
611
|
.compilation=${this.compilation}
|
612
612
|
></vmp-video-preview-content>
|
613
|
-
`}};Zi([Dt({type:String})],Rs.prototype,"src",2),Zi([Dt({type:Object})],Rs.prototype,"data",2),Zi([Dt({type:Object})],Rs.prototype,"template",2),Zi([Dt({type:Boolean})],Rs.prototype,"disabled",2),Zi([Dt({type:Number})],Rs.prototype,"aspectRatio",2),Zi([Dt({attribute:!1})],Rs.prototype,"compilation",2),Rs=Zi([Fi("vmp-video-preview")],Rs);class aA extends sa{constructor(t){if(super(t),t.type!==yn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),ms}}const Yf=bn(aA);class oA{constructor(t){this.hiddenControls=[],this._measureRef=Li(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,n,o;const c=this._measureRef.value,d=(o=(n=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:n[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(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(A=>f.includes(A))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return
|
614
|
-
`;var lA=Object.defineProperty,cA=Object.getOwnPropertyDescriptor,Ca=(s,t,e,i)=>{for(var n=i>1?void 0:i?cA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&lA(t,e,n),n};let cn=class extends
|
613
|
+
`}};Zi([Dt({type:String})],Rs.prototype,"src",2),Zi([Dt({type:Object})],Rs.prototype,"data",2),Zi([Dt({type:Object})],Rs.prototype,"template",2),Zi([Dt({type:Boolean})],Rs.prototype,"disabled",2),Zi([Dt({type:Number})],Rs.prototype,"aspectRatio",2),Zi([Dt({attribute:!1})],Rs.prototype,"compilation",2),Rs=Zi([Fi("vmp-video-preview")],Rs);class aA extends sa{constructor(t){if(super(t),t.type!==yn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(t,[e]){return e==null||e(t.element),ms}}const Yf=bn(aA);class oA{constructor(t){this.hiddenControls=[],this._measureRef=Li(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=e=>{var i,n,o;const c=this._measureRef.value,d=(o=(n=(i=e==null?void 0:e[0])==null?void 0:i.borderBoxSize)==null?void 0:n[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(v=>this._hideables[v].hideIndex===f.length);if(!p)break;const g=this._hideables[p].element;g&&(g.style.display="none"),f.push(p),Object.keys(this._showables).forEach(v=>{this._showables[v].showOn.some(A=>f.includes(A))&&(this._showables[v].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=d,this.host.requestUpdate()}},this.host=t}measure(){return Ci(this._measureRef)}contain(){return nh(this._onResize)}hide(t,e){return Yf(i=>{this._hideables[t]={element:i,hideIndex:e}})}show(t,e){return Yf(i=>{this._showables[t]={element:i,showOn:e}})}}const oh=`.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)}
|
614
|
+
`;var lA=Object.defineProperty,cA=Object.getOwnPropertyDescriptor,Ca=(s,t,e,i)=>{for(var n=i>1?void 0:i?cA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&lA(t,e,n),n};let cn=class extends _e{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return te`
|
615
615
|
<div
|
616
616
|
part="content"
|
617
617
|
class=${Je({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
|
@@ -619,7 +619,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
619
619
|
>
|
620
620
|
${this.content}
|
621
621
|
</div>
|
622
|
-
`}};cn.styles=[
|
622
|
+
`}};cn.styles=[_e.styles??[],Ti`
|
623
623
|
:host {
|
624
624
|
--text-size: var(--fontSizes-medium);
|
625
625
|
--text-line-height: var(--lineHeights-medium);
|
@@ -656,9 +656,9 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
656
656
|
text-overflow: ellipsis;
|
657
657
|
overflow: hidden;
|
658
658
|
}
|
659
|
-
`],Ca([Dt({type:Boolean})],cn.prototype,"semibold",2),Ca([Dt({type:Boolean})],cn.prototype,"truncate",2),Ca([Dt({type:String})],cn.prototype,"size",2),Ca([Dt({type:String})],cn.prototype,"content",2),cn=Ca([Fi("vmp-text")],cn);var hA=Object.defineProperty,dA=Object.getOwnPropertyDescriptor,Ia=(s,t,e,i)=>{for(var n=i>1?void 0:i?dA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&hA(t,e,n),n};let hn=class extends
|
659
|
+
`],Ca([Dt({type:Boolean})],cn.prototype,"semibold",2),Ca([Dt({type:Boolean})],cn.prototype,"truncate",2),Ca([Dt({type:String})],cn.prototype,"size",2),Ca([Dt({type:String})],cn.prototype,"content",2),cn=Ca([Fi("vmp-text")],cn);var hA=Object.defineProperty,dA=Object.getOwnPropertyDescriptor,Ia=(s,t,e,i)=>{for(var n=i>1?void 0:i?dA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&hA(t,e,n),n};let hn=class extends _e{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=Li()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var s,t;const e=(t=(s=this.items)==null?void 0:s.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 s;const t=(s=this.shadowRoot)==null?void 0:s.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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){var s,t;return te`
|
660
660
|
<slot></slot>
|
661
|
-
<div ${
|
661
|
+
<div ${Ci(this._contentRef)} class="content">
|
662
662
|
<div class="title">
|
663
663
|
${this.subItemsActive?te`
|
664
664
|
<button class="back" @click=${this._handleBackClick}>
|
@@ -682,7 +682,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
682
682
|
</button>
|
683
683
|
`)}
|
684
684
|
</div>
|
685
|
-
`}};hn.styles=[
|
685
|
+
`}};hn.styles=[_e.styles??[],Zn(oh),Ti`
|
686
686
|
:host {
|
687
687
|
display: flex;
|
688
688
|
}
|
@@ -740,12 +740,12 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
740
740
|
height: 20px;
|
741
741
|
width: 20px;
|
742
742
|
}
|
743
|
-
`],Ia([Dt({type:Object})],hn.prototype,"items",2),Ia([Dt({type:Array})],hn.prototype,"activeItems",2),Ia([
|
743
|
+
`],Ia([Dt({type:Object})],hn.prototype,"items",2),Ia([Dt({type:Array})],hn.prototype,"activeItems",2),Ia([ki()],hn.prototype,"visibleItems",2),Ia([ki()],hn.prototype,"subItemsActive",2),hn=Ia([Fi("vmp-menu")],hn);var uA=Object.defineProperty,fA=Object.getOwnPropertyDescriptor,lh=(s,t,e,i)=>{for(var n=i>1?void 0:i?fA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&uA(t,e,n),n};let Da=class extends _e{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=Li()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var s;const t=(s=this.shadowRoot)==null?void 0:s.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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}updated(){var s,t;this.disabled?(s=this.tippy)==null||s.disable():(t=this.tippy)==null||t.enable()}render(){return te`
|
744
744
|
<slot></slot>
|
745
|
-
<div ${
|
745
|
+
<div ${Ci(this._contentRef)} class="content">
|
746
746
|
<vmp-text content=${this.content}></vmp-text>
|
747
747
|
</div>
|
748
|
-
`}};Da.styles=[
|
748
|
+
`}};Da.styles=[_e.styles??[],Zn(oh),Ti`
|
749
749
|
:host {
|
750
750
|
display: flex;
|
751
751
|
}
|
@@ -759,19 +759,19 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
759
759
|
background: var(--colors-dark-800);
|
760
760
|
border-radius: var(--radii-medium);
|
761
761
|
}
|
762
|
-
`],lh([Dt({type:String})],Da.prototype,"content",2),lh([Dt({type:Boolean})],Da.prototype,"disabled",2),Da=lh([Fi("vmp-tooltip")],Da);var pA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,ch=(s,t,e,i)=>{for(var n=i>1?void 0:i?gA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&pA(t,e,n),n};let xa=class extends
|
762
|
+
`],lh([Dt({type:String})],Da.prototype,"content",2),lh([Dt({type:Boolean})],Da.prototype,"disabled",2),Da=lh([Fi("vmp-tooltip")],Da);var pA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,ch=(s,t,e,i)=>{for(var n=i>1?void 0:i?gA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&pA(t,e,n),n};let xa=class extends _e{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=Li(),this._anchorRef=Li(),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 s;super.disconnectedCallback(),(s=this.tippy)==null||s.destroy()}render(){return te`
|
763
763
|
<vmp-icon-button
|
764
|
-
${
|
764
|
+
${Ci(this._anchorRef)}
|
765
765
|
icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
|
766
766
|
weight="heavy"
|
767
767
|
rounded="full"
|
768
768
|
@pointerdown=${s=>{this._menuOpen&&s.preventDefault()}}
|
769
769
|
@click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
|
770
770
|
></vmp-icon-button>
|
771
|
-
<div ${
|
771
|
+
<div ${Ci(this._contentRef)} class="content">
|
772
772
|
<input key="volume" type="range" min="0" max="1" step="0.01" .value=${this.volume.toString()} />
|
773
773
|
</div>
|
774
|
-
`}};xa.styles=[
|
774
|
+
`}};xa.styles=[_e.styles??[],Zn(oh),Ti`
|
775
775
|
.content {
|
776
776
|
--volume-slider-height: 4px;
|
777
777
|
--volume-slider-width: 78px;
|
@@ -899,10 +899,10 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
899
899
|
--volume-slider-height: 8px;
|
900
900
|
color: var(--colors-light-800);
|
901
901
|
}
|
902
|
-
`],ch([Dt({type:Number})],xa.prototype,"volume",2),ch([Dt({type:Boolean})],xa.prototype,"muted",2),xa=ch([Fi("vmp-volume-button")],xa);var mA=Object.defineProperty,vA=Object.getOwnPropertyDescriptor,Wo=(s,t,e,i)=>{for(var n=i>1?void 0:i?vA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&mA(t,e,n),n};let Pn=class extends
|
902
|
+
`],ch([Dt({type:Number})],xa.prototype,"volume",2),ch([Dt({type:Boolean})],xa.prototype,"muted",2),xa=ch([Fi("vmp-volume-button")],xa);var mA=Object.defineProperty,vA=Object.getOwnPropertyDescriptor,Wo=(s,t,e,i)=>{for(var n=i>1?void 0:i?vA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&mA(t,e,n),n};let Pn=class extends _e{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=Li(),this._handleContainerResize=()=>{var s;const t=(s=this._containerRef.value)==null?void 0:s.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:t,bubbles:!0,composed:!0}))},this._handleMouseEnter=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:s.clientX,y:s.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=s=>{var t;const e=(t=this._containerRef.value)==null?void 0:t.getBoundingClientRect(),i=(s.clientX-((e==null?void 0:e.left)??0))/((e==null?void 0:e.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:s.clientX,y:s.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=s=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:s.clientX,y:s.clientY},bubbles:!0,composed:!0}))}}render(){var s;const t=((s=this.buffer)==null?void 0:s.sort((e,i)=>e.start<i.start?-1:i.start<e.start?1:0).reduce((e,{start:i,end:n},o)=>{const c=e[o-1],d=Math.floor(i),f=Math.ceil(n);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 te`
|
903
903
|
<div
|
904
904
|
class="container"
|
905
|
-
${
|
905
|
+
${Ci(this._containerRef)}
|
906
906
|
${nh(this._handleContainerResize)}
|
907
907
|
@mouseenter=${this._handleMouseEnter}
|
908
908
|
@mousemove=${this._handleMouseMove}
|
@@ -922,7 +922,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
922
922
|
<div class="buffer" style=${`left: ${e.start}%; width: ${e.end-e.start}%`}></div>
|
923
923
|
`)}
|
924
924
|
</div>
|
925
|
-
`}};Pn.styles=[
|
925
|
+
`}};Pn.styles=[_e.styles??[],Ti`
|
926
926
|
:host {
|
927
927
|
--player-scrubber-height: 8px;
|
928
928
|
--player-scrubber-shadow-width: 4000px;
|
@@ -1055,7 +1055,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1055
1055
|
--player-scrubber-height: 16px;
|
1056
1056
|
color: var(--colors-light-800);
|
1057
1057
|
}
|
1058
|
-
`],Wo([Dt({type:Number})],Pn.prototype,"duration",2),Wo([Dt({type:Number})],Pn.prototype,"currentTime",2),Wo([Dt({type:Array})],Pn.prototype,"buffer",2),Pn=Wo([Fi("vmp-progress-scrubber")],Pn);var yA=Object.defineProperty,bA=Object.getOwnPropertyDescriptor,
|
1058
|
+
`],Wo([Dt({type:Number})],Pn.prototype,"duration",2),Wo([Dt({type:Number})],Pn.prototype,"currentTime",2),Wo([Dt({type:Array})],Pn.prototype,"buffer",2),Pn=Wo([Fi("vmp-progress-scrubber")],Pn);var yA=Object.defineProperty,bA=Object.getOwnPropertyDescriptor,Ri=(s,t,e,i)=>{for(var n=i>1?void 0:i?bA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&yA(t,e,n),n};let di=class extends _e{constructor(){super(...arguments),this.resizeHider=new oA(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=sh,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:s}){this.volumeMenuOpen=s}_handleLevelsMenuOpen({detail:s}){this.levelsMenuOpen=s}_handlePlaybackMenuToggle({detail:s}){this.playbackRateMenuOpen=s}_handleSettingsMenuToggle({detail:s}){this.settingsMenuOpen=s}hideMenus(){var s,t;(t=Array.from((s=this.shadowRoot)==null?void 0:s.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var s,t,e,i,n,o,c,d,f,p,g,v,A;const E=((s=this.levels)==null?void 0:s.map((U,q)=>{const At=Math.min(U.width,U.height);return{id:`level-${q.toString()}`,event:"level:click",label:`${At}p`,value:{resolution:At,level:q}}}))??[],T={title:"Quality",items:[...E.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},C=(t=T.items)==null?void 0:t.find(({value:U})=>U.level===this.level),x=["levels","playback-rate","captions","fullscreen"].filter(U=>{var q;return(q=this.controls)==null?void 0:q.includes(U)}),O={title:"Settings",items:[N4,U4,w,B4].filter(({id:U})=>x.includes(U)&&this.resizeHider.hiddenControls.includes(U))},B=(e=this.controls)==null?void 0:e.includes("progress"),D=(i=this.controls)==null?void 0:i.includes("navigation"),V=(n=this.controls)==null?void 0:n.includes("play"),$=(o=this.controls)==null?void 0:o.includes("volume"),z=(c=this.controls)==null?void 0:c.includes("current-time"),it=(d=this.controls)==null?void 0:d.includes("duration"),at=(f=this.controls)==null?void 0:f.includes("levels"),J=(p=this.controls)==null?void 0:p.includes("speed"),wt=(g=this.controls)==null?void 0:g.includes("captions"),vt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Ot=V||$||z||it||at||J||wt||vt,Gt=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return te`
|
1059
1059
|
<div
|
1060
1060
|
${this.resizeHider.measure()}
|
1061
1061
|
${this.resizeHider.contain()}
|
@@ -1185,7 +1185,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1185
1185
|
</div>
|
1186
1186
|
</div>
|
1187
1187
|
</div>
|
1188
|
-
`}};
|
1188
|
+
`}};di.styles=[_e.styles??[],Ti`
|
1189
1189
|
:host {
|
1190
1190
|
--controls-border-radius: var(--player-border-radius, 0px);
|
1191
1191
|
|
@@ -1256,17 +1256,17 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1256
1256
|
.hidden {
|
1257
1257
|
display: none;
|
1258
1258
|
}
|
1259
|
-
`],
|
1259
|
+
`],Ri([Dt({type:Boolean})],di.prototype,"playing",2),Ri([Dt({type:Number})],di.prototype,"volume",2),Ri([Dt({type:Boolean})],di.prototype,"muted",2),Ri([Dt({type:Number})],di.prototype,"currentTime",2),Ri([Dt({type:Number})],di.prototype,"duration",2),Ri([Dt({type:Number})],di.prototype,"level",2),Ri([Dt({type:Number})],di.prototype,"playbackRate",2),Ri([Dt({type:Array})],di.prototype,"buffer",2),Ri([Dt({type:Array,attribute:!1})],di.prototype,"levels",2),Ri([Dt({type:Boolean})],di.prototype,"captions",2),Ri([Dt({type:Boolean})],di.prototype,"fullscreen",2),Ri([Dt({type:Array})],di.prototype,"controls",2),Ri([ki()],di.prototype,"volumeMenuOpen",2),Ri([ki()],di.prototype,"levelsMenuOpen",2),Ri([ki()],di.prototype,"playbackRateMenuOpen",2),Ri([ki()],di.prototype,"settingsMenuOpen",2),di=Ri([Fi("vmp-player-controls")],di);var AA=Object.defineProperty,EA=Object.getOwnPropertyDescriptor,TA=(s,t,e,i)=>{for(var n=i>1?void 0:i?EA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&AA(t,e,n),n};let hh=class extends _e{render(){return te`<vmp-icon icon="loading"></vmp-icon>`}};hh.styles=[_e.styles??[],Ti`
|
1260
1260
|
:host {
|
1261
1261
|
display: flex;
|
1262
1262
|
align-items: center;
|
1263
1263
|
justify-content: center;
|
1264
1264
|
}
|
1265
|
-
`],hh=TA([Fi("vmp-loading-spinner")],hh);var kA=Object.defineProperty,wA=Object.getOwnPropertyDescriptor,Xf=(s,t,e,i)=>{for(var n=i>1?void 0:i?wA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&kA(t,e,n),n};let jo=class extends
|
1265
|
+
`],hh=TA([Fi("vmp-loading-spinner")],hh);var kA=Object.defineProperty,wA=Object.getOwnPropertyDescriptor,Xf=(s,t,e,i)=>{for(var n=i>1?void 0:i?wA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&kA(t,e,n),n};let jo=class extends _e{constructor(){super(...arguments),this.caption=""}render(){return te`
|
1266
1266
|
<div class="container">
|
1267
1267
|
<vmp-text content=${this.caption} size="large"></vmp-text>
|
1268
1268
|
</div>
|
1269
|
-
`}};jo.styles=[
|
1269
|
+
`}};jo.styles=[_e.styles??[],Ti`
|
1270
1270
|
.container {
|
1271
1271
|
display: block;
|
1272
1272
|
margin: 0 var(--space-small);
|
@@ -1285,7 +1285,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1285
1285
|
/* Line height controls the spacing between the cloned boxes so has to override the default */
|
1286
1286
|
line-height: 2.2;
|
1287
1287
|
}
|
1288
|
-
`],Xf([Dt({type:String})],jo.prototype,"caption",2),jo=Xf([Fi("vmp-captions")],jo);var SA=Object.defineProperty,RA=Object.getOwnPropertyDescriptor,
|
1288
|
+
`],Xf([Dt({type:String})],jo.prototype,"caption",2),jo=Xf([Fi("vmp-captions")],jo);var SA=Object.defineProperty,RA=Object.getOwnPropertyDescriptor,xi=(s,t,e,i)=>{for(var n=i>1?void 0:i?RA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&SA(t,e,n),n};const _A=3e3;let mi=class extends _e{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=sh,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=Li()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},_A)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(s){var t;s.has("playing")&&this.playing&&this._startHideControls(),s.has("showControls")&&this.playing&&!this.showControls&&((t=this._playerControlsRef.value)==null||t.hideMenus())}render(){var s;const t=(s=this.controls)==null?void 0:s.includes("play-large"),e=this.playing&&!this.showControls,i=!!(t&&!this.playing);return te`
|
1289
1289
|
<div
|
1290
1290
|
class=${Je({container:!0,hide:e})}
|
1291
1291
|
@mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
|
@@ -1315,7 +1315,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1315
1315
|
caption=${this.caption}
|
1316
1316
|
></vmp-captions>`:null}
|
1317
1317
|
<vmp-player-controls
|
1318
|
-
${
|
1318
|
+
${Ci(this._playerControlsRef)}
|
1319
1319
|
?playing=${this.playing}
|
1320
1320
|
?muted=${this.muted}
|
1321
1321
|
volume=${this.volume}
|
@@ -1331,7 +1331,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1331
1331
|
></vmp-player-controls>
|
1332
1332
|
</div>
|
1333
1333
|
</div>
|
1334
|
-
`}};mi.styles=[
|
1334
|
+
`}};mi.styles=[_e.styles??[],Ti`
|
1335
1335
|
:host {
|
1336
1336
|
--overlay-border-radius: var(--player-border-radius, 0px);
|
1337
1337
|
}
|
@@ -1403,7 +1403,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1403
1403
|
vmp-captions.hiddenControls {
|
1404
1404
|
transform: translateY(calc(var(--space-small) * -1));
|
1405
1405
|
}
|
1406
|
-
`],
|
1406
|
+
`],xi([Dt({type:Boolean})],mi.prototype,"loading",2),xi([Dt({type:Boolean})],mi.prototype,"playing",2),xi([Dt({type:Number})],mi.prototype,"volume",2),xi([Dt({type:Boolean})],mi.prototype,"muted",2),xi([Dt({type:Number})],mi.prototype,"currentTime",2),xi([Dt({type:Number})],mi.prototype,"duration",2),xi([Dt({type:Array,attribute:!1})],mi.prototype,"levels",2),xi([Dt({type:Number})],mi.prototype,"level",2),xi([Dt({type:Number})],mi.prototype,"playbackRate",2),xi([Dt({type:String})],mi.prototype,"caption",2),xi([Dt({type:Array})],mi.prototype,"buffer",2),xi([Dt({type:Boolean})],mi.prototype,"captions",2),xi([Dt({type:Boolean})],mi.prototype,"fullscreen",2),xi([Dt({type:Array})],mi.prototype,"controls",2),xi([ki()],mi.prototype,"showControls",2),mi=xi([Fi("vmp-player-overlay")],mi);var LA=Object.defineProperty,CA=Object.getOwnPropertyDescriptor,si=(s,t,e,i)=>{for(var n=i>1?void 0:i?CA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&LA(t,e,n),n};const IA=1e3/60;let ii=class extends _e{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Ol,this._sceneController=new M4(this),this._drawController=new lv(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._seekerTimeout=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=Li(),this._canvasRef=Li(),this._pageHidden=document.visibilityState==="hidden",this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var s;(s=this.shadowRoot)!=null&&s.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._loop=()=>{this._endLoop(),this._pageHidden?this._seekerTimeout=setTimeout(this._seeker,IA):this._seekerRAF=requestAnimationFrame(this._seeker)},this._endLoop=()=>{this._seekerRAF&&cancelAnimationFrame(this._seekerRAF),this._seekerTimeout&&clearTimeout(this._seekerTimeout),this._seekerRAF=null,this._seekerTimeout=null},this._seeker=(s=performance.now())=>{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")),s-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(s-(this._lastTimestamp??s))/1e3*this.playbackRate,this._lastTimestamp=s),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=s=>{this._errors=[...this.errors,s.error],s.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1},this._handleVisibilityChange=()=>{this._pageHidden=document.visibilityState==="hidden",this.paused||this._loop()}}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 initialised(){return this._initialised=this._initialised??new Promise(s=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&s(!1),!this.loading&&!this.processing&&this.scenes.length>0&&s(!0)},500);setTimeout(()=>{clearInterval(t),s(!1)},60*1e3)}),this._initialised}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var s;return((s=this._sceneController.scenes)==null?void 0:s.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((s,{video:t,start:e,duration:i})=>{const n=(t==null?void 0:t.key)??`${e}-${i}`;return s[n]=this.videoState[n],s},{})}set paused(s){s!==this._paused&&(this._paused=s,this.requestUpdate(),this.dispatchEvent(new CustomEvent(s?"pause":"play")))}get paused(){return this._paused}set playbackRate(s){s!==this._playbackRate&&(this._playbackRate=s,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=s)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:s})))}get playbackRate(){return this._playbackRate}set volume(s){const t=Math.min(1,Math.max(0,s));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(s){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=s)}),s!==this._muted&&(this._muted=s,localStorage.setItem("vmp-player-muted",s.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:s?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(s){s!==this._videoResolution&&(this._videoResolution=s,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===s);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(s){s!==this._drawController.currentTime&&(this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s))}get currentTime(){return this._drawController.currentTime}reset(s=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=s,this._sceneController.setVideosCurrentTime(s),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._loop()}pause(){this._endLoop(),this.paused=!0,this.scenes.forEach(({video:s})=>{s&&s.node.pause()})}draw(s){return this._drawController.draw(s)}setScene(s){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[s];if(!i){const n=new Jr(`No scene at index: ${s}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:n,message:n.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(s){s??this.fullscreen?F4():this._playerRef.value&&$4(this._playerRef.value)}connectedCallback(){var s;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(s=this.shadowRoot)!=null&&s.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(s){s.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&s.has("_processing")&&this.play()}disconnectedCallback(){var s;super.disconnectedCallback(),(s=this._observer)==null||s.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?te`
|
1407
1407
|
<style>
|
1408
1408
|
:host {
|
1409
1409
|
aspect-ratio: ${this.propAspectRatio};
|
@@ -1427,12 +1427,12 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1427
1427
|
</div>`}render(){var s,t,e,i,n,o;const c=this.loading||this.processing||!this.scenes||this.duration<=0,{height:d,width:f}=Ml({resolution:((s=this.sceneConfig)==null?void 0:s.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce((O,B)=>O.concat(this.sceneVideoState[B].buffered??[]),[]),g=c?[]:(t=this.controls??sh)==null?void 0:t.filter(O=>!(O==="fullscreen"&&P4()||O==="navigation"&&(!this.scenes||this.scenes.length<=1))),v=!(g!=null&&g.includes("preview")),A=(((e=this.scenes)==null?void 0:e.length)??0)-1,E=((i=this.scenes)==null?void 0:i.findIndex(O=>O===this._drawController.activeScenes[0]))??0,T=(o=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:o.hls,w=this.loading||this.waiting||this.processing,C=!this.src&&!this.data,x=!!this.errors.find(O=>O.fatal);return te`
|
1428
1428
|
${this._renderStyles()}
|
1429
1429
|
<div
|
1430
|
-
${
|
1430
|
+
${Ci(this._playerRef)}
|
1431
1431
|
class=${Je({player:!0,responsive:!this.propAspectRatio})}
|
1432
1432
|
style=${jl({aspectRatio:this.aspectRatio})}
|
1433
1433
|
>
|
1434
1434
|
${!w&&(C||x)?this._renderError():te`<canvas
|
1435
|
-
${
|
1435
|
+
${Ci(this._canvasRef)}
|
1436
1436
|
${this._drawController.canvas()}
|
1437
1437
|
${nh(this._handleCanvasResize)}
|
1438
1438
|
height=${d}
|
@@ -1477,7 +1477,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1477
1477
|
.compilation=${this.compilation}
|
1478
1478
|
></vmp-video-preview>`}
|
1479
1479
|
</div>
|
1480
|
-
`}};ii.styles=[
|
1480
|
+
`}};ii.styles=[_e.styles??[],Ti`
|
1481
1481
|
:host {
|
1482
1482
|
--player-border-radius: var(--vouch-media-player-border-radius, 0px);
|
1483
1483
|
|
@@ -1538,7 +1538,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1538
1538
|
top: 0;
|
1539
1539
|
left: 0;
|
1540
1540
|
}
|
1541
|
-
`],si([Dt({type:Object})],ii.prototype,"data",2),si([Dt({type:Object})],ii.prototype,"template",2),si([Dt({type:Boolean})],ii.prototype,"burnCaptions",2),si([Dt({type:Boolean})],ii.prototype,"debug",2),si([Dt({type:String})],ii.prototype,"src",2),si([Dt({type:String})],ii.prototype,"track",2),si([Dt({type:Number,attribute:"aspectratio"})],ii.prototype,"propAspectRatio",2),si([Dt({type:String})],ii.prototype,"preload",2),si([Dt({type:Boolean})],ii.prototype,"autoplay",2),si([Dt({type:Boolean})],ii.prototype,"loading",2),si([Dt({type:Array})],ii.prototype,"controls",2),si([Dt({attribute:!1})],ii.prototype,"compilation",2),si([
|
1541
|
+
`],si([Dt({type:Object})],ii.prototype,"data",2),si([Dt({type:Object})],ii.prototype,"template",2),si([Dt({type:Boolean})],ii.prototype,"burnCaptions",2),si([Dt({type:Boolean})],ii.prototype,"debug",2),si([Dt({type:String})],ii.prototype,"src",2),si([Dt({type:String})],ii.prototype,"track",2),si([Dt({type:Number,attribute:"aspectratio"})],ii.prototype,"propAspectRatio",2),si([Dt({type:String})],ii.prototype,"preload",2),si([Dt({type:Boolean})],ii.prototype,"autoplay",2),si([Dt({type:Boolean})],ii.prototype,"loading",2),si([Dt({type:Array})],ii.prototype,"controls",2),si([Dt({attribute:!1})],ii.prototype,"compilation",2),si([ki()],ii.prototype,"_pageHidden",2),si([ki()],ii.prototype,"_aspectRatio",2),si([ki()],ii.prototype,"_processing",2),si([ki()],ii.prototype,"_waiting",2),si([ki()],ii.prototype,"_errors",2),si([ki()],ii.prototype,"_seeking",2),si([ki()],ii.prototype,"_captions",2),si([ki()],ii.prototype,"_fullscreen",2),ii=si([Fi("vmp-media-player")],ii);var DA=Object.defineProperty,xA=Object.getOwnPropertyDescriptor,Ni=(s,t,e,i)=>{for(var n=i>1?void 0:i?xA(t,e):t,o=s.length-1,c;o>=0;o--)(c=s[o])&&(n=(i?c(t,e,n):c(n))||n);return i&&n&&DA(t,e,n),n};$e.PlayerEmbed=class extends vn{constructor(){super(...arguments),this._mediaPlayerRef=Li(),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new fg(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 Fg(this),this._trackingController=new Lm(this)}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get initialised(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.initialised}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)}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?te`
|
1542
1542
|
<style>
|
1543
1543
|
:host {
|
1544
1544
|
aspect-ratio: ${this.aspectRatio};
|
@@ -1554,7 +1554,7 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1554
1554
|
`}render(){return te`
|
1555
1555
|
${this._renderStyles()}
|
1556
1556
|
<vmp-media-player
|
1557
|
-
${
|
1557
|
+
${Ci(this._mediaPlayerRef)}
|
1558
1558
|
${this.eventController.register()}
|
1559
1559
|
?autoplay=${this.autoplay}
|
1560
1560
|
?loading=${this.fetching}
|
@@ -1564,9 +1564,9 @@ ${t}`,im=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),rm=Objec
|
|
1564
1564
|
preload=${Xs(this.preload)}
|
1565
1565
|
.controls=${this.controls}
|
1566
1566
|
></vmp-media-player>
|
1567
|
-
`}},$e.PlayerEmbed.styles=[
|
1567
|
+
`}},$e.PlayerEmbed.styles=[Ti`
|
1568
1568
|
:host {
|
1569
1569
|
display: flex;
|
1570
1570
|
}
|
1571
|
-
`],Ni([Dt({type:Object})],$e.PlayerEmbed.prototype,"data",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"vouchId",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"templateId",2),Ni([Dt({type:Array})],$e.PlayerEmbed.prototype,"questions",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"env",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"apiKey",2),Ni([Dt({type:Boolean})],$e.PlayerEmbed.prototype,"disableTracking",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"trackingSource",2),Ni([Dt({type:Array})],$e.PlayerEmbed.prototype,"controls",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"preload",2),Ni([Dt({type:Boolean})],$e.PlayerEmbed.prototype,"autoplay",2),Ni([Dt({type:Number})],$e.PlayerEmbed.prototype,"aspectRatio",2),Ni([Ti()],$e.PlayerEmbed.prototype,"vouch",2),Ni([Ti()],$e.PlayerEmbed.prototype,"template",2),$e.PlayerEmbed=Ni([tg("vouch-embed-player")],$e.PlayerEmbed);function Fr(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function Zf(s,t){for(var e="",i=0,n=-1,o=0,c,d=0;d<=s.length;++d){if(d<s.length)c=s.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(n===d-1||o===1))if(n!==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("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+s.slice(n+1,d):e=s.slice(n+1,d),i=d-n-1;n=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function PA(s,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+s+i:i}var On={resolve:function(){for(var t="",e=!1,i,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(i===void 0&&(i=process.cwd()),o=i),Fr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Zf(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=Zf(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?".":On.normalize(t)},relative:function(t,e){if(Fr(t),Fr(e),t===e||(t=On.resolve(t),e=On.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var n=t.length,o=n-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),E=e.charCodeAt(c+v);if(A!==E)break;A===47&&(g=v)}var T="";for(v=i+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+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,n=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){n=c;break}}else o=!1;return n===-1?i?"/":".":i&&n===1?"//":t.slice(0,n)},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,n=-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&&(n=c):(d=-1,n=f))}return i===n?n=f:n===-1&&(n=t.length),t.slice(i,n)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else n===-1&&(o=!1,n=c+1);return n===-1?"":t.slice(i,n)}},extname:function(t){Fr(t);for(var e=-1,i=0,n=-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}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||n===-1||c===0||c===1&&e===n-1&&e===i+1?"":t.slice(e,n)},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 PA("/",t)},parse:function(t){Fr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),n=i===47,o;n?(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&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(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):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};On.posix=On;var OA=On;const{basename:qf,extname:MA}=OA;class $A{constructor(){let t=(()=>typeof Ja>"u")(),e="image/png",i="image/jpeg",n="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:n,webp:o}:{png:e,jpg:i,jpeg:n,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 FA(s,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:A}=new $A,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||MA(t),w=g(v(T)||T),C=v(w),x=s.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${A})`);if(!x)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let O,B,D=t.replace(/{(\d*)}/g,($,z)=>(B=!0,z=parseInt(z,10),O=isFinite(z)?z:isFinite(O)?O:-1,"{}")),V=n>0?n-1:n<0?x+n:void 0;if(isFinite(V)&&V<0||V>=x)throw new RangeError(x==1?`Canvas only has a ‘page 1’ (${V} is out of bounds)`:`Canvas has pages 1–${x} (${V} is out of bounds)`);if(s=isFinite(V)?[s[V]]:B||w=="pdf"?s:s.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 $=(e||qf(t,T)).match(/@(\d+)x$/i);d=$?parseInt($[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:C,pages:s,padding:O,quality:o,matte:c,density:d,outline:f,archive:E}}class Ko{static for(t){return new Ko().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^i[(e^t[n])&255];return this.crc=e,this}}Ko.prototype.table=(()=>{var s,t,e,i=[];for(s=0;s<256;s++){for(e=s,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[s]=e}return i})();function dh(s){let t=new Uint8Array(s),e=new DataView(t.buffer),i={array:t,view:e,size:s,set8(n,o){return e.setUint8(n,o),i},set16(n,o){return e.setUint16(n,o,!0),i},set32(n,o){return e.setUint32(n,o,!0),i},bytes(n,o){return t.set(o,n),i}};return i}const zo=class zo{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,n=zo.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+n.length,d=c+o.length,f=16,{offset:p}=this,g=dh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ko.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=c;let v=dh(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).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:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:A})=>46+A.length+v,0),e=dh(t+22),i=0;for(var{offset:n,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,n).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"})}};A2(zo,"encoder",new TextEncoder);let uh=zo;const fh=(s,t,e,i)=>{if(i){let{width:n,height:o}=s,c=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,n,o),d.drawImage(s,0,0),s=c}return new Promise((n,o)=>s.toBlob(n,t,e))},NA=(...s)=>fh(...s).then(t=>t.arrayBuffer()),UA=async(s,t,e,i,n)=>{Qf(n,await fh(s,t,e,i))},BA=async(s,t,e,i,n,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=qf(n,".zip")||"archive",p=new uh(f);await Promise.all(s.map(async(g,v)=>{let A=d(v);await p.add(A,await fh(g,t,e,i))})),Qf(`${f}.zip`,p.blob)},Qf=(s,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",s),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:NA,asDownload:UA,asZipDownload:BA,atScale:(s,t,e)=>s.map(i=>{if(t==1&&!e)return i.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),c=i.canvas?i.canvas:i;return n.width=c.width*t,n.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(c,0,0),n}),options:FA};const{asBuffer:ph,asDownload:VA,asZipDownload:HA,atScale:gh,options:mh}=GA,Jf=Symbol.for("toDataURL"),WA=s=>{let t=Object.assign(new tp,{crossOrigin:"Anonymous",src:s});return t.decode().then(()=>t)};class jA{constructor(t,e){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>ph(i,"image/png"),jpg:()=>ph(i,"image/jpeg"),pages:()=>n.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),n.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=mh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:A,quality:E,matte:T,density:w,archive:C}=p,x=gh(p.pages,w);return v==null?VA(x[0],A,E,T,d):HA(x,A,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=mh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=gh(E,T,A)[0];return ph(w,g,v,A)},[Jf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=mh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=gh(E,T,A)[0],C=w[w===i?Jf:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:KA,CanvasGradient:zA,CanvasPattern:YA,Image:tp,ImageData:XA,Path2D:ZA,DOMMatrix:qA,DOMRect:QA,DOMPoint:JA}=window;var ep={Canvas:jA,loadImage:WA,CanvasRenderingContext2D:KA,CanvasGradient:zA,CanvasPattern:YA,Image:tp,ImageData:XA,Path2D:ZA,DOMMatrix:qA,DOMRect:QA,DOMPoint:JA};const ip=zr({__proto__:null,default:Dl(ep)},[ep]);return Object.defineProperty($e,Symbol.toStringTag,{value:"Module"}),$e}({});
|
1571
|
+
`],Ni([Dt({type:Object})],$e.PlayerEmbed.prototype,"data",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"vouchId",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"templateId",2),Ni([Dt({type:Array})],$e.PlayerEmbed.prototype,"questions",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"env",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"apiKey",2),Ni([Dt({type:Boolean})],$e.PlayerEmbed.prototype,"disableTracking",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"trackingSource",2),Ni([Dt({type:Array})],$e.PlayerEmbed.prototype,"controls",2),Ni([Dt({type:String})],$e.PlayerEmbed.prototype,"preload",2),Ni([Dt({type:Boolean})],$e.PlayerEmbed.prototype,"autoplay",2),Ni([Dt({type:Number})],$e.PlayerEmbed.prototype,"aspectRatio",2),Ni([ki()],$e.PlayerEmbed.prototype,"vouch",2),Ni([ki()],$e.PlayerEmbed.prototype,"template",2),$e.PlayerEmbed=Ni([tg("vouch-embed-player")],$e.PlayerEmbed);function Nr(s){if(typeof s!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(s))}function Zf(s,t){for(var e="",i=0,n=-1,o=0,c,d=0;d<=s.length;++d){if(d<s.length)c=s.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(n===d-1||o===1))if(n!==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("/")),n=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+s.slice(n+1,d):e=s.slice(n+1,d),i=d-n-1;n=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function PA(s,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+s+i:i}var On={resolve:function(){for(var t="",e=!1,i,n=arguments.length-1;n>=-1&&!e;n--){var o;n>=0?o=arguments[n]:(i===void 0&&(i=process.cwd()),o=i),Nr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Zf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Nr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Zf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Nr(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];Nr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":On.normalize(t)},relative:function(t,e){if(Nr(t),Nr(e),t===e||(t=On.resolve(t),e=On.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var n=t.length,o=n-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),E=e.charCodeAt(c+v);if(A!==E)break;A===47&&(g=v)}var T="";for(v=i+g+1;v<=n;++v)(v===n||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if(Nr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,n=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){n=c;break}}else o=!1;return n===-1?i?"/":".":i&&n===1?"//":t.slice(0,n)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Nr(t);var i=0,n=-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&&(n=c):(d=-1,n=f))}return i===n?n=f:n===-1&&(n=t.length),t.slice(i,n)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else n===-1&&(o=!1,n=c+1);return n===-1?"":t.slice(i,n)}},extname:function(t){Nr(t);for(var e=-1,i=0,n=-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}n===-1&&(o=!1,n=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||n===-1||c===0||c===1&&e===n-1&&e===i+1?"":t.slice(e,n)},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 PA("/",t)},parse:function(t){Nr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),n=i===47,o;n?(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&&n?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&n?(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):n&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};On.posix=On;var OA=On;const{basename:qf,extname:MA}=OA;class $A{constructor(){let t=(()=>typeof Ja>"u")(),e="image/png",i="image/jpeg",n="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:n,webp:o}:{png:e,jpg:i,jpeg:n,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 FA(s,{filename:t="",extension:e="",format:w,page:n,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:A}=new $A,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||MA(t),w=g(v(T)||T),C=v(w),x=s.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${A})`);if(!x)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let O,B,D=t.replace(/{(\d*)}/g,($,z)=>(B=!0,z=parseInt(z,10),O=isFinite(z)?z:isFinite(O)?O:-1,"{}")),V=n>0?n-1:n<0?x+n:void 0;if(isFinite(V)&&V<0||V>=x)throw new RangeError(x==1?`Canvas only has a ‘page 1’ (${V} is out of bounds)`:`Canvas has pages 1–${x} (${V} is out of bounds)`);if(s=isFinite(V)?[s[V]]:B||w=="pdf"?s:s.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 $=(e||qf(t,T)).match(/@(\d+)x$/i);d=$?parseInt($[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:C,pages:s,padding:O,quality:o,matte:c,density:d,outline:f,archive:E}}class Ko{static for(t){return new Ko().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,n=0,o=t.length|0;n<o;n++)e=e>>>8^i[(e^t[n])&255];return this.crc=e,this}}Ko.prototype.table=(()=>{var s,t,e,i=[];for(s=0;s<256;s++){for(e=s,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[s]=e}return i})();function dh(s){let t=new Uint8Array(s),e=new DataView(t.buffer),i={array:t,view:e,size:s,set8(n,o){return e.setUint8(n,o),i},set16(n,o){return e.setUint16(n,o,!0),i},set32(n,o){return e.setUint32(n,o,!0),i},bytes(n,o){return t.set(o,n),i}};return i}const zo=class zo{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,n=zo.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+n.length,d=c+o.length,f=16,{offset:p}=this,g=dh(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,Ko.for(o)).set32(14,o.length).set32(18,o.length).set16(22,n.length);p+=c;let v=dh(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,n).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:n,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:A})=>46+A.length+v,0),e=dh(t+22),i=0;for(var{offset:n,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,n).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"})}};A2(zo,"encoder",new TextEncoder);let uh=zo;const fh=(s,t,e,i)=>{if(i){let{width:n,height:o}=s,c=Object.assign(document.createElement("canvas"),{width:n,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,n,o),d.drawImage(s,0,0),s=c}return new Promise((n,o)=>s.toBlob(n,t,e))},NA=(...s)=>fh(...s).then(t=>t.arrayBuffer()),UA=async(s,t,e,i,n)=>{Qf(n,await fh(s,t,e,i))},BA=async(s,t,e,i,n,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=qf(n,".zip")||"archive",p=new uh(f);await Promise.all(s.map(async(g,v)=>{let A=d(v);await p.add(A,await fh(g,t,e,i))})),Qf(`${f}.zip`,p.blob)},Qf=(s,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",s),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:NA,asDownload:UA,asZipDownload:BA,atScale:(s,t,e)=>s.map(i=>{if(t==1&&!e)return i.canvas;let n=document.createElement("canvas"),o=n.getContext("2d"),c=i.canvas?i.canvas:i;return n.width=c.width*t,n.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,n.width,n.height)),o.scale(t,t),o.drawImage(c,0,0),n}),options:FA};const{asBuffer:ph,asDownload:VA,asZipDownload:HA,atScale:gh,options:mh}=GA,Jf=Symbol.for("toDataURL"),WA=s=>{let t=Object.assign(new tp,{crossOrigin:"Anonymous",src:s});return t.decode().then(()=>t)};class jA{constructor(t,e){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>ph(i,"image/png"),jpg:()=>ph(i,"image/jpeg"),pages:()=>n.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),n.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=mh(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:A,quality:E,matte:T,density:w,archive:C}=p,x=gh(p.pages,w);return v==null?VA(x[0],A,E,T,d):HA(x,A,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=mh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=gh(E,T,A)[0];return ph(w,g,v,A)},[Jf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=mh(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:A,pages:E,density:T}=p,w=gh(E,T,A)[0],C=w[w===i?Jf:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:KA,CanvasGradient:zA,CanvasPattern:YA,Image:tp,ImageData:XA,Path2D:ZA,DOMMatrix:qA,DOMRect:QA,DOMPoint:JA}=window;var ep={Canvas:jA,loadImage:WA,CanvasRenderingContext2D:KA,CanvasGradient:zA,CanvasPattern:YA,Image:tp,ImageData:XA,Path2D:ZA,DOMMatrix:qA,DOMRect:QA,DOMPoint:JA};const ip=Yr({__proto__:null,default:Dl(ep)},[ep]);return Object.defineProperty($e,Symbol.toStringTag,{value:"Module"}),$e}({});
|
1572
1572
|
//# sourceMappingURL=embeds.iife.js.map
|