@vouchfor/embeds 0.0.0-experiment.90d5928 → 0.0.0-experiment.90dc1dd

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. package/dist/es/browser-91e16108.js +733 -0
  2. package/dist/es/browser-91e16108.js.map +1 -0
  3. package/dist/es/embeds.js +12 -1499
  4. package/dist/es/embeds.js.map +1 -1
  5. package/dist/es/index-14de0872.js +16482 -0
  6. package/dist/es/index-14de0872.js.map +1 -0
  7. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  8. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  9. package/dist/es/src/components/DialogEmbed/index.d.ts +36 -0
  10. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  11. package/dist/es/{components/Embed → src/components/PlayerEmbed}/controllers/fetcher.d.ts +5 -4
  12. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  13. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  14. package/dist/es/{components/Embed → src/components/PlayerEmbed}/index.d.ts +28 -19
  15. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  16. package/dist/es/src/index.d.ts +2 -0
  17. package/dist/iife/dialog-embed/browser-8829205f.js +433 -0
  18. package/dist/iife/dialog-embed/browser-8829205f.js.map +1 -0
  19. package/dist/iife/dialog-embed/embed.iife.js +1722 -0
  20. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  21. package/dist/iife/dialog-embed/embed.js +5 -0
  22. package/dist/iife/dialog-embed/embed.js.map +1 -0
  23. package/dist/iife/dialog-embed/index-64277c3d.js +33265 -0
  24. package/dist/iife/dialog-embed/index-64277c3d.js.map +1 -0
  25. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  26. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  27. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +36 -0
  28. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  29. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  30. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  31. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  32. package/dist/iife/dialog-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  33. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  34. package/dist/iife/dialog-embed/src/index.d.ts +2 -0
  35. package/dist/iife/dialog-embed/src/utils/env.d.ts +12 -0
  36. package/dist/iife/dialog-embed/src/utils/events.d.ts +2 -0
  37. package/dist/iife/embeds.iife.js +642 -326
  38. package/dist/iife/embeds.iife.js.map +1 -1
  39. package/dist/iife/player-embed/browser-5865adfa.js +433 -0
  40. package/dist/iife/player-embed/browser-5865adfa.js.map +1 -0
  41. package/dist/iife/player-embed/embed.iife.js +1584 -0
  42. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  43. package/dist/iife/player-embed/embed.js +5 -0
  44. package/dist/iife/player-embed/embed.js.map +1 -0
  45. package/dist/iife/player-embed/index-653d8046.js +32820 -0
  46. package/dist/iife/player-embed/index-653d8046.js.map +1 -0
  47. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +19 -0
  48. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +35 -0
  49. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +36 -0
  50. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +15 -0
  51. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +14 -0
  52. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +36 -0
  53. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +17 -0
  54. package/dist/iife/player-embed/src/components/PlayerEmbed/index.d.ts +73 -0
  55. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +3 -0
  56. package/dist/iife/player-embed/src/index.d.ts +2 -0
  57. package/dist/iife/player-embed/src/utils/env.d.ts +12 -0
  58. package/dist/iife/player-embed/src/utils/events.d.ts +2 -0
  59. package/package.json +13 -5
  60. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  61. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  62. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  63. package/src/components/DialogEmbed/index.ts +97 -0
  64. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +27 -14
  65. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  66. package/src/components/PlayerEmbed/controllers/fetcher.ts +152 -0
  67. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  68. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  69. package/src/components/{Embed → PlayerEmbed}/index.ts +78 -27
  70. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +80 -0
  71. package/src/components/PlayerEmbed/tests/data.ts +183 -0
  72. package/src/index.ts +2 -1
  73. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -28
  74. package/dist/es/index.d.ts +0 -1
  75. package/src/components/Embed/controllers/fetcher.ts +0 -113
  76. package/src/components/Embed/controllers/tracking.ts +0 -261
  77. /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
  78. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
@@ -0,0 +1,1722 @@
1
+ var yw=Object.defineProperty;var Aw=(Qt,es,Pr)=>es in Qt?yw(Qt,es,{enumerable:!0,configurable:!0,writable:!0,value:Pr}):Qt[es]=Pr;var bg=(Qt,es,Pr)=>(Aw(Qt,typeof es!="symbol"?es+"":es,Pr),Pr);var dialogEmbed=function(Qt){var sm;"use strict";function es(r,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const n in i)if(n!=="default"&&!(n in r)){const a=Object.getOwnPropertyDescriptor(i,n);a&&Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>i[n]})}}}return Object.freeze(Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}))}/**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */const Pr=globalThis,Dl=Pr.ShadowRoot&&(Pr.ShadyCSS===void 0||Pr.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,xh=Symbol(),Th=new WeakMap;let kg=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==xh)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Dl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Th.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Th.set(t,e))}return e}toString(){return this.cssText}};const Sg=r=>new kg(typeof r=="string"?r:r+"",void 0,xh),wg=(r,e)=>{if(Dl)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=Pr.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,r.appendChild(i)}},kh=Dl?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return Sg(t)})(r):r;/**
6
+ * @license
7
+ * Copyright 2017 Google LLC
8
+ * SPDX-License-Identifier: BSD-3-Clause
9
+ */const{is:_g,defineProperty:Rg,getOwnPropertyDescriptor:Lg,getOwnPropertyNames:Cg,getOwnPropertySymbols:Ig,getPrototypeOf:Dg}=Object,As=globalThis,Sh=As.trustedTypes,Og=Sh?Sh.emptyScript:"",Ol=As.reactiveElementPolyfillSupport,Qn=(r,e)=>r,sa={toAttribute(r,e){switch(e){case Boolean:r=r?Og:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Pl=(r,e)=>!_g(r,e),wh={attribute:!0,type:String,converter:sa,reflect:!1,hasChanged:Pl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),As.litPropertyMetadata??(As.litPropertyMetadata=new WeakMap);let Jn=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=wh){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&Rg(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=Lg(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??wh}static _$Ei(){if(this.hasOwnProperty(Qn("elementProperties")))return;const e=Dg(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Qn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Qn("properties"))){const t=this.properties,i=[...Cg(t),...Ig(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(kh(n))}else e!==void 0&&t.push(kh(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$ES(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$E_??(this._$E_=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$E_)==null||t.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return wg(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:sa).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:sa;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??Pl)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!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[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$E_)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$E_)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}};Jn.elementStyles=[],Jn.shadowRootOptions={mode:"open"},Jn[Qn("elementProperties")]=new Map,Jn[Qn("finalized")]=new Map,Ol==null||Ol({ReactiveElement:Jn}),(As.reactiveElementVersions??(As.reactiveElementVersions=[])).push("2.0.2");/**
10
+ * @license
11
+ * Copyright 2017 Google LLC
12
+ * SPDX-License-Identifier: BSD-3-Clause
13
+ */const eo=globalThis,na=eo.trustedTypes,_h=na?na.createPolicy("lit-html",{createHTML:r=>r}):void 0,$l="$lit$",ts=`lit$${(Math.random()+"").slice(9)}$`,Fl="?"+ts,Pg=`<${Fl}>`,qs=document,oa=()=>qs.createComment(""),to=r=>r===null||typeof r!="object"&&typeof r!="function",Rh=Array.isArray,Lh=r=>Rh(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",Ml=`[
14
+ \f\r]`,io=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Ch=/-->/g,Ih=/>/g,Qs=RegExp(`>|${Ml}(?:([^\\s"'>=/]+)(${Ml}*=${Ml}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),Dh=/'/g,Oh=/"/g,Ph=/^(?:script|style|textarea|title)$/i,Es=Symbol.for("lit-noChange"),ii=Symbol.for("lit-nothing"),$h=new WeakMap,Js=qs.createTreeWalker(qs,129);function Fh(r,e){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return _h!==void 0?_h.createHTML(e):e}const Mh=(r,e)=>{const t=r.length-1,i=[];let n,a=e===2?"<svg>":"",l=io;for(let h=0;h<t;h++){const f=r[h];let p,m,g=-1,A=0;for(;A<f.length&&(l.lastIndex=A,m=l.exec(f),m!==null);)A=l.lastIndex,l===io?m[1]==="!--"?l=Ch:m[1]!==void 0?l=Ih:m[2]!==void 0?(Ph.test(m[2])&&(n=RegExp("</"+m[2],"g")),l=Qs):m[3]!==void 0&&(l=Qs):l===Qs?m[0]===">"?(l=n??io,g=-1):m[1]===void 0?g=-2:(g=l.lastIndex-m[2].length,p=m[1],l=m[3]===void 0?Qs:m[3]==='"'?Oh:Dh):l===Oh||l===Dh?l=Qs:l===Ch||l===Ih?l=io:(l=Qs,n=void 0);const b=l===Qs&&r[h+1].startsWith("/>")?" ":"";a+=l===io?f+Pg:g>=0?(i.push(p),f.slice(0,g)+$l+f.slice(g)+ts+b):f+ts+(g===-2?h:b)}return[Fh(r,a+(r[t]||"<?>")+(e===2?"</svg>":"")),i]};let Nl=class xg{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let a=0,l=0;const h=e.length-1,f=this.parts,[p,m]=Mh(e,t);if(this.el=xg.createElement(p,i),Js.currentNode=this.el.content,t===2){const g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(n=Js.nextNode())!==null&&f.length<h;){if(n.nodeType===1){if(n.hasAttributes())for(const g of n.getAttributeNames())if(g.endsWith($l)){const A=m[l++],b=n.getAttribute(g).split(ts),x=/([.?@])?(.*)/.exec(A);f.push({type:1,index:a,name:x[2],strings:b,ctor:x[1]==="."?Uh:x[1]==="?"?Bh:x[1]==="@"?Gh:ro}),n.removeAttribute(g)}else g.startsWith(ts)&&(f.push({type:6,index:a}),n.removeAttribute(g));if(Ph.test(n.tagName)){const g=n.textContent.split(ts),A=g.length-1;if(A>0){n.textContent=na?na.emptyScript:"";for(let b=0;b<A;b++)n.append(g[b],oa()),Js.nextNode(),f.push({type:2,index:++a});n.append(g[A],oa())}}}else if(n.nodeType===8)if(n.data===Fl)f.push({type:2,index:a});else{let g=-1;for(;(g=n.data.indexOf(ts,g+1))!==-1;)f.push({type:7,index:a}),g+=ts.length-1}a++}}static createElement(e,t){const i=qs.createElement("template");return i.innerHTML=e,i}};function en(r,e,t=r,i){var l,h;if(e===Es)return e;let n=i!==void 0?(l=t._$Co)==null?void 0:l[i]:t._$Cl;const a=to(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==a&&((h=n==null?void 0:n._$AO)==null||h.call(n,!1),a===void 0?n=void 0:(n=new a(r),n._$AT(r,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=n:t._$Cl=n),n!==void 0&&(e=en(r,n._$AS(r,e.values),n,i)),e}let Nh=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,n=((e==null?void 0:e.creationScope)??qs).importNode(t,!0);Js.currentNode=n;let a=Js.nextNode(),l=0,h=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new Ul(a,a.nextSibling,this,e):f.type===1?p=new f.ctor(a,f.name,f.strings,this,e):f.type===6&&(p=new Vh(a,this,e)),this._$AV.push(p),f=i[++h]}l!==(f==null?void 0:f.index)&&(a=Js.nextNode(),l++)}return Js.currentNode=qs,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},Ul=class Tg{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=ii,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=en(this,e,t),to(e)?e===ii||e==null||e===""?(this._$AH!==ii&&this._$AR(),this._$AH=ii):e!==this._$AH&&e!==Es&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):Lh(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==ii&&to(this._$AH)?this._$AA.nextSibling.data=e:this.$(qs.createTextNode(e)),this._$AH=e}g(e){var a;const{values:t,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Nl.createElement(Fh(i.h,i.h[0]),this.options)),i);if(((a=this._$AH)==null?void 0:a._$AD)===n)this._$AH.p(t);else{const l=new Nh(n,this),h=l.u(this.options);l.p(t),this.$(h),this._$AH=l}}_$AC(e){let t=$h.get(e.strings);return t===void 0&&$h.set(e.strings,t=new Nl(e)),t}T(e){Rh(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const a of e)n===t.length?t.push(i=new Tg(this.k(oa()),this.k(oa()),this,this.options)):i=t[n],i._$AI(a),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},ro=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,a){this.type=1,this._$AH=ii,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=ii}_$AI(e,t=this,i,n){const a=this.strings;let l=!1;if(a===void 0)e=en(this,e,t,0),l=!to(e)||e!==this._$AH&&e!==Es,l&&(this._$AH=e);else{const h=e;let f,p;for(e=a[0],f=0;f<a.length-1;f++)p=en(this,h[i+f],t,f),p===Es&&(p=this._$AH[f]),l||(l=!to(p)||p!==this._$AH[f]),p===ii?e=ii:e!==ii&&(e+=(p??"")+a[f+1]),this._$AH[f]=p}l&&!n&&this.O(e)}O(e){e===ii?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},Uh=class extends ro{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===ii?void 0:e}},Bh=class extends ro{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==ii)}},Gh=class extends ro{constructor(e,t,i,n,a){super(e,t,i,n,a),this.type=5}_$AI(e,t=this){if((e=en(this,e,t,0)??ii)===Es)return;const i=this._$AH,n=e===ii&&i!==ii||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,a=e!==ii&&(i===ii||n);n&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},Vh=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){en(this,e)}};const $g={j:$l,P:ts,A:Fl,C:1,M:Mh,L:Nh,R:Lh,V:en,D:Ul,I:ro,H:Bh,N:Gh,U:Uh,B:Vh},Bl=eo.litHtmlPolyfillSupport;Bl==null||Bl(Nl,Ul),(eo.litHtmlVersions??(eo.litHtmlVersions=[])).push("3.1.0");/**
16
+ * @license
17
+ * Copyright 2019 Google LLC
18
+ * SPDX-License-Identifier: BSD-3-Clause
19
+ */const aa=globalThis,Gl=aa.ShadowRoot&&(aa.ShadyCSS===void 0||aa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Vl=Symbol(),Hh=new WeakMap;let Wh=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==Vl)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Gl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=Hh.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Hh.set(t,e))}return e}toString(){return this.cssText}};const so=r=>new Wh(typeof r=="string"?r:r+"",void 0,Vl),ai=(r,...e)=>{const t=r.length===1?r[0]:e.reduce((i,n,a)=>i+(l=>{if(l._$cssResult$===!0)return l.cssText;if(typeof l=="number")return l;throw Error("Value passed to 'css' function must be a 'css' function result: "+l+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+r[a+1],r[0]);return new Wh(t,r,Vl)},Fg=(r,e)=>{if(Gl)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=aa.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,r.appendChild(i)}},jh=Gl?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return so(t)})(r):r;/**
20
+ * @license
21
+ * Copyright 2017 Google LLC
22
+ * SPDX-License-Identifier: BSD-3-Clause
23
+ */const{is:Mg,defineProperty:Ng,getOwnPropertyDescriptor:Ug,getOwnPropertyNames:Bg,getOwnPropertySymbols:Gg,getPrototypeOf:Vg}=Object,bs=globalThis,Kh=bs.trustedTypes,Hg=Kh?Kh.emptyScript:"",Hl=bs.reactiveElementPolyfillSupport,no=(r,e)=>r,Wl={toAttribute(r,e){switch(e){case Boolean:r=r?Hg:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},zh=(r,e)=>!Mg(r,e),Yh={attribute:!0,type:String,converter:Wl,reflect:!1,hasChanged:zh};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),bs.litPropertyMetadata??(bs.litPropertyMetadata=new WeakMap);let Tn=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Yh){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&Ng(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=Ug(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Yh}static _$Ei(){if(this.hasOwnProperty(no("elementProperties")))return;const e=Vg(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(no("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(no("properties"))){const t=this.properties,i=[...Bg(t),...Gg(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(jh(n))}else e!==void 0&&t.push(jh(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$ES(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$E_??(this._$E_=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$E_)==null||t.delete(e)}_$ES(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Fg(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$E_)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:Wl).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:Wl;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??zh)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!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[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$E_)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$E_)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}};Tn.elementStyles=[],Tn.shadowRootOptions={mode:"open"},Tn[no("elementProperties")]=new Map,Tn[no("finalized")]=new Map,Hl==null||Hl({ReactiveElement:Tn}),(bs.reactiveElementVersions??(bs.reactiveElementVersions=[])).push("2.0.2");/**
24
+ * @license
25
+ * Copyright 2017 Google LLC
26
+ * SPDX-License-Identifier: BSD-3-Clause
27
+ */const oo=globalThis,la=oo.trustedTypes,Xh=la?la.createPolicy("lit-html",{createHTML:r=>r}):void 0,Zh="$lit$",xs=`lit$${(Math.random()+"").slice(9)}$`,qh="?"+xs,Wg=`<${qh}>`,tn=document,ao=()=>tn.createComment(""),lo=r=>r===null||typeof r!="object"&&typeof r!="function",Qh=Array.isArray,jg=r=>Qh(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",jl=`[
28
+ \f\r]`,co=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Jh=/-->/g,e0=/>/g,rn=RegExp(`>|${jl}(?:([^\\s"'>=/]+)(${jl}*=${jl}*(?:[^
29
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),t0=/'/g,i0=/"/g,r0=/^(?:script|style|textarea|title)$/i,Kg=r=>(e,...t)=>({_$litType$:r,strings:e,values:t}),Qe=Kg(1),Ts=Symbol.for("lit-noChange"),pi=Symbol.for("lit-nothing"),s0=new WeakMap,sn=tn.createTreeWalker(tn,129);function n0(r,e){if(!Array.isArray(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xh!==void 0?Xh.createHTML(e):e}const zg=(r,e)=>{const t=r.length-1,i=[];let n,a=e===2?"<svg>":"",l=co;for(let h=0;h<t;h++){const f=r[h];let p,m,g=-1,A=0;for(;A<f.length&&(l.lastIndex=A,m=l.exec(f),m!==null);)A=l.lastIndex,l===co?m[1]==="!--"?l=Jh:m[1]!==void 0?l=e0:m[2]!==void 0?(r0.test(m[2])&&(n=RegExp("</"+m[2],"g")),l=rn):m[3]!==void 0&&(l=rn):l===rn?m[0]===">"?(l=n??co,g=-1):m[1]===void 0?g=-2:(g=l.lastIndex-m[2].length,p=m[1],l=m[3]===void 0?rn:m[3]==='"'?i0:t0):l===i0||l===t0?l=rn:l===Jh||l===e0?l=co:(l=rn,n=void 0);const b=l===rn&&r[h+1].startsWith("/>")?" ":"";a+=l===co?f+Wg:g>=0?(i.push(p),f.slice(0,g)+Zh+f.slice(g)+xs+b):f+xs+(g===-2?h:b)}return[n0(r,a+(r[t]||"<?>")+(e===2?"</svg>":"")),i]};class uo{constructor({strings:e,_$litType$:t},i){let n;this.parts=[];let a=0,l=0;const h=e.length-1,f=this.parts,[p,m]=zg(e,t);if(this.el=uo.createElement(p,i),sn.currentNode=this.el.content,t===2){const g=this.el.content.firstChild;g.replaceWith(...g.childNodes)}for(;(n=sn.nextNode())!==null&&f.length<h;){if(n.nodeType===1){if(n.hasAttributes())for(const g of n.getAttributeNames())if(g.endsWith(Zh)){const A=m[l++],b=n.getAttribute(g).split(xs),x=/([.?@])?(.*)/.exec(A);f.push({type:1,index:a,name:x[2],strings:b,ctor:x[1]==="."?Xg:x[1]==="?"?Zg:x[1]==="@"?qg:ca}),n.removeAttribute(g)}else g.startsWith(xs)&&(f.push({type:6,index:a}),n.removeAttribute(g));if(r0.test(n.tagName)){const g=n.textContent.split(xs),A=g.length-1;if(A>0){n.textContent=la?la.emptyScript:"";for(let b=0;b<A;b++)n.append(g[b],ao()),sn.nextNode(),f.push({type:2,index:++a});n.append(g[A],ao())}}}else if(n.nodeType===8)if(n.data===qh)f.push({type:2,index:a});else{let g=-1;for(;(g=n.data.indexOf(xs,g+1))!==-1;)f.push({type:7,index:a}),g+=xs.length-1}a++}}static createElement(e,t){const i=tn.createElement("template");return i.innerHTML=e,i}}function kn(r,e,t=r,i){var l,h;if(e===Ts)return e;let n=i!==void 0?(l=t._$Co)==null?void 0:l[i]:t._$Cl;const a=lo(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==a&&((h=n==null?void 0:n._$AO)==null||h.call(n,!1),a===void 0?n=void 0:(n=new a(r),n._$AT(r,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=n:t._$Cl=n),n!==void 0&&(e=kn(r,n._$AS(r,e.values),n,i)),e}let Yg=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:i}=this._$AD,n=((e==null?void 0:e.creationScope)??tn).importNode(t,!0);sn.currentNode=n;let a=sn.nextNode(),l=0,h=0,f=i[0];for(;f!==void 0;){if(l===f.index){let p;f.type===2?p=new ho(a,a.nextSibling,this,e):f.type===1?p=new f.ctor(a,f.name,f.strings,this,e):f.type===6&&(p=new Qg(a,this,e)),this._$AV.push(p),f=i[++h]}l!==(f==null?void 0:f.index)&&(a=sn.nextNode(),l++)}return sn.currentNode=tn,n}p(e){let t=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}};class ho{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,n){this.type=2,this._$AH=pi,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=kn(this,e,t),lo(e)?e===pi||e==null||e===""?(this._$AH!==pi&&this._$AR(),this._$AH=pi):e!==this._$AH&&e!==Ts&&this._(e):e._$litType$!==void 0?this.g(e):e.nodeType!==void 0?this.$(e):jg(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==pi&&lo(this._$AH)?this._$AA.nextSibling.data=e:this.$(tn.createTextNode(e)),this._$AH=e}g(e){var a;const{values:t,_$litType$:i}=e,n=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=uo.createElement(n0(i.h,i.h[0]),this.options)),i);if(((a=this._$AH)==null?void 0:a._$AD)===n)this._$AH.p(t);else{const l=new Yg(n,this),h=l.u(this.options);l.p(t),this.$(h),this._$AH=l}}_$AC(e){let t=s0.get(e.strings);return t===void 0&&s0.set(e.strings,t=new uo(e)),t}T(e){Qh(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,n=0;for(const a of e)n===t.length?t.push(i=new ho(this.k(ao()),this.k(ao()),this,this.options)):i=t[n],i._$AI(a),n++;n<t.length&&(this._$AR(i&&i._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e&&e!==this._$AB;){const n=e.nextSibling;e.remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}}class ca{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,n,a){this.type=1,this._$AH=pi,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=a,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=pi}_$AI(e,t=this,i,n){const a=this.strings;let l=!1;if(a===void 0)e=kn(this,e,t,0),l=!lo(e)||e!==this._$AH&&e!==Ts,l&&(this._$AH=e);else{const h=e;let f,p;for(e=a[0],f=0;f<a.length-1;f++)p=kn(this,h[i+f],t,f),p===Ts&&(p=this._$AH[f]),l||(l=!lo(p)||p!==this._$AH[f]),p===pi?e=pi:e!==pi&&(e+=(p??"")+a[f+1]),this._$AH[f]=p}l&&!n&&this.O(e)}O(e){e===pi?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class Xg extends ca{constructor(){super(...arguments),this.type=3}O(e){this.element[this.name]=e===pi?void 0:e}}class Zg extends ca{constructor(){super(...arguments),this.type=4}O(e){this.element.toggleAttribute(this.name,!!e&&e!==pi)}}class qg extends ca{constructor(e,t,i,n,a){super(e,t,i,n,a),this.type=5}_$AI(e,t=this){if((e=kn(this,e,t,0)??pi)===Ts)return;const i=this._$AH,n=e===pi&&i!==pi||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,a=e!==pi&&(i===pi||n);n&&this.element.removeEventListener(this.name,this,i),a&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}}class Qg{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){kn(this,e)}}const Kl=oo.litHtmlPolyfillSupport;Kl==null||Kl(uo,ho),(oo.litHtmlVersions??(oo.litHtmlVersions=[])).push("3.1.0");const Jg=(r,e,t)=>{const i=(t==null?void 0:t.renderBefore)??e;let n=i._$litPart$;if(n===void 0){const a=(t==null?void 0:t.renderBefore)??null;i._$litPart$=n=new ho(e.insertBefore(ao(),a),a,void 0,t??{})}return n._$AI(r),n};/**
30
+ * @license
31
+ * Copyright 2017 Google LLC
32
+ * SPDX-License-Identifier: BSD-3-Clause
33
+ */let is=class extends Tn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;const e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Jg(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Ts}};is._$litElement$=!0,is.finalized=!0,(sm=globalThis.litElementHydrateSupport)==null||sm.call(globalThis,{LitElement:is});const zl=globalThis.litElementPolyfillSupport;zl==null||zl({LitElement:is}),(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.0.2");/**
34
+ * @license
35
+ * Copyright 2017 Google LLC
36
+ * SPDX-License-Identifier: BSD-3-Clause
37
+ */const ua=r=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(r,e)}):customElements.define(r,e)};/**
38
+ * @license
39
+ * Copyright 2017 Google LLC
40
+ * SPDX-License-Identifier: BSD-3-Clause
41
+ */const e2={attribute:!0,type:String,converter:sa,reflect:!1,hasChanged:Pl},t2=(r=e2,e,t)=>{const{kind:i,metadata:n}=t;let a=globalThis.litPropertyMetadata.get(n);if(a===void 0&&globalThis.litPropertyMetadata.set(n,a=new Map),a.set(t.name,r),i==="accessor"){const{name:l}=t;return{set(h){const f=e.get.call(this);e.set.call(this,h),this.requestUpdate(l,f,r)},init(h){return h!==void 0&&this.C(l,void 0,r),h}}}if(i==="setter"){const{name:l}=t;return function(h){const f=this[l];e.call(this,h),this.requestUpdate(l,f,r)}}throw Error("Unsupported decorator location: "+i)};function be(r){return(e,t)=>typeof t=="object"?t2(r,e,t):((i,n,a)=>{const l=n.hasOwnProperty(a);return n.constructor.createProperty(a,l?{...i,wrapped:!0}:i),l?Object.getOwnPropertyDescriptor(n,a):void 0})(r,e,t)}/**
42
+ * @license
43
+ * Copyright 2017 Google LLC
44
+ * SPDX-License-Identifier: BSD-3-Clause
45
+ */function mi(r){return be({...r,state:!0,attribute:!1})}/**
46
+ * @license
47
+ * Copyright 2018 Google LLC
48
+ * SPDX-License-Identifier: BSD-3-Clause
49
+ */const li=r=>r??ii;let ha;const i2=new Uint8Array(16);function r2(){if(!ha&&(ha=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ha))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ha(i2)}const Ti=[];for(let r=0;r<256;++r)Ti.push((r+256).toString(16).slice(1));function s2(r,e=0){return Ti[r[e+0]]+Ti[r[e+1]]+Ti[r[e+2]]+Ti[r[e+3]]+"-"+Ti[r[e+4]]+Ti[r[e+5]]+"-"+Ti[r[e+6]]+Ti[r[e+7]]+"-"+Ti[r[e+8]]+Ti[r[e+9]]+"-"+Ti[r[e+10]]+Ti[r[e+11]]+Ti[r[e+12]]+Ti[r[e+13]]+Ti[r[e+14]]+Ti[r[e+15]]}const o0={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function ks(r,e,t){if(o0.randomUUID&&!e&&!r)return o0.randomUUID();r=r||{};const i=r.random||(r.rng||r2)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return s2(i)}/**
50
+ * @license
51
+ * Copyright 2020 Google LLC
52
+ * SPDX-License-Identifier: BSD-3-Clause
53
+ */const{D:n2}=$g,o2=r=>r.strings===void 0,a0=()=>document.createComment(""),fo=(r,e,t)=>{var a;const i=r._$AA.parentNode,n=e===void 0?r._$AB:e._$AA;if(t===void 0){const l=i.insertBefore(a0(),n),h=i.insertBefore(a0(),n);t=new n2(l,h,r,r.options)}else{const l=t._$AB.nextSibling,h=t._$AM,f=h!==r;if(f){let p;(a=t._$AQ)==null||a.call(t,r),t._$AM=r,t._$AP!==void 0&&(p=r._$AU)!==h._$AU&&t._$AP(p)}if(l!==n||f){let p=t._$AA;for(;p!==l;){const m=p.nextSibling;i.insertBefore(p,n),p=m}}}return t},nn=(r,e,t=r)=>(r._$AI(e,t),r),a2={},l2=(r,e=a2)=>r._$AH=e,c2=r=>r._$AH,Yl=r=>{var i;(i=r._$AP)==null||i.call(r,!1,!0);let e=r._$AA;const t=r._$AB.nextSibling;for(;e!==t;){const n=e.nextSibling;e.remove(),e=n}};/**
54
+ * @license
55
+ * Copyright 2017 Google LLC
56
+ * SPDX-License-Identifier: BSD-3-Clause
57
+ */const Sn={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},wn=r=>(...e)=>({_$litDirective$:r,values:e});let po=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}};/**
58
+ * @license
59
+ * Copyright 2017 Google LLC
60
+ * SPDX-License-Identifier: BSD-3-Clause
61
+ */const mo=(r,e)=>{var i;const t=r._$AN;if(t===void 0)return!1;for(const n of t)(i=n._$AO)==null||i.call(n,e,!1),mo(n,e);return!0},da=r=>{let e,t;do{if((e=r._$AM)===void 0)break;t=e._$AN,t.delete(r),r=e}while((t==null?void 0:t.size)===0)},l0=r=>{for(let e;e=r._$AM;r=e){let t=e._$AN;if(t===void 0)e._$AN=t=new Set;else if(t.has(r))break;t.add(r),d2(e)}};function u2(r){this._$AN!==void 0?(da(this),this._$AM=r,l0(this)):this._$AM=r}function h2(r,e=!1,t=0){const i=this._$AH,n=this._$AN;if(n!==void 0&&n.size!==0)if(e)if(Array.isArray(i))for(let a=t;a<i.length;a++)mo(i[a],!1),da(i[a]);else i!=null&&(mo(i,!1),da(i));else mo(this,r)}const d2=r=>{r.type==Sn.CHILD&&(r._$AP??(r._$AP=h2),r._$AQ??(r._$AQ=u2))};let c0=class extends po{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,t,i){super._$AT(e,t,i),l0(this),this.isConnected=e._$AU}_$AO(e,t=!0){var i,n;e!==this.isConnected&&(this.isConnected=e,e?(i=this.reconnected)==null||i.call(this):(n=this.disconnected)==null||n.call(this)),t&&(mo(this,e),da(this))}setValue(e){if(o2(this._$Ct))this._$Ct._$AI(e,this);else{const t=[...this._$Ct._$AH];t[this._$Ci]=e,this._$Ct._$AI(t,this,0)}}disconnected(){}reconnected(){}};/**
62
+ * @license
63
+ * Copyright 2020 Google LLC
64
+ * SPDX-License-Identifier: BSD-3-Clause
65
+ */const ki=()=>new f2;let f2=class{};const Xl=new WeakMap,Si=wn(class extends c0{render(r){return ii}update(r,[e]){var i;const t=e!==this.G;return t&&this.G!==void 0&&this.ot(void 0),(t||this.rt!==this.lt)&&(this.G=e,this.ct=(i=r.options)==null?void 0:i.host,this.ot(this.lt=r.element)),ii}ot(r){if(typeof this.G=="function"){const e=this.ct??globalThis;let t=Xl.get(e);t===void 0&&(t=new WeakMap,Xl.set(e,t)),t.get(this.G)!==void 0&&this.G.call(this.ct,void 0),t.set(this.G,r),r!==void 0&&this.G.call(this.ct,r)}else this.G.value=r}get rt(){var r,e;return typeof this.G=="function"?(r=Xl.get(this.ct??globalThis))==null?void 0:r.get(this.G):(e=this.G)==null?void 0:e.value}disconnected(){this.rt===this.lt&&this.ot(void 0)}reconnected(){this.ot(this.lt)}});function p2(r,e,t){function i(n){t.dispatchEvent(new CustomEvent(n.type,n))}return e.addEventListener(r,i),()=>{e.removeEventListener(r,i)}}class m2{constructor(e,t){this._events=[],this._cleanup=[],this._forwardElementRef=ki(),this.host=e,this._events=t,e.addController(this)}register(){return Si(this._forwardElementRef)}hostConnected(){requestAnimationFrame(()=>{this._events.forEach(e=>{this._forwardElementRef.value&&this._cleanup.push(p2(e,this._forwardElementRef.value,this.host))})})}hostDisconnected(){this._cleanup.forEach(e=>{e()}),this._cleanup=[]}}/**
66
+ * @license
67
+ * Copyright 2019 Google LLC
68
+ * SPDX-License-Identifier: BSD-3-Clause
69
+ */const fa=globalThis,Zl=fa.ShadowRoot&&(fa.ShadyCSS===void 0||fa.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,u0=Symbol(),h0=new WeakMap;let g2=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==u0)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Zl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=h0.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&h0.set(t,e))}return e}toString(){return this.cssText}};const v2=r=>new g2(typeof r=="string"?r:r+"",void 0,u0),y2=(r,e)=>{if(Zl)r.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),n=fa.litNonce;n!==void 0&&i.setAttribute("nonce",n),i.textContent=t.cssText,r.appendChild(i)}},d0=Zl?r=>r:r=>r instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return v2(t)})(r):r;/**
70
+ * @license
71
+ * Copyright 2017 Google LLC
72
+ * SPDX-License-Identifier: BSD-3-Clause
73
+ */const{is:A2,defineProperty:E2,getOwnPropertyDescriptor:b2,getOwnPropertyNames:x2,getOwnPropertySymbols:T2,getPrototypeOf:k2}=Object,Ss=globalThis,f0=Ss.trustedTypes,S2=f0?f0.emptyScript:"",ql=Ss.reactiveElementPolyfillSupport,go=(r,e)=>r,Ql={toAttribute(r,e){switch(e){case Boolean:r=r?S2:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,e){let t=r;switch(e){case Boolean:t=r!==null;break;case Number:t=r===null?null:Number(r);break;case Object:case Array:try{t=JSON.parse(r)}catch{t=null}}return t}},Jl=(r,e)=>!A2(r,e),p0={attribute:!0,type:String,converter:Ql,reflect:!1,hasChanged:Jl};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Ss.litPropertyMetadata??(Ss.litPropertyMetadata=new WeakMap);class vo extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=p0){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),n=this.getPropertyDescriptor(e,i,t);n!==void 0&&E2(this.prototype,e,n)}}static getPropertyDescriptor(e,t,i){const{get:n,set:a}=b2(this.prototype,e)??{get(){return this[t]},set(l){this[t]=l}};return{get(){return n==null?void 0:n.call(this)},set(l){const h=n==null?void 0:n.call(this);a.call(this,l),this.requestUpdate(e,h,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??p0}static _$Ei(){if(this.hasOwnProperty(go("elementProperties")))return;const e=k2(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(go("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(go("properties"))){const t=this.properties,i=[...x2(t),...T2(t)];for(const n of i)this.createProperty(n,t[n])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,n]of t)this.elementProperties.set(i,n)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const n=this._$Eu(t,i);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const n of i)t.unshift(d0(n))}else e!==void 0&&t.push(d0(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$Eg=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$ES??(this._$ES=[])).push(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$ES)==null||t.splice(this._$ES.indexOf(e)>>>0,1)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return y2(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$ES)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$ES)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t){var a;const i=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,i);if(n!==void 0&&i.reflect===!0){const l=(((a=i.converter)==null?void 0:a.toAttribute)!==void 0?i.converter:Ql).toAttribute(t,i.type);this._$Em=e,l==null?this.removeAttribute(n):this.setAttribute(n,l),this._$Em=null}}_$AK(e,t){var a;const i=this.constructor,n=i._$Eh.get(e);if(n!==void 0&&this._$Em!==n){const l=i.getPropertyOptions(n),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((a=l.converter)==null?void 0:a.fromAttribute)!==void 0?l.converter:Ql;this._$Em=n,this[n]=h.fromAttribute(t,l.type),this._$Em=null}}requestUpdate(e,t,i,n=!1,a){if(e!==void 0){if(i??(i=this.constructor.getPropertyOptions(e)),!(i.hasChanged??Jl)(n?a:this[e],t))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$Eg=this._$EP())}C(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??(this._$Ej=new Set)).add(e)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[a,l]of this._$Ep)this[a]=l;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[a,l]of n)l.wrapped!==!0||this._$AL.has(a)||this[a]===void 0||this.C(a,this[a],l)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$ES)==null||i.forEach(n=>{var a;return(a=n.hostUpdate)==null?void 0:a.call(n)}),this.update(t)):this._$ET()}catch(n){throw e=!1,this._$ET(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$ES)==null||t.forEach(i=>{var n;return(n=i.hostUpdated)==null?void 0:n.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(e){return!0}update(e){this._$Ej&&(this._$Ej=this._$Ej.forEach(t=>this._$EO(t,this[t]))),this._$ET()}updated(e){}firstUpdated(e){}}vo.elementStyles=[],vo.shadowRootOptions={mode:"open"},vo[go("elementProperties")]=new Map,vo[go("finalized")]=new Map,ql==null||ql({ReactiveElement:vo}),(Ss.reactiveElementVersions??(Ss.reactiveElementVersions=[])).push("2.0.0");/**
74
+ * @license
75
+ * Copyright 2017 Google LLC
76
+ * SPDX-License-Identifier: BSD-3-Clause
77
+ */const w2=Symbol();class pa{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((e,t)=>{this.i=e,this.o=t}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(e,t,i){var a;this.u=0,this.status=0,(this.p=e).addController(this);const n=typeof t=="object"?t:{task:t,args:i};this._=n.task,this.v=n.args,this.j=n.argsEqual??_2,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=(a=this.A)==null?void 0:a.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const e=this.v();if(!Array.isArray(e))throw Error("The args function must return an array");return e}async O(){const e=this.A(),t=this.k;this.k=e,e===t||e===void 0||t!==void 0&&this.j(t,e)||await this.run(e)}async run(e){var l,h,f,p,m;let t,i;e??(e=this.A()),this.k=e,this.status===1?(l=this.T)==null||l.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 a=!1;try{t=await this._(e,{signal:this.T.signal})}catch(g){a=!0,i=g}if(this.u===n){if(t===w2)this.status=0;else{if(a===!1){try{(h=this.m)==null||h.call(this,t)}catch{}this.status=2,(f=this.i)==null||f.call(this,t)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(m=this.o)==null||m.call(this,i)}this.l=t,this.h=i}this.p.requestUpdate()}}abort(e){var t;this.status===1&&((t=this.T)==null||t.abort(e))}get value(){return this.l}get error(){return this.h}render(e){var t,i,n,a;switch(this.status){case 0:return(t=e.initial)==null?void 0:t.call(e);case 1:return(i=e.pending)==null?void 0:i.call(e);case 2:return(n=e.complete)==null?void 0:n.call(e,this.value);case 3:return(a=e.error)==null?void 0:a.call(e,this.error);default:throw Error("Unexpected status: "+this.status)}}}const _2=(r,e)=>r===e||r.length===e.length&&r.every((t,i)=>!Jl(t,e[i])),m0="https://d2rxhdlm2q91uk.cloudfront.net",R2="https://d1ix11aj5kfygl.cloudfront.net",L2="https://d157jlwnudd93d.cloudfront.net",g0="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",C2="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",I2="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",D2="http://localhost:6060/v2",O2="https://embed-dev.vouchfor.com/v2",P2="https://embed-staging.vouchfor.com/v2",$2="https://embed.vouchfor.com/v2";function ma(r){if(!["local","dev","staging","prod"].includes(r))throw new Error(`Unknown environment: ${r}`);if(r==="local")return{videoUrl:m0,publicApiUrl:g0,embedApiUrl:D2};if(r==="dev")return{videoUrl:m0,publicApiUrl:g0,embedApiUrl:O2};if(r==="staging")return{videoUrl:R2,publicApiUrl:C2,embedApiUrl:P2};if(r==="prod")return{videoUrl:L2,publicApiUrl:I2,embedApiUrl:$2}}class F2{constructor(e){this._fetching=!1,this.getVouch=async(t,i,n)=>{var m;const{embedApiUrl:a}=ma(t),l=ks(),h=await fetch(`${a}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),f=await h.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:f==null?void 0:f.id})),((m=h==null?void 0:h.headers)==null?void 0:m.get("X-Cache-Check"))!==l&&fetch(`${a}/vouches/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(t,i,n)=>{var m;const{embedApiUrl:a}=ma(t),l=ks(),h=await fetch(`${a}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",l]]}),f=await h.json();return((m=h==null?void 0:h.headers)==null?void 0:m.get("X-Cache-Check"))!==l&&fetch(`${a}/templates/${n}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=e,new pa(this.host,async([t,i,n,a,l])=>{var h,f,p,m;try{if(e.vouch=void 0,e.template=void 0,n){let g;l&&(this.fetching=!0,g=await this.getTemplate(t,i,l)),this._vouch=n,e.template=g??((f=(h=n==null?void 0:n.settings)==null?void 0:h.template)==null?void 0:f.instance)}else if(a){this.fetching=!0;const[g,A]=await Promise.all([this.getVouch(t,i,a),l?this.getTemplate(t,i,l):null]);this._vouch=g,e.template=A??((m=(p=g==null?void 0:g.settings)==null?void 0:p.template)==null?void 0:m.instance)}}finally{this.fetching=!1}},()=>[e.env,e.apiKey,e.data,e.vouchId,e.templateId]),new pa(this.host,([t,i])=>{e.vouch=t?{...t,questions:{items:t==null?void 0:t.questions.items.filter((n,a)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(a+1)))}}:void 0},()=>[this._vouch,e.questions])}set fetching(e){this._fetching!==e&&(this._fetching=e,this.host.requestUpdate())}get fetching(){return this._fetching}}const M2=(r,e,t,i)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const n=Object.getOwnPropertyDescriptor(r,t),a=Object.getOwnPropertyDescriptor(e,t);!N2(n,a)&&i||Object.defineProperty(r,t,a)},N2=function(r,e){return r===void 0||r.configurable||r.writable===e.writable&&r.enumerable===e.enumerable&&r.configurable===e.configurable&&(r.writable||r.value===e.value)},U2=(r,e)=>{const t=Object.getPrototypeOf(e);t!==Object.getPrototypeOf(r)&&Object.setPrototypeOf(r,t)},B2=(r,e)=>`/* Wrapped ${r}*/
78
+ ${e}`,G2=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),V2=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),H2=(r,e,t)=>{const i=t===""?"":`with ${t.trim()}() `,n=B2.bind(null,i,e.toString());Object.defineProperty(n,"name",V2),Object.defineProperty(r,"toString",{...G2,value:n})};function W2(r,e,{ignoreNonConfigurable:t=!1}={}){const{name:i}=r;for(const n of Reflect.ownKeys(e))M2(r,e,n,t);return U2(r,e),H2(r,e,i),r}const j2=new WeakMap,v0=new WeakMap;function ec(r,{cacheKey:e,cache:t=new Map,maxAge:i}={}){if(i===0)return r;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(...a){var p;const l=e?e(a):a[0],h=t.get(l);if(h)return h.data;const f=r.apply(this,a);if(t.set(l,{data:f,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const m=setTimeout(()=>{t.delete(l)},i);(p=m.unref)==null||p.call(m);const g=v0.get(r)??new Set;g.add(m),v0.set(r,g)}return f};return W2(n,r,{ignoreNonConfigurable:!0}),j2.set(n,t),n}var ga=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function va(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var xt={},tc={},nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.default=nt.Wrap=nt.Unit=nt.PrintOptions=nt.PositionType=nt.Overflow=nt.NodeType=nt.MeasureMode=nt.LogLevel=nt.Justify=nt.Gutter=nt.FlexDirection=nt.ExperimentalFeature=nt.Errata=nt.Edge=nt.Display=nt.Direction=nt.Dimension=nt.Align=void 0;let rs=function(r){return r[r.Auto=0]="Auto",r[r.FlexStart=1]="FlexStart",r[r.Center=2]="Center",r[r.FlexEnd=3]="FlexEnd",r[r.Stretch=4]="Stretch",r[r.Baseline=5]="Baseline",r[r.SpaceBetween=6]="SpaceBetween",r[r.SpaceAround=7]="SpaceAround",r}({});nt.Align=rs;let ic=function(r){return r[r.Width=0]="Width",r[r.Height=1]="Height",r}({});nt.Dimension=ic;let ya=function(r){return r[r.Inherit=0]="Inherit",r[r.LTR=1]="LTR",r[r.RTL=2]="RTL",r}({});nt.Direction=ya;let rc=function(r){return r[r.Flex=0]="Flex",r[r.None=1]="None",r}({});nt.Display=rc;let $r=function(r){return r[r.Left=0]="Left",r[r.Top=1]="Top",r[r.Right=2]="Right",r[r.Bottom=3]="Bottom",r[r.Start=4]="Start",r[r.End=5]="End",r[r.Horizontal=6]="Horizontal",r[r.Vertical=7]="Vertical",r[r.All=8]="All",r}({});nt.Edge=$r;let yo=function(r){return r[r.None=0]="None",r[r.StretchFlexBasis=1]="StretchFlexBasis",r[r.All=2147483647]="All",r[r.Classic=2147483646]="Classic",r}({});nt.Errata=yo;let Aa=function(r){return r[r.WebFlexBasis=0]="WebFlexBasis",r[r.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",r[r.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",r}({});nt.ExperimentalFeature=Aa;let Ao=function(r){return r[r.Column=0]="Column",r[r.ColumnReverse=1]="ColumnReverse",r[r.Row=2]="Row",r[r.RowReverse=3]="RowReverse",r}({});nt.FlexDirection=Ao;let Ea=function(r){return r[r.Column=0]="Column",r[r.Row=1]="Row",r[r.All=2]="All",r}({});nt.Gutter=Ea;let on=function(r){return r[r.FlexStart=0]="FlexStart",r[r.Center=1]="Center",r[r.FlexEnd=2]="FlexEnd",r[r.SpaceBetween=3]="SpaceBetween",r[r.SpaceAround=4]="SpaceAround",r[r.SpaceEvenly=5]="SpaceEvenly",r}({});nt.Justify=on;let an=function(r){return r[r.Error=0]="Error",r[r.Warn=1]="Warn",r[r.Info=2]="Info",r[r.Debug=3]="Debug",r[r.Verbose=4]="Verbose",r[r.Fatal=5]="Fatal",r}({});nt.LogLevel=an;let ba=function(r){return r[r.Undefined=0]="Undefined",r[r.Exactly=1]="Exactly",r[r.AtMost=2]="AtMost",r}({});nt.MeasureMode=ba;let sc=function(r){return r[r.Default=0]="Default",r[r.Text=1]="Text",r}({});nt.NodeType=sc;let xa=function(r){return r[r.Visible=0]="Visible",r[r.Hidden=1]="Hidden",r[r.Scroll=2]="Scroll",r}({});nt.Overflow=xa;let Ta=function(r){return r[r.Static=0]="Static",r[r.Relative=1]="Relative",r[r.Absolute=2]="Absolute",r}({});nt.PositionType=Ta;let ka=function(r){return r[r.Layout=1]="Layout",r[r.Style=2]="Style",r[r.Children=4]="Children",r}({});nt.PrintOptions=ka;let Eo=function(r){return r[r.Undefined=0]="Undefined",r[r.Point=1]="Point",r[r.Percent=2]="Percent",r[r.Auto=3]="Auto",r}({});nt.Unit=Eo;let Sa=function(r){return r[r.NoWrap=0]="NoWrap",r[r.Wrap=1]="Wrap",r[r.WrapReverse=2]="WrapReverse",r}({});nt.Wrap=Sa;var K2={ALIGN_AUTO:rs.Auto,ALIGN_FLEX_START:rs.FlexStart,ALIGN_CENTER:rs.Center,ALIGN_FLEX_END:rs.FlexEnd,ALIGN_STRETCH:rs.Stretch,ALIGN_BASELINE:rs.Baseline,ALIGN_SPACE_BETWEEN:rs.SpaceBetween,ALIGN_SPACE_AROUND:rs.SpaceAround,DIMENSION_WIDTH:ic.Width,DIMENSION_HEIGHT:ic.Height,DIRECTION_INHERIT:ya.Inherit,DIRECTION_LTR:ya.LTR,DIRECTION_RTL:ya.RTL,DISPLAY_FLEX:rc.Flex,DISPLAY_NONE:rc.None,EDGE_LEFT:$r.Left,EDGE_TOP:$r.Top,EDGE_RIGHT:$r.Right,EDGE_BOTTOM:$r.Bottom,EDGE_START:$r.Start,EDGE_END:$r.End,EDGE_HORIZONTAL:$r.Horizontal,EDGE_VERTICAL:$r.Vertical,EDGE_ALL:$r.All,ERRATA_NONE:yo.None,ERRATA_STRETCH_FLEX_BASIS:yo.StretchFlexBasis,ERRATA_ALL:yo.All,ERRATA_CLASSIC:yo.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:Aa.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:Aa.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:Aa.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:Ao.Column,FLEX_DIRECTION_COLUMN_REVERSE:Ao.ColumnReverse,FLEX_DIRECTION_ROW:Ao.Row,FLEX_DIRECTION_ROW_REVERSE:Ao.RowReverse,GUTTER_COLUMN:Ea.Column,GUTTER_ROW:Ea.Row,GUTTER_ALL:Ea.All,JUSTIFY_FLEX_START:on.FlexStart,JUSTIFY_CENTER:on.Center,JUSTIFY_FLEX_END:on.FlexEnd,JUSTIFY_SPACE_BETWEEN:on.SpaceBetween,JUSTIFY_SPACE_AROUND:on.SpaceAround,JUSTIFY_SPACE_EVENLY:on.SpaceEvenly,LOG_LEVEL_ERROR:an.Error,LOG_LEVEL_WARN:an.Warn,LOG_LEVEL_INFO:an.Info,LOG_LEVEL_DEBUG:an.Debug,LOG_LEVEL_VERBOSE:an.Verbose,LOG_LEVEL_FATAL:an.Fatal,MEASURE_MODE_UNDEFINED:ba.Undefined,MEASURE_MODE_EXACTLY:ba.Exactly,MEASURE_MODE_AT_MOST:ba.AtMost,NODE_TYPE_DEFAULT:sc.Default,NODE_TYPE_TEXT:sc.Text,OVERFLOW_VISIBLE:xa.Visible,OVERFLOW_HIDDEN:xa.Hidden,OVERFLOW_SCROLL:xa.Scroll,POSITION_TYPE_STATIC:Ta.Static,POSITION_TYPE_RELATIVE:Ta.Relative,POSITION_TYPE_ABSOLUTE:Ta.Absolute,PRINT_OPTIONS_LAYOUT:ka.Layout,PRINT_OPTIONS_STYLE:ka.Style,PRINT_OPTIONS_CHILDREN:ka.Children,UNIT_UNDEFINED:Eo.Undefined,UNIT_POINT:Eo.Point,UNIT_PERCENT:Eo.Percent,UNIT_AUTO:Eo.Auto,WRAP_NO_WRAP:Sa.NoWrap,WRAP_WRAP:Sa.Wrap,WRAP_WRAP_REVERSE:Sa.WrapReverse};nt.default=K2,Object.defineProperty(tc,"__esModule",{value:!0}),tc.default=Y2;var ws=z2(nt);function y0(r){if(typeof WeakMap!="function")return null;var e=new WeakMap,t=new WeakMap;return(y0=function(i){return i?t:e})(r)}function z2(r,e){if(!e&&r&&r.__esModule)return r;if(r===null||typeof r!="object"&&typeof r!="function")return{default:r};var t=y0(e);if(t&&t.has(r))return t.get(r);var i={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in r)if(a!=="default"&&Object.prototype.hasOwnProperty.call(r,a)){var l=n?Object.getOwnPropertyDescriptor(r,a):null;l&&(l.get||l.set)?Object.defineProperty(i,a,l):i[a]=r[a]}return i.default=r,t&&t.set(r,i),i}function Y2(r){function e(n,a,l){const h=n[a];n[a]=function(){for(var f=arguments.length,p=new Array(f),m=0;m<f;m++)p[m]=arguments[m];return l.call(this,h,...p)}}for(const n of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const a={[ws.Unit.Point]:r.Node.prototype[n],[ws.Unit.Percent]:r.Node.prototype[`${n}Percent`],[ws.Unit.Auto]:r.Node.prototype[`${n}Auto`]};e(r.Node.prototype,n,function(l){for(var h=arguments.length,f=new Array(h>1?h-1:0),p=1;p<h;p++)f[p-1]=arguments[p];const m=f.pop();let g,A;if(m==="auto")g=ws.Unit.Auto,A=void 0;else if(typeof m=="object")g=m.unit,A=m.valueOf();else if(g=typeof m=="string"&&m.endsWith("%")?ws.Unit.Percent:ws.Unit.Point,A=parseFloat(m),!Number.isNaN(m)&&Number.isNaN(A))throw new Error(`Invalid value ${m} for ${n}`);if(!a[g])throw new Error(`Failed to execute "${n}": Unsupported unit '${m}'`);return A!==void 0?a[g].call(this,...f,A):a[g].call(this,...f)})}function t(n){return r.MeasureCallback.implement({measure:function(){const{width:a,height:l}=n(...arguments);return{width:a??NaN,height:l??NaN}}})}e(r.Node.prototype,"setMeasureFunc",function(n,a){return a?n.call(this,t(a)):this.unsetMeasureFunc()});function i(n){return r.DirtiedCallback.implement({dirtied:n})}return e(r.Node.prototype,"setDirtiedFunc",function(n,a){n.call(this,i(a))}),e(r.Config.prototype,"free",function(){r.Config.destroy(this)}),e(r.Node,"create",(n,a)=>a?r.Node.createWithConfig(a):r.Node.createDefault()),e(r.Node.prototype,"free",function(){r.Node.destroy(this)}),e(r.Node.prototype,"freeRecursive",function(){for(let n=0,a=this.getChildCount();n<a;++n)this.getChild(0).freeRecursive();this.free()}),e(r.Node.prototype,"calculateLayout",function(n){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,l=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:ws.Direction.LTR;return n.call(this,a,l,h)}),{Config:r.Config,Node:r.Node,...ws.default}}var A0={exports:{}};(function(r,e){var t=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(n){n=n||{};var a;a||(a=typeof n<"u"?n:{});var l,h;a.ready=new Promise(function(R,L){l=R,h=L});var f=Object.assign({},a),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 m=a.print||console.log.bind(console),g=a.printErr||console.warn.bind(console);Object.assign(a,f),f=null;var A;a.wasmBinary&&(A=a.wasmBinary),a.noExitRuntime;function b(){this.buffer=new ArrayBuffer(B/65536*65536)}function x(){}function k(R){this.exports=function(V){function X(Ai){return Ai.set=function(ut,cr){this[ut]=cr},Ai.get=function(ut){return this[ut]},Ai}for(var Z,ye=new Uint8Array(123),ke=25;ke>=0;--ke)ye[48+ke]=52+ke,ye[65+ke]=ke,ye[97+ke]=26+ke;ye[43]=62,ye[47]=63;function le(Ai,ut,cr){for(var Hi,ge,jr=0,c=ut,xe=cr.length,Wn=ut+(xe*3>>2)-(cr[xe-2]=="=")-(cr[xe-1]=="=");jr<xe;jr+=4)Hi=ye[cr.charCodeAt(jr+1)],ge=ye[cr.charCodeAt(jr+2)],Ai[c++]=ye[cr.charCodeAt(jr)]<<2|Hi>>4,c<Wn&&(Ai[c++]=Hi<<4|ge>>2),c<Wn&&(Ai[c++]=ge<<6|ye[cr.charCodeAt(jr+3)])}function Pe(Ai){le(Z,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),le(Z,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),le(Z,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),le(Z,4432,"xwAAAMgAAADJ"),le(Z,4452,"xwAAAMoAAADLAAAArBs="),le(Z,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),le(Z,4552,"zAAAAM0AAADO"),le(Z,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),le(Z,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),le(Z,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),le(Z,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),le(Z,5179,"DA=="),le(Z,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),le(Z,5237,"EA=="),le(Z,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),le(Z,5295,"Eg=="),le(Z,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),le(Z,5362,"GgAAABoaGgAAAAAAAAk="),le(Z,5411,"FA=="),le(Z,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),le(Z,5469,"Fg=="),le(Z,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),le(Z,5556,"1Q=="),le(Z,5596,"//////////8="),le(Z,5664,"8B8BAAAAAAAF"),le(Z,5684,"0A=="),le(Z,5708,"0QAAANIAAADUGw=="),le(Z,5732,"Ag=="),le(Z,5748,"//////////8="),le(Z,5816,"BQ=="),le(Z,5828,"0w=="),le(Z,5852,"0QAAANQAAADoGwAAAAQ="),le(Z,5876,"AQ=="),le(Z,5892,"/////wo="),le(Z,5960,"1g==")}var De=new ArrayBuffer(16),Ge=new Int32Array(De),Ye=new Float32Array(De),yt=new Float64Array(De);function mt(Ai){return Ge[Ai]}function Ce(Ai,ut){Ge[Ai]=ut}function Li(){return yt[0]}function Mi(Ai){yt[0]=Ai}function kt(){throw new Error("abort")}function yi(Ai){Ye[2]=Ai}function He(){return Ye[2]}function xl(Ai){var ut=Ai.a,cr=ut.a,Hi=cr.buffer;cr.grow=vw;var ge=new Int8Array(Hi),jr=new Int16Array(Hi),c=new Int32Array(Hi),xe=new Uint8Array(Hi),Wn=new Uint16Array(Hi),hm=new Uint32Array(Hi),C=new Float32Array(Hi),Ht=new Float64Array(Hi),Wt=Math.imul,v=Math.fround,zt=Math.abs,Tr=Math.clz32,fT=Math.min,pT=Math.max,Xe=NaN,dm=1/0,Re=ut.b,Ci=ut.c,ps=ut.d,ms=ut.e,Gs=ut.f,jn=ut.g,Zo=ut.h,Tl=ut.i,Ju=ut.j,eh=ut.k,th=ut.l,fm=ut.m,pm=ut.n,mm=ut.o,gm=ut.p,vm=ut.q,mT=ut.r,gT=ut.s,vT=ut.t,yT=ut.u,AT=ut.v,ET=ut.w,bT=ut.x,xT=ut.y,TT=ut.z,kT=ut.A,ST=ut.B,wT=ut.C,_T=ut.D,Te=73712,Wi=0;function ym(s,o,u,d,y,E,T,S,D,j,te,de,ee,ie){var F=0,H=v(0),z=0,J=v(0),oe=0,ae=v(0),ve=0,Ae=v(0),Ie=0,Fe=0,Ne=v(0),We=0,et=0,lt=v(0),vt=v(0),Lt=v(0),Pt=v(0),Ft=0,jt=v(0),Xt=v(0),si=0,ni=0,xi=v(0),Ni=0,Ui=0,Bi=0,zi=0,sr=v(0),nr=0,Dr=0,Or=0,Zr=0,qr=v(0),Qr=0,Jr=0,gs=0,vs=0,ys=v(0),js=0,Ks=0,zs=0,Ys=v(0),Xs=0,Zs=v(0),Jo=0,ea=v(0),ta=v(0),ia=v(0),ra=0,Il=v(0),gh=0,vh=v(0),yh=v(0),Ah=v(0),Eh=v(0),bh=0,pg=0,mg=0,gg=0,vg=0,yg=0,Ag=0,Eg=0,Zt=0,qt=v(0),qn=v(0);F=Te-384|0,Te=F;e:{r:{i:{if(!(y&&o!=o)){if(!(E&&u!=u)){if(z=(D?0:4)+te|0,c[z>>2]=c[z>>2]+1,z=c[s+24>>2]&3,gh=(d|0)<=1?1:d,zi=z||gh,ge[s+300|0]=xe[s+300|0]&252|zi&3,z=s+252|0,d=((zi|0)!=1)<<3,js=(zi|0)==2?3:2,ae=ft(s,js,T),C[z+d>>2]=ae,oe=z,z=((zi|0)==1)<<3,vt=St(s,js,T),C[oe+z>>2]=vt,Ae=ft(s,0,T),C[s+256>>2]=Ae,Pt=St(s,0,T),C[s+264>>2]=Pt,oe=s+268|0,Zt=oe+d|0,qt=gt(s,js),C[Zt>>2]=qt,Zt=z+oe|0,qt=wt(s,js),C[Zt>>2]=qt,H=gt(s,0),C[s+272>>2]=H,jt=wt(s,0),C[s+280>>2]=jt,oe=d,d=s+284|0,Zt=oe+d|0,qt=Dt(s,js,T),C[Zt>>2]=qt,Zt=d+z|0,qt=Ot(s,js,T),C[Zt>>2]=qt,J=Dt(s,0,T),C[s+288>>2]=J,Ne=Ot(s,0,T),C[s+296>>2]=Ne,ae=v(ae+vt),vt=v(Ae+Pt),d=c[s+8>>2],d){Ae=v(v(v(C[s+284>>2]+C[s+292>>2])+C[s+268>>2])+C[s+276>>2]),u=v(E?u-vt:Xe),H=v(v(J+Ne)+H),J=v(y?o-ae:Xe),o=J;t:{if(o!=o)break t;if(o=v(J-Ae),o!=o){o=v(0);break t}o=ht(o,v(0))}ae=v(H+jt),H=u;t:{if(u!=u)break t;if(H=v(u-ae),H!=H){H=v(0);break t}H=ht(H,v(0))}if(!((y|0)!=1|(E|0)!=1)){o=Yt(s,2,J,T),d=o!=o,H=v(v(Dt(s,2,T)+gt(s,2))+v(Ot(s,2,T)+wt(s,2)));t:{if(!(d|H!=H)){o=ht(o,H);break t}o=d?H:o}C[s+516>>2]=o,o=Yt(s,0,u,S),d=o!=o,u=v(v(Dt(s,0,T)+gt(s,0))+v(Ot(s,0,T)+wt(s,0)));t:{if(!(d|u!=u)){o=ht(o,u);break t}o=d?u:o}C[s+520>>2]=o;break e}t:{if(xe[s+4|0]&16){$e[d|0](F+24|0,s,o,y,H,E,0);break t}$e[d|0](F+24|0,s,o,y,H,E)}c[te+20>>2]=c[te+20>>2]+1,d=(ie<<2)+te|0,c[d+24>>2]=c[d+24>>2]+1,o=v(Ae+C[F+24>>2]),o=Yt(s,2,y?(y|0)==2?o:J:o,T),d=o!=o,H=v(v(Dt(s,2,T)+gt(s,2))+v(Ot(s,2,T)+wt(s,2)));t:{if(!(d|H!=H)){o=ht(o,H);break t}o=d?H:o}C[s+516>>2]=o,o=v(ae+C[F+28>>2]),o=Yt(s,0,E?(E|0)==2?o:u:o,S),d=o!=o,u=v(v(Dt(s,0,T)+gt(s,0))+v(Ot(s,0,T)+wt(s,0)));t:{if(!(d|u!=u)){o=ht(o,u);break t}o=d?u:o}C[s+520>>2]=o;break e}if(d=c[s+556>>2],ie=c[s+560>>2],(d|0)==(ie|0)){vt=v(u-vt),o=Yt(s,2,y&-3?v(o-ae):v(v(v(C[s+284>>2]+C[s+292>>2])+C[s+268>>2])+C[s+276>>2]),T),d=o!=o,u=v(v(Dt(s,2,T)+gt(s,2))+v(Ot(s,2,T)+wt(s,2)));t:{if(!(d|u!=u)){o=ht(o,u);break t}o=d?u:o}C[s+516>>2]=o,o=Yt(s,0,E&-3?vt:v(v(v(J+Ne)+H)+jt),S),d=o!=o,u=v(v(Dt(s,0,T)+gt(s,0))+v(Ot(s,0,T)+wt(s,0)));t:{if(!(d|u!=u)){o=ht(o,u);break t}o=d?u:o}C[s+520>>2]=o;break e}t:{if(D||(H=v(o-ae),J=v(u-vt),!(!(!(H<=v(0))|(y|0)!=2)&H==H|!(!(J<=v(0))|(E|0)!=2)&J==J)&((y|0)!=1|(E|0)!=1)))break t;o=Yt(s,2,H!=H||(y|0)==2&&H<v(0)?v(0):H,T),d=o!=o,u=v(v(Dt(s,2,T)+gt(s,2))+v(Ot(s,2,T)+wt(s,2)));s:{if(!(d|u!=u)){o=ht(o,u);break s}o=d?u:o}C[s+516>>2]=o,o=Yt(s,0,J!=J||(E|0)==2&&J<v(0)?v(0):J,S),d=o!=o,u=v(v(Dt(s,0,T)+gt(s,0))+v(Ot(s,0,T)+wt(s,0)));s:{if(!(d|u!=u)){o=ht(o,u);break s}o=d?u:o}C[s+520>>2]=o;break e}for(si=ie-d|0,Zr=si>>2;z=c[d>>2],c[z+552>>2]!=(s|0)&&(oe=c[s+568>>2],z=Dm(c[oe>>2],xe[oe+8|0],z,s,Ie,0),c[d>>2]=z,c[z+552>>2]=s),Ie=Ie+1|0,d=d+4|0,(ie|0)!=(d|0););ge[s+300|0]=xe[s+300|0]&251,Ie=3,Ni=c[s+24>>2],d=Ni>>>2&3;t:{s:{n:{if((zi|0)==2){ie=0;o:switch(d-2|0){case 0:break t;case 1:break o;default:break n}Ie=2;break t}if(Ie=2,ie=0,d>>>0>1)break s}ie=Ie}Ie=d}vh=v(o-ae),qr=v(v(Dt(s,Ie,T)+gt(s,Ie))+v(Ot(s,Ie,T)+wt(s,Ie))),jt=v(Dt(s,ie,T)+gt(s,ie)),sr=v(jt+v(Ot(s,ie,T)+wt(s,ie))),nr=Ie>>>0>1,Ae=Tm(s,0,vh,nr?qr:sr,T),yh=v(u-vt),Xt=Tm(s,1,yh,nr?sr:qr,S),Pt=nr?Xt:Ae,vt=nr?Ae:Xt,Qr=c[s+560>>2],z=c[s+556>>2],Ui=nr?y:E;t:{if((Ui|0)!=1)break t;if((z|0)==(Qr|0))break i;for(d=z;;){oe=c[d>>2];s:{if(!Vm(oe))break s;if(et=0,ve)break t;n:{o:{if(!c[oe+552>>2]){H=v(0);break o}if(u=C[oe+32>>2],u!=u&&(H=v(0),u=C[oe+28>>2],!(u>v(0))))break o;if(H=u,u!=u)break n}if(v(zt(H))<v(9999999747378752e-20))break t}if(o=Xn(oe),o!=o){ve=oe;break s}if(ve=oe,v(zt(o))<v(9999999747378752e-20))break t}if(et=ve,d=d+4|0,(Qr|0)==(d|0))break}}if((z|0)==(Qr|0))break i;for(Jo=(zi|0)<=1?1:zi,Ks=Ae!=Ae,Jr=Ks|(y|0)!=1,gs=Xt==Xt,zs=Ae==Ae,H=v(0);;){We=c[z>>2],xm(We),oe=c[We+24>>2];t:{if(oe&4194304){if(wm(We,0),d=xe[We+4|0],oe=d|1,ge[We+4|0]=oe,!(d&4))break t;ge[We+4|0]=oe&251;break t}if(D&&(d=oe&3,Om(We,d||Jo,vt,Pt,Ae),oe=c[We+24>>2]),(oe&196608)==131072)break t;s:{if((We|0)==(et|0)){c[et+308>>2]=0,c[et+304>>2]=ee,u=v(0);break s}vs=c[s+24>>2],d=vs>>>2&3;n:{o:{if((zi|0)!=2)break o;ve=3;a:switch(d-2|0){case 0:break n;case 1:break a;default:break o}ve=2;break n}ve=d}Dr=ve>>>0>1,ae=Dr?Ae:Xt,u=v(0),o=C[We+40>>2];n:{o:{Fe=c[We+40>>2];a:{if((Fe|0)==2139156720)break a;if((Fe|0)==2140081935)break o;d=4336;l:{if((Fe|0)!=2141891242){if(o==o)break l;d=4344}u=C[d>>2];c:{u:switch(Fe=c[d+4>>2],Fe|0){case 0:case 3:break u;default:break c}if(o=v(Xe),!(C[We+28>>2]>v(0)))break n;Fe=ge[c[We+568>>2]+8|0]&1,d=Fe?2143289344:0,Fe=Fe?3:1,u=(Ce(2,d),He())}switch(o=v(Xe),Fe-1|0){case 0:break o;case 1:break a;default:break n}}if(u=(Ce(2,(Fe&-1073741825)+536870912|0),He()),!(Fe&1073741824))break o}o=v(v(ae*u)*v(.009999999776482582));break n}o=u}u=C[We+572>>2],Fe=0;n:{o:switch(Ft=c[We+576>>2],Ft|0){case 0:case 3:break n;default:break o}if(J=C[We+572>>2],!((Ft|0)!=1|J!=J)){if(u<v(0))break n;Fe=1;break n}if(Fe=1,(Ft|0)!=2|J!=J||(Fe=0,u<v(0)))break n;Fe=zs}J=C[We+580>>2],d=0;n:{o:switch(ni=c[We+584>>2],ni|0){case 0:case 3:break n;default:break o}if(Ne=C[We+580>>2],!((ni|0)!=1|Ne!=Ne)){if(J<v(0))break n;d=1;break n}if(d=1,(ni|0)!=2|Ne!=Ne||(d=0,J<v(0)))break n;d=gs}n:{o:{if(!(o!=o|ae!=ae)){if(u=C[We+308>>2],(!(ge[c[We+568>>2]+12|0]&1)|c[We+304>>2]==(ee|0))&u==u)break n;if(u=v(v(Dt(We,ve,Ae)+gt(We,ve))+v(Ot(We,ve,Ae)+wt(We,ve))),!(u<=o)&o<u)break o;u=o;break o}if(Fe&Dr){J=v(v(Dt(We,2,Ae)+gt(We,2))+v(Ot(We,2,Ae)+wt(We,2))),o=v(Xe);a:switch(Ft-1|0){case 1:u=v(v(Ae*u)*v(.009999999776482582));case 0:if(o=u,J<=o)break o;break;default:break a}if(!(o==o|J==J)){u=o;break o}if(o<J){u=J;break o}u=o!=o?J:o;break o}if(!(Dr|d^1)){o=v(v(Dt(We,0,Ae)+gt(We,0))+v(Ot(We,0,Ae)+wt(We,0))),u=v(Xe);a:switch(ni-1|0){case 1:J=v(v(Xt*J)*v(.009999999776482582));case 0:if(u=J,o<=u)break o;break;default:break a}if(u!=u&o!=o)break o;if(o>u){u=o;break o}u=u!=u?o:u;break o}if(c[F+360>>2]=2143289344,c[F+24>>2]=2143289344,Bi=0,c[F+356>>2]=0,c[F+352>>2]=0,Ne=v(ft(We,2,Ae)+St(We,2,Ae)),lt=ft(We,0,Ae),Lt=St(We,0,Ae),ae=v(Xe),Or=0,o=v(Xe),Fe){a:{l:switch(Ft-1|0){case 0:o=u;break a;case 1:break l;default:break a}o=v(v(Ae*u)*v(.009999999776482582))}c[F+356>>2]=1,o=v(Ne+o),C[F+24>>2]=o,Or=1}if(lt=v(lt+Lt),d){u=v(Xe);a:{l:switch(ni-1|0){case 0:u=J;break a;case 1:break l;default:break a}u=v(v(Xt*J)*v(.009999999776482582))}c[F+352>>2]=1,ae=v(lt+u),C[F+360>>2]=ae,Bi=1}Ft=(vs&3145728)==2097152,ni=ve>>>0<2;a:{l:{c:{if(!(Ft&ni)){if(Ft|Ks)break l;if(o!=o)break c;break l}if(Ks|o==o)break a}Or=2,c[F+356>>2]=2,C[F+24>>2]=Ae,o=Ae}l:{if(!Ft||ni){if(Ft|Xt!=Xt)break a;if(ae!=ae)break l;break a}if(ae==ae|Xt!=Xt)break a}Bi=2,c[F+352>>2]=2,C[F+360>>2]=Xt,ae=Xt}u=C[We+224>>2],Ft=u!=u;a:{if(Ft)break a;l:{if(!(Dr|(Or|0)!=1)){c[F+352>>2]=1,C[F+360>>2]=lt+v(v(o-Ne)/u);break l}if(ni|(Bi|0)!=1)break a;c[F+356>>2]=1,C[F+24>>2]=v(v(ae-lt)*u)+Ne}Bi=1,Or=1}oe=oe>>>13&7,oe=oe||vs>>>10&7;a:{if((oe|0)==5|(Or|0)==1|(Dr|(Fe|Jr))|(oe|0)!=4||(c[F+356>>2]=1,C[F+24>>2]=Ae,Ft))break a;Bi=1,c[F+352>>2]=1,C[F+360>>2]=v(Ae-Ne)/u}a:{if(ni|(E|0)!=1|Xt!=Xt|d|(oe|0)!=4|(Bi|0)==1||(c[F+352>>2]=1,C[F+360>>2]=Xt,Ft))break a;c[F+356>>2]=1,C[F+24>>2]=v(Xt-lt)*u}if(Kn(We,2,Ae,Ae,F+356|0,F+24|0),Kn(We,0,Xt,Ae,F+352|0,F+360|0),An(We,C[F+24>>2],C[F+360>>2],zi,c[F+356>>2],c[F+352>>2],Ae,Xt,0,5,j,te,de,ee),o=C[(We+(c[(ve<<2)+4320>>2]<<2)|0)+516>>2],d=o!=o,u=v(v(Dt(We,ve,Ae)+gt(We,ve))+v(Ot(We,ve,Ae)+wt(We,ve))),!(d|u!=u)){u=ht(o,u);break o}u=d?u:o}C[We+308>>2]=u}c[We+304>>2]=ee}H=v(H+v(u+v(ft(We,Ie,Ae)+St(We,Ie,Ae))))}if(z=z+4|0,(Qr|0)==(z|0))break}break r}c[F>>2]=3072,ur(s,F),rr(),kt()}c[F+16>>2]=3154,ur(s,F+16|0),rr(),kt()}H=v(0)}o=v(H+v(0)),ea=nr?S:T,Ys=nr?T:S,si>>>0>=5&&(o=v(v(kl(s,Ie,Pt)*v(Zr-1>>>0))+o)),d=o>vt,Qr=Ni&786432,gs=(Ui|0)==2&&Qr&&d?1:Ui,We=nr?E:y,Dr=(We|0)==1,pg=Dr&(D^1),nr=Ie>>>0<2,mg=We&-3,Ks=s+208|0,E=ie<<2,ni=E+4288|0,gg=Dr&!Qr,vg=(We|0)!=1|D,z=Ie<<2,Or=z+4288|0,zs=z+4320|0,vs=Pt==Pt,yg=vs<<1,Ft=E+4320|0,Ag=!Ui|!d,Jo=F+52|0,Ah=kl(s,ie,Pt),oe=0,d=0,Bi=0;r:{for(;;){Ui=d,Ki(F+24|0,0,44),d=c[s+560>>2],E=c[s+556>>2];i:{if((d|0)==(E|0))break i;if(d=d-E|0,(d|0)<0)break r;if(z=Qo(F+360|0,d>>2,0,Jo),d=c[F+44>>2],E=c[F+48>>2]-d|0,E=Vs(c[F+364>>2]-E|0,d,E),d=c[F+44>>2],c[F+364>>2]=d,c[F+44>>2]=E,ve=c[F+368>>2],Fe=c[F+372>>2],E=c[F+48>>2],c[F+368>>2]=E,et=c[F+52>>2],c[F+48>>2]=ve,c[F+52>>2]=Fe,c[F+372>>2]=et,c[z>>2]=d,(d|0)!=(E|0)&&(c[F+368>>2]=E+((d-E|0)+3&-4)),!d)break i;Ei(d)}et=c[s+24>>2],d=et>>>2&3;i:{t:{if(E=et&3,((E||gh)|0)!=2)break t;ve=3;s:switch(d-2|0){case 0:break i;case 1:break s;default:break t}ve=2;break i}ve=d}H=kl(s,ve,Ae),z=oe,Fe=c[s+560>>2],E=c[s+556>>2];i:{if(z>>>0>=Fe-E>>2>>>0)break i;for(et=et&786432,u=v(0);;){if(Fe-E>>2>>>0<=z>>>0)break r;if(d=c[(z<<2)+E>>2],si=c[d+24>>2],!(si&4194304|(si&196608)==131072)){if(c[d+548>>2]=Ui,o=ft(d,ve,Ae),J=St(d,ve,Ae),E=c[F+24>>2],ae=(z|0)==(oe|0)?v(0):H,o=v(o+J),J=C[d+308>>2],Ne=Yt(d,ve,J,Ys),!(!E||!(v(ae+v(o+v(u+Ne)))>vt)|!et))break i;if(c[F+24>>2]=E+1,ae=v(ae+v(o+Ne)),C[F+28>>2]=ae+C[F+28>>2],Vm(d)){t:{if(!c[d+552>>2]){o=v(0);break t}if(o=C[d+32>>2],o==o)break t;o=C[d+28>>2],o=o>v(0)?o:v(0)}C[F+32>>2]=o+C[F+32>>2],Zt=F,qt=v(C[F+36>>2]-v(Xn(d)*J)),C[Zt+36>>2]=qt}E=c[F+48>>2];t:{if((E|0)!=c[F+52>>2]){c[E>>2]=d,c[F+48>>2]=E+4;break t}if(E=E-c[F+44>>2]|0,si=E>>2,Fe=si+1|0,Fe>>>0>=1073741824)break r;if(Ni=E>>1,Fe=Qo(F+360|0,E>>>0>=2147483644?1073741823:Fe>>>0<Ni>>>0?Ni:Fe,si,Jo),c[c[F+368>>2]>>2]=d,c[F+368>>2]=c[F+368>>2]+4,d=c[F+44>>2],E=c[F+48>>2]-d|0,E=Vs(c[F+364>>2]-E|0,d,E),d=c[F+44>>2],c[F+364>>2]=d,c[F+44>>2]=E,si=c[F+368>>2],Ni=c[F+372>>2],E=c[F+48>>2],c[F+368>>2]=E,Jr=c[F+52>>2],c[F+48>>2]=si,c[F+52>>2]=Ni,c[F+372>>2]=Jr,c[Fe>>2]=d,(d|0)!=(E|0)&&(c[F+368>>2]=E+((d-E|0)+3&-4)),!d)break t;Ei(d)}E=c[s+556>>2],Fe=c[s+560>>2],u=v(u+ae)}if(z=z+1|0,!(z>>>0<Fe-E>>2>>>0))break}}Lt=C[F+32>>2],!(Lt>v(0))|!(Lt<v(1))||(c[F+32>>2]=1065353216,Lt=v(1)),xi=C[F+36>>2],!(xi>v(0))|!(xi<v(1))||(c[F+36>>2]=1065353216,xi=v(1)),c[F+40>>2]=z,Ne=C[F+28>>2],ve=c[F+24>>2],Bi&&Ei(Bi),J=C[F+56>>2],si=c[F+48>>2],Bi=c[F+44>>2];i:{t:{s:{n:{if((gs|0)==1)break n;u=v(0),o=C[Ks>>2];o:{a:{d=c[Ks>>2];l:{if((d|0)==2139156720)break l;if((d|0)==2140081935)break a;E=4336;c:{if((d|0)!=2141891242){if(o==o)break c;E=4344}switch(u=C[E>>2],o=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break a}o=v(v(u*T)*v(.009999999776482582));break o}o=u}u=v(0),H=C[s+216>>2];o:{a:{d=c[s+216>>2];l:{if((d|0)==2139156720)break l;if((d|0)==2140081935)break a;E=4336;c:{if((d|0)!=2141891242){if(H==H)break c;E=4344}switch(u=C[E>>2],H=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break a}H=v(v(u*T)*v(.009999999776482582));break o}H=u}u=v(0),ae=C[s+212>>2];o:{a:{d=c[s+212>>2];l:{if((d|0)==2139156720)break l;if((d|0)==2140081935)break a;E=4336;c:{if((d|0)!=2141891242){if(ae==ae)break c;E=4344}switch(u=C[E>>2],ae=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break a}ae=v(v(u*S)*v(.009999999776482582));break o}ae=u}u=v(0),lt=C[s+220>>2];o:{a:{d=c[s+220>>2];l:{if((d|0)==2139156720)break l;if((d|0)==2140081935)break a;E=4336;c:{if((d|0)!=2141891242){if(lt==lt)break c;E=4344}switch(u=C[E>>2],lt=v(Xe),c[E+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break a}lt=v(v(u*S)*v(.009999999776482582));break o}lt=u}if(d=Ie>>>0>1,u=v((d?o:ae)-qr),u==u&u>Ne||(u=v((d?H:lt)-qr),u==u&u<Ne))break s;if(ge[c[s+568>>2]+16|0]&1)break n;if(u=Ne,!c[s+552>>2]|Lt==v(0))break t;o=C[s+32>>2];o:{a:{if(o==o){u=o;break a}if(u=C[s+28>>2],!(u>v(0)))break o}if(u!=u){u=vt;break t}o=C[s+32>>2]}if(o!=o&&(u=Ne,o=C[s+28>>2],!(o>v(0)))||(u=vt,o!=v(0)))break t;u=Ne;break t}u=vt}if(u!=u)break t;J=v(u-Ne);break i}if(!(Ne<v(0)))break i;J=v(-Ne)}if(vt=u,!pg){i:{if((si|0)==(Bi|0)){ae=v(0);break i}for(lt=v(0),E=Bi;;){d=c[E>>2],Ne=C[d+308>>2],u=Yt(d,Ie,Ne,Ys);t:{if(J<v(0)){if(o=v(u*v(-Xn(d))),!(o>v(0)|o<v(0)))break t;H=v(v(v(J/xi)*o)+u),o=Yt(d,Ie,H,vt),Fe=o!=o,ae=v(v(Dt(d,Ie,Ae)+gt(d,Ie))+v(Ot(d,Ie,Ae)+wt(d,Ie)));s:{if(!(Fe|ae!=ae)){o=ht(o,ae);break s}o=Fe?ae:o}if(H!=H|o!=o|o==H)break t;lt=v(lt+v(o-u)),xi=v(v(Xn(d)*Ne)+xi);break t}if(!(J>v(0))|!c[d+552>>2]||(H=C[d+32>>2],H!=H&&(H=C[d+28>>2],!(H>v(0))))||!(H<v(0)|H>v(0)))break t;ae=v(v(v(J/Lt)*H)+u),o=Yt(d,Ie,ae,vt),Fe=o!=o,Ne=v(v(Dt(d,Ie,Ae)+gt(d,Ie))+v(Ot(d,Ie,Ae)+wt(d,Ie)));s:{if(!(Fe|Ne!=Ne)){o=ht(o,Ne);break s}o=Fe?Ne:o}if(ae!=ae|o!=o|o==ae)break t;Lt=v(Lt-H),lt=v(lt+v(o-u))}if(E=E+4|0,(si|0)==(E|0))break}for(lt=v(J-lt),ta=v(lt/xi),ia=v(lt/Lt),ra=Dr&(Ag|!(xe[s+26|0]&12)),Jr=!ra,Ni=c[Ft>>2],ae=v(0),Fe=Bi;;){d=c[Fe>>2],Ne=Yt(d,Ie,C[d+308>>2],Ys);t:{s:{if(lt<v(0)){if(H=Ne,o=v(H*v(-Xn(d))),o==v(0))break t;o=xi==v(0)?v(Ne+o):v(v(ta*o)+Ne);break s}if(H=Ne,!(lt>v(0))|!c[d+552>>2]||(o=C[d+32>>2],o!=o&&(o=C[d+28>>2],!(o>v(0))))||!(o<v(0)|o>v(0)))break t;o=v(v(ia*o)+Ne)}if(o=Yt(d,Ie,o,vt),E=o!=o,u=v(v(Dt(d,Ie,Ae)+gt(d,Ie))+v(Ot(d,Ie,Ae)+wt(d,Ie))),!(E|u!=u)){H=ht(o,u);break t}H=E?u:o}o=ft(d,Ie,Ae),u=St(d,Ie,Ae),Lt=ft(d,ie,Ae),Il=St(d,ie,Ae),u=v(o+u),Eh=v(H+u),C[F+352>>2]=Eh,c[F+344>>2]=1,Lt=v(Lt+Il),o=C[d+224>>2];t:{if(o==o){c[F+348>>2]=1,u=v(Eh-u),C[F+356>>2]=Lt+v(nr?u*o:u/o);break t}s:{if(Xs=Pt!=Pt,Xs)break s;et=(Ni<<3)+d|0,o=C[et+572>>2];n:{o:{a:{l:switch(E=c[et+576>>2],E|0){case 0:case 3:break a;default:break l}if(u=C[et+572>>2],(E|0)!=1|u!=u)break o;if(!(Jr|!(o<v(0))))break n;break s}if(!ra)break s;break n}if(Jr|(!(o<v(0))|((E|0)!=2|u!=u)))break s}if(E=c[d+24>>2]>>>13&7,E||(E=c[s+24>>2]>>>10&7),(E|0)!=4||(bn(F+24|0,d,ie),c[F+28>>2]==3)||(En(F+360|0,d,ie),c[F+364>>2]==3))break s;c[F+348>>2]=1,C[F+356>>2]=Pt;break t}et=(Ni<<3)+d|0,u=C[et+572>>2];s:{n:{o:{a:{l:switch(E=c[et+576>>2],E|0){case 0:case 3:break a;default:break l}if(o=C[et+572>>2],!((E|0)!=1|o!=o)){if(o=u,o<v(0))break a;break s}if((E|0)!=2|o!=o)break o;if(Xs)break a;if(!(u<v(0)))break n}c[F+348>>2]=yg,C[F+356>>2]=Pt;break t}o=v(Xe);o:switch(E-1|0){case 1:break n;case 0:break o;default:break s}o=u;break s}o=v(v(Pt*u)*v(.009999999776482582))}o=v(Lt+o),C[F+356>>2]=o,c[F+348>>2]=(Dr|(E|0)!=2)&o==o}Kn(d,Ie,vt,Ae,F+344|0,F+352|0),Kn(d,ie,Pt,Ae,F+348|0,F+356|0),et=(Ni<<3)+d|0,o=C[et+572>>2];t:{s:{n:{o:switch(E=c[et+576>>2],E|0){case 0:case 3:break n;default:break o}if(u=C[et+572>>2],!((E|0)!=1|u!=u)){if(o<v(0))break n;break s}if((E|0)!=2|u!=u)break s;if(o<v(0))break n;if(et=0,vs)break t}if(et=0,E=c[d+24>>2]>>>13&7,E||(E=c[s+24>>2]>>>10&7),(E|0)!=4||(bn(F+24|0,d,ie),c[F+28>>2]==3))break t;En(F+360|0,d,ie),et=c[F+364>>2]!=3;break t}et=0}o=C[F+352>>2],u=C[F+356>>2],E=Ie>>>0>1,Lt=E?o:u,o=E?u:o,Xs=c[F+344>>2],bh=c[F+348>>2],Eg=E?Xs:bh,Xs=E?bh:Xs,E=(et^1)&D,An(d,Lt,o,xe[s+300|0]&3,Eg,Xs,Ae,Xt,E,E?4:7,j,te,de,ee),ae=v(ae+v(H-Ne)),E=xe[s+300|0];t:{s:{if(E&4){et=E&251;break s}if(et=E&251,E=0,!(xe[d+300|0]&4))break t}E=4}if(ge[s+300|0]=E|et,Fe=Fe+4|0,(si|0)==(Fe|0))break}}J=v(J-ae)}d=xe[s+300|0],ge[s+300|0]=d&251|(J<v(0)?4:d&4),lt=v(Dt(s,Ie,T)+gt(s,Ie)),ta=v(Ot(s,Ie,T)+wt(s,Ie)),Ne=kl(s,Ie,T);i:{if(!(!(J>v(0))|(gs|0)!=2)){ae=v(0),u=v(0);t:{s:{d=Ks+(c[zs>>2]<<2)|0,o=C[d>>2],d=c[d>>2],E=(d|0)==2139156720;n:{if(!E){if(Fe=(d|0)==2140081935,Fe)break s;if(et=(d|0)==2141891242,et|o!=o)break i;if(Fe)break s;if(et)break i;if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break n}u=v(v(Ys*u)*v(.009999999776482582))}if(u!=u)break i;u=v(0);n:{if(E)break n;if((d|0)==2140081935)break s;E=4336;o:{if((d|0)!=2141891242){if(o==o)break o;E=4344}switch(u=C[E>>2],H=v(Xe),c[E+4>>2]-1|0){case 0:break s;case 1:break n;default:break t}}if(u=(Ce(2,(d&-1073741825)+536870912|0),He()),!(d&1073741824))break s}H=v(v(Ys*u)*v(.009999999776482582));break t}H=u}if(o=v(v(v(H-lt)-ta)-v(vt-J)),o!=o)break i;ae=ht(o,v(0));break i}ae=J}et=z>>>0<=oe>>>0;i:{if(!et){for(si=c[s+556>>2],d=c[s+560>>2]-si>>2,Ni=d>>>0<oe>>>0?oe:d,Fe=0,d=oe;;){if((d|0)==(Ni|0))break r;if(E=c[si+(d<<2)>>2],(c[E+24>>2]&196608)!=131072&&(Jr=F+24|0,bn(Jr,E,Ie),ra=c[F+28>>2],En(Jr,E,Ie),Fe=(((ra|0)==3)+Fe|0)+(c[F+28>>2]==3)|0),d=d+1|0,(z|0)==(d|0))break}if(Lt=v(0),u=Ne,Fe)break i}Lt=v(0),Fe=0,u=Ne;t:switch((c[s+24>>2]>>>4&7)-1|0){case 0:Lt=v(ae*v(.5));break i;case 1:Lt=ae;break i;case 2:if(ve>>>0<2)break i;u=v(Ne+v((qt=v(0),qn=ht(ae,v(0)),Zt=ae!=ae,(Zt?qt:qn)/v(ve-1>>>0))));break i;case 4:Lt=v(ae/v(ve+1>>>0)),u=v(Ne+Lt);break i;case 3:break t;default:break i}Lt=v(v(ae*v(.5))/v(ve>>>0)),u=v(v(Lt+Lt)+Ne)}if(o=v(lt+Lt),J=v(0),si=$m(s),et)u=v(0);else{for(Ni=z-1|0,ia=v(ae/v(Fe|0)),lt=v(0),H=v(0),d=oe;;){if(E=c[s+556>>2],c[s+560>>2]-E>>2>>>0<=d>>>0)break r;E=c[E+(d<<2)>>2],ve=E+228|0,ji(F+24|0,ve,320),u=v(u-((d|0)==(Ni|0)?Ne:v(0))),Fe=c[E+24>>2];i:{if(Fe&4194304)break i;t:{if((Fe&196608)==131072){if(!hr(E,Ie))break t;if(!D)break i;ae=Hs(E,Ie,vt),xi=gt(s,Ie),Il=ft(E,Ie,Ae),C[ve+(c[Or>>2]<<2)>>2]=Il+v(ae+xi);break i}if(bn(F+360|0,E,Ie),o=v(o+(c[F+364>>2]==3?ia:v(-0))),D&&(Fe=ve,ve=c[Or>>2]<<2,C[Fe+ve>>2]=o+C[ve+(F+24|0)>>2]),En(F+360|0,E,Ie),o=v(o+(c[F+364>>2]==3?ia:v(-0))),!vg){o=v(o+v(v(u+v(ft(E,Ie,Ae)+St(E,Ie,Ae)))+C[F+104>>2])),J=Pt;break i}if(ve=E+516|0,o=v(o+v(u+v(C[ve+(c[zs>>2]<<2)>>2]+v(ft(E,Ie,Ae)+St(E,Ie,Ae))))),si){ae=Sl(E),xi=ft(E,0,Ae),ae=v(ae+xi),xi=v(v(C[E+520>>2]+v(ft(E,0,Ae)+St(E,0,Ae)))-ae),E=lt!=lt;s:{if(!(E|ae!=ae)){lt=ht(lt,ae);break s}lt=E?ae:lt}if(E=H!=H,!(E|xi!=xi)){H=ht(H,xi);break i}H=E?xi:H;break i}if(ae=v(C[ve+(c[Ft>>2]<<2)>>2]+v(ft(E,ie,Ae)+St(E,ie,Ae))),E=J!=J,!(ae!=ae|E)){J=ht(J,ae);break i}J=E?ae:J;break i}if(!D)break i;E=c[Or>>2]<<2,ae=C[E+(F+24|0)>>2],Zt=E+ve|0,qt=v(Lt+v(ae+gt(s,Ie))),C[Zt>>2]=qt}if(d=d+1|0,(z|0)==(d|0))break}u=v(H+lt)}if(J=si?u:J,ae=Pt,!mg){u=Yt(s,ie,v(sr+J),ea),d=u!=u,H=v(v(Dt(s,ie,T)+gt(s,ie))+v(Ot(s,ie,T)+wt(s,ie)));i:{if(!(d|H!=H)){u=ht(u,H);break i}u=d?H:u}ae=v(u-sr)}u=Yt(s,ie,v(sr+(gg?Pt:J)),ea),d=u!=u,H=v(v(Dt(s,ie,T)+gt(s,ie))+v(Ot(s,ie,T)+wt(s,ie)));i:{if(!(d|H!=H)){u=ht(u,H);break i}u=d?H:u}if(H=v(u-sr),!(et|!D))for(;;){if(d=c[s+556>>2],c[s+560>>2]-d>>2>>>0<=oe>>>0)break r;ve=c[d+(oe<<2)>>2],d=c[ve+24>>2];i:{if(d&4194304)break i;if((d&196608)==131072){t:{if(!hr(ve,ie)){E=c[ni>>2];break t}if(u=Hs(ve,ie,Pt),J=gt(s,ie),Ne=ft(ve,ie,Ae),E=c[ni>>2],u=v(Ne+v(u+J)),C[(ve+(E<<2)|0)+228>>2]=u,u==u)break i}Zt=ve+(E<<2)|0,qt=v(gt(s,ie)+ft(ve,ie,Ae)),C[Zt+228>>2]=qt;break i}E=d>>>13&7,E||(E=c[s+24>>2]>>>10&7);t:{s:{if((E|0)==5){E=c[s+24>>2]&8?5:1;break s}if((E|0)!=4||(bn(F+24|0,ve,ie),E=4,c[F+28>>2]==3)||(En(F+360|0,ve,ie),c[F+364>>2]==3))break s;E=ve+(c[Ft>>2]<<3)|0,J=C[E+572>>2];n:{o:switch(d=c[E+576>>2],d|0){case 0:case 3:break n;default:break o}if(Ne=C[E+572>>2],!((d|0)!=1|Ne!=Ne)){if(u=jt,J<v(0))break n;break t}if(u=jt,vs&!(J<v(0))|((d|0)!=2|Ne!=Ne))break t}J=C[(ve+(c[zs>>2]<<2)|0)+516>>2],u=H,Ne=C[ve+224>>2],Ne==Ne&&(u=v(v(ft(ve,ie,Ae)+St(ve,ie,Ae))+v(nr?J*Ne:J/Ne))),C[F+360>>2]=u,Zt=F,qt=v(J+v(ft(ve,Ie,Ae)+St(ve,Ie,Ae))),C[Zt+24>>2]=qt,c[F+356>>2]=1,c[F+352>>2]=1,Kn(ve,Ie,vt,Ae,F+356|0,F+24|0),Kn(ve,ie,Pt,Ae,F+352|0,F+360|0),J=C[F+360>>2],Ne=C[F+24>>2],d=Ie>>>0>1,u=d?J:Ne,J=d?Ne:J,d=(Qr|0)!=0&(c[s+24>>2]&896)!=512,An(ve,J,u,zi,!(d&nr|J!=J),(!d|nr)&u==u,Ae,Xt,1,2,j,te,de,ee),u=jt;break t}u=C[(ve+(c[Ft>>2]<<2)|0)+516>>2],J=ft(ve,ie,Ae),Ne=St(ve,ie,Ae),bn(F+24|0,ve,ie),J=v(ae-v(u+v(J+Ne)));s:{if(c[F+28>>2]!=3||(En(F+360|0,ve,ie),c[F+364>>2]!=3))break s;u=v(J*v(.5)),u=v(jt+(qt=v(0),qn=ht(u,v(0)),Zt=u!=u,Zt?qt:qn));break t}if(En(F+24|0,ve,ie),u=jt,c[F+28>>2]==3)break t;if(bn(F+24|0,ve,ie),c[F+28>>2]==3){u=v(jt+(qt=v(0),qn=ht(J,v(0)),Zt=J!=J,Zt?qt:qn));break t}s:switch(E-1|0){case 1:u=v(jt+v(J*v(.5)));break t;case 0:break t;default:break s}u=v(jt+J)}d=ve+(c[ni>>2]<<2)|0,C[d+228>>2]=u+v(ys+C[d+228>>2])}if(oe=oe+1|0,(oe|0)==(z|0))break}u=v((Ui?Ah:v(0))+H),d=Zs!=Zs,o=v(ta+o);i:{if(!(d|o!=o)){Zs=ht(Zs,o);break i}Zs=d?o:Zs}if(ys=v(ys+u),d=Ui+1|0,oe=z,!(Zr>>>0>z>>>0))break}i:{if(!D||!Qr&&!$m(s))break i;lt=v(0);t:{s:{if(Pt!=Pt)break s;o=v(Pt-ys);n:switch((c[s+24>>2]>>>7&7)-2|0){case 0:jt=v(jt+v(o*v(.5)));break s;case 2:if(!(Pt>ys))break s;lt=v(o/v(d>>>0));break s;case 5:if(Pt>ys){if(jt=v(jt+v(o/v(d<<1>>>0))),d>>>0<2)break s;lt=v(o/v(d>>>0));break t}jt=v(jt+v(o*v(.5)));break s;case 4:if(!(Pt>ys)|d>>>0<2)break s;lt=v(o/v(Ui>>>0));break t;case 1:break n;default:break s}jt=v(jt+o)}if(!d)break i}for(Fe=0,d=0,E=0;;){if(J=v(0),u=v(0),o=v(0),H=v(0),z=d,Zr>>>0>d>>>0){t:{for(;;){if(E=c[s+556>>2],c[s+560>>2]-E>>2>>>0<=z>>>0)break r;oe=c[E+(z<<2)>>2],ve=c[oe+24>>2];s:{if(ve&4194304|(ve&196608)==131072)break s;if(E=z,c[oe+548>>2]!=(Fe|0))break t;o=C[(oe+(c[Ft>>2]<<2)|0)+516>>2];n:{if(!(o>=v(0)))break n;if(E=u!=u,o=v(o+v(ft(oe,ie,Ae)+St(oe,ie,Ae))),!(E|o!=o)){u=ht(u,o);break n}u=E?o:u}if(E=ve>>>13&7,E||(E=c[s+24>>2]>>>10&7),!(xe[s+24|0]&8)|(E|0)!=5)break s;o=Sl(oe),ae=ft(oe,0,Ae),o=v(o+ae),ae=v(v(C[oe+520>>2]+v(ft(oe,0,Ae)+St(oe,0,Ae)))-o),E=u!=u,oe=H!=H;n:{if(!(oe|o!=o)){H=ht(H,o);break n}H=oe?o:H}oe=J!=J;n:{if(!(oe|ae!=ae)){J=ht(J,ae);break n}J=oe?ae:J}if(o=v(H+J),!(E|o!=o)){u=ht(u,o);break s}u=E?o:u}if(z=z+1|0,(Zr|0)==(z|0))break}E=Zr}o=u}if(ae=v(jt+(Fe?Ah:v(0))),u=v(lt+o),jt=v(ae+u),d>>>0<E>>>0)for(Ne=v(ae+H);;){if(z=c[s+556>>2],c[s+560>>2]-z>>2>>>0<=d>>>0)break r;oe=c[z+(d<<2)>>2],z=c[oe+24>>2];t:{if(z&4194304|(z&196608)==131072)break t;z=z>>>13&7,z||(z=c[s+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(xe[s+24|0]&8)break s;case 0:o=ft(oe,ie,Ae),C[(oe+(c[ni>>2]<<2)|0)+228>>2]=ae+o;break t;case 2:o=St(oe,ie,Ae),z=oe+228|0,C[z+(c[ni>>2]<<2)>>2]=v(jt-o)-C[(z+(c[Ft>>2]<<2)|0)+288>>2];break t;case 1:z=oe+228|0,C[z+(c[ni>>2]<<2)>>2]=ae+v(v(u-C[(z+(c[Ft>>2]<<2)|0)+288>>2])*v(.5));break t;case 3:break n;default:break t}o=ft(oe,ie,Ae),C[(oe+(c[ni>>2]<<2)|0)+228>>2]=ae+o,ve=oe+(c[Ft>>2]<<3)|0,o=C[ve+572>>2];n:{o:switch(z=c[ve+576>>2],z|0){case 0:case 3:break n;default:break o}if(H=C[ve+572>>2],!((z|0)!=1|H!=H)){if(o<v(0))break n;break t}if(vs&!(o<v(0))|((z|0)!=2|H!=H))break t}n:{if(Ie>>>0>=2){J=u,o=C[oe+516>>2],H=v(o+v(ft(oe,Ie,Ae)+St(oe,Ie,Ae)));break n}J=v(C[oe+520>>2]+v(ft(oe,ie,Ae)+St(oe,ie,Ae))),o=C[oe+516>>2],H=u}n:{o:{if(!(H!=H|o!=o)){if(v(zt(v(H-o)))<v(9999999747378752e-20))break o;break n}if(H==H|o==o)break n}if(o=C[oe+520>>2],z=o!=o,!(z|J!=J)){if(!(v(zt(v(J-o)))<v(9999999747378752e-20)))break n;break t}if(J==J)break n;if(z)break t}An(oe,H,J,zi,1,1,Ae,Xt,1,3,j,te,de,ee);break t}Zt=oe,qt=v(v(Ne-Sl(oe))+Hs(oe,0,Pt)),C[Zt+232>>2]=qt}if(d=d+1|0,(E|0)==(d|0))break}if(z=(Fe|0)!=(Ui|0),Fe=Fe+1|0,d=E,!z)break}}ve=s+516|0,o=Yt(s,2,vh,T),d=o!=o,u=v(v(Dt(s,2,T)+gt(s,2))+v(Ot(s,2,T)+wt(s,2)));i:{if(!(d|u!=u)){o=ht(o,u);break i}o=d?u:o}C[ve>>2]=o,o=Yt(s,0,yh,S),d=o!=o,u=v(v(Dt(s,0,T)+gt(s,0))+v(Ot(s,0,T)+wt(s,0)));i:{if(!(d|u!=u)){o=ht(o,u);break i}o=d?u:o}C[s+520>>2]=o;i:{t:{s:{if(gs&&(d=c[s+24>>2]>>>20&3,(d|0)==2|(gs|0)!=2))break s;if(o=Yt(s,Ie,Zs,Ys),d=o!=o,u=v(v(Dt(s,Ie,T)+gt(s,Ie))+v(Ot(s,Ie,T)+wt(s,Ie))),!(d|u!=u)){o=ht(o,u);break t}o=d?u:o;break t}if((gs|0)!=2|(d|0)!=2)break i;u=v(qr+vt),d=u!=u,o=Yt(s,Ie,Zs,Ys);s:{if(!(d|o!=o)){o=uh(u,o);break s}o=d?o:u}if(d=o!=o,!(d|qr!=qr)){o=ht(o,qr);break t}o=d?qr:o}C[ve+(c[zs>>2]<<2)>>2]=o}i:{t:{s:{if(We&&(E=(We|0)!=2,d=c[s+24>>2]>>>20&3,E|(d|0)==2))break s;if(o=Yt(s,ie,v(sr+ys),ea),d=o!=o,u=v(v(Dt(s,ie,T)+gt(s,ie))+v(Ot(s,ie,T)+wt(s,ie))),!(d|u!=u)){o=ht(o,u);break t}o=d?u:o;break t}if(E|(d|0)!=2)break i;u=v(sr+Pt),d=u!=u,o=Yt(s,ie,v(sr+ys),ea);s:{if(!(d|o!=o)){o=uh(u,o);break s}o=d?o:u}if(d=o!=o,!(d|sr!=sr)){o=ht(o,sr);break t}o=d?sr:o}C[ve+(c[Ft>>2]<<2)>>2]=o}i:{if(!D)break i;if((c[s+24>>2]&786432)==524288)for(E=Zr>>>0<=1?1:Zr,D=c[s+556>>2],oe=c[s+560>>2]-D>>2,d=0;z=0,z=d>>>0<oe>>>0?c[D+(d<<2)>>2]:z,(c[z+24>>2]&196608)!=131072&&(z=z+228|0,Fe=z+(c[ni>>2]<<2)|0,et=c[Ft>>2]<<2,C[Fe>>2]=v(C[et+ve>>2]-C[Fe>>2])-C[(z+et|0)+288>>2]),d=d+1|0,(E|0)!=(d|0););if(E=c[s+556>>2],D=c[s+560>>2],(E|0)!=(D|0))for(Fe=((Ie>>>0>1?gs:y)|0)!=0;;){y=c[E>>2];t:{if((c[y+24>>2]&4390912)!=131072)break t;H=Ae,vt=Xt,xe[c[s+568>>2]+12|0]&2&&(vt=C[s+520>>2],H=C[s+516>>2]),d=c[s+24>>2]>>>2&3;s:{n:{if((zi|0)==2){oe=0,z=3;o:switch(d-2|0){case 0:break s;case 1:break o;default:break n}z=2;break s}if(oe=0,d>>>0<=1)break n;z=d;break s}z=d,oe=js}S=v(ft(y,2,H)+St(y,2,H)),T=ft(y,0,H),J=St(y,0,H),o=C[y+572>>2];s:{n:{o:switch(d=c[y+576>>2],d|0){case 0:case 3:break n;default:break o}u=C[y+572>>2];o:{if(!((d|0)!=1|u!=u)){if(u=o,!(o<v(0)))break o;break n}a:{if(!((d|0)!=2|u!=u)){if(H!=H|o<v(0))break n;break a}u=v(Xe);l:switch(d-1|0){case 1:break a;case 0:break l;default:break o}u=o;break o}u=v(v(H*o)*v(.009999999776482582))}u=v(S+u);break s}if(u=v(Xe),!hr(y,2)||!Rl(y,2))break s;if(o=Yt(y,2,v(v(C[s+516>>2]-v(gt(s,2)+wt(s,2)))-v(Hs(y,2,H)+qo(y,2,H))),H),d=o!=o,u=v(v(Dt(y,2,H)+gt(y,2))+v(Ot(y,2,H)+wt(y,2))),!(d|u!=u)){u=ht(o,u);break s}u=d?u:o}J=v(T+J);s:{n:{o:{a:{l:{c:{u:{et=u!=u,T=C[y+580>>2];f:{h:{p:switch(d=c[y+584>>2],d|0){case 0:case 3:break h;default:break p}o=C[y+580>>2];p:{if(!((d|0)!=1|o!=o)){if(o=T,!(o<v(0)))break p;break h}v:{if(!((d|0)!=2|o!=o)){if(vt!=vt|T<v(0))break h;break v}o=v(Xe);y:switch(d-1|0){case 1:break v;case 0:break y;default:break p}o=T;break p}o=v(v(vt*T)*v(.009999999776482582))}o=v(J+o);break f}h:{if(hr(y,0)&&Rl(y,0))break h;if(o=v(Xe),u==u)break u;break o}if(o=Yt(y,0,v(v(C[s+520>>2]-v(gt(s,0)+wt(s,0)))-v(Hs(y,0,vt)+qo(y,0,vt))),vt),d=o!=o,T=v(v(Dt(y,0,H)+gt(y,0))+v(Ot(y,0,H)+wt(y,0))),!(d|T!=T)){o=ht(o,T);break f}o=d?T:o}if((et|0)==(o!=o|0)||(ae=C[y+224>>2],ae!=ae))break l;if(u!=u){u=v(v(v(o-J)*ae)+S);break l}if(o==o)break l;break c}if(ae=C[y+224>>2],ae!=ae)break a}o=v(J+v(v(u-S)/ae))}if(u!=u)break o;if(o==o)break s}d=0;break n}d=1}et=H>v(0),Ui=d&Fe&z>>>0<2,u=Ui&&et?H:u,d=d^1,An(y,u,o,zi,Ui&&et?2:d,o==o,u,o,0,6,j,te,de,ee),u=v(C[y+516>>2]+sg(y,2,H)),o=v(C[y+520>>2]+sg(y,0,H))}An(y,u,o,zi,1,1,u,o,1,1,j,te,de,ee);s:{n:{o:{if(!Rl(y,z)||hr(y,z))break o;d=c[(z<<2)+4320>>2]<<2,o=z>>>0<2?vt:H,o=v(v(v(v(C[d+ve>>2]-C[(d+y|0)+516>>2])-wt(s,z))-St(y,z,o))-qo(y,z,o));break n}if(!(hr(y,z)|(c[s+24>>2]&112)!=16)){d=c[(z<<2)+4320>>2]<<2,o=v(v(C[d+ve>>2]-C[(d+y|0)+516>>2])*v(.5));break n}if(!(hr(y,z)|(c[s+24>>2]&112)!=32)){d=c[(z<<2)+4320>>2]<<2,o=v(C[d+ve>>2]-C[(d+y|0)+516>>2]);break n}if(!(xe[c[s+568>>2]+12|0]&2)||!hr(y,z))break s;o=C[ve+(c[(z<<2)+4320>>2]<<2)>>2],o=v(v(Hs(y,z,o)+gt(s,z))+ft(y,z,o))}C[(y+(c[(z<<2)+4288>>2]<<2)|0)+228>>2]=o}s:{n:{if(!Rl(y,oe)||hr(y,oe))break n;d=c[(oe<<2)+4320>>2]<<2,o=z>>>0<2?H:vt,o=v(v(v(v(C[d+ve>>2]-C[(d+y|0)+516>>2])-wt(s,oe))-St(y,oe,o))-qo(y,oe,o));break s}n:{if(hr(y,oe)||(d=c[y+24>>2]>>>13&7,d||(d=c[s+24>>2]>>>10&7),(d|0)!=2))break n;d=c[(oe<<2)+4320>>2]<<2,o=v(v(C[d+ve>>2]-C[(d+y|0)+516>>2])*v(.5));break s}n:{if(hr(y,oe))break n;z=c[y+24>>2]>>>13&7,d=c[s+24>>2],z=z||d>>>10&7;o:{if((z|0)==5){if((d&786432)==524288)break o;break n}if(((z|0)==3|0)==((d&786432)==524288|0))break n}d=c[(oe<<2)+4320>>2]<<2,o=v(C[d+ve>>2]-C[(d+y|0)+516>>2]);break s}if(!(xe[c[s+568>>2]+12|0]&2)||!hr(y,oe))break t;o=C[ve+(c[(oe<<2)+4320>>2]<<2)>>2],o=v(v(Hs(y,oe,o)+gt(s,oe))+ft(y,oe,o))}C[(y+(c[(oe<<2)+4288>>2]<<2)|0)+228>>2]=o}if(E=E+4|0,(D|0)==(E|0))break}if(!((ie|Ie)&1))break i;for(E=ie&1,D=Ie&1,j=Zr>>>0<=1?1:Zr,te=(ie<<2)+4304|0,de=(Ie<<2)+4304|0,ee=c[s+556>>2],ie=c[s+560>>2]-ee>>2,s=0;;){if((s|0)==(ie|0))break r;d=c[ee+(s<<2)>>2];t:{if(xe[d+26|0]&64||(D&&(y=d+228|0,z=c[zs>>2]<<2,C[y+(c[de>>2]<<2)>>2]=v(C[z+ve>>2]-C[(y+z|0)+288>>2])-C[y+(c[Or>>2]<<2)>>2]),!E))break t;d=d+228|0,y=c[Ft>>2]<<2,C[d+(c[te>>2]<<2)>>2]=v(C[y+ve>>2]-C[(d+y|0)+288>>2])-C[d+(c[ni>>2]<<2)>>2]}if(s=s+1|0,(j|0)==(s|0))break}}if(!Bi)break e;Ei(Bi);break e}Gs(),kt()}Te=F+384|0}function Am(){var s=0,o=0;jn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),s=he(8),c[s>>2]=8,c[s+4>>2]=1,Re(7032,2922,6,4368,4392,19,s|0,1),jn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),s=he(4),c[s>>2]=24,Re(7036,2359,2,4400,4408,25,s|0,0),ps(7032,1398,2,4412,4420,26,27),ps(7032,3027,3,4500,4512,28,29),jn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),s=he(8),c[s>>2]=8,c[s+4>>2]=1,Re(7056,3293,2,4520,4408,32,s|0,1),jn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),s=he(4),c[s>>2]=37,Re(7059,2359,2,4528,4408,38,s|0,0),ps(7056,1398,2,4536,4420,39,40),ps(7056,3027,3,4500,4512,28,41),jn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),gm(7062,1,4584,4352,44,45),ps(7062,2915,1,4584,4352,44,45),ps(7062,1129,2,4588,4408,46,47),s=he(8),c[s+4>>2]=0,c[s>>2]=48,Re(7062,3234,4,4608,4624,49,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=50,Re(7062,1981,3,4632,4644,51,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=52,Re(7062,1952,3,4652,4664,53,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=54,Re(7062,3389,3,4672,4664,55,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=56,Re(7062,1800,3,4652,4664,53,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=57,Re(7062,3264,3,4684,4512,58,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=59,Re(7062,1926,2,4696,4420,60,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=61,Re(7062,3399,2,4704,4420,62,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=63,Re(7062,1785,2,4696,4420,60,s|0,0),th(7065,1271,4712,64,4357,65),Zn(1732,0),Zn(1612,8),Zn(2145,16),Zn(2455,24),Zn(2561,32),Zn(1618,40),eh(7065),th(7035,2898,4712,66,4357,67),Xm(2561,0),Xm(1618,8),eh(7035),th(7066,2909,4712,68,4357,69),s=he(4),c[s>>2]=8,o=he(4),c[o>>2]=8,Tl(7066,2903,7098,4714,70,s|0,7098,4718,71,o|0),s=he(4),c[s>>2]=0,o=he(4),c[o>>2]=0,Tl(7066,1607,7091,4420,72,s|0,7091,4664,73,o|0),eh(7066),jn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),gm(7067,1,4724,4352,76,77),ps(7067,1593,1,4724,4352,76,77),ps(7067,2851,2,4728,4420,78,79),ps(7067,1129,2,4736,4408,80,81),s=he(8),c[s+4>>2]=0,c[s>>2]=82,Re(7067,1753,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=84,Re(7067,3005,3,4744,4664,85,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=86,Re(7067,2930,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=88,Re(7067,2335,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=90,Re(7067,1485,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=91,Re(7067,1356,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=92,Re(7067,1818,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=93,Re(7067,2872,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=94,Re(7067,2379,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=95,Re(7067,2164,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=96,Re(7067,1320,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=97,Re(7067,2413,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=98,Re(7067,1504,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=99,Re(7067,2236,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=100,Re(7067,1220,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=101,Re(7067,1137,3,4756,4664,87,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=102,Re(7067,1159,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=104,Re(7067,1846,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=105,Re(7067,1465,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=106,Re(7067,2219,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=107,Re(7067,1196,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=108,Re(7067,2501,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=109,Re(7067,2591,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=110,Re(7067,1540,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=111,Re(7067,2250,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=112,Re(7067,1651,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=113,Re(7067,1428,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=114,Re(7067,2205,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=115,Re(7067,2609,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=116,Re(7067,1556,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=117,Re(7067,1671,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=118,Re(7067,1445,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=119,Re(7067,2567,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=120,Re(7067,1521,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=121,Re(7067,1625,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=122,Re(7067,1408,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=123,Re(7067,2305,3,4792,4718,103,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=124,Re(7067,2093,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=125,Re(7067,2719,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=126,Re(7067,1575,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=127,Re(7067,2188,4,4768,4784,89,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=128,Re(7067,2946,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=130,Re(7067,2347,3,4812,4512,131,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=132,Re(7067,1372,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=133,Re(7067,1832,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=134,Re(7067,2885,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=135,Re(7067,2396,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=136,Re(7067,2176,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=137,Re(7067,1338,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=138,Re(7067,2423,3,4812,4512,131,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=139,Re(7067,1859,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=141,Re(7067,1208,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=143,Re(7067,2515,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=144,Re(7067,2600,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=145,Re(7067,1661,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=146,Re(7067,2621,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=147,Re(7067,1684,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=148,Re(7067,2579,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=149,Re(7067,1638,2,4824,4420,140,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=150,Re(7067,2320,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=151,Re(7067,2103,3,4840,4852,152,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=153,Re(7067,1232,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=154,Re(7067,1148,2,4804,4420,129,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=155,Re(7067,2730,3,4812,4512,131,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=156,Re(7067,2195,3,4860,4872,157,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=158,Re(7067,3034,4,4880,4624,159,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=160,Re(7067,3055,3,4896,4664,161,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=162,Re(7067,1293,2,4908,4420,163,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=164,Re(7067,1388,2,4916,4420,165,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=166,Re(7067,3046,3,4924,4512,167,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=168,Re(7067,2962,2,4936,4420,169,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=170,Re(7067,2982,3,4944,4664,171,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=172,Re(7067,3357,3,4956,4664,173,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=174,Re(7067,3355,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=175,Re(7067,3374,3,4968,4664,176,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=177,Re(7067,3372,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=178,Re(7067,1119,2,4736,4408,83,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=179,Re(7067,1111,2,4980,4420,180,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=181,Re(7067,1244,5,4992,5012,182,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=183,Re(7067,1737,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=184,Re(7067,1715,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=185,Re(7067,2149,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=186,Re(7067,2462,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=187,Re(7067,2633,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=188,Re(7067,1697,2,4832,4714,142,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=189,Re(7067,1260,2,5020,4420,190,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=191,Re(7067,2433,3,4840,4852,152,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=192,Re(7067,2113,3,4840,4852,152,s|0,0),s=he(8),c[s+4>>2]=0,c[s>>2]=193,Re(7067,2741,3,4840,4852,152,s|0,0)}function RT(s,o,u,d,y,E){s=s|0,o=+o,u=u|0,d=d|0,y=y|0,E=E|0;var T=0,S=0,D=0,j=0,te=0,de=0,ee=0,ie=0,F=0,H=0,z=0,J=0,oe=0,ae=0,ve=0,Ae=0,Ie=0,Fe=0,Ne=0;ee=Te-560|0,Te=ee,c[ee+44>>2]=0,Mi(+o),T=mt(1)|0,mt(0)|0;e:{if((T|0)<0){oe=1,Fe=1177,o=-o,Mi(+o),T=mt(1)|0,mt(0)|0;break e}if(y&2048){oe=1,Fe=1180;break e}oe=y&1,Fe=oe?1183:1178,Ne=!oe}e:{if((T&2146435072)==2146435072){T=oe+3|0,bi(s,32,u,T,y&-65537),fi(s,Fe,oe),d=E&32,fi(s,o!=o?d?2451:3459:d?2868:3463,3),bi(s,32,u,T,y^8192),ie=(u|0)<(T|0)?T:u;break e}ve=ee+16|0;r:{i:{t:{if(o=Nm(o,ee+44|0),o=o+o,o!=0){if(T=c[ee+44>>2],c[ee+44>>2]=T-1,Ae=E|32,(Ae|0)!=97)break t;break r}if(Ae=E|32,(Ae|0)==97)break r;te=c[ee+44>>2],de=(d|0)<0?6:d;break i}te=T-29|0,c[ee+44>>2]=te,o=o*268435456,de=(d|0)<0?6:d}for(z=(ee+48|0)+((te|0)>=0?288:0)|0,S=z;o<4294967296&o>=0?d=~~o>>>0:d=0,c[S>>2]=d,S=S+4|0,o=(o-+(d>>>0))*1e9,o!=0;);i:{if((te|0)<=0){d=te,T=S,D=z;break i}for(D=z,d=te;;){F=(d|0)>=29?29:d,T=S-4|0;t:{if(D>>>0>T>>>0)break t;for(d=0;j=c[T>>2],Ie=d,d=F&31,(F&63)>>>0>=32?(ie=j<<d,d=0):(ie=(1<<d)-1&j>>>32-d,d=j<<d),Ie=Ie+d|0,j=ie+H|0,d=Sm(Ie,d>>>0>Ie>>>0?j+1|0:j,1e9),j=ch(d,Wi,-1e9,0)+Ie|0,c[T>>2]=j,T=T-4|0,D>>>0<=T>>>0;);if(!d)break t;D=D-4|0,c[D>>2]=d}for(;T=S,D>>>0<T>>>0&&(S=T-4|0,!c[S>>2]););if(d=c[ee+44>>2]-F|0,c[ee+44>>2]=d,S=T,!((d|0)>0))break}}if((d|0)<0)for(ae=((de+25>>>0)/9|0)+1|0,H=(Ae|0)==102;;){d=0-d|0,ie=(d|0)>=9?9:d;i:{if(T>>>0<=D>>>0){S=c[D>>2];break i}for(F=1e9>>>ie|0,j=-1<<ie^-1,d=0,S=D;Ie=d,d=c[S>>2],c[S>>2]=Ie+(d>>>ie|0),d=Wt(F,d&j),S=S+4|0,S>>>0<T>>>0;);if(S=c[D>>2],!d)break i;c[T>>2]=d,T=T+4|0}if(d=ie+c[ee+44>>2]|0,c[ee+44>>2]=d,D=(!S<<2)+D|0,S=H?z:D,T=T-S>>2>(ae|0)?S+(ae<<2)|0:T,!((d|0)<0))break}d=0;i:{if(T>>>0<=D>>>0||(d=Wt(z-D>>2,9),S=10,j=c[D>>2],j>>>0<10))break i;for(;d=d+1|0,S=Wt(S,10),j>>>0>=S>>>0;);}if(S=(de-((Ae|0)!=102?d:0)|0)-((Ae|0)==103&(de|0)!=0)|0,(S|0)<(Wt(T-z>>2,9)-9|0)){if(F=S+9216|0,j=(F|0)/9|0,te=((((te|0)<0?4:292)+ee|0)+(j<<2)|0)-4048|0,S=10,ie=F+Wt(j,-9)|0,(ie|0)<=7)for(;S=Wt(S,10),ie=ie+1|0,(ie|0)!=8;);F=c[te>>2],ae=(F>>>0)/(S>>>0)|0,H=Wt(ae,S),j=te+4|0;i:{if((F|0)==(H|0)&(j|0)==(T|0))break i;F=F-H|0;t:{if(!(ae&1)&&(o=9007199254740992,!(ge[te-4|0]&1)|((S|0)!=1e9|D>>>0>=te>>>0)))break t;o=9007199254740994}if(J=(T|0)==(j|0)?1:1.5,j=S>>>1|0,J=j>>>0>F>>>0?.5:(j|0)==(F|0)?J:1.5,xe[Fe|0]!=45|Ne||(J=-J,o=-o),c[te>>2]=H,o+J==o)break i;if(d=S+H|0,c[te>>2]=d,d>>>0>=1e9)for(;c[te>>2]=0,te=te-4|0,te>>>0<D>>>0&&(D=D-4|0,c[D>>2]=0),d=c[te>>2]+1|0,c[te>>2]=d,d>>>0>999999999;);if(d=Wt(z-D>>2,9),S=10,j=c[D>>2],j>>>0<10)break i;for(;d=d+1|0,S=Wt(S,10),j>>>0>=S>>>0;);}S=te+4|0,T=T>>>0>S>>>0?S:T}for(;j=T,F=T>>>0<=D>>>0,!F&&(T=j-4|0,!c[T>>2]););i:{if((Ae|0)!=103){te=y&8;break i}if(S=de||1,T=(S|0)>(d|0)&(d|0)>-5,de=(T?d^-1:-1)+S|0,E=(T?-1:-2)+E|0,te=y&8,te)break i;T=-9;t:{if(F||(te=c[j-4>>2],!te)||(ie=10,T=0,(te>>>0)%10|0))break t;for(;S=T,T=T+1|0,ie=Wt(ie,10),!((te>>>0)%(ie>>>0)|0););T=S^-1}if(S=Wt(j-z>>2,9),(E&-33)==70){te=0,T=(T+S|0)-9|0,T=(T|0)>0?T:0,de=(T|0)>(de|0)?de:T;break i}te=0,T=((d+S|0)+T|0)-9|0,T=(T|0)>0?T:0,de=(T|0)>(de|0)?de:T}if(ie=-1,F=te|de,((F?2147483645:2147483646)|0)<(de|0))break e;H=(((F|0)!=0)+de|0)+1|0,S=E&-33;i:{if((S|0)==70){if((H^2147483647)<(d|0))break e;T=(d|0)>0?d:0;break i}if(T=d>>31,T=zn((T^d)-T|0,0,ve),(ve-T|0)<=1)for(;T=T-1|0,ge[T|0]=48,(ve-T|0)<2;);if(ae=T-2|0,ge[ae|0]=E,ge[T-1|0]=(d|0)<0?45:43,T=ve-ae|0,(T|0)>(H^2147483647))break e}if(d=T+H|0,(d|0)>(oe^2147483647))break e;H=d+oe|0,bi(s,32,u,H,y),fi(s,Fe,oe),bi(s,48,u,H,y^65536);i:{t:{s:{if((S|0)==70){for(E=ee+16|0,d=E|8,te=E|9,S=D>>>0>z>>>0?z:D,D=S;;){T=zn(c[D>>2],0,te);n:{if((S|0)!=(D|0)){if(ee+16>>>0>=T>>>0)break n;for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);break n}if((T|0)!=(te|0))break n;ge[ee+24|0]=48,T=d}if(fi(s,T,te-T|0),D=D+4|0,!(z>>>0>=D>>>0))break}if(F&&fi(s,4275,1),(de|0)<=0|D>>>0>=j>>>0)break s;for(;;){if(T=zn(c[D>>2],0,te),T>>>0>ee+16>>>0)for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);if(fi(s,T,(de|0)>=9?9:de),T=de-9|0,D=D+4|0,j>>>0<=D>>>0)break t;if(d=(de|0)>9,de=T,!d)break}break t}n:{if((de|0)<0)break n;for(z=D>>>0<j>>>0?j:D+4|0,E=ee+16|0,d=E|8,j=E|9,S=D;;){T=zn(c[S>>2],0,j),(j|0)==(T|0)&&(ge[ee+24|0]=48,T=d);o:{if((S|0)!=(D|0)){if(ee+16>>>0>=T>>>0)break o;for(;T=T-1|0,ge[T|0]=48,ee+16>>>0<T>>>0;);break o}if(fi(s,T,1),T=T+1|0,!(te|de))break o;fi(s,4275,1)}if(E=j-T|0,fi(s,T,(E|0)>(de|0)?de:E),de=de-E|0,S=S+4|0,z>>>0<=S>>>0)break n;if(!((de|0)>=0))break}}bi(s,48,de+18|0,18,0),fi(s,ae,ve-ae|0);break i}T=de}bi(s,48,T+9|0,9,0)}bi(s,32,u,H,y^8192),ie=(u|0)<(H|0)?H:u;break e}te=(E<<26>>31&9)+Fe|0;r:{if(d>>>0>11)break r;for(T=12-d|0,J=16;J=J*16,T=T-1|0,!!T;);if(xe[te|0]==45){o=-(J+(-o-J));break r}o=o+J-J}for(z=oe|2,D=E&32,S=c[ee+44>>2],T=S>>31,T=zn((T^S)-T|0,0,ve),(ve|0)==(T|0)&&(ge[ee+15|0]=48,T=ee+15|0),de=T-2|0,ge[de|0]=E+15,ge[T-1|0]=(S|0)<0?45:43,T=y&8,S=ee+16|0;E=S,zt(o)<2147483648?j=~~o:j=-2147483648,ge[S|0]=D|xe[j+5504|0],o=(o-+(j|0))*16,S=E+1|0,!(T|(d|0)>0)&o==0|(S-(ee+16|0)|0)!=1||(ge[E+1|0]=46,S=E+2|0),o!=0;);if(ie=-1,T=ve-de|0,E=T+z|0,(2147483645-E|0)<(d|0))break e;r:{i:{if(!d||(D=S-(ee+16|0)|0,(D-2|0)>=(d|0)))break i;d=d+2|0;break r}D=S-(ee+16|0)|0,d=D}E=d+E|0,bi(s,32,u,E,y),fi(s,te,z),bi(s,48,u,E,y^65536),fi(s,ee+16|0,D),bi(s,48,d-D|0,0,0),fi(s,de,T),bi(s,32,u,E,y^8192),ie=(u|0)<(E|0)?E:u}return Te=ee+560|0,ie|0}function Em(s,o,u,d,y,E,T){var S=0,D=0,j=0,te=0,de=0,ee=0,ie=0,F=0,H=0,z=0,J=0,oe=0,ae=0,ve=0,Ae=0,Ie=0,Fe=0,Ne=0,We=0,et=0;j=Te-80|0,Te=j,c[j+76>>2]=o,Ne=j+55|0,ae=j+56|0;e:{r:{i:{t:{s:for(;;){if(te=o,(H^2147483647)<(S|0))break t;H=S+H|0;n:{o:{a:{if(S=te,D=xe[S|0],D)for(;;){l:{o=D&255;c:{if(!o){o=S;break c}if((o|0)!=37)break l;for(D=S;;){if(xe[D+1|0]!=37){o=D;break c}if(S=S+1|0,de=xe[D+2|0],o=D+2|0,D=o,(de|0)!=37)break}}if(S=S-te|0,Fe=H^2147483647,(S|0)>(Fe|0))break t;if(s&&fi(s,te,S),S)continue s;c[j+76>>2]=o,S=o+1|0,J=-1,D=ge[o+1|0],!Cl(D)|xe[o+2|0]!=36||(J=D-48|0,ve=1,S=o+3|0),c[j+76>>2]=S,F=0,D=ge[S|0],o=D-32|0;c:{if(o>>>0>31){de=S;break c}if(de=S,o=1<<o,!(o&75913))break c;for(;;){if(de=S+1|0,c[j+76>>2]=de,F=o|F,D=ge[S+1|0],o=D-32|0,o>>>0>=32)break c;if(S=de,o=1<<o,!(o&75913))break}}c:{if((D|0)==42){o=ge[de+1|0];u:{if(!(!Cl(o)|xe[de+2|0]!=36)){c[((o<<2)+y|0)-192>>2]=10,D=de+3|0,ve=1,z=c[((ge[de+1|0]<<3)+d|0)-384>>2];break u}if(ve)break a;if(D=de+1|0,!s){c[j+76>>2]=D,ve=0,z=0;break c}o=c[u>>2],c[u>>2]=o+4,ve=0,z=c[o>>2]}if(c[j+76>>2]=D,(z|0)>=0)break c;z=0-z|0,F=F|8192;break c}if(z=Hm(j+76|0),(z|0)<0)break t;D=c[j+76>>2]}S=0,ie=-1;c:{if(xe[D|0]!=46){o=D,oe=0;break c}if(xe[D+1|0]==42){o=ge[D+2|0];u:{if(!(!Cl(o)|xe[D+3|0]!=36)){c[((o<<2)+y|0)-192>>2]=10,o=D+4|0,ie=c[((ge[D+2|0]<<3)+d|0)-384>>2];break u}if(ve)break a;if(o=D+2|0,ie=0,!s)break u;D=c[u>>2],c[u>>2]=D+4,ie=c[D>>2]}c[j+76>>2]=o,oe=(ie^-1)>>>31|0;break c}c[j+76>>2]=D+1,ie=Hm(j+76|0),o=c[j+76>>2],oe=1}for(;;){if(ee=S,de=28,Ae=o,S=ge[o|0],S-123>>>0<4294967238)break i;if(o=Ae+1|0,S=xe[(S+Wt(ee,58)|0)+4975|0],!(S-1>>>0<8))break}c[j+76>>2]=o;c:{u:{if((S|0)!=27){if(!S)break i;if((J|0)>=0){c[(J<<2)+y>>2]=S,S=(J<<3)+d|0,D=c[S+4>>2],c[j+64>>2]=c[S>>2],c[j+68>>2]=D;break u}if(!s)break n;Lm(j- -64|0,S,u,T);break c}if((J|0)>=0)break i}if(S=0,!s)continue s}D=F&-65537,F=F&8192?D:F,J=0,Ie=1167,de=ae;c:{u:{f:{h:{p:{v:{y:{d:{m:{A:{g:{x:{T:{E:{k:{b:switch(S=ge[Ae|0],S=ee&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break u;case 27:break y;case 12:case 17:break A;case 23:break g;case 0:case 32:break x;case 24:break T;case 22:break E;case 29:break k;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 o;default:break b}b:switch(S-65|0){case 0:case 4:case 5:case 6:break u;case 2:break p;case 1:case 3:break o;default:break b}if((S|0)==83)break v;break o}D=c[j+64>>2],ee=c[j+68>>2],S=1167;break m}S=0;E:switch(ee&255){case 0:c[c[j+64>>2]>>2]=H;continue s;case 1:c[c[j+64>>2]>>2]=H;continue s;case 2:te=c[j+64>>2],c[te>>2]=H,c[te+4>>2]=H>>31;continue s;case 3:jr[c[j+64>>2]>>1]=H;continue s;case 4:ge[c[j+64>>2]]=H;continue s;case 6:c[c[j+64>>2]>>2]=H;continue s;case 7:break E;default:continue s}te=c[j+64>>2],c[te>>2]=H,c[te+4>>2]=H>>31;continue s}ie=ie>>>0<=8?8:ie,F=F|8,S=120}if(te=ae,D=c[j+64>>2],ee=c[j+68>>2],D|ee)for(We=S&32;te=te-1|0,ge[te|0]=We|xe[(D&15)+5504|0],et=!ee&D>>>0>15|(ee|0)!=0,Ae=ee,ee=ee>>>4|0,D=(Ae&15)<<28|D>>>4,!!et;);if(!(F&8)|!(c[j+64>>2]|c[j+68>>2]))break d;Ie=(S>>>4|0)+1167|0,J=2;break d}if(S=ae,te=c[j+68>>2],ee=te,D=c[j+64>>2],te|D)for(;S=S-1|0,ge[S|0]=D&7|48,Ae=!ee&D>>>0>7|(ee|0)!=0,te=ee,ee=te>>>3|0,D=(te&7)<<29|D>>>3,!!Ae;);if(te=S,!(F&8))break d;S=ae-te|0,ie=(S|0)<(ie|0)?ie:S+1|0;break d}if(D=c[j+64>>2],S=c[j+68>>2],ee=S,(S|0)<0){te=0-(ee+((D|0)!=0)|0)|0,ee=te,D=0-D|0,c[j+64>>2]=D,c[j+68>>2]=te,J=1,S=1167;break m}if(F&2048){J=1,S=1168;break m}J=F&1,S=J?1169:1167}Ie=S,te=zn(D,ee,ae)}if((ie|0)<0&&oe)break t;if(F=oe?F&-65537:F,S=c[j+64>>2],D=c[j+68>>2],!((S|D)!=0|ie)){te=ae,ie=0;break o}S=!(S|D)+(ae-te|0)|0,ie=(S|0)<(ie|0)?ie:S;break o}F=0,oe=ie>>>0>=2147483647?2147483647:ie,ee=oe,de=(ee|0)!=0;y:{d:{S=c[j+64>>2],te=S||4277,S=te;m:{A:{g:{if(!(S&3)|!ee)break g;for(;;){if(F=xe[S|0],!F)break A;if(ee=ee-1|0,de=(ee|0)!=0,S=S+1|0,!(S&3))break g;if(!ee)break}}if(!de)break d;g:{if(!(!xe[S|0]|ee>>>0<4))for(;;){if(de=c[S>>2],(de^-1)&de-16843009&-2139062144)break g;if(S=S+4|0,ee=ee-4|0,!(ee>>>0>3))break}if(!ee)break d}de=0;break m}de=1}for(;;){if(!de){F=xe[S|0],de=1;continue}if(!F)break y;if(S=S+1|0,ee=ee-1|0,!ee)break d;de=0}}S=0}if(S=S?S-te|0:oe,de=S+te|0,(ie|0)>=0){F=D,ie=S;break o}if(F=D,ie=S,xe[de|0])break t;break o}if(ie){D=c[j+64>>2];break h}S=0,bi(s,32,z,0,F);break f}c[j+12>>2]=0,c[j+8>>2]=c[j+64>>2],D=j+8|0,c[j+64>>2]=D,ie=-1}S=0;h:{for(;;){if(te=c[D>>2],!te)break h;if(te=Ym(j+4|0,te),de=(te|0)<0,!(de|te>>>0>ie-S>>>0)){if(D=D+4|0,S=S+te|0,ie>>>0>S>>>0)continue;break h}break}if(de)break r}if(de=61,(S|0)<0)break i;if(bi(s,32,z,S,F),!S){S=0;break f}for(de=0,D=c[j+64>>2];;){if(te=c[D>>2],!te||(te=Ym(j+4|0,te),de=te+de|0,de>>>0>S>>>0))break f;if(fi(s,j+4|0,te),D=D+4|0,!(S>>>0>de>>>0))break}}bi(s,32,z,S,F^8192),S=(S|0)<(z|0)?z:S;continue s}if((ie|0)<0&&oe)break t;if(de=61,S=$e[E|0](s,Ht[j+64>>3],z,ie,F,S)|0,(S|0)>=0)continue s;break i}ge[j+55|0]=c[j+64>>2],ie=1,te=Ne,F=D;break o}D=xe[S+1|0],S=S+1|0}if(s)break e;if(!ve)break n;for(S=1;;){if(s=c[(S<<2)+y>>2],s){if(Lm((S<<3)+d|0,s,u,T),H=1,S=S+1|0,(S|0)!=10)continue;break e}break}if(H=1,S>>>0>=10)break e;for(;;){if(c[(S<<2)+y>>2])break a;if(S=S+1|0,(S|0)==10)break}break e}de=28;break i}if(ee=de-te|0,ie=(ie|0)>(ee|0)?ie:ee,(ie|0)>(J^2147483647))break t;if(de=61,D=ie+J|0,S=(D|0)<(z|0)?z:D,(Fe|0)<(S|0))break i;bi(s,32,S,D,F),fi(s,Ie,J),bi(s,48,S,D,F^65536),bi(s,48,ie,ee,0),fi(s,te,ee),bi(s,32,S,D,F^8192);continue}break}H=0;break e}de=61}c[1781]=de}H=-1}return Te=j+80|0,H}function LT(s,o,u,d){s=s|0,o=+o,u=+u,d=d|0;var y=v(0),E=v(0),T=0,S=v(0),D=0,j=v(0),te=0,de=v(0),ee=0;ee=Te+-64|0,Te=ee,T=c[s>>2],Ki(ee+8|0,0,56),c[1755]=c[1755]+1,xm(T),S=v(o),E=C[T+572>>2];e:{r:{i:switch(s=c[T+576>>2],s|0){case 0:case 3:break r;default:break i}y=C[T+572>>2];i:{if(!((s|0)!=1|y!=y)){if(y=E,!(y<v(0)))break i;break r}t:{if(!((s|0)!=2|y!=y)){if(S!=S|E<v(0))break r;break t}y=v(Xe);s:switch(s-1|0){case 1:break t;case 0:break s;default:break i}y=E;break i}y=v(v(E*S)*v(.009999999776482582))}de=v(y+v(ft(T,2,S)+St(T,2,S))),te=1;break e}y=v(0),E=C[T+216>>2];r:{i:{s=c[T+216>>2];t:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break r;te=4336;n:{if((s|0)!=2141891242){if(E==E)break n;te=4344}switch(y=C[te>>2],c[te+4>>2]-1|0){case 0:break t;case 1:break s;default:break i}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break t}y=v(v(y*S)*v(.009999999776482582))}if(y!=y)break i;y=v(0);t:{if((s|0)==2139156720)break t;if((s|0)==2140081935)break r;D=4336;s:{if((s|0)!=2141891242){if(E==E)break s;D=4344}switch(y=C[D>>2],de=v(Xe),te=2,c[D+4>>2]-1|0){case 1:break t;case 0:break r;default:break e}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break r}de=v(v(y*S)*v(.009999999776482582)),te=2;break e}te=S==S,de=S;break e}te=2,de=y}j=v(u),E=C[T+580>>2];e:{r:{i:switch(s=c[T+584>>2],s|0){case 0:case 3:break r;default:break i}y=C[T+580>>2];i:{if(!((s|0)!=1|y!=y)){if(y=E,!(y<v(0)))break i;break r}t:{if(!((s|0)!=2|y!=y)){if(j!=j|E<v(0))break r;break t}y=v(Xe);s:switch(s-1|0){case 1:break t;case 0:break s;default:break i}y=E;break i}y=v(v(E*j)*v(.009999999776482582))}E=v(y+v(ft(T,0,S)+St(T,0,S))),s=1;break e}y=v(0),E=C[T+220>>2];r:{i:{s=c[T+220>>2];t:{s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break r;D=4336;n:{if((s|0)!=2141891242){if(E==E)break n;D=4344}switch(y=C[D>>2],c[D+4>>2]-1|0){case 0:break t;case 1:break s;default:break i}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break t}y=v(v(y*j)*v(.009999999776482582))}if(y!=y)break i;y=v(0);t:{if((s|0)==2139156720)break t;if((s|0)==2140081935)break r;D=4336;s:{if((s|0)!=2141891242){if(E==E)break s;D=4344}switch(y=C[D>>2],E=v(Xe),s=2,c[D+4>>2]-1|0){case 0:break r;case 1:break t;default:break e}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break r}E=v(v(y*j)*v(.009999999776482582)),s=2;break e}s=j==j,E=j;break e}s=2,E=y}An(T,de,E,d,te,s,S,j,1,0,c[T+568>>2],ee+8|0,0,c[1755])&&(Om(T,xe[T+300|0]&3,S,j,S),Cm(T,+C[c[T+568>>2]+20>>2],0,0)),Te=ee- -64|0}function CT(s,o){s=s|0,o=o|0;var u=0,d=v(0),y=0,E=0,T=v(0),S=0,D=0,j=0,te=v(0);e:{D=c[o>>2],o=c[s>>2];r:{if((c[D+24>>2]^c[o+24>>2])&8388607)break r;te=C[D+40>>2],y=c[D+40>>2],d=C[o+40>>2];i:{t:{if(u=c[o+40>>2],(u|0)!=2139156720){if(T=v(Xe),s=3,(u|0)==2141891242)break i;if((u|0)!=2140081935)break t;T=v(0),s=1;break i}s=2;break i}if(s=0,d!=d)break i;T=(Ce(2,(u&-1073741825)+536870912|0),He()),s=u&1073741824?2:1}i:{t:{if((y|0)!=2139156720){if(d=v(Xe),u=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break t;d=v(0),u=1;break i}d=v(0),u=2;break i}if(u=0,te!=te)break i;d=(Ce(2,(y&-1073741825)+536870912|0),He()),u=y&1073741824?2:1}if((u|0)!=(s|0)|!(!s|T!=T&d!=d|v(zt(v(T-d)))<v(9999999747378752e-20))||(u=o+44|0,E=D+44|0,c[u>>2]!=c[E>>2]))break r;s=0;i:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break i;if(S=s<<2,c[S+u>>2]!=c[E+S>>2])break}if(y>>>0<8)break r}if(u=o+80|0,E=D+80|0,c[u>>2]!=c[E>>2])break r;s=0;i:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break i;if(S=s<<2,c[S+u>>2]!=c[E+S>>2])break}if(y>>>0<8)break r}if(u=o+116|0,E=D+116|0,c[u>>2]!=c[E>>2])break r;s=0;i:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break i;if(S=s<<2,c[S+u>>2]!=c[E+S>>2])break}if(y>>>0<8)break r}if(u=o+152|0,E=D+152|0,c[u>>2]!=c[E>>2])break r;s=0;i:{for(;;){if(y=s,s=s+1|0,(s|0)==9)break i;if(S=s<<2,c[S+u>>2]!=c[E+S>>2])break}if(y>>>0<8)break r}if(u=o+188|0,E=D+188|0,c[u>>2]!=c[E>>2])break r;s=0;i:{for(;;){if(y=s,s=s+1|0,(s|0)==3)break i;if(S=s<<2,c[S+u>>2]!=c[E+S>>2])break}if(y>>>0<2)break r}for(S=D+200|0,j=o+200|0,s=0,y=1;;){i:{if(s=s<<2,u=c[s+S>>2],E=c[s+j>>2],!y)break i;if(y=0,s=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0))break r;for(S=D+208|0,j=o+208|0,s=0,y=1;;){i:{if(s=s<<2,u=c[s+S>>2],E=c[s+j>>2],!y)break i;if(y=0,s=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0))break r;for(S=D+216|0,j=o+216|0,s=0,y=1;;){i:{if(s=s<<2,u=c[s+S>>2],E=c[s+j>>2],!y)break i;if(y=0,s=1,(u|0)==(E|0))continue}break}if((u|0)!=(E|0)||(T=C[D+28>>2],s=T!=T,d=C[o+28>>2],(s|0)==(d==d|0)|!(s|d!=d)&d!=T)||(d=C[o+32>>2],T=C[D+32>>2],(d==d|0)==(T!=T|0)|d==d&d!=T)||(T=C[D+36>>2],s=T!=T,d=C[o+36>>2],(s|0)==(d==d|0)|!s&d!=T))break r;if(s=0,d=C[o+224>>2],d!=d&&(s=1,T=C[D+224>>2],T!=T)||(T=d,d=C[D+224>>2],T==d|d!=d&s))break e}for(ji(o+24|0,D+24|0,204);;){if(s=xe[o+4|0],s&4)break e;if(ge[o+4|0]=s|4,s=c[o+20>>2],s&&$e[s|0](o),c[o+308>>2]=2143289344,o=c[o+552>>2],!o)break}}}function IT(s,o){s=s|0,o=o|0;var u=0,d=0,y=0,E=0,T=0,S=0,D=0,j=0,te=0,de=0,ee=0,ie=0,F=0,H=0,z=0,J=0;u=o,o=c[o>>2]+7&-8,c[u>>2]=o+16,F=s,D=c[o>>2],d=c[o+4>>2],s=c[o+12>>2],ee=s,T=Te-32|0,Te=T,s=s&2147483647,S=s,y=s-1006698496|0,s=s-1140785152|0,u=c[o+8>>2],o=u;e:{if((y|0)==(s|0)&o>>>0<o>>>0|s>>>0>y>>>0){if(s=u,u=ee<<4|s>>>28,o=s<<4|d>>>28,s=u,d=d&268435455,(d|0)==134217728&(D|0)!=0|d>>>0>134217728){s=s+1073741824|0,o=o+1|0,s=o?s:s+1|0;break e}if(s=s+1073741824|0,D|(d|0)!=134217728)break e;d=o&1,o=d+o|0,s=o>>>0<d>>>0?s+1|0:s;break e}if(!(!o&(S|0)==2147418112?!(d|D):S>>>0<2147418112)){s=u,u=ee<<4|s>>>28,o=s<<4|d>>>28,s=u&524287|2146959360;break e}if(o=0,s=2146435072,S>>>0>1140785151||(s=0,ie=S>>>16|0,ie>>>0<15249))break e;o=D,s=d,y=ee&65535|65536,S=y,de=u,E=u,j=ie-15233|0;r:{if(j&64){u=o,y=j+-64|0,o=y&31,(y&63)>>>0>=32?(s=u<<o,E=0):(s=(1<<o)-1&u>>>32-o|s<<o,E=u<<o),y=s,o=0,s=0;break r}if(!j)break r;te=E,E=j&31,(j&63)>>>0>=32?(u=te<<E,E=0):(u=(1<<E)-1&te>>>32-E|y<<E,E=te<<E),y=u,H=E,te=o,u=64-j|0,E=u&31,(u&63)>>>0>=32?(u=0,o=s>>>E|0):(u=s>>>E|0,o=((1<<E)-1&s)<<32-E|te>>>E),E=H|o,y=u|y,o=j&31,(j&63)>>>0>=32?(u=te<<o,o=0):(u=(1<<o)-1&te>>>32-o|s<<o,o=te<<o),s=u}c[T+16>>2]=o,c[T+20>>2]=s,c[T+24>>2]=E,c[T+28>>2]=y,o=15361-ie|0;r:{if(o&64){d=de,o=o+-64|0,s=o&31,(o&63)>>>0>=32?(u=0,D=S>>>s|0):(u=S>>>s|0,D=((1<<s)-1&S)<<32-s|d>>>s),d=u,de=0,S=0;break r}if(!o)break r;y=de,s=64-o|0,u=s&31,(s&63)>>>0>=32?(s=y<<u,E=0):(s=(1<<u)-1&y>>>32-u|S<<u,E=y<<u),y=D,D=o&31,(o&63)>>>0>=32?(u=0,y=d>>>D|0):(u=d>>>D|0,y=((1<<D)-1&d)<<32-D|y>>>D),D=E|y,d=s|u,y=de,u=o&31,(o&63)>>>0>=32?(s=0,de=S>>>u|0):(s=S>>>u|0,de=((1<<u)-1&S)<<32-u|y>>>u),S=s}if(c[T>>2]=D,c[T+4>>2]=d,c[T+8>>2]=de,c[T+12>>2]=S,o=c[T+8>>2],s=c[T+12>>2]<<4|o>>>28,o=o<<4,u=c[T>>2],S=c[T+4>>2],o=S>>>28|o,d=S&268435455,u=u|(c[T+16>>2]|c[T+24>>2]|(c[T+20>>2]|c[T+28>>2]))!=0,(d|0)==134217728&(u|0)!=0|d>>>0>134217728){o=o+1|0,s=o?s:s+1|0;break e}if(u|(d|0)!=134217728)break e;u=o,o=o+(o&1)|0,s=u>>>0>o>>>0?s+1|0:s}Te=T+32|0,Ce(0,o|0),Ce(1,ee&-2147483648|s),z=F,J=+Li(),Ht[z>>3]=J}function An(s,o,u,d,y,E,T,S,D,j,te,de,ee,ie){var F=v(0),H=0,z=0,J=0,oe=0,ae=v(0),ve=0,Ae=0,Ie=v(0);e:{if(!(c[s+312>>2]!=(ie|0)&&xe[s+4|0]&4)&&(oe=0,c[s+316>>2]==(d|0)))break e;c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+320>>2]=0,oe=1}ve=ee+1|0;e:{r:{i:{t:{if(c[s+8>>2]){if(ae=ft(s,2,T),Ie=St(s,2,T),F=v(ft(s,0,T)+St(s,0,T)),ee=s+524|0,ae=v(ae+Ie),km(y,o,E,u,c[s+532>>2],C[ee>>2],c[s+536>>2],C[s+528>>2],C[s+540>>2],C[s+544>>2],ae,F,te))break i;if(z=c[s+320>>2],!z)break t;for(H=s+324|0;;){if(ee=H+Wt(J,24)|0,km(y,o,E,u,c[ee+8>>2],C[ee>>2],c[ee+12>>2],C[ee+4>>2],C[ee+16>>2],C[ee+20>>2],ae,F,te))break i;if(J=J+1|0,(z|0)==(J|0))break}break t}if(!D){if(Ae=c[s+320>>2],!Ae)break t;for(z=s+324|0;;){H=Wt(J,24),ee=H+z|0,F=C[ee>>2];s:{n:{if(!(F!=F|o!=o)){if(v(zt(v(F-o)))<v(9999999747378752e-20))break n;break s}if(F==F|o==o)break s}H=z+H|0,F=C[H+4>>2];n:{if(!(F!=F|u!=u)){if(v(zt(v(F-u)))<v(9999999747378752e-20))break n;break s}if(F==F|u==u)break s}if(c[H+8>>2]!=(y|0))break s;if(c[H+12>>2]==(E|0))break i}if(J=J+1|0,(Ae|0)==(J|0))break}break t}ee=s+524|0,F=C[ee>>2];s:{if(!(F!=F|o!=o)){if(v(zt(v(F-o)))<v(9999999747378752e-20))break s;break t}if(F==F|o==o)break t}H=c[s+532>>2]==(y|0)&&c[s+536>>2]==(E|0)?ee:0,F=C[s+528>>2],ee=F!=F,z=u!=u;s:{if(ee|z){ee=ee&z;break s}ee=v(zt(v(F-u)))<v(9999999747378752e-20)}ee=ee?H:0;break i}ym(s,o,u,d,y,E,T,S,D,te,de,ve,ie,j),c[s+316>>2]=d;break r}if(!(!ee|oe)){C[s+516>>2]=C[ee+16>>2],C[s+520>>2]=C[ee+20>>2],d=(D?12:16)+de|0,c[d>>2]=c[d>>2]+1;break e}if(ym(s,o,u,d,y,E,T,S,D,te,de,ve,ie,j),c[s+316>>2]=d,ee)break e}ee=c[s+320>>2],d=ee+1|0,d>>>0>hm[de+8>>2]&&(c[de+8>>2]=d),(ee|0)==8&&(c[s+320>>2]=0,ee=0),D?d=s+524|0:(c[s+320>>2]=ee+1,d=(Wt(ee,24)+s|0)+324|0),c[d+12>>2]=E,c[d+8>>2]=y,C[d+4>>2]=u,C[d>>2]=o,C[d+16>>2]=C[s+516>>2],C[d+20>>2]=C[s+520>>2],ee=0}e:{if(!D||(d=c[s+520>>2],c[s+244>>2]=c[s+516>>2],c[s+248>>2]=d,d=xe[s+4|0],y=d|1,ge[s+4|0]=y,!(d&4)))break e;ge[s+4|0]=y&251}return c[s+312>>2]=ie,!ee|oe}function ih(s){s=s|0;var o=0,u=0,d=0,y=0,E=0,T=0,S=0,D=0,j=0,te=0,de=0;S=8;e:{if(s>>>0>4294967239)break e;r:{for(;;){S=S>>>0<=8?8:S,o=c[1751],E=o,y=c[1750],s=s>>>0<=8?8:s+3&-4;i:{if(s>>>0<=127){T=(s>>>3|0)-1|0;break i}if(d=Tr(s),T=((s>>>29-d^4)-(d<<2)|0)+110|0,s>>>0<=4095)break i;d=((s>>>30-d^2)-(d<<1)|0)+71|0,T=d>>>0>=63?63:d}if(u=T&31,(T&63)>>>0>=32?(d=0,o=o>>>u|0):(d=o>>>u|0,o=((1<<u)-1&o)<<32-u|y>>>u),o|d){for(;;){y=d;i:{if(o|d){u=d-1|0,D=u+1|0,E=u,u=o-1|0,E=(u|0)!=-1?D:E,d=Tr(d^E),d=(d|0)==32?Tr(o^u)+32|0:d,u=63-d|0,Wi=0-(d>>>0>63)|0;break i}Wi=0,u=64}E=u,u=E&31,(E&63)>>>0>=32?(d=0,o=y>>>u|0):(d=y>>>u|0,o=((1<<u)-1&y)<<32-u|o>>>u),D=o,T=E+T|0,u=T<<4,o=c[u+5976>>2],E=u+5968|0;i:{if((o|0)!=(E|0)){if(y=nh(o,S,s),y)break e;y=c[o+4>>2],c[y+8>>2]=c[o+8>>2],c[c[o+8>>2]+4>>2]=y,c[o+8>>2]=E,y=u+5972|0,c[o+4>>2]=c[y>>2],c[y>>2]=o,c[c[o+4>>2]+8>>2]=o,T=T+1|0,o=(d&1)<<31|D>>>1,d=d>>>1|0;break i}j=c[1751],E=T&63,o=E,y=o&31,o>>>0>=32?(o=0,u=-1>>>y|0):(o=-1>>>y|0,u=o|(1<<y)-1<<32-y),u=u&-2,y=E&31,E>>>0>=32?(o=u<<y,u=0):(o=(1<<y)-1&u>>>32-y|o<<y,u=u<<y),te=u,y=o,E=0-T&63,u=E,o=u&31,u>>>0>=32?(o=-1<<o,u=0):(u=-1<<o,o=u|(1<<o)-1&-1>>>32-o),de=u&-2,u=E&31,E>>>0>=32?(E=0,o=o>>>u|0):(E=o>>>u|0,o=((1<<u)-1&o)<<32-u|de>>>u),o=o|te,Wi=y|E,c[1750]=c[1750]&o,c[1751]=Wi&j,o=D^1}if(!(o|d))break}E=c[1751],y=c[1750]}i:{if(y|E){d=Tr(E),u=63-((d|0)==32?Tr(y)+32|0:d)|0,o=u<<4,d=c[o+5976>>2];t:{if(!E&y>>>0<1073741824||(T=99,o=o+5968|0,(o|0)==(d|0)))break t;for(;;){if(!T)break t;if(y=nh(d,S,s),y)break e;if(T=T-1|0,d=c[d+8>>2],(o|0)==(d|0))break}d=o}if(sh(s+48|0))break i;if(!d||(o=(u<<4)+5968|0,(o|0)==(d|0)))break r;for(;;){if(y=nh(d,S,s),y)break e;if(d=c[d+8>>2],(o|0)==(d|0))break}break r}if(!sh(s+48|0))break r}if(y=0,S-1&S)break e;if(!(s>>>0<=4294967239))break}break e}y=0}return y|0}function DT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=0,T=0,S=0,D=0,j=0,te=0,de=0,ee=0;S=Te-80|0,Te=S,s=c[s>>2];e:{r:{if(D=c[o>>2],!c[D+552>>2]){if(c[s+8>>2])break r;o=c[s+556>>2],T=o+(u<<2)|0,d=c[s+560>>2],y=s+564|0,E=c[y>>2];i:{if(d>>>0<E>>>0){if((d|0)==(T|0)){c[T>>2]=D,c[s+560>>2]=T+4;break i}if(u=d,o=d-4|0,d>>>0>o>>>0)for(;c[u>>2]=c[o>>2],u=u+4|0,o=o+4|0,d>>>0>o>>>0;);c[s+560>>2]=u,o=T+4|0,(o|0)!=(d|0)&&(o=d-o|0,Vs(d-(o&-4)|0,T,o)),c[T>>2]=D;break i}if(d=(d-o>>2)+1|0,d>>>0>=1073741824)break e;o=E-o|0,E=o>>1,y=Qo(S+32|0,o>>>0>=2147483644?1073741823:d>>>0<E>>>0?E:d,u,y),u=c[y+8>>2];t:{if((u|0)!=c[y+12>>2])break t;if(o=c[y+4>>2],d=c[y>>2],o>>>0>d>>>0){d=((o-d>>2)+1|0)/-2<<2,j=d+o|0,E=o,o=u-o|0,u=Vs(j,E,o)+o|0,c[y+8>>2]=u,c[y+4>>2]=d+c[y+4>>2];break t}o=(u|0)==(d|0)?1:u-d>>1,E=Qo(S+56|0,o,o>>>2|0,c[y+16>>2]),d=c[E+8>>2],o=c[y+4>>2],u=c[y+8>>2];s:{if((o|0)==(u|0)){u=d,d=o;break s}for(u=(u-o|0)+d|0;c[d>>2]=c[o>>2],o=o+4|0,d=d+4|0,(d|0)!=(u|0););o=c[y+8>>2],d=c[y+4>>2]}if(j=c[y>>2],c[y>>2]=c[E>>2],c[E>>2]=j,c[y+4>>2]=c[E+4>>2],c[E+4>>2]=d,c[y+8>>2]=u,c[E+8>>2]=o,te=c[y+12>>2],c[y+12>>2]=c[E+12>>2],c[E+12>>2]=te,(o|0)!=(d|0)&&(c[E+8>>2]=((d-o|0)+3&-4)+o),!j)break t;Ei(j),u=c[y+8>>2]}if(c[u>>2]=D,c[y+8>>2]=c[y+8>>2]+4,o=c[s+556>>2],u=T-o|0,de=y,ee=Vs(c[y+4>>2]-u|0,o,u),c[de+4>>2]=ee,d=c[s+560>>2]-T|0,T=Vs(c[y+8>>2],T,d),o=c[s+556>>2],c[s+556>>2]=c[y+4>>2],c[y+4>>2]=o,u=c[s+560>>2],c[s+560>>2]=d+T,c[y+8>>2]=u,d=c[s+564>>2],c[s+564>>2]=c[y+12>>2],c[y>>2]=o,c[y+12>>2]=d,(o|0)!=(u|0)&&(c[y+8>>2]=u+((o-u|0)+3&-4)),!o)break i;Ei(o)}for(c[D+552>>2]=s;o=xe[s+4|0],!!(!(o&4)&&(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););Te=S+80|0;return}c[S+16>>2]=4075,ur(s,S+16|0),rr(),kt()}c[S>>2]=4208,ur(s,S),rr(),kt()}Gs(),kt()}function bm(s,o){var u=0,d=0;for(c[s>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s+24>>2]=0,c[s+36>>2]=2143289344,c[s+40>>2]=2141891242,c[s+28>>2]=2143289344,c[s+32>>2]=2143289344,ge[s+4|0]=xe[s+4|0]&128,d=Ki(s+44|0,0,36);c[d+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,d=Ki(s+80|0,0,36);c[d+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,d=Ki(s+116|0,0,36);c[d+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,d=Ki(s+152|0,0,36);c[d+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=9;);for(u=0,c[s+196>>2]=0,d=s+188|0,c[d>>2]=0,c[d+4>>2]=0;c[d+(u<<2)>>2]=2143289344,u=u+1|0,(u|0)!=3;);for(c[s+24>>2]=4224,c[s+224>>2]=2143289344,c[s+216>>2]=2143289344,c[s+220>>2]=2143289344,c[s+208>>2]=2143289344,c[s+212>>2]=2143289344,c[s+200>>2]=2141891242,c[s+204>>2]=2141891242,Ki(s+228|0,0,288),c[s+244>>2]=2143289344,c[s+248>>2]=2143289344,Ki(s+252|0,0,49),c[s+308>>2]=2143289344,d=s+516|0,u=s+324|0;c[u+16>>2]=-1082130432,c[u+20>>2]=-1082130432,c[u+8>>2]=0,c[u+12>>2]=0,c[u>>2]=-1082130432,c[u+4>>2]=-1082130432,u=u+24|0,(d|0)!=(u|0););return c[s+548>>2]=0,c[s+552>>2]=0,c[s+516>>2]=2143289344,c[s+520>>2]=2143289344,c[s+572>>2]=2143289344,c[s+576>>2]=0,c[s+568>>2]=o,c[s+540>>2]=-1082130432,c[s+544>>2]=-1082130432,c[s+532>>2]=0,c[s+536>>2]=0,c[s+524>>2]=-1082130432,c[s+528>>2]=-1082130432,c[s+556>>2]=0,c[s+560>>2]=0,c[s+564>>2]=0,c[s+580>>2]=2143289344,c[s+584>>2]=0,eg((o|0)!=0,2760),ge[s+4|0]=xe[s+4|0]|1,ge[o+8|0]&1&&(c[s+24>>2]=c[s+24>>2]&-909|520),s}function Yt(s,o,u,d){var y=v(0),E=v(0),T=0,S=v(0);e:{r:{i:{t:{s:{n:{if(o>>>0<=1){E=C[s+212>>2],o=c[s+212>>2];o:{if((o|0)==2139156720)break o;if((o|0)==2140081935)break n;T=4336;a:{if((o|0)!=2141891242){if(E==E)break a;T=4344}switch(y=C[T>>2],E=v(Xe),c[T+4>>2]-1|0){case 0:break n;case 1:break o;default:break s}}if(y=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break n}E=v(v(y*d)*v(.009999999776482582));break s}E=C[s+208>>2];o:{a:{o=c[s+208>>2];l:{if((o|0)==2139156720)break l;if((o|0)==2140081935)break a;T=4336;c:{if((o|0)!=2141891242){if(E==E)break c;T=4344}switch(y=C[T>>2],E=v(Xe),c[T+4>>2]-1|0){case 0:break a;case 1:break l;default:break o}}if(y=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break a}E=v(v(y*d)*v(.009999999776482582));break o}E=y}y=v(0),S=C[s+216>>2],s=c[s+216>>2];o:{if((s|0)==2139156720)break o;if((s|0)==2140081935)break i;o=4336;a:{if((s|0)!=2141891242){if(S==S)break a;o=4344}switch(y=C[o>>2],c[o+4>>2]-1|0){case 1:break o;case 0:break t;default:break r}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break t}y=v(v(y*d)*v(.009999999776482582));break t}E=y}y=v(0),S=C[s+220>>2],s=c[s+220>>2];s:{if((s|0)==2139156720)break s;if((s|0)==2140081935)break i;o=4336;n:{if((s|0)!=2141891242){if(S==S)break n;o=4344}switch(y=C[o>>2],c[o+4>>2]-1|0){case 1:break s;case 0:break t;default:break r}}if(y=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break t}y=v(v(y*d)*v(.009999999776482582))}if(!(y>=v(0)))break r}if(u>y)break e}if(!(E>=v(0)))return u;y=u<E?E:u}return y}function xm(s){var o=0,u=0,d=v(0),y=v(0),E=v(0),T=0,S=0,D=0,j=0,te=0,de=0,ee=0,ie=0,F=0;for(T=Te-16|0,c[T+8>>2]=0,c[T+12>>2]=1,te=s+200|0,de=s+572|0,ee=s+208|0,ie=s+216|0,s=0;;){F=s,j=c[(T+8|0)+(s<<2)>>2],S=j<<2,s=ie+S|0,d=C[s>>2];e:{r:{i:{t:{s:{n:{if(o=c[s>>2],D=(o|0)==2139156720,!(D|(o|0)==2140081935|(o|0)==2141891242)&d!=d)break n;s=S+ee|0,y=C[s>>2],u=c[s>>2];o:{a:{if((u|0)!=2139156720){if(E=v(Xe),s=3,(u|0)==2141891242)break o;if((u|0)!=2140081935)break a;E=v(0),s=1;break o}E=v(0),s=2;break o}if(s=0,y!=y)break o;E=(Ce(2,(u&-1073741825)+536870912|0),He()),s=u&1073741824?2:1}u=s;o:{a:{if(!D){if(y=v(Xe),s=3,(o|0)==2141891242)break o;if((o|0)!=2140081935)break a;y=v(0),s=1;break o}y=v(0),s=2;break o}if(s=0,d!=d)break o;y=(Ce(2,(o&-1073741825)+536870912|0),He()),s=o&1073741824?2:1}if((u|0)!=(s|0)|!(!s|y!=y&E!=E|v(zt(v(y-E)))<v(9999999747378752e-20)))break n;if(s=0,D)break s;if((o|0)==2140081935)break r;if((o|0)==2141891242)break i;if(d!=d)break t;s=(o&-1073741825)+536870912|0,o=o&1073741824?2:1;break e}if(s=0,o=S+te|0,d=C[o>>2],o=c[o>>2],(o|0)==2139156720)break s;if((o|0)==2140081935)break r;if((o|0)==2141891242)break i;if(d!=d)break t;s=(o&-1073741825)+536870912|0,o=o&1073741824?2:1;break e}o=2;break e}s=2143289344,o=0;break e}s=2143289344,o=3;break e}o=1}if(u=(j<<3)+de|0,c[u+4>>2]=o,c[u>>2]=s,s=1,!!(F&1))break}}function ji(s,o,u){var d=0,y=0,E=0;if(u>>>0>=512)return xT(s|0,o|0,u|0),s;y=s+u|0;e:{if(!((s^o)&3)){r:{if(!(s&3)){u=s;break r}if(!u){u=s;break r}for(u=s;;){if(ge[u|0]=xe[o|0],o=o+1|0,u=u+1|0,!(u&3))break r;if(!(u>>>0<y>>>0))break}}d=y&-4;r:{if(d>>>0<64||(E=d+-64|0,E>>>0<u>>>0))break r;for(;c[u>>2]=c[o>>2],c[u+4>>2]=c[o+4>>2],c[u+8>>2]=c[o+8>>2],c[u+12>>2]=c[o+12>>2],c[u+16>>2]=c[o+16>>2],c[u+20>>2]=c[o+20>>2],c[u+24>>2]=c[o+24>>2],c[u+28>>2]=c[o+28>>2],c[u+32>>2]=c[o+32>>2],c[u+36>>2]=c[o+36>>2],c[u+40>>2]=c[o+40>>2],c[u+44>>2]=c[o+44>>2],c[u+48>>2]=c[o+48>>2],c[u+52>>2]=c[o+52>>2],c[u+56>>2]=c[o+56>>2],c[u+60>>2]=c[o+60>>2],o=o- -64|0,u=u- -64|0,E>>>0>=u>>>0;);}if(u>>>0>=d>>>0)break e;for(;c[u>>2]=c[o>>2],o=o+4|0,u=u+4|0,d>>>0>u>>>0;);break e}if(y>>>0<4){u=s;break e}if(d=y-4|0,d>>>0<s>>>0){u=s;break e}for(u=s;ge[u|0]=xe[o|0],ge[u+1|0]=xe[o+1|0],ge[u+2|0]=xe[o+2|0],ge[u+3|0]=xe[o+3|0],o=o+4|0,u=u+4|0,d>>>0>=u>>>0;);}if(u>>>0<y>>>0)for(;ge[u|0]=xe[o|0],o=o+1|0,u=u+1|0,(y|0)!=(u|0););return s}function Tm(s,o,u,d,y){var E=v(0),T=0,S=v(0),D=v(0),j=0,te=0,de=v(0),ee=v(0),ie=0;if(S=v(u-d),te=S!=S,!te){u=v(0),T=(o<<2)+s|0,E=C[T+208>>2];e:{r:{T=c[T+208>>2];i:{t:{if((T|0)==2139156720)break t;if((T|0)==2140081935)break r;j=4336;s:{if((T|0)!=2141891242){if(E==E)break s;j=4344}switch(u=C[j>>2],c[j+4>>2]-1|0){case 0:break i;case 1:break t;default:break e}}if(u=(Ce(2,(T&-1073741825)+536870912|0),He()),!(T&1073741824))break i}u=v(v(u*y)*v(.009999999776482582))}if(u==u)break r;break e}D=v(u-d)}u=v(0),s=(o<<2)+s|0,E=C[s+216>>2];e:{r:{o=c[s+216>>2];i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break r;s=4336;s:{if((o|0)!=2141891242){if(E==E)break s;s=4344}switch(u=C[s>>2],E=v(34028234663852886e22),c[s+4>>2]-1|0){case 0:break i;case 1:break t;default:break e}}if(u=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}u=v(v(u*y)*v(.009999999776482582))}if(u==u)break r;E=v(34028234663852886e22);break e}E=v(u-d)}if(u=(de=S,ee=uh(S,E),ie=E!=E|te,ie?de:ee),s=u!=u,!(s|D!=D))return ht(u,D);S=s?D:u}return S}function km(s,o,u,d,y,E,T,S,D,j,te,de,ee){var ie=v(0),F=v(0),H=0,z=0,J=v(0),oe=v(0),ae=v(0),ve=0,Ae=0;if(D<v(0)|j<v(0))s=0;else{J=E,oe=o,ae=d,F=S;e:{if(!ee||(ie=C[ee+20>>2],F=S,ie==v(0)))break e;ve=+ie,oe=Yr(+o,ve,0,0),ae=Yr(+d,ve,0,0),J=Yr(+E,ve,0,0),F=Yr(+S,ve,0,0)}ie=F,ee=0;e:{if((s|0)!=(y|0))break e;if(Ae=J!=J,ee=oe!=oe,Ae|ee){ee=ee&Ae;break e}ee=v(zt(v(J-oe)))<v(9999999747378752e-20)}Ae=ee;e:{if((u|0)!=(T|0))break e;if(H=ie!=ie,ee=ae!=ae,H|ee){H=ee&H;break e}H=v(zt(v(ie-ae)))<v(9999999747378752e-20)}z=1,ee=1;e:{if(Ae)break e;o=v(o-te);r:{if((s|0)==1)break r;if(s=(s|0)!=2,!(s|y)){if(!(o>=D))break r;break e}if(ee=0,!(o<E)|(s|(y|0)!=2|(o!=o|E!=E|D!=D))||(ee=1,o>=D))break e}if(y=o!=o,s=D!=D,y|s){ee=s&y;break e}ee=v(zt(v(o-D)))<v(9999999747378752e-20)}e:{if(H)break e;o=v(d-de);r:{if((u|0)==1)break r;if(s=(u|0)!=2,!(s|T)){if(!(o>=j))break r;break e}if(z=0,!(o<S)|(s|(T|0)!=2|(o!=o|S!=S|j!=j))||(z=1,o>=j))break e}if(u=o!=o,s=j!=j,u|s){z=s&u;break e}z=v(zt(v(o-j)))<v(9999999747378752e-20)}s=ee&z}return s}function rh(s){var o=0,u=0,d=0,y=0,E=0,T=0,S=0,D=0;if(Mi(+s),E=mt(1)|0,d=mt(0)|0,y=E>>>20&2047,(y|0)==2047)return s=s*1,s/s;if(o=d<<1,T=E<<1|d>>>31,!o&(T|0)==2145386496|T>>>0<2145386496)return!o&(T|0)==2145386496?s*0:s;e:{if(!y){if(y=0,u=d<<12,o=E<<12|d>>>20,(o|0)>0|(o|0)>=0)for(;y=y-1|0,o=o<<1|u>>>31,u=u<<1,!!((o|0)>0|(o|0)>=0););o=1-y|0,u=o&31,(o&63)>>>0>=32?(o=d<<u,d=0):(o=(1<<u)-1&d>>>32-u|E<<u,d=d<<u);break e}o=E&1048575|1048576}if(u=d,(y|0)>1023){for(;;){e:{if(d=o+-1048576|0,(d|0)<0||(o=d,o|u))break e;return s*0}if(o=o<<1|u>>>31,u=u<<1,y=y-1|0,!((y|0)>1023))break}y=1023}e:{if(d=o+-1048576|0,(d|0)<0||(o=d,o|u))break e;return s*0}if((o|0)==1048575|o>>>0<1048575)for(;y=y-1|0,d=o>>>0<524288,T=o<<1|u>>>31,u=u<<1,o=T,!!d;);return D=E&-2147483648,T=o+-1048576|y<<20,S=u,E=o,S=u,d=1-y|0,u=d&31,(d&63)>>>0>=32?(o=0,d=E>>>u|0):(o=E>>>u|0,d=((1<<u)-1&E)<<32-u|S>>>u),u=(y|0)>0,Ce(0,(u?S:d)|0),Ce(1,(u?T:o)|D),+Li()}function sh(s){var o=0,u=0,d=0,y=0,E=0;d=c[1416],o=s+7&-8,u=d+o|0;e:{r:{if(u>>>0<=d>>>0&&o||u>>>0>fg()<<16>>>0&&!(bT(u|0)|0))break r;c[1416]=u;break e}c[1781]=48,d=-1}if((d|0)!=-1){o=s+d|0,u=o-16|0,c[u+12>>2]=16,c[u>>2]=16,s=c[1748],s?E=c[s+8>>2]:E=0;e:{r:{if((E|0)==(d|0)){if(y=d-(c[d-4>>2]&-2)|0,E=c[y-4>>2],c[s+8>>2]=o,s=y-(E&-2)|0,o=-16,!(ge[(s+c[s>>2]|0)-4|0]&1))break r;o=c[s+4>>2],c[o+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=o,u=u-s|0,c[s>>2]=u;break e}c[d+12>>2]=16,c[d>>2]=16,c[d+8>>2]=o,c[d+4>>2]=s,c[1748]=d,o=16}s=o+d|0,u=u-s|0,c[s>>2]=u}c[((u&-4)+s|0)-4>>2]=u|1,o=c[s>>2]-8|0;e:{if(o>>>0<=127){u=(o>>>3|0)-1|0;break e}if(y=Tr(o),u=((o>>>29-y^4)-(y<<2)|0)+110|0,o>>>0<=4095)break e;u=((o>>>30-y^2)-(y<<1)|0)+71|0,u=u>>>0>=63?63:u}o=u<<4,c[s+4>>2]=o+5968,o=o+5976|0,c[s+8>>2]=c[o>>2],c[o>>2]=s,c[c[s+8>>2]+4>>2]=s,o=c[1750],y=c[1751],s=u&31,(u&63)>>>0>=32?(u=1<<s,E=0):(E=1<<s,u=E-1&1>>>32-s),c[1750]=E|o,c[1751]=u|y}return(d|0)!=-1}function Sm(s,o,u){var d=0,y=0,E=0,T=0,S=0,D=0,j=0,te=0,de=0;e:{r:{i:{t:{s:{n:{o:{a:{l:{c:{if(o){if(!u)break c;break l}s=(s>>>0)/(u>>>0)|0,Wi=0;break e}if(!s)break a;break o}if(!(u-1&u))break n;E=(Tr(u)+33|0)-Tr(o)|0,T=0-E|0;break t}s=(o>>>0)/0|0,Wi=0;break e}if(d=32-Tr(o)|0,d>>>0<31)break s;break i}if((u|0)==1)break r;E=u?31-Tr(u-1^u)|0:32,u=E&31,(E&63)>>>0>=32?s=o>>>u|0:(d=o>>>u|0,s=((1<<u)-1&o)<<32-u|s>>>u),Wi=d;break e}E=d+1|0,T=63-d|0}if(d=E&63,y=d&31,d>>>0>=32?(d=0,S=o>>>y|0):(d=o>>>y|0,S=((1<<y)-1&o)<<32-y|s>>>y),T=T&63,y=T&31,T>>>0>=32?(o=s<<y,s=0):(o=(1<<y)-1&s>>>32-y|o<<y,s=s<<y),E)for(T=u-1|0,de=(T|0)==-1?-1:0;D=d<<1|S>>>31,d=S<<1|o>>>31,y=de-(D+(d>>>0>T>>>0)|0)>>31,j=u&y,S=d-j|0,d=D-(d>>>0<j>>>0)|0,o=o<<1|s>>>31,s=te|s<<1,te=y&1,E=E-1|0,!!E;);Wi=o<<1|s>>>31,s=te|s<<1;break e}s=0,o=0}Wi=o}return s}function kl(s,o,u){var d=v(0),y=v(0);e:{r:{i:{if((o&-2)==2){if(o=c[s+188>>2],d=C[s+188>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|d==d||(o=c[s+196>>2],d=C[s+196>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|d==d))break i;break r}if(o=c[s+192>>2],d=C[s+192>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|d==d||(d=C[s+196>>2],o=c[s+196>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242))break i;if(d!=d)break r}d=v(0);i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;s=4336;s:{if((o|0)!=2141891242){if(d=(Ce(2,o),He()),d==d)break s;s=4344}switch(d=C[s>>2],y=v(Xe),c[s+4>>2]-1|0){case 0:break e;case 1:break t;default:break i}}if(d=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}y=v(v(d*u)*v(.009999999776482582))}return y}d=v(0)}return d}function wm(s,o){var u=0,d=0,y=0,E=0,T=0,S=0;for(u=Te-320|0,Te=u,d=Ki(u,0,288),u=d,c[u+16>>2]=2143289344,c[u+20>>2]=2143289344,Ki(u+24|0,0,49),c[u+80>>2]=2143289344,E=u+288|0,y=u+96|0;u=y,c[u+16>>2]=-1082130432,c[u+20>>2]=-1082130432,c[u+8>>2]=0,c[u+12>>2]=0,c[u>>2]=-1082130432,c[u+4>>2]=-1082130432,y=u+24|0,(E|0)!=(y|0););if(c[d+312>>2]=-1082130432,c[d+316>>2]=-1082130432,c[d+304>>2]=0,c[d+308>>2]=0,c[d+296>>2]=-1082130432,c[d+300>>2]=-1082130432,c[d+288>>2]=2143289344,c[d+292>>2]=2143289344,ji(s+228|0,d,320),c[s+244>>2]=0,c[s+248>>2]=0,ge[s+4|0]=xe[s+4|0]|1,y=c[s+556>>2],T=c[s+560>>2],(y|0)!=(T|0))for(;u=c[y>>2],c[u+552>>2]!=(s|0)&&(E=c[s+568>>2],u=Dm(c[E>>2],xe[E+8|0],u,s,S,o),c[y>>2]=u,c[u+552>>2]=s,u=c[y>>2]),wm(u,o),S=S+1|0,y=y+4|0,(T|0)!=(y|0););Te=d+320|0}function nh(s,o,u){var d=0,y=0,E=0,T=0;if(d=s+4|0,y=(d+o|0)-1&0-o,o=c[s>>2],y+u>>>0<=(o+s|0)-4>>>0){E=c[s+4>>2],c[E+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=E,(d|0)!=(y|0)&&(y=y-d|0,E=s-(c[s-4>>2]&-2)|0,d=y+c[E>>2]|0,c[E>>2]=d,c[(E+(d&-4)|0)-4>>2]=d,s=s+y|0,o=o-y|0,c[s>>2]=o);e:{if(u+24>>>0<=o>>>0){d=(s+u|0)+8|0,o=(o-u|0)-8|0,c[d>>2]=o,c[(d+(o&-4)|0)-4>>2]=o|1,y=c[d>>2]-8|0;r:{if(y>>>0<=127){o=(y>>>3|0)-1|0;break r}if(E=Tr(y),o=((y>>>29-E^4)-(E<<2)|0)+110|0,y>>>0<=4095)break r;o=((y>>>30-E^2)-(E<<1)|0)+71|0,o=o>>>0>=63?63:o}y=o<<4,c[d+4>>2]=y+5968,y=y+5976|0,c[d+8>>2]=c[y>>2],c[y>>2]=d,c[c[d+8>>2]+4>>2]=d,y=c[1750],E=c[1751],d=o&31,(o&63)>>>0>=32?(o=1<<d,d=0):(T=1<<d,o=T-1&1>>>32-d,d=T),c[1750]=d|y,c[1751]=o|E,o=u+8|0,c[s>>2]=o,c[((o&-4)+s|0)-4>>2]=o;break e}c[(s+o|0)-4>>2]=o}s=s+4|0}else s=0;return s}function OT(s,o){s=s|0,o=o|0;var u=0,d=0,y=0,E=0;y=Te-320|0,Te=y,s=c[s>>2];e:{if(c[s+560>>2]==c[s+556>>2]||(d=c[o>>2],o=c[d+552>>2],!Mm(s,d)))break e;if((s|0)==(o|0)){for(u=Ki(y,0,288),o=u,c[o+16>>2]=2143289344,c[o+20>>2]=2143289344,Ki(o+24|0,0,49),c[o+80>>2]=2143289344,E=o+288|0,o=o+96|0;c[o+16>>2]=-1082130432,c[o+20>>2]=-1082130432,c[o+8>>2]=0,c[o+12>>2]=0,c[o>>2]=-1082130432,c[o+4>>2]=-1082130432,o=o+24|0,(E|0)!=(o|0););c[u+312>>2]=-1082130432,c[u+316>>2]=-1082130432,c[u+304>>2]=0,c[u+308>>2]=0,c[u+296>>2]=-1082130432,c[u+300>>2]=-1082130432,c[u+288>>2]=2143289344,c[u+292>>2]=2143289344,ji(d+228|0,u,320),c[d+552>>2]=0}for(;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}Te=y+320|0}function _m(s){s=s|0;var o=0,u=0,d=0,y=0,E=0,T=0,S=0;if(s){if(T=Te-32|0,Te=T,o=c[s>>2],d=c[o+552>>2],d&&(Mm(d,o),c[o+552>>2]=0),d=c[o+556>>2],u=c[o+560>>2],(d|0)!=(u|0))for(u=u-d>>2,y=u>>>0<=1?1:u,u=0;c[c[(u<<2)+d>>2]+552>>2]=0,u=u+1|0,(y|0)!=(u|0););c[o+560>>2]=d,u=o+564|0;e:{if(c[u>>2]==(d|0)||(u=Qo(T+8|0,0,0,u),y=c[o+556>>2],E=c[o+560>>2]-y|0,d=c[u+4>>2]-E|0,E=Vs(d,y,E),y=c[o+556>>2],c[o+556>>2]=E,c[u+4>>2]=y,E=c[o+560>>2],c[o+560>>2]=c[u+8>>2],c[u+8>>2]=E,S=c[o+564>>2],c[o+564>>2]=c[u+12>>2],c[u>>2]=y,c[u+12>>2]=S,(y|0)!=(E|0)&&(c[u+8>>2]=E+((y-E|0)+3&-4)),!y))break e;Ei(y),d=c[o+556>>2]}d&&(c[o+560>>2]=d,Ei(d)),Ei(o),o=c[s+8>>2],c[s+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),o=c[s+4>>2],c[s+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),Te=T+32|0,Ei(s)}}function PT(s){s=s|0;var o=0,u=0,d=0;d=Te-624|0,Te=d,o=c[s+4>>2],c[s+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),o=c[s+8>>2],c[s+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o);e:{if(s=c[s>>2],c[s+560>>2]==c[s+556>>2]){if(c[s+552>>2])break e;o=bm(d+32|0,c[s+568>>2]),u=c[o+4>>2],c[s>>2]=c[o>>2],c[s+4>>2]=u,u=c[o+20>>2],c[s+16>>2]=c[o+16>>2],c[s+20>>2]=u,u=c[o+12>>2],c[s+8>>2]=c[o+8>>2],c[s+12>>2]=u,ji(s+24|0,o+24|0,204),ji(s+228|0,o+228|0,328),u=c[s+556>>2],u&&(c[s+560>>2]=u,Ei(u)),c[s+556>>2]=c[o+556>>2],c[s+560>>2]=c[o+560>>2],c[s+564>>2]=c[o+564>>2],c[s+584>>2]=c[o+584>>2],u=c[o+580>>2],c[s+576>>2]=c[o+576>>2],c[s+580>>2]=u,u=c[o+572>>2],c[s+568>>2]=c[o+568>>2],c[s+572>>2]=u,Te=d+624|0;return}c[d+16>>2]=3301,ur(s,d+16|0),rr(),kt()}c[d>>2]=2047,ur(s,d),rr(),kt()}function Rm(){_T(7084,3067),wT(7085,2480,1,1,0),ms(7086,2140,1,-128,127),ms(7087,2133,1,-128,127),ms(7088,2131,1,0,255),ms(7089,1287,2,-32768,32767),ms(7090,1278,2,0,65535),ms(7091,1316,4,-2147483648,2147483647),ms(7092,1307,4,0,-1),ms(7093,2659,4,-2147483648,2147483647),ms(7094,2650,4,0,-1),ng(7095,1777,-2147483648,2147483647),ng(7096,1776,0,-1),pm(7097,1770,4),pm(7098,3015,8),mm(7099,2677),mm(7100,3904),Ju(7101,4,2664),Ju(7102,2,2689),Ju(7103,4,2704),ST(7104,2485),Ci(7105,0,3835),Ci(7106,0,3937),Ci(7107,1,3865),Ci(7108,2,3467),Ci(7109,3,3498),Ci(7110,4,3538),Ci(7111,5,3567),Ci(7112,4,3974),Ci(7113,5,4004),Ci(7106,0,3669),Ci(7107,1,3636),Ci(7108,2,3735),Ci(7109,3,3701),Ci(7110,4,3802),Ci(7111,5,3768),Ci(7114,6,3605),Ci(7115,7,4043)}function Vs(s,o,u){var d=0,y=0;e:{if((s|0)==(o|0))break e;if(y=s+u|0,o-y>>>0<=0-(u<<1)>>>0)return ji(s,o,u);d=(s^o)&3;r:{i:{if(s>>>0<o>>>0){if(d){d=s;break r}if(!(s&3)){d=s;break i}for(d=s;;){if(!u)break e;if(ge[d|0]=xe[o|0],o=o+1|0,u=u-1|0,d=d+1|0,!(d&3))break}break i}t:{if(d)break t;if(y&3)for(;;){if(!u)break e;if(u=u-1|0,d=u+s|0,ge[d|0]=xe[o+u|0],!(d&3))break}if(u>>>0<=3)break t;for(;u=u-4|0,c[u+s>>2]=c[o+u>>2],u>>>0>3;);}if(!u)break e;for(;u=u-1|0,ge[u+s|0]=xe[o+u|0],!!u;);break e}if(u>>>0<=3)break r;for(;c[d>>2]=c[o>>2],o=o+4|0,d=d+4|0,u=u-4|0,u>>>0>3;);}if(!u)break e;for(;ge[d|0]=xe[o|0],d=d+1|0,o=o+1|0,u=u-1|0,!!u;);}return s}function Lm(s,o,u,d){e:switch(o-9|0){case 0:o=c[u>>2],c[u>>2]=o+4,c[s>>2]=c[o>>2];return;case 6:o=c[u>>2],c[u>>2]=o+4,o=jr[o>>1],c[s>>2]=o,c[s+4>>2]=o>>31;return;case 7:o=c[u>>2],c[u>>2]=o+4,c[s>>2]=Wn[o>>1],c[s+4>>2]=0;return;case 8:o=c[u>>2],c[u>>2]=o+4,o=ge[o|0],c[s>>2]=o,c[s+4>>2]=o>>31;return;case 9:o=c[u>>2],c[u>>2]=o+4,c[s>>2]=xe[o|0],c[s+4>>2]=0;return;case 16:o=c[u>>2]+7&-8,c[u>>2]=o+8,Ht[s>>3]=Ht[o>>3];return;case 17:$e[d|0](s,u);default:return;case 1:case 4:case 14:o=c[u>>2],c[u>>2]=o+4,o=c[o>>2],c[s>>2]=o,c[s+4>>2]=o>>31;return;case 2:case 5:case 11:case 15:o=c[u>>2],c[u>>2]=o+4,c[s>>2]=c[o>>2],c[s+4>>2]=0;return;case 3:case 10:case 12:case 13:break e}o=c[u>>2]+7&-8,c[u>>2]=o+8,u=c[o+4>>2],c[s>>2]=c[o>>2],c[s+4>>2]=u}function Cm(s,o,u,d){var y=0,E=0,T=0,S=0,D=0,j=0,te=0,de=0,ee=0,ie=v(0),F=v(0),H=v(0),z=0,J=v(0);e:{if(o==0||(ie=C[s+248>>2],F=C[s+244>>2],H=C[s+232>>2],D=+C[s+228>>2],y=xe[s+4|0]&8,E=y>>>3|0,z=s,J=Yr(D,o,0,E),C[z+228>>2]=J,j=+H,z=s,J=Yr(j,o,0,E),C[z+232>>2]=J,te=+F,T=rh(te*o),E=T==T&zt(T)<1e-4,S=!(E|T!=T?E:zt(T+-1)<1e-4),de=+ie,T=rh(de*o),E=T==T&zt(T)<1e-4,ee=!(E|T!=T?E:zt(T+-1)<1e-4),E=0,u=D+u,y=(y|0)!=0,z=s,J=v(Yr(u+te,o,y&S,y&!S)-Yr(u,o,0,y)),C[z+244>>2]=J,d=j+d,z=s,J=v(Yr(d+de,o,y&ee,y&!ee)-Yr(d,o,0,y)),C[z+248>>2]=J,y=c[s+560>>2],S=c[s+556>>2],(y|0)==(S|0)))break e;for(y=y-S>>2,S=y>>>0<=1?1:y;y=c[s+556>>2],c[s+560>>2]-y>>2>>>0>E>>>0?y=c[y+(E<<2)>>2]:y=0,Cm(y,o,u,d),E=E+1|0,(S|0)!=(E|0););}}function Ki(s,o,u){var d=0,y=0,E=0,T=0;e:{if(!u||(ge[s|0]=o,d=s+u|0,ge[d-1|0]=o,u>>>0<3)||(ge[s+2|0]=o,ge[s+1|0]=o,ge[d-3|0]=o,ge[d-2|0]=o,u>>>0<7)||(ge[s+3|0]=o,ge[d-4|0]=o,u>>>0<9)||(d=0-s&3,y=d+s|0,o=Wt(o&255,16843009),c[y>>2]=o,d=u-d&-4,u=d+y|0,c[u-4>>2]=o,d>>>0<9)||(c[y+8>>2]=o,c[y+4>>2]=o,c[u-8>>2]=o,c[u-12>>2]=o,d>>>0<25)||(c[y+24>>2]=o,c[y+20>>2]=o,c[y+16>>2]=o,c[y+12>>2]=o,c[u-16>>2]=o,c[u-20>>2]=o,c[u-24>>2]=o,c[u-28>>2]=o,T=y&4|24,u=d-T|0,u>>>0<32))break e;for(d=ch(o,0,1,1),E=Wi,o=y+T|0;c[o+24>>2]=d,c[o+28>>2]=E,c[o+16>>2]=d,c[o+20>>2]=E,c[o+8>>2]=d,c[o+12>>2]=E,c[o>>2]=d,c[o+4>>2]=E,o=o+32|0,u=u-32|0,u>>>0>31;);}return s}function Ei(s){s=s|0;var o=0,u=0,d=0,y=0,E=0;if(s){o=s-4|0,y=c[o>>2],u=y,d=o,E=c[s-8>>2],s=E&-2,(s|0)!=(E|0)&&(d=o-s|0,u=c[d+4>>2],c[u+8>>2]=c[d+8>>2],c[c[d+8>>2]+4>>2]=u,u=s+y|0),s=o+y|0,o=c[s>>2],(o|0)!=c[(s+o|0)-4>>2]&&(y=c[s+4>>2],c[y+8>>2]=c[s+8>>2],c[c[s+8>>2]+4>>2]=y,u=o+u|0),c[d>>2]=u,c[((u&-4)+d|0)-4>>2]=u|1,o=c[d>>2]-8|0;e:{if(o>>>0<=127){s=(o>>>3|0)-1|0;break e}if(u=Tr(o),s=((o>>>29-u^4)-(u<<2)|0)+110|0,o>>>0<=4095)break e;s=((o>>>30-u^2)-(u<<1)|0)+71|0,s=s>>>0>=63?63:s}o=s<<4,c[d+4>>2]=o+5968,o=o+5976|0,c[d+8>>2]=c[o>>2],c[o>>2]=d,c[c[d+8>>2]+4>>2]=d,o=c[1750],u=c[1751],d=s&31,(s&63)>>>0>=32?(s=1<<d,y=0):(y=1<<d,s=y-1&1>>>32-d),c[1750]=y|o,c[1751]=s|u}}function $T(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=0,T=0,S=0,D=0,j=0;d=Te-32|0,Te=d,y=c[s+28>>2],c[d+16>>2]=y,E=c[s+20>>2],c[d+28>>2]=u,c[d+24>>2]=o,o=E-y|0,c[d+20>>2]=o,E=o+u|0,D=2,o=d+16|0;e:{for(;;){r:{i:{t:{if(!rg(TT(c[s+60>>2],o|0,D|0,d+12|0)|0)){if(T=c[d+12>>2],(T|0)==(E|0))break t;if((T|0)>=0)break i;break r}if((E|0)!=-1)break r}o=c[s+44>>2],c[s+28>>2]=o,c[s+20>>2]=o,c[s+16>>2]=o+c[s+48>>2],s=u;break e}S=c[o+4>>2],j=S>>>0<T>>>0,y=(j<<3)+o|0,S=T-(j?S:0)|0,c[y>>2]=S+c[y>>2],o=(j?12:4)+o|0,c[o>>2]=c[o>>2]-S,E=E-T|0,D=D-j|0,o=y;continue}break}if(c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,c[s>>2]=c[s>>2]|32,s=0,(D|0)==2)break e;s=u-c[o+4>>2]|0}return Te=d+32|0,s|0}function FT(s){s=s|0;var o=0,u=0,d=0,y=0,E=0;u=Te-96|0,Te=u,c[u>>2]=s,d=Te-16|0,Te=d,c[d+12>>2]=u,s=Te-144|0,Te=s,s=ji(s,5520,144),E=u+16|0,o=E,c[s+44>>2]=o,c[s+20>>2]=o,y=-2-o|0,y=y>>>0>=2147483647?2147483647:y,c[s+48>>2]=y,o=o+y|0,c[s+28>>2]=o,c[s+16>>2]=o,Im(s,2202,u,0,0),y&&(o=c[s+20>>2],ge[o-((o|0)==c[s+16>>2])|0]=0),Te=s+144|0,Te=d+16|0,s=E;e:{if(s&3)for(;;){if(!xe[s|0])break e;if(s=s+1|0,!(s&3))break}for(;o=s,s=s+4|0,d=c[o>>2],!((d^-1)&d-16843009&-2139062144););for(;s=o,o=s+1|0,!!xe[s|0];);}return s=(s-E|0)+1|0,o=ih(s),o?s=ji(o,E,s):s=0,Te=u+96|0,s|0}function Im(s,o,u,d,y){var E=0,T=0,S=0,D=0;E=Te-208|0,Te=E,c[E+204>>2]=u,u=E+160|0,Ki(u,0,40),c[E+200>>2]=c[E+204>>2];e:{if((Em(0,o,E+200|0,E+80|0,u,d,y)|0)<0){y=-1;break e}D=c[s+76>>2]>=0,T=c[s>>2],c[s+72>>2]<=0&&(c[s>>2]=T&-33);r:{i:{t:{if(!c[s+48>>2]){c[s+48>>2]=80,c[s+28>>2]=0,c[s+16>>2]=0,c[s+20>>2]=0,S=c[s+44>>2],c[s+44>>2]=E;break t}if(c[s+16>>2])break i}if(u=-1,Wm(s))break r}u=Em(s,o,E+200|0,E+80|0,E+160|0,d,y)}if(S&&($e[c[s+36>>2]](s,0,0)|0,c[s+48>>2]=0,c[s+44>>2]=S,c[s+28>>2]=0,o=c[s+20>>2],c[s+16>>2]=0,c[s+20>>2]=0,u=o?u:-1),o=s,s=c[s>>2],c[o>>2]=s|T&32,y=s&32?-1:u,!D)break e}return Te=E+208|0,y}function Sl(s){var o=0,u=v(0),d=0,y=0,E=0,T=0,S=0,D=v(0),j=0;E=Te-16|0,Te=E,o=c[s+12>>2];e:{if(o){D=C[s+520>>2],u=C[s+516>>2];r:{if(xe[s+4|0]&32){u=v($e[o|0](s,u,D,0));break r}u=v($e[o|0](s,u,D))}if(u==u)break e;c[E>>2]=3409,ur(s,E),rr(),kt()}r:{i:{if(T=c[s+556>>2],o=c[s+560>>2],(T|0)!=(o|0)){for(o=o-T>>2,j=o>>>0<=1?1:o;;){if(y=c[(S<<2)+T>>2],!c[y+548>>2]){if(o=c[y+24>>2],(o&196608)!=131072){if(o=o>>>13&7,o||(o=c[s+24>>2]>>>10&7),xe[y+4|0]&2|(xe[s+24|0]&8?(o|0)==5:0))break i;d=d||y}if(S=S+1|0,(j|0)!=(S|0))continue}break}if(d)break r}u=C[s+520>>2];break e}d=y}u=v(Sl(d)+C[d+232>>2])}return Te=E+16|0,u}function Kn(s,o,u,d,y,E){var T=0,S=v(0),D=0,j=v(0);T=(c[(o<<2)+4320>>2]<<2)+s|0,S=C[T+216>>2];e:{r:{T=c[T+216>>2];i:{if((T|0)==2139156720)break i;if((T|0)==2140081935)break r;D=4336;t:{if((T|0)!=2141891242){if(S==S)break t;D=4344}switch(j=C[D>>2],S=v(Xe),c[D+4>>2]-1|0){case 0:break r;case 1:break i;default:break e}}if(j=(Ce(2,(T&-1073741825)+536870912|0),He()),!(T&1073741824))break r}S=v(v(j*u)*v(.009999999776482582));break e}S=j}d=v(S+v(ft(s,o,d)+St(s,o,d)));e:{r:{i:switch(c[y>>2]){case 1:case 2:u=C[E>>2],d=d!=d||u<d?u:d;break r;case 0:break i;default:break e}if(d!=d)break e;c[y>>2]=2}C[E>>2]=d}}function Dt(s,o,u){var d=v(0),y=v(0),E=0,T=v(0);s=s+116|0,E=c[(o<<2)+4288>>2];e:{if((o&-2)==2){o=Kr(s,4,E,2140081935);break e}o=zr(s,E,2140081935)}e:{r:{i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;s=4336;s:{if((o|0)!=2141891242){if(d=(Ce(2,o),He()),d==d)break s;s=4344}switch(d=C[s>>2],y=v(Xe),c[s+4>>2]-1|0){case 0:break i;case 1:break t;default:break r}}if(d=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}d=v(v(d*u)*v(.009999999776482582))}if(d>=v(0))return d;if(y=d,d<v(0))break e}T=y==y?y:v(0)}return T}function Ot(s,o,u){var d=v(0),y=v(0),E=0,T=v(0);s=s+116|0,E=c[(o<<2)+4304>>2];e:{if((o&-2)==2){o=Kr(s,5,E,2140081935);break e}o=zr(s,E,2140081935)}e:{r:{i:{t:{if((o|0)==2139156720)break t;if((o|0)==2140081935)break e;s=4336;s:{if((o|0)!=2141891242){if(d=(Ce(2,o),He()),d==d)break s;s=4344}switch(d=C[s>>2],y=v(Xe),c[s+4>>2]-1|0){case 0:break i;case 1:break t;default:break r}}if(d=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break i}d=v(v(d*u)*v(.009999999776482582))}if(d>=v(0))return d;if(y=d,d<v(0))break e}T=y==y?y:v(0)}return T}function Dm(s,o,u,d,y,E){var T=0;e:{r:{if(s){i:{if(o&4){E=$e[s|0](u,d,y,E)|0;break i}E=$e[s|0](u,d,y)|0}if(E)break r}if(E=he(588),o=ji(E,u,552),c[o+564>>2]=0,c[o+556>>2]=0,c[o+560>>2]=0,y=c[u+556>>2],d=c[u+560>>2],(y|0)!=(d|0)){if(T=d-y|0,(T|0)<0)break e;for(s=he(T),c[o+556>>2]=s,c[o+564>>2]=s+T;c[s>>2]=c[y>>2],s=s+4|0,y=y+4|0,(d|0)!=(y|0););c[o+560>>2]=s}s=c[u+572>>2],c[o+568>>2]=c[u+568>>2],c[o+572>>2]=s,c[o+584>>2]=c[u+584>>2],s=c[u+580>>2],c[o+576>>2]=c[u+576>>2],c[o+580>>2]=s,c[o+552>>2]=0}return E}Gs(),kt()}function ur(s,o){var u=0,d=0,y=0;y=Te-16|0,Te=y,c[y+12>>2]=o;e:{r:{if(!s){o=c[y+12>>2];break r}if(o=c[y+12>>2],u=c[s+568>>2],!u)break r;if(d=c[u+4>>2],xe[u+8|0]&8){$e[d|0](u,s,5,0,4284,o)|0;break e}$e[d|0](u,s,5,4284,o)|0;break e}r:{if(!xe[7016]){u=he(28),c[u+20>>2]=1065353216,c[u+24>>2]=0,c[u+12>>2]=0,c[u+16>>2]=0,c[u>>2]=0,ge[u+8|0]=0,d=1,c[u+4>>2]=1,c[1753]=u,ge[7016]=1,c[1752]=c[1752]+1;break r}if(u=c[1753],d=c[u+4>>2],!(xe[u+8|0]&8))break r;$e[d|0](u,s,5,0,4284,o)|0;break e}$e[d|0](u,s,5,4284,o)|0}Te=y+16|0}function qo(s,o,u){var d=v(0),y=0,E=v(0);s=s+80|0,y=c[(o<<2)+4304>>2];e:{r:{if((o&-2)==2){o=Kr(s,5,y,2140081935);break r}o=zr(s,y,2140081935)}r:{i:{if((o|0)==2139156720)break i;if((o|0)==2140081935)break e;s=4336;t:{if((o|0)!=2141891242){if(d=(Ce(2,o),He()),d==d)break t;s=4344}switch(d=C[s>>2],E=v(Xe),c[s+4>>2]-1|0){case 0:break e;case 1:break i;default:break r}}if(d=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}E=v(v(d*u)*v(.009999999776482582))}return E}return d}function Hs(s,o,u){var d=v(0),y=0,E=v(0);s=s+80|0,y=c[(o<<2)+4288>>2];e:{r:{if((o&-2)==2){o=Kr(s,4,y,2140081935);break r}o=zr(s,y,2140081935)}r:{i:{if((o|0)==2139156720)break i;if((o|0)==2140081935)break e;s=4336;t:{if((o|0)!=2141891242){if(d=(Ce(2,o),He()),d==d)break t;s=4344}switch(d=C[s>>2],E=v(Xe),c[s+4>>2]-1|0){case 0:break e;case 1:break i;default:break r}}if(d=(Ce(2,(o&-1073741825)+536870912|0),He()),!(o&1073741824))break e}E=v(v(d*u)*v(.009999999776482582))}return E}return d}function Kr(s,o,u,d){var y=v(0);o=(o<<2)+s|0,y=C[o>>2],o=c[o>>2];e:{if((o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y||(o=(u<<2)+s|0,y=C[o>>2],o=c[o>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y)||(o=c[s+24>>2],y=C[s+24>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|y==y)||(y=C[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(o=d,y!=y)))break e;o=s}return o}function MT(s,o){s=s|0,o=v(o);var u=0,d=0,y=0;if(u=Te-16|0,Te=u,s=c[s>>2],!(o>=v(0))){c[u>>2]=2263,d=Te-16|0,Te=d,c[d+12>>2]=u;e:{if(s)break e;if(xe[7016]){s=c[1753];break e}s=he(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,ge[s+8|0]=0,c[s+4>>2]=1,c[1753]=s,ge[7016]=1,c[1752]=c[1752]+1}y=c[s+4>>2];e:{if(xe[s+8|0]&8){$e[y|0](s,0,5,0,4284,u)|0;break e}$e[y|0](s,0,5,4284,u)|0}Te=d+16|0,rr(),kt()}C[s+20>>2]=o==v(0)?v(0):o,Te=u+16|0}function Om(s,o,u,d,y){var E=0,T=0,S=v(0),D=0;E=2,T=c[s+24>>2]>>>2&3;e:{r:{i:{if(!(!c[s+552>>2]|(o|0)!=2)){o=0,E=3;t:switch(T-2|0){case 0:break e;case 1:break t;default:break i}E=2;break e}if(o=0,T>>>0>1)break r}o=E}E=T}u=Jm(s,E,u),d=Jm(s,o,d),S=ft(s,E,y),T=s+228|0,D=E<<2,C[T+(c[D+4288>>2]<<2)>>2]=u+S,S=St(s,E,y),C[T+(c[D+4304>>2]<<2)>>2]=u+S,u=ft(s,o,y),E=o<<2,C[T+(c[E+4288>>2]<<2)>>2]=d+u,u=St(s,o,y),C[T+(c[E+4304>>2]<<2)>>2]=d+u}function NT(s,o,u,d,y,E){s=s|0,o=o|0,u=v(u),d=d|0,y=v(y),E=E|0;var T=0,S=0,D=0;T=Te-48|0,Te=T,D=c[o+8>>2];e:{if(ge[7052]&1){o=c[1762];break e}o=fm(5,4480)|0,ge[7052]=1,c[1762]=o}c[T+40>>2]=E,C[T+32>>2]=y,c[T+24>>2]=d,C[T+16>>2]=u,S=+vT(o|0,D|0,2922,T+12|0,T+16|0);e:{if(S<4294967296&S>=0){o=~~S>>>0;break e}o=0}d=c[T+12>>2],E=c[o+4>>2],c[s>>2]=c[o>>2],c[s+4>>2]=E,E=c[o+12>>2],c[s+8>>2]=c[o+8>>2],c[s+12>>2]=E,gT(d|0),Te=T+48|0}function UT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=0,T=0;if(d=Te-32|0,Te=d,y=c[o>>2],y>>>0<2147483632){e:{r:{if(y>>>0>=11){E=(y|15)+1|0,T=he(E),c[d+16>>2]=E|-2147483648,c[d+8>>2]=T,c[d+12>>2]=y,E=y+T|0;break r}if(ge[d+19|0]=y,T=d+8|0,E=T+y|0,!y)break e}ji(T,o+4|0,y)}return ge[E|0]=0,c[d>>2]=u,$e[s|0](d+24|0,d+8|0,d),mT(c[d+24>>2]),s=c[d+24>>2],Zo(s|0),Zo(c[d>>2]),ge[d+19|0]<0&&Ei(c[d+8>>2]),Te=d+32|0,s|0}Gs(),kt()}function fi(s,o,u){var d=0,y=0,E=0;if(!(xe[s|0]&32))e:{d=o,o=s,s=c[o+16>>2];r:{if(!s){if(Wm(o))break r;s=c[o+16>>2]}if(E=c[o+20>>2],s-E>>>0<u>>>0){$e[c[o+36>>2]](o,d,u)|0;break e}i:{if(c[o+80>>2]<0)break i;for(s=u;;){if(y=s,!s)break i;if(s=y-1|0,xe[d+s|0]==10)break}if($e[c[o+36>>2]](o,d,y)>>>0<y>>>0)break r;d=d+y|0,u=u-y|0,E=c[o+20>>2]}ji(E,d,u),c[o+20>>2]=c[o+20>>2]+u}}}function oh(s,o,u){var d=0,y=0,E=0;d=Te-16|0,Te=d,y=s+24|0,$e[o|0](d+8|0,y),E=c[d+12>>2];e:{if((c[c[d+8>>2]>>2]&7<<E)>>E==(u|0))break e;for($e[o|0](d+8|0,y),o=c[d+8>>2],y=o,E=c[o>>2],o=c[d+12>>2],c[y>>2]=E&(7<<o^-1)|(u&7)<<o;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}Te=d+16|0}function zr(s,o,u){var d=v(0);o=(o<<2)+s|0,d=C[o>>2],o=c[o>>2];e:{if((o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|d==d||(o=c[s+28>>2],d=C[s+28>>2],(o|0)==2139156720|(o|0)==2140081935|(o|0)==2141891242|d==d)||(d=C[s+32>>2],s=c[s+32>>2],!((s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242)&&(o=u,d!=d)))break e;o=s}return o}function St(s,o,u){var d=v(0),y=0;s=s+44|0,y=c[(o<<2)+4304>>2];e:{if((o&-2)==2){s=Kr(s,5,y,2140081935);break e}s=zr(s,y,2140081935)}e:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break e;if(d=(Ce(2,s),He()),d!=d)return v(Xe);if(d=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break e}d=v(v(d*u)*v(.009999999776482582))}return d}function ft(s,o,u){var d=v(0),y=0;s=s+44|0,y=c[(o<<2)+4288>>2];e:{if((o&-2)==2){s=Kr(s,4,y,2140081935);break e}s=zr(s,y,2140081935)}e:{if((s|0)!=2139156720){if((s|0)==2140081935|(s|0)==2141891242)break e;if(d=(Ce(2,s),He()),d!=d)return v(Xe);if(d=(Ce(2,(s&-1073741825)+536870912|0),He()),!(s&1073741824))break e}d=v(v(d*u)*v(.009999999776482582))}return d}function BT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=0,T=0,S=0;return y=c[s+84>>2],E=c[y>>2],d=c[y+4>>2],S=c[s+28>>2],T=c[s+20>>2]-S|0,T=d>>>0<T>>>0?d:T,T&&(ji(E,S,T),E=T+c[y>>2]|0,c[y>>2]=E,d=c[y+4>>2]-T|0,c[y+4>>2]=d),d=u>>>0>d>>>0?d:u,d&&(ji(E,o,d),E=d+c[y>>2]|0,c[y>>2]=E,c[y+4>>2]=c[y+4>>2]-d),ge[E|0]=0,o=c[s+44>>2],c[s+28>>2]=o,c[s+20>>2]=o,u|0}function wt(s,o){var u=v(0),d=0;s=s+152|0,d=c[(o<<2)+4304>>2];e:{if((o&-2)==2){s=Kr(s,5,d,2140081935);break e}s=zr(s,d,2140081935)}u=v(0);e:{if((s|0)==2139156720||(u=v(0),(s|0)==2140081935))break e;r:{if((s|0)==2141891242||(u=(Ce(2,s),He()),u!=u))break r;u=(Ce(2,(s&-1073741825)+536870912|0),He());break e}u=v(Xe)}return ht(u,v(0))}function gt(s,o){var u=v(0),d=0;s=s+152|0,d=c[(o<<2)+4288>>2];e:{if((o&-2)==2){s=Kr(s,4,d,2140081935);break e}s=zr(s,d,2140081935)}u=v(0);e:{if((s|0)==2139156720||(u=v(0),(s|0)==2140081935))break e;r:{if((s|0)==2141891242||(u=(Ce(2,s),He()),u!=u))break r;u=(Ce(2,(s&-1073741825)+536870912|0),He());break e}u=v(Xe)}return ht(u,v(0))}function GT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=v(0);d=2,o=c[o>>2]+(u<<2)|0,E=C[o+116>>2];e:{r:{if(o=c[o+116>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){d=3;break e}if((o|0)!=2140081935)break r;y=0,d=1;break e}break e}if(E!=E){d=0;break e}d=o&1073741824?2:1,y=(Ce(2,(o&-1073741825)+536870912|0),+He())}Ht[s+8>>3]=y,c[s>>2]=d}function VT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=v(0);d=2,o=c[o>>2]+(u<<2)|0,E=C[o+80>>2];e:{r:{if(o=c[o+80>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){d=3;break e}if((o|0)!=2140081935)break r;y=0,d=1;break e}break e}if(E!=E){d=0;break e}d=o&1073741824?2:1,y=(Ce(2,(o&-1073741825)+536870912|0),+He())}Ht[s+8>>3]=y,c[s>>2]=d}function HT(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0,E=v(0);d=2,o=c[o>>2]+(u<<2)|0,E=C[o+44>>2];e:{r:{if(o=c[o+44>>2],(o|0)!=2139156720){if(y=Xe,(o|0)==2141891242){d=3;break e}if((o|0)!=2140081935)break r;y=0,d=1;break e}break e}if(E!=E){d=0;break e}d=o&1073741824?2:1,y=(Ce(2,(o&-1073741825)+536870912|0),+He())}Ht[s+8>>3]=y,c[s>>2]=d}function Yr(s,o,u,d){var y=0,E=0,T=0;s=s*o,y=rh(s),y=y<0?y+1:y,T=y!=y;e:{if(!(T|!(zt(y)<1e-4))){s=s-y;break e}r:{if(y!=y){s=s-y;break r}if(s=s-y,!(zt(y+-1)<1e-4))break r;s=s+1;break e}if(u){s=s+1;break e}if(d)break e;E=0;r:{if(T||(E=1,y>.5))break r;E=zt(y+-.5)<1e-4?1:0}s=s+E}return s!=s|o!=o?v(Xe):v(s/o)}function Pm(s,o){var u=v(0);e:{if((o|0)!=2139156720){if((o|0)!=2140081935){if((o|0)!=2141891242)break e;c[s>>2]=2143289344,c[s+4>>2]=3;return}c[s>>2]=0,c[s+4>>2]=1;return}c[s>>2]=0,c[s+4>>2]=2;return}if(u=(Ce(2,o),He()),u!=u){c[s>>2]=2143289344,c[s+4>>2]=0;return}c[s+4>>2]=o&1073741824?2:1,c[s>>2]=(o&-1073741825)+536870912}function $m(s){var o=0,u=0,d=0;u=c[s+24>>2];e:{if(!(u&8)||(o=1,(u&7168)==5120)||(o=0,d=c[s+560>>2],u=c[s+556>>2],(d|0)==(u|0)))break e;for(s=d-u>>2,d=s>>>0<=1?1:s,s=0;;){if(o=c[c[u+(s<<2)>>2]+24>>2],o=(o&196608)!=131072&(o&57344)==40960,o)break e;if(s=s+1|0,(d|0)==(s|0))break}}return o}function WT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+220>>2];e:{r:{if(o=c[o+220>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function jT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+200>>2];e:{r:{if(o=c[o+200>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function KT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+204>>2];e:{r:{if(o=c[o+204>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function zT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+208>>2];e:{r:{if(o=c[o+208>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function YT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+212>>2];e:{r:{if(o=c[o+212>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function XT(s,o){s=s|0,o=o|0;var u=0,d=0,y=v(0);o=c[o>>2],y=C[o+216>>2];e:{r:{if(o=c[o+216>>2],(o|0)!=2139156720){if(d=Xe,u=3,(o|0)==2141891242)break e;if((o|0)!=2140081935)break r;d=0,u=1;break e}u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),+He()),u=o&1073741824?2:1}o=u,Ht[s+8>>3]=d,c[s>>2]=o}function ZT(s,o){s=s|0,o=o|0;var u=0;if(u=Te-16|0,Te=u,s=c[s>>2],(o|0)<6){Te=u+16|0;e:{r:switch(o-4|0){case 0:if(o=s+260|0,(xe[s+300|0]&3)==2)break e;o=s+252|0;break e;case 1:if(o=s+252|0,(xe[s+300|0]&3)==2)break e;o=s+260|0;break e;default:break r}o=(s+(o<<2)|0)+252|0}return+C[o>>2]}c[u>>2]=1872,ur(s,u),rr(),kt()}function qT(s,o){s=s|0,o=o|0;var u=0;if(u=Te-16|0,Te=u,s=c[s>>2],(o|0)<6){Te=u+16|0;e:{r:switch(o-4|0){case 0:if(o=s+276|0,(xe[s+300|0]&3)==2)break e;o=s+268|0;break e;case 1:if(o=s+268|0,(xe[s+300|0]&3)==2)break e;o=s+276|0;break e;default:break r}o=(s+(o<<2)|0)+268|0}return+C[o>>2]}c[u>>2]=1872,ur(s,u),rr(),kt()}function QT(s,o){s=s|0,o=o|0;var u=0;if(u=Te-16|0,Te=u,s=c[s>>2],(o|0)<6){Te=u+16|0;e:{r:switch(o-4|0){case 0:if(o=s+292|0,(xe[s+300|0]&3)==2)break e;o=s+284|0;break e;case 1:if(o=s+284|0,(xe[s+300|0]&3)==2)break e;o=s+292|0;break e;default:break r}o=(s+(o<<2)|0)+284|0}return+C[o>>2]}c[u>>2]=1872,ur(s,u),rr(),kt()}function JT(s,o){s=s|0,o=o|0;var u=0,d=v(0),y=v(0);d=v(Xe),o=c[o>>2],y=C[o+40>>2],o=c[o+40>>2],u=3;e:{if((o|0)==2141891242)break e;if((o|0)==2140081935){d=v(0),u=1;break e}if((o|0)==2139156720){d=v(0),u=2;break e}if(u=0,y!=y)break e;d=(Ce(2,(o&-1073741825)+536870912|0),He()),u=o&1073741824?2:1}c[s>>2]=u,Ht[s+8>>3]=d}function Xr(s){var o=0,u=v(0);o=2143289344;e:{if(v(zt(s))==v(dm)|s!=s||(o=2139156720,s<v(10842021724855044e-35)&s>v(-10842021724855044e-35)|s==v(0)))break e;u=(Ce(2,(yi(s),mt(2)&-2147483648|1602224127)),He()),o=(yi(s>v(0xffffff0000000000)||s<v(-0xffffff0000000000)?u:s),mt(2)-536870912|1073741824)}return o}function kr(s){var o=0,u=v(0);o=2143289344;e:{if(v(zt(s))==v(dm)|s!=s||(o=2140081935,s<v(10842021724855044e-35)&s>v(-10842021724855044e-35)|s==v(0)))break e;u=(Ce(2,(yi(s),mt(2)&-2147483648|1610612735)),He()),o=(yi(s>v(36893485948395848e3)||s<v(-36893485948395848e3)?u:s),mt(2)-536870912|0)}return o}function ek(s,o){s=s|0,o=o|0;var u=v(0),d=v(0);s=c[s>>2]+(o<<2)|0,d=C[s+188>>2];e:{r:{if(s=c[s+188>>2],(s|0)==2139156720|(s|0)==2140081935)break r;if(u=v(Xe),(s|0)==2141891242|d!=d)break e;if((s|0)==2139156720)break r;return v((Ce(2,(s&-1073741825)+536870912|0),He()))}u=v(0)}return v(u)}function tk(s,o,u,d,y,E){s=s|0,o=o|0,u=v(u),d=d|0,y=v(y),E=E|0;var T=0,S=0;return T=Te-16|0,Te=T,S=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(S=c[S+c[o>>2]>>2]),$e[S|0](T,o,u,d,y,E),s=he(16),o=c[T+12>>2],c[s+8>>2]=c[T+8>>2],c[s+12>>2]=o,o=c[T+4>>2],c[s>>2]=c[T>>2],c[s+4>>2]=o,Te=T+16|0,s|0}function Fm(s,o){e:{if(o){o=ig(c[o>>2]);break e}r:{if(xe[7016]){o=c[1753];break r}o=he(28),c[o+20>>2]=1065353216,c[o+24>>2]=0,c[o+12>>2]=0,c[o+16>>2]=0,c[o>>2]=0,ge[o+8|0]=0,c[o+4>>2]=1,c[1753]=o,ge[7016]=1,c[1752]=c[1752]+1}o=ig(o)}return c[s+4>>2]=0,c[s+8>>2]=0,c[s>>2]=o,c[o>>2]=s,s}function ik(s,o,u){s=s|0,o=o|0,u=+u;var d=0,y=0;e:{if(s=c[s>>2],o=s+(o<<2)|0,y=c[o+152>>2],d=kr(v(u)),(y|0)==(d|0))break e;for(c[o+152>>2]=d;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function rk(s,o,u){s=s|0,o=o|0,u=+u;var d=0,y=0;e:{if(s=c[s>>2],o=s+(o<<2)|0,y=c[o+188>>2],d=kr(v(u)),(y|0)==(d|0))break e;for(c[o+188>>2]=d;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function sk(s,o){s=s|0,o=o|0;var u=0,d=v(0);s=c[s>>2]+(o<<2)|0,d=C[s+152>>2];e:{r:{if(s=c[s+152>>2],(s|0)==2139156720|(s|0)==2140081935)break r;if(u=Xe,(s|0)==2141891242|d!=d)break e;if((s|0)==2139156720)break r;return Ce(2,(s&-1073741825)+536870912|0),+He()}u=0}return+u}function nk(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>20&3)==(o|0))break e;for(c[s+24>>2]=u&-3145729|o<<20&3145728;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function zn(s,o,u){var d=0,y=0,E=0;e:{if(!o){d=s;break e}for(;d=Sm(s,o,10),y=Wi,s=ch(d,y,246,0)+s|0,u=u-1|0,ge[u|0]=s|48,E=o>>>0>9,s=d,o=y,!!E;);}if(d)for(;u=u-1|0,s=(d>>>0)/10|0,ge[u|0]=Wt(s,246)+d|48,o=d>>>0>9,d=s,!!o;);return u}function ok(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>22&1)==(o|0))break e;for(c[s+24>>2]=u&-4194305|o<<22&4194304;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function ak(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>18&3)==(o|0))break e;for(c[s+24>>2]=u&-786433|o<<18&786432;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function lk(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>16&3)==(o|0))break e;for(c[s+24>>2]=u&-196609|o<<16&196608;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function ck(s,o){s=s|0,o=+o;var u=0,d=v(0),y=v(0);e:{if(d=v(o),s=c[s>>2],y=C[s+224>>2],d==y|d!=d&y!=y)break e;for(C[s+224>>2]=d;;){if(u=xe[s+4|0],u&4)break e;if(ge[s+4|0]=u|4,u=c[s+20>>2],u&&$e[u|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function uk(s,o){s=s|0,o=+o;var u=0,d=v(0),y=v(0);e:{if(d=v(o),s=c[s>>2],y=C[s+28>>2],d==y|d!=d&y!=y)break e;for(C[s+28>>2]=d;;){if(u=xe[s+4|0],u&4)break e;if(ge[s+4|0]=u|4,u=c[s+20>>2],u&&$e[u|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function hk(s,o){s=s|0,o=+o;var u=0,d=v(0),y=v(0);e:{if(d=v(o),s=c[s>>2],y=C[s+32>>2],d==y|d!=d&y!=y)break e;for(C[s+32>>2]=d;;){if(u=xe[s+4|0],u&4)break e;if(ge[s+4|0]=u|4,u=c[s+20>>2],u&&$e[u|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function dk(s,o){s=s|0,o=+o;var u=0,d=v(0),y=v(0);e:{if(d=v(o),s=c[s>>2],y=C[s+36>>2],d==y|d!=d&y!=y)break e;for(C[s+36>>2]=d;;){if(u=xe[s+4|0],u&4)break e;if(ge[s+4|0]=u|4,u=c[s+20>>2],u&&$e[u|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function fk(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>4&7)==(o|0))break e;for(c[s+24>>2]=u&-113|o<<4&112;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function pk(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=c[s+24>>2],(u>>>2&3)==(o|0))break e;for(c[s+24>>2]=u&-13|o<<2&12;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function mk(s,o){s=s|0,o=o|0;var u=0;e:{if(s=c[s>>2],u=xe[s+4|0],((u&2)>>>1|0)==(o|0))break e;for(ge[s+4|0]=u&253|(o?2:0);;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function gk(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0;return d=Te-16|0,Te=d,y=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](d,o,u),s=he(16),o=c[d+12>>2],c[s+8>>2]=c[d+8>>2],c[s+12>>2]=o,o=c[d+4>>2],c[s>>2]=c[d>>2],c[s+4>>2]=o,Te=d+16|0,s|0}function Mm(s,o){var u=0,d=0;e:{r:{if(u=c[s+556>>2],d=c[s+560>>2],(u|0)==(d|0))break r;for(;;){if(c[u>>2]==(o|0))break r;if(u=u+4|0,(d|0)==(u|0))break}break e}if((u|0)==(d|0))break e;return o=u+4|0,Vs(u,o,d-o|0),c[s+560>>2]=d-4,1}return 0}function vk(s){s=s|0;var o=0,u=0;if(u=Te-16|0,Te=u,s=c[s>>2],c[s+8>>2]){for(;o=xe[s+4|0],!!(!(o&4)&&(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],s)););Te=u+16|0;return}c[u>>2]=1024,ur(s,u),rr(),kt()}function Nm(s,o){var u=0,d=0,y=0;if(Mi(+s),d=mt(1)|0,y=mt(0)|0,u=d>>>20&2047,(u|0)!=2047){if(!u)return s==0?u=0:(s=Nm(s*18446744073709552e3,o),u=c[o>>2]+-64|0),c[o>>2]=u,s;c[o>>2]=u-1022,Ce(0,y|0),Ce(1,d&-2146435073|1071644672),s=+Li()}return s}function yk(s,o){s=s|0,o=o|0;var u=0,d=0;return u=Te-16|0,Te=u,d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](u,o),s=he(16),o=c[u+12>>2],c[s+8>>2]=c[u+8>>2],c[s+12>>2]=o,o=c[u+4>>2],c[s>>2]=c[u>>2],c[s+4>>2]=o,Te=u+16|0,s|0}function wl(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+184>>2]==(u|0))break e;for(c[((o<<2)+d|0)+184>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function _l(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+192>>2]==(u|0))break e;for(c[((o<<2)+d|0)+192>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Yn(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+176>>2]==(u|0))break e;for(c[((o<<2)+d|0)+176>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function ah(s,o){var u=0,d=0,y=0;e:{if(u=s+24|0,c[u+16>>2]==(o|0))break e;for(d=$e[9](u)|0,y=o,c[d+16>>2]=y;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Um(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+92>>2]==(u|0))break e;for(c[((o<<2)+d|0)+92>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function lh(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+20>>2]==(u|0))break e;for(c[((o<<2)+d|0)+20>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Bm(s,o,u){var d=0;e:{if(d=s+24|0,c[(d+(o<<2)|0)+56>>2]==(u|0))break e;for(c[((o<<2)+d|0)+56>>2]=u;;){if(o=xe[s+4|0],o&4)break e;if(ge[s+4|0]=o|4,o=c[s+20>>2],o&&$e[o|0](s),c[s+308>>2]=2143289344,s=c[s+552>>2],!s)break}}}function Ak(){for(var s=0,o=0,u=0;o=s<<4,u=o+5968|0,c[o+5972>>2]=u,c[o+5976>>2]=u,s=s+1|0,(s|0)!=64;);sh(48),c[1756]=16,c[1757]=0,Am(),c[1757]=c[1768],c[1768]=7024,c[1769]=198,c[1770]=0,Rm(),c[1770]=c[1768],c[1768]=7076}function hr(s,o){var u=0,d=v(0);s=s+80|0,u=c[(o<<2)+4288>>2];e:{if((o&-2)==2){s=Kr(s,4,u,2143289344);break e}s=zr(s,u,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(d=(Ce(2,s),He()),s=d==d),s}function Rl(s,o){var u=0,d=v(0);s=s+80|0,u=c[(o<<2)+4304>>2];e:{if((o&-2)==2){s=Kr(s,5,u,2143289344);break e}s=zr(s,u,2143289344)}return(s|0)==2139156720|(s|0)==2140081935|(s|0)==2141891242?s=1:(d=(Ce(2,s),He()),s=d==d),s}function ch(s,o,u,d){var y=0,E=0,T=0,S=0,D=0,j=0;return y=u>>>16|0,E=s>>>16|0,j=Wt(y,E),T=u&65535,S=s&65535,D=Wt(T,S),E=(D>>>16|0)+Wt(E,T)|0,y=(E&65535)+Wt(y,S)|0,Wi=(Wt(o,u)+j|0)+Wt(s,d)+(E>>>16)+(y>>>16)|0,D&65535|y<<16}function Gm(s,o){var u=0,d=0,y=0;d=Te-16|0,Te=d,u=xe[s+4|0],y=u&-17,ge[s+4|0]=y;e:{if(o){if(c[s+560>>2]!=c[s+556>>2])break e;u=y|8}else u=u&231;c[s+8>>2]=o,ge[s+4|0]=u,Te=d+16|0;return}c[d>>2]=4128,ur(s,d),rr(),kt()}function Vm(s){var o=0,u=v(0);o=0;e:{if((c[s+24>>2]&196608)==131072)break e;r:{if(!c[s+552>>2]||(u=C[s+32>>2],u!=u&&(u=C[s+28>>2],!(u>v(0)))))break r;if(o=1,u!=v(0))break e}o=Xn(s)!=v(0)}return o}function bi(s,o,u,d,y){var E=0;if(E=Te-256|0,Te=E,!(y&73728|(u|0)<=(d|0))){if(d=u-d|0,u=d>>>0<256,Ki(E,o&255,u?d:256),!u)for(;fi(s,E,256),d=d-256|0,d>>>0>255;);fi(s,E,d)}Te=E+256|0}function En(s,o,u){var d=0,y=v(0);e:{if((u&-2)==2&&(d=o- -64|0,y=C[d>>2],d=c[d>>2],(d|0)==2139156720|(d|0)==2140081935|(d|0)==2141891242|y==y))break e;d=c[((c[(u<<2)+4304>>2]<<2)+o|0)+44>>2]}Pm(s,d)}function bn(s,o,u){var d=0,y=v(0);e:{if((u&-2)==2&&(d=c[o+60>>2],y=C[o+60>>2],(d|0)==2139156720|(d|0)==2140081935|(d|0)==2141891242|y==y))break e;d=c[((c[(u<<2)+4288>>2]<<2)+o|0)+44>>2]}Pm(s,d)}function Xn(s){var o=v(0),u=v(0);if(!c[s+552>>2])return v(0);o=C[s+36>>2];e:{if(o==o||(o=v(1),ge[c[s+568>>2]+8|0]&1)||(o=v(0),u=C[s+28>>2],!(u<v(0))))break e;o=v(-u)}return o}function Hm(s){var o=0,u=0,d=0;for(d=c[s>>2];;){if(u=ge[d|0],Cl(u)){d=d+1|0,c[s>>2]=d,o>>>0<=214748364?(u=u-48|0,o=Wt(o,10),o=(u|0)>(o^2147483647)?-1:u+o|0):o=-1;continue}break}return o}function Qo(s,o,u,d){var y=0;c[s+12>>2]=0,c[s+16>>2]=d;e:{if(o){if(o>>>0>=1073741824)break e;y=he(o<<2)}return c[s>>2]=y,u=(u<<2)+y|0,c[s+8>>2]=u,c[s+12>>2]=(o<<2)+y,c[s+4>>2]=u,s}mh(),kt()}function Wm(s){var o=0;return o=c[s+72>>2],c[s+72>>2]=o-1|o,o=c[s>>2],o&8?(c[s>>2]=o|32,-1):(c[s+4>>2]=0,c[s+8>>2]=0,o=c[s+44>>2],c[s+28>>2]=o,c[s+20>>2]=o,c[s+16>>2]=o+c[s+48>>2],0)}function Ek(s,o,u,d,y,E){s=s|0,o=o|0,u=v(u),d=d|0,y=v(y),E=E|0;var T=0;T=Te-16|0,Te=T,o=c[c[o>>2]+4>>2],$e[c[c[o>>2]+8>>2]](T,o,u,d,y,E),C[s>>2]=Ht[T>>3],C[s+4>>2]=Ht[T+8>>3],Te=T+16|0}function bk(){var s=0,o=0;return o=he(4),s=he(28),c[s+20>>2]=1065353216,c[s+24>>2]=0,c[s+12>>2]=0,c[s+16>>2]=0,c[s>>2]=0,ge[s+8|0]=0,c[s+4>>2]=1,c[1752]=c[1752]+1,c[o>>2]=s,o|0}function xk(s,o){s=s|0,o=o|0,o=c[o>>2],Ht[s>>3]=C[o+228>>2],Ht[s+8>>3]=C[o+236>>2],Ht[s+16>>3]=C[o+232>>2],Ht[s+24>>3]=C[o+240>>2],Ht[s+32>>3]=C[o+244>>2],Ht[s+40>>3]=C[o+248>>2]}function Tk(s,o){s=s|0,o=o|0;var u=0,d=0;return u=Te-48|0,Te=u,d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](u,o),s=ji(he(48),u,48),Te=u+48|0,s|0}function kk(s,o,u,d){s=s|0,o=o|0,u=u|0,d=d|0;var y=0;return y=Te-16|0,Te=y,s=rg(AT(c[s+60>>2],o|0,u|0,d&255,y+8|0)|0),Te=y+16|0,Wi=s?-1:c[y+12>>2],(s?-1:c[y+8>>2])|0}function Sk(s,o){s=s|0,o=o|0;var u=0,d=0;u=c[s>>2],s=c[u+556>>2];e:{if(c[u+560>>2]-s>>2>>>0<=o>>>0||(s=c[s+(o<<2)>>2],!s))break e;d=c[s>>2]}return d|0}function wk(s,o,u){if(s=s|0,o=o|0,u=u|0,o>>>0<3){o=1<<o,s=c[s>>2],u?o=o|c[s+12>>2]:o=c[s+12>>2]&(o^-1),c[s+12>>2]=o;return}Gs(),kt()}function _k(s,o,u,d,y){s=s|0,o=o|0,u=+u,d=+d,y=y|0;var E=0;E=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(E=c[E+c[o>>2]>>2]),$e[E|0](o,u,d,y)}function Rk(s,o,u){s=s|0,o=o|0,u=u|0;var d=0;return d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),v(v($e[d|0](o,u)))}function jm(s,o,u,d){s=s|0,o=o|0,u=u|0,d=d|0;var y=0;y=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](o,u,d)}function Km(s,o,u){s=s|0,o=o|0,u=u|0;var d=0;return d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](o,u)|0}function Lk(s,o,u,d){s=s|0,o=o|0,u=u|0,d=+d;var y=0;y=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(y=c[y+c[o>>2]>>2]),$e[y|0](o,u,d)}function Ck(s,o,u){s=s|0,o=o|0,u=u|0;var d=0;return d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),+$e[d|0](o,u)}function he(s){var o=0;s=s||1;e:{for(;;){if(o=ih(s),o)break e;if(o=c[2042],o){$e[o|0]();continue}break}Gs(),kt()}return o}function Ik(s,o,u){s=s|0,o=o|0,u=v(u);var d=0;d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](o,u)}function Ws(s,o,u){s=s|0,o=o|0,u=u|0;var d=0;d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](o,u)}function xn(s,o){s=s|0,o=o|0;var u=0;return u=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(u=c[u+c[o>>2]>>2]),$e[u|0](o)|0}function uh(s,o){return yi(s),(mt(2)&2147483647)>>>0<=2139095040?(yi(o),(mt(2)&2147483647)>>>0>2139095040?s:v(fT(s,o))):o}function ht(s,o){return yi(s),(mt(2)&2147483647)>>>0<=2139095040?(yi(o),(mt(2)&2147483647)>>>0>2139095040?s:v(pT(s,o))):o}function zm(s,o){s=s|0,o=o|0;var u=0;return u=Te-16|0,Te=u,c[u+8>>2]=o,s=$e[s|0](u+8|0)|0,Zo(c[u+8>>2]),Te=u+16|0,s|0}function Dk(s,o,u){s=s|0,o=o|0,u=+u;var d=0;d=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(d=c[d+c[o>>2]>>2]),$e[d|0](o,u)}function Ok(s,o,u,d,y){return u=u|0,d=d|0,y=y|0,u&&(u|0)!=5?ag(5816,d,y)|0:ag(5672,d,y)|0}function Ym(s,o){if(!s)return 0;e:{if(!((o&-128)==57216|o>>>0<=127)){c[1781]=25,s=-1;break e}ge[s|0]=o,s=1}return s}function Pk(s,o){s=s|0,o=o|0;var u=0;return u=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(u=c[u+c[o>>2]>>2]),+$e[u|0](o)}function Xm(s,o){var u=0,d=0;u=he(4),c[u>>2]=o,d=he(4),c[d>>2]=o,Tl(7035,s|0,7098,4714,196,u|0,7098,4718,197,d|0)}function Zn(s,o){var u=0,d=0;u=he(4),c[u>>2]=o,d=he(4),c[d>>2]=o,Tl(7065,s|0,7098,4714,194,u|0,7098,4718,195,d|0)}function hh(s,o){var u=0;e:{if(ge[7044]&1){u=c[1760];break e}u=fm(1,4464)|0,ge[7044]=1,c[1760]=u}yT(u|0,s|0,o|0,0)}function $k(s,o){s=s|0,o=o|0;var u=0;u=c[s+8>>2],c[s+8>>2]=o,u&&$e[c[c[u>>2]+4>>2]](u),c[c[s>>2]+20>>2]=15}function Fk(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0;d=s,y=vm((ge[o+11|0]<0?c[o>>2]:o)|0,7036,c[u>>2])|0,c[d>>2]=y}function Mk(s,o,u){s=s|0,o=o|0,u=u|0;var d=0,y=0;d=s,y=vm((ge[o+11|0]<0?c[o>>2]:o)|0,7059,c[u>>2])|0,c[d>>2]=y}function Zm(s,o){s=s|0,o=o|0;var u=0;u=c[s>>2],s=c[s+4>>2],o=(s>>1)+o|0,s&1&&(u=c[u+c[o>>2]>>2]),$e[u|0](o)}function Nk(s){s=s|0;var o=v(0);return s=c[s>>2],o=C[s+36>>2],o!=o&&(o=ge[c[s+568>>2]+8|0]&1?v(1):v(0)),+o}function Uk(s,o){s=s|0,o=o|0;var u=0;u=c[s+4>>2],c[s+4>>2]=o,u&&$e[c[c[u>>2]+4>>2]](u),Gm(c[s>>2],14)}function Bk(s){s=s|0;var o=0;o=c[s+8>>2],c[s+8>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),c[c[s>>2]+20>>2]=0}function Gk(s){s=s|0;var o=0;return o=he(12),ge[o+4|0]=0,c[o+8>>2]=c[s>>2],c[s>>2]=0,c[o>>2]=4432,o|0}function Vk(s){s=s|0;var o=0;return o=he(12),ge[o+4|0]=0,c[o+8>>2]=c[s>>2],c[s>>2]=0,c[o>>2]=4552,o|0}function Hk(){var s=0;if(s=c[1768],s)for(;$e[c[s>>2]](),s=c[s+4>>2],!!s;);}function Wk(s){s=s|0;var o=0;o=c[s+4>>2],c[s+4>>2]=0,o&&$e[c[c[o>>2]+4>>2]](o),Gm(c[s>>2],0)}function qm(s){return s=s|0,c[s>>2]=4572,xe[s+4|0]&&hh(c[s+8>>2],1759),Zo(c[s+8>>2]),s|0}function Qm(s){return s=s|0,c[s>>2]=4452,xe[s+4|0]&&hh(c[s+8>>2],1759),Zo(c[s+8>>2]),s|0}function jk(){var s=0;return s=he(16),c[s>>2]=0,c[s+4>>2]=0,c[s+8>>2]=0,c[s+12>>2]=0,s|0}function Jm(s,o,u){return hr(s,o)?Hs(s,o,u):(u=qo(s,o,u),u==u&&(u=v(-u)),u)}function eg(s,o){var u=0;u=Te-16|0,Te=u,s||(c[u>>2]=o,ur(0,u),rr(),kt()),Te=u+16|0}function tg(s){s=s|0;var o=0;s&&(o=c[s>>2],o&&Ei(o),c[1752]=c[1752]-1,Ei(s))}function Kk(s,o){return s=s|0,o=o|0,o>>>0>=3&&(Gs(),kt()),c[c[s>>2]+12>>2]>>>o&1}function zk(s,o,u,d,y){return s=s|0,o=o|0,u=u|0,d=d|0,y=y|0,$e[s|0](o,u,d,y)|0}function Yk(){var s=0;return s=he(16),c[s+8>>2]=0,c[s+12>>2]=0,c[s>>2]=0,s|0}function Xk(s){s=s|0;var o=v(0);return o=C[c[s>>2]+224>>2],+(o!=o?v(Xe):o)}function Zk(s){return s=s|0,s=c[c[s>>2]+552>>2],s?c[s>>2]:0}function qk(s){s=s|0;var o=v(0);return o=C[c[s>>2]+32>>2],+(o==o?o:v(0))}function ig(s){var o=0;return o=bm(he(588),s),eg((s|0)!=0,2808),o}function Qk(s,o){s=s|0,o=o|0,s=c[s>>2],c[s+16>>2]=c[s+16>>2]&-2|o}function Jk(s){return s=s|0,s=c[s>>2],c[s+560>>2]-c[s+556>>2]>>2}function eS(s,o){s=s|0,o=o|0,s=c[s>>2],ge[s+8|0]=xe[s+8|0]&254|o}function tS(s){s=s|0,s=c[c[s>>2]+8>>2],$e[c[c[s>>2]+8>>2]](s)}function iS(s,o,u){s=s|0,o=o|0,u=+u,lh(c[s>>2],o,kr(v(u)))}function rS(s,o,u){s=s|0,o=o|0,u=+u,lh(c[s>>2],o,Xr(v(u)))}function sS(s,o,u,d){return Wi=0,0}function nS(s,o,u){s=s|0,o=o|0,u=+u,Um(c[s>>2],o,kr(v(u)))}function oS(s,o,u){s=s|0,o=o|0,u=+u,Um(c[s>>2],o,Xr(v(u)))}function aS(s,o,u){s=s|0,o=o|0,u=+u,Bm(c[s>>2],o,kr(v(u)))}function lS(s,o,u){s=s|0,o=o|0,u=+u,Bm(c[s>>2],o,Xr(v(u)))}function cS(s,o,u){s=s|0,o=o|0,u=u|0,c[c[s>>2]+o>>2]=u}function uS(s,o){s=s|0,o=o|0,lh(c[s>>2],o,2141891242)}function dh(s,o,u){s=s|0,o=o|0,u=+u,Ht[c[s>>2]+o>>3]=u}function hS(s){return s=s|0,(xe[c[s>>2]+4|0]&2)>>>1|0}function dS(s){return s=s|0,(xe[c[s>>2]+4|0]&4)>>>2|0}function fS(s,o){s=s|0,o=o|0,c[s+4>>2]=10,c[s>>2]=o}function pS(s,o){s=s|0,o=o|0,c[s+4>>2]=13,c[s>>2]=o}function mS(s){return s=s|0,c[c[s>>2]+24>>2]>>>10&7}function gS(s){return s=s|0,c[c[s>>2]+24>>2]>>>13&7}function fh(s,o){return s=s|0,o=o|0,+Ht[c[s>>2]+o>>3]}function vS(s){return s=s|0,c[c[s>>2]+24>>2]>>>18&3}function yS(s){return s=s|0,c[c[s>>2]+24>>2]>>>20&3}function AS(s){return s=s|0,c[c[s>>2]+24>>2]>>>22&1}function ES(s,o){return s=s|0,o=o|0,c[c[s>>2]+o>>2]}function bS(s,o){s=s|0,o=+o,Yn(c[s>>2],0,kr(v(o)))}function xS(s,o){s=s|0,o=+o,Yn(c[s>>2],0,Xr(v(o)))}function TS(s,o){s=s|0,o=+o,Yn(c[s>>2],1,kr(v(o)))}function kS(s,o){s=s|0,o=+o,Yn(c[s>>2],1,Xr(v(o)))}function SS(s,o){s=s|0,o=o|0,c[s+4>>2]=7,c[s>>2]=o}function wS(s,o){s=s|0,o=+o,wl(c[s>>2],0,kr(v(o)))}function _S(s,o){s=s|0,o=+o,wl(c[s>>2],0,Xr(v(o)))}function RS(s,o){s=s|0,o=+o,wl(c[s>>2],1,kr(v(o)))}function LS(s,o){s=s|0,o=+o,wl(c[s>>2],1,Xr(v(o)))}function CS(s,o){s=s|0,o=+o,_l(c[s>>2],0,kr(v(o)))}function IS(s,o){s=s|0,o=+o,_l(c[s>>2],1,kr(v(o)))}function DS(s,o){s=s|0,o=+o,_l(c[s>>2],1,Xr(v(o)))}function OS(s){return s=s|0,c[c[s>>2]+24>>2]>>>7&7}function PS(s){return s=s|0,c[c[s>>2]+24>>2]>>>2&3}function $S(s){return s=s|0,c[c[s>>2]+24>>2]>>>4&7}function Ll(s){s=s|0,s&&$e[c[c[s>>2]+4>>2]](s)}function FS(s,o){s=s|0,o=+o,_l(c[s>>2],0,Xr(v(o)))}function rg(s){return s?(c[1781]=s,-1):0}function MS(s,o){s=s|0,o=+o,ah(c[s>>2],kr(v(o)))}function NS(s,o){s=s|0,o=+o,ah(c[s>>2],Xr(v(o)))}function sg(s,o,u){return v(ft(s,o,u)+St(s,o,u))}function US(s,o){return s=s|0,o=o|0,$e[s|0](o)|0}function ng(s,o,u,d){ET(s|0,o|0,8,0,u|0,-1,d|0)}function BS(s,o){s=s|0,o=o|0,c[c[s>>2]+16>>2]=o}function GS(s){return s=s|0,c[c[s>>2]+16>>2]&1}function VS(s){return s=s|0,Wn[c[s>>2]+26>>1]&3}function HS(s){s=s|0,Yn(c[s>>2],0,2141891242)}function WS(s){s=s|0,Yn(c[s>>2],1,2141891242)}function jS(s){return s=s|0,+C[c[s>>2]+228>>2]}function KS(s){return s=s|0,+C[c[s>>2]+236>>2]}function zS(s){return s=s|0,+C[c[s>>2]+232>>2]}function YS(s){return s=s|0,+C[c[s>>2]+240>>2]}function XS(s){return s=s|0,+C[c[s>>2]+244>>2]}function ZS(s){return s=s|0,+C[c[s>>2]+248>>2]}function qS(s){return s=s|0,kT(c[s+60>>2])|0}function QS(s){return s=s|0,c[c[s>>2]+16>>2]}function JS(s){return s=s|0,ge[c[s>>2]+8|0]&1}function ew(s,o){s=s|0,o=o|0,oh(c[s>>2],5,o)}function tw(s,o){s=s|0,o=o|0,oh(c[s>>2],6,o)}function iw(s,o){s=s|0,o=o|0,oh(c[s>>2],7,o)}function rw(s){s=s|0,ah(c[s>>2],2141891242)}function og(s,o){s=s|0,o=o|0,$e[c[s>>2]](o)}function sw(s){return s=s|0,Fm(he(12),s)|0}function nw(s){s=s|0,hh(c[s+8>>2],3293)}function ag(s,o,u){return Im(s,o,u,2,3)}function lg(s){return s=s|0,$e[s|0]()|0}function cg(s,o){s=s|0,o=o|0,$e[s|0](o)}function ow(){return Ki(he(48),0,48)|0}function rr(){$e[c[1490]](),mh(),kt()}function aw(){return Fm(he(12),0)|0}function ph(s){s=s|0,s&&Ei(s)}function Cl(s){return s-48>>>0<10}function lw(s){return 7032}function cw(s){return 7036}function uw(s){return 7056}function hw(s){return 7059}function dw(s){return 7062}function fw(s){return 7067}function Ir(s){return s=s|0,s|0}function ug(s){s=s|0,ge[s+4|0]=1}function pw(s){s=s|0,Ei(qm(s))}function mw(s){s=s|0,Ei(Qm(s))}function gw(s){return 0}function hg(s){kt()}function dg(){mh(),kt()}function mh(){Gs(),kt()}Z=xe,Pe();var $e=X([null,Ok,RT,IT,Ir,SS,fS,pS,Ir,Ir,Ir,Ir,Ir,Ir,Ek,tS,Am,lw,Ll,tk,cw,Ir,Ir,Ll,ug,og,zm,Gk,UT,Fk,uw,Ll,Zm,hw,Ir,Ir,Ll,ug,og,zm,Vk,Mk,dw,tg,lg,bk,cg,tg,wk,jm,MT,Ik,Qk,Ws,BS,Ws,eS,Kk,Km,GS,xn,QS,xn,JS,ow,ph,jk,ph,Yk,ph,fh,dh,ES,cS,fw,_m,lg,aw,US,sw,cg,_m,PT,Zm,CT,Ws,lk,Ws,aS,Lk,lS,ew,tw,iw,pk,ak,fk,iS,rS,uS,nk,ok,uk,Dk,MS,NS,rw,hk,dk,bS,xS,HS,TS,kS,WS,wS,_S,RS,LS,CS,FS,IS,DS,ck,ik,nS,oS,rk,VS,xn,VT,gk,OS,mS,gS,PS,vS,$S,HT,JT,yk,qk,Pk,Nk,jT,KT,zT,YT,XT,WT,Xk,sk,Ck,yS,AS,GT,ek,Rk,DT,jm,OT,Ws,Jk,xn,Zk,xn,Sk,Km,hS,xn,mk,Ws,Uk,Ws,Wk,$k,Ws,Bk,vk,dS,xn,LT,_k,jS,KS,zS,YS,XS,ZS,xk,Tk,ZT,qT,QT,fh,dh,fh,dh,Rm,Qm,mw,NT,hg,dg,qm,pw,nw,hg,qS,$T,kk,gw,sS,BT,dg]);function fg(){return Hi.byteLength/65536|0}function vw(s){s=s|0;var o=fg()|0,u=o+s|0;if(o<u&&u<65536){var d=new ArrayBuffer(Wt(u,65536)),y=new Int8Array(d);y.set(ge),ge=new Int8Array(d),jr=new Int16Array(d),c=new Int32Array(d),xe=new Uint8Array(d),Wn=new Uint16Array(d),hm=new Uint32Array(d),C=new Float32Array(d),Ht=new Float64Array(d),Hi=d,cr.buffer=Hi,Z=xe}return o}return{E:Ak,F:FT,G:Hk,H:ih,I:$e,J:Ei,K:zk}}return xl(V)}(R)}var w=Error,P={};A=[],typeof P!="object"&&Le("no native wasm support detected");var $,N=!1;function I(R,L,V){V=L+V;for(var X="";!(L>=V);){var Z=R[L++];if(!Z)break;if(Z&128){var ye=R[L++]&63;if((Z&224)==192)X+=String.fromCharCode((Z&31)<<6|ye);else{var ke=R[L++]&63;Z=(Z&240)==224?(Z&15)<<12|ye<<6|ke:(Z&7)<<18|ye<<12|ke<<6|R[L++]&63,65536>Z?X+=String.fromCharCode(Z):(Z-=65536,X+=String.fromCharCode(55296|Z>>10,56320|Z&1023))}}else X+=String.fromCharCode(Z)}return X}var O,K,U,re,ne,Y,Ee,ce,_e;function Oe(R){O=R,a.HEAP8=K=new Int8Array(R),a.HEAP16=re=new Int16Array(R),a.HEAP32=Y=new Int32Array(R),a.HEAPU8=U=new Uint8Array(R),a.HEAPU16=ne=new Uint16Array(R),a.HEAPU32=Ee=new Uint32Array(R),a.HEAPF32=ce=new Float32Array(R),a.HEAPF64=_e=new Float64Array(R)}var B=a.INITIAL_MEMORY||16777216;a.wasmMemory?$=a.wasmMemory:$=new b,$&&(O=$.buffer),B=O.byteLength,Oe(O);var W,we=[],M=[],G=[];function Q(){var R=a.preRun.shift();we.unshift(R)}var me=0,pe=null;function Le(R){throw a.onAbort&&a.onAbort(R),R="Aborted("+R+")",g(R),N=!0,R=new w(R+". Build with -sASSERTIONS for more info."),h(R),R}function Ue(R){return R.startsWith("data:application/octet-stream;base64,")}var Ke;if(Ke="<<< WASM_BINARY_FILE >>>",!Ue(Ke)){var Ze=Ke;Ke=a.locateFile?a.locateFile(Ze,p):p+Ze}function pt(R){var L=Ke;try{try{if(L==Ke&&A)new Uint8Array(A);else{if(Ue(L)){try{var V=uT(L.slice(37)),X=new Uint8Array(V.length);for(L=0;L<V.length;++L)X[L]=V.charCodeAt(L);var Z=X}catch{throw Error("Converting base64 string to bytes failed.")}var ye=Z}else ye=void 0;if(!ye)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(Pe){Le(Pe)}var ke=new x,le=new k(R)}catch(Pe){throw R=Pe.toString(),g("failed to compile wasm module: "+R),(R.includes("imported Memory")||R.includes("memory import"))&&g("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)."),Pe}return[le,ke]}function dt(R){for(;0<R.length;)R.shift()(a)}function Kt(R){if(R===void 0)return"_unknown";R=R.replace(/[^a-zA-Z0-9_]/g,"$");var L=R.charCodeAt(0);return 48<=L&&57>=L?"_"+R:R}function _t(R,L){return R=Kt(R),function(){return L.apply(this,arguments)}}var je=[{},{value:void 0},{value:null},{value:!0},{value:!1}],qe=[];function Be(R){var L=Error,V=_t(R,function(X){this.name=R,this.message=X,X=Error(X).stack,X!==void 0&&(this.stack=this.toString()+`
79
+ `+X.replace(/^Error(:[^\n]*)?\n/,""))});return V.prototype=Object.create(L.prototype),V.prototype.constructor=V,V.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},V}var ot=void 0;function Me(R){throw new ot(R)}var It=R=>(R||Me("Cannot use deleted val. handle = "+R),je[R].value),At=R=>{switch(R){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=qe.length?qe.pop():je.length;return je[L]={fa:1,value:R},L}},Ut=void 0,hi=void 0;function st(R){for(var L="";U[R];)L+=hi[U[R++]];return L}var Bt=[];function at(){for(;Bt.length;){var R=Bt.pop();R.L.Z=!1,R.delete()}}var $t=void 0,Gt={};function ir(R,L){for(L===void 0&&Me("ptr should not be undefined");R.P;)L=R.aa(L),R=R.P;return L}var Vt={};function Pi(R){R=dT(R);var L=st(R);return Bs(R),L}function hs(R,L){var V=Vt[R];return V===void 0&&Me(L+" has unknown type "+Pi(R)),V}function di(){}var Lr=!1;function Fs(R){--R.count.value,R.count.value===0&&(R.S?R.T.V(R.S):R.O.M.V(R.N))}function Ms(R,L,V){return L===V?R:V.P===void 0?null:(R=Ms(R,L,V.P),R===null?null:V.ma(R))}var lr={};function ue(R,L){return L=ir(R,L),Gt[L]}var Ve=void 0;function Je(R){throw new Ve(R)}function Et(R,L){return L.O&&L.N||Je("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Je("Both smartPtrType and smartPtr must be specified"),L.count={value:1},ct(Object.create(R,{L:{value:L}}))}function ct(R){return typeof FinalizationRegistry>"u"?(ct=L=>L,R):(Lr=new FinalizationRegistry(L=>{Fs(L.L)}),ct=L=>{var V=L.L;return V.S&&Lr.register(L,{L:V},L),L},di=L=>{Lr.unregister(L)},ct(R))}var oi={};function $i(R){for(;R.length;){var L=R.pop();R.pop()(L)}}function Ar(R){return this.fromWireType(Y[R>>2])}var ds={},Er={};function br(R,L,V){function X(le){le=V(le),le.length!==R.length&&Je("Mismatched type converter count");for(var Pe=0;Pe<R.length;++Pe)Fi(R[Pe],le[Pe])}R.forEach(function(le){Er[le]=L});var Z=Array(L.length),ye=[],ke=0;L.forEach((le,Pe)=>{Vt.hasOwnProperty(le)?Z[Pe]=Vt[le]:(ye.push(le),ds.hasOwnProperty(le)||(ds[le]=[]),ds[le].push(()=>{Z[Pe]=Vt[le],++ke,ke===ye.length&&X(Z)}))}),ye.length===0&&X(Z)}function Ns(R){switch(R){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+R)}}function Fi(R,L,V={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var X=L.name;if(R||Me('type "'+X+'" must have a positive integer typeid pointer'),Vt.hasOwnProperty(R)){if(V.ta)return;Me("Cannot register type '"+X+"' twice")}Vt[R]=L,delete Er[R],ds.hasOwnProperty(R)&&(L=ds[R],delete ds[R],L.forEach(Z=>Z()))}function Xo(R){Me(R.L.O.M.name+" instance already deleted")}function xr(){}function Us(R,L,V){if(R[L].R===void 0){var X=R[L];R[L]=function(){return R[L].R.hasOwnProperty(arguments.length)||Me("Function '"+V+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+R[L].R+")!"),R[L].R[arguments.length].apply(this,arguments)},R[L].R=[],R[L].R[X.Y]=X}}function jx(R,L){a.hasOwnProperty(R)?(Me("Cannot register public name '"+R+"' twice"),Us(a,R,R),a.hasOwnProperty(void 0)&&Me("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),a[R].R[void 0]=L):a[R]=L}function Kx(R,L,V,X,Z,ye,ke,le){this.name=R,this.constructor=L,this.W=V,this.V=X,this.P=Z,this.oa=ye,this.aa=ke,this.ma=le,this.ia=[]}function Yu(R,L,V){for(;L!==V;)L.aa||Me("Expected null or instance of "+V.name+", got an instance of "+L.name),R=L.aa(R),L=L.P;return R}function zx(R,L){return L===null?(this.da&&Me("null is not a valid "+this.name),0):(L.L||Me('Cannot pass "'+Qu(L)+'" as a '+this.name),L.L.N||Me("Cannot pass deleted object as a pointer of type "+this.name),Yu(L.L.N,L.L.O.M,this.M))}function Yx(R,L){if(L===null){if(this.da&&Me("null is not a valid "+this.name),this.ca){var V=this.ea();return R!==null&&R.push(this.V,V),V}return 0}if(L.L||Me('Cannot pass "'+Qu(L)+'" as a '+this.name),L.L.N||Me("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Me("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),V=Yu(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Me("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?V=L.L.S:Me("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:V=L.L.S;break;case 2:if(L.L.T===this)V=L.L.S;else{var X=L.clone();V=this.wa(V,At(function(){X.delete()})),R!==null&&R.push(this.V,V)}break;default:Me("Unsupporting sharing policy")}return V}function Xx(R,L){return L===null?(this.da&&Me("null is not a valid "+this.name),0):(L.L||Me('Cannot pass "'+Qu(L)+'" as a '+this.name),L.L.N||Me("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Me("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),Yu(L.L.N,L.L.O.M,this.M))}function fs(R,L,V,X){this.name=R,this.M=L,this.da=V,this.ba=X,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=Yx:(this.toWireType=X?zx:Xx,this.U=null)}function Zx(R,L){a.hasOwnProperty(R)||Je("Replacing nonexistant public symbol"),a[R]=L,a[R].Y=void 0}function qx(R,L){var V=[];return function(){if(V.length=0,Object.assign(V,arguments),R.includes("j")){var X=a["dynCall_"+R];X=V&&V.length?X.apply(null,[L].concat(V)):X.call(null,L)}else X=W.get(L).apply(null,V);return X}}function Cr(R,L){R=st(R);var V=R.includes("j")?qx(R,L):W.get(L);return typeof V!="function"&&Me("unknown function pointer with signature "+R+": "+L),V}var nm=void 0;function yl(R,L){function V(ye){Z[ye]||Vt[ye]||(Er[ye]?Er[ye].forEach(V):(X.push(ye),Z[ye]=!0))}var X=[],Z={};throw L.forEach(V),new nm(R+": "+X.map(Pi).join([", "]))}function Xu(R,L,V,X,Z){var ye=L.length;2>ye&&Me("argTypes array size mismatch! Must at least get return value and 'this' types!");var ke=L[1]!==null&&V!==null,le=!1;for(V=1;V<L.length;++V)if(L[V]!==null&&L[V].U===void 0){le=!0;break}var Pe=L[0].name!=="void",De=ye-2,Ge=Array(De),Ye=[],yt=[];return function(){if(arguments.length!==De&&Me("function "+R+" called with "+arguments.length+" arguments, expected "+De+" args!"),yt.length=0,Ye.length=ke?2:1,Ye[0]=Z,ke){var mt=L[1].toWireType(yt,this);Ye[1]=mt}for(var Ce=0;Ce<De;++Ce)Ge[Ce]=L[Ce+2].toWireType(yt,arguments[Ce]),Ye.push(Ge[Ce]);if(Ce=X.apply(null,Ye),le)$i(yt);else for(var Li=ke?1:2;Li<L.length;Li++){var Mi=Li===1?mt:Ge[Li-2];L[Li].U!==null&&L[Li].U(Mi)}return mt=Pe?L[0].fromWireType(Ce):void 0,mt}}function Zu(R,L){for(var V=[],X=0;X<R;X++)V.push(Ee[L+4*X>>2]);return V}function qu(R){4<R&&--je[R].fa===0&&(je[R]=void 0,qe.push(R))}function Qu(R){if(R===null)return"null";var L=typeof R;return L==="object"||L==="array"||L==="function"?R.toString():""+R}function Qx(R,L){switch(L){case 2:return function(V){return this.fromWireType(ce[V>>2])};case 3:return function(V){return this.fromWireType(_e[V>>3])};default:throw new TypeError("Unknown float type: "+R)}}function Jx(R,L,V){switch(L){case 0:return V?function(X){return K[X]}:function(X){return U[X]};case 1:return V?function(X){return re[X>>1]}:function(X){return ne[X>>1]};case 2:return V?function(X){return Y[X>>2]}:function(X){return Ee[X>>2]};default:throw new TypeError("Unknown integer type: "+R)}}function eT(R,L){for(var V="",X=0;!(X>=L/2);++X){var Z=re[R+2*X>>1];if(Z==0)break;V+=String.fromCharCode(Z)}return V}function tT(R,L,V){if(V===void 0&&(V=2147483647),2>V)return 0;V-=2;var X=L;V=V<2*R.length?V/2:R.length;for(var Z=0;Z<V;++Z)re[L>>1]=R.charCodeAt(Z),L+=2;return re[L>>1]=0,L-X}function iT(R){return 2*R.length}function rT(R,L){for(var V=0,X="";!(V>=L/4);){var Z=Y[R+4*V>>2];if(Z==0)break;++V,65536<=Z?(Z-=65536,X+=String.fromCharCode(55296|Z>>10,56320|Z&1023)):X+=String.fromCharCode(Z)}return X}function sT(R,L,V){if(V===void 0&&(V=2147483647),4>V)return 0;var X=L;V=X+V-4;for(var Z=0;Z<R.length;++Z){var ye=R.charCodeAt(Z);if(55296<=ye&&57343>=ye){var ke=R.charCodeAt(++Z);ye=65536+((ye&1023)<<10)|ke&1023}if(Y[L>>2]=ye,L+=4,L+4>V)break}return Y[L>>2]=0,L-X}function nT(R){for(var L=0,V=0;V<R.length;++V){var X=R.charCodeAt(V);55296<=X&&57343>=X&&++V,L+=4}return L}var oT={};function om(R){var L=oT[R];return L===void 0?st(R):L}var Al=[];function aT(R){var L=Al.length;return Al.push(R),L}function lT(R,L){for(var V=Array(R),X=0;X<R;++X)V[X]=hs(Ee[L+4*X>>2],"parameter "+X);return V}var am=[],cT=[null,[],[]];ot=a.BindingError=Be("BindingError"),a.count_emval_handles=function(){for(var R=0,L=5;L<je.length;++L)je[L]!==void 0&&++R;return R},a.get_first_emval=function(){for(var R=5;R<je.length;++R)if(je[R]!==void 0)return je[R];return null},Ut=a.PureVirtualError=Be("PureVirtualError");for(var lm=Array(256),El=0;256>El;++El)lm[El]=String.fromCharCode(El);hi=lm,a.getInheritedInstanceCount=function(){return Object.keys(Gt).length},a.getLiveInheritedInstances=function(){var R=[],L;for(L in Gt)Gt.hasOwnProperty(L)&&R.push(Gt[L]);return R},a.flushPendingDeletes=at,a.setDelayFunction=function(R){$t=R,Bt.length&&$t&&$t(at)},Ve=a.InternalError=Be("InternalError"),xr.prototype.isAliasOf=function(R){if(!(this instanceof xr&&R instanceof xr))return!1;var L=this.L.O.M,V=this.L.N,X=R.L.O.M;for(R=R.L.N;L.P;)V=L.aa(V),L=L.P;for(;X.P;)R=X.aa(R),X=X.P;return L===X&&V===R},xr.prototype.clone=function(){if(this.L.N||Xo(this),this.L.$)return this.L.count.value+=1,this;var R=ct,L=Object,V=L.create,X=Object.getPrototypeOf(this),Z=this.L;return R=R(V.call(L,X,{L:{value:{count:Z.count,Z:Z.Z,$:Z.$,N:Z.N,O:Z.O,S:Z.S,T:Z.T}}})),R.L.count.value+=1,R.L.Z=!1,R},xr.prototype.delete=function(){this.L.N||Xo(this),this.L.Z&&!this.L.$&&Me("Object already scheduled for deletion"),di(this),Fs(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},xr.prototype.isDeleted=function(){return!this.L.N},xr.prototype.deleteLater=function(){return this.L.N||Xo(this),this.L.Z&&!this.L.$&&Me("Object already scheduled for deletion"),Bt.push(this),Bt.length===1&&$t&&$t(at),this.L.Z=!0,this},fs.prototype.pa=function(R){return this.ja&&(R=this.ja(R)),R},fs.prototype.ga=function(R){this.V&&this.V(R)},fs.prototype.argPackAdvance=8,fs.prototype.readValueFromPointer=Ar,fs.prototype.deleteObject=function(R){R!==null&&R.delete()},fs.prototype.fromWireType=function(R){function L(){return this.ca?Et(this.M.W,{O:this.va,N:V,T:this,S:R}):Et(this.M.W,{O:this,N:R})}var V=this.pa(R);if(!V)return this.ga(R),null;var X=ue(this.M,V);if(X!==void 0)return X.L.count.value===0?(X.L.N=V,X.L.S=R,X.clone()):(X=X.clone(),this.ga(R),X);if(X=this.M.oa(V),X=lr[X],!X)return L.call(this);X=this.ba?X.ka:X.pointerType;var Z=Ms(V,this.M,X.M);return Z===null?L.call(this):this.ca?Et(X.M.W,{O:X,N:Z,T:this,S:R}):Et(X.M.W,{O:X,N:Z})},nm=a.UnboundTypeError=Be("UnboundTypeError");var uT=typeof atob=="function"?atob:function(R){var L="",V=0;R=R.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),Z="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++)),ke="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(R.charAt(V++));X=X<<2|Z>>4,Z=(Z&15)<<4|ye>>2;var le=(ye&3)<<6|ke;L+=String.fromCharCode(X),ye!==64&&(L+=String.fromCharCode(Z)),ke!==64&&(L+=String.fromCharCode(le))}while(V<R.length);return L},hT={q:function(R,L,V){R=st(R),L=hs(L,"wrapper"),V=It(V);var X=[].slice,Z=L.M,ye=Z.W,ke=Z.P.W,le=Z.P.constructor;R=_t(R,function(){Z.P.ia.forEach((function(De){if(this[De]===ke[De])throw new Ut("Pure virtual function "+De+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:ye}),this.__construct.apply(this,X.call(arguments))}),ye.__construct=function(){this===ye&&Me("Pass correct 'this' to __construct");var De=le.implement.apply(void 0,[this].concat(X.call(arguments)));di(De);var Ge=De.L;De.notifyOnDestruction(),Ge.$=!0,Object.defineProperties(this,{L:{value:Ge}}),ct(this),De=Ge.N,De=ir(Z,De),Gt.hasOwnProperty(De)?Me("Tried to register registered instance: "+De):Gt[De]=this},ye.__destruct=function(){this===ye&&Me("Pass correct 'this' to __destruct"),di(this);var De=this.L.N;De=ir(Z,De),Gt.hasOwnProperty(De)?delete Gt[De]:Me("Tried to unregister unregistered instance: "+De)},R.prototype=Object.create(ye);for(var Pe in V)R.prototype[Pe]=V[Pe];return At(R)},k:function(R){var L=oi[R];delete oi[R];var V=L.ea,X=L.V,Z=L.ha,ye=Z.map(ke=>ke.sa).concat(Z.map(ke=>ke.ya));br([R],ye,ke=>{var le={};return Z.forEach((Pe,De)=>{var Ge=ke[De],Ye=Pe.qa,yt=Pe.ra,mt=ke[De+Z.length],Ce=Pe.xa,Li=Pe.za;le[Pe.na]={read:Mi=>Ge.fromWireType(Ye(yt,Mi)),write:(Mi,kt)=>{var yi=[];Ce(Li,Mi,mt.toWireType(yi,kt)),$i(yi)}}}),[{name:L.name,fromWireType:function(Pe){var De={},Ge;for(Ge in le)De[Ge]=le[Ge].read(Pe);return X(Pe),De},toWireType:function(Pe,De){for(var Ge in le)if(!(Ge in De))throw new TypeError('Missing field: "'+Ge+'"');var Ye=V();for(Ge in le)le[Ge].write(Ye,De[Ge]);return Pe!==null&&Pe.push(X,Ye),Ye},argPackAdvance:8,readValueFromPointer:Ar,U:X}]})},w:function(){},C:function(R,L,V,X,Z){var ye=Ns(V);L=st(L),Fi(R,{name:L,fromWireType:function(ke){return!!ke},toWireType:function(ke,le){return le?X:Z},argPackAdvance:8,readValueFromPointer:function(ke){if(V===1)var le=K;else if(V===2)le=re;else if(V===4)le=Y;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(le[ke>>ye])},U:null})},g:function(R,L,V,X,Z,ye,ke,le,Pe,De,Ge,Ye,yt){Ge=st(Ge),ye=Cr(Z,ye),le&&(le=Cr(ke,le)),De&&(De=Cr(Pe,De)),yt=Cr(Ye,yt);var mt=Kt(Ge);jx(mt,function(){yl("Cannot construct "+Ge+" due to unbound types",[X])}),br([R,L,V],X?[X]:[],function(Ce){if(Ce=Ce[0],X)var Li=Ce.M,Mi=Li.W;else Mi=xr.prototype;Ce=_t(mt,function(){if(Object.getPrototypeOf(this)!==kt)throw new ot("Use 'new' to construct "+Ge);if(yi.X===void 0)throw new ot(Ge+" has no accessible constructor");var xl=yi.X[arguments.length];if(xl===void 0)throw new ot("Tried to invoke ctor of "+Ge+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(yi.X).toString()+") parameters instead!");return xl.apply(this,arguments)});var kt=Object.create(Mi,{constructor:{value:Ce}});Ce.prototype=kt;var yi=new Kx(Ge,Ce,kt,yt,Li,ye,le,De);Li=new fs(Ge,yi,!0,!1),Mi=new fs(Ge+"*",yi,!1,!1);var He=new fs(Ge+" const*",yi,!1,!0);return lr[R]={pointerType:Mi,ka:He},Zx(mt,Ce),[Li,Mi,He]})},d:function(R,L,V,X,Z,ye,ke){var le=Zu(V,X);L=st(L),ye=Cr(Z,ye),br([],[R],function(Pe){function De(){yl("Cannot call "+Ge+" due to unbound types",le)}Pe=Pe[0];var Ge=Pe.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Ye=Pe.M.constructor;return Ye[L]===void 0?(De.Y=V-1,Ye[L]=De):(Us(Ye,L,Ge),Ye[L].R[V-1]=De),br([],le,function(yt){return yt=Xu(Ge,[yt[0],null].concat(yt.slice(1)),null,ye,ke),Ye[L].R===void 0?(yt.Y=V-1,Ye[L]=yt):Ye[L].R[V-1]=yt,[]}),[]})},p:function(R,L,V,X,Z,ye){0<L||Le();var ke=Zu(L,V);Z=Cr(X,Z),br([],[R],function(le){le=le[0];var Pe="constructor "+le.name;if(le.M.X===void 0&&(le.M.X=[]),le.M.X[L-1]!==void 0)throw new ot("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+le.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return le.M.X[L-1]=()=>{yl("Cannot construct "+le.name+" due to unbound types",ke)},br([],ke,function(De){return De.splice(1,0,null),le.M.X[L-1]=Xu(Pe,De,null,Z,ye),[]}),[]})},b:function(R,L,V,X,Z,ye,ke,le){var Pe=Zu(V,X);L=st(L),ye=Cr(Z,ye),br([],[R],function(De){function Ge(){yl("Cannot call "+Ye+" due to unbound types",Pe)}De=De[0];var Ye=De.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),le&&De.M.ia.push(L);var yt=De.M.W,mt=yt[L];return mt===void 0||mt.R===void 0&&mt.className!==De.name&&mt.Y===V-2?(Ge.Y=V-2,Ge.className=De.name,yt[L]=Ge):(Us(yt,L,Ye),yt[L].R[V-2]=Ge),br([],Pe,function(Ce){return Ce=Xu(Ye,Ce,De,ye,ke),yt[L].R===void 0?(Ce.Y=V-2,yt[L]=Ce):yt[L].R[V-2]=Ce,[]}),[]})},B:function(R,L){L=st(L),Fi(R,{name:L,fromWireType:function(V){var X=It(V);return qu(V),X},toWireType:function(V,X){return At(X)},argPackAdvance:8,readValueFromPointer:Ar,U:null})},n:function(R,L,V){V=Ns(V),L=st(L),Fi(R,{name:L,fromWireType:function(X){return X},toWireType:function(X,Z){return Z},argPackAdvance:8,readValueFromPointer:Qx(L,V),U:null})},e:function(R,L,V,X,Z){L=st(L),Z===-1&&(Z=4294967295),Z=Ns(V);var ye=le=>le;if(X===0){var ke=32-8*V;ye=le=>le<<ke>>>ke}V=L.includes("unsigned")?function(le,Pe){return Pe>>>0}:function(le,Pe){return Pe},Fi(R,{name:L,fromWireType:ye,toWireType:V,argPackAdvance:8,readValueFromPointer:Jx(L,Z,X!==0),U:null})},c:function(R,L,V){function X(ye){ye>>=2;var ke=Ee;return new Z(O,ke[ye+1],ke[ye])}var Z=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];V=st(V),Fi(R,{name:V,fromWireType:X,argPackAdvance:8,readValueFromPointer:X},{ta:!0})},o:function(R,L){L=st(L);var V=L==="std::string";Fi(R,{name:L,fromWireType:function(X){var Z=Ee[X>>2],ye=X+4;if(V)for(var ke=ye,le=0;le<=Z;++le){var Pe=ye+le;if(le==Z||U[Pe]==0){if(ke=ke?I(U,ke,Pe-ke):"",De===void 0)var De=ke;else De+=String.fromCharCode(0),De+=ke;ke=Pe+1}}else{for(De=Array(Z),le=0;le<Z;++le)De[le]=String.fromCharCode(U[ye+le]);De=De.join("")}return Bs(X),De},toWireType:function(X,Z){Z instanceof ArrayBuffer&&(Z=new Uint8Array(Z));var ye,ke=typeof Z=="string";if(ke||Z instanceof Uint8Array||Z instanceof Uint8ClampedArray||Z instanceof Int8Array||Me("Cannot pass non-string to std::string"),V&&ke){var le=0;for(ye=0;ye<Z.length;++ye){var Pe=Z.charCodeAt(ye);127>=Pe?le++:2047>=Pe?le+=2:55296<=Pe&&57343>=Pe?(le+=4,++ye):le+=3}ye=le}else ye=Z.length;if(le=cm(4+ye+1),Pe=le+4,Ee[le>>2]=ye,V&&ke){if(ke=Pe,Pe=ye+1,ye=U,0<Pe){Pe=ke+Pe-1;for(var De=0;De<Z.length;++De){var Ge=Z.charCodeAt(De);if(55296<=Ge&&57343>=Ge){var Ye=Z.charCodeAt(++De);Ge=65536+((Ge&1023)<<10)|Ye&1023}if(127>=Ge){if(ke>=Pe)break;ye[ke++]=Ge}else{if(2047>=Ge){if(ke+1>=Pe)break;ye[ke++]=192|Ge>>6}else{if(65535>=Ge){if(ke+2>=Pe)break;ye[ke++]=224|Ge>>12}else{if(ke+3>=Pe)break;ye[ke++]=240|Ge>>18,ye[ke++]=128|Ge>>12&63}ye[ke++]=128|Ge>>6&63}ye[ke++]=128|Ge&63}}ye[ke]=0}}else if(ke)for(ke=0;ke<ye;++ke)De=Z.charCodeAt(ke),255<De&&(Bs(Pe),Me("String has UTF-16 code units that do not fit in 8 bits")),U[Pe+ke]=De;else for(ke=0;ke<ye;++ke)U[Pe+ke]=Z[ke];return X!==null&&X.push(Bs,le),le},argPackAdvance:8,readValueFromPointer:Ar,U:function(X){Bs(X)}})},j:function(R,L,V){if(V=st(V),L===2)var X=eT,Z=tT,ye=iT,ke=()=>ne,le=1;else L===4&&(X=rT,Z=sT,ye=nT,ke=()=>Ee,le=2);Fi(R,{name:V,fromWireType:function(Pe){for(var De=Ee[Pe>>2],Ge=ke(),Ye,yt=Pe+4,mt=0;mt<=De;++mt){var Ce=Pe+4+mt*L;(mt==De||Ge[Ce>>le]==0)&&(yt=X(yt,Ce-yt),Ye===void 0?Ye=yt:(Ye+=String.fromCharCode(0),Ye+=yt),yt=Ce+L)}return Bs(Pe),Ye},toWireType:function(Pe,De){typeof De!="string"&&Me("Cannot pass non-string to C++ string type "+V);var Ge=ye(De),Ye=cm(4+Ge+L);return Ee[Ye>>2]=Ge>>le,Z(De,Ye+4,Ge+L),Pe!==null&&Pe.push(Bs,Ye),Ye},argPackAdvance:8,readValueFromPointer:Ar,U:function(Pe){Bs(Pe)}})},l:function(R,L,V,X,Z,ye){oi[R]={name:st(L),ea:Cr(V,X),V:Cr(Z,ye),ha:[]}},i:function(R,L,V,X,Z,ye,ke,le,Pe,De){oi[R].ha.push({na:st(L),sa:V,qa:Cr(X,Z),ra:ye,ya:ke,xa:Cr(le,Pe),za:De})},D:function(R,L){L=st(L),Fi(R,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(R,L,V,X,Z){R=Al[R],L=It(L),V=om(V);var ye=[];return Ee[X>>2]=At(ye),R(L,V,ye,Z)},u:function(R,L,V,X){R=Al[R],L=It(L),V=om(V),R(L,V,null,X)},h:qu,m:function(R,L){var V=lT(R,L),X=V[0];L=X.name+"_$"+V.slice(1).map(function(ke){return ke.name}).join("_")+"$";var Z=am[L];if(Z!==void 0)return Z;var ye=Array(R-1);return Z=aT((ke,le,Pe,De)=>{for(var Ge=0,Ye=0;Ye<R-1;++Ye)ye[Ye]=V[Ye+1].readValueFromPointer(De+Ge),Ge+=V[Ye+1].argPackAdvance;for(ke=ke[le].apply(ke,ye),Ye=0;Ye<R-1;++Ye)V[Ye+1].la&&V[Ye+1].la(ye[Ye]);if(!X.ua)return X.toWireType(Pe,ke)}),am[L]=Z},r:function(R){4<R&&(je[R].fa+=1)},s:function(R){var L=It(R);$i(L),qu(R)},f:function(){Le("")},y:function(R,L,V){U.copyWithin(R,L,L+V)},x:function(R){var L=U.length;if(R>>>=0,2147483648<R)return!1;for(var V=1;4>=V;V*=2){var X=L*(1+.2/V);X=Math.min(X,R+100663296);var Z=Math;X=Math.max(R,X),Z=Z.min.call(Z,2147483648,X+(65536-X%65536)%65536);e:{try{$.grow(Z-O.byteLength+65535>>>16),Oe($.buffer);var ye=1;break e}catch{}ye=void 0}if(ye)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(R,L,V,X){for(var Z=0,ye=0;ye<V;ye++){var ke=Ee[L>>2],le=Ee[L+4>>2];L+=8;for(var Pe=0;Pe<le;Pe++){var De=U[ke+Pe],Ge=cT[R];De===0||De===10?((R===1?m:g)(I(Ge,0)),Ge.length=0):Ge.push(De)}Z+=le}return Ee[X>>2]=Z,0},a:$},Hn=function(){function R(V){a.asm=V.exports,W=a.asm.I,M.unshift(a.asm.E),me--,a.monitorRunDependencies&&a.monitorRunDependencies(me),me==0&&pe&&(V=pe,pe=null,V())}var L={a:hT};if(me++,a.monitorRunDependencies&&a.monitorRunDependencies(me),a.instantiateWasm)try{return a.instantiateWasm(L,R)}catch(V){g("Module.instantiateWasm callback failed with error: "+V),h(V)}return L=pt(L),R(L[0]),a.asm}();a.___wasm_call_ctors=Hn.E;var dT=a.___getTypeName=Hn.F;a.__embind_initialize_bindings=Hn.G;var cm=a._malloc=Hn.H,Bs=a._free=Hn.J;a.dynCall_jiji=Hn.K;var bl;pe=function R(){bl||um(),bl||(pe=R)};function um(){function R(){if(!bl&&(bl=!0,a.calledRun=!0,!N)){if(dt(M),l(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),a.postRun)for(typeof a.postRun=="function"&&(a.postRun=[a.postRun]);a.postRun.length;){var L=a.postRun.shift();G.unshift(L)}dt(G)}}if(!(0<me)){if(a.preRun)for(typeof a.preRun=="function"&&(a.preRun=[a.preRun]);a.preRun.length;)Q();dt(we),0<me||(a.setStatus?(a.setStatus("Running..."),setTimeout(function(){setTimeout(function(){a.setStatus("")},1),R()},1)):R())}}if(a.preInit)for(typeof a.preInit=="function"&&(a.preInit=[a.preInit]);0<a.preInit.length;)a.preInit.pop()();return um(),n}})();r.exports=t})(A0);var X2=A0.exports;(function(r){Object.defineProperty(r,"__esModule",{value:!0});var e={};r.default=void 0;var t=n(tc),i=nt;Object.keys(i).forEach(function(f){f==="default"||f==="__esModule"||Object.prototype.hasOwnProperty.call(e,f)||f in r&&r[f]===i[f]||Object.defineProperty(r,f,{enumerable:!0,get:function(){return i[f]}})});function n(f){return f&&f.__esModule?f:{default:f}}const a=X2;var h=(0,t.default)(a());r.default=h})(xt);const E0=va(xt);var b0=function(){};const Z2=(r,e,t)=>Math.min(Math.max(t,r),e),x0=(r,e,t)=>{const i=e-r;return i===0?1:(t-r)/i},nc=(r,e,t)=>-t*r+t*e+r,T0=(r,e)=>t=>Math.max(Math.min(t,e),r),bo=r=>r%1?Number(r.toFixed(5)):r,wa=/(-)?([\d]*\.?[\d])+/g,oc=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,q2=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function xo(r){return typeof r=="string"}const _a={test:r=>typeof r=="number",parse:parseFloat,transform:r=>r},k0=Object.assign(Object.assign({},_a),{transform:T0(0,1)});Object.assign(Object.assign({},_a),{default:1});const To=(r=>({test:e=>xo(e)&&e.endsWith(r)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${r}`}))("%");Object.assign(Object.assign({},To),{parse:r=>To.parse(r)/100,transform:r=>To.transform(r*100)});const ac=(r,e)=>t=>!!(xo(t)&&q2.test(t)&&t.startsWith(r)||e&&Object.prototype.hasOwnProperty.call(t,e)),S0=(r,e,t)=>i=>{if(!xo(i))return i;const[n,a,l,h]=i.match(wa);return{[r]:parseFloat(n),[e]:parseFloat(a),[t]:parseFloat(l),alpha:h!==void 0?parseFloat(h):1}},ln={test:ac("hsl","hue"),parse:S0("hue","saturation","lightness"),transform:({hue:r,saturation:e,lightness:t,alpha:i=1})=>"hsla("+Math.round(r)+", "+To.transform(bo(e))+", "+To.transform(bo(t))+", "+bo(k0.transform(i))+")"},Q2=T0(0,255),lc=Object.assign(Object.assign({},_a),{transform:r=>Math.round(Q2(r))}),_s={test:ac("rgb","red"),parse:S0("red","green","blue"),transform:({red:r,green:e,blue:t,alpha:i=1})=>"rgba("+lc.transform(r)+", "+lc.transform(e)+", "+lc.transform(t)+", "+bo(k0.transform(i))+")"};function J2(r){let e="",t="",i="",n="";return r.length>5?(e=r.substr(1,2),t=r.substr(3,2),i=r.substr(5,2),n=r.substr(7,2)):(e=r.substr(1,1),t=r.substr(2,1),i=r.substr(3,1),n=r.substr(4,1),e+=e,t+=t,i+=i,n+=n),{red:parseInt(e,16),green:parseInt(t,16),blue:parseInt(i,16),alpha:n?parseInt(n,16)/255:1}}const cc={test:ac("#"),parse:J2,transform:_s.transform},Ra={test:r=>_s.test(r)||cc.test(r)||ln.test(r),parse:r=>_s.test(r)?_s.parse(r):ln.test(r)?ln.parse(r):cc.parse(r),transform:r=>xo(r)?r:r.hasOwnProperty("red")?_s.transform(r):ln.transform(r)},w0="${c}",_0="${n}";function e1(r){var e,t,i,n;return isNaN(r)&&xo(r)&&((t=(e=r.match(wa))===null||e===void 0?void 0:e.length)!==null&&t!==void 0?t:0)+((n=(i=r.match(oc))===null||i===void 0?void 0:i.length)!==null&&n!==void 0?n:0)>0}function R0(r){typeof r=="number"&&(r=`${r}`);const e=[];let t=0;const i=r.match(oc);i&&(t=i.length,r=r.replace(oc,w0),e.push(...i.map(Ra.parse)));const n=r.match(wa);return n&&(r=r.replace(wa,_0),e.push(...n.map(_a.parse))),{values:e,numColors:t,tokenised:r}}function L0(r){return R0(r).values}function C0(r){const{values:e,numColors:t,tokenised:i}=R0(r),n=e.length;return a=>{let l=i;for(let h=0;h<n;h++)l=l.replace(h<t?w0:_0,h<t?Ra.transform(a[h]):bo(a[h]));return l}}const t1=r=>typeof r=="number"?0:r;function i1(r){const e=L0(r);return C0(r)(e.map(t1))}const I0={test:e1,parse:L0,createTransformer:C0,getAnimatableNone:i1};function uc(r,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<.16666666666666666?r+(e-r)*6*t:t<.5?e:t<.6666666666666666?r+(e-r)*(.6666666666666666-t)*6:r}function D0({hue:r,saturation:e,lightness:t,alpha:i}){r/=360,e/=100,t/=100;let n=0,a=0,l=0;if(!e)n=a=l=t;else{const h=t<.5?t*(1+e):t+e-t*e,f=2*t-h;n=uc(f,h,r+.3333333333333333),a=uc(f,h,r),l=uc(f,h,r-.3333333333333333)}return{red:Math.round(n*255),green:Math.round(a*255),blue:Math.round(l*255),alpha:i}}const r1=(r,e,t)=>{const i=r*r,n=e*e;return Math.sqrt(Math.max(0,t*(n-i)+i))},s1=[cc,_s,ln],O0=r=>s1.find(e=>e.test(r)),P0=(r,e)=>{let t=O0(r),i=O0(e),n=t.parse(r),a=i.parse(e);t===ln&&(n=D0(n),t=_s),i===ln&&(a=D0(a),i=_s);const l=Object.assign({},n);return h=>{for(const f in l)f!=="alpha"&&(l[f]=r1(n[f],a[f],h));return l.alpha=nc(n.alpha,a.alpha,h),t.transform(l)}},n1=r=>typeof r=="number",o1=(r,e)=>t=>e(r(t)),$0=(...r)=>r.reduce(o1);function F0(r,e){return n1(r)?t=>nc(r,e,t):Ra.test(r)?P0(r,e):U0(r,e)}const M0=(r,e)=>{const t=[...r],i=t.length,n=r.map((a,l)=>F0(a,e[l]));return a=>{for(let l=0;l<i;l++)t[l]=n[l](a);return t}},a1=(r,e)=>{const t=Object.assign(Object.assign({},r),e),i={};for(const n in t)r[n]!==void 0&&e[n]!==void 0&&(i[n]=F0(r[n],e[n]));return n=>{for(const a in i)t[a]=i[a](n);return t}};function N0(r){const e=I0.parse(r),t=e.length;let i=0,n=0,a=0;for(let l=0;l<t;l++)i||typeof e[l]=="number"?i++:e[l].hue!==void 0?a++:n++;return{parsed:e,numNumbers:i,numRGB:n,numHSL:a}}const U0=(r,e)=>{const t=I0.createTransformer(e),i=N0(r),n=N0(e);return i.numHSL===n.numHSL&&i.numRGB===n.numRGB&&i.numNumbers>=n.numNumbers?$0(M0(i.parsed,n.parsed),t):l=>`${l>0?e:r}`},l1=(r,e)=>t=>nc(r,e,t);function c1(r){if(typeof r=="number")return l1;if(typeof r=="string")return Ra.test(r)?P0:U0;if(Array.isArray(r))return M0;if(typeof r=="object")return a1}function u1(r,e,t){const i=[],n=t||c1(r[0]),a=r.length-1;for(let l=0;l<a;l++){let h=n(r[l],r[l+1]);if(e){const f=Array.isArray(e)?e[l]:e;h=$0(f,h)}i.push(h)}return i}function h1([r,e],[t]){return i=>t(x0(r,e,i))}function d1(r,e){const t=r.length,i=t-1;return n=>{let a=0,l=!1;if(n<=r[0]?l=!0:n>=r[i]&&(a=i-1,l=!0),!l){let f=1;for(;f<t&&!(r[f]>n||f===i);f++);a=f-1}const h=x0(r[a],r[a+1],n);return e[a](h)}}function f1(r,e,{clamp:t=!0,ease:i,mixer:n}={}){const a=r.length;b0(a===e.length),b0(!i||!Array.isArray(i)||i.length===a-1),r[0]>r[a-1]&&(r=[].concat(r),e=[].concat(e),r.reverse(),e.reverse());const l=u1(e,i,n),h=a===2?h1(r,l):d1(r,l);return t?f=>h(Z2(r[0],r[a-1],f)):h}const La=r=>e=>1-r(1-e),hc=r=>e=>e<=.5?r(2*e)/2:(2-r(2*(1-e)))/2,p1=r=>e=>Math.pow(e,r),B0=r=>e=>e*e*((r+1)*e-r),m1=r=>{const e=B0(r);return t=>(t*=2)<1?.5*e(t):.5*(2-Math.pow(2,-10*(t-1)))},G0=1.525,g1=4/11,v1=8/11,y1=9/10,A1=r=>r,dc=p1(2),E1=La(dc),b1=hc(dc),V0=r=>1-Math.sin(Math.acos(r)),H0=La(V0),x1=hc(H0),fc=B0(G0),T1=La(fc),k1=hc(fc),S1=m1(G0),w1=4356/361,_1=35442/1805,R1=16061/1805,Ca=r=>{if(r===1||r===0)return r;const e=r*r;return r<g1?7.5625*e:r<v1?9.075*e-9.9*r+3.4:r<y1?w1*e-_1*r+R1:10.8*r*r-20.52*r+10.72},L1=La(Ca),C1=r=>r<.5?.5*(1-Ca(1-r*2)):.5*Ca(r*2-1)+.5,I1=(r,e,t,i)=>{if(t==="length"||t==="prototype"||t==="arguments"||t==="caller")return;const n=Object.getOwnPropertyDescriptor(r,t),a=Object.getOwnPropertyDescriptor(e,t);!D1(n,a)&&i||Object.defineProperty(r,t,a)},D1=function(r,e){return r===void 0||r.configurable||r.writable===e.writable&&r.enumerable===e.enumerable&&r.configurable===e.configurable&&(r.writable||r.value===e.value)},O1=(r,e)=>{const t=Object.getPrototypeOf(e);t!==Object.getPrototypeOf(r)&&Object.setPrototypeOf(r,t)},P1=(r,e)=>`/* Wrapped ${r}*/
80
+ ${e}`,$1=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),F1=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),M1=(r,e,t)=>{const i=t===""?"":`with ${t.trim()}() `,n=P1.bind(null,i,e.toString());Object.defineProperty(n,"name",F1),Object.defineProperty(r,"toString",{...$1,value:n})};function N1(r,e,{ignoreNonConfigurable:t=!1}={}){const{name:i}=r;for(const n of Reflect.ownKeys(e))I1(r,e,n,t);return O1(r,e),M1(r,e,i),r}const U1=new WeakMap;function Rs(r,{cacheKey:e=([i])=>i,cache:t=new Map}={}){const i=new Map,n=function(...a){const l=e(a);if(i.has(l))return i.get(l);const h=(async()=>{try{if(t&&await t.has(l))return await t.get(l);const p=await r.apply(this,a);try{return p}finally{t&&await t.set(l,p)}}finally{i.delete(l)}})();return i.set(l,h),h};return N1(n,r,{ignoreNonConfigurable:!0}),U1.set(n,t),n}var pc={exports:{}};(function(r,e){(function(t,i){i(e)})(ga,function(t){function i(M){var G,Q,me=new Error(M);return G=me,Q=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(G,Q):G.__proto__=Q,me}function n(M,G,Q){var me=G.slice(0,Q).split(/\n/),pe=me.length,Le=me[pe-1].length+1;throw i(M+=" at line "+pe+" col "+Le+`:
81
+
82
+ `+G.split(/\n/)[pe-1]+`
83
+ `+Array(Le).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var a=new Function("return this")().Promise,l=!1;try{l=new Function("return (async function(){}).constructor")()}catch(M){if(!(M instanceof SyntaxError))throw M}function h(M,G){return Object.prototype.hasOwnProperty.call(M,G)}function f(M,G,Q){for(var me in G)h(G,me)&&(G[me]==null||typeof G[me]!="object"||me!=="storage"&&me!=="prefixes"||Q?M[me]=G[me]:M[me]=f({},G[me]));return M}var p=/^async +/,m=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,g=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,A=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,b=/[.*+\-?^${}()|[\]\\]/g;function x(M){return b.test(M)?M.replace(b,"\\$&"):M}function k(M,G){G.rmWhitespace&&(M=M.replace(/[\r\n]+/g,`
84
+ `).replace(/^\s+|\s+$/gm,"")),m.lastIndex=0,g.lastIndex=0,A.lastIndex=0;var Q=G.prefixes,me=[Q.h,Q.b,Q.i,Q.r,Q.c,Q.e].reduce(function(_t,je){return _t&&je?_t+"|"+x(je):je?x(je):_t},""),pe=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+x(G.tags[1])+")","g"),Le=new RegExp("([^]*?)"+x(G.tags[0])+"(-|_)?\\s*("+me+")?\\s*","g"),Ue=0,Ke=!1;function Ze(_t,je){var qe,Be={f:[]},ot=0,Me="c";function It(Gt){var ir=M.slice(Ue,Gt),Vt=ir.trim();if(Me==="f")Vt==="safe"?Be.raw=!0:G.async&&p.test(Vt)?(Vt=Vt.replace(p,""),Be.f.push([Vt,"",!0])):Be.f.push([Vt,""]);else if(Me==="fp")Be.f[Be.f.length-1][1]+=Vt;else if(Me==="err"){if(Vt){var Pi=ir.search(/\S/);n("invalid syntax",M,Ue+Pi)}}else Be[Me]=Vt;Ue=Gt+1}for(je==="h"||je==="b"||je==="c"?Me="n":je==="r"&&(Be.raw=!0,je="i"),pe.lastIndex=Ue;(qe=pe.exec(M))!==null;){var At=qe[1],Ut=qe[2],hi=qe[3],st=qe[4],Bt=qe[5],at=qe.index;if(At)At==="("?(ot===0&&(Me==="n"?(It(at),Me="p"):Me==="f"&&(It(at),Me="fp")),ot++):At===")"?--ot===0&&Me!=="c"&&(It(at),Me="err"):ot===0&&At==="|"?(It(at),Me="f"):At==="=>"&&(It(at),Ue+=1,Me="res");else if(Ut)if(Ut==="/*"){var $t=M.indexOf("*/",pe.lastIndex);$t===-1&&n("unclosed comment",M,qe.index),pe.lastIndex=$t+2}else Ut==="'"?(g.lastIndex=qe.index,g.exec(M)?pe.lastIndex=g.lastIndex:n("unclosed string",M,qe.index)):Ut==='"'?(A.lastIndex=qe.index,A.exec(M)?pe.lastIndex=A.lastIndex:n("unclosed string",M,qe.index)):Ut==="`"&&(m.lastIndex=qe.index,m.exec(M)?pe.lastIndex=m.lastIndex:n("unclosed string",M,qe.index));else if(hi)return It(at),Ue=at+qe[0].length,Le.lastIndex=Ue,Ke=Bt,st&&je==="h"&&(je="s"),Be.t=je,Be}return n("unclosed tag",M,_t),Be}var pt=function _t(je,qe){je.b=[],je.d=[];var Be,ot=!1,Me=[];function It(Pi,hs){Pi&&(Pi=function(di,Lr,Fs,Ms){var lr,ue;return typeof Lr.autoTrim=="string"?lr=ue=Lr.autoTrim:Array.isArray(Lr.autoTrim)&&(lr=Lr.autoTrim[1],ue=Lr.autoTrim[0]),(Fs||Fs===!1)&&(lr=Fs),(Ms||Ms===!1)&&(ue=Ms),lr==="slurp"&&ue==="slurp"?di.trim():(lr==="_"||lr==="slurp"?di=String.prototype.trimLeft?di.trimLeft():di.replace(/^[\s\uFEFF\xA0]+/,""):lr!=="-"&&lr!=="nl"||(di=di.replace(/^(?:\n|\r|\r\n)/,"")),ue==="_"||ue==="slurp"?di=String.prototype.trimRight?di.trimRight():di.replace(/[\s\uFEFF\xA0]+$/,""):ue!=="-"&&ue!=="nl"||(di=di.replace(/(?:\n|\r|\r\n)$/,"")),di)}(Pi,G,Ke,hs))&&(Pi=Pi.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Me.push(Pi))}for(;(Be=Le.exec(M))!==null;){var At,Ut=Be[1],hi=Be[2],st=Be[3]||"";for(var Bt in Q)if(Q[Bt]===st){At=Bt;break}It(Ut,hi),Ue=Be.index+Be[0].length,At||n("unrecognized tag type: "+st,M,Ue);var at=Ze(Be.index,At),$t=at.t;if($t==="h"){var Gt=at.n||"";G.async&&p.test(Gt)&&(at.a=!0,at.n=Gt.replace(p,"")),at=_t(at),Me.push(at)}else if($t==="c"){if(je.n===at.n)return ot?(ot.d=Me,je.b.push(ot)):je.d=Me,je;n("Helper start and end don't match",M,Be.index+Be[0].length)}else if($t==="b"){ot?(ot.d=Me,je.b.push(ot)):je.d=Me;var ir=at.n||"";G.async&&p.test(ir)&&(at.a=!0,at.n=ir.replace(p,"")),ot=at,Me=[]}else if($t==="s"){var Vt=at.n||"";G.async&&p.test(Vt)&&(at.a=!0,at.n=Vt.replace(p,"")),Me.push(at)}else Me.push(at)}if(!qe)throw i('unclosed helper "'+je.n+'"');return It(M.slice(Ue,M.length),!1),je.d=Me,je}({f:[]},!0);if(G.plugins)for(var dt=0;dt<G.plugins.length;dt++){var Kt=G.plugins[dt];Kt.processAST&&(pt.d=Kt.processAST(pt.d,G))}return pt.d}function w(M,G){var Q=k(M,G),me="var tR='';"+(G.useWith?"with("+G.varName+"||{}){":"")+O(Q,G)+"if(cb){cb(null,tR)} return tR"+(G.useWith?"}":"");if(G.plugins)for(var pe=0;pe<G.plugins.length;pe++){var Le=G.plugins[pe];Le.processFnString&&(me=Le.processFnString(me,G))}return me}function P(M,G){for(var Q=0;Q<G.length;Q++){var me=G[Q][0],pe=G[Q][1];M=(G[Q][2]?"await ":"")+"c.l('F','"+me+"')("+M,pe&&(M+=","+pe),M+=")"}return M}function $(M,G,Q,me,pe,Le){var Ue="{exec:"+(pe?"async ":"")+I(Q,G,M)+",params:["+me+"]";return Le&&(Ue+=",name:'"+Le+"'"),pe&&(Ue+=",async:true"),Ue+="}"}function N(M,G){for(var Q="[",me=0;me<M.length;me++){var pe=M[me];Q+=$(G,pe.res||"",pe.d,pe.p||"",pe.a,pe.n),me<M.length&&(Q+=",")}return Q+="]"}function I(M,G,Q){return"function("+G+"){var tR='';"+O(M,Q)+"return tR}"}function O(M,G){for(var Q=0,me=M.length,pe="";Q<me;Q++){var Le=M[Q];if(typeof Le=="string")pe+="tR+='"+Le+"';";else{var Ue=Le.t,Ke=Le.c||"",Ze=Le.f,pt=Le.n||"",dt=Le.p||"",Kt=Le.res||"",_t=Le.b,je=!!Le.a;if(Ue==="i"){G.defaultFilter&&(Ke="c.l('F','"+G.defaultFilter+"')("+Ke+")");var qe=P(Ke,Ze);!Le.raw&&G.autoEscape&&(qe="c.l('F','e')("+qe+")"),pe+="tR+="+qe+";"}else if(Ue==="h")if(G.storage.nativeHelpers.get(pt))pe+=G.storage.nativeHelpers.get(pt)(Le,G);else{var Be=(je?"await ":"")+"c.l('H','"+pt+"')("+$(G,Kt,Le.d,dt,je);Be+=_t?","+N(_t,G):",[]",pe+="tR+="+P(Be+=",c)",Ze)+";"}else Ue==="s"?pe+="tR+="+P((je?"await ":"")+"c.l('H','"+pt+"')({params:["+dt+"]},[],c)",Ze)+";":Ue==="e"&&(pe+=Ke+`
85
+ `)}}return pe}var K=function(){function M(G){this.cache=G}return M.prototype.define=function(G,Q){this.cache[G]=Q},M.prototype.get=function(G){return this.cache[G]},M.prototype.remove=function(G){delete this.cache[G]},M.prototype.reset=function(){this.cache={}},M.prototype.load=function(G){f(this.cache,G,!0)},M}();function U(M,G,Q,me){if(G&&G.length>0)throw i((me?"Native":"")+"Helper '"+M+"' doesn't accept blocks");if(Q&&Q.length>0)throw i((me?"Native":"")+"Helper '"+M+"' doesn't accept filters")}var re={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ne(M){return re[M]}var Y=new K({}),Ee=new K({each:function(M,G){var Q="",me=M.params[0];if(U("each",G,!1),M.async)return new Promise(function(Le){(function Ue(Ke,Ze,pt,dt,Kt){pt(Ke[Ze],Ze).then(function(_t){dt+=_t,Ze===Ke.length-1?Kt(dt):Ue(Ke,Ze+1,pt,dt,Kt)})})(me,0,M.exec,Q,Le)});for(var pe=0;pe<me.length;pe++)Q+=M.exec(me[pe],pe);return Q},foreach:function(M,G){var Q=M.params[0];if(U("foreach",G,!1),M.async)return new Promise(function(Le){(function Ue(Ke,Ze,pt,dt,Kt,_t){dt(Ze[pt],Ke[Ze[pt]]).then(function(je){Kt+=je,pt===Ze.length-1?_t(Kt):Ue(Ke,Ze,pt+1,dt,Kt,_t)})})(Q,Object.keys(Q),0,M.exec,"",Le)});var me="";for(var pe in Q)h(Q,pe)&&(me+=M.exec(pe,Q[pe]));return me},include:function(M,G,Q){U("include",G,!1);var me=Q.storage.templates.get(M.params[0]);if(!me)throw i('Could not fetch template "'+M.params[0]+'"');return me(M.params[1],Q)},extends:function(M,G,Q){var me=M.params[1]||{};me.content=M.exec();for(var pe=0;pe<G.length;pe++){var Le=G[pe];me[Le.name]=Le.exec()}var Ue=Q.storage.templates.get(M.params[0]);if(!Ue)throw i('Could not fetch template "'+M.params[0]+'"');return Ue(me,Q)},useScope:function(M,G){return U("useScope",G,!1),M.exec(M.params[0])}}),ce=new K({if:function(M,G){U("if",!1,M.f,!0);var Q="if("+M.p+"){"+O(M.d,G)+"}";if(M.b)for(var me=0;me<M.b.length;me++){var pe=M.b[me];pe.n==="else"?Q+="else{"+O(pe.d,G)+"}":pe.n==="elif"&&(Q+="else if("+pe.p+"){"+O(pe.d,G)+"}")}return Q},try:function(M,G){if(U("try",!1,M.f,!0),!M.b||M.b.length!==1||M.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var Q="try{"+O(M.d,G)+"}",me=M.b[0];return Q+="catch"+(me.res?"("+me.res+")":"")+"{"+O(me.d,G)+"}"},block:function(M,G){return U("block",M.b,M.f,!0),"if(!"+G.varName+"["+M.p+"]){tR+=("+I(M.d,"",G)+")()}else{tR+="+G.varName+"["+M.p+"]}"}}),_e=new K({e:function(M){var G=String(M);return/[&<>"']/.test(G)?G.replace(/[&<>"']/g,ne):G}}),Oe={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function(M,G){if(M==="H"){var Q=this.storage.helpers.get(G);if(Q)return Q;throw i("Can't find helper '"+G+"'")}if(M==="F"){var me=this.storage.filters.get(G);if(me)return me;throw i("Can't find filter '"+G+"'")}},async:!1,storage:{helpers:Ee,nativeHelpers:ce,filters:_e,templates:Y},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function B(M,G){var Q={};return f(Q,Oe),G&&f(Q,G),M&&f(Q,M),Q.l.bind(Q),Q}function W(M,G){var Q=B(G||{}),me=Function;if(Q.async){if(!l)throw i("This environment doesn't support async/await");me=l}try{return new me(Q.varName,"c","cb",w(M,Q))}catch(pe){throw pe instanceof SyntaxError?i(`Bad template syntax
86
+
87
+ `+pe.message+`
88
+ `+Array(pe.message.length+1).join("=")+`
89
+ `+w(M,Q)):pe}}function we(M,G){var Q;return G.cache&&G.name&&G.storage.templates.get(G.name)?G.storage.templates.get(G.name):(Q=typeof M=="function"?M:W(M,G),G.cache&&G.name&&G.storage.templates.define(G.name,Q),Q)}Oe.l.bind(Oe),t.compile=W,t.compileScope=O,t.compileScopeIntoFunction=I,t.compileToString=w,t.defaultConfig=Oe,t.filters=_e,t.getConfig=B,t.helpers=Ee,t.nativeHelpers=ce,t.parse=k,t.render=function(M,G,Q,me){var pe=B(Q||{});if(!pe.async)return we(M,pe)(G,pe);if(!me){if(typeof a=="function")return new a(function(Le,Ue){try{Le(we(M,pe)(G,pe))}catch(Ke){Ue(Ke)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{we(M,pe)(G,pe,me)}catch(Le){return me(Le)}},t.templates=Y,Object.defineProperty(t,"__esModule",{value:!0})})})(pc,pc.exports);var Ia=pc.exports,mc={exports:{}};(function(r,e){var t=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof ga<"u"&&ga,i=function(){function a(){this.fetch=!1,this.DOMException=t.DOMException}return a.prototype=t,new a}();(function(a){(function(l){var h=typeof a<"u"&&a||typeof self<"u"&&self||typeof h<"u"&&h,f={searchParams:"URLSearchParams"in h,iterable:"Symbol"in h&&"iterator"in Symbol,blob:"FileReader"in h&&"Blob"in h&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in h,arrayBuffer:"ArrayBuffer"in h};function p(B){return B&&DataView.prototype.isPrototypeOf(B)}if(f.arrayBuffer)var m=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(B){return B&&m.indexOf(Object.prototype.toString.call(B))>-1};function A(B){if(typeof B!="string"&&(B=String(B)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(B)||B==="")throw new TypeError('Invalid character in header field name: "'+B+'"');return B.toLowerCase()}function b(B){return typeof B!="string"&&(B=String(B)),B}function x(B){var W={next:function(){var we=B.shift();return{done:we===void 0,value:we}}};return f.iterable&&(W[Symbol.iterator]=function(){return W}),W}function k(B){this.map={},B instanceof k?B.forEach(function(W,we){this.append(we,W)},this):Array.isArray(B)?B.forEach(function(W){this.append(W[0],W[1])},this):B&&Object.getOwnPropertyNames(B).forEach(function(W){this.append(W,B[W])},this)}k.prototype.append=function(B,W){B=A(B),W=b(W);var we=this.map[B];this.map[B]=we?we+", "+W:W},k.prototype.delete=function(B){delete this.map[A(B)]},k.prototype.get=function(B){return B=A(B),this.has(B)?this.map[B]:null},k.prototype.has=function(B){return this.map.hasOwnProperty(A(B))},k.prototype.set=function(B,W){this.map[A(B)]=b(W)},k.prototype.forEach=function(B,W){for(var we in this.map)this.map.hasOwnProperty(we)&&B.call(W,this.map[we],we,this)},k.prototype.keys=function(){var B=[];return this.forEach(function(W,we){B.push(we)}),x(B)},k.prototype.values=function(){var B=[];return this.forEach(function(W){B.push(W)}),x(B)},k.prototype.entries=function(){var B=[];return this.forEach(function(W,we){B.push([we,W])}),x(B)},f.iterable&&(k.prototype[Symbol.iterator]=k.prototype.entries);function w(B){if(B.bodyUsed)return Promise.reject(new TypeError("Already read"));B.bodyUsed=!0}function P(B){return new Promise(function(W,we){B.onload=function(){W(B.result)},B.onerror=function(){we(B.error)}})}function $(B){var W=new FileReader,we=P(W);return W.readAsArrayBuffer(B),we}function N(B){var W=new FileReader,we=P(W);return W.readAsText(B),we}function I(B){for(var W=new Uint8Array(B),we=new Array(W.length),M=0;M<W.length;M++)we[M]=String.fromCharCode(W[M]);return we.join("")}function O(B){if(B.slice)return B.slice(0);var W=new Uint8Array(B.byteLength);return W.set(new Uint8Array(B)),W.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(B){this.bodyUsed=this.bodyUsed,this._bodyInit=B,B?typeof B=="string"?this._bodyText=B:f.blob&&Blob.prototype.isPrototypeOf(B)?this._bodyBlob=B:f.formData&&FormData.prototype.isPrototypeOf(B)?this._bodyFormData=B:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(B)?this._bodyText=B.toString():f.arrayBuffer&&f.blob&&p(B)?(this._bodyArrayBuffer=O(B.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(B)||g(B))?this._bodyArrayBuffer=O(B):this._bodyText=B=Object.prototype.toString.call(B):this._bodyText="",this.headers.get("content-type")||(typeof B=="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(B)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var B=w(this);if(B)return B;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 B=w(this);return B||(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($)}),this.text=function(){var B=w(this);if(B)return B;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(I(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(Y)}),this.json=function(){return this.text().then(JSON.parse)},this}var U=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function re(B){var W=B.toUpperCase();return U.indexOf(W)>-1?W:B}function ne(B,W){if(!(this instanceof ne))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');W=W||{};var we=W.body;if(B instanceof ne){if(B.bodyUsed)throw new TypeError("Already read");this.url=B.url,this.credentials=B.credentials,W.headers||(this.headers=new k(B.headers)),this.method=B.method,this.mode=B.mode,this.signal=B.signal,!we&&B._bodyInit!=null&&(we=B._bodyInit,B.bodyUsed=!0)}else this.url=String(B);if(this.credentials=W.credentials||this.credentials||"same-origin",(W.headers||!this.headers)&&(this.headers=new k(W.headers)),this.method=re(W.method||this.method||"GET"),this.mode=W.mode||this.mode||null,this.signal=W.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&we)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(we),(this.method==="GET"||this.method==="HEAD")&&(W.cache==="no-store"||W.cache==="no-cache")){var M=/([?&])_=[^&]*/;if(M.test(this.url))this.url=this.url.replace(M,"$1_="+new Date().getTime());else{var G=/\?/;this.url+=(G.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}ne.prototype.clone=function(){return new ne(this,{body:this._bodyInit})};function Y(B){var W=new FormData;return B.trim().split("&").forEach(function(we){if(we){var M=we.split("="),G=M.shift().replace(/\+/g," "),Q=M.join("=").replace(/\+/g," ");W.append(decodeURIComponent(G),decodeURIComponent(Q))}}),W}function Ee(B){var W=new k,we=B.replace(/\r?\n[\t ]+/g," ");return we.split("\r").map(function(M){return M.indexOf(`
90
+ `)===0?M.substr(1,M.length):M}).forEach(function(M){var G=M.split(":"),Q=G.shift().trim();if(Q){var me=G.join(":").trim();W.append(Q,me)}}),W}K.call(ne.prototype);function ce(B,W){if(!(this instanceof ce))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');W||(W={}),this.type="default",this.status=W.status===void 0?200:W.status,this.ok=this.status>=200&&this.status<300,this.statusText=W.statusText===void 0?"":""+W.statusText,this.headers=new k(W.headers),this.url=W.url||"",this._initBody(B)}K.call(ce.prototype),ce.prototype.clone=function(){return new ce(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new k(this.headers),url:this.url})},ce.error=function(){var B=new ce(null,{status:0,statusText:""});return B.type="error",B};var _e=[301,302,303,307,308];ce.redirect=function(B,W){if(_e.indexOf(W)===-1)throw new RangeError("Invalid status code");return new ce(null,{status:W,headers:{location:B}})},l.DOMException=h.DOMException;try{new l.DOMException}catch{l.DOMException=function(W,we){this.message=W,this.name=we;var M=Error(W);this.stack=M.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function Oe(B,W){return new Promise(function(we,M){var G=new ne(B,W);if(G.signal&&G.signal.aborted)return M(new l.DOMException("Aborted","AbortError"));var Q=new XMLHttpRequest;function me(){Q.abort()}Q.onload=function(){var Le={status:Q.status,statusText:Q.statusText,headers:Ee(Q.getAllResponseHeaders()||"")};Le.url="responseURL"in Q?Q.responseURL:Le.headers.get("X-Request-URL");var Ue="response"in Q?Q.response:Q.responseText;setTimeout(function(){we(new ce(Ue,Le))},0)},Q.onerror=function(){setTimeout(function(){M(new TypeError("Network request failed"))},0)},Q.ontimeout=function(){setTimeout(function(){M(new TypeError("Network request failed"))},0)},Q.onabort=function(){setTimeout(function(){M(new l.DOMException("Aborted","AbortError"))},0)};function pe(Le){try{return Le===""&&h.location.href?h.location.href:Le}catch{return Le}}Q.open(G.method,pe(G.url),!0),G.credentials==="include"?Q.withCredentials=!0:G.credentials==="omit"&&(Q.withCredentials=!1),"responseType"in Q&&(f.blob?Q.responseType="blob":f.arrayBuffer&&G.headers.get("Content-Type")&&G.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(Q.responseType="arraybuffer")),W&&typeof W.headers=="object"&&!(W.headers instanceof k)?Object.getOwnPropertyNames(W.headers).forEach(function(Le){Q.setRequestHeader(Le,b(W.headers[Le]))}):G.headers.forEach(function(Le,Ue){Q.setRequestHeader(Ue,Le)}),G.signal&&(G.signal.addEventListener("abort",me),Q.onreadystatechange=function(){Q.readyState===4&&G.signal.removeEventListener("abort",me)}),Q.send(typeof G._bodyInit>"u"?null:G._bodyInit)})}return Oe.polyfill=!0,h.fetch||(h.fetch=Oe,h.Headers=k,h.Request=ne,h.Response=ce),l.Headers=k,l.Request=ne,l.Response=ce,l.fetch=Oe,l})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var n=t.fetch?t:i;e=n.fetch,e.default=n.fetch,e.fetch=n.fetch,e.Headers=n.Headers,e.Request=n.Request,e.Response=n.Response,r.exports=e})(mc,mc.exports);var B1=mc.exports;const G1=va(B1);function gc({canvas:r,scenes:e,currentTime:t}){if(e&&r){const i=e.scenes.filter(({start:a,duration:l})=>t>=a&&t<=a+l);if(i.length<=0)return;const n=r.getContext("2d");if(n){const a=e.transitionDuration,l=Math.max(...e.scenes.map(({start:h,duration:f})=>h+f));n.globalCompositeOperation="lighter",n.clearRect(0,0,r.width,r.height),i.forEach(({start:h,duration:f,draw:p,transitionCanvas:m})=>{if(n.globalAlpha=1,m.width=m.height=0,m.width=r.width,m.height=r.height,m.getContext("2d")){const A=h+f,b=h===0,x=A===l;p({currentTime:t,canvas:m}),!b&&t>=h&&t<=h+a?n.globalAlpha=Math.max(0,Math.min(1,(t-h)/a)):!x&&t>=A-a&&t<=A&&(n.globalAlpha=Math.max(0,Math.min(1,(A-t)/a))),n.drawImage(m,0,0,r.width,r.height)}})}}}function V1(r){if(typeof r=="string"){const[e,t]=r.split(":");return Math.min(parseFloat(e),parseFloat(t))}return r}function H1(r){if(typeof r=="string"){const[e,t]=r.split(":"),i=parseFloat(e),n=parseFloat(t);return i/n}return r}function vc({resolution:r,aspectRatio:e}){const t=V1(r),i=H1(e),n=i>=1,a=Math.min(n?t*i:t/i,t),l=Math.max(n?t*i:t/i,t);return{resolution:t,aspectRatio:i,height:n?a:l,width:n?l:a}}function W1({format:r,resolution:e,aspectRatio:t,sourceWidth:i,sourceHeight:n}){const{width:a,height:l}=vc({resolution:e,aspectRatio:t}),h=i/n,f=t>h;let p=1;if(r==="letterbox"||r==="letterbox-video")p=f?l/n:a/i;else if(r==="squarebox"){const x=Math.min(l,a);p=i>=n?x/n:x/i}else r==="crop"&&(p=f?a/i:l/n);const m=a/p,g=l/p,A=(i-m)/2,b=(n-g)/2;return{sx:A,sy:b,sWidth:m,sHeight:g,scale:p}}function ko({source:r,sx:e,sy:t,sw:i,sh:n,dx:a,dy:l,dw:h,dh:f}){const p=(r==null?void 0:r.naturalWidth)??(r==null?void 0:r.videoWidth)??(r==null?void 0:r.width),m=(r==null?void 0:r.naturalHeight)??(r==null?void 0:r.videoHeight)??(r==null?void 0:r.height);e=e??0,t=t??0,i=i??p,n=n??m,i<0&&(e+=i,i=Math.abs(i)),n<0&&(t+=n,n=Math.abs(n)),h<0&&(a+=h,h=Math.abs(h)),f<0&&(l+=f,f=Math.abs(f));const g=Math.max(e,0),A=Math.min(e+i,p),b=Math.max(t,0),x=Math.min(t+n,m),k=h/i,w=f/n;return[r,g,b,A-g,x-b,e<0?a-e*k:a,t<0?l-t*w:l,(A-g)*k,(x-b)*w]}function W0({context:r,source:e,crop:t,format:i="letterbox",posX:n,posY:a,drawAreaWidth:l,drawAreaHeight:h,sourceWidth:f,sourceHeight:p,cropCanvas:m,letterboxCanvas:g}){const{x:A,y:b,width:x,height:k}=t??{},w=f*(A??0),P=p*(b??0),$=f*Math.min(1-(A??0),x??1),N=p*Math.min(1-(b??0),k??1),I=m.getContext("2d");if(I){m.width=$,m.height=N;const W=ko({source:e,sx:w,sy:P,sw:$,sh:N,dx:0,dy:0,dw:$,dh:N});I.drawImage(...W)}const O=$/N,{sx:K,sy:U,sWidth:re,sHeight:ne,scale:Y}=W1({resolution:Math.min(l,h),aspectRatio:l/h,format:i,sourceWidth:$,sourceHeight:N}),Ee=m&&typeof r.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!Ee){if(K<0){const W=Math.abs(K)*Y;r.fillStyle="black",r.beginPath(),r.rect(n,a,W,h),r.rect(n+l-W,a,W,h),r.fill(),r.closePath()}if(U<0){const W=Math.abs(U)*Y;r.fillStyle="black",r.beginPath(),r.rect(n,a,l,W),r.rect(n,a+h-W,l,W),r.fill(),r.closePath()}}if(i==="letterbox-video"&&Ee){const W=g.getContext("2d");if(W){g.width=$,g.height=N,r.save(),r.globalCompositeOperation="destination-out",r.fillRect(n,a,l,h);const we=ko({source:m,sx:K,sy:U,sw:re,sh:ne,dx:n,dy:a,dw:l,dh:h});r.globalCompositeOperation="source-over",r.drawImage(...we),W.save();const M=1.2,G=-($*M-$)/2,Q=-(N*M-N)/2,me=Math.min($/20,N/20);if(W.filter=`blur(${me}px) brightness(20%)`,W.translate(G,Q),W.scale(M,M),W.drawImage(m,0,0,$,N),W.restore(),r.globalCompositeOperation="destination-over",K<0){const pe=l/O,Le=h/pe,Ue=ko({source:g,sy:(1-Le)*N/2,sh:Le*N,dx:n,dy:a,dw:l,dh:h});r.drawImage(...Ue)}if(U<0){const pe=h*O,Le=l/pe,Ue=ko({source:g,sx:(1-Le)*$/2,sw:Le*$,dx:n,dy:a,dw:l,dh:h});r.drawImage(...Ue)}r.restore()}}else{const W=ko({source:m,sx:K,sy:U,sw:re,sh:ne,dx:n,dy:a,dw:l,dh:h});r.drawImage(...W)}const ce=K*-1*Y,_e=U*-1*Y,Oe=l-ce*2,B=h-_e*2;return{dx:ce,dy:_e,dw:Oe,dh:B}}function j0({context:r,word:e,maxW:t=1/0}){const i=[],n=r.measureText(e);if(n.width<t)return[{text:e,metrics:n}];for(let a=0;a<e.length;a++){const l=i[i.length-1],h=((l==null?void 0:l.text)??"")+e[a],f=r.measureText(h);f.width<t?i[l?i.length-1:0]={text:h,metrics:f}:i.push({text:e[a],metrics:r.measureText(e[a])})}return i}const K0=ec(({font:r,scale:e,context:t,maxW:i,maxH:n,text:a,minSize:l,maxSize:h})=>{var f,p;let m=0;if(h){m=(l??0)*e;let A=0;for(;h*e>m+1;){m+=1;const b=$a({context:t,font:r,fontSize:m,text:a,maxW:i});if(A=b.reduce((x,k)=>(k.metrics.width>x&&(x=k.metrics.width),x),0),A>i||b.length*m>n){m-=1;break}}}else m=parseFloat(((p=(f=r.match(Pa))==null?void 0:f.groups)==null?void 0:p.value)??"0")*e;return m},{cacheKey:([{font:r,text:e,minSize:t,maxSize:i,scale:n,maxW:a,maxH:l}])=>`${r}_${e}_${t}_${i}_${n}_${a}_${l}`});function j1(r,e){return typeof r=="number"?{top:r*e,right:r*e,bottom:r*e,left:r*e}:{top:typeof r.top=="number"?r.top*e:r.top,right:typeof r.right=="number"?r.right*e:r.right,bottom:typeof r.bottom=="number"?r.bottom*e:r.bottom,left:typeof r.left=="number"?r.left*e:r.left}}function z0(r,e){return typeof r=="number"?{top:r*e,right:r*e,bottom:r*e,left:r*e}:{top:(typeof r.top=="number"?r.top*e:r.top)??0,right:(typeof r.right=="number"?r.right*e:r.right)??0,bottom:(typeof r.bottom=="number"?r.bottom*e:r.bottom)??0,left:(typeof r.left=="number"?r.left*e:r.left)??0}}function Y0(r,{layout:e,scale:t=1}){const{position:i="static",inset:n,width:a,height:l,minWidth:h,minHeight:f,maxWidth:p,maxHeight:m,flex:g,gap:A,margin:b,padding:x,direction:k="column",align:w="start",alignSelf:P,justify:$="start"}=e,N={static:xt.PositionType.Static,relative:xt.PositionType.Relative,absolute:xt.PositionType.Absolute};if(r.setPositionType(N[i]),n){const{top:U,right:re,bottom:ne,left:Y}=j1(n,t);U&&r.setPosition(xt.Edge.Top,U),re&&r.setPosition(xt.Edge.Right,re),ne&&r.setPosition(xt.Edge.Bottom,ne),Y&&r.setPosition(xt.Edge.Left,Y)}const I={row:xt.FlexDirection.Row,column:xt.FlexDirection.Column,"row-reverse":xt.FlexDirection.RowReverse,"column-reverse":xt.FlexDirection.ColumnReverse};r.setFlexDirection(I[k]);const O={start:xt.Align.FlexStart,end:xt.Align.FlexEnd,center:xt.Align.Center,stretch:xt.Align.Stretch};r.setAlignItems(O[w]),P&&r.setAlignSelf(O[P]);const K={start:xt.Justify.FlexStart,end:xt.Justify.FlexEnd,center:xt.Justify.Center,"space-between":xt.Justify.SpaceBetween,"space-around":xt.Justify.SpaceAround,"space-evenly":xt.Justify.SpaceEvenly};if(r.setJustifyContent(K[$]),b){const{top:U,right:re,bottom:ne,left:Y}=z0(b,t);r.setMargin(xt.Edge.Top,U),r.setMargin(xt.Edge.Right,re),r.setMargin(xt.Edge.Bottom,ne),r.setMargin(xt.Edge.Left,Y)}if(x){const{top:U,right:re,bottom:ne,left:Y}=z0(x,t);r.setPadding(xt.Edge.Top,U),r.setPadding(xt.Edge.Right,re),r.setPadding(xt.Edge.Bottom,ne),r.setPadding(xt.Edge.Left,Y)}g&&r.setFlex(g),r.setGap(xt.Gutter.All,(A??0)*t),a&&r.setWidth(typeof a=="number"?a*t:a),l&&(typeof l=="function"?r.setHeight("100%"):r.setHeight(typeof l=="number"?l*t:l)),h&&r.setMinWidth(typeof h=="number"?h*t:h),f&&r.setMinHeight(typeof f=="number"?f*t:f),p&&r.setMaxWidth(typeof p=="number"?p*t:p),m&&r.setMaxHeight(typeof m=="number"?m*t:m)}function X0({canvas:r,debug:e=!1,scale:t=1,position:i=[]}){i.forEach(({x:n,y:a,width:l,height:h,childNodes:f,element:p})=>{const m=r.getContext("2d",{alpha:!1});if(m){const{draw:g}=p;g&&(m.save(),g({scale:t,dx:n,dy:a,dw:l,dh:h}),e&&(m.strokeStyle="red",m.strokeRect(n,a,l,h))),X0({canvas:r,debug:e,scale:t,position:f}),m.restore()}})}function Z0(r,e,t){const i=e.map((n,a)=>{const l=E0.Node.create(),{radius:h,elements:f=[],draw:p,...m}=n;return Y0(l,{layout:m,scale:t}),r.insertChild(l,a),{node:l,element:n,childNodes:Z0(l,f,t)}});return r.calculateLayout(),i}function q0(r,e,t=0,i=0){const{top:n,left:a}=r.getComputedLayout();return e.map(({node:l,element:h,childNodes:f})=>{const{top:p,left:m,width:g,height:A}=l.getComputedLayout(),b=t+m,x=i+p;return{x:a+b,y:n+x,width:g,height:A,element:h,childNodes:q0(r,f,b,x)}})}function Q0(r,e){r.forEach(({node:t,element:i,childNodes:n})=>{const{height:a}=i;if(a&&typeof a=="function"){const l=t.getComputedWidth(),h=t.getComputedHeight(),f=a({width:l,maxHeight:h,scale:e});t.setHeight(f)}Q0(n,e)})}function K1({canvas:r,origin:e,elements:t,...i}){const n={inset:{top:0,left:0},width:r.width,height:r.height,...e},a=E0.Node.create();Y0(a,{layout:n}),a.calculateLayout();const{width:l,height:h}=a.getComputedLayout(),f=Math.min(l,h)/1080,p=Z0(a,t,f);Q0(p,f),a.calculateLayout();const m=q0(a,p);return X0({...i,scale:f,canvas:r,position:m})}const z1={linear:A1,easeIn:dc,easeInOut:b1,easeOut:E1,circIn:V0,circInOut:x1,circOut:H0,backIn:fc,backInOut:k1,backOut:T1,anticipate:S1,bounceIn:L1,bounceInOut:C1,bounceOut:Ca},Da=ec((r,e,{clamp:t=!0,ease:i="easeIn",...n}={})=>f1(r,e,{...n,clamp:t,ease:z1[i]}),{cacheKey:([r,e,t])=>JSON.stringify({from:r,to:e,options:t})}),J0=[{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 Oa({text:r,font:e}){let t=e;return J0.forEach(({family:i,regex:n})=>{n.exec(r)&&(t+=`, ${i}`)}),t}const ss=1.8,Pa=/(?<value>\d+\.?\d*)(?=px)/;function Y1(r,e=1){return typeof r=="number"?{topLeft:r*e,topRight:r*e,bottomRight:r*e,bottomLeft:r*e}:{topLeft:((r==null?void 0:r.topLeft)??0)*e,topRight:((r==null?void 0:r.topRight)??0)*e,bottomRight:((r==null?void 0:r.bottomRight)??0)*e,bottomLeft:((r==null?void 0:r.bottomLeft)??0)*e}}function ed(r){const{visible:e,node:t}=r,i=[...(t==null?void 0:t.elements)??[],...(r==null?void 0:r.elements)??[]];return e??(t&&t.type!=="box"&&t.type!=="gradient"?!!t.value:i==null?void 0:i.some(n=>ed(n)))}function td({debug:r=!1,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a=[],currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g}){return a.map(A=>{var b,x,k,w,P,$,N,I;const{node:O,transient:K=[{from:0,duration:1/0}]}=A,U=e.getContext("2d"),re={total:l,content:h,scene:f},ne={total:p,content:m,scene:g},Y=K.reduce((Ee,{type:ce="scene",from:_e,duration:Oe,animation:B})=>{const W=_e<0?ne[ce]+_e:_e;return re[ce]>=W&&re[ce]<=W+Oe&&Ee.push({type:ce,animation:B,duration:Oe,from:W}),Ee},[]);if(U&&Y.length>0&&ed(A)){let Ee=A.width,ce=A.height;if((O==null?void 0:O.type)==="text"&&O.value){const{align:_e="left"}=O,Oe=Oa({text:O.value,font:O.font});U.save(),U.font=Oe,U.textBaseline="top",U.textAlign=_e,O.wrap?ce=({width:B,maxHeight:W,scale:we})=>{var M,G;const Q=K0({font:Oe,scale:we,context:U,maxW:B,maxH:W,text:O.value??"",minSize:(M=O.fill)==null?void 0:M.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});return $a({context:U,font:Oe,fontSize:Q,text:O.value??"",maxW:B}).length*Q}:(Ee=U.measureText(O.value).width,ce=parseFloat(((x=(b=Oe.match(Pa))==null?void 0:b.groups)==null?void 0:x.value)??"0")),U.restore()}if((O==null?void 0:O.type)==="image"&&O.image&&O.size){const _e=((k=O.image)==null?void 0:k.naturalWidth)??((w=O.image)==null?void 0:w.width),Oe=((P=O.image)==null?void 0:P.naturalHeight)??(($=O.image)==null?void 0:$.height),B=_e/Oe,W=(N=O.size)==null?void 0:N.width,we=(I=O.size)==null?void 0:I.height;Ee=W??(B>=1?(we??0)*B:(we??0)/B),ce=we??(B<1?(W??0)*B:(W??0)/B)}return{...A,width:Ee,height:ce,elements:td({debug:r,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:A.elements,currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g}),draw:({dx:_e,dy:Oe,dw:B,dh:W,scale:we})=>{var M,G,Q,me,pe,Le,Ue,Ke,Ze,pt,dt,Kt,_t;if(Y.forEach(je=>{const{type:qe="scene",from:Be,duration:ot,animation:Me={type:"fade",duration:.3333333333333333,easing:{in:"easeOut",out:"easeOut"}}}=je;if(Me){const{type:It,duration:At,easing:{in:Ut="easeOut",out:hi="easeOut"}={}}=Me;if(Be>0&&re[qe]<=Be+At)switch(It){case"fade":{const st=Da([Be,Be+At],[0,1],{ease:Ut});U.globalAlpha=st(re[qe]);break}case"slide":{const{options:st}=Me,Bt={up:[{x:0,y:W},{x:0,y:0}],right:[{x:B,y:0},{x:0,y:0}],down:[{x:0,y:-W},{x:0,y:0}],left:[{x:-B,y:0},{x:0,y:0}]},at=Da([Be,Be+At],Bt[st.direction.in],{ease:Ut}),{x:$t,y:Gt}=at(re[qe]);U.translate($t,Gt);break}}if(Be+ot<ne[qe]&&Be+ot-At<=re[qe])switch(It){case"fade":{const st=Da([Be+ot-At,Be+ot],[1,0],{ease:hi});U.globalAlpha=st(re[qe]);break}case"slide":{const{options:st}=Me,Bt={up:[{x:0,y:0},{x:0,y:-W}],right:[{x:0,y:0},{x:B,y:0}],down:[{x:0,y:0},{x:0,y:W}],left:[{x:0,y:0},{x:-B,y:0}]},at=Da([Be+ot-At,Be+ot],Bt[st.direction.out],{ease:hi}),{x:$t,y:Gt}=at(re[qe]);U.translate($t,Gt);break}}}}),O){const{type:je}=O;if(A.radius){const{topLeft:qe,topRight:Be,bottomRight:ot,bottomLeft:Me}=Y1(A.radius,we);U.beginPath(),U.moveTo(_e+Math.min(W/ss,qe),Oe),U.lineTo(_e+B-Math.min(W/ss,Be),Oe),U.quadraticCurveTo(_e+B,Oe,_e+B,Oe+Math.min(W/ss,Be)),U.lineTo(_e+B,Oe+W-Math.min(W/ss,ot)),U.quadraticCurveTo(_e+B,Oe+W,_e+B-Math.min(W/ss,ot),Oe+W),U.lineTo(_e+Math.min(W/ss,Me),Oe+W),U.quadraticCurveTo(_e,Oe+W,_e,Oe+W-Math.min(W/ss,Me)),U.lineTo(_e,Oe+Math.min(W/ss,qe)),U.quadraticCurveTo(_e,Oe,_e+Math.min(W/ss,qe),Oe),U.closePath(),r&&(U.strokeStyle="blue",U.stroke()),U.clip()}if(je==="box"&&(U.fillStyle=O.background,U.fillRect(_e,Oe,B,W)),je==="text"&&O.value){const{align:qe="left"}=O,Be=Oa({text:O.value,font:O.font}),ot=K0({font:Be,scale:we,context:U,maxW:B,maxH:W,text:O.value??"",minSize:(M=O.fill)==null?void 0:M.minSize,maxSize:(G=O.fill)==null?void 0:G.maxSize});U.font=Be.replace(Pa,ot.toString()),U.textBaseline="top",U.fillStyle=O.color,U.textAlign=qe;const Me={left:_e,center:_e+B/2,right:_e+B};O.wrap?$a({context:U,font:Be,fontSize:ot,text:O.value,maxW:B}).forEach((At,Ut)=>{U.fillText(At.text,Me[qe],Oe+ot*Ut)}):U.fillText(O.value,Me[qe],Oe)}if(je==="image"&&O.image&&U.drawImage(O.image,_e,Oe,B,W),je==="video"&&((Q=O.video)!=null&&Q.node||(me=O.video)!=null&&me.getSource)){const qe=O.format??"letterbox",Be=((Le=(pe=O.video)==null?void 0:pe.getSource)==null?void 0:Le.call(pe,f))??O.video.node,ot=(Be==null?void 0:Be.videoWidth)??(Be==null?void 0:Be.naturalWidth)??(Be==null?void 0:Be.width),Me=(Be==null?void 0:Be.videoHeight)??(Be==null?void 0:Be.naturalHeight)??(Be==null?void 0:Be.height);if(ot&&Me){const{dx:At,dy:Ut,dw:hi,dh:st}=W0({context:U,cropCanvas:t,letterboxCanvas:n,source:Be,format:qe,crop:(Ue=O==null?void 0:O.value)==null?void 0:Ue.crop,sourceWidth:ot,sourceHeight:Me,posX:_e,posY:Oe,drawAreaWidth:B,drawAreaHeight:W});O.elements&&yc({debug:r,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g,origin:{inset:{top:Math.max(Oe,Oe+Ut),left:Math.max(_e,_e+At)},width:Math.min(B,hi),height:Math.min(W,st)}})}const It=1/3;if(O.poster&&l>=0&&l<=It){U.save(),U.globalAlpha=1-l/It;const At=((Ke=O.poster)==null?void 0:Ke.naturalWidth)??((Ze=O.poster)==null?void 0:Ze.width),Ut=((pt=O.poster)==null?void 0:pt.naturalHeight)??((dt=O.poster)==null?void 0:dt.height);i.width=i.height=0,i.width=B,i.height=W;const hi=i.getContext("2d");if(hi&&At&&Ut){const{dx:st,dy:Bt,dw:at,dh:$t}=W0({context:hi,cropCanvas:t,letterboxCanvas:n,source:O.poster,format:qe,crop:(Kt=O==null?void 0:O.value)==null?void 0:Kt.crop,sourceWidth:At,sourceHeight:Ut,posX:0,posY:0,drawAreaWidth:B,drawAreaHeight:W});O.elements&&yc({debug:r,canvas:i,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:O.elements,currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g,origin:{inset:{top:Math.max(0,Bt),left:Math.max(0,st)},width:Math.min(B,at),height:Math.min(W,$t)}}),U.drawImage(i,_e,Oe,B,W),U.restore()}}}if(je==="gradient"&&O.value){const qe=U.createLinearGradient(_e+B,Oe,_e+B,Oe+W);(_t=O.value)==null||_t.forEach(Be=>{qe.addColorStop(Be.percent,Be.color)}),U.fillStyle=qe,U.fillRect(_e,Oe,B,W)}}}}}}).filter(Boolean)}function yc({debug:r,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a,currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g,...A}){return K1({...A,debug:r,canvas:e,elements:td({debug:r,canvas:e,cropCanvas:t,posterCanvas:i,letterboxCanvas:n,elements:a,currentTime:l,contentTime:h,sceneTime:f,totalDuration:p,contentDuration:m,sceneDuration:g})})}const $a=ec(({context:r,font:e,fontSize:t,text:i,maxW:n=1/0})=>{try{return r.save(),r.font=e.replace(Pa,t.toString()),i.split(`
91
+ `).flatMap(l=>{const h=l.split(" ").filter(Boolean);return h.length?h.slice(1).reduce((f,p)=>{const g=`${f[f.length-1].text} ${p}`.trim(),A=r.measureText(g);return A.width>n?f=[...f,...j0({context:r,word:p,maxW:n})]:f[f.length-1]={text:g,metrics:A},f},j0({context:r,word:h[0],maxW:n})):{text:"",metrics:r.measureText("")}})}finally{r.restore()}},{cacheKey:([{font:r,fontSize:e,text:t,maxW:i}])=>`${r}_${e}_${t}_${i}`}),X1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,Z1=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function id(r){if(!r)return[];const e=r.match(X1);return e?e==null?void 0:e.map(t=>{const[i,n]=t.replace(`\r
92
+ `,`
93
+ `).split(`
94
+ `),[a,l]=i.match(Z1)||[];return{start:a,end:l,text:n}}):[]}function Fa(r){const[e,t,i]=r.split(":");return i?parseInt(e)*60*60+parseInt(t)*60+parseFloat(i):parseInt(e)*60+parseInt(t)}function q1({canvas:r,dx:e,dy:t,dw:i,dh:n,sceneTime:a,vttCaptions:l}){if(l){const f=id(l).find(({start:p,end:m})=>p&&m&&a>=Fa(p)&&a<Fa(m));if(f){const p=r.getContext("2d");if(p){const m=Math.min(i,n),g=m*.04,A=Oa({text:l,font:`400 ${g}px Roobert Captions`});p.font=A,p.textBaseline="middle";const b=i*.9,x=$a({context:p,font:A,fontSize:g,text:f.text,maxW:b});x.forEach(({text:k,metrics:w},P)=>{const $=e+(i-w.width)/2,N=t+(n*.85-(g+m*.03)*(x.length-1-P)),I=g*.8,O=g/1.5,K=e+(i-w.width-O)/2,U=N-I,re=w.width+O,ne=I*2,Y=p.globalAlpha;p.save(),p.globalAlpha=.8*Y,p.fillStyle="#000000",p.beginPath(),p.roundRect(K,U,re,ne,m*.01),p.fill(),p.closePath(),p.globalAlpha=Y,p.fillStyle="#FFFFFF",p.fillText(k,$,N),p.restore()})}}}}const Q1={id:"073977ec-6384-4329-b7c5-8275fb513e74",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",templates:[{id:"046f363c-960a-449c-ae5e-984ac6ab58c2",version:"2",name:"None",entityId:"none",templateId:"a95e537e-fb4d-4d2f-9c72-86c0925c7176",layouts:[{name:"none",tree:`[
95
+ {
96
+ "width": "100%",
97
+ "height": "100%",
98
+ "node": {
99
+ "type": "video",
100
+ "format": {{ it.videoFormat }},
101
+ "value": {
102
+ "id": {{ it.id }},
103
+ "key": {{ it.key }},
104
+ "src": {{@async resolve-source({ sources: [it.mp4, it.input] }) /}},
105
+ "playlist": {{@async resolve-source({ sources: [it.playlist] }) /}},
106
+ "poster": {{ it.poster }},
107
+ "captions": {{ it.captions }},
108
+ "duration": {{ it.duration }},
109
+ "startOffset": {{ it.startOffset }},
110
+ "endOffset": {{ it.endOffset }},
111
+ "crop": {
112
+ "x": {{ it.crop?.x }},
113
+ "y": {{ it.crop?.y }},
114
+ "width": {{ it.crop?.width }},
115
+ "height": {{ it.crop?.height }}
116
+ }
117
+ }
118
+ }
119
+ }
120
+ ]`}],content:[{scenes:[{layout:"none",data:`{
121
+ "id": {{ it.root?.answer?.id }},
122
+ "key": {{ it.root?.answer?.id + '-intro' }},
123
+ "mp4": {{ it.root?.answer?.media?.video }},
124
+ "input": {{ it.root?.answer?.media?.input }},
125
+ "playlist": {{ it.root?.answer?.media?.playlist }},
126
+ "poster": {{ it.root?.answer?.media?.thumbnail }},
127
+ "captions": {{ it.root?.answer?.captions?.current }},
128
+ "duration": {{ it.root?.answer?.metadata?.duration }},
129
+ "startOffset": {{ it.root?.answer?.settings?.startOffset }},
130
+ "endOffset": {{ it.root?.answer?.settings?.endOffset }},
131
+ "crop": {
132
+ "x": {{ it.root?.answer?.settings?.crop?.x }},
133
+ "y": {{ it.root?.answer?.settings?.crop?.y }},
134
+ "width": {{ it.root?.answer?.settings?.crop?.width }},
135
+ "height": {{ it.root?.answer?.settings?.crop?.height }}
136
+ }
137
+ }`}],root:"{{ it.intro?.questions?.items }}"},{scenes:[{layout:"none",data:`{
138
+ "id": {{ it.root?.answer?.id }},
139
+ "key": {{ it.root?.answer?.id + '-' + it.index }},
140
+ "mp4": {{ it.root?.answer?.media?.video }},
141
+ "input": {{ it.root?.answer?.media?.input }},
142
+ "playlist": {{ it.root?.answer?.media?.playlist }},
143
+ "poster": {{ it.root?.answer?.media?.thumbnail }},
144
+ "captions": {{ it.root?.answer?.captions?.current }},
145
+ "duration": {{ it.root?.answer?.metadata?.duration }},
146
+ "startOffset": {{ it.root?.answer?.settings?.startOffset }},
147
+ "endOffset": {{ it.root?.answer?.settings?.endOffset }},
148
+ "crop": {
149
+ "x": {{ it.root?.answer?.settings?.crop?.x }},
150
+ "y": {{ it.root?.answer?.settings?.crop?.y }},
151
+ "width": {{ it.root?.answer?.settings?.crop?.width }},
152
+ "height": {{ it.root?.answer?.settings?.crop?.height }}
153
+ }
154
+ }`}],root:"{{ it.questions?.items }}"},{scenes:[{layout:"none",data:`{
155
+ "id": {{ it.root?.answer?.id }},
156
+ "key": {{ it.root?.answer?.id + '-outro' }},
157
+ "mp4": {{ it.root?.answer?.media?.video }},
158
+ "input": {{ it.root?.answer?.media?.input }},
159
+ "playlist": {{ it.root?.answer?.media?.playlist }},
160
+ "poster": {{ it.root?.answer?.media?.thumbnail }},
161
+ "captions": {{ it.root?.answer?.captions?.current }},
162
+ "duration": {{ it.root?.answer?.metadata?.duration }},
163
+ "startOffset": {{ it.root?.answer?.settings?.startOffset }},
164
+ "endOffset": {{ it.root?.answer?.settings?.endOffset }},
165
+ "crop": {
166
+ "x": {{ it.root?.answer?.settings?.crop?.x }},
167
+ "y": {{ it.root?.answer?.settings?.crop?.y }},
168
+ "width": {{ it.root?.answer?.settings?.crop?.width }},
169
+ "height": {{ it.root?.answer?.settings?.crop?.height }}
170
+ }
171
+ }`}],root:"{{ it.outro?.questions?.items }}"}],system:!0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}],meta:{frameRate:30,resolution:720,transitionDuration:1/3},system:!0,default:0,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};async function J1(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>rm);return new r.Image}return new Image}const rd=Rs(async function(e){return e?new Promise((t,i)=>{J1().then(n=>{n.onload=()=>{t(n)},n.onerror=a=>{i(a)},n.src=e})}):null});async function Ac({element:r,meta:e},t,i){var n,a,l;let h={...r};const{node:f}=r;if((f==null?void 0:f.type)==="video"&&((n=f==null?void 0:f.value)!=null&&n.src||(a=f==null?void 0:f.value)!=null&&a.playlist)){const p=await t(f.value,e);let m;try{m=await rd(f.value.poster)}catch{m=null}h={...h,node:{...f,video:p,poster:m,meta:await i(f.value,p.node,e)}}}if((f==null?void 0:f.type)==="image"&&f.value){let p;try{p=await rd(f.value)}catch{p=null}h={...h,node:{...f,image:p}}}return h.node&&((l=r.node)!=null&&l.elements)&&(h.node.elements=await Promise.all(r.node.elements.map(p=>Ac({element:p,meta:e},t,i)))),r.elements&&(h.elements=await Promise.all(r.elements.map(p=>Ac({element:p,meta:e},t,i)))),h}async function Ma(){if(typeof window>"u"){const r=await Promise.resolve().then(()=>rm),e=new r.Canvas;return e.gpu=!1,e}return document.createElement("canvas")}async function ev(r){var e;try{if((e=await G1(r,{method:"HEAD"}))!=null&&e.ok)return r}catch{return}}async function tv({sources:r}){let e=null;if(r){const t=r.filter(Boolean).map(i=>ev(i));e=(await Promise.all(t)).find(Boolean)}return e}function So(r=[]){var e;for(const t of r){if(((e=t==null?void 0:t.node)==null?void 0:e.type)==="video")return t.node;const i=So(t==null?void 0:t.elements);if(i)return i}}function iv(r,e){return r.reduce((t,i,n)=>[...t,i.map(({duration:a},l)=>n===r.length-1&&l===i.length-1?a:a-e)],[])}function rv(r){if(r===null||typeof r!="object")return!1;if(Object.getPrototypeOf(r)===null)return!0;let e=r;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(r)===e}function sv(r){return r.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\f/g,"\\f").replace(/"/g,'\\"')}function Na(r){return r.flatMap(e=>e).reduce((e,t)=>e+t,0)}Ia.filters.define("parse",r=>typeof r>"u"?null:typeof r=="string"?`"${sv(r)}"`:rv(r)||Array.isArray(r)?JSON.stringify(r):r),Ia.helpers.define("resolve-source",Rs(async r=>{const{sources:e}=r.params[0]??{},t=e==null?void 0:e.filter(Boolean),i=t==null?void 0:t.find(l=>l.includes("blob:")),n=t==null?void 0:t.find(l=>!l.includes("http")),a=i??n??await tv({sources:e});return a?`"${a}"`:"null"},{cacheKey:([r])=>JSON.stringify(r.params[0]??{})}));const wo=(r,e,t)=>Ia.render(r,e,Ia.getConfig({autoEscape:!1,defaultFilter:"parse",async:!0,asyncHelpers:["resolve-source"],...t}));async function _n({data:r,template:e,burnCaptions:t=!1,debug:i=!1},n,a){var l,h,f,p;const m=e??Q1;if(!((l=m.templates)!=null&&l.length))throw new Error(`No templates found for template instance: ${m.id}`);let g=m.templates.find(({version:K})=>K===Ec);if(!g){const K=m.templates.map(({version:U})=>`"${U}"`).join(", ");console.warn(`Template renderer expects template version "${Ec}" but got ${K}`),g=m.templates[m.templates.length-1]}const A=await Promise.all(g.content.map(async({scenes:K,root:U})=>{const re={...m.options,...r,intro:m.intro,outro:m.outro};async function ne(Y,Ee){return Promise.all(K.map(async({layout:ce,duration:_e,data:Oe,options:B})=>{var W,we,M;const G={...re,index:Ee,root:Y},Q=Oe?JSON.parse(await wo(Oe,G)):{},me=B?JSON.parse(await wo(B,G)):{},pe=_e?parseFloat(await wo(_e,G)):NaN,Le=(W=g.layouts.find(dt=>dt.name===ce))==null?void 0:W.tree;if(!Le)throw new Error(`Layout tree "${ce}" not found in template "${g.id}" layouts.`);const Ue=JSON.parse(await wo(Le,{...Q,...me})),Ke=await Promise.all(Ue.flatMap(dt=>Ac({element:dt,meta:m.meta},n,a))),Ze=So(Ke);return{duration:(isNaN(pe)?null:pe)??((we=Ze==null?void 0:Ze.meta)==null?void 0:we.duration)??0,captions:(M=Ze==null?void 0:Ze.meta)==null?void 0:M.captions,elements:Ke}}))}if(U){const Y=JSON.parse(await wo(U,re));return Array.isArray(Y)?(await Promise.all(Y.map(async(Ee,ce)=>ne(Ee,ce)))).flatMap(Ee=>Ee):ne(Y,null)}return ne(r,null)}));if(A.every(K=>K.every(U=>{const re=So(U.elements);return!(re!=null&&re.value.src)&&!(re!=null&&re.value.playlist)}))){const K=A.flatMap(U=>U.map(re=>{const ne=So(re.elements);return!(ne!=null&&ne.value.src)&&!(ne!=null&&ne.value.playlist)&&(ne==null?void 0:ne.value.id)}).filter(Boolean)).join(", ");throw new Error(`Video(s) with ID ${K} failed to load, video can not be processed`)}if(A.every(K=>K.every(U=>U.duration<=0)))throw new Error("No scenes have any duration, video can not be processed");const k=A.reduce((K,U)=>{const re=U.filter(ne=>ne.duration>0);return re.length>0&&(K=[...K,re]),K},[]),w=((h=m.meta)==null?void 0:h.frameRate)??30,P=((f=m.meta)==null?void 0:f.resolution)??720,$=((p=m.meta)==null?void 0:p.transitionDuration)??1/3,N=iv(k,$),I=Na(N);return{scenes:(await Promise.all(k.map((K,U)=>{const re=Na(N[U]),ne=Na(N.slice(0,U));return Promise.all(K.map(async({duration:Y,captions:Ee,elements:ce},_e)=>{var Oe,B;const W=await Ma(),we=await Ma(),M=await Ma(),G=await Ma(),Q=So(ce),me=Na([...N.slice(0,U),...N[U].slice(0,_e)]);return{draw:({canvas:Le,currentTime:Ue})=>{const Ke=Math.max(0,Ue-ne),Ze=Math.max(0,Ue-me);yc({debug:i,canvas:Le,cropCanvas:W,posterCanvas:G,letterboxCanvas:we,elements:ce,currentTime:Ue,contentTime:Ke,sceneTime:Ze,totalDuration:I,contentDuration:re,sceneDuration:Y}),Ee&&t&&q1({canvas:Le,dx:0,dy:0,dw:Le.width,dh:Le.height,vttCaptions:Ee,sceneTime:Ze+((Q==null?void 0:Q.meta.start)??0)})},duration:Y,transitionCanvas:M,start:me,video:Q==null?void 0:Q.video,videoMeta:Q==null?void 0:Q.meta,audio:{duration:Y,src:(Oe=Q==null?void 0:Q.value)==null?void 0:Oe.src,start:(B=Q==null?void 0:Q.meta)==null?void 0:B.start}}}))}))).flatMap(K=>K),frameRate:w,resolution:P,transitionDuration:$,fonts:g.fonts??[],duration:I}}const Ec="2",nv={name:"@vouchfor/embeds",version:"0.0.0-experiment.90dc1dd",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:"experiment",access:"public"},scripts:{build:"rm -rf dist && tsc && yarn build:self","build:deps":"yarn --cwd ../media-player build","build:self":"vite build --mode iife && vite build --mode es && node scripts/build.cjs","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:{"@a11y/focus-trap":"^1.0.5","@lit/task":"^1.0.0","@vouchfor/media-player":"0.0.0-experiment.90dc1dd",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",glob:"^10.3.10","lint-staged":"^14.0.1",lit:"^3.1.0",lodash:"^4.17.21",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0","rollup-plugin-internal":"^1.0.4",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 ov(r){const{publicApiUrl:e}=ma(r),t=ks();return navigator.sendBeacon(`${e}/api/visitor`,JSON.stringify({visitorId:t})),t}function av(r){var a,l,h,f,p,m,g,A,b,x,k,w;if(typeof window>"u")return{client:null,tab:null,request:ks()};let e=(l=(a=window.localStorage)==null?void 0:a.getItem)==null?void 0:l.call(a,"vouch-uid-visitor"),t=(f=(h=window.localStorage)==null?void 0:h.getItem)==null?void 0:f.call(h,"vouch-uid-client"),i=(m=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:m.call(p,"vouch-uid-tab");const n=ks();return e||(e=ov(r),(A=(g=window.localStorage)==null?void 0:g.setItem)==null||A.call(g,"vouch-uid-visitor",e)),t||(t=ks(),(x=(b=window.localStorage)==null?void 0:b.setItem)==null||x.call(b,"vouch-uid-client",t)),i||(i=ks(),(w=(k=window.sessionStorage)==null?void 0:k.setItem)==null||w.call(k,"vouch-uid-tab",i)),{client:t,tab:i,request:n,visitor:e}}function lv(r,e){return r&&"vouchId"in r?r.vouchId:(e==null?void 0:e.id)??null}function cv(r="embedded_player"){var n,a;const[e,t]=((a=(n=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:n.split)==null?void 0:a.call(n,"/"))??[],i={};return[...new URLSearchParams(location.search).entries()].forEach(([l,h])=>{if(/utm/.test(l)){const f=l.toLowerCase().replace(/[-_][a-z0-9]/g,p=>p.slice(-1).toUpperCase());i[f]=h}}),{source:r,time:new Date,region:t,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:nv.version,templateVersion:Ec,...i}}const sd=1;class uv{constructor(e){this._batchedEvents=[],this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createTrackingEvent=(t,i)=>{const n=lv(i,this.host.vouch);!n||this.host.disableTracking||this._batchedEvents.push({event:t,payload:{...i,vouchId:n,time:new Date().toISOString()}})},this._sendTrackingEvent=()=>{if(this._batchedEvents.length<=0)return;const{publicApiUrl:t}=ma(this.host.env),{client:i,tab:n,request:a,visitor:l}=av(this.host.env);navigator.sendBeacon(`${t}/api/batchevents`,JSON.stringify({payload:{events:this._batchedEvents},context:{"x-uid-client":i,"x-uid-tab":n,"x-uid-request":a,"x-uid-visitor":l,"x-reporting-metadata":cv(this.host.trackingSource)}})),this._batchedEvents=[]},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:t,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+sd&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:t})=>{t&&(this._hasLoaded[t]||(this._createTrackingEvent("VOUCH_LOADED",{vouchId:t}),this._hasLoaded[t]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._createTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:t,key:i}})=>{this._answersViewed[i]||(this._createTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:t}),this._answersViewed[i]=!0)},this._handleVideoTimeUpdate=({detail:{id:t,key:i,node:n}})=>{var a,l;!this.host.paused&&t===((l=(a=this.host.scene)==null?void 0:a.video)==null?void 0:l.id)&&(this._currentlyPlayingVideo={id:t,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:t,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+sd&&this._createTrackingEvent("VIDEO_STREAMED",{answerId:t,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=e,e.addController(this)}hostConnected(){requestAnimationFrame(()=>{var e,t,i,n;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.addEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.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 e,t,i,n;this._pageUnloading(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(e=this.host.mediaPlayer)==null||e.removeEventListener("play",this._handlePlay),(t=this.host.mediaPlayer)==null||t.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
+ * @license
173
+ * Copyright 2018 Google LLC
174
+ * SPDX-License-Identifier: BSD-3-Clause
175
+ */const Mt=wn(class extends po{constructor(r){var e;if(super(r),r.type!==Sn.ATTRIBUTE||r.name!=="class"||((e=r.strings)==null?void 0:e.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(r){return" "+Object.keys(r).filter(e=>r[e]).join(" ")+" "}update(r,[e]){var i,n;if(this.it===void 0){this.it=new Set,r.strings!==void 0&&(this.st=new Set(r.strings.join(" ").split(/\s/).filter(a=>a!=="")));for(const a in e)e[a]&&!((i=this.st)!=null&&i.has(a))&&this.it.add(a);return this.render(e)}const t=r.element.classList;for(const a of this.it)a in e||(t.remove(a),this.it.delete(a));for(const a in e){const l=!!e[a];l===this.it.has(a)||(n=this.st)!=null&&n.has(a)||(l?(t.add(a),this.it.add(a)):(t.remove(a),this.it.delete(a)))}return Es}});/**
176
+ * @license
177
+ * Copyright 2018 Google LLC
178
+ * SPDX-License-Identifier: BSD-3-Clause
179
+ */const nd="important",hv=" !"+nd,_o=wn(class extends po{constructor(r){var e;if(super(r),r.type!==Sn.ATTRIBUTE||r.name!=="style"||((e=r.strings)==null?void 0:e.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(r){return Object.keys(r).reduce((e,t)=>{const i=r[t];return i==null?e:e+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(r,[e]){const{style:t}=r.element;if(this.ut===void 0)return this.ut=new Set(Object.keys(e)),this.render(e);for(const i of this.ut)e[i]==null&&(this.ut.delete(i),i.includes("-")?t.removeProperty(i):t[i]=null);for(const i in e){const n=e[i];if(n!=null){this.ut.add(i);const a=typeof n=="string"&&n.endsWith(hv);i.includes("-")||a?t.setProperty(i,a?n.slice(0,-11):n,a?nd:""):t[i]=n}}return Es}});function dv(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var od={exports:{}};(function(r,e){(function(t){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,n=/^(?=([^\/?#]*))\1([^]*)$/,a=/(?:\/|^)\.(?=\/)/g,l=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,h={buildAbsoluteURL:function(f,p,m){if(m=m||{},f=f.trim(),p=p.trim(),!p){if(!m.alwaysNormalize)return f;var g=h.parseURL(f);if(!g)throw new Error("Error trying to parse base URL.");return g.path=h.normalizePath(g.path),h.buildURLFromParts(g)}var A=h.parseURL(p);if(!A)throw new Error("Error trying to parse relative URL.");if(A.scheme)return m.alwaysNormalize?(A.path=h.normalizePath(A.path),h.buildURLFromParts(A)):p;var b=h.parseURL(f);if(!b)throw new Error("Error trying to parse base URL.");if(!b.netLoc&&b.path&&b.path[0]!=="/"){var x=n.exec(b.path);b.netLoc=x[1],b.path=x[2]}b.netLoc&&!b.path&&(b.path="/");var k={scheme:b.scheme,netLoc:A.netLoc,path:null,params:A.params,query:A.query,fragment:A.fragment};if(!A.netLoc&&(k.netLoc=b.netLoc,A.path[0]!=="/"))if(!A.path)k.path=b.path,A.params||(k.params=b.params,A.query||(k.query=b.query));else{var w=b.path,P=w.substring(0,w.lastIndexOf("/")+1)+A.path;k.path=h.normalizePath(P)}return k.path===null&&(k.path=m.alwaysNormalize?h.normalizePath(A.path):A.path),h.buildURLFromParts(k)},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(a,"");f.length!==(f=f.replace(l,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};r.exports=h})()})(od);var bc=od.exports;function ad(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,i)}return t}function Yi(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ad(Object(t),!0).forEach(function(i){fv(r,i,t[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ad(Object(t)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(t,i))})}return r}function fv(r,e,t){return e=mv(e),e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ci(){return ci=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},ci.apply(this,arguments)}function pv(r,e){if(typeof r!="object"||r===null)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var i=t.call(r,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function mv(r){var e=pv(r,"string");return typeof e=="symbol"?e:String(e)}const ze=Number.isFinite||function(r){return typeof r=="number"&&isFinite(r)};let _=function(r){return r.MEDIA_ATTACHING="hlsMediaAttaching",r.MEDIA_ATTACHED="hlsMediaAttached",r.MEDIA_DETACHING="hlsMediaDetaching",r.MEDIA_DETACHED="hlsMediaDetached",r.BUFFER_RESET="hlsBufferReset",r.BUFFER_CODECS="hlsBufferCodecs",r.BUFFER_CREATED="hlsBufferCreated",r.BUFFER_APPENDING="hlsBufferAppending",r.BUFFER_APPENDED="hlsBufferAppended",r.BUFFER_EOS="hlsBufferEos",r.BUFFER_FLUSHING="hlsBufferFlushing",r.BUFFER_FLUSHED="hlsBufferFlushed",r.MANIFEST_LOADING="hlsManifestLoading",r.MANIFEST_LOADED="hlsManifestLoaded",r.MANIFEST_PARSED="hlsManifestParsed",r.LEVEL_SWITCHING="hlsLevelSwitching",r.LEVEL_SWITCHED="hlsLevelSwitched",r.LEVEL_LOADING="hlsLevelLoading",r.LEVEL_LOADED="hlsLevelLoaded",r.LEVEL_UPDATED="hlsLevelUpdated",r.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",r.LEVELS_UPDATED="hlsLevelsUpdated",r.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",r.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",r.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",r.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",r.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",r.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",r.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",r.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",r.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",r.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",r.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",r.CUES_PARSED="hlsCuesParsed",r.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",r.INIT_PTS_FOUND="hlsInitPtsFound",r.FRAG_LOADING="hlsFragLoading",r.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",r.FRAG_LOADED="hlsFragLoaded",r.FRAG_DECRYPTED="hlsFragDecrypted",r.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",r.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",r.FRAG_PARSING_METADATA="hlsFragParsingMetadata",r.FRAG_PARSED="hlsFragParsed",r.FRAG_BUFFERED="hlsFragBuffered",r.FRAG_CHANGED="hlsFragChanged",r.FPS_DROP="hlsFpsDrop",r.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",r.ERROR="hlsError",r.DESTROYING="hlsDestroying",r.KEY_LOADING="hlsKeyLoading",r.KEY_LOADED="hlsKeyLoaded",r.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",r.BACK_BUFFER_REACHED="hlsBackBufferReached",r}({}),tt=function(r){return r.NETWORK_ERROR="networkError",r.MEDIA_ERROR="mediaError",r.KEY_SYSTEM_ERROR="keySystemError",r.MUX_ERROR="muxError",r.OTHER_ERROR="otherError",r}({}),fe=function(r){return r.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",r.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",r.KEY_SYSTEM_NO_SESSION="keySystemNoSession",r.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",r.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",r.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",r.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",r.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",r.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",r.MANIFEST_LOAD_ERROR="manifestLoadError",r.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",r.MANIFEST_PARSING_ERROR="manifestParsingError",r.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",r.LEVEL_EMPTY_ERROR="levelEmptyError",r.LEVEL_LOAD_ERROR="levelLoadError",r.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",r.LEVEL_PARSING_ERROR="levelParsingError",r.LEVEL_SWITCH_ERROR="levelSwitchError",r.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",r.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",r.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",r.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",r.FRAG_LOAD_ERROR="fragLoadError",r.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",r.FRAG_DECRYPT_ERROR="fragDecryptError",r.FRAG_PARSING_ERROR="fragParsingError",r.FRAG_GAP="fragGap",r.REMUX_ALLOC_ERROR="remuxAllocError",r.KEY_LOAD_ERROR="keyLoadError",r.KEY_LOAD_TIMEOUT="keyLoadTimeOut",r.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",r.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",r.BUFFER_APPEND_ERROR="bufferAppendError",r.BUFFER_APPENDING_ERROR="bufferAppendingError",r.BUFFER_STALLED_ERROR="bufferStalledError",r.BUFFER_FULL_ERROR="bufferFullError",r.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",r.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",r.INTERNAL_EXCEPTION="internalException",r.INTERNAL_ABORTED="aborted",r.UNKNOWN="unknown",r}({});const cn=function(){},xc={trace:cn,debug:cn,log:cn,warn:cn,info:cn,error:cn};let Ro=xc;function gv(r){const e=self.console[r];return e?e.bind(self.console,`[${r}] >`):cn}function vv(r,...e){e.forEach(function(t){Ro[t]=r[t]?r[t].bind(r):gv(t)})}function yv(r,e){if(self.console&&r===!0||typeof r=="object"){vv(r,"debug","log","info","warn","error");try{Ro.log(`Debug logs enabled for "${e}" in hls.js version 1.4.12`)}catch{Ro=xc}}else Ro=xc}const q=Ro,Av=/^(\d+)x(\d+)$/,ld=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Jt{constructor(e){typeof e=="string"&&(e=Jt.parseAttrList(e));for(const t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const i=new Uint8Array(t.length/2);for(let n=0;n<t.length/2;n++)i[n]=parseInt(t.slice(n*2,n*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const i=this[e];return i?parseFloat(i):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Av.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const i={},n='"';for(ld.lastIndex=0;(t=ld.exec(e))!==null;){let a=t[2];a.indexOf(n)===0&&a.lastIndexOf(n)===a.length-1&&(a=a.slice(1,-1));const l=t[1].trim();i[l]=a}return i}}function Ev(r){return r!=="ID"&&r!=="CLASS"&&r!=="START-DATE"&&r!=="DURATION"&&r!=="END-DATE"&&r!=="END-ON-NEXT"}function bv(r){return r==="SCTE35-OUT"||r==="SCTE35-IN"}class cd{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const i=t.attr;for(const n in i)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==i[n]){q.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=ci(new Jt({}),i,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);ze(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 e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(ze(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&ze(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Ua{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 Ct={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class ud{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Ct.AUDIO]:null,[Ct.VIDEO]:null,[Ct.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const i=e.split("@",2),n=[];i.length===1?n[0]=t?t.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=bc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Tc extends ud{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Ua,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=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.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||!ze(this.programDateTime))return null;const e=ze(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),i=t.length;if(i>1||i===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,i,n,a,l=!1){const{elementaryStreams:h}=this,f=h[e];if(!f){h[e]={startPTS:t,endPTS:i,startDTS:n,endDTS:a,partial:l};return}f.startPTS=Math.min(f.startPTS,t),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,n),f.endDTS=Math.max(f.endDTS,a)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Ct.AUDIO]=null,e[Ct.VIDEO]=null,e[Ct.AUDIOVIDEO]=null}}class xv extends ud{constructor(e,t,i,n,a){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 Ua,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=n;const l=e.enumeratedString("BYTERANGE");l&&this.setByteRange(l,a),a&&(this.fragOffset=a.fragOffset+a.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const Tv=10;class kv{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,i=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!i||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?ze(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||Tv}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function kc(r){return Uint8Array.from(atob(r),e=>e.charCodeAt(0))}function Sv(r){const e=hd(r).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function wv(r){const e=function(i,n,a){const l=i[n];i[n]=i[a],i[a]=l};e(r,0,3),e(r,1,2),e(r,4,5),e(r,6,7)}function _v(r){const e=r.split(":");let t=null;if(e[0]==="data"&&e.length===2){const i=e[1].split(";"),n=i[i.length-1].split(",");if(n.length===2){const a=n[0]==="base64",l=n[1];a?(i.splice(-1,1),t=kc(l)):t=Sv(l)}}return t}function hd(r){return Uint8Array.from(unescape(encodeURIComponent(r)),e=>e.charCodeAt(0))}var ei={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Xi={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function dd(r){switch(r){case Xi.FAIRPLAY:return ei.FAIRPLAY;case Xi.PLAYREADY:return ei.PLAYREADY;case Xi.WIDEVINE:return ei.WIDEVINE;case Xi.CLEARKEY:return ei.CLEARKEY}}var fd={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function Rv(r){if(r===fd.WIDEVINE)return ei.WIDEVINE}function pd(r){switch(r){case ei.FAIRPLAY:return Xi.FAIRPLAY;case ei.PLAYREADY:return Xi.PLAYREADY;case ei.WIDEVINE:return Xi.WIDEVINE;case ei.CLEARKEY:return Xi.CLEARKEY}}function Sc(r){const{drmSystems:e,widevineLicenseUrl:t}=r,i=e?[ei.FAIRPLAY,ei.WIDEVINE,ei.PLAYREADY,ei.CLEARKEY].filter(n=>!!e[n]):[];return!i[ei.WIDEVINE]&&t&&i.push(ei.WIDEVINE),i}const md=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Lv(r,e,t,i){let n;switch(r){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: ${r}`)}return Cv(n,e,t,i)}function Cv(r,e,t,i){return[{initDataTypes:r,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(a=>({contentType:`audio/mp4; codecs="${a}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:t.map(a=>({contentType:`video/mp4; codecs="${a}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function un(r,e,t){return Uint8Array.prototype.slice?r.slice(e,t):new Uint8Array(Array.prototype.slice.call(r,e,t))}const wc=(r,e)=>e+10<=r.length&&r[e]===73&&r[e+1]===68&&r[e+2]===51&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,gd=(r,e)=>e+10<=r.length&&r[e]===51&&r[e+1]===68&&r[e+2]===73&&r[e+3]<255&&r[e+4]<255&&r[e+6]<128&&r[e+7]<128&&r[e+8]<128&&r[e+9]<128,Ba=(r,e)=>{const t=e;let i=0;for(;wc(r,e);){i+=10;const n=Ga(r,e+6);i+=n,gd(r,e+10)&&(i+=10),e+=i}if(i>0)return r.subarray(t,t+i)},Ga=(r,e)=>{let t=0;return t=(r[e]&127)<<21,t|=(r[e+1]&127)<<14,t|=(r[e+2]&127)<<7,t|=r[e+3]&127,t},Iv=(r,e)=>wc(r,e)&&Ga(r,e+6)+10<=r.length-e,Dv=r=>{const e=yd(r);for(let t=0;t<e.length;t++){const i=e[t];if(vd(i))return Nv(i)}},vd=r=>r&&r.key==="PRIV"&&r.info==="com.apple.streaming.transportStreamTimestamp",Ov=r=>{const e=String.fromCharCode(r[0],r[1],r[2],r[3]),t=Ga(r,4),i=10;return{type:e,size:t,data:r.subarray(i,i+t)}},yd=r=>{let e=0;const t=[];for(;wc(r,e);){const i=Ga(r,e+6);e+=10;const n=e+i;for(;e+8<n;){const a=Ov(r.subarray(e)),l=Pv(a);l&&t.push(l),e+=a.size+10}gd(r,e)&&(e+=10)}return t},Pv=r=>r.type==="PRIV"?$v(r):r.type[0]==="W"?Mv(r):Fv(r),$v=r=>{if(r.size<2)return;const e=Fr(r.data,!0),t=new Uint8Array(r.data.subarray(e.length+1));return{key:r.type,info:e,data:t.buffer}},Fv=r=>{if(r.size<2)return;if(r.type==="TXXX"){let t=1;const i=Fr(r.data.subarray(t),!0);t+=i.length+1;const n=Fr(r.data.subarray(t));return{key:r.type,info:i,data:n}}const e=Fr(r.data.subarray(1));return{key:r.type,data:e}},Mv=r=>{if(r.type==="WXXX"){if(r.size<2)return;let t=1;const i=Fr(r.data.subarray(t),!0);t+=i.length+1;const n=Fr(r.data.subarray(t));return{key:r.type,info:i,data:n}}const e=Fr(r.data);return{key:r.type,data:e}},Nv=r=>{if(r.data.byteLength===8){const e=new Uint8Array(r.data),t=e[3]&1;let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,t&&(i+=4772185884e-2),Math.round(i)}},Fr=(r,e=!1)=>{const t=Uv();if(t){const p=t.decode(r);if(e){const m=p.indexOf("\0");return m!==-1?p.substring(0,m):p}return p.replace(/\0/g,"")}const i=r.length;let n,a,l,h="",f=0;for(;f<i;){if(n=r[f++],n===0&&e)return h;if(n===0||n===3)continue;switch(n>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:h+=String.fromCharCode(n);break;case 12:case 13:a=r[f++],h+=String.fromCharCode((n&31)<<6|a&63);break;case 14:a=r[f++],l=r[f++],h+=String.fromCharCode((n&15)<<12|(a&63)<<6|(l&63)<<0);break}}return h};let _c;function Uv(){return!_c&&typeof self.TextDecoder<"u"&&(_c=new self.TextDecoder("utf-8")),_c}const Mr={hexDump:function(r){let e="";for(let t=0;t<r.length;t++){let i=r[t].toString(16);i.length<2&&(i="0"+i),e+=i}return e}},Va=Math.pow(2,32)-1,Bv=[].push,Ad={video:1,audio:2,id3:3,text:4};function wi(r){return String.fromCharCode.apply(null,r)}function Ed(r,e){const t=r[e]<<8|r[e+1];return t<0?65536+t:t}function rt(r,e){const t=bd(r,e);return t<0?4294967296+t:t}function bd(r,e){return r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}function Rc(r,e,t){r[e]=t>>24,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=t&255}function bt(r,e){const t=[];if(!e.length)return t;const i=r.byteLength;for(let n=0;n<i;){const a=rt(r,n),l=wi(r.subarray(n+4,n+8)),h=a>1?n+a:i;if(l===e[0])if(e.length===1)t.push(r.subarray(n+8,h));else{const f=bt(r.subarray(n+8,h),e.slice(1));f.length&&Bv.apply(t,f)}n=h}return t}function Gv(r){const e=[],t=r[0];let i=8;const n=rt(r,i);i+=4;const a=0,l=0;t===0?i+=8:i+=16,i+=2;let h=r.length+l;const f=Ed(r,i);i+=2;for(let p=0;p<f;p++){let m=i;const g=rt(r,m);m+=4;const A=g&2147483647;if((g&2147483648)>>>31===1)return q.warn("SIDX has hierarchical references (not supported)"),null;const x=rt(r,m);m+=4,e.push({referenceSize:A,subsegmentDuration:x,info:{duration:x/n,start:h,end:h+A-1}}),h+=A,m+=4,i=m}return{earliestPresentationTime:a,timescale:n,version:t,referencesCount:f,references:e}}function xd(r){const e=[],t=bt(r,["moov","trak"]);for(let n=0;n<t.length;n++){const a=t[n],l=bt(a,["tkhd"])[0];if(l){let h=l[0],f=h===0?12:20;const p=rt(l,f),m=bt(a,["mdia","mdhd"])[0];if(m){h=m[0],f=h===0?12:20;const g=rt(m,f),A=bt(a,["mdia","hdlr"])[0];if(A){const b=wi(A.subarray(8,12)),x={soun:Ct.AUDIO,vide:Ct.VIDEO}[b];if(x){const k=bt(a,["mdia","minf","stbl","stsd"])[0];let w;k&&(w=wi(k.subarray(12,16))),e[p]={timescale:g,type:x},e[x]={timescale:g,id:p,codec:w}}}}}}return bt(r,["moov","mvex","trex"]).forEach(n=>{const a=rt(n,4),l=e[a];l&&(l.default={duration:rt(n,12),flags:rt(n,20)})}),e}function Vv(r,e){if(!r||!e)return r;const t=e.keyId;return t&&e.isCommonEncryption&&bt(r,["moov","trak"]).forEach(n=>{const l=bt(n,["mdia","minf","stbl","stsd"])[0].subarray(8);let h=bt(l,["enca"]);const f=h.length>0;f||(h=bt(l,["encv"])),h.forEach(p=>{const m=f?p.subarray(28):p.subarray(78);bt(m,["sinf"]).forEach(A=>{const b=Td(A);if(b){const x=b.subarray(8,24);x.some(k=>k!==0)||(q.log(`[eme] Patching keyId in 'enc${f?"a":"v"}>sinf>>tenc' box: ${Mr.hexDump(x)} -> ${Mr.hexDump(t)}`),b.set(t,8))}})})}),r}function Td(r){const e=bt(r,["schm"])[0];if(e){const t=wi(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return bt(r,["schi","tenc"])[0]}return q.error("[eme] missing 'schm' box"),null}function Hv(r,e){return bt(e,["moof","traf"]).reduce((t,i)=>{const n=bt(i,["tfdt"])[0],a=n[0],l=bt(i,["tfhd"]).reduce((h,f)=>{const p=rt(f,4),m=r[p];if(m){let g=rt(n,4);if(a===1){if(g===Va)return q.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),h;g*=Va+1,g+=rt(n,8)}const A=m.timescale||9e4,b=g/A;if(isFinite(b)&&(h===null||b<h))return b}return h},null);return l!==null&&isFinite(l)&&(t===null||l<t)?l:t},null)}function Wv(r,e){let t=0,i=0,n=0;const a=bt(r,["moof","traf"]);for(let l=0;l<a.length;l++){const h=a[l],f=bt(h,["tfhd"])[0],p=rt(f,4),m=e[p];if(!m)continue;const g=m.default,A=rt(f,0)|(g==null?void 0:g.flags);let b=g==null?void 0:g.duration;A&8&&(A&2?b=rt(f,12):b=rt(f,8));const x=m.timescale||9e4,k=bt(h,["trun"]);for(let w=0;w<k.length;w++){if(t=jv(k[w]),!t&&b){const P=rt(k[w],4);t=b*P}m.type===Ct.VIDEO?i+=t/x:m.type===Ct.AUDIO&&(n+=t/x)}}if(i===0&&n===0){let l=0;const h=bt(r,["sidx"]);for(let f=0;f<h.length;f++){const p=Gv(h[f]);p!=null&&p.references&&(l+=p.references.reduce((m,g)=>m+g.info.duration||0,0))}return l}return i||n}function jv(r){const e=rt(r,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let i=0;const n=rt(r,4);for(let a=0;a<n;a++){if(e&256){const l=rt(r,t);i+=l,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return i}function Kv(r,e,t){bt(e,["moof","traf"]).forEach(i=>{bt(i,["tfhd"]).forEach(n=>{const a=rt(n,4),l=r[a];if(!l)return;const h=l.timescale||9e4;bt(i,["tfdt"]).forEach(f=>{const p=f[0];let m=rt(f,4);if(p===0)m-=t*h,m=Math.max(m,0),Rc(f,4,m);else{m*=Math.pow(2,32),m+=rt(f,8),m-=t*h,m=Math.max(m,0);const g=Math.floor(m/(Va+1)),A=Math.floor(m%(Va+1));Rc(f,4,g),Rc(f,8,A)}})})})}function zv(r){const e={valid:null,remainder:null},t=bt(r,["moof"]);if(t){if(t.length<2)return e.remainder=r,e}else return e;const i=t[t.length-1];return e.valid=un(r,0,i.byteOffset-8),e.remainder=un(r,i.byteOffset-8),e}function hn(r,e){const t=new Uint8Array(r.length+e.length);return t.set(r),t.set(e,r.length),t}function kd(r,e){const t=[],i=e.samples,n=e.timescale,a=e.id;let l=!1;return bt(i,["moof"]).map(f=>{const p=f.byteOffset-8;bt(f,["traf"]).map(g=>{const A=bt(g,["tfdt"]).map(b=>{const x=b[0];let k=rt(b,4);return x===1&&(k*=Math.pow(2,32),k+=rt(b,8)),k/n})[0];return A!==void 0&&(r=A),bt(g,["tfhd"]).map(b=>{const x=rt(b,4),k=rt(b,0)&16777215,w=(k&1)!==0,P=(k&2)!==0,$=(k&8)!==0;let N=0;const I=(k&16)!==0;let O=0;const K=(k&32)!==0;let U=8;x===a&&(w&&(U+=8),P&&(U+=4),$&&(N=rt(b,U),U+=4),I&&(O=rt(b,U),U+=4),K&&(U+=4),e.type==="video"&&(l=Yv(e.codec)),bt(g,["trun"]).map(re=>{const ne=re[0],Y=rt(re,0)&16777215,Ee=(Y&1)!==0;let ce=0;const _e=(Y&4)!==0,Oe=(Y&256)!==0;let B=0;const W=(Y&512)!==0;let we=0;const M=(Y&1024)!==0,G=(Y&2048)!==0;let Q=0;const me=rt(re,4);let pe=8;Ee&&(ce=rt(re,pe),pe+=4),_e&&(pe+=4);let Le=ce+p;for(let Ue=0;Ue<me;Ue++){if(Oe?(B=rt(re,pe),pe+=4):B=N,W?(we=rt(re,pe),pe+=4):we=O,M&&(pe+=4),G&&(ne===0?Q=rt(re,pe):Q=bd(re,pe),pe+=4),e.type===Ct.VIDEO){let Ke=0;for(;Ke<we;){const Ze=rt(i,Le);if(Le+=4,Xv(l,i[Le])){const pt=i.subarray(Le,Le+Ze);Sd(pt,l?2:1,r+Q/n,t)}Le+=Ze,Ke+=Ze+4}}r+=B/n}}))})})}),t}function Yv(r){if(!r)return!1;const e=r.indexOf("."),t=e<0?r:r.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Xv(r,e){if(r){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function Sd(r,e,t,i){const n=wd(r);let a=0;a+=e;let l=0,h=0,f=!1,p=0;for(;a<n.length;){l=0;do{if(a>=n.length)break;p=n[a++],l+=p}while(p===255);h=0;do{if(a>=n.length)break;p=n[a++],h+=p}while(p===255);const m=n.length-a;if(!f&&l===4&&a<n.length){if(f=!0,n[a++]===181){const A=Ed(n,a);if(a+=2,A===49){const b=rt(n,a);if(a+=4,b===1195456820){const x=n[a++];if(x===3){const k=n[a++],w=31&k,P=64&k,$=P?2+w*3:0,N=new Uint8Array($);if(P){N[0]=k;for(let I=1;I<$;I++)N[I]=n[a++]}i.push({type:x,payloadType:l,pts:t,bytes:N})}}}}}else if(l===5&&h<m){if(f=!0,h>16){const g=[];for(let x=0;x<16;x++){const k=n[a++].toString(16);g.push(k.length==1?"0"+k:k),(x===3||x===5||x===7||x===9)&&g.push("-")}const A=h-16,b=new Uint8Array(A);for(let x=0;x<A;x++)b[x]=n[a++];i.push({payloadType:l,pts:t,uuid:g.join(""),userData:Fr(b),userDataBytes:b})}}else if(h<m)a+=h;else if(h>m)break}}function wd(r){const e=r.byteLength,t=[];let i=1;for(;i<e-2;)r[i]===0&&r[i+1]===0&&r[i+2]===3?(t.push(i+2),i+=2):i++;if(t.length===0)return r;const n=e-t.length,a=new Uint8Array(n);let l=0;for(i=0;i<n;l++,i++)l===t[0]&&(l++,t.shift()),a[i]=r[l];return a}function Zv(r){const e=r[0];let t="",i="",n=0,a=0,l=0,h=0,f=0,p=0;if(e===0){for(;wi(r.subarray(p,p+1))!=="\0";)t+=wi(r.subarray(p,p+1)),p+=1;for(t+=wi(r.subarray(p,p+1)),p+=1;wi(r.subarray(p,p+1))!=="\0";)i+=wi(r.subarray(p,p+1)),p+=1;i+=wi(r.subarray(p,p+1)),p+=1,n=rt(r,12),a=rt(r,16),h=rt(r,20),f=rt(r,24),p=28}else if(e===1){p+=4,n=rt(r,p),p+=4;const g=rt(r,p);p+=4;const A=rt(r,p);for(p+=4,l=4294967296*g+A,Number.isSafeInteger(l)||(l=Number.MAX_SAFE_INTEGER,q.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),h=rt(r,p),p+=4,f=rt(r,p),p+=4;wi(r.subarray(p,p+1))!=="\0";)t+=wi(r.subarray(p,p+1)),p+=1;for(t+=wi(r.subarray(p,p+1)),p+=1;wi(r.subarray(p,p+1))!=="\0";)i+=wi(r.subarray(p,p+1)),p+=1;i+=wi(r.subarray(p,p+1)),p+=1}const m=r.subarray(p,r.byteLength);return{schemeIdUri:t,value:i,timeScale:n,presentationTime:l,presentationTimeDelta:a,eventDuration:h,id:f,payload:m}}function qv(r,...e){const t=e.length;let i=8,n=t;for(;n--;)i+=e[n].byteLength;const a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=i&255,a.set(r,4),n=0,i=8;n<t;n++)a.set(e[n],i),i+=e[n].byteLength;return a}function Qv(r,e,t){if(r.byteLength!==16)throw new RangeError("Invalid system id");let i,n;if(e){i=1,n=new Uint8Array(e.length*16);for(let h=0;h<e.length;h++){const f=e[h];if(f.byteLength!==16)throw new RangeError("Invalid key");n.set(f,h*16)}}else i=0,n=new Uint8Array;let a;i>0?(a=new Uint8Array(4),e.length>0&&new DataView(a.buffer).setUint32(0,e.length,!1)):a=new Uint8Array;const l=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(l.buffer).setUint32(0,t.byteLength,!1),qv([112,115,115,104],new Uint8Array([i,0,0,0]),r,a,n,l,t||new Uint8Array)}function Jv(r){if(!(r instanceof ArrayBuffer)||r.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(r),i=t.getUint32(0);if(r.byteLength!==i&&i>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Mr.hexDump(new Uint8Array(r,12,16));const a=t.getUint32(28);if(e.version===0){if(i-32<a)return null;e.data=new Uint8Array(r,32,a)}else if(e.version===1){e.kids=[];for(let l=0;l<a;l++)e.kids.push(new Uint8Array(r,32+l*16,16))}return e}let Ha={};class Lo{static clearKeyUriToKeyIdMap(){Ha={}}constructor(e,t,i,n=[1],a=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=i,this.keyFormatVersions=n,this.iv=a,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="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 Xi.FAIRPLAY:case Xi.WIDEVINE:case Xi.PLAYREADY:case Xi.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&q.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const i=ey(e);return new Lo(this.method,this.uri,"identity",this.keyFormatVersions,i)}const t=_v(this.uri);if(t)switch(this.keyFormat){case Xi.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Xi.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Qv(i,null,t);const n=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),a=String.fromCharCode.apply(null,Array.from(n)),l=a.substring(a.indexOf("<"),a.length),p=new DOMParser().parseFromString(l,"text/xml").getElementsByTagName("KID")[0];if(p){const m=p.childNodes[0]?p.childNodes[0].nodeValue:p.getAttribute("VALUE");if(m){const g=kc(m).subarray(0,16);wv(g),this.keyId=g}}break}default:{let i=t.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=Ha[this.uri];if(!i){const n=Object.keys(Ha).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,n),Ha[this.uri]=i}this.keyId=i}return this}}function ey(r){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=r>>8*(15-t)&255;return e}const _d=/\{\$([a-zA-Z0-9-_]+)\}/g;function Rd(r){return _d.test(r)}function Zi(r,e,t){if(r.variableList!==null||r.hasVariableRefs)for(let i=t.length;i--;){const n=t[i],a=e[n];a&&(e[n]=Lc(r,a))}}function Lc(r,e){if(r.variableList!==null||r.hasVariableRefs){const t=r.variableList;return e.replace(_d,i=>{const n=i.substring(2,i.length-1),a=t==null?void 0:t[n];return a===void 0?(r.playlistParsingError||(r.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${n}"`)),i):a})}return e}function Ld(r,e,t){let i=r.variableList;i||(r.variableList=i={});let n,a;if("QUERYPARAM"in e){n=e.QUERYPARAM;try{const l=new self.URL(t).searchParams;if(l.has(n))a=l.get(n);else throw new Error(`"${n}" does not match any query parameter in URI: "${t}"`)}catch(l){r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${l.message}`))}}else n=e.NAME,a=e.VALUE;n in i?r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${n}"`)):i[n]=a||""}function ty(r,e,t){const i=e.IMPORT;if(t&&i in t){let n=r.variableList;n||(r.variableList=n={}),n[i]=t[i]}else r.playlistParsingError||(r.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function Wa(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const iy={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}},Cd=Wa();function ry(r,e){const t=iy[e];return!!t&&t[r.slice(0,4)]===!0}function Cc(r,e){var t;return(t=Cd==null?void 0:Cd.isTypeSupported(`${e||"video"}/mp4;codecs="${r}"`))!=null?t:!1}const Id=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Dd=/#EXT-X-MEDIA:(.*)/g,sy=/^#EXT(?:INF|-X-TARGETDURATION):/m,Od=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ny=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 Sr{static findGroup(e,t){for(let i=0;i<e.length;i++){const n=e[i];if(n.id===t)return n}}static convertAVC1ToAVCOTI(e){const t=e.split(".");if(t.length>2){let i=t.shift()+".";return i+=parseInt(t.shift()).toString(16),i+=("000"+parseInt(t.shift()).toString(16)).slice(-4),i}return e}static resolve(e,t){return bc.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return sy.test(e)}static parseMasterPlaylist(e,t){const i=Rd(e),n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},a=[];Id.lastIndex=0;let l;for(;(l=Id.exec(e))!=null;)if(l[1]){var h;const p=new Jt(l[1]);Zi(n,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const m=Lc(n,l[2]),g={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:Sr.resolve(m,t)},A=p.decimalResolution("RESOLUTION");A&&(g.width=A.width,g.height=A.height),oy((p.CODECS||"").split(/[ ,]+/).filter(b=>b),g),g.videoCodec&&g.videoCodec.indexOf("avc1")!==-1&&(g.videoCodec=Sr.convertAVC1ToAVCOTI(g.videoCodec)),(h=g.unknownCodecs)!=null&&h.length||a.push(g),n.levels.push(g)}else if(l[3]){const p=l[3],m=l[4];switch(p){case"SESSION-DATA":{const g=new Jt(m);Zi(n,g,["DATA-ID","LANGUAGE","VALUE","URI"]);const A=g["DATA-ID"];A&&(n.sessionData===null&&(n.sessionData={}),n.sessionData[A]=g);break}case"SESSION-KEY":{const g=Pd(m,t,n);g.encrypted&&g.isSupported()?(n.sessionKeys===null&&(n.sessionKeys=[]),n.sessionKeys.push(g)):q.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${m}"`);break}case"DEFINE":{{const g=new Jt(m);Zi(n,g,["NAME","VALUE","QUERYPARAM"]),Ld(n,g,t)}break}case"CONTENT-STEERING":{const g=new Jt(m);Zi(n,g,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Sr.resolve(g["SERVER-URI"],t),pathwayId:g["PATHWAY-ID"]||"."};break}case"START":{n.startTimeOffset=$d(m);break}}}const f=a.length>0&&a.length<n.levels.length;return n.levels=f?a:n.levels,n.levels.length===0&&(n.playlistParsingError=new Error("no levels found in manifest")),n}static parseMasterPlaylistMedia(e,t,i){let n;const a={},l=i.levels,h={AUDIO:l.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:l.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(Dd.lastIndex=0;(n=Dd.exec(e))!==null;){const p=new Jt(n[1]),m=p.TYPE;if(m){const g=h[m],A=a[m]||[];a[m]=A,Zi(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const b={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:m,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?Sr.resolve(p.URI,t):""};if(g!=null&&g.length){const x=Sr.findGroup(g,b.groupId)||g[0];Fd(b,x,"audioCodec"),Fd(b,x,"textCodec")}A.push(b)}}return a}static parseLevelPlaylist(e,t,i,n,a,l){const h=new kv(t),f=h.fragments;let p=null,m=0,g=0,A=0,b=0,x=null,k=new Tc(n,t),w,P,$,N=-1,I=!1;for(Od.lastIndex=0,h.m3u8=e,h.hasVariableRefs=Rd(e);(w=Od.exec(e))!==null;){I&&(I=!1,k=new Tc(n,t),k.start=A,k.sn=m,k.cc=b,k.level=i,p&&(k.initSegment=p,k.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const re=w[1];if(re){k.duration=parseFloat(re);const ne=(" "+w[2]).slice(1);k.title=ne||null,k.tagList.push(ne?["INF",re,ne]:["INF",re])}else if(w[3]){if(ze(k.duration)){k.start=A,$&&Ud(k,$,h),k.sn=m,k.level=i,k.cc=b,k.urlId=a,f.push(k);const ne=(" "+w[3]).slice(1);k.relurl=Lc(h,ne),Md(k,x),x=k,A+=k.duration,m++,g=0,I=!0}}else if(w[4]){const ne=(" "+w[4]).slice(1);x?k.setByteRange(ne,x):k.setByteRange(ne)}else if(w[5])k.rawProgramDateTime=(" "+w[5]).slice(1),k.tagList.push(["PROGRAM-DATE-TIME",k.rawProgramDateTime]),N===-1&&(N=f.length);else{if(w=w[0].match(ny),!w){q.warn("No matches on slow regex match for level playlist!");continue}for(P=1;P<w.length&&!(typeof w[P]<"u");P++);const ne=(" "+w[P]).slice(1),Y=(" "+w[P+1]).slice(1),Ee=w[P+2]?(" "+w[P+2]).slice(1):"";switch(ne){case"PLAYLIST-TYPE":h.type=Y.toUpperCase();break;case"MEDIA-SEQUENCE":m=h.startSN=parseInt(Y);break;case"SKIP":{const ce=new Jt(Y);Zi(h,ce,["RECENTLY-REMOVED-DATERANGES"]);const _e=ce.decimalInteger("SKIPPED-SEGMENTS");if(ze(_e)){h.skippedSegments=_e;for(let B=_e;B--;)f.unshift(null);m+=_e}const Oe=ce.enumeratedString("RECENTLY-REMOVED-DATERANGES");Oe&&(h.recentlyRemovedDateranges=Oe.split(" "));break}case"TARGETDURATION":h.targetduration=Math.max(parseInt(Y),1);break;case"VERSION":h.version=parseInt(Y);break;case"EXTM3U":break;case"ENDLIST":h.live=!1;break;case"#":(Y||Ee)&&k.tagList.push(Ee?[Y,Ee]:[Y]);break;case"DISCONTINUITY":b++,k.tagList.push(["DIS"]);break;case"GAP":k.gap=!0,k.tagList.push([ne]);break;case"BITRATE":k.tagList.push([ne,Y]);break;case"DATERANGE":{const ce=new Jt(Y);Zi(h,ce,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Zi(h,ce,ce.clientAttrs);const _e=new cd(ce,h.dateRanges[ce.ID]);_e.isValid||h.skippedSegments?h.dateRanges[_e.id]=_e:q.warn(`Ignoring invalid DATERANGE tag: "${Y}"`),k.tagList.push(["EXT-X-DATERANGE",Y]);break}case"DEFINE":{{const ce=new Jt(Y);Zi(h,ce,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in ce?ty(h,ce,l):Ld(h,ce,t)}break}case"DISCONTINUITY-SEQUENCE":b=parseInt(Y);break;case"KEY":{const ce=Pd(Y,t,h);if(ce.isSupported()){if(ce.method==="NONE"){$=void 0;break}$||($={}),$[ce.keyFormat]&&($=ci({},$)),$[ce.keyFormat]=ce}else q.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Y}"`);break}case"START":h.startTimeOffset=$d(Y);break;case"MAP":{const ce=new Jt(Y);if(Zi(h,ce,["BYTERANGE","URI"]),k.duration){const _e=new Tc(n,t);Nd(_e,ce,i,$),p=_e,k.initSegment=p,p.rawProgramDateTime&&!k.rawProgramDateTime&&(k.rawProgramDateTime=p.rawProgramDateTime)}else Nd(k,ce,i,$),p=k,I=!0;break}case"SERVER-CONTROL":{const ce=new Jt(Y);h.canBlockReload=ce.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=ce.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&ce.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=ce.optionalFloat("PART-HOLD-BACK",0),h.holdBack=ce.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const ce=new Jt(Y);h.partTarget=ce.decimalFloatingPoint("PART-TARGET");break}case"PART":{let ce=h.partList;ce||(ce=h.partList=[]);const _e=g>0?ce[ce.length-1]:void 0,Oe=g++,B=new Jt(Y);Zi(h,B,["BYTERANGE","URI"]);const W=new xv(B,k,t,Oe,_e);ce.push(W),k.duration+=W.duration;break}case"PRELOAD-HINT":{const ce=new Jt(Y);Zi(h,ce,["URI"]),h.preloadHint=ce;break}case"RENDITION-REPORT":{const ce=new Jt(Y);Zi(h,ce,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(ce);break}default:q.warn(`line parsed but not handled: ${w}`);break}}}x&&!x.relurl?(f.pop(),A-=x.duration,h.partList&&(h.fragmentHint=x)):h.partList&&(Md(k,x),k.cc=b,h.fragmentHint=k,$&&Ud(k,$,h));const O=f.length,K=f[0],U=f[O-1];if(A+=h.skippedSegments*h.targetduration,A>0&&O&&U){h.averagetargetduration=A/O;const re=U.sn;h.endSN=re!=="initSegment"?re:0,h.live||(U.endList=!0),K&&(h.startCC=K.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(A+=h.fragmentHint.duration),h.totalduration=A,h.endCC=b,N>0&&ay(f,N),h}}function Pd(r,e,t){var i,n;const a=new Jt(r);Zi(t,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const l=(i=a.METHOD)!=null?i:"",h=a.URI,f=a.hexadecimalInteger("IV"),p=a.KEYFORMATVERSIONS,m=(n=a.KEYFORMAT)!=null?n:"identity";h&&a.IV&&!f&&q.error(`Invalid IV: ${a.IV}`);const g=h?Sr.resolve(h,e):"",A=(p||"1").split("/").map(Number).filter(Number.isFinite);return new Lo(l,g,m,A,f)}function $d(r){const t=new Jt(r).decimalFloatingPoint("TIME-OFFSET");return ze(t)?t:null}function oy(r,e){["video","audio","text"].forEach(t=>{const i=r.filter(n=>ry(n,t));if(i.length){const n=i.filter(a=>a.lastIndexOf("avc1",0)===0||a.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=n.length>0?n[0]:i[0],r=r.filter(a=>i.indexOf(a)===-1)}}),e.unknownCodecs=r}function Fd(r,e,t){const i=e[t];i&&(r[t]=i)}function ay(r,e){let t=r[e];for(let i=e;i--;){const n=r[i];if(!n)return;n.programDateTime=t.programDateTime-n.duration*1e3,t=n}}function Md(r,e){r.rawProgramDateTime?r.programDateTime=Date.parse(r.rawProgramDateTime):e!=null&&e.programDateTime&&(r.programDateTime=e.endProgramDateTime),ze(r.programDateTime)||(r.programDateTime=null,r.rawProgramDateTime=null)}function Nd(r,e,t,i){r.relurl=e.URI,e.BYTERANGE&&r.setByteRange(e.BYTERANGE),r.level=t,r.sn="initSegment",i&&(r.levelkeys=i),r.initSegment=null}function Ud(r,e,t){r.levelkeys=e;const{encryptedFragments:i}=t;(!i.length||i[i.length-1].levelkeys!==e)&&Object.keys(e).some(n=>e[n].isCommonEncryption)&&i.push(r)}var Tt={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},it={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Bd(r){const{type:e}=r;switch(e){case Tt.AUDIO_TRACK:return it.AUDIO;case Tt.SUBTITLE_TRACK:return it.SUBTITLE;default:return it.MAIN}}function Ic(r,e){let t=r.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class ly{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(_.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,i=t.pLoader,n=t.loader,a=i||n,l=new a(t);return this.loaders[e.type]=l,l}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:i}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Tt.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(e,t){const{id:i,level:n,url:a,deliveryDirectives:l}=t;this.load({id:i,level:n,responseType:"text",type:Tt.LEVEL,url:a,deliveryDirectives:l})}onAudioTrackLoading(e,t){const{id:i,groupId:n,url:a,deliveryDirectives:l}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Tt.AUDIO_TRACK,url:a,deliveryDirectives:l})}onSubtitleTrackLoading(e,t){const{id:i,groupId:n,url:a,deliveryDirectives:l}=t;this.load({id:i,groupId:n,level:null,responseType:"text",type:Tt.SUBTITLE_TRACK,url:a,deliveryDirectives:l})}load(e){var t;const i=this.hls.config;let n=this.getInternalLoader(e);if(n){const p=n.context;if(p&&p.url===e.url){q.trace("[playlist-loader]: playlist request ongoing");return}q.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}let a;if(e.type===Tt.MANIFEST?a=i.manifestLoadPolicy.default:a=ci({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let p;if(e.type===Tt.LEVEL&&e.level!==null?p=this.hls.levels[e.level].details:e.type===Tt.AUDIO_TRACK&&e.id!==null?p=this.hls.audioTracks[e.id].details:e.type===Tt.SUBTITLE_TRACK&&e.id!==null&&(p=this.hls.subtitleTracks[e.id].details),p){const m=p.partTarget,g=p.targetduration;if(m&&g){const A=Math.max(m*3,g*.8)*1e3;a=ci({},a,{maxTimeToFirstByteMs:Math.min(A,a.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(A,a.maxTimeToFirstByteMs)})}}}const l=a.errorRetry||a.timeoutRetry||{},h={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},f={onSuccess:(p,m,g,A)=>{const b=this.getInternalLoader(g);this.resetInternalLoader(g.type);const x=p.data;if(x.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,g,new Error("no EXTM3U delimiter"),A||null,m);return}m.parsing.start=performance.now(),Sr.isMediaPlaylist(x)?this.handleTrackOrLevelPlaylist(p,m,g,A||null,b):this.handleMasterPlaylist(p,m,g,A)},onError:(p,m,g,A)=>{this.handleNetworkError(m,g,!1,p,A)},onTimeout:(p,m,g)=>{this.handleNetworkError(m,g,!0,void 0,p)}};n.load(e,h,f)}handleMasterPlaylist(e,t,i,n){const a=this.hls,l=e.data,h=Ic(e,i),f=Sr.parseMasterPlaylist(l,h);if(f.playlistParsingError){this.handleManifestParsingError(e,i,f.playlistParsingError,n,t);return}const{contentSteering:p,levels:m,sessionData:g,sessionKeys:A,startTimeOffset:b,variableList:x}=f;this.variableList=x;const{AUDIO:k=[],SUBTITLES:w,"CLOSED-CAPTIONS":P}=Sr.parseMasterPlaylistMedia(l,h,f);k.length&&!k.some(N=>!N.url)&&m[0].audioCodec&&!m[0].attrs.AUDIO&&(q.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),k.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Jt({}),bitrate:0,url:""})),a.trigger(_.MANIFEST_LOADED,{levels:m,audioTracks:k,subtitles:w,captions:P,contentSteering:p,url:h,stats:t,networkDetails:n,sessionData:g,sessionKeys:A,startTimeOffset:b,variableList:x})}handleTrackOrLevelPlaylist(e,t,i,n,a){const l=this.hls,{id:h,level:f,type:p}=i,m=Ic(e,i),g=ze(h)?h:0,A=ze(f)?f:g,b=Bd(i),x=Sr.parseLevelPlaylist(e.data,m,A,b,g,this.variableList);if(p===Tt.MANIFEST){const k={attrs:new Jt({}),bitrate:0,details:x,name:"",url:m};l.trigger(_.MANIFEST_LOADED,{levels:[k],audioTracks:[],url:m,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),i.levelDetails=x,this.handlePlaylistLoaded(x,e,t,i,n,a)}handleManifestParsingError(e,t,i,n,a){this.hls.trigger(_.ERROR,{type:tt.NETWORK_ERROR,details:fe.MANIFEST_PARSING_ERROR,fatal:t.type===Tt.MANIFEST,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:a})}handleNetworkError(e,t,i=!1,n,a){let l=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading ${e.type}`;e.type===Tt.LEVEL?l+=`: ${e.level} id: ${e.id}`:(e.type===Tt.AUDIO_TRACK||e.type===Tt.SUBTITLE_TRACK)&&(l+=` id: ${e.id} group-id: "${e.groupId}"`);const h=new Error(l);q.warn(`[playlist-loader]: ${l}`);let f=fe.UNKNOWN,p=!1;const m=this.getInternalLoader(e);switch(e.type){case Tt.MANIFEST:f=i?fe.MANIFEST_LOAD_TIMEOUT:fe.MANIFEST_LOAD_ERROR,p=!0;break;case Tt.LEVEL:f=i?fe.LEVEL_LOAD_TIMEOUT:fe.LEVEL_LOAD_ERROR,p=!1;break;case Tt.AUDIO_TRACK:f=i?fe.AUDIO_TRACK_LOAD_TIMEOUT:fe.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Tt.SUBTITLE_TRACK:f=i?fe.SUBTITLE_TRACK_LOAD_TIMEOUT:fe.SUBTITLE_LOAD_ERROR,p=!1;break}m&&this.resetInternalLoader(e.type);const g={type:tt.NETWORK_ERROR,details:f,fatal:p,url:e.url,loader:m,context:e,error:h,networkDetails:t,stats:a};if(n){const A=(t==null?void 0:t.url)||e.url;g.response=Yi({url:A,data:void 0},n)}this.hls.trigger(_.ERROR,g)}handlePlaylistLoaded(e,t,i,n,a,l){const h=this.hls,{type:f,level:p,id:m,groupId:g,deliveryDirectives:A}=n,b=Ic(t,n),x=Bd(n),k=typeof n.level=="number"&&x===it.MAIN?p:void 0;if(!e.fragments.length){const P=new Error("No Segments found in Playlist");h.trigger(_.ERROR,{type:tt.NETWORK_ERROR,details:fe.LEVEL_EMPTY_ERROR,fatal:!1,url:b,error:P,reason:P.message,response:t,context:n,level:k,parent:x,networkDetails:a,stats:i});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const w=e.playlistParsingError;if(w){h.trigger(_.ERROR,{type:tt.NETWORK_ERROR,details:fe.LEVEL_PARSING_ERROR,fatal:!1,url:b,error:w,reason:w.message,response:t,context:n,level:k,parent:x,networkDetails:a,stats:i});return}switch(e.live&&l&&(l.getCacheAge&&(e.ageHeader=l.getCacheAge()||0),(!l.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),f){case Tt.MANIFEST:case Tt.LEVEL:h.trigger(_.LEVEL_LOADED,{details:e,level:k||0,id:m||0,stats:i,networkDetails:a,deliveryDirectives:A});break;case Tt.AUDIO_TRACK:h.trigger(_.AUDIO_TRACK_LOADED,{details:e,id:m||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:A});break;case Tt.SUBTITLE_TRACK:h.trigger(_.SUBTITLE_TRACK_LOADED,{details:e,id:m||0,groupId:g||"",stats:i,networkDetails:a,deliveryDirectives:A});break}}}function Gd(r,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=r,e.dispatchEvent(t)}function Vd(r,e){const t=r.mode;if(t==="disabled"&&(r.mode="hidden"),r.cues&&!r.cues.getCueById(e.id))try{if(r.addCue(e),!r.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(i){q.debug(`[texttrack-utils]: ${i}`);try{const n=new self.TextTrackCue(e.startTime,e.endTime,e.text);n.id=e.id,r.addCue(n)}catch(n){q.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${n}`)}}t==="disabled"&&(r.mode=t)}function Rn(r){const e=r.mode;if(e==="disabled"&&(r.mode="hidden"),r.cues)for(let t=r.cues.length;t--;)r.removeCue(r.cues[t]);e==="disabled"&&(r.mode=e)}function Dc(r,e,t,i){const n=r.mode;if(n==="disabled"&&(r.mode="hidden"),r.cues&&r.cues.length>0){const a=uy(r.cues,e,t);for(let l=0;l<a.length;l++)(!i||i(a[l]))&&r.removeCue(a[l])}n==="disabled"&&(r.mode=n)}function cy(r,e){if(e<r[0].startTime)return 0;const t=r.length-1;if(e>r[t].endTime)return-1;let i=0,n=t;for(;i<=n;){const a=Math.floor((n+i)/2);if(e<r[a].startTime)n=a-1;else if(e>r[a].startTime&&i<t)i=a+1;else return a}return r[i].startTime-e<e-r[n].startTime?i:n}function uy(r,e,t){const i=[],n=cy(r,e);if(n>-1)for(let a=n,l=r.length;a<l;a++){const h=r[a];if(h.startTime>=e&&h.endTime<=t)i.push(h);else if(h.startTime>t)return i}return i}var wr={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const hy=.25;function Oc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const ja=(()=>{const r=Oc();try{new r(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Pc(r,e){return r.getTime()/1e3-e}function dy(r){return Uint8Array.from(r.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class fy{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Rn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const i=e[t];if(i.kind==="metadata"&&i.label==="id3")return Gd(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:n}}}=this;if(!i&&!n)return;const{samples:a}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=Oc();for(let h=0;h<a.length;h++){const f=a[h].type;if(f===wr.emsg&&!i||!n)continue;const p=yd(a[h].data);if(p){const m=a[h].pts;let g=m+a[h].duration;g>ja&&(g=ja),g-m<=0&&(g=m+hy);for(let b=0;b<p.length;b++){const x=p[b];if(!vd(x)){this.updateId3CueEnds(m,f);const k=new l(m,g,"");k.value=x,f&&(k.type=f),this.id3Track.addCue(k)}}}}}updateId3CueEnds(e,t){var i;const n=(i=this.id3Track)==null?void 0:i.cues;if(n)for(let a=n.length;a--;){const l=n[a];l.type===t&&l.startTime<e&&l.endTime===ja&&(l.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:i,type:n}){const{id3Track:a,hls:l}=this;if(!l)return;const{config:{enableEmsgMetadataCues:h,enableID3MetadataCues:f}}=l;if(a&&(h||f)){let p;n==="audio"?p=m=>m.type===wr.audioId3&&f:n==="video"?p=m=>m.type===wr.emsg&&h:p=m=>m.type===wr.audioId3&&f||m.type===wr.emsg&&h,Dc(a,t,i,p)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:n}=this,{dateRanges:a}=t,l=Object.keys(a);if(n){const m=Object.keys(i).filter(g=>!l.includes(g));for(let g=m.length;g--;){const A=m[g];Object.keys(i[A].cues).forEach(b=>{n.removeCue(i[A].cues[b])}),delete i[A]}}const h=t.fragments[t.fragments.length-1];if(l.length===0||!ze(h==null?void 0:h.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=h.programDateTime/1e3-h.start,p=Oc();for(let m=0;m<l.length;m++){const g=l[m],A=a[g],b=i[g],x=(b==null?void 0:b.cues)||{};let k=(b==null?void 0:b.durationKnown)||!1;const w=Pc(A.startDate,f);let P=ja;const $=A.endDate;if($)P=Pc($,f),k=!0;else if(A.endOnNext&&!k){const I=l.reduce((O,K)=>{const U=a[K];return U.class===A.class&&U.id!==K&&U.startDate>A.startDate&&O.push(U),O},[]).sort((O,K)=>O.startDate.getTime()-K.startDate.getTime())[0];I&&(P=Pc(I.startDate,f),k=!0)}const N=Object.keys(A.attr);for(let I=0;I<N.length;I++){const O=N[I];if(!Ev(O))continue;let K=x[O];if(K)k&&!b.durationKnown&&(K.endTime=P);else{let U=A.attr[O];K=new p(w,P,""),bv(O)&&(U=dy(U)),K.value={key:O,data:U},K.type=wr.dateRange,K.id=g,this.id3Track.addCue(K),x[O]=K}}i[g]={cues:x,dateRange:A,durationKnown:k}}}}class py{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:i,targetduration:n}=e,{liveSyncDuration:a,liveSyncDurationCount:l,lowLatencyMode:h}=this.config,f=this.hls.userConfig;let p=h&&i||t;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=a!==void 0?a:l*n);const m=n,g=1;return p+Math.min(this.stallCount*g,m)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,i=this.levelDetails;if(e===null||t===null||i===null)return null;const n=i.edge,a=e-t-this.edgeStalled,l=n-i.totalduration,h=n-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(l,a),h)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const i=e.buffered.length;return(i?e.buffered.end(i-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(_.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(_.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var i;t.details===fe.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&q.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:n,maxLiveSyncPlaybackRate:a}=this.config;if(!n||a===1)return;const l=this.targetLatency;if(l===null)return;const h=i-l,f=Math.min(this.maxLatency,l+t.targetduration),p=h<f;if(t.live&&p&&h>.05&&this.forwardBufferLength>1){const m=Math.min(2,Math.max(1,a)),g=Math.round(2/(1+Math.exp(-.75*h-this.edgeStalled))*20)/20;e.playbackRate=Math.min(m,Math.max(1,g))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const $c=["NONE","TYPE-0","TYPE-1",null];var Co={No:"",Yes:"YES",v2:"v2"};function my(r,e){const{canSkipUntil:t,canSkipDateRanges:i,endSN:n}=r,a=e!==void 0?e-n:0;return t&&a<t?i?Co.v2:Co.Yes:Co.No}class Hd{constructor(e,t,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=i}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class Io{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).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(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function Fc(r,e){const t=e.startPTS;if(ze(t)){let i=0,n;e.sn>r.sn?(i=t-r.start,n=r):(i=r.start-t,n=e),n.duration!==i&&(n.duration=i)}else e.sn>r.sn?r.cc===e.cc&&r.minEndPTS?e.start=r.start+(r.minEndPTS-r.start):e.start=r.start+r.duration:e.start=Math.max(r.start-e.duration,0)}function Wd(r,e,t,i,n,a){i-t<=0&&(q.warn("Fragment should have a positive duration",e),i=t+e.duration,a=n+e.duration);let h=t,f=i;const p=e.startPTS,m=e.endPTS;if(ze(p)){const w=Math.abs(p-t);ze(e.deltaPTS)?e.deltaPTS=Math.max(w,e.deltaPTS):e.deltaPTS=w,h=Math.max(t,p),t=Math.min(t,p),n=Math.min(n,e.startDTS),f=Math.min(i,m),i=Math.max(i,m),a=Math.max(a,e.endDTS)}const g=t-e.start;e.start!==0&&(e.start=t),e.duration=i-e.start,e.startPTS=t,e.maxStartPTS=h,e.startDTS=n,e.endPTS=i,e.minEndPTS=f,e.endDTS=a;const A=e.sn;if(!r||A<r.startSN||A>r.endSN)return 0;let b;const x=A-r.startSN,k=r.fragments;for(k[x]=e,b=x;b>0;b--)Fc(k[b],k[b-1]);for(b=x;b<k.length-1;b++)Fc(k[b],k[b+1]);return r.fragmentHint&&Fc(k[k.length-1],r.fragmentHint),r.PTSKnown=r.alignedSliding=!0,g}function gy(r,e){let t=null;const i=r.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){t=p;break}}r.fragmentHint&&delete r.fragmentHint.endPTS;let n=0,a;if(Ay(r,e,(f,p)=>{f.relurl&&(n=f.cc-p.cc),ze(f.startPTS)&&ze(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&&(a=p),e.PTSKnown=e.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,t=f.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(p=>{var m;(!p.initSegment||p.initSegment.relurl===((m=t)==null?void 0:m.relurl))&&(p.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(f=>!f),e.deltaUpdateFailed){q.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=e.skippedSegments;f--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=vy(r.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const l=e.fragments;if(n){q.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<l.length;f++)l[f].cc+=n}e.skippedSegments&&(e.startCC=e.fragments[0].cc),yy(r.partList,e.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),a?Wd(e,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS):jd(r,e),l.length&&(e.totalduration=e.edge-l[0].start),e.driftStartTime=r.driftStartTime,e.driftStart=r.driftStart;const h=e.advancedDateTime;if(e.advanced&&h){const f=e.edge;e.driftStart||(e.driftStartTime=h,e.driftStart=f),e.driftEndTime=h,e.driftEnd=f}else e.driftEndTime=r.driftEndTime,e.driftEnd=r.driftEnd,e.advancedDateTime=r.advancedDateTime}function vy(r,e,t){const i=ci({},r);return t&&t.forEach(n=>{delete i[n]}),Object.keys(e).forEach(n=>{const a=new cd(e[n].attr,i[n]);a.isValid?i[n]=a:q.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[n].attr)}"`)}),i}function yy(r,e,t){if(r&&e){let i=0;for(let n=0,a=r.length;n<=a;n++){const l=r[n],h=e[n+i];l&&h&&l.index===h.index&&l.fragment.sn===h.fragment.sn?t(l,h):i--}}}function Ay(r,e,t){const i=e.skippedSegments,n=Math.max(r.startSN,e.startSN)-e.startSN,a=(r.fragmentHint?1:0)+(i?e.endSN:Math.min(r.endSN,e.endSN))-e.startSN,l=e.startSN-r.startSN,h=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,f=r.fragmentHint?r.fragments.concat(r.fragmentHint):r.fragments;for(let p=n;p<=a;p++){const m=f[l+p];let g=h[p];i&&!g&&p<i&&(g=e.fragments[p]=m),m&&g&&t(m,g)}}function jd(r,e){const t=e.startSN+e.skippedSegments-r.startSN,i=r.fragments;t<0||t>=i.length||Mc(e,i[t].start)}function Mc(r,e){if(e){const t=r.fragments;for(let i=r.skippedSegments;i<t.length;i++)t[i].start+=e;r.fragmentHint&&(r.fragmentHint.start+=e)}}function Ey(r,e=1/0){let t=1e3*r.targetduration;if(r.updated){const i=r.fragments,n=4;if(i.length&&t*n>e){const a=i[i.length-1].duration*1e3;a<t&&(t=a)}}else t/=2;return Math.round(t)}function by(r,e,t){if(!(r!=null&&r.details))return null;const i=r.details;let n=i.fragments[e-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===e)?n:e<i.startSN&&t&&t.sn===e?t:null}function Kd(r,e,t){var i;return r!=null&&r.details?zd((i=r.details)==null?void 0:i.partList,e,t):null}function zd(r,e,t){if(r)for(let i=r.length;i--;){const n=r[i];if(n.index===t&&n.fragment.sn===e)return n}return null}function Ka(r){switch(r.details){case fe.FRAG_LOAD_TIMEOUT:case fe.KEY_LOAD_TIMEOUT:case fe.LEVEL_LOAD_TIMEOUT:case fe.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Yd(r,e){const t=Ka(e);return r.default[`${t?"timeout":"error"}Retry`]}function Nc(r,e){const t=r.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*r.retryDelayMs,r.maxRetryDelayMs)}function Xd(r){return Yi(Yi({},r),{errorRetry:null,timeoutRetry:null})}function za(r,e,t,i){return!!r&&e<r.maxNumRetry&&(xy(i)||!!t)}function xy(r){return r===0&&navigator.onLine===!1||!!r&&(r<400||r>499)}const Zd={search:function(r,e){let t=0,i=r.length-1,n=null,a=null;for(;t<=i;){n=(t+i)/2|0,a=r[n];const l=e(a);if(l>0)t=n+1;else if(l<0)i=n-1;else return a}return null}};function Ty(r,e,t){if(e===null||!Array.isArray(r)||!r.length||!ze(e))return null;const i=r[0].programDateTime;if(e<(i||0))return null;const n=r[r.length-1].endProgramDateTime;if(e>=(n||0))return null;t=t||0;for(let a=0;a<r.length;++a){const l=r[a];if(ky(e,t,l))return l}return null}function Do(r,e,t=0,i=0){let n=null;if(r?n=e[r.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(n=e[0]),n&&Uc(t,i,n)===0)return n;const a=Zd.search(e,Uc.bind(null,t,i));return a&&(a!==r||!n)?a:n}function Uc(r=0,e=0,t){if(t.start<=r&&t.start+t.duration>r)return 0;const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-i<=r?1:t.start-i>r&&t.start?-1:0}function ky(r,e,t){const i=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-i>r}function Sy(r,e){return Zd.search(r,t=>t.cc<e?1:t.cc>e?-1:0)}const wy=3e5;var Ii={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},dr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class _y{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=q.log.bind(q,"[info]:"),this.warn=q.warn.bind(q,"[warning]:"),this.error=q.error.bind(q,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(_.ERROR,this.onError,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(_.ERROR,this.onError,this),e.off(_.ERROR,this.onErrorOut,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===it.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var i,n;if(t.fatal)return;const a=this.hls,l=t.context;switch(t.details){case fe.FRAG_LOAD_ERROR:case fe.FRAG_LOAD_TIMEOUT:case fe.KEY_LOAD_ERROR:case fe.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case fe.FRAG_PARSING_ERROR:if((i=t.frag)!=null&&i.gap){t.errorAction={action:Ii.DoNothing,flags:dr.None};return}case fe.FRAG_GAP:case fe.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ii.SendAlternateToPenaltyBox;return}case fe.LEVEL_EMPTY_ERROR:case fe.LEVEL_PARSING_ERROR:{var h,f;const p=t.parent===it.MAIN?t.level:a.loadLevel;t.details===fe.LEVEL_EMPTY_ERROR&&((h=t.context)!=null&&(f=h.levelDetails)!=null&&f.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,p):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p))}return;case fe.LEVEL_LOAD_ERROR:case fe.LEVEL_LOAD_TIMEOUT:typeof(l==null?void 0:l.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,l.level));return;case fe.AUDIO_TRACK_LOAD_ERROR:case fe.AUDIO_TRACK_LOAD_TIMEOUT:case fe.SUBTITLE_LOAD_ERROR:case fe.SUBTITLE_TRACK_LOAD_TIMEOUT:if(l){const p=a.levels[a.loadLevel];if(p&&(l.type===Tt.AUDIO_TRACK&&l.groupId===p.audioGroupId||l.type===Tt.SUBTITLE_TRACK&&l.groupId===p.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.loadLevel),t.errorAction.action=Ii.SendAlternateToPenaltyBox,t.errorAction.flags=dr.MoveAllAlternatesMatchingHost;return}}return;case fe.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=a.levels[a.loadLevel],m=p==null?void 0:p.attrs["HDCP-LEVEL"];m&&(t.errorAction={action:Ii.SendAlternateToPenaltyBox,flags:dr.MoveAllAlternatesMatchingHDCP,hdcpLevel:m})}return;case fe.BUFFER_ADD_CODEC_ERROR:case fe.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(n=t.level)!=null?n:a.loadLevel);return;case fe.INTERNAL_EXCEPTION:case fe.BUFFER_APPENDING_ERROR:case fe.BUFFER_APPEND_ERROR:case fe.BUFFER_FULL_ERROR:case fe.LEVEL_SWITCH_ERROR:case fe.BUFFER_STALLED_ERROR:case fe.BUFFER_SEEK_OVER_HOLE:case fe.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Ii.DoNothing,flags:dr.None};return}if(t.type===tt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,p);return}}getPlaylistRetryOrSwitchAction(e,t){var i;const n=this.hls,a=Yd(n.config.playlistLoadPolicy,e),l=this.playlistError++,h=(i=e.response)==null?void 0:i.code;if(za(a,l,Ka(e),h))return{action:Ii.RetryRequest,flags:dr.None,retryConfig:a,retryCount:l};const p=this.getLevelSwitchAction(e,t);return a&&(p.retryConfig=a,p.retryCount=l),p}getFragRetryOrSwitchAction(e){const t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:a,keyLoadPolicy:l}=t.config,h=Yd(e.details.startsWith("key")?l:a,e),f=t.levels.reduce((g,A)=>g+A.fragmentError,0);if(n){var p;e.details!==fe.FRAG_GAP&&n.fragmentError++;const g=(p=e.response)==null?void 0:p.code;if(za(h,f,Ka(e),g))return{action:Ii.RetryRequest,flags:dr.None,retryConfig:h,retryCount:f}}const m=this.getLevelSwitchAction(e,i);return h&&(m.retryConfig=h,m.retryCount=f),m}getLevelSwitchAction(e,t){const i=this.hls;t==null&&(t=i.loadLevel);const n=this.hls.levels[t];if(n&&(n.loadError++,i.autoLevelEnabled)){var a,l;let h=-1;const{levels:f,loadLevel:p,minAutoLevel:m,maxAutoLevel:g}=i,A=(a=e.frag)==null?void 0:a.type,{type:b,groupId:x}=(l=e.context)!=null?l:{};for(let k=f.length;k--;){const w=(k+p)%f.length;if(w!==p&&w>=m&&w<=g&&f[w].loadError===0){const P=f[w];if(e.details===fe.FRAG_GAP&&e.frag){const $=f[w].details;if($){const N=Do(e.frag,$.fragments,e.frag.start);if(N!=null&&N.gap)continue}}else{if(b===Tt.AUDIO_TRACK&&x===P.audioGroupId||b===Tt.SUBTITLE_TRACK&&x===P.textGroupId)continue;if(A===it.AUDIO&&n.audioGroupId===P.audioGroupId||A===it.SUBTITLE&&n.textGroupId===P.textGroupId)continue}h=w;break}}if(h>-1&&i.loadLevel!==h)return e.levelRetry=!0,this.playlistError=0,{action:Ii.SendAlternateToPenaltyBox,flags:dr.None,nextAutoLevel:h}}return{action:Ii.SendAlternateToPenaltyBox,flags:dr.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var i;switch((i=t.errorAction)==null?void 0:i.action){case Ii.DoNothing:break;case Ii.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==fe.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,i=e.errorAction;if(!i)return;const{flags:n,hdcpLevel:a,nextAutoLevel:l}=i;switch(n){case dr.None:this.switchLevel(e,l);break;case dr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(e));break;case dr.MoveAllAlternatesMatchingHDCP:a&&(t.maxHdcpLevel=$c[$c.indexOf(a)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(e,l)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:t,penalizedRenditions:i}=this,n=e.parent===it.MAIN?e.level:t.loadLevel,a=t.levels[n],l=a.url.length,h=e.frag?e.frag.urlId:a.urlId;a.urlId===h&&(!e.frag||a.details)&&this.penalizeRendition(a,e);for(let f=1;f<l;f++){const p=(h+f)%l,m=i[p];if(!m||Ry(m,e,i[h]))return this.warn(`Switching to Redundant Stream ${p+1}/${l}: "${a.url[p]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(g=>{g.urlId=p}),t.nextLoadLevel=n,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:i}=this,n=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(t),n.details=e.details,i[e.urlId]=n}}function Ry(r,e,t){if(performance.now()-r.lastErrorPerfMs>wy)return!0;const i=r.details;if(e.details===fe.FRAG_GAP&&i&&e.frag){const n=e.frag.start,a=Do(null,i.fragments,n);if(a&&!a.gap)return!0}if(t&&r.errors.length<t.errors.length){const n=r.errors[r.errors.length-1];if(i&&n.frag&&e.frag&&Math.abs(n.frag.start-e.frag.start)>i.targetduration*3)return!0}return!1}class Bc{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=q.log.bind(q,`${t}:`),this.warn=q.warn.bind(q,`${t}:`),this.hls=e}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(e,t){const i=t==null?void 0:t.renditionReports;if(i){let n=-1;for(let a=0;a<i.length;a++){const l=i[a];let h;try{h=new self.URL(l.URI,t.url).href}catch(f){q.warn(`Could not construct new URL for Rendition Report: ${f}`),h=l.URI||""}if(h===e){n=a;break}else h===e.substring(0,h.length)&&(n=a)}if(n!==-1){const a=i[n],l=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let h=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(t.age-t.partTarget,t.targetduration);h>=0&&f>t.partTarget&&(h+=1)}return new Hd(l,h>=0?h:void 0,Co.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,i){const{details:n,stats:a}=t,l=self.performance.now(),h=a.loading.first?Math.max(0,l-a.loading.first):0;if(n.advancedDateTime=Date.now()-h,n.live||i!=null&&i.live){if(n.reloaded(i),i&&this.log(`live playlist ${e} ${n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED"}`),i&&n.fragments.length>0&&gy(i,n),!this.canLoad||!n.live)return;let f,p,m;if(n.canBlockReload&&n.endSN&&n.advanced){const w=this.hls.config.lowLatencyMode,P=n.lastPartSn,$=n.endSN,N=n.lastPartIndex,I=N!==-1,O=P===$,K=w?0:N;I?(p=O?$+1:P,m=O?K:N+1):p=$+1;const U=n.age,re=U+n.ageHeader;let ne=Math.min(re-n.partTarget,n.targetduration*1.5);if(ne>0){if(i&&ne>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${ne} with playlist age: ${n.age}`),ne=0;else{const Y=Math.floor(ne/n.targetduration);if(p+=Y,m!==void 0){const Ee=Math.round(ne%n.targetduration/n.partTarget);m+=Ee}this.log(`CDN Tune-in age: ${n.ageHeader}s last advanced ${U.toFixed(2)}s goal: ${ne} skip sn ${Y} to part ${m}`)}n.tuneInGoal=ne}if(f=this.getDeliveryDirectives(n,t.deliveryDirectives,p,m),w||!O){this.loadPlaylist(f);return}}else(n.canBlockReload||n.canSkipUntil)&&(f=this.getDeliveryDirectives(n,t.deliveryDirectives,p,m));const g=this.hls.mainForwardBufferInfo,A=g?g.end-g.len:0,b=(n.edge-A)*1e3,x=Ey(n,b);n.updated&&l>this.requestScheduled+x&&(this.requestScheduled=a.loading.start),p!==void 0&&n.canBlockReload?this.requestScheduled=a.loading.first+x-(n.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+x<l?this.requestScheduled=l:this.requestScheduled-l<=0&&(this.requestScheduled+=x);let k=this.requestScheduled-l;k=Math.max(0,k),this.log(`reload live playlist ${e} in ${Math.round(k)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),k)}else this.clearTimer()}getDeliveryDirectives(e,t,i,n){let a=my(e,i);return t!=null&&t.skip&&e.deltaUpdateFailed&&(i=t.msn,n=t.part,a=Co.No),new Hd(i,n,a)}checkRetry(e){const t=e.details,i=Ka(e),n=e.errorAction,{action:a,retryCount:l=0,retryConfig:h}=n||{},f=!!n&&!!h&&(a===Ii.RetryRequest||!n.resolved&&a===Ii.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,l>=h.maxNumRetry)return!1;if(i&&(p=e.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${l+1}/${h.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const m=Nc(h,l);this.timer=self.setTimeout(()=>this.loadPlaylist(),m),this.warn(`Retrying playlist loading ${l+1}/${h.maxNumRetry} after "${t}" in ${m}ms`)}e.levelRetry=!0,n.resolved=!0}return f}}let Gc;class Ly extends Bc{constructor(e,t){super(e,"[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=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.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(e,t){this.resetLevels()}onManifestLoaded(e,t){const i=[],n={};let a;t.levels.forEach(l=>{var h;const f=l.attrs;((h=l.audioCodec)==null?void 0:h.indexOf("mp4a.40.34"))!==-1&&(Gc||(Gc=/chrome|firefox/i.test(navigator.userAgent)),Gc&&(l.audioCodec=void 0));const{AUDIO:p,CODECS:m,"FRAME-RATE":g,"PATHWAY-ID":A,RESOLUTION:b,SUBTITLES:x}=f,w=`${`${A||"."}-`}${l.bitrate}-${b}-${g}-${m}`;a=n[w],a?a.addFallback(l):(a=new Io(l),n[w]=a,i.push(a)),Ya(a,"audio",p),Ya(a,"text",x)}),this.filterAndSortMediaOptions(i,t)}filterAndSortMediaOptions(e,t){let i=[],n=[],a=!1,l=!1,h=!1,f=e.filter(({audioCodec:b,videoCodec:x,width:k,height:w,unknownCodecs:P})=>(a||(a=!!(k&&w)),l||(l=!!x),h||(h=!!b),!(P!=null&&P.length)&&(!b||Cc(b,"audio"))&&(!x||Cc(x,"video"))));if((a||l)&&h&&(f=f.filter(({videoCodec:b,width:x,height:k})=>!!b||!!(x&&k))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const b=new Error("no level with compatible codecs found in manifest");this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:b,reason:b.message})}});return}t.audioTracks&&(i=t.audioTracks.filter(b=>!b.audioCodec||Cc(b.audioCodec,"audio")),qd(i)),t.subtitles&&(n=t.subtitles,qd(n));const p=f.slice(0);f.sort((b,x)=>b.attrs["HDCP-LEVEL"]!==x.attrs["HDCP-LEVEL"]?(b.attrs["HDCP-LEVEL"]||"")>(x.attrs["HDCP-LEVEL"]||"")?1:-1:b.bitrate!==x.bitrate?b.bitrate-x.bitrate:b.attrs["FRAME-RATE"]!==x.attrs["FRAME-RATE"]?b.attrs.decimalFloatingPoint("FRAME-RATE")-x.attrs.decimalFloatingPoint("FRAME-RATE"):b.attrs.SCORE!==x.attrs.SCORE?b.attrs.decimalFloatingPoint("SCORE")-x.attrs.decimalFloatingPoint("SCORE"):a&&b.height!==x.height?b.height-x.height:0);let m=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let b=0;b<p.length;b++)if(p[b].pathwayId===f[0].pathwayId){m=p[b];break}}this._levels=f;for(let b=0;b<f.length;b++)if(f[b]===m){this._firstLevel=b,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${m.bitrate}`);break}const g=h&&!l,A={levels:f,audioTracks:i,subtitleTracks:n,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:h,video:l,altAudio:!g&&i.some(b=>!!b.url)};this.hls.trigger(_.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(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const m=new Error("invalid level idx"),g=e<0;if(this.hls.trigger(_.ERROR,{type:tt.OTHER_ERROR,details:fe.LEVEL_SWITCH_ERROR,level:e,fatal:g,error:m,reason:m.message}),g)return;e=Math.min(e,t.length-1)}const i=this.currentLevelIndex,n=this.currentLevel,a=n?n.attrs["PATHWAY-ID"]:void 0,l=t[e],h=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=l,i===e&&l.details&&n&&a===h)return;this.log(`Switching to level ${e}${h?" with Pathway "+h:""} from level ${i}${a?" with Pathway "+a:""}`);const f=ci({},l,{level:e,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(_.LEVEL_SWITCHING,f);const p=l.details;if(!p||p.live){const m=this.switchParams(l.uri,n==null?void 0:n.details);this.loadPlaylist(m)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===Tt.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===it.MAIN){const i=this._levels[t.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(e,t){var i;const{level:n,details:a}=t,l=this._levels[n];if(!l){var h;this.warn(`Invalid level index ${n}`),(h=t.deliveryDirectives)!=null&&h.skip&&(a.deltaUpdateFailed=!0);return}n===this.currentLevelIndex?(l.fragmentError===0&&(l.loadError=0),this.playlistLoaded(n,t,l.details)):(i=t.deliveryDirectives)!=null&&i.skip&&(a.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const i=this.currentLevel;if(!i)return;const n=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let a=-1;for(let l=0;l<i.audioGroupIds.length;l++)if(i.audioGroupIds[l]===n){a=l;break}a!==-1&&a!==i.urlId&&(i.urlId=a,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const n=i.urlId;let a=i.uri;if(e)try{a=e.addDirectives(a)}catch(h){this.warn(`Could not construct new URL with HLS Delivery Directives: ${h}`)}const l=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${l?" Pathway "+l:""} URI ${n+1}/${i.url.length} ${a}`),this.clearTimer(),this.hls.trigger(_.LEVEL_LOADING,{url:a,level:t,id:n,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){const i=(a,l)=>l!==t,n=this._levels.filter((a,l)=>l!==e?!0:a.url.length>1&&t!==void 0?(a.url=a.url.filter(i),a.audioGroupIds&&(a.audioGroupIds=a.audioGroupIds.filter(i)),a.textGroupIds&&(a.textGroupIds=a.textGroupIds.filter(i)),a.urlId=0,!0):(this.steering&&this.steering.removeLevel(a),!1));this.hls.trigger(_.LEVELS_UPDATED,{levels:n})}onLevelsUpdated(e,{levels:t}){t.forEach((i,n)=>{const{details:a}=i;a!=null&&a.fragments&&a.fragments.forEach(l=>{l.level=n})}),this._levels=t}}function Ya(r,e,t){t&&(e==="audio"?(r.audioGroupIds||(r.audioGroupIds=[]),r.audioGroupIds[r.url.length-1]=t):e==="text"&&(r.textGroupIds||(r.textGroupIds=[]),r.textGroupIds[r.url.length-1]=t))}function qd(r){const e={};r.forEach(t=>{const i=t.groupId||"";t.id=e[i]=e[i]||0,e[i]++})}var gi={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Cy{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(_.BUFFER_APPENDED,this.onBufferAppended,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.BUFFER_APPENDED,this.onBufferAppended,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const i=this.activePartLists[t];if(i)for(let n=i.length;n--;){const a=i[n];if(!a)break;const l=a.end;if(a.start<=e&&l!==null&&e<=l)return a}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:i}=this,n=Object.keys(i);for(let a=n.length;a--;){const l=i[n[a]];if((l==null?void 0:l.body.type)===t&&l.buffered){const h=l.body;if(h.start<=e&&e<=h.end)return h}}return null}detectEvictedFragments(e,t,i,n){this.timeRanges&&(this.timeRanges[e]=t);const a=(n==null?void 0:n.fragment.sn)||-1;Object.keys(this.fragments).forEach(l=>{const h=this.fragments[l];if(!h||a>=h.body.sn)return;if(!h.buffered&&!h.loaded){h.body.type===i&&this.removeFragment(h.body);return}const f=h.range[e];f&&f.time.some(p=>{const m=!this.isTimeBuffered(p.startPTS,p.endPTS,t);return m&&this.removeFragment(h.body),m})})}detectPartialFragments(e){const t=this.timeRanges,{frag:i,part:n}=e;if(!t||i.sn==="initSegment")return;const a=Ln(i),l=this.fragments[a];if(!l||l.buffered&&i.gap)return;const h=!i.relurl;Object.keys(t).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const m=t[f],g=h||p.partial===!0;l.range[f]=this.getBufferedTimes(i,n,g,m)}),l.loaded=null,Object.keys(l.range).length?(l.buffered=!0,(l.body.endList=i.endList||l.body.endList)&&(this.endListFragments[l.body.type]=l),Xa(l)||this.removeParts(i.sn-1,i.type)):this.removeFragment(l.body)}removeParts(e,t){const i=this.activePartLists[t];i&&(this.activePartLists[t]=i.filter(n=>n.fragment.sn>=e))}fragBuffered(e,t){const i=Ln(e);let n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(e,t,i,n){const a={time:[],partial:i},l=e.start,h=e.end,f=e.minEndPTS||h,p=e.maxStartPTS||l;for(let m=0;m<n.length;m++){const g=n.start(m)-this.bufferPadding,A=n.end(m)+this.bufferPadding;if(p>=g&&f<=A){a.time.push({startPTS:Math.max(l,n.start(m)),endPTS:Math.min(h,n.end(m))});break}else if(l<A&&h>g)a.partial=!0,a.time.push({startPTS:Math.max(l,n.start(m)),endPTS:Math.min(h,n.end(m))});else if(h<=g)break}return a}getPartialFragment(e){let t=null,i,n,a,l=0;const{bufferPadding:h,fragments:f}=this;return Object.keys(f).forEach(p=>{const m=f[p];m&&Xa(m)&&(n=m.body.start-h,a=m.body.end+h,e>=n&&e<=a&&(i=Math.min(e-n,a-e),l<=i&&(t=m.body,l=i)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Xa(t))}getState(e){const t=Ln(e),i=this.fragments[t];return i?i.buffered?Xa(i)?gi.PARTIAL:gi.OK:gi.APPENDING:gi.NOT_LOADED}isTimeBuffered(e,t,i){let n,a;for(let l=0;l<i.length;l++){if(n=i.start(l)-this.bufferPadding,a=i.end(l)+this.bufferPadding,e>=n&&t<=a)return!0;if(t<=n)return!1}return!1}onFragLoaded(e,t){const{frag:i,part:n}=t;if(i.sn==="initSegment"||i.bitrateTest)return;const a=n?null:t,l=Ln(i);this.fragments[l]={body:i,appendedPTS:null,loaded:a,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:i,part:n,timeRanges:a}=t;if(i.sn==="initSegment")return;const l=i.type;if(n){let h=this.activePartLists[l];h||(this.activePartLists[l]=h=[]),h.push(n)}this.timeRanges=a,Object.keys(a).forEach(h=>{const f=a[h];this.detectEvictedFragments(h,f,l,n)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Ln(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,i,n,a){n&&!this.hasGaps||Object.keys(this.fragments).forEach(l=>{const h=this.fragments[l];if(!h)return;const f=h.body;f.type!==i||n&&!f.gap||f.start<t&&f.end>e&&(h.buffered||a)&&this.removeFragment(f)})}removeFragment(e){const t=Ln(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const i=this.activePartLists[e.type];if(i){const n=e.sn;this.activePartLists[e.type]=i.filter(a=>a.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Xa(r){var e,t,i;return r.buffered&&(r.body.gap||((e=r.range.video)==null?void 0:e.partial)||((t=r.range.audio)==null?void 0:t.partial)||((i=r.range.audiovideo)==null?void 0:i.partial))}function Ln(r){return`${r.type}_${r.level}_${r.urlId}_${r.sn}`}const Qd=Math.pow(2,17);class Iy{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const i=e.url;if(!i)return Promise.reject(new ns({type:tt.NETWORK_ERROR,details:fe.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const n=this.config,a=n.fLoader,l=n.loader;return new Promise((h,f)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(b=>b[0]==="GAP")){f(ef(e));return}else e.gap=!1;const p=this.loader=e.loader=a?new a(n):new l(n),m=Jd(e),g=Xd(n.fragLoadPolicy.default),A={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Qd};e.stats=p.stats,p.load(m,A,{onSuccess:(b,x,k,w)=>{this.resetLoader(e,p);let P=b.data;k.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(P.slice(0,16)),P=P.slice(16)),h({frag:e,part:null,payload:P,networkDetails:w})},onError:(b,x,k,w)=>{this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Yi({url:i,data:void 0},b),error:new Error(`HTTP Error ${b.code} ${b.text}`),networkDetails:k,stats:w}))},onAbort:(b,x,k)=>{this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:k,stats:b}))},onTimeout:(b,x,k)=>{this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:k,stats:b}))},onProgress:(b,x,k,w)=>{t&&t({frag:e,part:null,payload:k,networkDetails:w})}})})}loadPart(e,t,i){this.abort();const n=this.config,a=n.fLoader,l=n.loader;return new Promise((h,f)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){f(ef(e,t));return}const p=this.loader=e.loader=a?new a(n):new l(n),m=Jd(e,t),g=Xd(n.fragLoadPolicy.default),A={loadPolicy:g,timeout:g.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Qd};t.stats=p.stats,p.load(m,A,{onSuccess:(b,x,k,w)=>{this.resetLoader(e,p),this.updateStatsFromPart(e,t);const P={frag:e,part:t,payload:b.data,networkDetails:w};i(P),h(P)},onError:(b,x,k,w)=>{this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Yi({url:m.url,data:void 0},b),error:new Error(`HTTP Error ${b.code} ${b.text}`),networkDetails:k,stats:w}))},onAbort:(b,x,k)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:k,stats:b}))},onTimeout:(b,x,k)=>{this.resetLoader(e,p),f(new ns({type:tt.NETWORK_ERROR,details:fe.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${A.timeout}ms`),networkDetails:k,stats:b}))}})})}updateStatsFromPart(e,t){const i=e.stats,n=t.stats,a=n.total;if(i.loaded+=n.loaded,a){const f=Math.round(e.duration/t.duration),p=Math.min(Math.round(i.loaded/a),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const l=i.loading,h=n.loading;l.start?l.first+=h.first-h.start:(l.start=h.start,l.first=h.first),l.end=h.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Jd(r,e=null){const t=e||r,i={frag:r,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},n=t.byteRangeStartOffset,a=t.byteRangeEndOffset;if(ze(n)&&ze(a)){var l;let h=n,f=a;if(r.sn==="initSegment"&&((l=r.decryptdata)==null?void 0:l.method)==="AES-128"){const p=a-n;p%16&&(f=a+(16-p%16)),n!==0&&(i.resetIV=!0,h=n-16)}i.rangeStart=h,i.rangeEnd=f}return i}function ef(r,e){const t=new Error(`GAP ${r.gap?"tag":"attribute"} found`),i={type:tt.MEDIA_ERROR,details:fe.FRAG_GAP,fatal:!1,frag:r,error:t,networkDetails:null};return e&&(i.part=e),(e||r).stats.aborted=!0,new ns(i)}class ns extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Dy{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[t].loader;if(i){if(e&&e!==i.context.frag.type)return;i.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=fe.KEY_LOAD_ERROR,i,n,a){return new ns({type:tt.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:a,error:i,networkDetails:n})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:n}=e;for(let a=0;a<t.length;a++){const l=t[a];if(n<=l.cc&&(i==="initSegment"||l.sn==="initSegment"||i<l.sn)){this.emeController.selectKeySystemFormat(l).then(h=>{l.setKeyFormat(h)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var i,n;t&&e.setKeyFormat(t);const a=e.decryptdata;if(!a){const p=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,fe.KEY_LOAD_ERROR,p))}const l=a.uri;if(!l)return Promise.reject(this.createKeyLoadError(e,fe.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${l}"`)));let h=this.keyUriToKeyInfo[l];if((i=h)!=null&&i.decryptdata.key)return a.key=h.decryptdata.key,Promise.resolve({frag:e,keyInfo:h});if((n=h)!=null&&n.keyLoadPromise){var f;switch((f=h.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return h.keyLoadPromise.then(p=>(a.key=p.keyInfo.decryptdata.key,{frag:e,keyInfo:h}))}}switch(h=this.keyUriToKeyInfo[l]={decryptdata:a,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},a.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return a.keyFormat==="identity"?this.loadKeyHTTP(h,e):this.loadKeyEME(h,e);case"AES-128":return this.loadKeyHTTP(h,e);default:return Promise.reject(this.createKeyLoadError(e,fe.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${a.method}"`)))}}loadKeyEME(e,t){const i={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const n=this.emeController.loadKey(i);if(n)return(e.keyLoadPromise=n.then(a=>(e.mediaKeySessionContext=a,i))).catch(a=>{throw e.keyLoadPromise=null,a})}return Promise.resolve(i)}loadKeyHTTP(e,t){const i=this.config,n=i.loader,a=new n(i);return t.keyLoader=e.loader=a,e.keyLoadPromise=new Promise((l,h)=>{const f={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},p=i.keyLoadPolicy.default,m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(A,b,x,k)=>{const{frag:w,keyInfo:P,url:$}=x;if(!w.decryptdata||P!==this.keyUriToKeyInfo[$])return h(this.createKeyLoadError(w,fe.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),k));P.decryptdata.key=w.decryptdata.key=new Uint8Array(A.data),w.keyLoader=null,P.loader=null,l({frag:w,keyInfo:P})},onError:(A,b,x,k)=>{this.resetLoader(b),h(this.createKeyLoadError(t,fe.KEY_LOAD_ERROR,new Error(`HTTP Error ${A.code} loading key ${A.text}`),x,Yi({url:f.url,data:void 0},A)))},onTimeout:(A,b,x)=>{this.resetLoader(b),h(this.createKeyLoadError(t,fe.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),x))},onAbort:(A,b,x)=>{this.resetLoader(b),h(this.createKeyLoadError(t,fe.INTERNAL_ABORTED,new Error("key loading aborted"),x))}};a.load(f,m,g)})}resetLoader(e){const{frag:t,keyInfo:i,url:n}=e,a=i.loader;t.keyLoader===a&&(t.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[n],a&&a.destroy()}}class Oy{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!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 Py={length:0,start:()=>0,end:()=>0};class Nt{static isBuffered(e,t){try{if(e){const i=Nt.getBuffered(e);for(let n=0;n<i.length;n++)if(t>=i.start(n)&&t<=i.end(n))return!0}}catch{}return!1}static bufferInfo(e,t,i){try{if(e){const n=Nt.getBuffered(e),a=[];let l;for(l=0;l<n.length;l++)a.push({start:n.start(l),end:n.end(l)});return this.bufferedInfo(a,t,i)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,i){t=Math.max(0,t),e.sort(function(p,m){const g=p.start-m.start;return g||m.end-p.end});let n=[];if(i)for(let p=0;p<e.length;p++){const m=n.length;if(m){const g=n[m-1].end;e[p].start-g<i?e[p].end>g&&(n[m-1].end=e[p].end):n.push(e[p])}else n.push(e[p])}else n=e;let a=0,l,h=t,f=t;for(let p=0;p<n.length;p++){const m=n[p].start,g=n[p].end;if(t+i>=m&&t<g)h=m,f=g,a=f-t;else if(t+i<m){l=m;break}}return{len:a,start:h||0,end:f||0,nextStart:l}}static getBuffered(e){try{return e.buffered}catch(t){return q.log("failed to get media.buffered",t),Py}}}class Vc{constructor(e,t,i,n=0,a=-1,l=!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=Za(),this.buffering={audio:Za(),video:Za(),audiovideo:Za()},this.level=e,this.sn=t,this.id=i,this.size=n,this.part=a,this.partial=l}}function Za(){return{start:0,executeStart:0,executeEnd:0,end:0}}function tf(r,e){let t=null;for(let i=0,n=r.length;i<n;i++){const a=r[i];if(a&&a.cc===e){t=a;break}}return t}function $y(r,e,t){return!!(e.details&&(t.endCC>t.startCC||r&&r.cc<t.startCC))}function Fy(r,e,t=0){const i=r.fragments,n=e.fragments;if(!n.length||!i.length){q.log("No fragments to align");return}const a=tf(i,n[0].cc);if(!a||a&&!a.startPTS){q.log("No frag in previous level to align on");return}return a}function rf(r,e){if(r){const t=r.start+e;r.start=r.startPTS=t,r.endPTS=t+r.duration}}function Hc(r,e){const t=e.fragments;for(let i=0,n=t.length;i<n;i++)rf(t[i],r);e.fragmentHint&&rf(e.fragmentHint,r),e.alignedSliding=!0}function My(r,e,t){e&&(Ny(r,t,e),!t.alignedSliding&&e.details&&Uy(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&jd(e.details,t))}function Ny(r,e,t){if($y(r,t,e)){const i=Fy(t.details,e);i&&ze(i.start)&&(q.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Hc(i.start,e))}}function Uy(r,e){if(!e.fragments.length||!r.hasProgramDateTime||!e.hasProgramDateTime)return;const t=e.fragments[0].programDateTime,i=r.fragments[0].programDateTime,n=(i-t)/1e3+e.fragments[0].start;n&&ze(n)&&(q.log(`Adjusting PTS using programDateTime delta ${i-t}ms, sliding:${n.toFixed(3)} ${r.url} `),Hc(n,r))}function sf(r,e){if(!r.hasProgramDateTime||!e.hasProgramDateTime)return;const t=r.fragments,i=e.fragments;if(!t.length||!i.length)return;const n=Math.round(i.length/2)-1,a=i[n],l=tf(t,a.cc)||t[Math.round(t.length/2)-1],h=a.programDateTime,f=l.programDateTime;if(h===null||f===null)return;const p=(f-h)/1e3-(l.start-a.start);Hc(p,r)}class By{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Gy{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Vy(r){const e=r.byteLength,t=e&&new DataView(r.buffer).getUint8(e-1);return t?un(r,0,e-t):r}class Hy{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),i=new Uint32Array(4);for(let n=0;n<4;n++)i[n]=t.getUint32(n*4);return i}initTable(){const e=this.sBox,t=this.invSBox,i=this.subMix,n=i[0],a=i[1],l=i[2],h=i[3],f=this.invSubMix,p=f[0],m=f[1],g=f[2],A=f[3],b=new Uint32Array(256);let x=0,k=0,w=0;for(w=0;w<256;w++)w<128?b[w]=w<<1:b[w]=w<<1^283;for(w=0;w<256;w++){let P=k^k<<1^k<<2^k<<3^k<<4;P=P>>>8^P&255^99,e[x]=P,t[P]=x;const $=b[x],N=b[$],I=b[N];let O=b[P]*257^P*16843008;n[x]=O<<24|O>>>8,a[x]=O<<16|O>>>16,l[x]=O<<8|O>>>24,h[x]=O,O=I*16843009^N*65537^$*257^x*16843008,p[P]=O<<24|O>>>8,m[P]=O<<16|O>>>16,g[P]=O<<8|O>>>24,A[P]=O,x?(x=$^b[b[b[I^$]]],k^=b[b[k]]):x=k=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let i=!0,n=0;for(;n<t.length&&i;)i=t[n]===this.key[n],n++;if(i)return;this.key=t;const a=this.keySize=t.length;if(a!==4&&a!==6&&a!==8)throw new Error("Invalid aes key size="+a);const l=this.ksRows=(a+6+1)*4;let h,f;const p=this.keySchedule=new Uint32Array(l),m=this.invKeySchedule=new Uint32Array(l),g=this.sBox,A=this.rcon,b=this.invSubMix,x=b[0],k=b[1],w=b[2],P=b[3];let $,N;for(h=0;h<l;h++){if(h<a){$=p[h]=t[h];continue}N=$,h%a===0?(N=N<<8|N>>>24,N=g[N>>>24]<<24|g[N>>>16&255]<<16|g[N>>>8&255]<<8|g[N&255],N^=A[h/a|0]<<24):a>6&&h%a===4&&(N=g[N>>>24]<<24|g[N>>>16&255]<<16|g[N>>>8&255]<<8|g[N&255]),p[h]=$=(p[h-a]^N)>>>0}for(f=0;f<l;f++)h=l-f,f&3?N=p[h]:N=p[h-4],f<4||h<=4?m[f]=N:m[f]=x[g[N>>>24]]^k[g[N>>>16&255]]^w[g[N>>>8&255]]^P[g[N&255]],m[f]=m[f]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,i){const n=this.keySize+6,a=this.invKeySchedule,l=this.invSBox,h=this.invSubMix,f=h[0],p=h[1],m=h[2],g=h[3],A=this.uint8ArrayToUint32Array_(i);let b=A[0],x=A[1],k=A[2],w=A[3];const P=new Int32Array(e),$=new Int32Array(P.length);let N,I,O,K,U,re,ne,Y,Ee,ce,_e,Oe,B,W;const we=this.networkToHostOrderSwap;for(;t<P.length;){for(Ee=we(P[t]),ce=we(P[t+1]),_e=we(P[t+2]),Oe=we(P[t+3]),U=Ee^a[0],re=Oe^a[1],ne=_e^a[2],Y=ce^a[3],B=4,W=1;W<n;W++)N=f[U>>>24]^p[re>>16&255]^m[ne>>8&255]^g[Y&255]^a[B],I=f[re>>>24]^p[ne>>16&255]^m[Y>>8&255]^g[U&255]^a[B+1],O=f[ne>>>24]^p[Y>>16&255]^m[U>>8&255]^g[re&255]^a[B+2],K=f[Y>>>24]^p[U>>16&255]^m[re>>8&255]^g[ne&255]^a[B+3],U=N,re=I,ne=O,Y=K,B=B+4;N=l[U>>>24]<<24^l[re>>16&255]<<16^l[ne>>8&255]<<8^l[Y&255]^a[B],I=l[re>>>24]<<24^l[ne>>16&255]<<16^l[Y>>8&255]<<8^l[U&255]^a[B+1],O=l[ne>>>24]<<24^l[Y>>16&255]<<16^l[U>>8&255]<<8^l[re&255]^a[B+2],K=l[Y>>>24]<<24^l[U>>16&255]<<16^l[re>>8&255]<<8^l[ne&255]^a[B+3],$[t]=we(N^b),$[t+1]=we(K^x),$[t+2]=we(O^k),$[t+3]=we(I^w),b=Ee,x=ce,k=_e,w=Oe,t=t+4}return $.buffer}}const Wy=16;class Wc{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const 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:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const i=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?Vy(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,i){return this.useSoftware?new Promise((n,a)=>{this.softwareDecrypt(new Uint8Array(e),t,i);const l=this.flush();l?n(l.buffer):a(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,i)}softwareDecrypt(e,t,i){const{currentIV:n,currentResult:a,remainderData:l}=this;this.logOnce("JS AES decrypt"),l&&(e=hn(l,e),this.remainderData=null);const h=this.getValidChunk(e);if(!h.length)return null;n&&(i=n);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new Hy),f.expandKey(t);const p=a;return this.currentResult=f.decrypt(h.buffer,0,i),this.currentIV=un(h,-16).buffer,p||null}webCryptoDecrypt(e,t,i){const n=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Gy(n,t)),this.fastAesKey.expandKey().then(a=>n?(this.logOnce("WebCrypto AES decrypt"),new By(n,new Uint8Array(i)).decrypt(e.buffer,a)):Promise.reject(new Error("web crypto not initialized"))).catch(a=>(q.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${a.name}: ${a.message}`),this.onWebCryptoError(e,t,i)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);const n=this.flush();if(n)return n.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const i=e.length-e.length%Wy;return i!==e.length&&(t=un(e,0,i),this.remainderData=un(e,i)),t}logOnce(e){this.logEnabled&&(q.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const jy={toString:function(r){let e="";const t=r.length;for(let i=0;i<t;i++)e+=`[${r.start(i).toFixed(3)}-${r.end(i).toFixed(3)}]`;return e}},Se={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 jc extends Oy{constructor(e,t,i,n,a){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Se.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=a,this.logPrefix=n,this.log=q.log.bind(q,`${n}:`),this.warn=q.warn.bind(q,`${n}:`),this.hls=e,this.fragmentLoader=new Iy(e.config),this.keyLoader=i,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Wc(e.config),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Se.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const i=t.partList;if(i!=null&&i.length){const a=i[i.length-1];return Nt.isBuffered(this.media,a.start+a.duration/2)}const n=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(n)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){const i=this.media=this.mediaBuffer=t.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===Se.STOPPED&&this.startLoad(n.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:i,mediaBuffer:n,state:a}=this,l=i?i.currentTime:0,h=Nt.bufferInfo(n||i,l,e.maxBufferHole);if(this.log(`media seeking to ${ze(l)?l.toFixed(3):l}, state: ${a}`),this.state===Se.ENDED)this.resetLoadingState();else if(t){const f=e.maxFragLookUpTolerance,p=t.start-f,m=t.start+t.duration+f;if(!h.len||m<h.start||p>h.end){const g=l>m;(l<p||g)&&(g&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(l,1/0,this.playlistType,!0),this.lastCurrentTime=l),!this.loadedmetadata&&!h.len&&(this.nextLoadPosition=this.startPosition=l),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Se.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(e,t,i){this._loadFragForPlayback(e,t,i)}_loadFragForPlayback(e,t,i){const n=a=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${a.part?" p: "+a.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(a)};this._doFragLoad(e,t,i,n).then(a=>{if(!a)return;const l=this.state;if(this.fragContextChanged(e)){(l===Se.FRAG_LOADING||!this.fragCurrent&&l===Se.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=Se.IDLE);return}"payload"in a&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(_.FRAG_LOADED,a)),this._handleFragmentLoadComplete(a)}).catch(a=>{this.state===Se.STOPPED||this.state===Se.ERROR||(this.warn(a),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:i}=this;if(i.getState(e)===gi.APPENDING){const a=e.type,l=this.getFwdBufferInfo(this.mediaBuffer,a),h=Math.max(e.duration,l?l.len:this.config.maxBufferLength);this.reduceMaxBufferLength(h)&&i.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===gi.PARTIAL&&i.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,i=null){if(!(e-t))return;const n={startOffset:e,endOffset:t,type:i};this.hls.trigger(_.BUFFER_FLUSHING,n)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(i=>{if(!i||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:n}=this,{payload:a}=i,l=e.decryptdata;if(a&&a.byteLength>0&&l&&l.key&&l.iv&&l.method==="AES-128"){const h=self.performance.now();return this.decrypter.decrypt(new Uint8Array(a),l.key.buffer,l.iv.buffer).catch(f=>{throw n.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:e}),f}).then(f=>{const p=self.performance.now();return n.trigger(_.FRAG_DECRYPTED,{frag:e,payload:f,stats:{tstart:h,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:n,hls:a,levels:l}=this;if(!l)throw new Error("init load aborted, missing levels");const h=e.stats;this.state=Se.IDLE,t.fragmentError=0,e.data=new Uint8Array(i.payload),h.parsing.start=h.buffering.start=self.performance.now(),h.parsing.end=h.buffering.end=self.performance.now(),i.frag===n&&a.trigger(_.FRAG_BUFFERED,{stats:h,frag:n,part:null,id:e.type}),this.tick()}).catch(i=>{this.state===Se.STOPPED||this.state===Se.ERROR||(this.warn(i),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var i,n,a,l;const h=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===it.MAIN?"level":"track"} ${e.level} (frag:[${((i=e.startPTS)!=null?i:NaN).toFixed(3)}-${((n=e.endPTS)!=null?n:NaN).toFixed(3)}] > buffer:${h?jy.toString(Nt.getBuffered(h)):"(detached)"})`),this.state=Se.IDLE,h&&(!this.loadedmetadata&&e.type==it.MAIN&&h.buffered.length&&((a=this.fragCurrent)==null?void 0:a.sn)===((l=this.fragPrevious)==null?void 0:l.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:i,part:n,partsLoaded:a}=e,l=!a||a.length===0||a.some(f=>!f),h=new Vc(i.level,i.sn,i.stats.chunkCount+1,0,n?n.index:-1,!l);t.flush(h)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,i=null,n){var a;const l=t==null?void 0:t.details;if(!this.levels||!l)throw new Error(`frag load aborted, missing level${l?"":" detail"}s`);let h=null;if(e.encrypted&&!((a=e.decryptdata)!=null&&a.key)?(this.log(`Loading key for ${e.sn} of [${l.startSN}-${l.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=Se.KEY_LOADING,this.fragCurrent=e,h=this.keyLoader.load(e).then(m=>{if(!this.fragContextChanged(m.frag))return this.hls.trigger(_.KEY_LOADED,m),this.state===Se.KEY_LOADING&&(this.state=Se.IDLE),m}),this.hls.trigger(_.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(h=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&l.encryptedFragments.length&&this.keyLoader.loadClear(e,l.encryptedFragments),i=Math.max(e.start,i||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const m=l.partList;if(m&&n){i>e.end&&l.fragmentHint&&(e=l.fragmentHint);const g=this.getNextPart(m,e,i);if(g>-1){const A=m[g];this.log(`Loading part sn: ${e.sn} p: ${A.index} cc: ${e.cc} of playlist [${l.startSN}-${l.endSN}] parts [0-${g}-${m.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=A.start+A.duration,this.state=Se.FRAG_LOADING;let b;return h?b=h.then(x=>!x||this.fragContextChanged(x.frag)?null:this.doFragPartsLoad(e,A,t,n)).catch(x=>this.handleFragLoadError(x)):b=this.doFragPartsLoad(e,A,t,n).catch(x=>this.handleFragLoadError(x)),this.hls.trigger(_.FRAG_LOADING,{frag:e,part:A,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):b}else if(!e.url||this.loadedEndOfParts(m,i))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${l?"of ["+l.startSN+"-"+l.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(i.toFixed(3))}`),ze(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=Se.FRAG_LOADING;const f=this.config.progressive;let p;return f&&h?p=h.then(m=>!m||this.fragContextChanged(m==null?void 0:m.frag)?null:this.fragmentLoader.load(e,n)).catch(m=>this.handleFragLoadError(m)):p=Promise.all([this.fragmentLoader.load(e,f?n:void 0),h]).then(([m])=>(!f&&m&&n&&n(m),m)).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(_.FRAG_LOADING,{frag:e,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(e,t,i,n){return new Promise((a,l)=>{var h;const f=[],p=(h=i.details)==null?void 0:h.partList,m=g=>{this.fragmentLoader.loadPart(e,g,n).then(A=>{f[g.index]=A;const b=A.part;this.hls.trigger(_.FRAG_LOADED,A);const x=Kd(i,e.sn,g.index+1)||zd(p,e.sn,g.index+1);if(x)m(x);else return a({frag:e,part:b,partsLoaded:f})}).catch(l)};m(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===fe.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(_.ERROR,t)}else this.hls.trigger(_.ERROR,{type:tt.OTHER_ERROR,details:fe.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==Se.PARSING){!this.fragCurrent&&this.state!==Se.STOPPED&&this.state!==Se.ERROR&&(this.state=Se.IDLE);return}const{frag:i,part:n,level:a}=t,l=self.performance.now();i.stats.parsing.end=l,n&&(n.stats.parsing.end=l),this.updateLevelTiming(i,n,a,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:i}=this,{level:n,sn:a,part:l}=e;if(!(t!=null&&t[n]))return this.warn(`Levels object was unset while buffering fragment ${a} of level ${n}. The current chunk will not be buffered.`),null;const h=t[n],f=l>-1?Kd(h,a,l):null,p=f?f.fragment:by(h,a,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:h}):null}bufferFragmentData(e,t,i,n,a){var l;if(!e||this.state!==Se.PARSING)return;const{data1:h,data2:f}=e;let p=h;if(h&&f&&(p=hn(h,f)),!((l=p)!=null&&l.length))return;const m={type:e.type,frag:t,part:i,chunkMeta:n,parent:t.type,data:p};if(this.hls.trigger(_.BUFFER_APPENDING,m),e.dropped&&e.independent&&!i){if(a)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Nt.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const i=t.currentTime,n=Nt.bufferInfo(t,i,0),a=e.duration,l=Math.min(this.config.maxFragLookUpTolerance*2,a*.25),h=Math.max(Math.min(e.start-l,n.end-l),i+l);e.start-h>l&&this.flushMainBuffer(h,e.start)}getFwdBufferInfo(e,t){const i=this.getLoadPosition();return ze(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){const{config:{maxBufferHole:n}}=this,a=Nt.bufferInfo(e,t,n);if(a.len===0&&a.nextStart!==void 0){const l=this.fragmentTracker.getBufferedFrag(t,i);if(l&&a.nextStart<l.end)return Nt.bufferInfo(e,t,Math.max(a.nextStart,n))}return a}getMaxBufferLength(e){const{config:t}=this;let i;return e?i=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):i=t.maxBufferLength,Math.min(i,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,i=e||t.maxBufferLength;return t.maxMaxBufferLength>=i?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=it.MAIN){const i=this.fragmentTracker.getAppendedFrag(e,it.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(e,t){const i=t.fragments,n=i.length;if(!n)return null;const{config:a}=this,l=i[0].start;let h;if(t.live){const f=a.initialLiveManifestSize;if(n<f)return this.warn(`Not enough fragments to start playback (have: ${n}, need: ${f})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(h=this.getInitialLiveFragment(t,i),this.startPosition=h?this.hls.liveSyncPosition||h.start:e)}else e<=l&&(h=i[0]);if(!h){const f=a.lowLatencyMode?t.partEnd:t.fragmentEnd;h=this.getFragmentAtPosition(e,f,t)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(e,t){const i=this.fragmentTracker.getState(e);return(i===gi.OK||i===gi.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,i,n,a){const l=e.gap,h=this.getNextFragment(this.nextLoadPosition,t);if(h===null)return h;if(e=h,l&&e&&!e.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,n);if(f!==null&&i.len+f.len>=a)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,i){let n=-1,a=!1,l=!0;for(let h=0,f=e.length;h<f;h++){const p=e[h];if(l=l&&!p.independent,n>-1&&i<p.start)break;const m=p.loaded;m?n=-1:(a||p.independent||l)&&p.fragment===t&&(n=h),a=m}return n}loadedEndOfParts(e,t){const i=e[e.length-1];return i&&t>i.start&&i.loaded}getInitialLiveFragment(e,t){const i=this.fragPrevious;let n=null;if(i){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),n=Ty(t,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!n){const a=i.sn+1;if(a>=e.startSN&&a<=e.endSN){const l=t[a-e.startSN];i.cc===l.cc&&(n=l,this.log(`Live playlist, switching playlist, load frag with next SN: ${n.sn}`))}n||(n=Sy(t,i.cc),n&&this.log(`Live playlist, switching playlist, load frag with same CC: ${n.sn}`))}}else{const a=this.hls.liveSyncPosition;a!==null&&(n=this.getFragmentAtPosition(a,this.bitrateTest?e.fragmentEnd:e.edge,e))}return n}getFragmentAtPosition(e,t,i){const{config:n}=this;let{fragPrevious:a}=this,{fragments:l,endSN:h}=i;const{fragmentHint:f}=i,p=n.maxFragLookUpTolerance,m=i.partList,g=!!(n.lowLatencyMode&&m!=null&&m.length&&f);g&&f&&!this.bitrateTest&&(l=l.concat(f),h=f.sn);let A;if(e<t){const b=e>t-p?0:p;A=Do(a,l,e,b)}else A=l[l.length-1];if(A){const b=A.sn-i.startSN,x=this.fragmentTracker.getState(A);if((x===gi.OK||x===gi.PARTIAL&&A.gap)&&(a=A),a&&A.sn===a.sn&&(!g||m[0].fragment.sn>A.sn)&&a&&A.level===a.level){const w=l[b+1];A.sn<h&&this.fragmentTracker.getState(w)!==gi.OK?A=w:A=null}}return A}synchronizeToLiveEdge(e){const{config:t,media:i}=this;if(!i)return;const n=this.hls.liveSyncPosition,a=i.currentTime,l=e.fragments[0].start,h=e.edge,f=a>=l-t.maxFragLookUpTolerance&&a<=h;if(n!==null&&i.duration>n&&(a<n||!f)){const p=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!f&&i.readyState<4||a<h-p)&&(this.loadedmetadata||(this.nextLoadPosition=n),i.readyState&&(this.warn(`Playback: ${a.toFixed(3)} is located too far from the end of live sliding playlist: ${h}, reset currentTime to : ${n.toFixed(3)}`),i.currentTime=n))}}alignPlaylists(e,t){const{levels:i,levelLastLoaded:n,fragPrevious:a}=this,l=n!==null?i[n]:null,h=e.fragments.length;if(!h)return this.warn("No fragments in live playlist"),0;const f=e.fragments[0].start,p=!t,m=e.alignedSliding&&ze(f);if(p||!m&&!f){My(a,l,e);const g=e.fragments[0].start;return this.log(`Live playlist sliding: ${g.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${a?a.sn:"na"} fragments: ${h}`),g}return f}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let i=this.startPosition;if(i<t&&(i=-1),i===-1||this.lastCurrentTime===-1){const n=this.startTimeOffset!==null,a=n?this.startTimeOffset:e.startTimeOffset;a!==null&&ze(a)?(i=t+a,a<0&&(i+=e.totalduration),i=Math.min(Math.max(t,i),t+e.totalduration),this.log(`Start time offset ${a} found in ${n?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):e.live?i=this.hls.liveSyncPosition||t:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==Se.FRAG_LOADING_WAITING_RETRY)&&(this.state=Se.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const g=this.getCurrentContext(t.chunkMeta);g&&(t.frag=g.frag)}const i=t.frag;if(!i||i.type!==e||!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 a=t.details===fe.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);const l=t.errorAction,{action:h,retryCount:f=0,retryConfig:p}=l||{};if(l&&h===Ii.RetryRequest&&p){var m;this.resetStartWhenNotLoaded((m=this.levelLastLoaded)!=null?m:i.level);const g=Nc(p,f);this.warn(`Fragment ${i.sn} of ${e} ${i.level} errored with ${t.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${g}ms`),l.resolved=!0,this.retryDate=self.performance.now()+g,this.state=Se.FRAG_LOADING_WAITING_RETRY}else p&&l?(this.resetFragmentErrors(e),f<p.maxNumRetry?a||(l.resolved=!0):q.warn(`${t.details} reached or exceeded max retry (${f})`)):(l==null?void 0:l.action)===Ii.SendAlternateToPenaltyBox?this.state=Se.WAITING_LEVEL:this.state=Se.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===Se.PARSING||this.state===Se.PARSED){const t=e.parent,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=i&&i.len>.5;n&&this.reduceMaxBufferLength(i.len);const a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===it.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Se.STOPPED&&(this.state=Se.IDLE)}afterBufferFlushed(e,t,i){if(!e)return;const n=Nt.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,n,i),this.state===Se.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Se.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,i,n){var a;const l=i.details;if(!l){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((f,p)=>{const m=e.elementaryStreams[p];if(m){const g=m.endPTS-m.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${e.sn} ${p} duration reliably (${g})`),f||!1;const A=n?0:Wd(l,e,m.startPTS,m.endPTS,m.startDTS,m.endDTS);return this.hls.trigger(_.LEVEL_PTS_UPDATED,{details:l,level:i,drift:A,type:p,frag:e,start:m.startPTS,end:m.endPTS}),!0}return f},!1))i.fragmentError=0;else if(((a=this.transmuxer)==null?void 0:a.error)===null){const f=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(f.message),this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,fatal:!1,error:f,frag:e,reason:`Found no media in msn ${e.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Se.PARSED,this.hls.trigger(_.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,i,n;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(i=this.levelLastLoaded)!=null?i:(n=this.fragCurrent)==null?void 0:n.level)!=null?t:0),this.resetLoadingState()}}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function nf(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ky(){const r=Wa();if(!r)return!1;const e=nf(),t=r&&typeof r.isTypeSupported=="function"&&r.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!i}function zy(){var r;const e=nf();return typeof(e==null||(r=e.prototype)==null?void 0:r.changeType)=="function"}function Yy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Xy(){const r=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(r);return{worker:new self.Worker(e),objectURL:e}}function Zy(r){const e=new self.URL(r,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function Nr(r="",e=9e4){return{type:r,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class of{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=hn(this.cachedData,e),this.cachedData=null);let i=Ba(e,0),n=i?i.length:0,a;const l=this._audioTrack,h=this._id3Track,f=i?Dv(i):void 0,p=e.length;for((this.basePTS===null||this.frameIndex===0&&ze(f))&&(this.basePTS=qy(f,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&h.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:wr.audioId3,duration:Number.POSITIVE_INFINITY});n<p;){if(this.canParse(e,n)){const m=this.appendFrame(l,e,n);m?(this.frameIndex++,this.lastPTS=m.sample.pts,n+=m.length,a=n):n=p}else Iv(e,n)?(i=Ba(e,n),h.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:wr.audioId3,duration:Number.POSITIVE_INFINITY}),n+=i.length,a=n):n++;if(n===p&&a!==p){const m=un(e,a);this.cachedData?this.cachedData=hn(this.cachedData,m):this.cachedData=m}}return{audioTrack:l,videoTrack:Nr(),id3Track:h,textTrack:Nr()}}demuxSampleAes(e,t,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Nr(),id3Track:this._id3Track,textTrack:Nr()}}destroy(){}}const qy=(r,e,t)=>{if(ze(r))return r*90;const i=t?t.baseTime*9e4/t.timescale:0;return e*9e4+i};function Qy(r,e,t,i){let n,a,l,h;const f=navigator.userAgent.toLowerCase(),p=i,m=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((e[t+2]&192)>>>6)+1;const g=(e[t+2]&60)>>>2;if(g>m.length-1){r.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${g}`});return}return l=(e[t+2]&1)<<2,l|=(e[t+3]&192)>>>6,q.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${g}`),/firefox/i.test(f)?g>=6?(n=5,h=new Array(4),a=g-3):(n=2,h=new Array(2),a=g):f.indexOf("android")!==-1?(n=2,h=new Array(2),a=g):(n=5,h=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&g>=6?a=g-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(g>=6&&l===1||/vivaldi/i.test(f))||!i&&l===1)&&(n=2,h=new Array(2)),a=g)),h[0]=n<<3,h[0]|=(g&14)>>1,h[1]|=(g&1)<<7,h[1]|=l<<3,n===5&&(h[1]|=(a&14)>>1,h[2]=(a&1)<<7,h[2]|=8,h[3]=0),{config:h,samplerate:m[g],channelCount:l,codec:"mp4a.40."+n,manifestCodec:p}}function af(r,e){return r[e]===255&&(r[e+1]&246)===240}function lf(r,e){return r[e+1]&1?7:9}function Kc(r,e){return(r[e+3]&3)<<11|r[e+4]<<3|(r[e+5]&224)>>>5}function Jy(r,e){return e+5<r.length}function qa(r,e){return e+1<r.length&&af(r,e)}function eA(r,e){return Jy(r,e)&&af(r,e)&&Kc(r,e)<=r.length-e}function tA(r,e){if(qa(r,e)){const t=lf(r,e);if(e+t>=r.length)return!1;const i=Kc(r,e);if(i<=t)return!1;const n=e+i;return n===r.length||qa(r,n)}return!1}function cf(r,e,t,i,n){if(!r.samplerate){const a=Qy(e,t,i,n);if(!a)return;r.config=a.config,r.samplerate=a.samplerate,r.channelCount=a.channelCount,r.codec=a.codec,r.manifestCodec=a.manifestCodec,q.log(`parsed codec:${r.codec}, rate:${a.samplerate}, channels:${a.channelCount}`)}}function uf(r){return 9216e4/r}function iA(r,e){const t=lf(r,e);if(e+t<=r.length){const i=Kc(r,e)-t;if(i>0)return{headerLength:t,frameLength:i}}}function hf(r,e,t,i,n){const a=uf(r.samplerate),l=i+n*a,h=iA(e,t);let f;if(h){const{frameLength:g,headerLength:A}=h,b=A+g,x=Math.max(0,t+b-e.length);x?(f=new Uint8Array(b-A),f.set(e.subarray(t+A,e.length),0)):f=e.subarray(t+A,t+b);const k={unit:f,pts:l};return x||r.samples.push(k),{sample:k,length:b,missing:x}}const p=e.length-t;return f=new Uint8Array(p),f.set(e.subarray(t,e.length),0),{sample:{unit:f,pts:l},length:p,missing:-1}}class rA extends of{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Ba(e,0)||[]).length;for(let n=e.length;i<n;i++)if(tA(e,i))return q.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return eA(e,t)}appendFrame(e,t,i){cf(e,this.observer,t,i,e.manifestCodec);const n=hf(e,t,i,this.basePTS,this.frameIndex);if(n&&n.missing===0)return n}}const sA=/\/emsg[-/]ID3/i;class nA{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,i,n){const a=this.videoTrack=Nr("video",1),l=this.audioTrack=Nr("audio",1),h=this.txtTrack=Nr("text",1);if(this.id3Track=Nr("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const f=xd(e);if(f.video){const{id:p,timescale:m,codec:g}=f.video;a.id=p,a.timescale=h.timescale=m,a.codec=g}if(f.audio){const{id:p,timescale:m,codec:g}=f.audio;l.id=p,l.timescale=m,l.codec=g}h.id=Ad.text,a.sampleDuration=0,a.duration=l.duration=n}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,bt(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let i=e;const n=this.videoTrack,a=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=hn(this.remainderData,e));const h=zv(i);this.remainderData=h.remainder,n.samples=h.valid||new Uint8Array}else n.samples=i;const l=this.extractID3Track(n,t);return a.samples=kd(t,n),{videoTrack:n,audioTrack:this.audioTrack,id3Track:l,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,i=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const n=this.extractID3Track(t,this.timeOffset);return i.samples=kd(e,t),{videoTrack:t,audioTrack:Nr(),id3Track:n,textTrack:Nr()}}extractID3Track(e,t){const i=this.id3Track;if(e.samples.length){const n=bt(e.samples,["emsg"]);n&&n.forEach(a=>{const l=Zv(a);if(sA.test(l.schemeIdUri)){const h=ze(l.presentationTime)?l.presentationTime/l.timeScale:t+l.presentationTimeDelta/l.timeScale;let f=l.eventDuration===4294967295?Number.POSITIVE_INFINITY:l.eventDuration/l.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=l.payload;i.samples.push({data:p,len:p.byteLength,dts:h,pts:h,type:wr.emsg,duration:f})}})}return i}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Qa=null;const oA=[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],aA=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],lA=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],cA=[0,1,1,4];function df(r,e,t,i,n){if(t+24>e.length)return;const a=ff(e,t);if(a&&t+a.frameLength<=e.length){const l=a.samplesPerFrame*9e4/a.sampleRate,h=i+n*l,f={unit:e.subarray(t,t+a.frameLength),pts:h,dts:h};return r.config=[],r.channelCount=a.channelCount,r.samplerate=a.sampleRate,r.samples.push(f),{sample:f,length:a.frameLength,missing:0}}}function ff(r,e){const t=r[e+1]>>3&3,i=r[e+1]>>1&3,n=r[e+2]>>4&15,a=r[e+2]>>2&3;if(t!==1&&n!==0&&n!==15&&a!==3){const l=r[e+2]>>1&1,h=r[e+3]>>6,f=t===3?3-i:i===3?3:4,p=oA[f*14+n-1]*1e3,g=aA[(t===3?0:t===2?1:2)*3+a],A=h===3?1:2,b=lA[t][i],x=cA[i],k=b*8*x,w=Math.floor(b*p/g+l)*x;if(Qa===null){const N=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Qa=N?parseInt(N[1]):0}return!!Qa&&Qa<=87&&i===2&&p>=224e3&&h===0&&(r[e+3]=r[e+3]|128),{sampleRate:g,channelCount:A,frameLength:w,samplesPerFrame:k}}}function zc(r,e){return r[e]===255&&(r[e+1]&224)===224&&(r[e+1]&6)!==0}function pf(r,e){return e+1<r.length&&zc(r,e)}function uA(r,e){return zc(r,e)&&4<=r.length-e}function hA(r,e){if(e+1<r.length&&zc(r,e)){const i=ff(r,e);let n=4;i!=null&&i.frameLength&&(n=i.frameLength);const a=e+n;return a===r.length||pf(r,a)}return!1}class mf{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,i=e.byteLength-t,n=new Uint8Array(4),a=Math.min(4,t);if(a===0)throw new Error("no bytes available");n.set(e.subarray(i,i+a)),this.word=new DataView(n.buffer).getUint32(0),this.bitsAvailable=a*8,this.bytesAvailable-=a}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const i=this.word>>>32-t;if(e>32&&q.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?i<<t|this.readBits(t):i}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,i=8,n;for(let a=0;a<e;a++)i!==0&&(n=this.readEG(),i=(t+n+256)%256),t=i===0?t:i}readSPS(){let e=0,t=0,i=0,n=0,a,l,h;const f=this.readUByte.bind(this),p=this.readBits.bind(this),m=this.readUEG.bind(this),g=this.readBoolean.bind(this),A=this.skipBits.bind(this),b=this.skipEG.bind(this),x=this.skipUEG.bind(this),k=this.skipScalingList.bind(this);f();const w=f();if(p(5),A(3),f(),x(),w===100||w===110||w===122||w===244||w===44||w===83||w===86||w===118||w===128){const K=m();if(K===3&&A(1),x(),x(),A(1),g())for(l=K!==3?8:12,h=0;h<l;h++)g()&&(h<6?k(16):k(64))}x();const P=m();if(P===0)m();else if(P===1)for(A(1),b(),b(),a=m(),h=0;h<a;h++)b();x(),A(1);const $=m(),N=m(),I=p(1);I===0&&A(1),A(1),g()&&(e=m(),t=m(),i=m(),n=m());let O=[1,1];if(g()&&g())switch(f()){case 1:O=[1,1];break;case 2:O=[12,11];break;case 3:O=[10,11];break;case 4:O=[16,11];break;case 5:O=[40,33];break;case 6:O=[24,11];break;case 7:O=[20,11];break;case 8:O=[32,11];break;case 9:O=[80,33];break;case 10:O=[18,11];break;case 11:O=[15,11];break;case 12:O=[64,33];break;case 13:O=[160,99];break;case 14:O=[4,3];break;case 15:O=[3,2];break;case 16:O=[2,1];break;case 255:{O=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil(($+1)*16-e*2-t*2),height:(2-I)*(N+1)*16-(I?2:4)*(i+n),pixelRatio:O}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class dA{constructor(e,t,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Wc(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,i){const n=e[t].unit;if(n.length<=16)return;const a=n.subarray(16,n.length-n.length%16),l=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(l).then(h=>{const f=new Uint8Array(h);n.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,i)})}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length){i();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,i=new Int8Array(t);let n=0;for(let a=32;a<e.length-16;a+=160,n+=16)i.set(e.subarray(a,a+16),n);return i}getAvcDecryptedUnit(e,t){const i=new Uint8Array(t);let n=0;for(let a=32;a<e.length-16;a+=160,n+=16)e.set(i.subarray(n,n+16),a);return e}decryptAvcSample(e,t,i,n,a){const l=wd(a.data),h=this.getAvcEncryptedData(l);this.decryptBuffer(h.buffer).then(f=>{a.data=this.getAvcDecryptedUnit(l,f),this.decrypter.isSync()||this.decryptAvcSamples(e,t,i+1,n)})}decryptAvcSamples(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length){n();return}const a=e[t].units;for(;!(i>=a.length);i++){const l=a[i];if(!(l.data.length<=48||l.type!==1&&l.type!==5)&&(this.decryptAvcSample(e,t,i,n,l),!this.decrypter.isSync()))return}}}}const Di=188;class Ls{constructor(e,t,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=e,this.config=t,this.typeSupported=i}static probe(e){const t=Ls.syncOffset(e);return t>0&&q.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let i=Math.min(Di*5,e.length-Di)+1,n=0;for(;n<i;){let a=!1,l=-1,h=0;for(let f=n;f<t;f+=Di)if(e[f]===71){if(h++,l===-1&&(l=f,l!==0&&(i=Math.min(l+Di*99,e.length-Di)+1)),a||(a=Yc(e,f)===0),a&&h>1&&(l===0&&h>2||f+Di>i))return l}else{if(h)return-1;break}n++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Ad[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Ls.createTrack("video"),this._audioTrack=Ls.createTrack("audio",n),this._id3Track=Ls.createTrack("id3"),this._txtTrack=Ls.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,i=!1,n=!1){i||(this.sampleAes=null);let a;const l=this._avcTrack,h=this._audioTrack,f=this._id3Track,p=this._txtTrack;let m=l.pid,g=l.pesData,A=h.pid,b=f.pid,x=h.pesData,k=f.pesData,w=null,P=this.pmtParsed,$=this._pmtId,N=e.length;if(this.remainderData&&(e=hn(this.remainderData,e),N=e.length,this.remainderData=null),N<Di&&!n)return this.remainderData=e,{audioTrack:h,videoTrack:l,id3Track:f,textTrack:p};const I=Math.max(0,Ls.syncOffset(e));N-=(N-I)%Di,N<e.byteLength&&!n&&(this.remainderData=new Uint8Array(e.buffer,N,e.buffer.byteLength-N));let O=0;for(let U=I;U<N;U+=Di)if(e[U]===71){const re=!!(e[U+1]&64),ne=Yc(e,U),Y=(e[U+3]&48)>>4;let Ee;if(Y>1){if(Ee=U+5+e[U+4],Ee===U+Di)continue}else Ee=U+4;switch(ne){case m:re&&(g&&(a=Cn(g))&&this.parseAVCPES(l,p,a,!1),g={data:[],size:0}),g&&(g.data.push(e.subarray(Ee,U+Di)),g.size+=U+Di-Ee);break;case A:if(re){if(x&&(a=Cn(x)))switch(h.segmentCodec){case"aac":this.parseAACPES(h,a);break;case"mp3":this.parseMPEGPES(h,a);break}x={data:[],size:0}}x&&(x.data.push(e.subarray(Ee,U+Di)),x.size+=U+Di-Ee);break;case b:re&&(k&&(a=Cn(k))&&this.parseID3PES(f,a),k={data:[],size:0}),k&&(k.data.push(e.subarray(Ee,U+Di)),k.size+=U+Di-Ee);break;case 0:re&&(Ee+=e[Ee]+1),$=this._pmtId=fA(e,Ee);break;case $:{re&&(Ee+=e[Ee]+1);const ce=pA(e,Ee,this.typeSupported,i);m=ce.avc,m>0&&(l.pid=m),A=ce.audio,A>0&&(h.pid=A,h.segmentCodec=ce.segmentCodec),b=ce.id3,b>0&&(f.pid=b),w!==null&&!P&&(q.warn(`MPEG-TS PMT found at ${U} after unknown PID '${w}'. Backtracking to sync byte @${I} to parse all TS packets.`),w=null,U=I-188),P=this.pmtParsed=!0;break}case 17:case 8191:break;default:w=ne;break}}else O++;if(O>0){const U=new Error(`Found ${O} TS packet/s that do not start with 0x47`);this.observer.emit(_.ERROR,_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,fatal:!1,error:U,reason:U.message})}l.pesData=g,h.pesData=x,f.pesData=k;const K={audioTrack:h,videoTrack:l,id3Track:f,textTrack:p};return n&&this.extractRemainingSamples(K),K}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:i,id3Track:n,textTrack:a}=e,l=i.pesData,h=t.pesData,f=n.pesData;let p;if(l&&(p=Cn(l))?(this.parseAVCPES(i,a,p,!0),i.pesData=null):i.pesData=l,h&&(p=Cn(h))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,p);break;case"mp3":this.parseMPEGPES(t,p);break}t.pesData=null}else h!=null&&h.size&&q.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=h;f&&(p=Cn(f))?(this.parseID3PES(n,p),n.pesData=null):n.pesData=f}demuxSampleAes(e,t,i){const n=this.demux(e,i,!0,!this.config.progressive),a=this.sampleAes=new dA(this.observer,this.config,t);return this.decrypt(n,a)}decrypt(e,t){return new Promise(i=>{const{audioTrack:n,videoTrack:a}=e;n.samples&&n.segmentCodec==="aac"?t.decryptAacSamples(n.samples,0,()=>{a.samples?t.decryptAvcSamples(a.samples,0,0,()=>{i(e)}):i(e)}):a.samples&&t.decryptAvcSamples(a.samples,0,0,()=>{i(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,i,n){const a=this.parseAVCNALu(e,i.data);let l=this.avcSample,h,f=!1;i.data=null,l&&a.length&&!e.audFound&&(Oo(l,e),l=this.avcSample=Ja(!1,i.pts,i.dts,"")),a.forEach(p=>{var m;switch(p.type){case 1:{let A=!1;h=!0;const b=p.data;if(f&&b.length>4){const x=new mf(b).readSliceType();(x===2||x===4||x===7||x===9)&&(A=!0)}if(A){var g;(g=l)!=null&&g.frame&&!l.key&&(Oo(l,e),l=this.avcSample=null)}l||(l=this.avcSample=Ja(!0,i.pts,i.dts,"")),l.frame=!0,l.key=A;break}case 5:h=!0,(m=l)!=null&&m.frame&&!l.key&&(Oo(l,e),l=this.avcSample=null),l||(l=this.avcSample=Ja(!0,i.pts,i.dts,"")),l.key=!0,l.frame=!0;break;case 6:{h=!0,Sd(p.data,1,i.pts,t.samples);break}case 7:if(h=!0,f=!0,!e.sps){const A=p.data,x=new mf(A).readSPS();e.width=x.width,e.height=x.height,e.pixelRatio=x.pixelRatio,e.sps=[A],e.duration=this._duration;const k=A.subarray(1,4);let w="avc1.";for(let P=0;P<3;P++){let $=k[P].toString(16);$.length<2&&($="0"+$),w+=$}e.codec=w}break;case 8:h=!0,e.pps||(e.pps=[p.data]);break;case 9:h=!1,e.audFound=!0,l&&Oo(l,e),l=this.avcSample=Ja(!1,i.pts,i.dts,"");break;case 12:h=!0;break;default:h=!1,l&&(l.debug+="unknown NAL "+p.type+" ");break}l&&h&&l.units.push(p)}),n&&l&&(Oo(l,e),this.avcSample=null)}getLastNalUnit(e){var t;let i=this.avcSample,n;if((!i||i.units.length===0)&&(i=e[e.length-1]),(t=i)!=null&&t.units){const a=i.units;n=a[a.length-1]}return n}parseAVCNALu(e,t){const i=t.byteLength;let n=e.naluState||0;const a=n,l=[];let h=0,f,p,m,g=-1,A=0;for(n===-1&&(g=0,A=t[0]&31,n=0,h=1);h<i;){if(f=t[h++],!n){n=f?0:1;continue}if(n===1){n=f?0:2;continue}if(!f)n=3;else if(f===1){if(g>=0){const b={data:t.subarray(g,h-n-1),type:A};l.push(b)}else{const b=this.getLastNalUnit(e.samples);if(b&&(a&&h<=4-a&&b.state&&(b.data=b.data.subarray(0,b.data.byteLength-a)),p=h-n-1,p>0)){const x=new Uint8Array(b.data.byteLength+p);x.set(b.data,0),x.set(t.subarray(0,p),b.data.byteLength),b.data=x,b.state=0}}h<i?(m=t[h]&31,g=h,A=m,n=0):n=-1}else n=0}if(g>=0&&n>=0){const b={data:t.subarray(g,i),type:A,state:n};l.push(b)}if(l.length===0){const b=this.getLastNalUnit(e.samples);if(b){const x=new Uint8Array(b.data.byteLength+t.byteLength);x.set(b.data,0),x.set(t,b.data.byteLength),b.data=x}}return e.naluState=n,l}parseAACPES(e,t){let i=0;const n=this.aacOverFlow;let a=t.data;if(n){this.aacOverFlow=null;const g=n.missing,A=n.sample.unit.byteLength;if(g===-1){const b=new Uint8Array(A+a.byteLength);b.set(n.sample.unit,0),b.set(a,A),a=b}else{const b=A-g;n.sample.unit.set(a.subarray(0,g),b),e.samples.push(n.sample),i=n.missing}}let l,h;for(l=i,h=a.length;l<h-1&&!qa(a,l);l++);if(l!==i){let g;const A=l<h-1;A?g=`AAC PES did not start with ADTS header,offset:${l}`:g="No ADTS header found in AAC PES";const b=new Error(g);if(q.warn(`parsing error: ${g}`),this.observer.emit(_.ERROR,_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,fatal:!1,levelRetry:A,error:b,reason:g}),!A)return}cf(e,this.observer,a,l,this.audioCodec);let f;if(t.pts!==void 0)f=t.pts;else if(n){const g=uf(e.samplerate);f=n.sample.pts+g}else{q.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,m;for(;l<h;)if(m=hf(e,a,l,f,p),l+=m.length,m.missing){this.aacOverFlow=m;break}else for(p++;l<h-1&&!qa(a,l);l++);}parseMPEGPES(e,t){const i=t.data,n=i.length;let a=0,l=0;const h=t.pts;if(h===void 0){q.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;l<n;)if(pf(i,l)){const f=df(e,i,l,h,a);if(f)l+=f.length,a++;else break}else l++}parseID3PES(e,t){if(t.pts===void 0){q.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ci({},t,{type:this._avcTrack?wr.emsg:wr.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(i)}}function Ja(r,e,t,i){return{key:r,frame:!1,pts:e,dts:t,units:[],debug:i,length:0}}function Yc(r,e){return((r[e+1]&31)<<8)+r[e+2]}function fA(r,e){return(r[e+10]&31)<<8|r[e+11]}function pA(r,e,t,i){const n={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=(r[e+1]&15)<<8|r[e+2],l=e+3+a-4,h=(r[e+10]&15)<<8|r[e+11];for(e+=12+h;e<l;){const f=Yc(r,e);switch(r[e]){case 207:if(!i){q.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){q.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:t.mpeg!==!0&&t.mp3!==!0?q.log("MPEG audio found, not supported in this browser"):n.audio===-1&&(n.audio=f,n.segmentCodec="mp3");break;case 36:q.warn("Unsupported HEVC stream type found");break}e+=((r[e+3]&15)<<8|r[e+4])+5}return n}function Cn(r){let e=0,t,i,n,a,l;const h=r.data;if(!r||r.size===0)return null;for(;h[0].length<19&&h.length>1;){const p=new Uint8Array(h[0].length+h[1].length);p.set(h[0]),p.set(h[1],h[0].length),h[0]=p,h.splice(1,1)}if(t=h[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(i=(t[4]<<8)+t[5],i&&i>r.size-6)return null;const p=t[7];p&192&&(a=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,p&64?(l=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,a-l>54e5&&(q.warn(`${Math.round((a-l)/9e4)}s delta between PTS and DTS, align them`),a=l)):l=a),n=t[8];let m=n+9;if(r.size<=m)return null;r.size-=m;const g=new Uint8Array(r.size);for(let A=0,b=h.length;A<b;A++){t=h[A];let x=t.byteLength;if(m)if(m>x){m-=x;continue}else t=t.subarray(m),x-=m,m=0;g.set(t,e),e+=x}return i&&(i-=n+3),{data:g,pts:a,dts:l,len:i}}return null}function Oo(r,e){if(r.units.length&&r.frame){if(r.pts===void 0){const t=e.samples,i=t.length;if(i){const n=t[i-1];r.pts=n.pts,r.dts=n.dts}else{e.dropped++;return}}e.samples.push(r)}r.debug.length&&q.log(r.pts+"/"+r.dts+":"+r.debug)}class mA extends of{resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let i=(Ba(e,0)||[]).length;for(let n=e.length;i<n;i++)if(hA(e,i))return q.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return uA(e,t)}appendFrame(e,t,i){if(this.basePTS!==null)return df(e,t,i,this.basePTS,this.frameIndex)}}class gf{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===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(t===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(t===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(t===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(t===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 Cs=Math.pow(2,32)-1;class se{static init(){se.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 e;for(e in se.types)se.types.hasOwnProperty(e)&&(se.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),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]);se.HDLR_TYPES={video:t,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]),a=new Uint8Array([0,0,0,0,0,0,0,0]);se.STTS=se.STSC=se.STCO=a,se.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),se.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),se.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),se.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const l=new Uint8Array([105,115,111,109]),h=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);se.FTYP=se.box(se.types.ftyp,l,f,l,h),se.DINF=se.box(se.types.dinf,se.box(se.types.dref,n))}static box(e,...t){let i=8,n=t.length;const a=n;for(;n--;)i+=t[n].byteLength;const l=new Uint8Array(i);for(l[0]=i>>24&255,l[1]=i>>16&255,l[2]=i>>8&255,l[3]=i&255,l.set(e,4),n=0,i=8;n<a;n++)l.set(t[n],i),i+=t[n].byteLength;return l}static hdlr(e){return se.box(se.types.hdlr,se.HDLR_TYPES[e])}static mdat(e){return se.box(se.types.mdat,e)}static mdhd(e,t){t*=e;const i=Math.floor(t/(Cs+1)),n=Math.floor(t%(Cs+1));return se.box(se.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&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(e){return se.box(se.types.mdia,se.mdhd(e.timescale,e.duration),se.hdlr(e.type),se.minf(e))}static mfhd(e){return se.box(se.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?se.box(se.types.minf,se.box(se.types.smhd,se.SMHD),se.DINF,se.stbl(e)):se.box(se.types.minf,se.box(se.types.vmhd,se.VMHD),se.DINF,se.stbl(e))}static moof(e,t,i){return se.box(se.types.moof,se.mfhd(e),se.traf(i,t))}static moov(e){let t=e.length;const i=[];for(;t--;)i[t]=se.trak(e[t]);return se.box.apply(null,[se.types.moov,se.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(se.mvex(e)))}static mvex(e){let t=e.length;const i=[];for(;t--;)i[t]=se.trex(e[t]);return se.box.apply(null,[se.types.mvex,...i])}static mvhd(e,t){t*=e;const i=Math.floor(t/(Cs+1)),n=Math.floor(t%(Cs+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&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 se.box(se.types.mvhd,a)}static sdtp(e){const t=e.samples||[],i=new Uint8Array(4+t.length);let n,a;for(n=0;n<t.length;n++)a=t[n].flags,i[n+4]=a.dependsOn<<4|a.isDependedOn<<2|a.hasRedundancy;return se.box(se.types.sdtp,i)}static stbl(e){return se.box(se.types.stbl,se.stsd(e),se.box(se.types.stts,se.STTS),se.box(se.types.stsc,se.STSC),se.box(se.types.stsz,se.STSZ),se.box(se.types.stco,se.STCO))}static avc1(e){let t=[],i=[],n,a,l;for(n=0;n<e.sps.length;n++)a=e.sps[n],l=a.byteLength,t.push(l>>>8&255),t.push(l&255),t=t.concat(Array.prototype.slice.call(a));for(n=0;n<e.pps.length;n++)a=e.pps[n],l=a.byteLength,i.push(l>>>8&255),i.push(l&255),i=i.concat(Array.prototype.slice.call(a));const h=se.box(se.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),f=e.width,p=e.height,m=e.pixelRatio[0],g=e.pixelRatio[1];return se.box(se.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]),h,se.box(se.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),se.box(se.types.pasp,new Uint8Array([m>>24,m>>16&255,m>>8&255,m&255,g>>24,g>>16&255,g>>8&255,g&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){const t=e.samplerate;return se.box(se.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),se.box(se.types.esds,se.esds(e)))}static mp3(e){const t=e.samplerate;return se.box(se.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?se.box(se.types.stsd,se.STSD,se.mp3(e)):se.box(se.types.stsd,se.STSD,se.mp4a(e)):se.box(se.types.stsd,se.STSD,se.avc1(e))}static tkhd(e){const t=e.id,i=e.duration*e.timescale,n=e.width,a=e.height,l=Math.floor(i/(Cs+1)),h=Math.floor(i%(Cs+1));return se.box(se.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,l>>24,l>>16&255,l>>8&255,l&255,h>>24,h>>16&255,h>>8&255,h&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,a>>8&255,a&255,0,0]))}static traf(e,t){const i=se.sdtp(e),n=e.id,a=Math.floor(t/(Cs+1)),l=Math.floor(t%(Cs+1));return se.box(se.types.traf,se.box(se.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,n&255])),se.box(se.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,l>>24,l>>16&255,l>>8&255,l&255])),se.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,se.box(se.types.trak,se.tkhd(e),se.mdia(e))}static trex(e){const t=e.id;return se.box(se.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const i=e.samples||[],n=i.length,a=12+16*n,l=new Uint8Array(a);let h,f,p,m,g,A;for(t+=8+a,l.set([e.type==="video"?1:0,0,15,1,n>>>24&255,n>>>16&255,n>>>8&255,n&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),h=0;h<n;h++)f=i[h],p=f.duration,m=f.size,g=f.flags,A=f.cts,l.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,g.isLeading<<2|g.dependsOn,g.isDependedOn<<6|g.hasRedundancy<<4|g.paddingValue<<1|g.isNonSync,g.degradPrio&61440,g.degradPrio&15,A>>>24&255,A>>>16&255,A>>>8&255,A&255],12+16*h);return se.box(se.types.trun,l)}static initSegment(e){se.types||se.init();const t=se.moov(e),i=new Uint8Array(se.FTYP.byteLength+t.byteLength);return i.set(se.FTYP),i.set(t,se.FTYP.byteLength),i}}se.types=void 0,se.HDLR_TYPES=void 0,se.STTS=void 0,se.STSC=void 0,se.STCO=void 0,se.STSZ=void 0,se.VMHD=void 0,se.SMHD=void 0,se.STSD=void 0,se.FTYP=void 0,se.DINF=void 0;const vf=9e4;function Xc(r,e,t=1,i=!1){const n=r*e*t;return i?Math.round(n):n}function gA(r,e,t=1,i=!1){return Xc(r,e,1/t,i)}function Po(r,e=!1){return Xc(r,1e3,1/vf,e)}function vA(r,e=1){return Xc(r,vf,1/e)}const yA=10*1e3,yf=1024,AA=1152;let el=null,Zc=null;class qc{constructor(e,t,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=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,el===null){const l=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);el=l?parseInt(l[1]):0}if(Zc===null){const a=navigator.userAgent.match(/Safari\/(\d+)/i);Zc=a?parseInt(a[1]):0}}destroy(){}resetTimeStamp(e){q.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){q.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){q.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const i=e.reduce((n,a)=>{const l=a.pts-n;return l<-4294967296?(t=!0,fr(n,a.pts)):l>0?n:a.pts},e[0].pts);return t&&q.debug("PTS rollover detected"),i}remux(e,t,i,n,a,l,h,f){let p,m,g,A,b,x,k=a,w=a;const P=e.pid>-1,$=t.pid>-1,N=t.samples.length,I=e.samples.length>0,O=h&&N>0||N>1;if((!P||I)&&(!$||O)||this.ISGenerated||h){this.ISGenerated||(g=this.generateIS(e,t,a,l));const U=this.isVideoContiguous;let re=-1,ne;if(O&&(re=EA(t.samples),!U&&this.config.forceKeyFrameOnDiscontinuity))if(x=!0,re>0){q.warn(`[mp4-remuxer]: Dropped ${re} out of ${N} video samples due to a missing keyframe`);const Y=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(re),t.dropped+=re,w+=(t.samples[0].pts-Y)/t.inputTimeScale,ne=w}else re===-1&&(q.warn(`[mp4-remuxer]: No keyframe found out of ${N} video samples`),x=!1);if(this.ISGenerated){if(I&&O){const Y=this.getVideoStartPts(t.samples),ce=(fr(e.samples[0].pts,Y)-Y)/t.inputTimeScale;k+=Math.max(0,ce),w+=Math.max(0,-ce)}if(I){if(e.samplerate||(q.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),g=this.generateIS(e,t,a,l)),m=this.remuxAudio(e,k,this.isAudioContiguous,l,$||O||f===it.AUDIO?w:void 0),O){const Y=m?m.endPTS-m.startPTS:0;t.inputTimeScale||(q.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),g=this.generateIS(e,t,a,l)),p=this.remuxVideo(t,w,U,Y)}}else O&&(p=this.remuxVideo(t,w,U,0));p&&(p.firstKeyFrame=re,p.independent=re!==-1,p.firstKeyFramePTS=ne)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(b=Af(i,a,this._initPTS,this._initDTS)),n.samples.length&&(A=Ef(n,a,this._initPTS))),{audio:m,video:p,initSegment:g,independent:x,text:A,id3:b}}generateIS(e,t,i,n){const a=e.samples,l=t.samples,h=this.typeSupported,f={},p=this._initPTS;let m=!p||n,g="audio/mp4",A,b,x;if(m&&(A=b=1/0),e.config&&a.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":h.mpeg?(g="audio/mpeg",e.codec=""):h.mp3&&(e.codec="mp3");break}f.audio={id:"audio",container:g,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&h.mpeg?new Uint8Array(0):se.initSegment([e]),metadata:{channelCount:e.channelCount}},m&&(x=e.inputTimeScale,!p||x!==p.timescale?A=b=a[0].pts-Math.round(x*i):m=!1)}if(t.sps&&t.pps&&l.length&&(t.timescale=t.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:se.initSegment([t]),metadata:{width:t.width,height:t.height}},m))if(x=t.inputTimeScale,!p||x!==p.timescale){const k=this.getVideoStartPts(l),w=Math.round(x*i);b=Math.min(b,fr(l[0].dts,k)-w),A=Math.min(A,k-w)}else m=!1;if(Object.keys(f).length)return this.ISGenerated=!0,m?(this._initPTS={baseTime:A,timescale:x},this._initDTS={baseTime:b,timescale:x}):A=x=void 0,{tracks:f,initPTS:A,timescale:x}}remuxVideo(e,t,i,n){const a=e.inputTimeScale,l=e.samples,h=[],f=l.length,p=this._initPTS;let m=this.nextAvcDts,g=8,A=this.videoSampleDuration,b,x,k=Number.POSITIVE_INFINITY,w=Number.NEGATIVE_INFINITY,P=!1;if(!i||m===null){const M=t*a,G=l[0].pts-fr(l[0].dts,l[0].pts);m=M-G}const $=p.baseTime*a/p.timescale;for(let M=0;M<f;M++){const G=l[M];G.pts=fr(G.pts-$,m),G.dts=fr(G.dts-$,m),G.dts<l[M>0?M-1:M].dts&&(P=!0)}P&&l.sort(function(M,G){const Q=M.dts-G.dts,me=M.pts-G.pts;return Q||me}),b=l[0].dts,x=l[l.length-1].dts;const N=x-b,I=N?Math.round(N/(f-1)):A||e.inputTimeScale/30;if(i){const M=b-m,G=M>I,Q=M<-1;if((G||Q)&&(G?q.warn(`AVC: ${Po(M,!0)} ms (${M}dts) hole between fragments detected, filling it`):q.warn(`AVC: ${Po(-M,!0)} ms (${M}dts) overlapping between fragments detected`),!Q||m>=l[0].pts)){b=m;const me=l[0].pts-M;l[0].dts=b,l[0].pts=me,q.log(`Video: First PTS/DTS adjusted: ${Po(me,!0)}/${Po(b,!0)}, delta: ${Po(M,!0)} ms`)}}b=Math.max(0,b);let O=0,K=0;for(let M=0;M<f;M++){const G=l[M],Q=G.units,me=Q.length;let pe=0;for(let Le=0;Le<me;Le++)pe+=Q[Le].data.length;K+=pe,O+=me,G.length=pe,G.dts=Math.max(G.dts,b),k=Math.min(G.pts,k),w=Math.max(G.pts,w)}x=l[f-1].dts;const U=K+4*O+8;let re;try{re=new Uint8Array(U)}catch(M){this.observer.emit(_.ERROR,_.ERROR,{type:tt.MUX_ERROR,details:fe.REMUX_ALLOC_ERROR,fatal:!1,error:M,bytes:U,reason:`fail allocating video mdat ${U}`});return}const ne=new DataView(re.buffer);ne.setUint32(0,U),re.set(se.types.mdat,4);let Y=!1,Ee=Number.POSITIVE_INFINITY,ce=Number.POSITIVE_INFINITY,_e=Number.NEGATIVE_INFINITY,Oe=Number.NEGATIVE_INFINITY;for(let M=0;M<f;M++){const G=l[M],Q=G.units;let me=0;for(let Ue=0,Ke=Q.length;Ue<Ke;Ue++){const Ze=Q[Ue],pt=Ze.data,dt=Ze.data.byteLength;ne.setUint32(g,dt),g+=4,re.set(pt,g),g+=dt,me+=4+dt}let pe;if(M<f-1)A=l[M+1].dts-G.dts,pe=l[M+1].pts-G.pts;else{const Ue=this.config,Ke=M>0?G.dts-l[M-1].dts:I;if(pe=M>0?G.pts-l[M-1].pts:I,Ue.stretchShortVideoTrack&&this.nextAudioPts!==null){const Ze=Math.floor(Ue.maxBufferHole*a),pt=(n?k+n*a:this.nextAudioPts)-G.pts;pt>Ze?(A=pt-Ke,A<0?A=Ke:Y=!0,q.log(`[mp4-remuxer]: It is approximately ${pt/90} ms to the next segment; using duration ${A/90} ms for the last video frame.`)):A=Ke}else A=Ke}const Le=Math.round(G.pts-G.dts);Ee=Math.min(Ee,A),_e=Math.max(_e,A),ce=Math.min(ce,pe),Oe=Math.max(Oe,pe),h.push(new bf(G.key,A,me,Le))}if(h.length){if(el){if(el<70){const M=h[0].flags;M.dependsOn=2,M.isNonSync=0}}else if(Zc&&Oe-ce<_e-Ee&&I/_e<.025&&h[0].cts===0){q.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let M=b;for(let G=0,Q=h.length;G<Q;G++){const me=M+h[G].duration,pe=M+h[G].cts;if(G<Q-1){const Le=me+h[G+1].cts;h[G].duration=Le-pe}else h[G].duration=G?h[G-1].duration:I;h[G].cts=0,M=me}}}A=Y||!A?I:A,this.nextAvcDts=m=x+A,this.videoSampleDuration=A,this.isVideoContiguous=!0;const B=se.moof(e.sequenceNumber++,b,ci({},e,{samples:h})),W="video",we={data1:B,data2:re,startPTS:k/a,endPTS:(w+A)/a,startDTS:b/a,endDTS:m/a,type:W,hasAudio:!1,hasVideo:!0,nb:h.length,dropped:e.dropped};return e.samples=[],e.dropped=0,we}remuxAudio(e,t,i,n,a){const l=e.inputTimeScale,h=e.samplerate?e.samplerate:l,f=l/h,p=e.segmentCodec==="aac"?yf:AA,m=p*f,g=this._initPTS,A=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,b=[],x=a!==void 0;let k=e.samples,w=A?0:8,P=this.nextAudioPts||-1;const $=t*l,N=g.baseTime*l/g.timescale;if(this.isAudioContiguous=i=i||k.length&&P>0&&(n&&Math.abs($-P)<9e3||Math.abs(fr(k[0].pts-N,$)-P)<20*m),k.forEach(function(W){W.pts=fr(W.pts-N,$)}),!i||P<0){if(k=k.filter(W=>W.pts>=0),!k.length)return;a===0?P=0:n&&!x?P=Math.max(0,$):P=k[0].pts}if(e.segmentCodec==="aac"){const W=this.config.maxAudioFramesDrift;for(let we=0,M=P;we<k.length;we++){const G=k[we],Q=G.pts,me=Q-M,pe=Math.abs(1e3*me/l);if(me<=-W*m&&x)we===0&&(q.warn(`Audio frame @ ${(Q/l).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*me/l)} ms.`),this.nextAudioPts=P=M=Q);else if(me>=W*m&&pe<yA&&x){let Le=Math.round(me/m);M=Q-Le*m,M<0&&(Le--,M+=m),we===0&&(this.nextAudioPts=P=M),q.warn(`[mp4-remuxer]: Injecting ${Le} audio frame @ ${(M/l).toFixed(3)}s due to ${Math.round(1e3*me/l)} ms gap.`);for(let Ue=0;Ue<Le;Ue++){const Ke=Math.max(M,0);let Ze=gf.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Ze||(q.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Ze=G.unit.subarray()),k.splice(we,0,{unit:Ze,pts:Ke}),M+=m,we++}}G.pts=M,M+=m}}let I=null,O=null,K,U=0,re=k.length;for(;re--;)U+=k[re].unit.byteLength;for(let W=0,we=k.length;W<we;W++){const M=k[W],G=M.unit;let Q=M.pts;if(O!==null){const pe=b[W-1];pe.duration=Math.round((Q-O)/f)}else if(i&&e.segmentCodec==="aac"&&(Q=P),I=Q,U>0){U+=w;try{K=new Uint8Array(U)}catch(pe){this.observer.emit(_.ERROR,_.ERROR,{type:tt.MUX_ERROR,details:fe.REMUX_ALLOC_ERROR,fatal:!1,error:pe,bytes:U,reason:`fail allocating audio mdat ${U}`});return}A||(new DataView(K.buffer).setUint32(0,U),K.set(se.types.mdat,4))}else return;K.set(G,w);const me=G.byteLength;w+=me,b.push(new bf(!0,p,me,0)),O=Q}const ne=b.length;if(!ne)return;const Y=b[b.length-1];this.nextAudioPts=P=O+f*Y.duration;const Ee=A?new Uint8Array(0):se.moof(e.sequenceNumber++,I/f,ci({},e,{samples:b}));e.samples=[];const ce=I/l,_e=P/l,B={data1:Ee,data2:K,startPTS:ce,endPTS:_e,startDTS:ce,endDTS:_e,type:"audio",hasAudio:!0,hasVideo:!1,nb:ne};return this.isAudioContiguous=!0,B}remuxEmptyAudio(e,t,i,n){const a=e.inputTimeScale,l=e.samplerate?e.samplerate:a,h=a/l,f=this.nextAudioPts,p=this._initDTS,m=p.baseTime*9e4/p.timescale,g=(f!==null?f:n.startDTS*a)+m,A=n.endDTS*a+m,b=h*yf,x=Math.ceil((A-g)/b),k=gf.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(q.warn("[mp4-remuxer]: remux empty Audio"),!k){q.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const w=[];for(let P=0;P<x;P++){const $=g+P*b;w.push({unit:k,pts:$,dts:$})}return e.samples=w,this.remuxAudio(e,t,i,!1)}}function fr(r,e){let t;if(e===null)return r;for(e<r?t=-8589934592:t=8589934592;Math.abs(r-e)>4294967296;)r+=t;return r}function EA(r){for(let e=0;e<r.length;e++)if(r[e].key)return e;return-1}function Af(r,e,t,i){const n=r.samples.length;if(!n)return;const a=r.inputTimeScale;for(let h=0;h<n;h++){const f=r.samples[h];f.pts=fr(f.pts-t.baseTime*a/t.timescale,e*a)/a,f.dts=fr(f.dts-i.baseTime*a/i.timescale,e*a)/a}const l=r.samples;return r.samples=[],{samples:l}}function Ef(r,e,t){const i=r.samples.length;if(!i)return;const n=r.inputTimeScale;for(let l=0;l<i;l++){const h=r.samples[l];h.pts=fr(h.pts-t.baseTime*n/t.timescale,e*n)/n}r.samples.sort((l,h)=>l.pts-h.pts);const a=r.samples;return r.samples=[],{samples:a}}class bf{constructor(e,t,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=n,this.flags=new bA(e)}}class bA{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}class xA{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(Vv(e,n)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const n=this.initData=xd(e);t||(t=xf(n.audio,Ct.AUDIO)),i||(i=xf(n.video,Ct.VIDEO));const a={};n.audio&&n.video?a.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:n.audio?a.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?a.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:q.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(e,t,i,n,a,l){var h,f;let{initPTS:p,lastEndTime:m}=this;const g={audio:void 0,video:void 0,text:n,id3:i,initSegment:void 0};ze(m)||(m=this.lastEndTime=a||0);const A=t.samples;if(!(A!=null&&A.length))return g;const b={initPTS:void 0,timescale:1};let x=this.initData;if((h=x)!=null&&h.length||(this.generateInitSegment(A),x=this.initData),!((f=x)!=null&&f.length))return q.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),g;this.emitInitSegment&&(b.tracks=this.initTracks,this.emitInitSegment=!1);const k=Wv(A,x),w=Hv(x,A),P=w===null?a:w;(TA(p,P,a,k)||b.timescale!==p.timescale&&l)&&(b.initPTS=P-a,p&&p.timescale===1&&q.warn(`Adjusting initPTS by ${b.initPTS-p.baseTime}`),this.initPTS=p={baseTime:b.initPTS,timescale:1});const $=e?P-p.baseTime/p.timescale:m,N=$+k;Kv(x,A,p.baseTime/p.timescale),k>0?this.lastEndTime=N:(q.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const I=!!x.audio,O=!!x.video;let K="";I&&(K+="audio"),O&&(K+="video");const U={data1:A,startPTS:$,startDTS:$,endPTS:N,endDTS:N,type:K,hasAudio:I,hasVideo:O,nb:1,dropped:0};return g.audio=U.type==="audio"?U:void 0,g.video=U.type!=="audio"?U:void 0,g.initSegment=b,g.id3=Af(i,a,p,p),n.samples.length&&(g.text=Ef(n,a,p)),g}}function TA(r,e,t,i){if(r===null)return!0;const n=Math.max(i,1),a=e-r.baseTime/r.timescale;return Math.abs(a-t)>n}function xf(r,e){const t=r==null?void 0:r.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Ct.VIDEO?"avc1.42e01e":"mp4a.40.5"}let os;try{os=self.performance.now.bind(self.performance)}catch{q.debug("Unable to use Performance API on this environment"),os=typeof self<"u"&&self.Date.now}const Qc=[{demux:nA,remux:xA},{demux:Ls,remux:qc},{demux:rA,remux:qc},{demux:mA,remux:qc}];class Tf{constructor(e,t,i,n,a){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=i,this.vendor=n,this.id=a}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,i,n){const a=i.transmuxing;a.executeStart=os();let l=new Uint8Array(e);const{currentTransmuxState:h,transmuxConfig:f}=this;n&&(this.currentTransmuxState=n);const{contiguous:p,discontinuity:m,trackSwitch:g,accurateTimeOffset:A,timeOffset:b,initSegmentChange:x}=n||h,{audioCodec:k,videoCodec:w,defaultInitPts:P,duration:$,initSegmentData:N}=f,I=kA(l,t);if(I&&I.method==="AES-128"){const re=this.getDecrypter();if(re.isSync()){let ne=re.softwareDecrypt(l,I.key.buffer,I.iv.buffer);if(i.part>-1&&(ne=re.flush()),!ne)return a.executeEnd=os(),Jc(i);l=new Uint8Array(ne)}else return this.decryptionPromise=re.webCryptoDecrypt(l,I.key.buffer,I.iv.buffer).then(ne=>{const Y=this.push(ne,null,i);return this.decryptionPromise=null,Y}),this.decryptionPromise}const O=this.needsProbing(m,g);if(O){const re=this.configureTransmuxer(l);if(re)return q.warn(`[transmuxer] ${re.message}`),this.observer.emit(_.ERROR,_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,fatal:!1,error:re,reason:re.message}),a.executeEnd=os(),Jc(i)}(m||g||x||O)&&this.resetInitSegment(N,k,w,$,t),(m||x||O)&&this.resetInitialTimestamp(P),p||this.resetContiguity();const K=this.transmux(l,I,b,A,i),U=this.currentTransmuxState;return U.contiguous=!0,U.discontinuity=!1,U.trackSwitch=!1,a.executeEnd=os(),K}flush(e){const t=e.transmuxing;t.executeStart=os();const{decrypter:i,currentTransmuxState:n,decryptionPromise:a}=this;if(a)return a.then(()=>this.flush(e));const l=[],{timeOffset:h}=n;if(i){const g=i.flush();g&&l.push(this.push(g,null,e))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return t.executeEnd=os(),[Jc(e)];const m=f.flush(h);return tl(m)?m.then(g=>(this.flushRemux(l,g,e),l)):(this.flushRemux(l,m,e),l)}flushRemux(e,t,i){const{audioTrack:n,videoTrack:a,id3Track:l,textTrack:h}=t,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;q.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const m=this.remuxer.remux(n,a,l,h,p,f,!0,this.id);e.push({remuxResult:m,chunkMeta:i}),i.transmuxing.executeEnd=os()}resetInitialTimestamp(e){const{demuxer:t,remuxer:i}=this;!t||!i||(t.resetTimeStamp(e),i.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,i,n,a){const{demuxer:l,remuxer:h}=this;!l||!h||(l.resetInitSegment(e,t,i,n),h.resetInitSegment(e,t,i,a))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,i,n,a){let l;return t&&t.method==="SAMPLE-AES"?l=this.transmuxSampleAes(e,t,i,n,a):l=this.transmuxUnencrypted(e,i,n,a),l}transmuxUnencrypted(e,t,i,n){const{audioTrack:a,videoTrack:l,id3Track:h,textTrack:f}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(a,l,h,f,t,i,!1,this.id),chunkMeta:n}}transmuxSampleAes(e,t,i,n,a){return this.demuxer.demuxSampleAes(e,t,i).then(l=>({remuxResult:this.remuxer.remux(l.audioTrack,l.videoTrack,l.id3Track,l.textTrack,i,n,!1,this.id),chunkMeta:a}))}configureTransmuxer(e){const{config:t,observer:i,typeSupported:n,vendor:a}=this;let l;for(let g=0,A=Qc.length;g<A;g++)if(Qc[g].demux.probe(e)){l=Qc[g];break}if(!l)return new Error("Failed to find demuxer by probing fragment data");const h=this.demuxer,f=this.remuxer,p=l.remux,m=l.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,t,n,a)),(!h||!(h instanceof m))&&(this.demuxer=new m(i,t,n),this.probe=m.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Wc(this.config)),e}}function kA(r,e){let t=null;return r.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Jc=r=>({remuxResult:{},chunkMeta:r});function tl(r){return"then"in r&&r.then instanceof Function}class SA{constructor(e,t,i,n,a){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=n,this.defaultInitPts=a||null}}class wA{constructor(e,t,i,n,a,l){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=a,this.initSegmentChange=l}}var kf={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(t=!1));function n(f,p,m){this.fn=f,this.context=p,this.once=m||!1}function a(f,p,m,g,A){if(typeof m!="function")throw new TypeError("The listener must be a function");var b=new n(m,g||f,A),x=t?t+p:p;return f._events[x]?f._events[x].fn?f._events[x]=[f._events[x],b]:f._events[x].push(b):(f._events[x]=b,f._eventsCount++),f}function l(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var p=[],m,g;if(this._eventsCount===0)return p;for(g in m=this._events)e.call(m,g)&&p.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?p.concat(Object.getOwnPropertySymbols(m)):p},h.prototype.listeners=function(p){var m=t?t+p:p,g=this._events[m];if(!g)return[];if(g.fn)return[g.fn];for(var A=0,b=g.length,x=new Array(b);A<b;A++)x[A]=g[A].fn;return x},h.prototype.listenerCount=function(p){var m=t?t+p:p,g=this._events[m];return g?g.fn?1:g.length:0},h.prototype.emit=function(p,m,g,A,b,x){var k=t?t+p:p;if(!this._events[k])return!1;var w=this._events[k],P=arguments.length,$,N;if(w.fn){switch(w.once&&this.removeListener(p,w.fn,void 0,!0),P){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,m),!0;case 3:return w.fn.call(w.context,m,g),!0;case 4:return w.fn.call(w.context,m,g,A),!0;case 5:return w.fn.call(w.context,m,g,A,b),!0;case 6:return w.fn.call(w.context,m,g,A,b,x),!0}for(N=1,$=new Array(P-1);N<P;N++)$[N-1]=arguments[N];w.fn.apply(w.context,$)}else{var I=w.length,O;for(N=0;N<I;N++)switch(w[N].once&&this.removeListener(p,w[N].fn,void 0,!0),P){case 1:w[N].fn.call(w[N].context);break;case 2:w[N].fn.call(w[N].context,m);break;case 3:w[N].fn.call(w[N].context,m,g);break;case 4:w[N].fn.call(w[N].context,m,g,A);break;default:if(!$)for(O=1,$=new Array(P-1);O<P;O++)$[O-1]=arguments[O];w[N].fn.apply(w[N].context,$)}}return!0},h.prototype.on=function(p,m,g){return a(this,p,m,g,!1)},h.prototype.once=function(p,m,g){return a(this,p,m,g,!0)},h.prototype.removeListener=function(p,m,g,A){var b=t?t+p:p;if(!this._events[b])return this;if(!m)return l(this,b),this;var x=this._events[b];if(x.fn)x.fn===m&&(!A||x.once)&&(!g||x.context===g)&&l(this,b);else{for(var k=0,w=[],P=x.length;k<P;k++)(x[k].fn!==m||A&&!x[k].once||g&&x[k].context!==g)&&w.push(x[k]);w.length?this._events[b]=w.length===1?w[0]:w:l(this,b)}return this},h.prototype.removeAllListeners=function(p){var m;return p?(m=t?t+p:p,this._events[m]&&l(this,m)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=t,h.EventEmitter=h,r.exports=h})(kf);var _A=kf.exports,eu=dv(_A);const tu=Wa()||{isTypeSupported:()=>!1};class Sf{constructor(e,t,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 a=e.config;this.hls=e,this.id=t,this.useWorker=!!a.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;const l=(p,m)=>{m=m||{},m.frag=this.frag,m.id=this.id,p===_.ERROR&&(this.error=m.error),this.hls.trigger(p,m)};this.observer=new eu,this.observer.on(_.FRAG_DECRYPTED,l),this.observer.on(_.ERROR,l);const h={mp4:tu.isTypeSupported("video/mp4"),mpeg:tu.isTypeSupported("audio/mpeg"),mp3:tu.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(a.workerPath||Yy())){try{a.workerPath?(q.log(`loading Web Worker ${a.workerPath} for "${t}"`),this.workerContext=Zy(a.workerPath)):(q.log(`injecting Web Worker for "${t}"`),this.workerContext=Xy()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:m}=this.workerContext;m.addEventListener("message",this.onwmsg),m.onerror=g=>{const A=new Error(`${g.message} (${g.filename}:${g.lineno})`);a.enableWorker=!1,q.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(_.ERROR,{type:tt.OTHER_ERROR,details:fe.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:A})},m.postMessage({cmd:"init",typeSupported:h,vendor:f,id:t,config:JSON.stringify(a)})}catch(m){q.warn(`Error setting up "${t}" Web Worker, fallback to inline`,m),this.resetWorker(),this.error=null,this.transmuxer=new Tf(this.observer,h,a,f,t)}return}this.transmuxer=new Tf(this.observer,h,a,f,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,n,a,l,h,f,p,m){var g,A;p.transmuxing.start=self.performance.now();const{transmuxer:b}=this,x=l?l.start:a.start,k=a.decryptdata,w=this.frag,P=!(w&&a.cc===w.cc),$=!(w&&p.level===w.level),N=w?p.sn-w.sn:-1,I=this.part?p.part-this.part.index:-1,O=N===0&&p.id>1&&p.id===(w==null?void 0:w.stats.chunkCount),K=!$&&(N===1||N===0&&(I===1||O&&I<=0)),U=self.performance.now();($||N||a.stats.parsing.start===0)&&(a.stats.parsing.start=U),l&&(I||!K)&&(l.stats.parsing.start=U);const re=!(w&&((g=a.initSegment)==null?void 0:g.url)===((A=w.initSegment)==null?void 0:A.url)),ne=new wA(P,K,f,$,x,re);if(!K||P||re){q.log(`[transmuxer-interface, ${a.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
180
+ discontinuity: ${P}
181
+ trackSwitch: ${$}
182
+ contiguous: ${K}
183
+ accurateTimeOffset: ${f}
184
+ timeOffset: ${x}
185
+ initSegmentChange: ${re}`);const Y=new SA(i,n,t,h,m);this.configureTransmuxer(Y)}if(this.frag=a,this.part=l,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:k,chunkMeta:p,state:ne},e instanceof ArrayBuffer?[e]:[]);else if(b){const Y=b.push(e,k,p,ne);tl(Y)?(b.async=!0,Y.then(Ee=>{this.handleTransmuxComplete(Ee)}).catch(Ee=>{this.transmuxerError(Ee,p,"transmuxer-interface push error")})):(b.async=!1,this.handleTransmuxComplete(Y))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let i=t.flush(e);tl(i)||t.async?(tl(i)||(i=Promise.resolve(i)),i.then(a=>{this.handleFlushResult(a,e)}).catch(a=>{this.transmuxerError(a,e,"transmuxer-interface flush error")})):this.handleFlushResult(i,e)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(i=>{this.handleTransmuxComplete(i)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,i=this.hls;switch(t.event){case"init":{var n;const a=(n=this.workerContext)==null?void 0:n.objectURL;a&&self.URL.revokeObjectURL(a);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":q[t.data.logType]&&q[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const RA=250,iu=2,LA=.1,CA=.05;class IA{constructor(e,t,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=e,this.media=t,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:i,media:n,stalled:a}=this;if(n===null)return;const{currentTime:l,seeking:h}=n,f=this.seeking&&!h,p=!this.seeking&&h;if(this.seeking=h,l!==e){if(this.moved=!0,a!==null){if(this.stallReported){const P=self.performance.now()-a;q.warn(`playback not stuck anymore @${l}, after ${Math.round(P)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(p||f){this.stalled=null;return}if(n.paused&&!h||n.ended||n.playbackRate===0||!Nt.getBuffered(n).length)return;const m=Nt.bufferInfo(n,l,0),g=m.len>0,A=m.nextStart||0;if(!g&&!A)return;if(h){const P=m.len>iu,$=!A||t&&t.start<=l||A-l>iu&&!this.fragmentTracker.getPartialFragment(l);if(P||$)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var b;const P=Math.max(A,m.start||0)-l,$=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,I=($==null||(b=$.details)==null?void 0:b.live)?$.details.targetduration*2:iu,O=this.fragmentTracker.getPartialFragment(l);if(P>0&&(P<=I||O)){this._trySkipBufferHole(O);return}}const x=self.performance.now();if(a===null){this.stalled=x;return}const k=x-a;if(!h&&k>=RA&&(this._reportStall(m),!this.media))return;const w=Nt.bufferInfo(n,l,i.maxBufferHole);this._tryFixBufferStall(w,k)}_tryFixBufferStall(e,t){const{config:i,fragmentTracker:n,media:a}=this;if(a===null)return;const l=a.currentTime,h=n.getPartialFragment(l);h&&(this._trySkipBufferHole(h)||!this.media)||(e.len>i.maxBufferHole||e.nextStart&&e.nextStart-l<i.maxBufferHole)&&t>i.highBufferWatchdogPeriod*1e3&&(q.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:i,stallReported:n}=this;if(!n&&i){this.stallReported=!0;const a=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`);q.warn(a.message),t.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_STALLED_ERROR,fatal:!1,error:a,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:i,media:n}=this;if(n===null)return 0;const a=n.currentTime,l=Nt.bufferInfo(n,a,0),h=a<l.start?l.start:l.nextStart;if(h){const f=l.len<=t.maxBufferHole,p=l.len>0&&l.len<1&&n.readyState<3,m=h-a;if(m>0&&(f||p)){if(m>t.maxBufferHole){const{fragmentTracker:A}=this;let b=!1;if(a===0){const x=A.getAppendedFrag(0,it.MAIN);x&&h<x.end&&(b=!0)}if(!b){const x=e||A.getAppendedFrag(a,it.MAIN);if(x){let k=!1,w=x.end;for(;w<h;){const P=A.getPartialFragment(w);if(P)w+=P.duration;else{k=!0;break}}if(k)return 0}}}const g=Math.max(h+CA,a+LA);if(q.warn(`skipping hole, adjusting currentTime from ${a} to ${g}`),this.moved=!0,this.stalled=null,n.currentTime=g,e&&!e.gap){const A=new Error(`fragment loaded with buffer holes, seeking from ${a} to ${g}`);i.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:A,reason:A.message,frag:e})}return g}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:i,nudgeRetry:n}=this;if(i===null)return;const a=i.currentTime;if(this.nudgeRetry++,n<e.nudgeMaxRetry){const l=a+(n+1)*e.nudgeOffset,h=new Error(`Nudging 'currentTime' from ${a} to ${l}`);q.warn(h.message),i.currentTime=l,t.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_NUDGE_ON_STALL,error:h,fatal:!1})}else{const l=new Error(`Playhead still not moving while enough data buffered @${a} after ${e.nudgeMaxRetry} nudges`);q.error(l.message),t.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_STALLED_ERROR,error:l,fatal:!0})}}}const DA=100;class OA extends jc{constructor(e,t,i){super(e,t,i,"[stream-controller]",it.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:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(_.ERROR,this.onError,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(_.ERROR,this.onError,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:i}=this;if(this.stopLoad(),this.setInterval(DA),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}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=Se.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=Se.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case Se.WAITING_LEVEL:{var e;const{levels:i,level:n}=this,a=i==null||(e=i[n])==null?void 0:e.details;if(a&&(!a.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(a))break;this.state=Se.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=Se.IDLE;break}break}case Se.FRAG_LOADING_WAITING_RETRY:{var t;const i=self.performance.now(),n=this.retryDate;(!n||i>=n||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Se.IDLE)}break}this.state===Se.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:i,media:n}=this,{config:a,nextLoadLevel:l}=e;if(t===null||!n&&(this.startFragRequested||!a.startFragPrefetch)||this.altAudio&&this.audioOnly||!(i!=null&&i[l]))return;const h=i[l],f=this.getMainFwdBufferInfo();if(f===null)return;const p=this.getLevelDetails();if(p&&this._streamEnded(f,p)){const w={};this.altAudio&&(w.type="video"),this.hls.trigger(_.BUFFER_EOS,w),this.state=Se.ENDED;return}e.loadLevel!==l&&e.manualLevel===-1&&this.log(`Adapting to level ${l} from level ${this.level}`),this.level=e.nextLoadLevel=l;const m=h.details;if(!m||this.state===Se.WAITING_LEVEL||m.live&&this.levelLastLoaded!==l){this.level=l,this.state=Se.WAITING_LEVEL;return}const g=f.len,A=this.getMaxBufferLength(h.maxBitrate);if(g>=A)return;this.backtrackFragment&&this.backtrackFragment.start>f.end&&(this.backtrackFragment=null);const b=this.backtrackFragment?this.backtrackFragment.start:f.end;let x=this.getNextFragment(b,m);if(this.couldBacktrack&&!this.fragPrevious&&x&&x.sn!=="initSegment"&&this.fragmentTracker.getState(x)!==gi.OK){var k;const P=((k=this.backtrackFragment)!=null?k:x).sn-m.startSN,$=m.fragments[P-1];$&&x.cc===$.cc&&(x=$,this.fragmentTracker.removeFragment($))}else this.backtrackFragment&&f.len&&(this.backtrackFragment=null);if(x&&this.isLoopLoading(x,b)){if(!x.gap){const P=this.audioOnly&&!this.altAudio?Ct.AUDIO:Ct.VIDEO,$=(P===Ct.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;$&&this.afterBufferFlushed($,P,it.MAIN)}x=this.getNextFragmentLoopLoading(x,m,f,it.MAIN,A)}x&&(x.initSegment&&!x.initSegment.data&&!this.bitrateTest&&(x=x.initSegment),this.loadFragment(x,h,b))}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===gi.NOT_LOADED||n===gi.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,it.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let i;const n=this.getAppendedFrag(t.currentTime);n&&n.start>1&&this.flushMainBuffer(0,n.start-1);const a=this.getLevelDetails();if(a!=null&&a.live){const h=this.getMainFwdBufferInfo();if(!h||h.len<a.targetduration*2)return}if(!t.paused&&e){const h=this.hls.nextLoadLevel,f=e[h],p=this.fragLastKbps;p&&this.fragCurrent?i=this.fragCurrent.duration*f.maxBitrate/(1e3*p)+1:i=0}else i=0;const l=this.getBufferedFrag(t.currentTime+i);if(l){const h=this.followingBufferedFrag(l);if(h){this.abortCurrentFrag();const f=h.maxStartPTS?h.maxStartPTS:h.start,p=h.duration,m=Math.max(l.end,f+Math.min(Math.max(p-this.config.maxFragLookUpTolerance,p*.5),p*.75));this.flushMainBuffer(m,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case Se.KEY_LOADING:case Se.FRAG_LOADING:case Se.FRAG_LOADING_WAITING_RETRY:case Se.PARSING:case Se.PARSED:this.state=Se.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const i=t.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 IA(this.config,i,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;ze(t)&&this.log(`Media seeked to ${t.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(_.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(e,t){let i=!1,n=!1,a;t.levels.forEach(l=>{a=l.audioCodec,a&&(a.indexOf("mp4a.40.2")!==-1&&(i=!0),a.indexOf("mp4a.40.5")!==-1&&(n=!0))}),this.audioCodecSwitch=i&&n&&!zy(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:i}=this;if(!i||this.state!==Se.IDLE)return;const n=i[t.level];(!n.details||n.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(n.details))&&(this.state=Se.WAITING_LEVEL)}onLevelLoaded(e,t){var i;const{levels:n}=this,a=t.level,l=t.details,h=l.totalduration;if(!n){this.warn(`Levels were reset while loading level ${a}`);return}this.log(`Level ${a} loaded [${l.startSN},${l.endSN}]${l.lastPartSn?`[part-${l.lastPartSn}-${l.lastPartIndex}]`:""}, cc [${l.startCC}, ${l.endCC}] duration:${h}`);const f=n[a],p=this.fragCurrent;p&&(this.state===Se.FRAG_LOADING||this.state===Se.FRAG_LOADING_WAITING_RETRY)&&(p.level!==t.level||p.urlId!==f.urlId)&&p.loader&&this.abortCurrentFrag();let m=0;if(l.live||(i=f.details)!=null&&i.live){if(this.checkLiveUpdate(l),l.deltaUpdateFailed)return;m=this.alignPlaylists(l,f.details)}if(f.details=l,this.levelLastLoaded=a,this.hls.trigger(_.LEVEL_UPDATED,{details:l,level:a}),this.state===Se.WAITING_LEVEL){if(this.waitForCdnTuneIn(l))return;this.state=Se.IDLE}this.startFragRequested?l.live&&this.synchronizeToLiveEdge(l):this.setStartPosition(l,m),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:n,payload:a}=e,{levels:l}=this;if(!l){this.warn(`Levels were reset while fragment load was in progress. Fragment ${i.sn} of level ${i.level} will not be buffered`);return}const h=l[i.level],f=h.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=h.videoCodec,m=f.PTSKnown||!f.live,g=(t=i.initSegment)==null?void 0:t.data,A=this._getAudioCodec(h),b=this.transmuxer=this.transmuxer||new Sf(this.hls,it.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),x=n?n.index:-1,k=x!==-1,w=new Vc(i.level,i.sn,i.stats.chunkCount,a.byteLength,x,k),P=this.initPTS[i.cc];b.push(a,g,A,p,i,n,f.totalduration,m,w,P)}onAudioTrackSwitching(e,t){const i=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const l=this.fragCurrent;l&&(this.log("Switching to main audio track, cancel main fragment load"),l.abortRequests(),this.fragmentTracker.removeFragment(l)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const a=this.hls;i&&(a.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),a.trigger(_.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const i=t.id,n=!!this.hls.audioTracks[i].url;if(n){const a=this.videoBuffer;a&&this.mediaBuffer!==a&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=a)}this.altAudio=n,this.tick()}onBufferCreated(e,t){const i=t.tracks;let n,a,l=!1;for(const h in i){const f=i[h];if(f.id==="main"){if(a=h,n=f,h==="video"){const p=i[h];p&&(this.videoBuffer=p.buffer)}}else l=!0}l&&n?(this.log(`Alternate track found, use ${a}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i&&i.type!==it.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===Se.PARSED&&(this.state=Se.IDLE);return}const a=n?n.stats:i.stats;this.fragLastKbps=Math.round(8*a.total/(a.buffering.end-a.loading.first)),i.sn!=="initSegment"&&(this.fragPrevious=i),this.fragBufferedComplete(i,n)}onError(e,t){var i;if(t.fatal){this.state=Se.ERROR;return}switch(t.details){case fe.FRAG_GAP:case fe.FRAG_PARSING_ERROR:case fe.FRAG_DECRYPT_ERROR:case fe.FRAG_LOAD_ERROR:case fe.FRAG_LOAD_TIMEOUT:case fe.KEY_LOAD_ERROR:case fe.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(it.MAIN,t);break;case fe.LEVEL_LOAD_ERROR:case fe.LEVEL_LOAD_TIMEOUT:case fe.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Se.WAITING_LEVEL&&((i=t.context)==null?void 0:i.type)===Tt.LEVEL&&(this.state=Se.IDLE);break;case fe.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case fe.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Nt.getBuffered(e).length){const i=this.state!==Se.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,i)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=Se.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Ct.AUDIO||this.audioOnly&&!this.altAudio){const i=(t===Ct.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,t,it.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let i=this.startPosition;if(i>=0&&t<i){if(e.seeking){this.log(`could not seek to ${i}, already seeking at ${t}`);return}const n=Nt.getBuffered(e),l=(n.length?n.start(0):0)-i;l>0&&(l<this.config.maxBufferHole||l<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${l} to match buffer start`),i+=l,this.startPosition=i),this.log(`seek to target start position ${i} from current time ${t}`),e.currentTime=i}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(i=>{const{hls:n}=this;if(!i||this.fragContextChanged(e))return;t.fragmentError=0,this.state=Se.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const a=e.stats;a.parsing.start=a.parsing.end=a.buffering.start=a.buffering.end=self.performance.now(),n.trigger(_.FRAG_LOADED,i),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const i="main",{hls:n}=this,{remuxResult:a,chunkMeta:l}=e,h=this.getCurrentContext(l);if(!h){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:m}=h,{video:g,text:A,id3:b,initSegment:x}=a,{details:k}=m,w=this.altAudio?void 0:a.audio;if(this.fragContextChanged(f)){this.fragmentTracker.removeFragment(f);return}if(this.state=Se.PARSING,x){if(x!=null&&x.tracks){const N=f.initSegment||f;this._bufferInitSegment(m,x.tracks,N,l),n.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:N,id:i,tracks:x.tracks})}const P=x.initPTS,$=x.timescale;ze(P)&&(this.initPTS[f.cc]={baseTime:P,timescale:$},n.trigger(_.INIT_PTS_FOUND,{frag:f,id:i,initPTS:P,timescale:$}))}if(g&&k&&f.sn!=="initSegment"){const P=k.fragments[f.sn-1-k.startSN],$=f.sn===k.startSN,N=!P||f.cc>P.cc;if(a.independent!==!1){const{startPTS:I,endPTS:O,startDTS:K,endDTS:U}=g;if(p)p.elementaryStreams[g.type]={startPTS:I,endPTS:O,startDTS:K,endDTS:U};else if(g.firstKeyFrame&&g.independent&&l.id===1&&!N&&(this.couldBacktrack=!0),g.dropped&&g.independent){const re=this.getMainFwdBufferInfo(),ne=(re?re.end:this.getLoadPosition())+this.config.maxBufferHole,Y=g.firstKeyFramePTS?g.firstKeyFramePTS:I;if(!$&&ne<Y-this.config.maxBufferHole&&!N){this.backtrack(f);return}else N&&(f.gap=!0);f.setElementaryStreamInfo(g.type,f.start,O,f.start,U,!0)}f.setElementaryStreamInfo(g.type,I,O,K,U),this.backtrackFragment&&(this.backtrackFragment=f),this.bufferFragmentData(g,f,p,l,$||N)}else if($||N)f.gap=!0;else{this.backtrack(f);return}}if(w){const{startPTS:P,endPTS:$,startDTS:N,endDTS:I}=w;p&&(p.elementaryStreams[Ct.AUDIO]={startPTS:P,endPTS:$,startDTS:N,endDTS:I}),f.setElementaryStreamInfo(Ct.AUDIO,P,$,N,I),this.bufferFragmentData(w,f,p,l)}if(k&&b!=null&&(t=b.samples)!=null&&t.length){const P={id:i,frag:f,details:k,samples:b.samples};n.trigger(_.FRAG_PARSING_METADATA,P)}if(k&&A){const P={id:i,frag:f,details:k,samples:A.samples};n.trigger(_.FRAG_PARSING_USERDATA,P)}}_bufferInitSegment(e,t,i,n){if(this.state!==Se.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:a,video:l,audiovideo:h}=t;if(a){let f=e.audioCodec;const p=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(f&&(f.indexOf("mp4a.40.5")!==-1?f="mp4a.40.2":f="mp4a.40.5"),a.metadata.channelCount!==1&&p.indexOf("firefox")===-1&&(f="mp4a.40.5")),p.indexOf("android")!==-1&&a.container!=="audio/mpeg"&&(f="mp4a.40.2",this.log(`Android: force audio codec to ${f}`)),e.audioCodec&&e.audioCodec!==f&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${f}"`),a.levelCodec=f,a.id="main",this.log(`Init audio buffer, container:${a.container}, codecs[selected/level/parsed]=[${f||""}/${e.audioCodec||""}/${a.codec}]`)}l&&(l.levelCodec=e.videoCodec,l.id="main",this.log(`Init video buffer, container:${l.container}, codecs[level/parsed]=[${e.videoCodec||""}/${l.codec}]`)),h&&this.log(`Init audiovideo buffer, container:${h.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${h.codec}]`),this.hls.trigger(_.BUFFER_CODECS,t),Object.keys(t).forEach(f=>{const m=t[f].initSegment;m!=null&&m.byteLength&&this.hls.trigger(_.BUFFER_APPENDING,{type:f,data:m,frag:i,part:null,chunkMeta:n,parent:i.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,it.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=Se.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const i=e.currentTime;if(Nt.isBuffered(e,i)?t=this.getAppendedFrag(i):Nt.isBuffered(e,i+.1)&&(t=this.getAppendedFrag(i+.1)),t){this.backtrackFragment=null;const n=this.fragPlaying,a=t.level;(!n||t.sn!==n.sn||n.level!==a||t.urlId!==n.urlId)&&(this.fragPlaying=t,this.hls.trigger(_.FRAG_CHANGED,{frag:t}),(!n||n.level!==a)&&this.hls.trigger(_.LEVEL_SWITCHED,{level:a}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,i=this.currentFrag;if(i&&ze(t)&&ze(i.programDateTime)){const n=i.programDateTime+(t-i.start)*1e3;return new Date(n)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class In{constructor(e,t=0,i=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=i}sample(e,t){const i=Math.pow(this.alpha_,e);this.estimate_=t*(1-i)+i*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class PA{constructor(e,t,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 In(e),this.fast_=new In(t),this.defaultTTFB_=n,this.ttfb_=new In(e)}update(e,t){const{slow_:i,fast_:n,ttfb_:a}=this;i.halfLife!==e&&(this.slow_=new In(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.fast_=new In(t,n.getEstimate(),n.getTotalWeight())),a.halfLife!==e&&(this.ttfb_=new In(e,a.getEstimate(),a.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const i=8*t,n=e/1e3,a=i/n;this.fast_.sample(n,a),this.slow_.sample(n,a)}sampleTTFB(e){const t=e/1e3,i=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(i,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class $A{constructor(e){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=e;const t=e.config;this.bwEstimator=new PA(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i;const n=t.frag;this.ignoreFragment(n)||(this.fragCurrent=n,this.partCurrent=(i=t.part)!=null?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,n){const a=e+i/t,l=n?this.lastLevelLoadSec:0;return a+l}onLevelLoaded(e,t){const i=this.hls.config,{total:n,bwEstimate:a}=t.stats;ze(n)&&ze(a)&&(this.lastLevelLoadSec=8*n/a),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{autoLevelEnabled:n,media:a}=i;if(!e||!a)return;const l=performance.now(),h=t?t.stats:e.stats,f=t?t.duration:e.duration,p=l-h.loading.start;if(h.aborted||h.loaded&&h.loaded===h.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const m=i.mainForwardBufferInfo;if(m===null)return;const g=this.bwEstimator.getEstimateTTFB(),A=Math.abs(a.playbackRate);if(p<=Math.max(g,1e3*(f/(A*2))))return;const b=m.len/A;if(b>=2*f/A)return;const x=h.loading.first?h.loading.first-h.loading.start:-1,k=h.loaded&&x>-1,w=this.bwEstimator.getEstimate(),{levels:P,minAutoLevel:$}=i,N=P[e.level],I=h.total||Math.max(h.loaded,Math.round(f*N.maxBitrate/8));let O=p-x;O<1&&k&&(O=Math.min(p,h.loaded*8/w));const K=k?h.loaded*1e3/O:0,U=K?(I-h.loaded)/K:I*8/w+g/1e3;if(U<=b)return;const re=K?K*8:w;let ne=Number.POSITIVE_INFINITY,Y;for(Y=e.level-1;Y>$;Y--){const Ee=P[Y].maxBitrate;if(ne=this.getTimeToLoadFrag(g/1e3,re,f*Ee,!P[Y].details),ne<b)break}ne>=U||ne>f*10||(i.nextLoadLevel=Y,k?this.bwEstimator.sample(p-Math.min(g,x),h.loaded):this.bwEstimator.sampleTTFB(p),this.clearTimer(),q.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
186
+ Time to underbuffer: ${b.toFixed(3)} s
187
+ Estimated load time for current fragment: ${U.toFixed(3)} s
188
+ Estimated load time for down switch fragment: ${ne.toFixed(3)} s
189
+ TTFB estimate: ${x}
190
+ Current BW estimate: ${ze(w)?(w/1024).toFixed(3):"Unknown"} Kb/s
191
+ New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
192
+ Aborting and switching to level ${Y}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),i.trigger(_.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:h}))}onFragLoaded(e,{frag:t,part:i}){const n=i?i.stats:t.stats;if(t.type===it.MAIN&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const a=i?i.duration:t.duration,l=this.hls.levels[t.level],h=(l.loaded?l.loaded.bytes:0)+n.loaded,f=(l.loaded?l.loaded.duration:0)+a;l.loaded={bytes:h,duration:f},l.realBitrate=Math.round(8*h/f)}if(t.bitrateTest){const a={stats:n,frag:t,part:i,id:t.type};this.onFragBuffered(_.FRAG_BUFFERED,a),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:i,part:n}=t,a=n!=null&&n.stats.loaded?n.stats:i.stats;if(a.aborted||this.ignoreFragment(i))return;const l=a.parsing.end-a.loading.start-Math.min(a.loading.first-a.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(l,a.loaded),a.bwEstimate=this.bwEstimator.getEstimate(),i.bitrateTest?this.bitrateTestDelay=l/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==it.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let i=this.getNextABRAutoLevel();if(e!==-1){const n=this.hls.levels;if(n.length>Math.max(e,i)&&n[e].loadError<=n[i].loadError)return e}return e!==-1&&(i=Math.min(e,i)),i}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:i}=this,{maxAutoLevel:n,config:a,minAutoLevel:l,media:h}=i,f=t?t.duration:e?e.duration:0,p=h&&h.playbackRate!==0?Math.abs(h.playbackRate):1,m=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,g=i.mainForwardBufferInfo,A=(g?g.len:0)/p;let b=this.findBestLevel(m,l,n,A,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(b>=0)return b;q.trace(`[abr] ${A?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let x=f?Math.min(f,a.maxStarvationDelay):a.maxStarvationDelay,k=a.abrBandWidthFactor,w=a.abrBandWidthUpFactor;if(!A){const P=this.bitrateTestDelay;P&&(x=(f?Math.min(f,a.maxLoadingDelay):a.maxLoadingDelay)-P,q.trace(`[abr] bitrate test took ${Math.round(1e3*P)}ms, set first fragment max fetchDuration to ${Math.round(1e3*x)} ms`),k=w=1)}return b=this.findBestLevel(m,l,n,A+x,k,w),Math.max(b,0)}findBestLevel(e,t,i,n,a,l){var h;const{fragCurrent:f,partCurrent:p,lastLoadedFragLevel:m}=this,{levels:g}=this.hls,A=g[m],b=!!(A!=null&&(h=A.details)!=null&&h.live),x=A==null?void 0:A.codecSet,k=p?p.duration:f?f.duration:0,w=this.bwEstimator.getEstimateTTFB()/1e3;let P=t,$=-1;for(let N=i;N>=t;N--){const I=g[N];if(!I||x&&I.codecSet!==x){I&&(P=Math.min(N,P),$=Math.max(N,$));continue}$!==-1&&q.trace(`[abr] Skipped level(s) ${P}-${$} with CODECS:"${g[$].attrs.CODECS}"; not compatible with "${A.attrs.CODECS}"`);const O=I.details,K=(p?O==null?void 0:O.partTarget:O==null?void 0:O.averagetargetduration)||k;let U;N<=m?U=a*e:U=l*e;const re=g[N].maxBitrate,ne=this.getTimeToLoadFrag(w,U,re*K,O===void 0);if(q.trace(`[abr] level:${N} adjustedbw-bitrate:${Math.round(U-re)} avgDuration:${K.toFixed(1)} maxFetchDuration:${n.toFixed(1)} fetchDuration:${ne.toFixed(1)}`),U>re&&(ne===0||!ze(ne)||b&&!this.bitrateTestDelay||ne<n))return N}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}}class wf{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let i;if(e.length)e.length===1?i=e[0]:i=FA(e,t);else return new Uint8Array(0);return this.reset(),i}reset(){this.chunks.length=0,this.dataLength=0}}function FA(r,e){const t=new Uint8Array(e);let i=0;for(let n=0;n<r.length;n++){const a=r[n];t.set(a,i),i+=a.length}return t}const _f=100;class MA extends jc{constructor(e,t,i){super(e,t,i,"[audio-stream-controller]",it.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:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(_.ERROR,this.onError,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this),e.on(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(_.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(_.ERROR,this.onError,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this),e.off(_.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:a}){if(i==="main"){const l=t.cc;this.initPTS[t.cc]={baseTime:n,timescale:a},this.log(`InitPTS for cc: ${l} found from main: ${n}`),this.videoTrackCC=l,this.state===Se.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=Se.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(_f),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=Se.IDLE):(this.loadedmetadata=!1,this.state=Se.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case Se.IDLE:this.doTickIdle();break;case Se.WAITING_TRACK:{var e;const{levels:i,trackId:n}=this,a=i==null||(e=i[n])==null?void 0:e.details;if(a){if(this.waitForCdnTuneIn(a))break;this.state=Se.WAITING_INIT_PTS}break}case Se.FRAG_LOADING_WAITING_RETRY:{var t;const i=performance.now(),n=this.retryDate;(!n||i>=n||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Se.IDLE);break}case Se.WAITING_INIT_PTS:{const i=this.waitingData;if(i){const{frag:n,part:a,cache:l,complete:h}=i;if(this.initPTS[n.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=Se.FRAG_LOADING;const f=l.flush(),p={frag:n,part:a,payload:f,networkDetails:null};this._handleFragmentLoadProgress(p),h&&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=Nt.bufferInfo(this.mediaBuffer,f,this.config.maxBufferHole);Uc(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=Se.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Se.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:i,trackId:n}=this,a=e.config;if(!(t!=null&&t[n])||!i&&(this.startFragRequested||!a.startFragPrefetch))return;const l=t[n],h=l.details;if(!h||h.live&&this.levelLastLoaded!==n||this.waitForCdnTuneIn(h)){this.state=Se.WAITING_TRACK;return}const f=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&f&&(this.bufferFlushed=!1,this.afterBufferFlushed(f,Ct.AUDIO,it.AUDIO));const p=this.getFwdBufferInfo(f,it.AUDIO);if(p===null)return;const{bufferedTrack:m,switchingTrack:g}=this;if(!g&&this._streamEnded(p,h)){e.trigger(_.BUFFER_EOS,{type:"audio"}),this.state=Se.ENDED;return}const A=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,it.MAIN),b=p.len,x=this.getMaxBufferLength(A==null?void 0:A.len);if(b>=x&&!g)return;const w=h.fragments[0].start;let P=p.end;if(g&&i){const O=this.getLoadPosition();m&&g.attrs!==m.attrs&&(P=O),h.PTSKnown&&O<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 $=this.getNextFragment(P,h),N=!1;if($&&this.isLoopLoading($,P)&&(N=!!$.gap,$=this.getNextFragmentLoopLoading($,h,p,it.MAIN,x)),!$){this.bufferFlushed=!0;return}const I=A&&$.start>A.end+h.targetduration;if(I||!(A!=null&&A.len)&&p.len){const O=this.getAppendedFrag($.start,it.MAIN);if(O===null||(N||(N=!!O.gap||!!I&&A.len===0),I&&!N||N&&p.nextStart&&p.nextStart<O.end))return}this.loadFragment($,l,P)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(i=>new Io(i))}onAudioTrackSwitching(e,t){const i=!!t.url;this.trackId=t.id;const{fragCurrent:n}=this;n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(_f):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=Se.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=Se.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(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(_.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var i;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:n}=this,{details:a,id:l}=t;if(!n){this.warn(`Audio tracks were reset while loading level ${l}`);return}this.log(`Track ${l} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`);const h=n[l];let f=0;if(a.live||(i=h.details)!=null&&i.live){this.checkLiveUpdate(a);const p=this.mainDetails;if(a.deltaUpdateFailed||!p)return;!h.details&&a.hasProgramDateTime&&p.hasProgramDateTime?(sf(a,p),f=a.fragments[0].start):f=this.alignPlaylists(a,h.details)}h.details=a,this.levelLastLoaded=l,!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(h.details,f),this.state===Se.WAITING_TRACK&&!this.waitForCdnTuneIn(a)&&(this.state=Se.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:i,part:n,payload:a}=e,{config:l,trackId:h,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[h];if(!p){this.warn("Audio track is undefined on fragment load progress");return}const m=p.details;if(!m){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(i.start);return}const g=l.defaultAudioCodec||p.audioCodec||"mp4a.40.2";let A=this.transmuxer;A||(A=this.transmuxer=new Sf(this.hls,it.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const b=this.initPTS[i.cc],x=(t=i.initSegment)==null?void 0:t.data;if(b!==void 0){const w=n?n.index:-1,P=w!==-1,$=new Vc(i.level,i.sn,i.stats.chunkCount,a.byteLength,w,P);A.push(a,x,g,"",i,n,m.totalduration,!1,$,b)}else{this.log(`Unknown video PTS for cc ${i.cc}, waiting for video PTS before demuxing audio frag ${i.sn} of [${m.startSN} ,${m.endSN}],track ${h}`);const{cache:k}=this.waitingData=this.waitingData||{frag:i,part:n,cache:new wf,complete:!1};k.push(new Uint8Array(a)),this.waitingVideoCC=this.videoTrackCC,this.state=Se.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:i,part:n}=t;if(i.type!==it.AUDIO){if(!this.loadedmetadata&&i.type===it.MAIN){const a=this.videoBuffer||this.media;a&&Nt.getBuffered(a).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 a=this.switchingTrack;a&&(this.bufferedTrack=a,this.switchingTrack=null,this.hls.trigger(_.AUDIO_TRACK_SWITCHED,Yi({},a)))}this.fragBufferedComplete(i,n)}onError(e,t){var i;if(t.fatal){this.state=Se.ERROR;return}switch(t.details){case fe.FRAG_GAP:case fe.FRAG_PARSING_ERROR:case fe.FRAG_DECRYPT_ERROR:case fe.FRAG_LOAD_ERROR:case fe.FRAG_LOAD_TIMEOUT:case fe.KEY_LOAD_ERROR:case fe.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(it.AUDIO,t);break;case fe.AUDIO_TRACK_LOAD_ERROR:case fe.AUDIO_TRACK_LOAD_TIMEOUT:case fe.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===Se.WAITING_TRACK&&((i=t.context)==null?void 0:i.type)===Tt.AUDIO_TRACK&&(this.state=Se.IDLE);break;case fe.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case fe.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Ct.AUDIO&&(this.bufferFlushed=!0,this.state===Se.ENDED&&(this.state=Se.IDLE))}_handleTransmuxComplete(e){var t;const i="audio",{hls:n}=this,{remuxResult:a,chunkMeta:l}=e,h=this.getCurrentContext(l);if(!h){this.resetWhenMissingContext(l);return}const{frag:f,part:p,level:m}=h,{details:g}=m,{audio:A,text:b,id3:x,initSegment:k}=a;if(this.fragContextChanged(f)||!g){this.fragmentTracker.removeFragment(f);return}if(this.state=Se.PARSING,this.switchingTrack&&A&&this.completeAudioSwitch(this.switchingTrack),k!=null&&k.tracks){const w=f.initSegment||f;this._bufferInitSegment(k.tracks,w,l),n.trigger(_.FRAG_PARSING_INIT_SEGMENT,{frag:w,id:i,tracks:k.tracks})}if(A){const{startPTS:w,endPTS:P,startDTS:$,endDTS:N}=A;p&&(p.elementaryStreams[Ct.AUDIO]={startPTS:w,endPTS:P,startDTS:$,endDTS:N}),f.setElementaryStreamInfo(Ct.AUDIO,w,P,$,N),this.bufferFragmentData(A,f,p,l)}if(x!=null&&(t=x.samples)!=null&&t.length){const w=ci({id:i,frag:f,details:g},x);n.trigger(_.FRAG_PARSING_METADATA,w)}if(b){const w=ci({id:i,frag:f,details:g},b);n.trigger(_.FRAG_PARSING_USERDATA,w)}}_bufferInitSegment(e,t,i){if(this.state!==Se.PARSING)return;e.video&&delete e.video;const n=e.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(_.BUFFER_CODECS,e);const a=n.initSegment;if(a!=null&&a.byteLength){const l={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:a};this.hls.trigger(_.BUFFER_APPENDING,l)}this.tick()}loadFragment(e,t,i){const n=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||n===gi.NOT_LOADED||n===gi.PARTIAL){var a;e.sn==="initSegment"?this._loadInitSegment(e,t):(a=t.details)!=null&&a.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=Se.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,i))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:i,bufferedTrack:n}=this,a=n==null?void 0:n.attrs,l=e.attrs;i&&a&&(a.CHANNELS!==l.CHANNELS||a.NAME!==l.NAME||a.LANGUAGE!==l.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(_.AUDIO_TRACK_SWITCHED,Yi({},e))}}class NA extends Bc{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(_.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(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:i,groupId:n,details:a}=t,l=this.tracksInGroup[i];if(!l||l.groupId!==n){this.warn(`Track with id:${i} and group:${n} not found in active group ${l.groupId}`);return}const h=l.details;l.details=t.details,this.log(`audio-track ${i} "${l.name}" lang:${l.lang} group:${n} loaded [${a.startSN}-${a.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,h)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;const i=t.audioGroupIds[t.urlId];if(this.groupId!==i){this.groupId=i||null;const n=this.tracks.filter(l=>!i||l.groupId===i);this.selectDefaultTrack&&!n.some(l=>l.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=n;const a={audioTracks:n};this.log(`Updating audio tracks, ${n.length} track(s) found in group:${i}`),this.hls.trigger(_.AUDIO_TRACKS_UPDATED,a),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===Tt.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const i=this.currentTrack;t[this.trackId];const n=t[e],{groupId:a,name:l}=n;if(this.log(`Switching to audio-track ${e} "${l}" lang:${n.lang} group:${a}`),this.trackId=e,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(_.AUDIO_TRACK_SWITCHING,Yi({},n)),n.details&&!n.details.live)return;const h=this.switchParams(n.url,i==null?void 0:i.details);this.loadPlaylist(h)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{const i=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(i.message),this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:i})}}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===n.attrs["STABLE-RENDITION-ID"]||e.name===n.name&&e.lang===n.lang))return n.id}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,n=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`loading audio-track playlist ${i} "${t.name}" lang:${t.lang} group:${n}`),this.clearTimer(),this.hls.trigger(_.AUDIO_TRACK_LOADING,{url:a,id:i,groupId:n,deliveryDirectives:e||null})}}}function Rf(r,e){if(r.length!==e.length)return!1;for(let t=0;t<r.length;t++)if(!UA(r[t].attrs,e[t].attrs))return!1;return!0}function UA(r,e){const t=r["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(i=>r[i]!==e[i])}const Lf=500;class BA extends jc{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",it.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.LEVEL_LOADED,this.onLevelLoaded,this),e.on(_.ERROR,this.onError,this),e.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.LEVEL_LOADED,this.onLevelLoaded,this),e.off(_.ERROR,this.onError,this),e.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(_.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=Se.IDLE,this.setInterval(Lf),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:i,success:n}=t;if(this.fragPrevious=i,this.state=Se.IDLE,!n)return;const a=this.tracksBuffered[this.currentTrackId];if(!a)return;let l;const h=i.start;for(let p=0;p<a.length;p++)if(h>=a[p].start&&h<=a[p].end){l=a[p];break}const f=i.start+i.duration;l?l.end=f:(l={start:h,end:f},a.push(l)),this.fragmentTracker.fragBuffered(i)}onBufferFlushing(e,t){const{startOffset:i,endOffset:n}=t;if(i===0&&n!==Number.POSITIVE_INFINITY){const a=n-1;if(a<=0)return;t.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach(l=>{for(let h=0;h<l.length;){if(l[h].end<=a){l.shift();continue}else if(l[h].start<a)l[h].start=a;else break;h++}}),this.fragmentTracker.removeFragmentsInRange(i,a,it.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===it.MAIN){var i;(i=this.media)!=null&&i.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const i=t.frag;(i==null?void 0:i.type)===it.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==Se.STOPPED&&(this.state=Se.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Rf(this.levels,t)){this.levels=t.map(i=>new Io(i));return}this.tracksBuffered=[],this.levels=t.map(i=>{const n=new Io(i);return this.tracksBuffered[n.id]=[],n}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,it.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.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(Lf)}onSubtitleTrackLoaded(e,t){var i;const{details:n,id:a}=t,{currentTrackId:l,levels:h}=this;if(!h.length)return;const f=h[l];if(a>=h.length||a!==l||!f)return;this.mediaBuffer=this.mediaBufferTimeRanges;let p=0;if(n.live||(i=f.details)!=null&&i.live){const m=this.mainDetails;if(n.deltaUpdateFailed||!m)return;const g=m.fragments[0];f.details?(p=this.alignPlaylists(n,f.details),p===0&&g&&(p=g.start,Mc(n,p))):n.hasProgramDateTime&&m.hasProgramDateTime?(sf(n,m),p=n.fragments[0].start):g&&(p=g.start,Mc(n,p))}f.details=n,this.levelLastLoaded=a,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(f.details,p),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===Se.IDLE&&(Do(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}_handleFragmentLoadComplete(e){const{frag:t,payload:i}=e,n=t.decryptdata,a=this.hls;if(!this.fragContextChanged(t)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&n.method==="AES-128"){const l=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(h=>{throw a.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.FRAG_DECRYPT_ERROR,fatal:!1,error:h,reason:h.message,frag:t}),h}).then(h=>{const f=performance.now();a.trigger(_.FRAG_DECRYPTED,{frag:t,payload:h,stats:{tstart:l,tdecrypt:f}})}).catch(h=>{this.warn(`${h.name}: ${h.message}`),this.state=Se.IDLE})}}doTick(){if(!this.media){this.state=Se.IDLE;return}if(this.state===Se.IDLE){const{currentTrackId:e,levels:t}=this,i=t[e];if(!t.length||!i||!i.details)return;const{config:n}=this,a=this.getLoadPosition(),l=Nt.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],a,n.maxBufferHole),{end:h,len:f}=l,p=this.getFwdBufferInfo(this.media,it.MAIN),m=i.details,g=this.getMaxBufferLength(p==null?void 0:p.len)+m.levelTargetDuration;if(f>g)return;const A=m.fragments,b=A.length,x=m.edge;let k=null;const w=this.fragPrevious;if(h<x){const P=n.maxFragLookUpTolerance,$=h>x-P?0:P;k=Do(w,A,Math.max(A[0].start,h),$),!k&&w&&w.start<A[0].start&&(k=A[0])}else k=A[b-1];if(!k)return;if(k=this.mapToInitFragWhenRequired(k),k.sn!=="initSegment"){const P=k.sn-m.startSN,$=A[P-1];$&&$.cc===k.cc&&this.fragmentTracker.getState($)===gi.NOT_LOADED&&(k=$)}this.fragmentTracker.getState(k)===gi.NOT_LOADED&&this.loadFragment(k,i,h)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,i){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,i))}get mediaBufferTimeRanges(){return new GA(this.tracksBuffered[this.currentTrackId]||[])}}class GA{constructor(e){this.buffered=void 0;const t=(i,n,a)=>{if(n=n>>>0,n>a-1)throw new DOMException(`Failed to execute '${i}' on 'TimeRanges': The index provided (${n}) is greater than the maximum bound (${a})`);return e[n][i]};this.buffered={get length(){return e.length},end(i){return t("end",i,e.length)},start(i){return t("start",i,e.length)}}}}class VA extends Bc{constructor(e){super(e,"[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(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.LEVEL_LOADING,this.onLevelLoading,this),e.on(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.LEVEL_LOADING,this.onLevelLoading,this),e.off(_.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(_.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(_.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),ru(this.media.textTracks).forEach(t=>{Rn(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:i,details:n}=t,{trackId:a}=this,l=this.tracksInGroup[a];if(!l){this.warn(`Invalid subtitle track id ${i}`);return}const h=l.details;l.details=t.details,this.log(`subtitle track ${i} loaded [${n.startSN}-${n.endSN}]`),i===this.trackId&&this.playlistLoaded(i,t,h)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;const i=t.textGroupIds[t.urlId],n=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==i){const a=this.tracks.filter(f=>!i||f.groupId===i);this.tracksInGroup=a;const l=this.findTrackId(n==null?void 0:n.name)||this.findTrackId();this.groupId=i||null;const h={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${i}" group-id`),this.hls.trigger(_.SUBTITLE_TRACKS_UPDATED,h),l!==-1&&this.setSubtitleTrack(l,n)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId,n)}findTrackId(e){const t=this.tracksInGroup;for(let i=0;i<t.length;i++){const n=t[i];if((!this.selectDefaultTrack||n.default)&&(!e||e===n.name))return n.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===Tt.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const i=t.id,n=t.groupId;let a=t.url;if(e)try{a=e.addDirectives(a)}catch(l){this.warn(`Could not construct new URL with HLS Delivery Directives: ${l}`)}this.log(`Loading subtitle playlist for id ${i}`),this.hls.trigger(_.SUBTITLE_TRACK_LOADING,{url:a,id:i,groupId:n,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:t,trackId:i}=this;if(!t)return;const n=ru(t.textTracks),a=n.filter(h=>h.groupId===this.groupId);if(e===-1)[].slice.call(n).forEach(h=>{h.mode="disabled"});else{const h=a[i];h&&(h.mode="disabled")}const l=a[e];l&&(l.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i;const n=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(i=n[e])!=null&&i.details)||e<-1||e>=n.length)return;this.clearTimer();const a=n[e];if(this.log(`Switching to subtitle-track ${e}`+(a?` "${a.name}" lang:${a.lang} group:${a.groupId}`:"")),this.trackId=e,a){const{id:l,groupId:h="",name:f,type:p,url:m}=a;this.hls.trigger(_.SUBTITLE_TRACK_SWITCH,{id:l,groupId:h,name:f,type:p,url:m});const g=this.switchParams(a.url,t==null?void 0:t.details);this.loadPlaylist(g)}else this.hls.trigger(_.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=ru(this.media.textTracks);for(let i=0;i<t.length;i++)if(t[i].mode==="hidden")e=i;else if(t[i].mode==="showing"){e=i;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}function ru(r){const e=[];for(let t=0;t<r.length;t++){const i=r[t];(i.kind==="subtitles"||i.kind==="captions")&&i.label&&e.push(r[t])}return e}class HA{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){const i=this.queues[t];i.push(e),i.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const i=new Promise(a=>{t=a}),n={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,e),i}executeNext(e){const{buffers:t,queues:i}=this,n=t[e],a=i[e];if(a.length){const l=a[0];try{l.execute()}catch(h){q.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),l.onError(h),n!=null&&n.updating||(a.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const Cf=Wa(),If=/([ha]vc.)(?:\.[^.,]+)+/;class WA{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:t,mediaSource:i}=this;q.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(_.MEDIA_ATTACHED,{media:t})),i&&i.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{q.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{q.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:i}=this;t&&t.src!==i&&q.error(`Media element src was set while attaching MediaSource (${i} > ${t.src})`)},this.hls=e,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:e}=this;e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_RESET,this.onBufferReset,this),e.on(_.BUFFER_APPENDING,this.onBufferAppending,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.BUFFER_EOS,this.onBufferEos,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(_.FRAG_PARSED,this.onFragParsed,this),e.on(_.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_RESET,this.onBufferReset,this),e.off(_.BUFFER_APPENDING,this.onBufferAppending,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.BUFFER_EOS,this.onBufferEos,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(_.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(_.FRAG_PARSED,this.onFragParsed,this),e.off(_.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new HA(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let i=2;(t.audio&&!t.video||!t.altAudio)&&(i=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=i,q.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const i=this.media=t.media;if(i&&Cf){const n=this.mediaSource=new Cf;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:e,mediaSource:t,_objectUrl:i}=this;if(t){if(q.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(n){q.warn(`[buffer-controller]: onMediaDetaching: ${n.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),i&&self.URL.revokeObjectURL(i),e.src===i?(e.removeAttribute("src"),e.load()):q.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(_.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(i){q.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,i)}}),this._initSourceBuffer()}onBufferCodecs(e,t){const i=this.getSourceBufferTypes().length;Object.keys(t).forEach(n=>{if(i){const a=this.tracks[n];if(a&&typeof a.buffer.changeType=="function"){const{id:l,codec:h,levelCodec:f,container:p,metadata:m}=t[n],g=(a.levelCodec||a.codec).replace(If,"$1"),A=(f||h).replace(If,"$1");if(g!==A){const b=`${p};codecs=${f||h}`;this.appendChangeType(n,b),q.log(`[buffer-controller]: switching codec ${g} to ${A}`),this.tracks[n]={buffer:a.buffer,codec:h,container:p,levelCodec:f,metadata:m,id:l}}}}else this.pendingTracks[n]=t[n]}),!i&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:i}=this,n={execute:()=>{const a=this.sourceBuffer[e];a&&(q.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),a.changeType(t)),i.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:a=>{q.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,a)}};i.append(n,e)}onBufferAppending(e,t){const{hls:i,operationQueue:n,tracks:a}=this,{data:l,type:h,frag:f,part:p,chunkMeta:m}=t,g=m.buffering[h],A=self.performance.now();g.start=A;const b=f.stats.buffering,x=p?p.stats.buffering:null;b.start===0&&(b.start=A),x&&x.start===0&&(x.start=A);const k=a.audio;let w=!1;h==="audio"&&(k==null?void 0:k.container)==="audio/mpeg"&&(w=!this.lastMpegAudioChunk||m.id===1||this.lastMpegAudioChunk.sn!==m.sn,this.lastMpegAudioChunk=m);const P=f.start,$={execute:()=>{if(g.executeStart=self.performance.now(),w){const N=this.sourceBuffer[h];if(N){const I=P-N.timestampOffset;Math.abs(I)>=.1&&(q.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${P} (delta: ${I}) sn: ${f.sn})`),N.timestampOffset=P)}}this.appendExecutor(l,h)},onStart:()=>{},onComplete:()=>{const N=self.performance.now();g.executeEnd=g.end=N,b.first===0&&(b.first=N),x&&x.first===0&&(x.first=N);const{sourceBuffer:I}=this,O={};for(const K in I)O[K]=Nt.getBuffered(I[K]);this.appendError=0,this.hls.trigger(_.BUFFER_APPENDED,{type:h,frag:f,part:p,chunkMeta:m,parent:f.type,timeRanges:O})},onError:N=>{q.error(`[buffer-controller]: Error encountered while trying to append to the ${h} SourceBuffer`,N);const I={type:tt.MEDIA_ERROR,parent:f.type,details:fe.BUFFER_APPEND_ERROR,frag:f,part:p,chunkMeta:m,error:N,err:N,fatal:!1};N.code===DOMException.QUOTA_EXCEEDED_ERR?I.details=fe.BUFFER_FULL_ERROR:(this.appendError++,I.details=fe.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(q.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),I.fatal=!0)),i.trigger(_.ERROR,I)}};n.append($,h)}onBufferFlushing(e,t){const{operationQueue:i}=this,n=a=>({execute:this.removeExecutor.bind(this,a,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(_.BUFFER_FLUSHED,{type:a})},onError:l=>{q.warn(`[buffer-controller]: Failed to remove from ${a} SourceBuffer`,l)}});t.type?i.append(n(t.type),t.type):this.getSourceBufferTypes().forEach(a=>{i.append(n(a),a)})}onFragParsed(e,t){const{frag:i,part:n}=t,a=[],l=n?n.elementaryStreams:i.elementaryStreams;l[Ct.AUDIOVIDEO]?a.push("audiovideo"):(l[Ct.AUDIO]&&a.push("audio"),l[Ct.VIDEO]&&a.push("video"));const h=()=>{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(_.FRAG_BUFFERED,{frag:i,part:n,stats:p,id:i.type})};a.length===0&&q.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: ${i.sn}`),this.blockBuffers(h,a)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((n,a)=>{const l=this.sourceBuffer[a];return l&&(!t.type||t.type===a)&&(l.ending=!0,l.ended||(l.ended=!0,q.log(`[buffer-controller]: ${a} sourceBuffer now EOS`))),n&&!!(!l||l.ended)},!0)&&(q.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(a=>{const l=this.sourceBuffer[a];l&&(l.ending=!1)});const{mediaSource:n}=this;if(!n||n.readyState!=="open"){n&&q.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${n.readyState}`);return}q.log("[buffer-controller]: Calling mediaSource.endOfStream()"),n.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:i,sourceBuffer:n}=this;if(!i||t===null)return;const a=this.getSourceBufferTypes();if(!a.length)return;const l=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!ze(l)||l<0)return;const h=i.currentTime,f=t.levelTargetDuration,p=Math.max(l,f),m=Math.floor(h/f)*f-p;a.forEach(g=>{const A=n[g];if(A){const b=Nt.getBuffered(A);if(b.length>0&&m>b.start(0)){if(e.trigger(_.BACK_BUFFER_REACHED,{bufferEnd:m}),t.live)e.trigger(_.LIVE_BACK_BUFFER_REACHED,{bufferEnd:m});else if(A.ended&&b.end(b.length-1)-h<f*2){q.info(`[buffer-controller]: Cannot flush ${g} back buffer while SourceBuffer is in ended state`);return}e.trigger(_.BUFFER_FLUSHING,{startOffset:0,endOffset:m,type:g})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:i,mediaSource:n}=this,a=e.fragments[0].start+e.totalduration,l=i.duration,h=ze(n.duration)?n.duration:0;e.live&&t.config.liveDurationInfinity?(q.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(e)):(a>h&&a>l||!ze(l))&&(q.log(`[buffer-controller]: Updating Media Source duration to ${a.toFixed(3)}`),n.duration=a)}updateSeekableRange(e){const t=this.mediaSource,i=e.fragments;if(i.length&&e.live&&t!=null&&t.setLiveSeekableRange){const a=Math.max(0,i[0].start),l=Math.max(a,a+e.totalduration);t.setLiveSeekableRange(a,l)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:i}=this,n=Object.keys(i).length;if(n&&!e||n===2){this.createSourceBuffers(i),this.pendingTracks={};const a=this.getSourceBufferTypes();if(a.length)this.hls.trigger(_.BUFFER_CREATED,{tracks:this.tracks}),a.forEach(l=>{t.executeNext(l)});else{const l=new Error("could not create source buffer for media codec(s)");this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:l,reason:l.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);const l=a.levelCodec||a.codec,h=`${a.container};codecs=${l}`;q.log(`[buffer-controller]: creating sourceBuffer(${h})`);try{const f=t[n]=i.addSourceBuffer(h),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:l,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(f){q.error(`[buffer-controller]: error while trying to add sourceBuffer: ${f.message}`),this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:f,mimeType:h})}}}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const i=new Error(`${e} SourceBuffer error`);q.error(`[buffer-controller]: ${i}`,t),this.hls.trigger(_.ERROR,{type:tt.MEDIA_ERROR,details:fe.BUFFER_APPENDING_ERROR,error:i,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(t)}removeExecutor(e,t,i){const{media:n,mediaSource:a,operationQueue:l,sourceBuffer:h}=this,f=h[e];if(!n||!a||!f){q.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),l.shiftAndExecuteNext(e);return}const p=ze(n.duration)?n.duration:1/0,m=ze(a.duration)?a.duration:1/0,g=Math.max(0,t),A=Math.min(i,p,m);A>g&&!f.ending?(f.ended=!1,q.log(`[buffer-controller]: Removing [${g},${A}] from the ${e} SourceBuffer`),f.remove(g,A)):l.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:i,sourceBuffer:n}=this,a=n[t];if(!a){q.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(t);return}a.ended=!1,a.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){q.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:i}=this,n=t.map(a=>i.appendBlocker(a));Promise.all(n).then(()=>{e(),t.forEach(a=>{const l=this.sourceBuffer[a];l!=null&&l.updating||i.shiftAndExecuteNext(a)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){const n=this.sourceBuffer[e];if(!n)return;const a=i.bind(this,e);this.listeners[e].push({event:t,listener:a}),n.addEventListener(t,a)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(i=>{t.removeEventListener(i.event,i.listener)})}}const Df={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},Of=function(e){let t=e;return Df.hasOwnProperty(e)&&(t=Df[e]),String.fromCharCode(t)},_r=15,as=100,jA={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},KA={17:2,18:4,21:6,22:8,23:10,19:13,20:15},zA={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},YA={25:2,26:4,29:6,30:8,31:10,27:13,28:15},XA=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class ZA{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const i=typeof t=="function"?t():t;q.log(`${this.time} [${e}] ${i}`)}}}const dn=function(e){const t=[];for(let i=0;i<e.length;i++)t.push(e[i].toString(16));return t};class Pf{constructor(e,t,i,n,a){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=i||!1,this.background=n||"black",this.flash=a||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let i=0;i<t.length;i++){const n=t[i];e.hasOwnProperty(n)&&(this[n]=e[n])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class qA{constructor(e,t,i,n,a,l){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Pf(t,i,n,a,l)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class QA{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<as;t++)this.chars.push(new qA);this.logger=e,this.pos=0,this.currPenState=new Pf}equals(e){let t=!0;for(let i=0;i<as;i++)if(!this.chars[i].equals(e.chars[i])){t=!1;break}return t}copy(e){for(let t=0;t<as;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<as;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>as&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=as)}moveCursor(e){const t=this.pos+e;if(e>1)for(let i=this.pos+1;i<t+1;i++)this.chars[i].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Of(e);if(this.pos>=as){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<as;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let i=0;i<as;i++){const n=this.chars[i].uchar;n!==" "&&(t=!1),e.push(n)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class su{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<_r;t++)this.rows.push(new QA(e));this.logger=e,this.currRow=_r-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<_r;e++)this.rows[e].clear();this.currRow=_r-1}equals(e){let t=!0;for(let i=0;i<_r;i++)if(!this.rows[i].equals(e.rows[i])){t=!1;break}return t}copy(e){for(let t=0;t<_r;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<_r;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let h=0;h<_r;h++)this.rows[h].clear();const a=this.currRow+1-this.nrRollUpRows,l=this.lastOutputScreen;if(l){const h=l.rows[a].cueStartTime,f=this.logger.time;if(h&&f!==null&&h<f)for(let p=0;p<this.nrRollUpRows;p++)this.rows[t-this.nrRollUpRows+p+1].copy(l.rows[a+p])}}this.currRow=t;const i=this.rows[this.currRow];if(e.indent!==null){const a=e.indent,l=Math.max(a-1,0);i.setCursor(e.indent),e.color=i.chars[l].penState.foreground}const n={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(n)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let i="",n=-1;for(let a=0;a<_r;a++){const l=this.rows[a].getTextString();l&&(n=a+1,e?t.push("Row "+n+": '"+l+"'"):t.push(l.trim()))}return t.length>0&&(e?i="["+t.join(" | ")+"]":i=t.join(`
193
+ `)),i}getTextAndFormat(){return this.rows}}class $f{constructor(e,t,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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new su(i),this.nonDisplayedMemory=new su(i),this.lastOutputScreen=new su(i),this.currRollUpRow=this.displayedMemory.rows[_r-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[_r-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),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=e)}insertChars(e){for(let i=0;i<e.length;i++)this.writeScreen.insertChar(e[i]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+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(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const i=Math.floor(e/2)-16,n=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=n[i]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Ff{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const n=new ZA;this.channels=[null,new $f(e,t,n),new $f(e+1,i,n)],this.cmdHistory=Nf(),this.logger=n}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i,n,a,l=!1;this.logger.time=e;for(let h=0;h<t.length;h+=2)if(n=t[h]&127,a=t[h+1]&127,!(n===0&&a===0)){if(this.logger.log(3,"["+dn([t[h],t[h+1]])+"] -> ("+dn([n,a])+")"),i=this.parseCmd(n,a),i||(i=this.parseMidrow(n,a)),i||(i=this.parsePAC(n,a)),i||(i=this.parseBackgroundAttributes(n,a)),!i&&(l=this.parseChars(n,a),l)){const f=this.currentChannel;f&&f>0?this.channels[f].insertChars(l):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!i&&!l&&this.logger.log(2,"Couldn't parse cleaned data "+dn([n,a])+" orig: "+dn([t[h],t[h+1]]))}}parseCmd(e,t){const{cmdHistory:i}=this,n=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,a=(e===23||e===31)&&t>=33&&t<=35;if(!(n||a))return!1;if(Mf(e,t,i))return Dn(null,null,i),this.logger.log(3,"Repeated command ("+dn([e,t])+") is dropped"),!0;const l=e===20||e===21||e===23?1:2,h=this.channels[l];return e===20||e===21||e===28||e===29?t===32?h.ccRCL():t===33?h.ccBS():t===34?h.ccAOF():t===35?h.ccAON():t===36?h.ccDER():t===37?h.ccRU(2):t===38?h.ccRU(3):t===39?h.ccRU(4):t===40?h.ccFON():t===41?h.ccRDC():t===42?h.ccTR():t===43?h.ccRTD():t===44?h.ccEDM():t===45?h.ccCR():t===46?h.ccENM():t===47&&h.ccEOC():h.ccTO(t-32),Dn(e,t,i),this.currentChannel=l,!0}parseMidrow(e,t){let i=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===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(t),this.logger.log(3,"MIDROW ("+dn([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let i;const n=this.cmdHistory,a=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,l=(e===16||e===24)&&t>=64&&t<=95;if(!(a||l))return!1;if(Mf(e,t,n))return Dn(null,null,n),!0;const h=e<=23?1:2;t>=64&&t<=95?i=h===1?jA[e]:zA[e]:i=h===1?KA[e]:YA[e];const f=this.channels[h];return f?(f.setPAC(this.interpretPAC(i,t)),Dn(e,t,n),this.currentChannel=h,!0):!1}interpretPAC(e,t){let i;const n={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?i=t-96:i=t-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(e,t){let i,n=null,a=null;if(e>=25?(i=2,a=e-8):(i=1,a=e),a>=17&&a<=19){let l;a===17?l=t+80:a===18?l=t+112:l=t+144,this.logger.log(2,"Special char '"+Of(l)+"' in channel "+i),n=[l]}else e>=32&&e<=127&&(n=t===0?[e]:[e,t]);if(n){const l=dn(n);this.logger.log(3,"Char codes = "+l.join(",")),Dn(e,t,this.cmdHistory)}return n}parseBackgroundAttributes(e,t){const i=(e===16||e===24)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=45&&t<=47;if(!(i||n))return!1;let a;const l={};e===16||e===24?(a=Math.floor((t-32)/2),l.background=XA[a],t%2===1&&(l.background=l.background+"_semi")):t===45?l.background="transparent":(l.foreground="black",t===47&&(l.underline=!0));const h=e<=23?1:2;return this.channels[h].setBkgData(l),Dn(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory=Nf()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const i=this.channels[t];i&&i.cueSplitAtTime(e)}}}function Dn(r,e,t){t.a=r,t.b=e}function Mf(r,e,t){return t.a===r&&t.b===e}function Nf(){return{a:null,b:null}}class il{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,i){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var nu=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const r=["","lr","rl"],e=["start","middle","end","left","right"];function t(h,f){if(typeof f!="string"||!Array.isArray(h))return!1;const p=f.toLowerCase();return~h.indexOf(p)?p:!1}function i(h){return t(r,h)}function n(h){return t(e,h)}function a(h,...f){let p=1;for(;p<arguments.length;p++){const m=arguments[p];for(const g in m)h[g]=m[g]}return h}function l(h,f,p){const m=this,g={enumerable:!0};m.hasBeenReset=!1;let A="",b=!1,x=h,k=f,w=p,P=null,$="",N=!0,I="auto",O="start",K=50,U="middle",re=50,ne="middle";Object.defineProperty(m,"id",a({},g,{get:function(){return A},set:function(Y){A=""+Y}})),Object.defineProperty(m,"pauseOnExit",a({},g,{get:function(){return b},set:function(Y){b=!!Y}})),Object.defineProperty(m,"startTime",a({},g,{get:function(){return x},set:function(Y){if(typeof Y!="number")throw new TypeError("Start time must be set to a number.");x=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"endTime",a({},g,{get:function(){return k},set:function(Y){if(typeof Y!="number")throw new TypeError("End time must be set to a number.");k=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"text",a({},g,{get:function(){return w},set:function(Y){w=""+Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"region",a({},g,{get:function(){return P},set:function(Y){P=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"vertical",a({},g,{get:function(){return $},set:function(Y){const Ee=i(Y);if(Ee===!1)throw new SyntaxError("An invalid or illegal string was specified.");$=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"snapToLines",a({},g,{get:function(){return N},set:function(Y){N=!!Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"line",a({},g,{get:function(){return I},set:function(Y){if(typeof Y!="number"&&Y!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");I=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"lineAlign",a({},g,{get:function(){return O},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");O=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"position",a({},g,{get:function(){return K},set:function(Y){if(Y<0||Y>100)throw new Error("Position must be between 0 and 100.");K=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"positionAlign",a({},g,{get:function(){return U},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");U=Ee,this.hasBeenReset=!0}})),Object.defineProperty(m,"size",a({},g,{get:function(){return re},set:function(Y){if(Y<0||Y>100)throw new Error("Size must be between 0 and 100.");re=Y,this.hasBeenReset=!0}})),Object.defineProperty(m,"align",a({},g,{get:function(){return ne},set:function(Y){const Ee=n(Y);if(!Ee)throw new SyntaxError("An invalid or illegal string was specified.");ne=Ee,this.hasBeenReset=!0}})),m.displayState=void 0}return l.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},l}();class JA{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Uf(r){function e(i,n,a,l){return(i|0)*3600+(n|0)*60+(a|0)+parseFloat(l||0)}const t=r.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class eE{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,i){return i?this.has(e)?this.values[e]:t[i]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,i){for(let n=0;n<i.length;++n)if(t===i[n]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const i=parseFloat(t);if(i>=0&&i<=100)return this.set(e,i),!0}return!1}}function Bf(r,e,t,i){const n=i?r.split(i):[r];for(const a in n){if(typeof n[a]!="string")continue;const l=n[a].split(t);if(l.length!==2)continue;const h=l[0],f=l[1];e(h,f)}}const ou=new nu(0,0,""),rl=ou.align==="middle"?"middle":"center";function tE(r,e,t){const i=r;function n(){const h=Uf(r);if(h===null)throw new Error("Malformed timestamp: "+i);return r=r.replace(/^[^\sa-zA-Z-]+/,""),h}function a(h,f){const p=new eE;Bf(h,function(A,b){let x;switch(A){case"region":for(let k=t.length-1;k>=0;k--)if(t[k].id===b){p.set(A,t[k].region);break}break;case"vertical":p.alt(A,b,["rl","lr"]);break;case"line":x=b.split(","),p.integer(A,x[0]),p.percent(A,x[0])&&p.set("snapToLines",!1),p.alt(A,x[0],["auto"]),x.length===2&&p.alt("lineAlign",x[1],["start",rl,"end"]);break;case"position":x=b.split(","),p.percent(A,x[0]),x.length===2&&p.alt("positionAlign",x[1],["start",rl,"end","line-left","line-right","auto"]);break;case"size":p.percent(A,b);break;case"align":p.alt(A,b,["start",rl,"end","left","right"]);break}},/:/,/\s/),f.region=p.get("region",null),f.vertical=p.get("vertical","");let m=p.get("line","auto");m==="auto"&&ou.line===-1&&(m=-1),f.line=m,f.lineAlign=p.get("lineAlign","start"),f.snapToLines=p.get("snapToLines",!0),f.size=p.get("size",100),f.align=p.get("align",rl);let g=p.get("position","auto");g==="auto"&&ou.position===50&&(g=f.align==="start"||f.align==="left"?0:f.align==="end"||f.align==="right"?100:50),f.position=g}function l(){r=r.replace(/^\s+/,"")}if(l(),e.startTime=n(),l(),r.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+i);r=r.slice(3),l(),e.endTime=n(),l(),a(r,e)}function Gf(r){return r.replace(/<br(?: \/)?>/gi,`
194
+ `)}class iE{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new JA,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function i(){let a=t.buffer,l=0;for(a=Gf(a);l<a.length&&a[l]!=="\r"&&a[l]!==`
195
+ `;)++l;const h=a.slice(0,l);return a[l]==="\r"&&++l,a[l]===`
196
+ `&&++l,t.buffer=a.slice(l),h}function n(a){Bf(a,function(l,h){},/:/)}try{let a="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;a=i();const h=a.match(/^()?WEBVTT([ \t].*)?$/);if(!(h!=null&&h[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let l=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(l?l=!1:a=i(),t.state){case"HEADER":/:/.test(a)?n(a):a||(t.state="ID");continue;case"NOTE":a||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(a)){t.state="NOTE";break}if(!a)continue;if(t.cue=new nu(0,0,""),t.state="CUE",a.indexOf("-->")===-1){t.cue.id=a;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{tE(a,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const h=a.indexOf("-->")!==-1;if(!a||h&&(l=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
197
+ `),t.cue.text+=a}continue;case"BADCUE":a||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
198
+
199
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const rE=/\r\n|\n\r|\n|\r/g,au=function(e,t,i=0){return e.slice(i,i+t.length)===t},sE=function(e){let t=parseInt(e.slice(-3));const i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),a=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!ze(t)||!ze(i)||!ze(n)||!ze(a))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*i,t+=60*1e3*n,t+=60*60*1e3*a,t},lu=function(e){let t=5381,i=e.length;for(;i;)t=t*33^e.charCodeAt(--i);return(t>>>0).toString()};function cu(r,e,t){return lu(r.toString())+lu(e.toString())+lu(t)}const nE=function(e,t,i){let n=e[t],a=e[n.prevCC];if(!a||!a.new&&n.new){e.ccOffset=e.presentationOffset=n.start,n.new=!1;return}for(;(l=a)!=null&&l.new;){var l;e.ccOffset+=n.start-a.start,n.new=!1,n=a,a=e[n.prevCC]}e.presentationOffset=i};function oE(r,e,t,i,n,a,l){const h=new iE,f=Fr(new Uint8Array(r)).trim().replace(rE,`
200
+ `).split(`
201
+ `),p=[],m=e?vA(e.baseTime,e.timescale):0;let g="00:00.000",A=0,b=0,x,k=!0;h.oncue=function(w){const P=t[i];let $=t.ccOffset;const N=(A-m)/9e4;if(P!=null&&P.new&&(b!==void 0?$=t.ccOffset=P.start:nE(t,i,N)),N){if(!e){x=new Error("Missing initPTS for VTT MPEGTS");return}$=N-t.presentationOffset}const I=w.endTime-w.startTime,O=fr((w.startTime+$-b)*9e4,n*9e4)/9e4;w.startTime=Math.max(O,0),w.endTime=Math.max(O+I,0);const K=w.text.trim();w.text=decodeURIComponent(encodeURIComponent(K)),w.id||(w.id=cu(w.startTime,w.endTime,K)),w.endTime>0&&p.push(w)},h.onparsingerror=function(w){x=w},h.onflush=function(){if(x){l(x);return}a(p)},f.forEach(w=>{if(k)if(au(w,"X-TIMESTAMP-MAP=")){k=!1,w.slice(16).split(",").forEach(P=>{au(P,"LOCAL:")?g=P.slice(6):au(P,"MPEGTS:")&&(A=parseInt(P.slice(7)))});try{b=sE(g)/1e3}catch(P){x=P}return}else w===""&&(k=!1);h.parse(w+`
202
+ `)}),h.flush()}const uu="stpp.ttml.im1t",Vf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Hf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,aE={left:"start",center:"center",right:"end",start:"start",end:"end"};function Wf(r,e,t,i){const n=bt(new Uint8Array(r),["mdat"]);if(n.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const a=n.map(h=>Fr(h)),l=gA(e.baseTime,1,e.timescale);try{a.forEach(h=>t(lE(h,l)))}catch(h){i(h)}}function lE(r,e){const n=new DOMParser().parseFromString(r,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const a={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},l=Object.keys(a).reduce((g,A)=>(g[A]=n.getAttribute(`ttp:${A}`)||a[A],g),{}),h=n.getAttribute("xml:space")!=="preserve",f=jf(hu(n,"styling","style")),p=jf(hu(n,"layout","region")),m=hu(n,"body","[begin]");return[].map.call(m,g=>{const A=Kf(g,h);if(!A||!g.hasAttribute("begin"))return null;const b=fu(g.getAttribute("begin"),l),x=fu(g.getAttribute("dur"),l);let k=fu(g.getAttribute("end"),l);if(b===null)throw zf(g);if(k===null){if(x===null)throw zf(g);k=b+x}const w=new nu(b-e,k-e,A);w.id=cu(w.startTime,w.endTime,w.text);const P=p[g.getAttribute("region")],$=f[g.getAttribute("style")],N=cE(P,$,f),{textAlign:I}=N;if(I){const O=aE[I];O&&(w.lineAlign=O),w.align=I}return ci(w,N),w}).filter(g=>g!==null)}function hu(r,e,t){const i=r.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(t)):[]}function jf(r){return r.reduce((e,t)=>{const i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function Kf(r,e){return[].slice.call(r.childNodes).reduce((t,i,n)=>{var a;return i.nodeName==="br"&&n?t+`
203
+ `:(a=i.childNodes)!=null&&a.length?Kf(i,e):e?t+i.textContent.trim().replace(/\s+/g," "):t+i.textContent},"")}function cE(r,e,t){const i="http://www.w3.org/ns/ttml#styling";let n=null;const a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],l=r!=null&&r.hasAttribute("style")?r.getAttribute("style"):null;return l&&t.hasOwnProperty(l)&&(n=t[l]),a.reduce((h,f)=>{const p=du(e,i,f)||du(r,i,f)||du(n,i,f);return p&&(h[f]=p),h},{})}function du(r,e,t){return r&&r.hasAttributeNS(e,t)?r.getAttributeNS(e,t):null}function zf(r){return new Error(`Could not parse ttml timestamp ${r}`)}function fu(r,e){if(!r)return null;let t=Uf(r);return t===null&&(Vf.test(r)?t=uE(r,e):Hf.test(r)&&(t=hE(r,e))),t}function uE(r,e){const t=Vf.exec(r),i=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+i/e.frameRate}function hE(r,e){const t=Hf.exec(r),i=Number(t[1]);switch(t[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}class dE{constructor(e){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=Yf(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const t=new il(this,"textTrack1"),i=new il(this,"textTrack2"),n=new il(this,"textTrack3"),a=new il(this,"textTrack4");this.cea608Parser1=new Ff(1,t,i),this.cea608Parser2=new Ff(3,n,a)}e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(_.FRAG_LOADING,this.onFragLoading,this),e.on(_.FRAG_LOADED,this.onFragLoaded,this),e.on(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(_.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(_.FRAG_LOADING,this.onFragLoading,this),e.off(_.FRAG_LOADED,this.onFragLoaded,this),e.off(_.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(_.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(_.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(_.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(_.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,i,n,a){let l=!1;for(let h=a.length;h--;){const f=a[h],p=pE(f[0],f[1],t,i);if(p>=0&&(f[0]=Math.min(f[0],t),f[1]=Math.max(f[1],i),l=!0,p/(i-t)>.5))return}if(l||a.push([t,i]),this.config.renderTextTracksNatively){const h=this.captionsTracks[e];this.Cues.newCue(h,t,i,n)}else{const h=this.Cues.newCue(null,t,i,n);this.hls.trigger(_.CUES_PARSED,{type:"captions",cues:h,track:e})}}onInitPtsFound(e,{frag:t,id:i,initPTS:n,timescale:a}){const{unparsedVttFrags:l}=this;i==="main"&&(this.initPTS[t.cc]={baseTime:n,timescale:a}),l.length&&(this.unparsedVttFrags=[],l.forEach(h=>{this.onFragLoaded(_.FRAG_LOADED,h)}))}getExistingTrack(e){const{media:t}=this;if(t)for(let i=0;i<t.textTracks.length;i++){const n=t.textTracks[i];if(n[e])return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:i,media:n}=this,{label:a,languageCode:l}=t[e],h=this.getExistingTrack(e);if(h)i[e]=h,Rn(i[e]),Gd(i[e],n);else{const f=this.createTextTrack("captions",a,l);f&&(f[e]=!0,i[e]=f)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const i=t.label,n={_id:e,label:i,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=n,this.hls.trigger(_.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}createTextTrack(e,t,i){const n=this.media;if(n)return n.addTextTrack(e,t,i)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Rn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Yf(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let i=0;i<t.length;i++)Rn(t[i])}onSubtitleTracksUpdated(e,t){const i=t.subtitleTracks||[],n=i.some(a=>a.textCodec===uu);if(this.config.enableWebVTT||n&&this.config.enableIMSC1){if(Rf(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const l=this.media?this.media.textTracks:null;this.tracks.forEach((h,f)=>{let p;if(l&&f<l.length){let m=null;for(let g=0;g<l.length;g++)if(fE(l[g],h)){m=l[g];break}m&&(p=m)}if(p)Rn(p);else{const m=this._captionsOrSubtitlesFromCharacteristics(h);p=this.createTextTrack(m,h.name,h.lang),p&&(p.mode="disabled")}p&&(p.groupId=h.groupId,this.textTracks.push(p))})}else if(this.tracks.length){const l=this.tracks.map(h=>({label:h.name,kind:h.type.toLowerCase(),default:h.default,subtitleTrack:h}));this.hls.trigger(_.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:l})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&i)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(i=>{const n=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!n)return;const a=`textTrack${n[1]}`,l=this.captionsProperties[a];l&&(l.label=i.name,i.lang&&(l.languageCode=i.lang),l.media=i)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:i,cea608Parser2:n,lastSn:a,lastPartIndex:l}=this;if(!(!this.enabled||!(i&&n))&&t.frag.type===it.MAIN){var h,f;const p=t.frag.sn,m=(h=t==null||(f=t.part)==null?void 0:f.index)!=null?h:-1;p===a+1||p===a&&m===l+1||(i.reset(),n.reset()),this.lastSn=p,this.lastPartIndex=m}}onFragLoaded(e,t){const{frag:i,payload:n}=t;if(i.type===it.SUBTITLE)if(n.byteLength){const a=i.decryptdata,l="stats"in t;if(a==null||!a.encrypted||l){const h=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),h&&h.textCodec===uu?this._parseIMSC1(i,n):this._parseVTTs(t)}}else this.hls.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const i=this.hls;Wf(t,this.initPTS[e.cc],n=>{this._appendCues(n,e.level),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},n=>{q.log(`Failed to parse IMSC1: ${n}`),i.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:n})})}_parseVTTs(e){var t;const{frag:i,payload:n}=e,{initPTS:a,unparsedVttFrags:l}=this,h=a.length-1;if(!a[i.cc]&&h===-1){l.push(e);return}const f=this.hls,p=(t=i.initSegment)!=null&&t.data?hn(i.initSegment.data,new Uint8Array(n)):n;oE(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,m=>{this._appendCues(m,i.level),f.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},m=>{const g=m.message==="Missing initPTS for VTT MPEGTS";g?l.push(e):this._fallbackToIMSC1(i,n),q.log(`Failed to parse VTT cue: ${m}`),!(g&&h>i.cc)&&f.trigger(_.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:m})})}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||Wf(t,this.initPTS[e.cc],()=>{i.textCodec=uu,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){const i=this.hls;if(this.config.renderTextTracksNatively){const n=this.textTracks[t];if(!n||n.mode==="disabled")return;e.forEach(a=>Vd(n,a))}else{const n=this.tracks[t];if(!n)return;const a=n.default?"default":"subtitles"+t;i.trigger(_.CUES_PARSED,{type:"subtitles",cues:e,track:a})}}onFragDecrypted(e,t){const{frag:i}=t;i.type===it.SUBTITLE&&this.onFragLoaded(_.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:i,cea608Parser2:n}=this;if(!this.enabled||!(i&&n))return;const{frag:a,samples:l}=t;if(!(a.type===it.MAIN&&this.closedCaptionsForLevel(a)==="NONE"))for(let h=0;h<l.length;h++){const f=l[h].bytes;if(f){const p=this.extractCea608Data(f);i.addData(l[h].pts,p[0]),n.addData(l[h].pts,p[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:i,endOffsetSubtitles:n,type:a}){const{media:l}=this;if(!(!l||l.currentTime<i)){if(!a||a==="video"){const{captionsTracks:h}=this;Object.keys(h).forEach(f=>Dc(h[f],t,i))}if(this.config.renderTextTracksNatively&&t===0&&n!==void 0){const{textTracks:h}=this;Object.keys(h).forEach(f=>Dc(h[f],t,n))}}}extractCea608Data(e){const t=[[],[]],i=e[0]&31;let n=2;for(let a=0;a<i;a++){const l=e[n++],h=127&e[n++],f=127&e[n++];if(h===0&&f===0)continue;if((4&l)!==0){const m=3&l;(m===0||m===1)&&(t[m].push(h),t[m].push(f))}}return t}}function fE(r,e){return!!r&&r.label===e.name&&!(r.textTrack1||r.textTrack2)}function pE(r,e,t,i){return Math.min(e,i)-Math.max(r,t)}function Yf(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class pu{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.BUFFER_CODECS,this.onBufferCodecs,this),e.on(_.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(_.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.BUFFER_CODECS,this.onBufferCodecs,this),e.off(_.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const i=this.hls.levels[t.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const i=t.filter((n,a)=>this.isLevelAllowed(n)&&a<=e);return this.clientRect=null,pu.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 e=this.media,t={width:0,height:0};if(e){const i=e.getBoundingClientRect();t.width=i.width,t.height=i.height,!t.width&&!t.height&&(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(i=>e.bitrate===i.bitrate&&e.width===i.width&&e.height===i.height)}static getMaxLevelByMediaSize(e,t,i){if(!(e!=null&&e.length))return-1;const n=(l,h)=>h?l.width!==h.width||l.height!==h.height:!0;let a=e.length-1;for(let l=0;l<e.length;l+=1){const h=e[l];if((h.width>=t||h.height>=i)&&n(h,e[l+1])){a=l;break}}return a}}class mE{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(_.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const i=this.hls.config;if(i.capLevelOnFPSDrop){const n=t.media instanceof self.HTMLVideoElement?t.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(e,t,i){const n=performance.now();if(t){if(this.lastTime){const a=n-this.lastTime,l=i-this.lastDroppedFrames,h=t-this.lastDecodedFrames,f=1e3*l/a,p=this.hls;if(p.trigger(_.FPS_DROP,{currentDropped:l,currentDecoded:h,totalDroppedFrames:i}),f>0&&l>p.config.fpsDroppedMonitoringThreshold*h){let m=p.currentLevel;q.warn("drop FPS ratio greater than max allowed value for currentLevel: "+m),m>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=m)&&(m=m-1,p.trigger(_.FPS_DROP_LEVEL_CAPPING,{level:m,droppedLevel:p.currentLevel}),p.autoLevelCapping=m,this.streamController.nextLevelSwitch())}}this.lastTime=n,this.lastDroppedFrames=i,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const sl="[eme]";class On{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=On.CDMCleanupPromise?[On.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=q.debug.bind(q,sl),this.log=q.log.bind(q,sl),this.warn=q.warn.bind(q,sl),this.error=q.error.bind(q,sl),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(_.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(_.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(_.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(_.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:i}=this.config,n=t[e];if(n)return n.licenseUrl;if(e===ei.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,i=t[e];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,i=(l,h,f)=>!!l&&f.indexOf(l)===h,n=t.map(l=>l.audioCodec).filter(i),a=t.map(l=>l.videoCodec).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((l,h)=>{const f=p=>{const m=p.shift();this.getMediaKeysPromise(m,n,a).then(g=>l({keySystem:m,mediaKeys:g})).catch(g=>{p.length?f(p):g instanceof pr?h(g):h(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_NO_ACCESS,error:g,fatal:!0},g.message))})};f(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let n=`Configured requestMediaKeySystemAccess is not a function ${i}`;return md===null&&self.location.protocol==="http:"&&(n=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(n))}return i(e,t)}getMediaKeysPromise(e,t,i){const n=Lv(e,t,i,this.config.drmSystemOptions),a=this.keySystemAccessPromises[e];let l=a==null?void 0:a.keySystemAccess;if(!l){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(n)}`),l=this.requestMediaKeySystemAccess(e,n);const h=this.keySystemAccessPromises[e]={keySystemAccess:l};return l.catch(f=>{this.log(`Failed to obtain access to key-system "${e}": ${f}`)}),l.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),h.mediaKeys=f.createMediaKeys().then(m=>(this.log(`Media-keys created for "${e}"`),p.then(g=>g?this.setMediaKeysServerCertificate(m,e,g):m))),h.mediaKeys.catch(m=>{this.error(`Failed to create media-keys for "${e}"}: ${m}`)}),h.mediaKeys})}return l.then(()=>a.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: ${Mr.hexDump(e.keyId||[])}`);const n=i.createSession(),a={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const i=this.createMediaKeySessionContext(e),n=this.getKeyIdString(t),a="cenc";this.keyIdToKeySessionPromise[n]=this.generateRequestWithPreferredKeySession(i,a,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Mr.hexDump(e.keyId)}updateKeySession(e,t){var i;const n=e.mediaKeysSession;return this.log(`Updating key-session "${n.sessionId}" for keyID ${Mr.hexDump(((i=e.decryptdata)==null?void 0:i.keyId)||[])}
204
+ } (data length: ${t&&t.byteLength})`),n.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,i)=>{const n=Sc(this.config),a=e.map(dd).filter(l=>!!l&&n.indexOf(l)!==-1);return this.getKeySystemSelectionPromise(a).then(({keySystem:l})=>{const h=pd(l);h?t(h):i(new Error(`Unable to find format for key-system "${l}"`))}).catch(i)})}loadKey(e){const t=e.keyInfo.decryptdata,i=this.getKeyIdString(t),n=`(keyId: ${i} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${n}`);let a=this.keyIdToKeySessionPromise[i];return a||(a=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(t).then(({keySystem:l,mediaKeys:h})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${n}`),this.attemptSetMediaKeys(l,h).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:l,mediaKeys:h,decryptdata:t}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,t.pssh,"playlist-key")}))),a.catch(l=>this.handleError(l))),a}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof pr?this.hls.trigger(_.ERROR,e.data):this.hls.trigger(_.ERROR,{type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),i=this.keyIdToKeySessionPromise[t];if(!i){const n=dd(e.keyFormat),a=n?[n]:Sc(this.config);return this.attemptKeySystemAccess(a)}return i}getKeySystemSelectionPromise(e){if(e.length||(e=Sc(this.config)),e.length===0)throw new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:i}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),i===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[ei.FAIRPLAY]){const m=wi(new Uint8Array(i));try{const g=kc(JSON.parse(m).sinf),A=Td(new Uint8Array(g));if(!A)return;n=A.subarray(8,24),a=ei.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const m=Jv(i);if(m===null)return;m.version===0&&m.systemId===fd.WIDEVINE&&m.data&&(n=m.data.subarray(8,24)),a=Rv(m.systemId)}if(!a||!n)return;const l=Mr.hexDump(n),{keyIdToKeySessionPromise:h,mediaKeySessions:f}=this;let p=h[l];for(let m=0;m<f.length;m++){const g=f[m],A=g.decryptdata;if(A.pssh||!A.keyId)continue;const b=Mr.hexDump(A.keyId);if(l===b||A.uri.replace(/-/g,"").indexOf(l)!==-1){p=h[b],delete h[b],A.pssh=new Uint8Array(i),A.keyId=n,p=h[l]=p.then(()=>this.generateRequestWithPreferredKeySession(g,t,i,"encrypted-event-key-match"));break}}p||(p=h[l]=this.getKeySystemSelectionPromise([a]).then(({keySystem:m,mediaKeys:g})=>{var A;this.throwIfDestroyed();const b=new Lo("ISO-23001-7",l,(A=pd(m))!=null?A:"");return b.pssh=new Uint8Array(i),b.keyId=n,this.attemptSetMediaKeys(m,g).then(()=>{this.throwIfDestroyed();const x=this.createMediaKeySessionContext({decryptdata:b,keySystem:m,mediaKeys:g});return this.generateRequestWithPreferredKeySession(x,t,i,"encrypted-event-no-match")})})),p.catch(m=>this.handleError(m))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const n=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(a=>i.indexOf(a)===-1)})}generateRequestWithPreferredKeySession(e,t,i,n){var a,l;const h=(a=this.config.drmSystems)==null||(l=a[e.keySystem])==null?void 0:l.generateRequest;if(h)try{const A=h.call(this.hls,t,i,e);if(!A)throw new Error("Invalid response from configured generateRequest filter");t=A.initDataType,i=e.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(e);const p=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${n}": ${p} (init data type: ${t} length: ${i?i.byteLength:null})`);const m=new eu;e.mediaKeysSession.onmessage=A=>{const b=e.mediaKeysSession;if(!b){m.emit("error",new Error("invalid state"));return}const{messageType:x,message:k}=A;this.log(`"${x}" message event for session "${b.sessionId}" message size: ${k.byteLength}`),x==="license-request"||x==="license-renewal"?this.renewLicense(e,k).catch(w=>{this.handleError(w),m.emit("error",w)}):x==="license-release"?e.keySystem===ei.FAIRPLAY&&(this.updateKeySession(e,hd("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${x}"`)},e.mediaKeysSession.onkeystatuseschange=A=>{if(!e.mediaKeysSession){m.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const x=e.keyStatus;m.emit("keyStatus",x),x==="expired"&&(this.warn(`${e.keySystem} expired for key ${p}`),this.renewKeySession(e))};const g=new Promise((A,b)=>{m.on("error",b),m.on("keyStatus",x=>{x.startsWith("usable")?A():x==="output-restricted"?b(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):x==="internal-error"?b(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${x}"`)):x==="expired"?b(new Error("key expired while generating request")):this.warn(`unhandled key status change "${x}"`)})});return e.mediaKeysSession.generateRequest(t,i).then(()=>{var A;this.log(`Request generated for key-session "${(A=e.mediaKeysSession)==null?void 0:A.sessionId}" keyId: ${p}`)}).catch(A=>{throw new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_NO_SESSION,error:A,fatal:!1},`Error generating key-session request: ${A}`)}).then(()=>g).catch(A=>{throw m.removeAllListeners(),this.removeSession(e),A}).then(()=>(m.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,i)=>{this.log(`key status change "${t}" 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(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,i=t.loader,n=new i(t),a=this.getServerCertificateUrl(e);return a?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((l,h)=>{const f={responseType:"arraybuffer",url:a},p=t.certLoadPolicy.default,m={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},g={onSuccess:(A,b,x,k)=>{l(A.data)},onError:(A,b,x,k)=>{h(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:x,response:Yi({url:f.url,data:void 0},A)},`"${e}" certificate request failed (${a}). Status: ${A.code} (${A.text})`))},onTimeout:(A,b,x)=>{h(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:x,response:{url:f.url,data:void 0}},`"${e}" certificate request timed out (${a})`))},onAbort:(A,b,x)=>{h(new Error("aborted"))}};n.load(f,m,g)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,i){return new Promise((n,a)=>{e.setServerCertificate(i).then(l=>{this.log(`setServerCertificate ${l?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${t}"`),n(e)}).catch(l=>{a(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:l,fatal:!0},l.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(i=>this.updateKeySession(e,new Uint8Array(i)).catch(n=>{throw new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:n,fatal:!0},n.message)}))}setupLicenseXHR(e,t,i,n){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return a.call(this.hls,e,t,i,n)}).catch(l=>{if(!i.decryptdata)throw l;return e.open("POST",t,!0),a.call(this.hls,e,t,i,n)}).then(l=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:l||n})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:n}))}requestLicense(e,t){const i=this.config.keyLoadPolicy.default;return new Promise((n,a)=>{const l=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${l}`);const h=new XMLHttpRequest;h.responseType="arraybuffer",h.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return a(new Error("invalid state"));if(h.readyState===4)if(h.status===200){this._requestLicenseFailureCount=0;let f=h.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,h,l,e)}catch(m){this.error(m)}n(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||h.status>=400&&h.status<500)a(new pr({type:tt.KEY_SYSTEM_ERROR,details:fe.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:h,response:{url:l,data:void 0,code:h.status,text:h.statusText}},`License Request XHR failed (${l}). Status: ${h.status} (${h.statusText})`));else{const m=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${m} attempts left`),this.requestLicense(e,t).then(n,a)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=h,this.setupLicenseXHR(h,l,e,t).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const i=t.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Lo.clearKeyUriToKeyIdMap();const i=t.length;On.CDMCleanupPromise=Promise.all(t.map(n=>this.removeSession(n)).concat(e==null?void 0:e.setMediaKeys(null).catch(n=>{this.log(`Could not clear media keys: ${n}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(n=>{this.log(`Could not close sessions and clear media keys: ${n}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=t.reduce((n,a)=>(n.indexOf(a.keyFormat)===-1&&n.push(a.keyFormat),n),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const n=this.mediaKeySessions.indexOf(e);return n>-1&&this.mediaKeySessions.splice(n,1),t.remove().catch(a=>{this.log(`Could not remove session: ${a}`)}).then(()=>t.close()).catch(a=>{this.log(`Could not close session: ${a}`)})}}}On.CDMCleanupPromise=void 0;class pr extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}const gE=1;var qi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const vE="h";class Is{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.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:qi.MANIFEST,su:!this.initialized})}catch(a){q.warn("Could not generate manifest CMCD data.",a)}},this.applyFragmentData=n=>{try{const a=n.frag,l=this.hls.levels[a.level],h=this.getObjectType(a),f={d:a.duration*1e3,ot:h};(h===qi.VIDEO||h===qi.AUDIO||h==qi.MUXED)&&(f.br=l.bitrate/1e3,f.tb=this.getTopBandwidth(h)/1e3,f.bl=this.getBufferLength(h)),this.apply(n,f)}catch(a){q.warn("Could not generate segment CMCD data.",a)}},this.hls=e;const t=this.config=e.config,{cmcd:i}=t;i!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||Is.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const e=this.hls;e.on(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(_.MEDIA_DETACHED,this.onMediaDetached,this),e.on(_.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(_.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(_.MEDIA_DETACHED,this.onMediaDetached,this),e.off(_.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i,n;this.audioBuffer=(i=t.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(n=t.tracks.video)==null?void 0:n.buffer}createData(){var e;return{v:gE,sf:vE,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ci(t,this.createData());const i=t.ot===qi.INIT||t.ot===qi.VIDEO||t.ot===qi.MUXED;if(this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){const n=Is.toHeaders(t);if(!Object.keys(n).length)return;e.headers||(e.headers={}),ci(e.headers,n)}else{const n=Is.toQuery(t);if(!n)return;e.url=Is.appendQueryToUri(e.url,n)}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return qi.TIMED_TEXT;if(e.sn==="initSegment")return qi.INIT;if(t==="audio")return qi.AUDIO;if(t==="main")return this.hls.audioTracks.length?qi.VIDEO:qi.MUXED}getTopBandwidth(e){let t=0,i;const n=this.hls;if(e===qi.AUDIO)i=n.audioTracks;else{const a=n.maxAutoLevel,l=a>-1?a+1:n.levels.length;i=n.levels.slice(0,l)}for(const a of i)a.bitrate>t&&(t=a.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,i=e===qi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!t?NaN:Nt.bufferInfo(i,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,i=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new i(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,l,h){t(a),this.loader.load(a,l,h)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,i=e||this.config.loader;return class{constructor(a){this.loader=void 0,this.loader=new i(a)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(a,l,h){t(a),this.loader.load(a,l,h)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],i=p=>!Number.isNaN(p)&&p!=null&&p!==""&&p!==!1,n=p=>Math.round(p),a=p=>n(p/100)*100,h={br:n,d:n,bl:a,dl:a,mtp:a,nor:p=>encodeURIComponent(p),rtp:a,tb:n},f=Object.keys(e||{}).sort();for(const p of f){let m=e[p];if(!i(m)||p==="v"&&m===1||p=="pr"&&m===1)continue;const g=h[p];g&&(m=g(m));const A=typeof m;let b;p==="ot"||p==="sf"||p==="st"?b=`${p}=${m}`:A==="boolean"?b=p:A==="number"?b=`${p}=${m}`:b=`${p}=${JSON.stringify(m)}`,t.push(b)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),i={},n=["Object","Request","Session","Status"],a=[{},{},{},{}],l={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 h of t){const f=l[h]!=null?l[h]:1;a[f][h]=e[h]}for(let h=0;h<a.length;h++){const f=Is.serialize(a[h]);f&&(i[`CMCD-${n[h]}`]=f)}return i}static toQuery(e){return`CMCD=${encodeURIComponent(Is.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;const i=e.includes("?")?"&":"?";return`${e}${i}${t}`}}const yE=3e5;class AE{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=q.log.bind(q,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(_.MANIFEST_LOADING,this.onManifestLoading,this),e.on(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(_.MANIFEST_PARSED,this.onManifestParsed,this),e.on(_.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(_.MANIFEST_LOADING,this.onManifestLoading,this),e.off(_.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(_.MANIFEST_PARSED,this.onManifestParsed,this),e.off(_.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}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(e){const t=this.levels;t&&(this.levels=t.filter(i=>i!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:i}=t;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:i}=t;if((i==null?void 0:i.action)===Ii.SendAlternateToPenaltyBox&&i.flags===dr.MoveAllAlternatesMatchingHost){let n=this.pathwayPriority;const a=this.pathwayId;this.penalizedPathways[a]||(this.penalizedPathways[a]=performance.now()),!n&&this.levels&&(n=this.levels.reduce((l,h)=>(l.indexOf(h.pathwayId)===-1&&l.push(h.pathwayId),l),[])),n&&n.length>1&&(this.updatePathwayPriority(n),i.resolved=this.pathwayId!==a)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const i=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),t=this.getLevelsForPathway(i),this.pathwayId=i}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(a=>{n-i[a]>yE&&delete i[a]});for(let a=0;a<e.length;a++){const l=e[a];if(i[l])continue;if(l===this.pathwayId)return;const h=this.hls.nextLoadLevel,f=this.hls.levels[h];if(t=this.getLevelsForPathway(l),t.length>0){this.log(`Setting Pathway to "${l}"`),this.pathwayId=l,this.hls.trigger(_.LEVELS_UPDATED,{levels:t});const p=this.hls.levels[h];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=h);break}}}clonePathways(e){const t=this.levels;if(!t)return;const i={},n={};e.forEach(a=>{const{ID:l,"BASE-ID":h,"URI-REPLACEMENT":f}=a;if(t.some(m=>m.pathwayId===l))return;const p=this.getLevelsForPathway(h).map(m=>{const g=ci({},m);g.details=void 0,g.url=Zf(m.uri,m.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const A=new Jt(m.attrs);A["PATHWAY-ID"]=l;const b=A.AUDIO&&`${A.AUDIO}_clone_${l}`,x=A.SUBTITLES&&`${A.SUBTITLES}_clone_${l}`;b&&(i[A.AUDIO]=b,A.AUDIO=b),x&&(n[A.SUBTITLES]=x,A.SUBTITLES=x),g.attrs=A;const k=new Io(g);return Ya(k,"audio",b),Ya(k,"text",x),k});t.push(...p),Xf(this.audioTracks,i,f,l),Xf(this.subtitleTracks,n,f,l)})}loadSteeringManifest(e){const t=this.hls.config,i=t.loader;this.loader&&this.loader.destroy(),this.loader=new i(t);let n;try{n=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(n.protocol!=="data:"){const m=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;n.searchParams.set("_HLS_pathway",this.pathwayId),n.searchParams.set("_HLS_throughput",""+m)}const a={responseType:"json",url:n.href},l=t.steeringManifestLoadPolicy.default,h=l.errorRetry||l.timeoutRetry||{},f={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:h.maxNumRetry||0,retryDelay:h.retryDelayMs||0,maxRetryDelay:h.maxRetryDelayMs||0},p={onSuccess:(m,g,A,b)=>{this.log(`Loaded steering manifest: "${n}"`);const x=m.data;if(x.VERSION!==1){this.log(`Steering VERSION ${x.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=x.TTL;const{"RELOAD-URI":k,"PATHWAY-CLONES":w,"PATHWAY-PRIORITY":P}=x;if(k)try{this.uri=new self.URL(k,n).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${k}`);return}this.scheduleRefresh(this.uri||A.url),w&&this.clonePathways(w),P&&this.updatePathwayPriority(P)},onError:(m,g,A,b)=>{if(this.log(`Error loading steering manifest: ${m.code} ${m.text} (${g.url})`),this.stopLoad(),m.code===410){this.enabled=!1,this.log(`Steering manifest ${g.url} no longer available`);return}let x=this.timeToLoad*1e3;if(m.code===429){const k=this.loader;if(typeof(k==null?void 0:k.getResponseHeader)=="function"){const w=k.getResponseHeader("Retry-After");w&&(x=parseFloat(w)*1e3)}this.log(`Steering manifest ${g.url} rate limited`);return}this.scheduleRefresh(this.uri||g.url,x)},onTimeout:(m,g,A)=>{this.log(`Timeout loading steering manifest (${g.url})`),this.scheduleRefresh(this.uri||g.url)}};this.log(`Requesting steering manifest: ${n}`),this.loader.load(a,f,p)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}function Xf(r,e,t,i){r&&Object.keys(e).forEach(n=>{const a=r.filter(l=>l.groupId===n).map(l=>{const h=ci({},l);return h.details=void 0,h.attrs=new Jt(h.attrs),h.url=h.attrs.URI=Zf(l.url,l.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),h.groupId=h.attrs["GROUP-ID"]=e[n],h.attrs["PATHWAY-ID"]=i,h});r.push(...a)})}function Zf(r,e,t,i){const{HOST:n,PARAMS:a,[t]:l}=i;let h;e&&(h=l==null?void 0:l[e],h&&(r=h));const f=new self.URL(r);return n&&!h&&(f.host=n),a&&Object.keys(a).sort().forEach(p=>{p&&f.searchParams.set(p,a[p])}),f.href}const EE=/^age:\s*[\d.]+\s*$/im;class qf{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Ua,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;const a=this.xhrSetup;a?Promise.resolve().then(()=>{if(!this.stats.aborted)return a(i,t.url)}).catch(l=>(i.open("GET",t.url,!0),a(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(l=>{this.callbacks.onError({code:i.status,text:l.message},t,i,n)}):this.openAndSendXhr(i,t,e)}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);const n=this.context.headers,{maxTimeToFirstByteMs:a,maxLoadTimeMs:l}=i.loadPolicy;if(n)for(const h in n)e.setRequestHeader(h,n[h]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=a&&ze(a)?a:l,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:i}=this;if(!e||!t)return;const n=t.readyState,a=this.config;if(!i.aborted&&n>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),a.timeout!==a.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),a.timeout=a.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),a.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),n===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const l=t.status,h=t.responseType!=="text";if(l>=200&&l<300&&(h&&t.response||t.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=h?t.response:t.responseText,p=t.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 m=this.callbacks.onProgress;if(m&&m(i,e,f,t),!this.callbacks)return;const g={url:t.responseURL,data:f,code:l};this.callbacks.onSuccess(g,i,e,t)}else{const f=a.loadPolicy.errorRetry,p=i.retry;za(f,p,!1,l)?this.retry(f):(q.error(`${l} while loading ${e.url}`),this.callbacks.onError({code:l,text:t.statusText},e,t,i))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,i=this.stats.retry;if(za(t,i,!0))this.retry(t);else{q.warn(`timeout while loading ${this.context.url}`);const n=this.callbacks;n&&(this.abortInternal(),n.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:i}=this;this.retryDelay=Nc(e,i.retry),i.retry++,q.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&EE.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function bE(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const xE=/(\d+)-(\d+)\/(\d+)/;class Qf{constructor(e){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=e.fetchSetup||wE,this.controller=new self.AbortController,this.stats=new Ua}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,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 a=TE(e,this.controller.signal),l=i.onProgress,h=e.responseType==="arraybuffer",f=h?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:m}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=i,this.request=this.fetchSetup(e,a),self.clearTimeout(this.requestTimeout),t.timeout=p&&ze(p)?p:m,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},t.timeout),self.fetch(this.request).then(g=>{this.response=this.loader=g;const A=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=m,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(n,e,this.response)},m-(A-n.loading.start)),!g.ok){const{status:b,statusText:x}=g;throw new _E(x||"fetch, bad network response",b,g)}return n.loading.first=A,n.total=SE(g.headers)||n.total,l&&ze(t.highWaterMark)?this.loadProgressively(g,n,e,t.highWaterMark,l):h?g.arrayBuffer():e.responseType==="json"?g.json():g.text()}).then(g=>{const{response:A}=this;self.clearTimeout(this.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);const b=g[f];b&&(n.loaded=n.total=b);const x={url:A.url,data:g,code:A.status};l&&!ze(t.highWaterMark)&&l(n,e,g,A),i.onSuccess(x,n,e,A)}).catch(g=>{if(self.clearTimeout(this.requestTimeout),n.aborted)return;const A=g&&g.code||0,b=g?g.message:null;i.onError({code:A,text:b},e,g?g.details:null,n)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,i,n=0,a){const l=new wf,h=e.body.getReader(),f=()=>h.read().then(p=>{if(p.done)return l.dataLength&&a(t,i,l.flush(),e),Promise.resolve(new ArrayBuffer(0));const m=p.value,g=m.length;return t.loaded+=g,g<n||l.dataLength?(l.push(m),l.dataLength>=n&&a(t,i,l.flush(),e)):a(t,i,m,e),f()}).catch(()=>Promise.reject());return f()}}function TE(r,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(ci({},r.headers))};return r.rangeEnd&&t.headers.set("Range","bytes="+r.rangeStart+"-"+String(r.rangeEnd-1)),t}function kE(r){const e=xE.exec(r);if(e)return parseInt(e[2])-parseInt(e[1])+1}function SE(r){const e=r.get("Content-Range");if(e){const i=kE(e);if(ze(i))return i}const t=r.get("Content-Length");if(t)return parseInt(t)}function wE(r,e){return new self.Request(r.url,e)}class _E extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const RE=/\s/,LE={newCue(r,e,t,i){const n=[];let a,l,h,f,p;const m=self.VTTCue||self.TextTrackCue;for(let A=0;A<i.rows.length;A++)if(a=i.rows[A],h=!0,f=0,p="",!a.isEmpty()){var g;for(let k=0;k<a.chars.length;k++)RE.test(a.chars[k].uchar)&&h?f++:(p+=a.chars[k].uchar,h=!1);a.cueStartTime=e,e===t&&(t+=1e-4),f>=16?f--:f++;const b=Gf(p.trim()),x=cu(e,t,b);r!=null&&(g=r.cues)!=null&&g.getCueById(x)||(l=new m(e,t,b),l.id=x,l.line=A+1,l.align="left",l.position=10+Math.min(80,Math.floor(f*8/32)*10),n.push(l))}return r&&n.length&&(n.sort((A,b)=>A.line==="auto"||b.line==="auto"?0:A.line>8&&b.line>8?b.line-A.line:A.line-b.line),n.forEach(A=>Vd(r,A))),n}},CE={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},IE=Yi(Yi({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:qf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:$A,bufferController:WA,capLevelController:pu,errorController:_y,fpsController:mE,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:md,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:CE},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},DE()),{},{subtitleStreamController:BA,subtitleTrackController:VA,timelineController:dE,audioStreamController:MA,audioTrackController:NA,emeController:On,cmcdController:Is,contentSteeringController:AE});function DE(){return{cueHandler:LE,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 OE(r,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=mu(r),i=["manifest","level","frag"],n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(a=>{const l=`${a==="level"?"playlist":a}LoadPolicy`,h=e[l]===void 0,f=[];n.forEach(p=>{const m=`${a}Loading${p}`,g=e[m];if(g!==void 0&&h){f.push(m);const A=t[l].default;switch(e[l]={default:A},p){case"TimeOut":A.maxLoadTimeMs=g,A.maxTimeToFirstByteMs=g;break;case"MaxRetry":A.errorRetry.maxNumRetry=g,A.timeoutRetry.maxNumRetry=g;break;case"RetryDelay":A.errorRetry.retryDelayMs=g,A.timeoutRetry.retryDelayMs=g;break;case"MaxRetryTimeout":A.errorRetry.maxRetryDelayMs=g,A.timeoutRetry.maxRetryDelayMs=g;break}}}),f.length&&q.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${l}": ${JSON.stringify(e[l])}`)}),Yi(Yi({},t),e)}function mu(r){return r&&typeof r=="object"?Array.isArray(r)?r.map(mu):Object.keys(r).reduce((e,t)=>(e[t]=mu(r[t]),e),{}):r}function PE(r){const e=r.loader;e!==Qf&&e!==qf?(q.log("[config]: Custom loader detected, cannot enable progressive streaming"),r.progressive=!1):bE()&&(r.loader=Qf,r.progressive=!0,r.enableSoftwareAES=!0,q.log("[config]: Progressive streaming enabled, using FetchLoader"))}class ls{static get version(){return"1.4.12"}static isSupported(){return Ky()}static get Events(){return _}static get ErrorTypes(){return tt}static get ErrorDetails(){return fe}static get DefaultConfig(){return ls.defaultConfig?ls.defaultConfig:IE}static set DefaultConfig(e){ls.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new eu,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,yv(e.debug||!1,"Hls instance");const t=this.config=OE(ls.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&PE(t);const{abrController:i,bufferController:n,capLevelController:a,errorController:l,fpsController:h}=t,f=new l(this),p=this.abrController=new i(this),m=this.bufferController=new n(this),g=this.capLevelController=new a(this),A=new h(this),b=new ly(this),x=new fy(this),k=t.contentSteeringController,w=k?new k(this):null,P=this.levelController=new Ly(this,w),$=new Cy(this),N=new Dy(this.config),I=this.streamController=new OA(this,$,N);g.setStreamController(I),A.setStreamController(I);const O=[b,P,I];w&&O.splice(1,0,w),this.networkControllers=O;const K=[p,m,g,A,x,$];this.audioTrackController=this.createController(t.audioTrackController,O);const U=t.audioStreamController;U&&O.push(new U(this,$,N)),this.subtitleTrackController=this.createController(t.subtitleTrackController,O);const re=t.subtitleStreamController;re&&O.push(new re(this,$,N)),this.createController(t.timelineController,K),N.emeController=this.emeController=this.createController(t.emeController,K),this.cmcdController=this.createController(t.cmcdController,K),this.latencyController=this.createController(py,K),this.coreComponents=K,O.push(f);const ne=f.onErrorOut;typeof ne=="function"&&this.on(_.ERROR,ne,f)}createController(e,t){if(e){const i=new e(this);return t&&t.push(i),i}return null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,n){this._emitter.off(e,t,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(i){q.error("An internal error happened while handling event "+e+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(_.ERROR,{type:tt.OTHER_ERROR,details:fe.INTERNAL_EXCEPTION,fatal:!1,event:e,error:i})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){q.log("destroy"),this.trigger(_.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){q.log("attachMedia"),this._media=e,this.trigger(_.MEDIA_ATTACHING,{media:e})}detachMedia(){q.log("detachMedia"),this.trigger(_.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,i=this.url,n=this.url=bc.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});q.log(`loadSource:${n}`),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(_.MANIFEST_LOADING,{url:e})}startLoad(e=-1){q.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){q.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){q.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){q.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){q.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){q.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){q.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){q.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){q.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(q.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){$c.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const i=e.length;for(let n=0;n<i;n++)if(e[n].maxBitrate>=t)return n;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:i}=this;let n;if(t===-1&&e&&e.length?n=e.length-1:n=t,i)for(let a=n;a--;){const l=e[a].attrs["HDCP-LEVEL"];if(l&&l<=i)return a}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}ls.defaultConfig=void 0;var $E=$o;$o.flatten=$o,$o.unflatten=tp;function Jf(r){return r&&r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function ep(r){return r}function $o(r,e){e=e||{};const t=e.delimiter||".",i=e.maxDepth,n=e.transformKey||ep,a={};function l(h,f,p){p=p||1,Object.keys(h).forEach(function(m){const g=h[m],A=e.safe&&Array.isArray(g),b=Object.prototype.toString.call(g),x=Jf(g),k=b==="[object Object]"||b==="[object Array]",w=f?f+t+n(m):n(m);if(!A&&!x&&k&&Object.keys(g).length&&(!e.maxDepth||p<i))return l(g,w,p+1);a[w]=g})}return l(r),a}function tp(r,e){e=e||{};const t=e.delimiter||".",i=e.overwrite||!1,n=e.transformKey||ep,a={};if(Jf(r)||Object.prototype.toString.call(r)!=="[object Object]")return r;function h(m){const g=Number(m);return isNaN(g)||m.indexOf(".")!==-1||e.object?m:g}function f(m,g,A){return Object.keys(A).reduce(function(b,x){return b[m+t+x]=A[x],b},g)}function p(m){const g=Object.prototype.toString.call(m),A=g==="[object Array]",b=g==="[object Object]";if(m){if(A)return!m.length;if(b)return!Object.keys(m).length}else return!0}return r=Object.keys(r).reduce(function(m,g){const A=Object.prototype.toString.call(r[g]);return!(A==="[object Object]"||A==="[object Array]")||p(r[g])?(m[g]=r[g],m):f(g,m,$o(r[g],e))},{}),Object.keys(r).forEach(function(m){const g=m.split(t).map(n);let A=h(g.shift()),b=h(g[0]),x=a;for(;b!==void 0;){if(A==="__proto__")return;const k=Object.prototype.toString.call(x[A]),w=k==="[object Object]"||k==="[object Array]";if(!i&&!w&&typeof x[A]<"u")return;(i&&!w||!i&&x[A]==null)&&(x[A]=typeof b=="number"&&!e.object?[]:{}),x=x[A],g.length>0&&(A=h(g.shift()),b=h(g[0]))}x[A]=tp(r[m],e)}),a}const FE=va($E);var ip=Number.isNaN||function(e){return typeof e=="number"&&e!==e};function ME(r,e){return!!(r===e||ip(r)&&ip(e))}function NE(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(!ME(r[t],e[t]))return!1;return!0}function UE(r,e){e===void 0&&(e=NE);var t=null;function i(){for(var n=[],a=0;a<arguments.length;a++)n[a]=arguments[a];if(t&&t.lastThis===this&&e(n,t.lastArgs))return t.lastResult;var l=r.apply(this,n);return t={lastResult:l,lastArgs:n,lastThis:this},l}return i.clear=function(){t=null},i}/**
205
+ * @license
206
+ * Copyright 2017 Google LLC
207
+ * SPDX-License-Identifier: BSD-3-Clause
208
+ */const rp=(r,e,t)=>{const i=new Map;for(let n=e;n<=t;n++)i.set(r[n],n);return i},sp=wn(class extends po{constructor(r){if(super(r),r.type!==Sn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(r,e,t){let i;t===void 0?t=e:e!==void 0&&(i=e);const n=[],a=[];let l=0;for(const h of r)n[l]=i?i(h,l):l,a[l]=t(h,l),l++;return{values:a,keys:n}}render(r,e,t){return this.ht(r,e,t).values}update(r,[e,t,i]){const n=c2(r),{values:a,keys:l}=this.ht(e,t,i);if(!Array.isArray(n))return this.dt=l,a;const h=this.dt??(this.dt=[]),f=[];let p,m,g=0,A=n.length-1,b=0,x=a.length-1;for(;g<=A&&b<=x;)if(n[g]===null)g++;else if(n[A]===null)A--;else if(h[g]===l[b])f[b]=nn(n[g],a[b]),g++,b++;else if(h[A]===l[x])f[x]=nn(n[A],a[x]),A--,x--;else if(h[g]===l[x])f[x]=nn(n[g],a[x]),fo(r,f[x+1],n[g]),g++,x--;else if(h[A]===l[b])f[b]=nn(n[A],a[b]),fo(r,n[g],n[A]),A--,b++;else if(p===void 0&&(p=rp(l,b,x),m=rp(h,g,A)),p.has(h[g]))if(p.has(h[A])){const k=m.get(l[b]),w=k!==void 0?n[k]:null;if(w===null){const P=fo(r,n[g]);nn(P,a[b]),f[b]=P}else f[b]=nn(w,a[b]),fo(r,n[g],w),n[k]=null;b++}else Yl(n[A]),A--;else Yl(n[g]),g++;for(;b<=x;){const k=fo(r,f[x+1]);nn(k,a[b]),f[b++]=k}for(;g<=A;){const k=n[g++];k!==null&&Yl(k)}return this.dt=l,l2(r,f),Es}});var Qi="top",mr="bottom",gr="right",Ji="left",gu="auto",Fo=[Qi,mr,gr,Ji],Pn="start",Mo="end",BE="clippingParents",np="viewport",No="popper",GE="reference",op=Fo.reduce(function(r,e){return r.concat([e+"-"+Pn,e+"-"+Mo])},[]),ap=[].concat(Fo,[gu]).reduce(function(r,e){return r.concat([e,e+"-"+Pn,e+"-"+Mo])},[]),VE="beforeRead",HE="read",WE="afterRead",jE="beforeMain",KE="main",zE="afterMain",YE="beforeWrite",XE="write",ZE="afterWrite",qE=[VE,HE,WE,jE,KE,zE,YE,XE,ZE];function Ur(r){return r?(r.nodeName||"").toLowerCase():null}function or(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}function fn(r){var e=or(r).Element;return r instanceof e||r instanceof Element}function vr(r){var e=or(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function vu(r){if(typeof ShadowRoot>"u")return!1;var e=or(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}function QE(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var i=e.styles[t]||{},n=e.attributes[t]||{},a=e.elements[t];!vr(a)||!Ur(a)||(Object.assign(a.style,i),Object.keys(n).forEach(function(l){var h=n[l];h===!1?a.removeAttribute(l):a.setAttribute(l,h===!0?"":h)}))})}function JE(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(i){var n=e.elements[i],a=e.attributes[i]||{},l=Object.keys(e.styles.hasOwnProperty(i)?e.styles[i]:t[i]),h=l.reduce(function(f,p){return f[p]="",f},{});!vr(n)||!Ur(n)||(Object.assign(n.style,h),Object.keys(a).forEach(function(f){n.removeAttribute(f)}))})}}const lp={name:"applyStyles",enabled:!0,phase:"write",fn:QE,effect:JE,requires:["computeStyles"]};function Br(r){return r.split("-")[0]}var pn=Math.max,nl=Math.min,$n=Math.round;function yu(){var r=navigator.userAgentData;return r!=null&&r.brands&&Array.isArray(r.brands)?r.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function cp(){return!/^((?!chrome|android).)*safari/i.test(yu())}function Fn(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var i=r.getBoundingClientRect(),n=1,a=1;e&&vr(r)&&(n=r.offsetWidth>0&&$n(i.width)/r.offsetWidth||1,a=r.offsetHeight>0&&$n(i.height)/r.offsetHeight||1);var l=fn(r)?or(r):window,h=l.visualViewport,f=!cp()&&t,p=(i.left+(f&&h?h.offsetLeft:0))/n,m=(i.top+(f&&h?h.offsetTop:0))/a,g=i.width/n,A=i.height/a;return{width:g,height:A,top:m,right:p+g,bottom:m+A,left:p,x:p,y:m}}function Au(r){var e=Fn(r),t=r.offsetWidth,i=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-i)<=1&&(i=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:i}}function up(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&vu(t)){var i=e;do{if(i&&r.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function cs(r){return or(r).getComputedStyle(r)}function eb(r){return["table","td","th"].indexOf(Ur(r))>=0}function Ds(r){return((fn(r)?r.ownerDocument:r.document)||window.document).documentElement}function ol(r){return Ur(r)==="html"?r:r.assignedSlot||r.parentNode||(vu(r)?r.host:null)||Ds(r)}function hp(r){return!vr(r)||cs(r).position==="fixed"?null:r.offsetParent}function tb(r){var e=/firefox/i.test(yu()),t=/Trident/i.test(yu());if(t&&vr(r)){var i=cs(r);if(i.position==="fixed")return null}var n=ol(r);for(vu(n)&&(n=n.host);vr(n)&&["html","body"].indexOf(Ur(n))<0;){var a=cs(n);if(a.transform!=="none"||a.perspective!=="none"||a.contain==="paint"||["transform","perspective"].indexOf(a.willChange)!==-1||e&&a.willChange==="filter"||e&&a.filter&&a.filter!=="none")return n;n=n.parentNode}return null}function Uo(r){for(var e=or(r),t=hp(r);t&&eb(t)&&cs(t).position==="static";)t=hp(t);return t&&(Ur(t)==="html"||Ur(t)==="body"&&cs(t).position==="static")?e:t||tb(r)||e}function Eu(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}function Bo(r,e,t){return pn(r,nl(e,t))}function ib(r,e,t){var i=Bo(r,e,t);return i>t?t:i}function dp(){return{top:0,right:0,bottom:0,left:0}}function fp(r){return Object.assign({},dp(),r)}function pp(r,e){return e.reduce(function(t,i){return t[i]=r,t},{})}var rb=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,fp(typeof e!="number"?e:pp(e,Fo))};function sb(r){var e,t=r.state,i=r.name,n=r.options,a=t.elements.arrow,l=t.modifiersData.popperOffsets,h=Br(t.placement),f=Eu(h),p=[Ji,gr].indexOf(h)>=0,m=p?"height":"width";if(!(!a||!l)){var g=rb(n.padding,t),A=Au(a),b=f==="y"?Qi:Ji,x=f==="y"?mr:gr,k=t.rects.reference[m]+t.rects.reference[f]-l[f]-t.rects.popper[m],w=l[f]-t.rects.reference[f],P=Uo(a),$=P?f==="y"?P.clientHeight||0:P.clientWidth||0:0,N=k/2-w/2,I=g[b],O=$-A[m]-g[x],K=$/2-A[m]/2+N,U=Bo(I,K,O),re=f;t.modifiersData[i]=(e={},e[re]=U,e.centerOffset=U-K,e)}}function nb(r){var e=r.state,t=r.options,i=t.element,n=i===void 0?"[data-popper-arrow]":i;n!=null&&(typeof n=="string"&&(n=e.elements.popper.querySelector(n),!n)||up(e.elements.popper,n)&&(e.elements.arrow=n))}const ob={name:"arrow",enabled:!0,phase:"main",fn:sb,effect:nb,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Mn(r){return r.split("-")[1]}var ab={top:"auto",right:"auto",bottom:"auto",left:"auto"};function lb(r,e){var t=r.x,i=r.y,n=e.devicePixelRatio||1;return{x:$n(t*n)/n||0,y:$n(i*n)/n||0}}function mp(r){var e,t=r.popper,i=r.popperRect,n=r.placement,a=r.variation,l=r.offsets,h=r.position,f=r.gpuAcceleration,p=r.adaptive,m=r.roundOffsets,g=r.isFixed,A=l.x,b=A===void 0?0:A,x=l.y,k=x===void 0?0:x,w=typeof m=="function"?m({x:b,y:k}):{x:b,y:k};b=w.x,k=w.y;var P=l.hasOwnProperty("x"),$=l.hasOwnProperty("y"),N=Ji,I=Qi,O=window;if(p){var K=Uo(t),U="clientHeight",re="clientWidth";if(K===or(t)&&(K=Ds(t),cs(K).position!=="static"&&h==="absolute"&&(U="scrollHeight",re="scrollWidth")),K=K,n===Qi||(n===Ji||n===gr)&&a===Mo){I=mr;var ne=g&&K===O&&O.visualViewport?O.visualViewport.height:K[U];k-=ne-i.height,k*=f?1:-1}if(n===Ji||(n===Qi||n===mr)&&a===Mo){N=gr;var Y=g&&K===O&&O.visualViewport?O.visualViewport.width:K[re];b-=Y-i.width,b*=f?1:-1}}var Ee=Object.assign({position:h},p&&ab),ce=m===!0?lb({x:b,y:k},or(t)):{x:b,y:k};if(b=ce.x,k=ce.y,f){var _e;return Object.assign({},Ee,(_e={},_e[I]=$?"0":"",_e[N]=P?"0":"",_e.transform=(O.devicePixelRatio||1)<=1?"translate("+b+"px, "+k+"px)":"translate3d("+b+"px, "+k+"px, 0)",_e))}return Object.assign({},Ee,(e={},e[I]=$?k+"px":"",e[N]=P?b+"px":"",e.transform="",e))}function cb(r){var e=r.state,t=r.options,i=t.gpuAcceleration,n=i===void 0?!0:i,a=t.adaptive,l=a===void 0?!0:a,h=t.roundOffsets,f=h===void 0?!0:h,p={placement:Br(e.placement),variation:Mn(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:n,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,mp(Object.assign({},p,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:l,roundOffsets:f})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,mp(Object.assign({},p,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const ub={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:cb,data:{}};var al={passive:!0};function hb(r){var e=r.state,t=r.instance,i=r.options,n=i.scroll,a=n===void 0?!0:n,l=i.resize,h=l===void 0?!0:l,f=or(e.elements.popper),p=[].concat(e.scrollParents.reference,e.scrollParents.popper);return a&&p.forEach(function(m){m.addEventListener("scroll",t.update,al)}),h&&f.addEventListener("resize",t.update,al),function(){a&&p.forEach(function(m){m.removeEventListener("scroll",t.update,al)}),h&&f.removeEventListener("resize",t.update,al)}}const db={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:hb,data:{}};var fb={left:"right",right:"left",bottom:"top",top:"bottom"};function ll(r){return r.replace(/left|right|bottom|top/g,function(e){return fb[e]})}var pb={start:"end",end:"start"};function gp(r){return r.replace(/start|end/g,function(e){return pb[e]})}function bu(r){var e=or(r),t=e.pageXOffset,i=e.pageYOffset;return{scrollLeft:t,scrollTop:i}}function xu(r){return Fn(Ds(r)).left+bu(r).scrollLeft}function mb(r,e){var t=or(r),i=Ds(r),n=t.visualViewport,a=i.clientWidth,l=i.clientHeight,h=0,f=0;if(n){a=n.width,l=n.height;var p=cp();(p||!p&&e==="fixed")&&(h=n.offsetLeft,f=n.offsetTop)}return{width:a,height:l,x:h+xu(r),y:f}}function gb(r){var e,t=Ds(r),i=bu(r),n=(e=r.ownerDocument)==null?void 0:e.body,a=pn(t.scrollWidth,t.clientWidth,n?n.scrollWidth:0,n?n.clientWidth:0),l=pn(t.scrollHeight,t.clientHeight,n?n.scrollHeight:0,n?n.clientHeight:0),h=-i.scrollLeft+xu(r),f=-i.scrollTop;return cs(n||t).direction==="rtl"&&(h+=pn(t.clientWidth,n?n.clientWidth:0)-a),{width:a,height:l,x:h,y:f}}function Tu(r){var e=cs(r),t=e.overflow,i=e.overflowX,n=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+n+i)}function vp(r){return["html","body","#document"].indexOf(Ur(r))>=0?r.ownerDocument.body:vr(r)&&Tu(r)?r:vp(ol(r))}function Go(r,e){var t;e===void 0&&(e=[]);var i=vp(r),n=i===((t=r.ownerDocument)==null?void 0:t.body),a=or(i),l=n?[a].concat(a.visualViewport||[],Tu(i)?i:[]):i,h=e.concat(l);return n?h:h.concat(Go(ol(l)))}function ku(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}function vb(r,e){var t=Fn(r,!1,e==="fixed");return t.top=t.top+r.clientTop,t.left=t.left+r.clientLeft,t.bottom=t.top+r.clientHeight,t.right=t.left+r.clientWidth,t.width=r.clientWidth,t.height=r.clientHeight,t.x=t.left,t.y=t.top,t}function yp(r,e,t){return e===np?ku(mb(r,t)):fn(e)?vb(e,t):ku(gb(Ds(r)))}function yb(r){var e=Go(ol(r)),t=["absolute","fixed"].indexOf(cs(r).position)>=0,i=t&&vr(r)?Uo(r):r;return fn(i)?e.filter(function(n){return fn(n)&&up(n,i)&&Ur(n)!=="body"}):[]}function Ab(r,e,t,i){var n=e==="clippingParents"?yb(r):[].concat(e),a=[].concat(n,[t]),l=a[0],h=a.reduce(function(f,p){var m=yp(r,p,i);return f.top=pn(m.top,f.top),f.right=nl(m.right,f.right),f.bottom=nl(m.bottom,f.bottom),f.left=pn(m.left,f.left),f},yp(r,l,i));return h.width=h.right-h.left,h.height=h.bottom-h.top,h.x=h.left,h.y=h.top,h}function Ap(r){var e=r.reference,t=r.element,i=r.placement,n=i?Br(i):null,a=i?Mn(i):null,l=e.x+e.width/2-t.width/2,h=e.y+e.height/2-t.height/2,f;switch(n){case Qi:f={x:l,y:e.y-t.height};break;case mr:f={x:l,y:e.y+e.height};break;case gr:f={x:e.x+e.width,y:h};break;case Ji:f={x:e.x-t.width,y:h};break;default:f={x:e.x,y:e.y}}var p=n?Eu(n):null;if(p!=null){var m=p==="y"?"height":"width";switch(a){case Pn:f[p]=f[p]-(e[m]/2-t[m]/2);break;case Mo:f[p]=f[p]+(e[m]/2-t[m]/2);break}}return f}function Vo(r,e){e===void 0&&(e={});var t=e,i=t.placement,n=i===void 0?r.placement:i,a=t.strategy,l=a===void 0?r.strategy:a,h=t.boundary,f=h===void 0?BE:h,p=t.rootBoundary,m=p===void 0?np:p,g=t.elementContext,A=g===void 0?No:g,b=t.altBoundary,x=b===void 0?!1:b,k=t.padding,w=k===void 0?0:k,P=fp(typeof w!="number"?w:pp(w,Fo)),$=A===No?GE:No,N=r.rects.popper,I=r.elements[x?$:A],O=Ab(fn(I)?I:I.contextElement||Ds(r.elements.popper),f,m,l),K=Fn(r.elements.reference),U=Ap({reference:K,element:N,strategy:"absolute",placement:n}),re=ku(Object.assign({},N,U)),ne=A===No?re:K,Y={top:O.top-ne.top+P.top,bottom:ne.bottom-O.bottom+P.bottom,left:O.left-ne.left+P.left,right:ne.right-O.right+P.right},Ee=r.modifiersData.offset;if(A===No&&Ee){var ce=Ee[n];Object.keys(Y).forEach(function(_e){var Oe=[gr,mr].indexOf(_e)>=0?1:-1,B=[Qi,mr].indexOf(_e)>=0?"y":"x";Y[_e]+=ce[B]*Oe})}return Y}function Eb(r,e){e===void 0&&(e={});var t=e,i=t.placement,n=t.boundary,a=t.rootBoundary,l=t.padding,h=t.flipVariations,f=t.allowedAutoPlacements,p=f===void 0?ap:f,m=Mn(i),g=m?h?op:op.filter(function(x){return Mn(x)===m}):Fo,A=g.filter(function(x){return p.indexOf(x)>=0});A.length===0&&(A=g);var b=A.reduce(function(x,k){return x[k]=Vo(r,{placement:k,boundary:n,rootBoundary:a,padding:l})[Br(k)],x},{});return Object.keys(b).sort(function(x,k){return b[x]-b[k]})}function bb(r){if(Br(r)===gu)return[];var e=ll(r);return[gp(r),e,gp(e)]}function xb(r){var e=r.state,t=r.options,i=r.name;if(!e.modifiersData[i]._skip){for(var n=t.mainAxis,a=n===void 0?!0:n,l=t.altAxis,h=l===void 0?!0:l,f=t.fallbackPlacements,p=t.padding,m=t.boundary,g=t.rootBoundary,A=t.altBoundary,b=t.flipVariations,x=b===void 0?!0:b,k=t.allowedAutoPlacements,w=e.options.placement,P=Br(w),$=P===w,N=f||($||!x?[ll(w)]:bb(w)),I=[w].concat(N).reduce(function(Ue,Ke){return Ue.concat(Br(Ke)===gu?Eb(e,{placement:Ke,boundary:m,rootBoundary:g,padding:p,flipVariations:x,allowedAutoPlacements:k}):Ke)},[]),O=e.rects.reference,K=e.rects.popper,U=new Map,re=!0,ne=I[0],Y=0;Y<I.length;Y++){var Ee=I[Y],ce=Br(Ee),_e=Mn(Ee)===Pn,Oe=[Qi,mr].indexOf(ce)>=0,B=Oe?"width":"height",W=Vo(e,{placement:Ee,boundary:m,rootBoundary:g,altBoundary:A,padding:p}),we=Oe?_e?gr:Ji:_e?mr:Qi;O[B]>K[B]&&(we=ll(we));var M=ll(we),G=[];if(a&&G.push(W[ce]<=0),h&&G.push(W[we]<=0,W[M]<=0),G.every(function(Ue){return Ue})){ne=Ee,re=!1;break}U.set(Ee,G)}if(re)for(var Q=x?3:1,me=function(Ke){var Ze=I.find(function(pt){var dt=U.get(pt);if(dt)return dt.slice(0,Ke).every(function(Kt){return Kt})});if(Ze)return ne=Ze,"break"},pe=Q;pe>0;pe--){var Le=me(pe);if(Le==="break")break}e.placement!==ne&&(e.modifiersData[i]._skip=!0,e.placement=ne,e.reset=!0)}}const Tb={name:"flip",enabled:!0,phase:"main",fn:xb,requiresIfExists:["offset"],data:{_skip:!1}};function Ep(r,e,t){return t===void 0&&(t={x:0,y:0}),{top:r.top-e.height-t.y,right:r.right-e.width+t.x,bottom:r.bottom-e.height+t.y,left:r.left-e.width-t.x}}function bp(r){return[Qi,gr,mr,Ji].some(function(e){return r[e]>=0})}function kb(r){var e=r.state,t=r.name,i=e.rects.reference,n=e.rects.popper,a=e.modifiersData.preventOverflow,l=Vo(e,{elementContext:"reference"}),h=Vo(e,{altBoundary:!0}),f=Ep(l,i),p=Ep(h,n,a),m=bp(f),g=bp(p);e.modifiersData[t]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:m,hasPopperEscaped:g},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":m,"data-popper-escaped":g})}const Sb={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:kb};function wb(r,e,t){var i=Br(r),n=[Ji,Qi].indexOf(i)>=0?-1:1,a=typeof t=="function"?t(Object.assign({},e,{placement:r})):t,l=a[0],h=a[1];return l=l||0,h=(h||0)*n,[Ji,gr].indexOf(i)>=0?{x:h,y:l}:{x:l,y:h}}function _b(r){var e=r.state,t=r.options,i=r.name,n=t.offset,a=n===void 0?[0,0]:n,l=ap.reduce(function(m,g){return m[g]=wb(g,e.rects,a),m},{}),h=l[e.placement],f=h.x,p=h.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=f,e.modifiersData.popperOffsets.y+=p),e.modifiersData[i]=l}const Rb={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:_b};function Lb(r){var e=r.state,t=r.name;e.modifiersData[t]=Ap({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const Cb={name:"popperOffsets",enabled:!0,phase:"read",fn:Lb,data:{}};function Ib(r){return r==="x"?"y":"x"}function Db(r){var e=r.state,t=r.options,i=r.name,n=t.mainAxis,a=n===void 0?!0:n,l=t.altAxis,h=l===void 0?!1:l,f=t.boundary,p=t.rootBoundary,m=t.altBoundary,g=t.padding,A=t.tether,b=A===void 0?!0:A,x=t.tetherOffset,k=x===void 0?0:x,w=Vo(e,{boundary:f,rootBoundary:p,padding:g,altBoundary:m}),P=Br(e.placement),$=Mn(e.placement),N=!$,I=Eu(P),O=Ib(I),K=e.modifiersData.popperOffsets,U=e.rects.reference,re=e.rects.popper,ne=typeof k=="function"?k(Object.assign({},e.rects,{placement:e.placement})):k,Y=typeof ne=="number"?{mainAxis:ne,altAxis:ne}:Object.assign({mainAxis:0,altAxis:0},ne),Ee=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,ce={x:0,y:0};if(K){if(a){var _e,Oe=I==="y"?Qi:Ji,B=I==="y"?mr:gr,W=I==="y"?"height":"width",we=K[I],M=we+w[Oe],G=we-w[B],Q=b?-re[W]/2:0,me=$===Pn?U[W]:re[W],pe=$===Pn?-re[W]:-U[W],Le=e.elements.arrow,Ue=b&&Le?Au(Le):{width:0,height:0},Ke=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:dp(),Ze=Ke[Oe],pt=Ke[B],dt=Bo(0,U[W],Ue[W]),Kt=N?U[W]/2-Q-dt-Ze-Y.mainAxis:me-dt-Ze-Y.mainAxis,_t=N?-U[W]/2+Q+dt+pt+Y.mainAxis:pe+dt+pt+Y.mainAxis,je=e.elements.arrow&&Uo(e.elements.arrow),qe=je?I==="y"?je.clientTop||0:je.clientLeft||0:0,Be=(_e=Ee==null?void 0:Ee[I])!=null?_e:0,ot=we+Kt-Be-qe,Me=we+_t-Be,It=Bo(b?nl(M,ot):M,we,b?pn(G,Me):G);K[I]=It,ce[I]=It-we}if(h){var At,Ut=I==="x"?Qi:Ji,hi=I==="x"?mr:gr,st=K[O],Bt=O==="y"?"height":"width",at=st+w[Ut],$t=st-w[hi],Gt=[Qi,Ji].indexOf(P)!==-1,ir=(At=Ee==null?void 0:Ee[O])!=null?At:0,Vt=Gt?at:st-U[Bt]-re[Bt]-ir+Y.altAxis,Pi=Gt?st+U[Bt]+re[Bt]-ir-Y.altAxis:$t,hs=b&&Gt?ib(Vt,st,Pi):Bo(b?Vt:at,st,b?Pi:$t);K[O]=hs,ce[O]=hs-st}e.modifiersData[i]=ce}}const Ob={name:"preventOverflow",enabled:!0,phase:"main",fn:Db,requiresIfExists:["offset"]};function Pb(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}function $b(r){return r===or(r)||!vr(r)?bu(r):Pb(r)}function Fb(r){var e=r.getBoundingClientRect(),t=$n(e.width)/r.offsetWidth||1,i=$n(e.height)/r.offsetHeight||1;return t!==1||i!==1}function Mb(r,e,t){t===void 0&&(t=!1);var i=vr(e),n=vr(e)&&Fb(e),a=Ds(e),l=Fn(r,n,t),h={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!t)&&((Ur(e)!=="body"||Tu(a))&&(h=$b(e)),vr(e)?(f=Fn(e,!0),f.x+=e.clientLeft,f.y+=e.clientTop):a&&(f.x=xu(a))),{x:l.left+h.scrollLeft-f.x,y:l.top+h.scrollTop-f.y,width:l.width,height:l.height}}function Nb(r){var e=new Map,t=new Set,i=[];r.forEach(function(a){e.set(a.name,a)});function n(a){t.add(a.name);var l=[].concat(a.requires||[],a.requiresIfExists||[]);l.forEach(function(h){if(!t.has(h)){var f=e.get(h);f&&n(f)}}),i.push(a)}return r.forEach(function(a){t.has(a.name)||n(a)}),i}function Ub(r){var e=Nb(r);return qE.reduce(function(t,i){return t.concat(e.filter(function(n){return n.phase===i}))},[])}function Bb(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}function Gb(r){var e=r.reduce(function(t,i){var n=t[i.name];return t[i.name]=n?Object.assign({},n,i,{options:Object.assign({},n.options,i.options),data:Object.assign({},n.data,i.data)}):i,t},{});return Object.keys(e).map(function(t){return e[t]})}var xp={placement:"bottom",modifiers:[],strategy:"absolute"};function Tp(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return!e.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function Vb(r){r===void 0&&(r={});var e=r,t=e.defaultModifiers,i=t===void 0?[]:t,n=e.defaultOptions,a=n===void 0?xp:n;return function(h,f,p){p===void 0&&(p=a);var m={placement:"bottom",orderedModifiers:[],options:Object.assign({},xp,a),modifiersData:{},elements:{reference:h,popper:f},attributes:{},styles:{}},g=[],A=!1,b={state:m,setOptions:function(P){var $=typeof P=="function"?P(m.options):P;k(),m.options=Object.assign({},a,m.options,$),m.scrollParents={reference:fn(h)?Go(h):h.contextElement?Go(h.contextElement):[],popper:Go(f)};var N=Ub(Gb([].concat(i,m.options.modifiers)));return m.orderedModifiers=N.filter(function(I){return I.enabled}),x(),b.update()},forceUpdate:function(){if(!A){var P=m.elements,$=P.reference,N=P.popper;if(Tp($,N)){m.rects={reference:Mb($,Uo(N),m.options.strategy==="fixed"),popper:Au(N)},m.reset=!1,m.placement=m.options.placement,m.orderedModifiers.forEach(function(Y){return m.modifiersData[Y.name]=Object.assign({},Y.data)});for(var I=0;I<m.orderedModifiers.length;I++){if(m.reset===!0){m.reset=!1,I=-1;continue}var O=m.orderedModifiers[I],K=O.fn,U=O.options,re=U===void 0?{}:U,ne=O.name;typeof K=="function"&&(m=K({state:m,options:re,name:ne,instance:b})||m)}}}},update:Bb(function(){return new Promise(function(w){b.forceUpdate(),w(m)})}),destroy:function(){k(),A=!0}};if(!Tp(h,f))return b;b.setOptions(p).then(function(w){!A&&p.onFirstUpdate&&p.onFirstUpdate(w)});function x(){m.orderedModifiers.forEach(function(w){var P=w.name,$=w.options,N=$===void 0?{}:$,I=w.effect;if(typeof I=="function"){var O=I({state:m,name:P,instance:b,options:N}),K=function(){};g.push(O||K)}})}function k(){g.forEach(function(w){return w()}),g=[]}return b}}var Hb=[db,Cb,ub,lp,Rb,Tb,Ob,ob,Sb],Wb=Vb({defaultModifiers:Hb}),jb="tippy-box",kp="tippy-content",Kb="tippy-backdrop",Sp="tippy-arrow",wp="tippy-svg-arrow",mn={passive:!0,capture:!0},_p=function(){return document.body};function Su(r,e,t){if(Array.isArray(r)){var i=r[e];return i??(Array.isArray(t)?t[e]:t)}return r}function wu(r,e){var t={}.toString.call(r);return t.indexOf("[object")===0&&t.indexOf(e+"]")>-1}function Rp(r,e){return typeof r=="function"?r.apply(void 0,e):r}function Lp(r,e){if(e===0)return r;var t;return function(i){clearTimeout(t),t=setTimeout(function(){r(i)},e)}}function zb(r){return r.split(/\s+/).filter(Boolean)}function Nn(r){return[].concat(r)}function Cp(r,e){r.indexOf(e)===-1&&r.push(e)}function Yb(r){return r.filter(function(e,t){return r.indexOf(e)===t})}function Xb(r){return r.split("-")[0]}function cl(r){return[].slice.call(r)}function Ip(r){return Object.keys(r).reduce(function(e,t){return r[t]!==void 0&&(e[t]=r[t]),e},{})}function Ho(){return document.createElement("div")}function ul(r){return["Element","Fragment"].some(function(e){return wu(r,e)})}function Zb(r){return wu(r,"NodeList")}function qb(r){return wu(r,"MouseEvent")}function Qb(r){return!!(r&&r._tippy&&r._tippy.reference===r)}function Jb(r){return ul(r)?[r]:Zb(r)?cl(r):Array.isArray(r)?r:cl(document.querySelectorAll(r))}function _u(r,e){r.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Dp(r,e){r.forEach(function(t){t&&t.setAttribute("data-state",e)})}function e4(r){var e,t=Nn(r),i=t[0];return i!=null&&(e=i.ownerDocument)!=null&&e.body?i.ownerDocument:document}function t4(r,e){var t=e.clientX,i=e.clientY;return r.every(function(n){var a=n.popperRect,l=n.popperState,h=n.props,f=h.interactiveBorder,p=Xb(l.placement),m=l.modifiersData.offset;if(!m)return!0;var g=p==="bottom"?m.top.y:0,A=p==="top"?m.bottom.y:0,b=p==="right"?m.left.x:0,x=p==="left"?m.right.x:0,k=a.top-i+g>f,w=i-a.bottom-A>f,P=a.left-t+b>f,$=t-a.right-x>f;return k||w||P||$})}function Ru(r,e,t){var i=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(n){r[i](n,t)})}function Op(r,e){for(var t=e;t;){var i;if(r.contains(t))return!0;t=t.getRootNode==null||(i=t.getRootNode())==null?void 0:i.host}return!1}var Gr={isTouch:!1},Pp=0;function i4(){Gr.isTouch||(Gr.isTouch=!0,window.performance&&document.addEventListener("mousemove",$p))}function $p(){var r=performance.now();r-Pp<20&&(Gr.isTouch=!1,document.removeEventListener("mousemove",$p)),Pp=r}function r4(){var r=document.activeElement;if(Qb(r)){var e=r._tippy;r.blur&&!e.state.isVisible&&r.blur()}}function s4(){document.addEventListener("touchstart",i4,mn),window.addEventListener("blur",r4)}var n4=typeof window<"u"&&typeof document<"u",o4=n4?!!window.msCrypto:!1,a4={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},l4={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Rr=Object.assign({appendTo:_p,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},a4,l4),c4=Object.keys(Rr),u4=function(e){var t=Object.keys(e);t.forEach(function(i){Rr[i]=e[i]})};function Fp(r){var e=r.plugins||[],t=e.reduce(function(i,n){var a=n.name,l=n.defaultValue;if(a){var h;i[a]=r[a]!==void 0?r[a]:(h=Rr[a])!=null?h:l}return i},{});return Object.assign({},r,t)}function h4(r,e){var t=e?Object.keys(Fp(Object.assign({},Rr,{plugins:e}))):c4,i=t.reduce(function(n,a){var l=(r.getAttribute("data-tippy-"+a)||"").trim();if(!l)return n;if(a==="content")n[a]=l;else try{n[a]=JSON.parse(l)}catch{n[a]=l}return n},{});return i}function Mp(r,e){var t=Object.assign({},e,{content:Rp(e.content,[r])},e.ignoreAttributes?{}:h4(r,e.plugins));return t.aria=Object.assign({},Rr.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var d4=function(){return"innerHTML"};function Lu(r,e){r[d4()]=e}function Np(r){var e=Ho();return r===!0?e.className=Sp:(e.className=wp,ul(r)?e.appendChild(r):Lu(e,r)),e}function Up(r,e){ul(e.content)?(Lu(r,""),r.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?Lu(r,e.content):r.textContent=e.content)}function Cu(r){var e=r.firstElementChild,t=cl(e.children);return{box:e,content:t.find(function(i){return i.classList.contains(kp)}),arrow:t.find(function(i){return i.classList.contains(Sp)||i.classList.contains(wp)}),backdrop:t.find(function(i){return i.classList.contains(Kb)})}}function Bp(r){var e=Ho(),t=Ho();t.className=jb,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var i=Ho();i.className=kp,i.setAttribute("data-state","hidden"),Up(i,r.props),e.appendChild(t),t.appendChild(i),n(r.props,r.props);function n(a,l){var h=Cu(e),f=h.box,p=h.content,m=h.arrow;l.theme?f.setAttribute("data-theme",l.theme):f.removeAttribute("data-theme"),typeof l.animation=="string"?f.setAttribute("data-animation",l.animation):f.removeAttribute("data-animation"),l.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof l.maxWidth=="number"?l.maxWidth+"px":l.maxWidth,l.role?f.setAttribute("role",l.role):f.removeAttribute("role"),(a.content!==l.content||a.allowHTML!==l.allowHTML)&&Up(p,r.props),l.arrow?m?a.arrow!==l.arrow&&(f.removeChild(m),f.appendChild(Np(l.arrow))):f.appendChild(Np(l.arrow)):m&&f.removeChild(m)}return{popper:e,onUpdate:n}}Bp.$$tippy=!0;var f4=1,hl=[],Iu=[];function p4(r,e){var t=Mp(r,Object.assign({},Rr,Fp(Ip(e)))),i,n,a,l=!1,h=!1,f=!1,p=!1,m,g,A,b=[],x=Lp(ot,t.interactiveDebounce),k,w=f4++,P=null,$=Yb(t.plugins),N={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},I={id:w,reference:r,popper:Ho(),popperInstance:P,props:t,state:N,plugins:$,clearDelayTimeouts:Vt,setProps:Pi,setContent:hs,show:di,hide:Lr,hideWithInteractivity:Fs,enable:Gt,disable:ir,unmount:Ms,destroy:lr};if(!t.render)return I;var O=t.render(I),K=O.popper,U=O.onUpdate;K.setAttribute("data-tippy-root",""),K.id="tippy-"+I.id,I.popper=K,r._tippy=I,K._tippy=I;var re=$.map(function(ue){return ue.fn(I)}),ne=r.hasAttribute("aria-expanded");return je(),Q(),we(),M("onCreate",[I]),t.showOnCreate&&at(),K.addEventListener("mouseenter",function(){I.props.interactive&&I.state.isVisible&&I.clearDelayTimeouts()}),K.addEventListener("mouseleave",function(){I.props.interactive&&I.props.trigger.indexOf("mouseenter")>=0&&Oe().addEventListener("mousemove",x)}),I;function Y(){var ue=I.props.touch;return Array.isArray(ue)?ue:[ue,0]}function Ee(){return Y()[0]==="hold"}function ce(){var ue;return!!((ue=I.props.render)!=null&&ue.$$tippy)}function _e(){return k||r}function Oe(){var ue=_e().parentNode;return ue?e4(ue):document}function B(){return Cu(K)}function W(ue){return I.state.isMounted&&!I.state.isVisible||Gr.isTouch||m&&m.type==="focus"?0:Su(I.props.delay,ue?0:1,Rr.delay)}function we(ue){ue===void 0&&(ue=!1),K.style.pointerEvents=I.props.interactive&&!ue?"":"none",K.style.zIndex=""+I.props.zIndex}function M(ue,Ve,Je){if(Je===void 0&&(Je=!0),re.forEach(function(ct){ct[ue]&&ct[ue].apply(ct,Ve)}),Je){var Et;(Et=I.props)[ue].apply(Et,Ve)}}function G(){var ue=I.props.aria;if(ue.content){var Ve="aria-"+ue.content,Je=K.id,Et=Nn(I.props.triggerTarget||r);Et.forEach(function(ct){var oi=ct.getAttribute(Ve);if(I.state.isVisible)ct.setAttribute(Ve,oi?oi+" "+Je:Je);else{var $i=oi&&oi.replace(Je,"").trim();$i?ct.setAttribute(Ve,$i):ct.removeAttribute(Ve)}})}}function Q(){if(!(ne||!I.props.aria.expanded)){var ue=Nn(I.props.triggerTarget||r);ue.forEach(function(Ve){I.props.interactive?Ve.setAttribute("aria-expanded",I.state.isVisible&&Ve===_e()?"true":"false"):Ve.removeAttribute("aria-expanded")})}}function me(){Oe().removeEventListener("mousemove",x),hl=hl.filter(function(ue){return ue!==x})}function pe(ue){if(!(Gr.isTouch&&(f||ue.type==="mousedown"))){var Ve=ue.composedPath&&ue.composedPath()[0]||ue.target;if(!(I.props.interactive&&Op(K,Ve))){if(Nn(I.props.triggerTarget||r).some(function(Je){return Op(Je,Ve)})){if(Gr.isTouch||I.state.isVisible&&I.props.trigger.indexOf("click")>=0)return}else M("onClickOutside",[I,ue]);I.props.hideOnClick===!0&&(I.clearDelayTimeouts(),I.hide(),h=!0,setTimeout(function(){h=!1}),I.state.isMounted||Ze())}}}function Le(){f=!0}function Ue(){f=!1}function Ke(){var ue=Oe();ue.addEventListener("mousedown",pe,!0),ue.addEventListener("touchend",pe,mn),ue.addEventListener("touchstart",Ue,mn),ue.addEventListener("touchmove",Le,mn)}function Ze(){var ue=Oe();ue.removeEventListener("mousedown",pe,!0),ue.removeEventListener("touchend",pe,mn),ue.removeEventListener("touchstart",Ue,mn),ue.removeEventListener("touchmove",Le,mn)}function pt(ue,Ve){Kt(ue,function(){!I.state.isVisible&&K.parentNode&&K.parentNode.contains(K)&&Ve()})}function dt(ue,Ve){Kt(ue,Ve)}function Kt(ue,Ve){var Je=B().box;function Et(ct){ct.target===Je&&(Ru(Je,"remove",Et),Ve())}if(ue===0)return Ve();Ru(Je,"remove",g),Ru(Je,"add",Et),g=Et}function _t(ue,Ve,Je){Je===void 0&&(Je=!1);var Et=Nn(I.props.triggerTarget||r);Et.forEach(function(ct){ct.addEventListener(ue,Ve,Je),b.push({node:ct,eventType:ue,handler:Ve,options:Je})})}function je(){Ee()&&(_t("touchstart",Be,{passive:!0}),_t("touchend",Me,{passive:!0})),zb(I.props.trigger).forEach(function(ue){if(ue!=="manual")switch(_t(ue,Be),ue){case"mouseenter":_t("mouseleave",Me);break;case"focus":_t(o4?"focusout":"blur",It);break;case"focusin":_t("focusout",It);break}})}function qe(){b.forEach(function(ue){var Ve=ue.node,Je=ue.eventType,Et=ue.handler,ct=ue.options;Ve.removeEventListener(Je,Et,ct)}),b=[]}function Be(ue){var Ve,Je=!1;if(!(!I.state.isEnabled||At(ue)||h)){var Et=((Ve=m)==null?void 0:Ve.type)==="focus";m=ue,k=ue.currentTarget,Q(),!I.state.isVisible&&qb(ue)&&hl.forEach(function(ct){return ct(ue)}),ue.type==="click"&&(I.props.trigger.indexOf("mouseenter")<0||l)&&I.props.hideOnClick!==!1&&I.state.isVisible?Je=!0:at(ue),ue.type==="click"&&(l=!Je),Je&&!Et&&$t(ue)}}function ot(ue){var Ve=ue.target,Je=_e().contains(Ve)||K.contains(Ve);if(!(ue.type==="mousemove"&&Je)){var Et=Bt().concat(K).map(function(ct){var oi,$i=ct._tippy,Ar=(oi=$i.popperInstance)==null?void 0:oi.state;return Ar?{popperRect:ct.getBoundingClientRect(),popperState:Ar,props:t}:null}).filter(Boolean);t4(Et,ue)&&(me(),$t(ue))}}function Me(ue){var Ve=At(ue)||I.props.trigger.indexOf("click")>=0&&l;if(!Ve){if(I.props.interactive){I.hideWithInteractivity(ue);return}$t(ue)}}function It(ue){I.props.trigger.indexOf("focusin")<0&&ue.target!==_e()||I.props.interactive&&ue.relatedTarget&&K.contains(ue.relatedTarget)||$t(ue)}function At(ue){return Gr.isTouch?Ee()!==ue.type.indexOf("touch")>=0:!1}function Ut(){hi();var ue=I.props,Ve=ue.popperOptions,Je=ue.placement,Et=ue.offset,ct=ue.getReferenceClientRect,oi=ue.moveTransition,$i=ce()?Cu(K).arrow:null,Ar=ct?{getBoundingClientRect:ct,contextElement:ct.contextElement||_e()}:r,ds={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ns){var Fi=Ns.state;if(ce()){var Xo=B(),xr=Xo.box;["placement","reference-hidden","escaped"].forEach(function(Us){Us==="placement"?xr.setAttribute("data-placement",Fi.placement):Fi.attributes.popper["data-popper-"+Us]?xr.setAttribute("data-"+Us,""):xr.removeAttribute("data-"+Us)}),Fi.attributes.popper={}}}},Er=[{name:"offset",options:{offset:Et}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!oi}},ds];ce()&&$i&&Er.push({name:"arrow",options:{element:$i,padding:3}}),Er.push.apply(Er,(Ve==null?void 0:Ve.modifiers)||[]),I.popperInstance=Wb(Ar,K,Object.assign({},Ve,{placement:Je,onFirstUpdate:A,modifiers:Er}))}function hi(){I.popperInstance&&(I.popperInstance.destroy(),I.popperInstance=null)}function st(){var ue=I.props.appendTo,Ve,Je=_e();I.props.interactive&&ue===_p||ue==="parent"?Ve=Je.parentNode:Ve=Rp(ue,[Je]),Ve.contains(K)||Ve.appendChild(K),I.state.isMounted=!0,Ut()}function Bt(){return cl(K.querySelectorAll("[data-tippy-root]"))}function at(ue){I.clearDelayTimeouts(),ue&&M("onTrigger",[I,ue]),Ke();var Ve=W(!0),Je=Y(),Et=Je[0],ct=Je[1];Gr.isTouch&&Et==="hold"&&ct&&(Ve=ct),Ve?i=setTimeout(function(){I.show()},Ve):I.show()}function $t(ue){if(I.clearDelayTimeouts(),M("onUntrigger",[I,ue]),!I.state.isVisible){Ze();return}if(!(I.props.trigger.indexOf("mouseenter")>=0&&I.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ue.type)>=0&&l)){var Ve=W(!1);Ve?n=setTimeout(function(){I.state.isVisible&&I.hide()},Ve):a=requestAnimationFrame(function(){I.hide()})}}function Gt(){I.state.isEnabled=!0}function ir(){I.hide(),I.state.isEnabled=!1}function Vt(){clearTimeout(i),clearTimeout(n),cancelAnimationFrame(a)}function Pi(ue){if(!I.state.isDestroyed){M("onBeforeUpdate",[I,ue]),qe();var Ve=I.props,Je=Mp(r,Object.assign({},Ve,Ip(ue),{ignoreAttributes:!0}));I.props=Je,je(),Ve.interactiveDebounce!==Je.interactiveDebounce&&(me(),x=Lp(ot,Je.interactiveDebounce)),Ve.triggerTarget&&!Je.triggerTarget?Nn(Ve.triggerTarget).forEach(function(Et){Et.removeAttribute("aria-expanded")}):Je.triggerTarget&&r.removeAttribute("aria-expanded"),Q(),we(),U&&U(Ve,Je),I.popperInstance&&(Ut(),Bt().forEach(function(Et){requestAnimationFrame(Et._tippy.popperInstance.forceUpdate)})),M("onAfterUpdate",[I,ue])}}function hs(ue){I.setProps({content:ue})}function di(){var ue=I.state.isVisible,Ve=I.state.isDestroyed,Je=!I.state.isEnabled,Et=Gr.isTouch&&!I.props.touch,ct=Su(I.props.duration,0,Rr.duration);if(!(ue||Ve||Je||Et)&&!_e().hasAttribute("disabled")&&(M("onShow",[I],!1),I.props.onShow(I)!==!1)){if(I.state.isVisible=!0,ce()&&(K.style.visibility="visible"),we(),Ke(),I.state.isMounted||(K.style.transition="none"),ce()){var oi=B(),$i=oi.box,Ar=oi.content;_u([$i,Ar],0)}A=function(){var Er;if(!(!I.state.isVisible||p)){if(p=!0,K.offsetHeight,K.style.transition=I.props.moveTransition,ce()&&I.props.animation){var br=B(),Ns=br.box,Fi=br.content;_u([Ns,Fi],ct),Dp([Ns,Fi],"visible")}G(),Q(),Cp(Iu,I),(Er=I.popperInstance)==null||Er.forceUpdate(),M("onMount",[I]),I.props.animation&&ce()&&dt(ct,function(){I.state.isShown=!0,M("onShown",[I])})}},st()}}function Lr(){var ue=!I.state.isVisible,Ve=I.state.isDestroyed,Je=!I.state.isEnabled,Et=Su(I.props.duration,1,Rr.duration);if(!(ue||Ve||Je)&&(M("onHide",[I],!1),I.props.onHide(I)!==!1)){if(I.state.isVisible=!1,I.state.isShown=!1,p=!1,l=!1,ce()&&(K.style.visibility="hidden"),me(),Ze(),we(!0),ce()){var ct=B(),oi=ct.box,$i=ct.content;I.props.animation&&(_u([oi,$i],Et),Dp([oi,$i],"hidden"))}G(),Q(),I.props.animation?ce()&&pt(Et,I.unmount):I.unmount()}}function Fs(ue){Oe().addEventListener("mousemove",x),Cp(hl,x),x(ue)}function Ms(){I.state.isVisible&&I.hide(),I.state.isMounted&&(hi(),Bt().forEach(function(ue){ue._tippy.unmount()}),K.parentNode&&K.parentNode.removeChild(K),Iu=Iu.filter(function(ue){return ue!==I}),I.state.isMounted=!1,M("onHidden",[I]))}function lr(){I.state.isDestroyed||(I.clearDelayTimeouts(),I.unmount(),qe(),delete r._tippy,I.state.isDestroyed=!0,M("onDestroy",[I]))}}function gn(r,e){e===void 0&&(e={});var t=Rr.plugins.concat(e.plugins||[]);s4();var i=Object.assign({},e,{plugins:t}),n=Jb(r),a=n.reduce(function(l,h){var f=h&&p4(h,i);return f&&l.push(f),l},[]);return ul(r)?a[0]:a}gn.defaultProps=Rr,gn.setDefaultProps=u4,gn.currentInput=Gr,Object.assign({},lp,{effect:function(e){var t=e.state,i={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,i.popper),t.styles=i,t.elements.arrow&&Object.assign(t.elements.arrow.style,i.arrow)}}),gn.setDefaultProps({render:Bp});class Vr extends Error{constructor(e,t=new Error,i=!1){super(),this.fatal=!1,this.fatal=i,this.stack=t.stack,this.message=[e,t.message].filter(Boolean).join(" - ")}}const m4=5;class g4{constructor(e){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=ki(),this._controls=ki(),this.host=e}set activeScenes(e){if(e!==this._activeScenes){const t=e[0],i=this._activeScenes[0];this._activeScenes=e,t!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:e[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(e){var t,i,n,a,l;const h=Math.min(this.host.duration,Math.max(0,e));this._currentTime=h,this.activeScenes=((t=this.host.scenes)==null?void 0:t.filter(({start:m,duration:g})=>h>=m&&h<m+g))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:m})=>h>=m-m4&&h<m))??[],this.loadScenes(),this.syncVideoState(),(n=this._controls.value)==null||n.setAttribute("currentTime",h.toString());const f=this.activeScenes[0],p=id((a=f==null?void 0:f.videoMeta)==null?void 0:a.captions);this.caption=((l=p.find(({start:m,end:g})=>{var A;const b=h-f.start+(((A=f.videoMeta)==null?void 0:A.start)??0);return m&&g&&b>=Fa(m)&&b<=Fa(g)}))==null?void 0:l.text)??"",this.draw(h),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:h}))}get currentTime(){return this._currentTime}set caption(e){e!==this._caption&&(this._caption=e,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Si(this._canvas)}controls(){return Si(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(e=>{var t,i,n;const{start:a,duration:l,video:h,videoMeta:f}=e,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(h&&f){const{key:m,hls:g,node:A}=h,{start:b,duration:x}=f,k=this.host.videoState[m];A&&k&&(A.currentTime>=b+x||A.ended||p&&(g?(t=g.startLoadOnce)==null||t.call(g,A.currentTime):k.initialised||(i=A.startLoadOnce)==null||i.call(A)))}else if(p){const m=`${a}-${l}`,g=this.host._sceneController.videoState[m];this.host.duration&&!((n=g==null?void 0:g.buffered)!=null&&n.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[m]:{...g,buffered:[{start:Math.max(0,a/this.host.duration*100),end:Math.min((a+l)/this.host.duration*100,100)}]}})}})}syncVideoState(){var e;(e=this.host.scenes)==null||e.forEach(t=>{if(t.video){const{key:i,node:n}=t.video,a=this.host.videoState[i],l=this.activeScenes.includes(t);if(n&&a)if(l&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(n.paused&&a.initialised)try{return n.play()}catch(h){throw new Vr("Video play error",h,!0)}}else n.paused||n.pause()}})}draw(e=this.currentTime){var t,i;this.host.sceneConfig&&this._canvas.value&&((i=(t=this.host).compilation)==null||i.call(t,{currentTime:e,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var e;const t=this._canvas.value;(e=t==null?void 0:t.getContext("2d"))==null||e.clearRect(0,0,t.width,t.height)}}function v4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function y4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Du(r){const{id:e,key:t,src:i,playlist:n,duration:a}=r;return new Promise(l=>{let h=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,n&&!v4()&&ls.isSupported()){let p=!1;h=new ls({autoStartLoad:!0,xhrSetup:m=>{const{open:g}=m,A=n.split("?")[1];m.open=function(b,x,k){x.toString().includes("?")||(x+="?"+A),g.apply(this,[b,x,k])}}}),h.loadSource(n),h.attachMedia(f),h.startLoadOnce=(m=-1,g)=>{if(h&&!p){const A=h==null?void 0:h.levels.findIndex(b=>Math.min(b.height,b.width)===g);h.startLevel=h.firstLevel,h.startLoad(m),p=!0,h.currentLevel=A!==-1?A:h.firstLevel}},h.on(ls.Events.LEVEL_LOADED,async()=>{p||h==null||h.stopLoad(),l({id:e,key:t,hls:h,config:r,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},a)f.preload="none",l({id:e,key:t,hls:h,config:r,node:f});else{f.preload="metadata";const m=async()=>{l({id:e,key:t,hls:h,config:r,node:f}),f.removeEventListener("loadedmetadata",m)};f.addEventListener("loadedmetadata",m)}}})}async function Gp(r){return r.duration===1/0?new Promise(e=>{r.currentTime=Number.MAX_SAFE_INTEGER,r.ontimeupdate=()=>{r.ontimeupdate=null,e(r.duration),r.currentTime=0}}):r.duration}const A4=Rs(async function(e){return new FontFace(e.name,`url(${e.woff2??e.url})`,{style:e.style,weight:e.weight}).load()},{cacheKey:([r])=>JSON.stringify(r)});let E4=class{constructor(e){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=Rs(async t=>{const{id:i,key:n}=t,a=await Du(t);a.node.volume=this.host.volume,a.node.playbackRate=this.host.playbackRate;const l={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},h=Object.keys(l).reduce((f,p)=>{const m=p,g=l[m]({id:i,key:n,node:a.node});return f[m]=g,a.node.addEventListener(p,g),f},{});return{...a,listeners:h}},{cacheKey:([{id:t,key:i,src:n,playlist:a}])=>JSON.stringify({id:t,key:i,src:n==null?void 0:n.split("?")[0],playlist:a==null?void 0:a.split("?")[0]})}),this._resolveVideoMeta=Rs(async(t,i)=>{const{id:n,captions:a,duration:l,startOffset:h,endOffset:f}=t,p=l??await Gp(i),m=(h??0)*p,g=(1-(f??0))*p;return{id:n,captions:a,start:m,duration:g-m}},{cacheKey:([{id:t,key:i,captions:n,duration:a,startOffset:l,endOffset:h}])=>JSON.stringify({id:t,key:i,captions:n,duration:a,startOffset:l,endOffset:h})}),this._handleLoadedData=({id:t,key:i,node:n})=>()=>{var a,l;const h=this.videoState[i];if(!(h!=null&&h.initialised)){this.videoState={...this.videoState,[i]:{...h,initialised:!0,waiting:!1,buffered:(h==null?void 0:h.buffered)??[]}};const f=(l=(a=this.scenes)==null?void 0:a.scenes)==null?void 0:l.find(({video:p})=>{p==null||p.key});f&&this._setVideoCurrentTime({scene:f,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:i,node:n}}))}},this._handleWaiting=({key:t})=>()=>{const i=this.videoState[t];i!=null&&i.initialised&&!(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[t]:{...i,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const i=this.videoState[t];i!=null&&i.initialised&&(i!=null&&i.waiting)&&(this.videoState={...this.videoState,[t]:{...i,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:i})=>()=>{const n=this.videoState[t],a=this._getBufferSegments({key:t,node:i,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...n,buffered:a}}},this._handleSeeking=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:i,node:n}}))},this._handleSeeked=({id:t,key:i,node:n})=>()=>{const a=this.videoState[i];a!=null&&a.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:i,node:n}})))},this._handlePlay=({id:t,key:i,node:n})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:i,node:n}}))},this._handlePlaying=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:i,node:n}}))},this._handlePause=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:i,node:n}}))},this._handleStalled=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:i,node:n}}))},this._handleTimeUpdate=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:i,node:n}}))},this._handleEnded=({id:t,key:i,node:n})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:i,node:n}}))},this._handleError=({id:t,key:i,node:n})=>()=>{const a=new Vr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:a,message:a.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:i,node:n}}))},this._cleanupVideo=t=>{var i;const n=this.videos[t];n&&(n.node.pause(),n.node.src="",(i=n.hls)==null||i.destroy(),Object.keys(n.listeners??{}).forEach(a=>{var l,h;if((l=this.videos)!=null&&l[t]){const f=(h=n.listeners)==null?void 0:h[a];f&&n.node.removeEventListener(a,f)}}),delete this.videos[t])},this.host=e,this.host.addController(this)}set hasPlayed(e){e!==this._hasPlayed&&(this._hasPlayed=e,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(e){!isNaN(e)&&e!==this._duration&&(this._duration=e,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(e){e!==this._scenes&&(this._scenes=e,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(e){e!==this._videos&&(this._videos=e,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(e){e!==this._videoMeta&&(this._videoMeta=e,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(e){e!==this._videoState&&(this._videoState=e,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:e,node:t,duration:i}){var n;const a=t==null?void 0:t.buffered,l=[],{start:h,video:f,videoMeta:p}=((n=this.scenes)==null?void 0:n.scenes.find(({video:m})=>e===(m==null?void 0:m.key)))??{};if(t&&a&&f&&p&&typeof h<"u")for(let m=0;m<a.length;m++){const g=a.start(m),A=a.end(m);Math.max(g,p.start)<=Math.min(A,p.start+p.duration)&&l.push({start:Math.max(0,(Math.max(g-p.start,0)+h)/i*100),end:Math.min((Math.min(A-p.start,p.duration)+h)/i*100,100)})}return l}_setupTask(){new pa(this.host,async([e,t,i,n,a,l])=>{try{let h=null;if(this.host._errors=[],i||e){if(this.host._processing=!0,i){let m=null;if(n)try{m=await(await fetch(n,{method:"GET"})).text()}catch(b){const x=new Vr("Track failed to fetch",b);this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:x,message:x.message}))}const A={questions:{items:[{answer:{id:"source",media:{[i.includes(".m3u8")?"playlist":"video"]:i},captions:{current:m}}}]}};try{this.scenes=await _n({data:A,template:t,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(b){try{this.scenes=await _n({data:A,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(x){throw new Vr("Fatal source template error",x,!0)}h=new Vr("Source template error",b)}}else try{this.scenes=await _n({data:e,template:t,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(m){try{this.scenes=await _n({data:e,burnCaptions:a,debug:l},this._resolveVideo,this._resolveVideoMeta)}catch(g){throw new Vr("Fatal data template error",g,!0)}h=new Vr("Data template error",m)}Object.keys(this.videos).forEach(m=>{this.scenes.scenes.find(({video:g})=>m===(g==null?void 0:g.key))||this._videos[m].node.pause()});const f=this.scenes.scenes.reduce((m,{video:g})=>(g&&(m[g.key]=g),m),{});Object.keys(this.videos).join("|")!==Object.keys(f).join("|")&&this.host.reset(0,!1),this.videos=f,this.videoState={...this.videoState,...this.scenes.scenes.reduce((m,{video:g,start:A,duration:b})=>{var x;const k=(g==null?void 0:g.key)??`${A}-${b}`,w=this._getBufferSegments({key:k,node:g==null?void 0:g.node,duration:this.scenes.duration});return m[k]={initialised:!g,waiting:!!g,...this.videoState[k],buffered:g?w:(x=this.videoState[k])==null?void 0:x.buffered},m},{})},this.videoMeta=this.scenes.scenes.reduce((m,{video:g,videoMeta:A})=>(g&&A&&(m[g.key]=A),m),{}),(await Promise.all(this.scenes.fonts.map(m=>A4(m)))).forEach(m=>{document.fonts.add(m)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}h&&this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:h,message:h.message}))}catch(h){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:h,message:h.message}))}finally{this.host._processing=!1}},()=>{const e=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===e)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=e,this._lastDeps=t,t})}_setVideoCurrentTime({time:e,scene:t}){const{start:i,video:n,videoMeta:a}=t;if(n&&n.node&&a&&typeof i<"u"){const l=e-i;n.node.currentTime=Math.max(a.start,Math.min(a.start+a.duration,l+a.start))}}setVideosCurrentTime(e){var t;(t=this.scenes)==null||t.scenes.forEach(i=>{this._setVideoCurrentTime({time:e,scene:i})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(e=>{this._cleanupVideo(e)}),this.videos={}}};function b4(r){r.requestFullscreen?r.requestFullscreen():r.mozRequestFullScreen?r.mozRequestFullScreen():r.webkitRequestFullscreen?r.webkitRequestFullscreen():r.msRequestFullscreen&&r.msRequestFullscreen()}function x4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const Ou=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],T4={id:"captions",event:"captions:click",label:"Closed Captions"},k4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Vp={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}]},S4={id:"playbackRate",label:"Playback playbackRate",subItems:Vp};class w4 extends c0{constructor(e){if(super(e),this.element=null,this.observer=void 0,e.type!==Sn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var e;(e=this.observer)==null||e.disconnect(),this.observer=void 0}reconnected(){var e;this.element&&((e=this.observer)==null||e.observe(this.element))}update(e,[t]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(t),this.element=e.element,this.observer.observe(this.element)),Ts}}const Pu=wn(w4),_4=UE(()=>{const r=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),e=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),t=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=J0.map(n=>({load:!1,font:new FontFace(n.family,`url(${n.url})`,{style:n.style})}));return[{load:!0,font:r},{load:!0,font:e},{load:!0,font:t},...i]}),Hr={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-80":"#f3fafa","teal-100":"#d6f1f1","teal-200":"#ace3e3","teal-300":"#7acace","teal-400":"#4faab2","teal-500":"#358f97","teal-600":"#287179","teal-700":"#22555c","teal-800":"#21484e","teal-900":"#1f3d42","teal-950":"#0d2126","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"},R4={colors:Hr,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 ${Hr["dark-100"]}`,medium:`0 .125rem .625rem ${Hr["dark-100"]}`,large:`0 .25rem 1rem ${Hr["dark-50"]}`,xl:`.25rem .25rem 1rem ${Hr["dark-250"]}`,xxl:`0 .25rem 2rem ${Hr["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${Hr["dark-250"]}`,toolbar:`0 -.625rem .625rem ${Hr["dark-50"]}`,text:`0 0 .25rem ${Hr["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:Hr["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Hp=FE.flatten(R4,{delimiter:"-"}),L4=Object.keys(Hp).map(r=>so(`:host { --${r}: ${Hp[r]}; }`)),Rt=(r=>{class e extends r{firstUpdated(){_4().forEach(({load:n,font:a})=>{document.fonts.add(a),n&&a.load()})}}return e.styles=[(r==null?void 0:r.styles)??[],L4,ai`
209
+ :host {
210
+ font-family: var(--fontFamilies-sans);
211
+ font-size: var(--fontSizes-medium);
212
+ line-height: var(--lineHeights-medium);
213
+ font-weight: var(--fontWeights-regular);
214
+ }
215
+ `,ai`
216
+ *,
217
+ *::before,
218
+ *::after,
219
+ ::slotted(*) {
220
+ box-sizing: border-box;
221
+ }
222
+
223
+ body,
224
+ h1,
225
+ h2,
226
+ h3,
227
+ h4,
228
+ p,
229
+ figure,
230
+ blockquote,
231
+ dl,
232
+ dd,
233
+ ::slotted(h1),
234
+ ::slotted(h2),
235
+ ::slotted(h3),
236
+ ::slotted(h4),
237
+ ::slotted(p),
238
+ ::slotted(figure),
239
+ ::slotted(blockquote),
240
+ ::slotted(dl),
241
+ ::slotted(dd) {
242
+ margin: 0;
243
+ }
244
+
245
+ ul[role='list'],
246
+ ol[role='list'],
247
+ ::slotted(ul[role='list']),
248
+ ::slotted(ol[role='list']) {
249
+ list-style: none;
250
+ }
251
+
252
+ a:not([class]),
253
+ ::slotted(a:not([class])) {
254
+ text-decoration-skip-ink: auto;
255
+ }
256
+
257
+ img,
258
+ picture,
259
+ ::slotted(img),
260
+ ::slotted(picture) {
261
+ max-width: 100%;
262
+ display: block;
263
+ }
264
+
265
+ input,
266
+ button,
267
+ textarea,
268
+ select,
269
+ ::slotted(input),
270
+ ::slotted(button),
271
+ ::slotted(textarea),
272
+ ::slotted(select) {
273
+ font: inherit;
274
+ }
275
+
276
+ @media (prefers-reduced-motion) {
277
+ *,
278
+ *::before,
279
+ *::after,
280
+ ::slotted(*),
281
+ ::slotted(*::before),
282
+ ::slotted(*::after) {
283
+ animation-duration: 0.01ms !important;
284
+ animation-iteration-count: 1 !important;
285
+ transition-duration: 0.01ms !important;
286
+ scroll-behavior: auto !important;
287
+ }
288
+ }
289
+ `],e})(is),C4=(r,e)=>(typeof window<"u"&&(window.customElements.get(r)??window.customElements.define(r,e)),e),I4=(r,e)=>{const{kind:t,elements:i}=e;return{kind:t,elements:i,finisher(n){typeof window<"u"&&(window.customElements.get(r)??window.customElements.define(r,n))}}},Gi=r=>e=>typeof e=="function"?C4(r,e):I4(r,e);class D4{constructor(e){this._memoKey=null,this._lastDeps=null,this._scenes=null,this._video=null,this._handleSeeked=()=>{this.host._draw()},this._resolveVideo=Rs(async t=>{const i=await Du(t);return i.node.play=async()=>{},i.node.addEventListener("seeked",this._handleSeeked),i},{cacheKey:([{id:t,src:i,playlist:n}])=>JSON.stringify({id:t,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0]})}),this._resolveAnswer=Rs(async t=>{const{id:i,key:n,poster:a}=t,{node:l}=await Du(t),h=new Image;return{id:i,key:n,config:t,node:l,getSource:()=>(a&&h.src!==a&&(h.onload=()=>{this.host._draw()},h.src=a),h)}},{cacheKey:([{id:t,src:i,playlist:n,poster:a}])=>JSON.stringify({id:t,src:i==null?void 0:i.split("?")[0],playlist:n==null?void 0:n.split("?")[0],poster:a==null?void 0:a.split("?")[0]})}),this._resolveVideoMeta=Rs(async(t,i)=>{const{id:n,duration:a,startOffset:l,endOffset:h}=t,f=a??await Gp(i),p=(l??0)*f,m=(1-(h??0))*f;return{id:n,start:p,duration:m-p}},{cacheKey:([{id:t,duration:i,startOffset:n,endOffset:a}])=>JSON.stringify({id:t,duration:i,startOffset:n,endOffset:a})}),this.host=e,this.host.addController(this)}set scenes(e){e!==this._scenes&&(this._scenes=e,this.host.requestUpdate())}get scenes(){return this._scenes}_setupTask(){new pa(this.host,async([e,t,i])=>{var n,a;try{if(e){const l=e.includes(".m3u8")?"playlist":"video";try{this.scenes=await _n({data:{questions:{items:[{answer:{id:"source",media:{[l]:e}}}]}},template:i},this._resolveVideo,this._resolveVideoMeta)}catch(h){throw new Vr("Video preview source template error",h)}this._video=((a=(n=this.scenes.scenes[0])==null?void 0:n.video)==null?void 0:a.node)??null}else if(t)try{this.scenes=await _n({data:t,template:i},this._resolveAnswer,this._resolveVideoMeta)}catch(l){throw new Vr("Video preview data template error",l)}}catch(l){this.scenes=null,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:l,message:l.message}))}},()=>{const e=JSON.stringify({data:this.host.data,template:this.host.template});if(this._lastDeps&&this._memoKey===e)return this._lastDeps;const t=[this.host.src,this.host.data,this.host.template];return this._memoKey=e,this._lastDeps=t,t})}hostConnected(){this._setupTask()}hostDisconnected(){this._video&&(this._video.pause(),this._video.removeEventListener("seeked",this._handleSeeked),this._video.src="",this._video=null)}}function Wp(r,e,t){return Math.min(Math.max(e,r),t)}function $u(r,e={}){const t=Math.max(0,r||0),i=Math.floor(t/3600),n=Math.floor(t%3600/60),a=Math.floor(t%3600%60),l=Math.floor(t%1*1e3);let h=i?`${i}:${`${n}`.padStart(2,"0")}:${`${a}`.padStart(2,"0")}`:`${n}:${`${a}`.padStart(2,"0")}`;return e.includeMs&&(h+=`:${`${l}`.padStart(3,"0")}`),h}var O4=Object.defineProperty,P4=Object.getOwnPropertyDescriptor,Un=(r,e,t,i)=>{for(var n=i>1?void 0:i?P4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&O4(e,t,n),n};let Os=class extends Rt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Qe`<button
290
+ class=${Mt({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
+ >
292
+ <slot></slot>
293
+ ${this.icon&&Qe`<vmp-icon icon=${this.icon}></vmp-icon>`}
294
+ </button>`}};Os.styles=[Rt.styles??[],ai`
295
+ :host {
296
+ --button-padding: var(--vu-button-padding, var(--space-s));
297
+ --button-color: var(--vu-button-color, var(--colors-dark-640));
298
+ --button-background: var(--vu-button-background, var(--colors-light-1000));
299
+ --button-background-hover: var(--vu-button-background-hover, var(--colors-light-1000));
300
+
301
+ display: block;
302
+ }
303
+
304
+ button {
305
+ position: relative;
306
+ display: flex;
307
+ align-items: center;
308
+ justify-content: center;
309
+ gap: var(--space-xxs);
310
+ border: none;
311
+ cursor: pointer;
312
+ font-weight: var(--fontWeights-semibold);
313
+ pointer-events: all;
314
+ transition: background 150ms ease;
315
+
316
+ padding: var(--button-padding);
317
+ color: var(--button-color);
318
+ background: var(--button-background);
319
+ padding: var(--button-padding);
320
+ }
321
+
322
+ button:focus {
323
+ outline: var(--borderWidths-thin) solid var(--colors-dark-1000);
324
+ }
325
+
326
+ .size-tiny {
327
+ --button-padding: var(--vu-button-padding, var(--space-xxs));
328
+ min-width: 20px;
329
+ }
330
+
331
+ .size-small {
332
+ --button-padding: var(--vu-button-padding, 6px);
333
+ min-width: 32px;
334
+ }
335
+
336
+ .size-large {
337
+ --button-padding: var(--vu-button-padding, var(--space-small));
338
+ min-width: 48px;
339
+ }
340
+
341
+ .radius-medium {
342
+ border-radius: var(--radii-small);
343
+ }
344
+
345
+ .radius-full {
346
+ border-radius: 100rem;
347
+ }
348
+
349
+ .weight-light {
350
+ --button-color: var(--vu-button-color, var(--colors-light-1000));
351
+ --button-background: var(--vu-button-background, transparent);
352
+ }
353
+
354
+ .weight-heavy {
355
+ --button-color: var(--vu-button-color, var(--colors-dark-640));
356
+ --button-background: var(--vu-button-background, var(--colors-light-1000));
357
+ }
358
+
359
+ .weight-heavy.active,
360
+ .weight-heavy:hover,
361
+ .weight-heavy:focus {
362
+ --button-background: var(--vu-button-background-hover, #cccccc);
363
+ }
364
+
365
+ .weight-light.active,
366
+ .weight-light:hover,
367
+ .weight-light:focus {
368
+ --button-background: var(--vu-button-background-hover, #9d9d9d);
369
+ }
370
+ `],Un([be({type:Boolean})],Os.prototype,"active",2),Un([be({type:String})],Os.prototype,"size",2),Un([be({type:String})],Os.prototype,"rounded",2),Un([be({type:String})],Os.prototype,"weight",2),Un([be({type:String})],Os.prototype,"icon",2),Os=Un([Gi("vmp-button")],Os);const jp={"arrow-left":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
371
+ <path
372
+ d="M16.6666 9.21875H6.52492L11.1833 4.85156L9.99992 3.75L3.33325 10L9.99992 16.25L11.1749 15.1484L6.52492 10.7812H16.6666V9.21875Z"
373
+ fill="currentColor"
374
+ />
375
+ </svg>`,"arrow-right":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
376
+ <path
377
+ d="M3.75 9.21875H13.2578L8.89062 4.85156L10 3.75L16.25 10L10 16.25L8.89844 15.1484L13.2578 10.7812H3.75V9.21875Z"
378
+ fill="currentColor"
379
+ />
380
+ </svg>`,"captions-cross":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
381
+ <path
382
+ d="M17.0625 19.4167L14.3125 16.6667H3.33333C2.875 16.6667 2.4825 16.5036 2.15583 16.1775C1.82972 15.8509 1.66667 15.4584 1.66667 15V4.16669C1.66667 4.13891 1.66667 4.11446 1.66667 4.09335C1.66667 4.0728 1.66667 4.04863 1.66667 4.02085L0.5625 2.91669L1.75 1.72919L18.25 18.2292L17.0625 19.4167ZM18.3333 15.9375L14.7083 12.3125C14.8056 12.2431 14.8786 12.1495 14.9275 12.0317C14.9758 11.9134 15 11.7917 15 11.6667V10.8334H13.75V11.25H13.6458L12.0833 9.68752V8.75002H13.75V9.16669H15V8.33335C15 8.09724 14.92 7.89919 14.76 7.73919C14.6006 7.57974 14.4028 7.50002 14.1667 7.50002H11.6667C11.4306 7.50002 11.2328 7.57974 11.0733 7.73919C10.9133 7.89919 10.8333 8.09724 10.8333 8.33335V8.43752L5.72917 3.33335H16.6667C17.125 3.33335 17.5175 3.49669 17.8442 3.82335C18.1703 4.14946 18.3333 4.54169 18.3333 5.00002V15.9375ZM5.83333 12.5H8.33333C8.56944 12.5 8.7675 12.42 8.9275 12.26C9.08694 12.1006 9.16667 11.9028 9.16667 11.6667V11.5209L8.47917 10.8334H7.91667V11.25H6.25V8.60419L5.3125 7.66669C5.21528 7.73613 5.13889 7.82974 5.08333 7.94752C5.02778 8.06585 5 8.19446 5 8.33335V11.6667C5 11.9028 5.07972 12.1006 5.23917 12.26C5.39917 12.42 5.59722 12.5 5.83333 12.5Z"
383
+ fill="currentColor"
384
+ />
385
+ </svg>`,captions:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
386
+ <path
387
+ d="M5.83342 12.5H8.33342C8.56953 12.5 8.76758 12.42 8.92758 12.26C9.08703 12.1005 9.16675 11.9028 9.16675 11.6666V10.8333H7.91675V11.25H6.25008V8.74998H7.91675V9.16665H9.16675V8.33331C9.16675 8.0972 9.08703 7.89915 8.92758 7.73915C8.76758 7.5797 8.56953 7.49998 8.33342 7.49998H5.83342C5.5973 7.49998 5.39925 7.5797 5.23925 7.73915C5.0798 7.89915 5.00008 8.0972 5.00008 8.33331V11.6666C5.00008 11.9028 5.0798 12.1005 5.23925 12.26C5.39925 12.42 5.5973 12.5 5.83342 12.5ZM11.6667 12.5H14.1667C14.4029 12.5 14.6006 12.42 14.7601 12.26C14.9201 12.1005 15.0001 11.9028 15.0001 11.6666V10.8333H13.7501V11.25H12.0834V8.74998H13.7501V9.16665H15.0001V8.33331C15.0001 8.0972 14.9201 7.89915 14.7601 7.73915C14.6006 7.5797 14.4029 7.49998 14.1667 7.49998H11.6667C11.4306 7.49998 11.2329 7.5797 11.0734 7.73915C10.9134 7.89915 10.8334 8.0972 10.8334 8.33331V11.6666C10.8334 11.9028 10.9134 12.1005 11.0734 12.26C11.2329 12.42 11.4306 12.5 11.6667 12.5ZM3.33341 16.6666C2.87508 16.6666 2.48258 16.5036 2.15591 16.1775C1.8298 15.8508 1.66675 15.4583 1.66675 15V4.99998C1.66675 4.54165 1.8298 4.14942 2.15591 3.82331C2.48258 3.49665 2.87508 3.33331 3.33341 3.33331H16.6667C17.1251 3.33331 17.5176 3.49665 17.8442 3.82331C18.1704 4.14942 18.3334 4.54165 18.3334 4.99998V15C18.3334 15.4583 18.1704 15.8508 17.8442 16.1775C17.5176 16.5036 17.1251 16.6666 16.6667 16.6666H3.33341Z"
388
+ fill="currentColor"
389
+ />
390
+ </svg>`,"chevron-down":()=>Qe`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" part="svg">
391
+ <path
392
+ d="M11.8032 7.13666L10.8632 6.19666L7.80322 9.24999L4.74322 6.19666L3.80322 7.13666L7.80322 11.1367L11.8032 7.13666Z"
393
+ fill="currentColor"
394
+ />
395
+ </svg>`,close:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
396
+ <path
397
+ d="M15.8334 5.34163L14.6584 4.16663L10 8.82496L5.34169 4.16663L4.16669 5.34163L8.82502 9.99996L4.16669 14.6583L5.34169 15.8333L10 11.175L14.6584 15.8333L15.8334 14.6583L11.175 9.99996L15.8334 5.34163Z"
398
+ fill="currentColor"
399
+ />
400
+ </svg>`,error:()=>Qe`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" part="svg">
401
+ <path
402
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm1 15h-2v-2h2v2Zm0-4h-2V7h2v6Z"
403
+ fill="currentColor"
404
+ />
405
+ </svg>`,loading:()=>Qe`<svg class="spinner" width="50" height="50" viewBox="0 0 50 50" part="svg">
406
+ <style>
407
+ /* SVG spinner icon animation */
408
+ .spinner {
409
+ -webkit-animation: rotate 2s linear infinite;
410
+ animation: rotate 2s linear infinite;
411
+ }
412
+
413
+ .spinner .path {
414
+ stroke: currentColor;
415
+ stroke-linecap: round;
416
+ -webkit-animation: dash 1.5s ease-in-out infinite;
417
+ animation: dash 1.5s ease-in-out infinite;
418
+ }
419
+
420
+ @-webkit-keyframes rotate {
421
+ 100% {
422
+ -webkit-transform: rotate(360deg);
423
+ transform: rotate(360deg);
424
+ }
425
+ }
426
+
427
+ @keyframes rotate {
428
+ 100% {
429
+ -webkit-transform: rotate(360deg);
430
+ transform: rotate(360deg);
431
+ }
432
+ }
433
+
434
+ @-webkit-keyframes dash {
435
+ 0% {
436
+ stroke-dasharray: 1, 150;
437
+ stroke-dashoffset: 0;
438
+ }
439
+ 50% {
440
+ stroke-dasharray: 90, 150;
441
+ stroke-dashoffset: -35;
442
+ }
443
+ 100% {
444
+ stroke-dasharray: 90, 150;
445
+ stroke-dashoffset: -124;
446
+ }
447
+ }
448
+
449
+ @keyframes dash {
450
+ 0% {
451
+ stroke-dasharray: 1, 150;
452
+ stroke-dashoffset: 0;
453
+ }
454
+ 50% {
455
+ stroke-dasharray: 90, 150;
456
+ stroke-dashoffset: -35;
457
+ }
458
+ 100% {
459
+ stroke-dasharray: 90, 150;
460
+ stroke-dashoffset: -124;
461
+ }
462
+ }
463
+ </style>
464
+ <circle class="path" cx="25" cy="25" r="20" fill="none" stroke-width="5" />
465
+ </svg>`,maximize:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
466
+ <path
467
+ fill-rule="evenodd"
468
+ clip-rule="evenodd"
469
+ d="M6.66675 3.33331H3.33341H1.66675V4.99998V8.33331H3.33341V4.99998H6.66675V3.33331ZM6.66675 15H3.33341V11.6666H1.66675V15V16.6666H3.33341H6.66675V15ZM13.3334 3.33331H16.6667H18.3334V4.99998V8.33331H16.6667V4.99998H13.3334V3.33331ZM16.6667 15H13.3334V16.6666H16.6667H18.3334V15V11.6666H16.6667V15Z"
470
+ fill="currentColor"
471
+ />
472
+ </svg>`,minimize:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
473
+ <path
474
+ fill-rule="evenodd"
475
+ clip-rule="evenodd"
476
+ d="M5.00008 3.33331H6.66675V6.66665V8.33331H5.00008H1.66675V6.66665H5.00008V3.33331ZM5.00008 11.6666H1.66675V13.3333H5.00008V16.6666H6.66675V13.3333V11.6666H5.00008ZM15.0001 6.66665H18.3334V8.33331H15.0001H13.3334V6.66665V3.33331H15.0001V6.66665ZM18.3334 11.6666H15.0001H13.3334V13.3333V16.6666H15.0001V13.3333H18.3334V11.6666Z"
477
+ fill="currentColor"
478
+ />
479
+ </svg>`,muted:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
480
+ <path
481
+ d="M13.75 10C13.75 8.525 12.9 7.25833 11.6667 6.64167V8.48333L13.7083 10.525C13.7333 10.3583 13.75 10.1833 13.75 10ZM15.8333 10C15.8333 10.7833 15.6667 11.5167 15.3833 12.2L16.6417 13.4583C17.1917 12.425 17.5 11.25 17.5 10C17.5 6.43333 15.0083 3.45 11.6667 2.69167V4.40833C14.075 5.125 15.8333 7.35833 15.8333 10ZM3.55833 2.5L2.5 3.55833L6.44167 7.5H2.5V12.5H5.83333L10 16.6667V11.0583L13.5417 14.6C12.9833 15.0333 12.3583 15.375 11.6667 15.5833V17.3C12.8167 17.0417 13.8583 16.5083 14.7417 15.7917L16.4417 17.5L17.5 16.4417L10 8.94167L3.55833 2.5ZM10 3.33333L8.25833 5.075L10 6.81667V3.33333Z"
482
+ fill="currentColor"
483
+ />
484
+ </svg>`,pause:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
485
+ <path
486
+ fill-rule="evenodd"
487
+ clip-rule="evenodd"
488
+ d="M8.33333 2.5H5V17.5H8.33333V2.5ZM15 2.5H11.6667V17.5H15V2.5Z"
489
+ fill="currentColor"
490
+ />
491
+ </svg>`,"play-large":()=>Qe`<svg width="45" height="53" viewBox="0 0 45 53" fill="none" part="svg">
492
+ <path
493
+ d="M43.5 23.8319C45.5 25.0083 45.5 27.9492 43.5 29.1256L4.5 52.0647C2.5 53.2411 0 51.7706 0 49.4179V3.53961C0 1.18687 2.5 -0.283582 4.5 0.892785L43.5 23.8319Z"
494
+ fill="currentColor"
495
+ />
496
+ </svg>`,play:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
497
+ <path d="M17.3803 9.99998L5.83325 16.6666V3.33331L17.3803 9.99998Z" fill="currentColor" />
498
+ </svg>`,settings:()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
499
+ <path
500
+ d="M7.70833 18.3334L7.375 15.6667C7.19445 15.5972 7.02444 15.5139 6.865 15.4167C6.705 15.3195 6.54861 15.2153 6.39583 15.1042L3.91667 16.1459L1.625 12.1875L3.77083 10.5625C3.75694 10.4653 3.75 10.3714 3.75 10.2809C3.75 10.1909 3.75 10.0972 3.75 10C3.75 9.9028 3.75 9.80891 3.75 9.71835C3.75 9.62835 3.75694 9.53474 3.77083 9.43752L1.625 7.81252L3.91667 3.85419L6.39583 4.89585C6.54861 4.78474 6.70833 4.68058 6.875 4.58335C7.04167 4.48613 7.20833 4.4028 7.375 4.33335L7.70833 1.66669H12.2917L12.625 4.33335C12.8056 4.4028 12.9758 4.48613 13.1358 4.58335C13.2953 4.68058 13.4514 4.78474 13.6042 4.89585L16.0833 3.85419L18.375 7.81252L16.2292 9.43752C16.2431 9.53474 16.25 9.62835 16.25 9.71835C16.25 9.80891 16.25 9.9028 16.25 10C16.25 10.0972 16.25 10.1909 16.25 10.2809C16.25 10.3714 16.2361 10.4653 16.2083 10.5625L18.3542 12.1875L16.0625 16.1459L13.6042 15.1042C13.4514 15.2153 13.2917 15.3195 13.125 15.4167C12.9583 15.5139 12.7917 15.5972 12.625 15.6667L12.2917 18.3334H7.70833ZM10.0417 12.9167C10.8472 12.9167 11.5347 12.632 12.1042 12.0625C12.6736 11.4931 12.9583 10.8056 12.9583 10C12.9583 9.19447 12.6736 8.50696 12.1042 7.93752C11.5347 7.36808 10.8472 7.08335 10.0417 7.08335C9.22222 7.08335 8.53111 7.36808 7.96833 7.93752C7.40611 8.50696 7.125 9.19447 7.125 10C7.125 10.8056 7.40611 11.4931 7.96833 12.0625C8.53111 12.632 9.22222 12.9167 10.0417 12.9167ZM10.0417 11.25C9.69445 11.25 9.39945 11.1284 9.15667 10.885C8.91333 10.6422 8.79167 10.3472 8.79167 10C8.79167 9.6528 8.91333 9.3578 9.15667 9.11502C9.39945 8.87169 9.69445 8.75002 10.0417 8.75002C10.3889 8.75002 10.6842 8.87169 10.9275 9.11502C11.1703 9.3578 11.2917 9.6528 11.2917 10C11.2917 10.3472 11.1703 10.6422 10.9275 10.885C10.6842 11.1284 10.3889 11.25 10.0417 11.25ZM9.16667 16.6667H10.8125L11.1042 14.4584C11.5347 14.3472 11.9342 14.1839 12.3025 13.9684C12.6703 13.7534 13.0069 13.4931 13.3125 13.1875L15.375 14.0417L16.1875 12.625L14.3958 11.2709C14.4653 11.0764 14.5139 10.8714 14.5417 10.6559C14.5694 10.4409 14.5833 10.2222 14.5833 10C14.5833 9.7778 14.5694 9.55891 14.5417 9.34335C14.5139 9.12835 14.4653 8.92363 14.3958 8.72919L16.1875 7.37502L15.375 5.95835L13.3125 6.83335C13.0069 6.51391 12.6703 6.24641 12.3025 6.03085C11.9342 5.81585 11.5347 5.6528 11.1042 5.54169L10.8333 3.33335H9.1875L8.89583 5.54169C8.46528 5.6528 8.06611 5.81585 7.69833 6.03085C7.33 6.24641 6.99306 6.50697 6.6875 6.81252L4.625 5.95835L3.8125 7.37502L5.60417 8.70835C5.53472 8.91669 5.48611 9.12502 5.45833 9.33335C5.43056 9.54169 5.41667 9.76391 5.41667 10C5.41667 10.2222 5.43056 10.4375 5.45833 10.6459C5.48611 10.8542 5.53472 11.0625 5.60417 11.2709L3.8125 12.625L4.625 14.0417L6.6875 13.1667C6.99306 13.4861 7.33 13.7534 7.69833 13.9684C8.06611 14.1839 8.46528 14.3472 8.89583 14.4584L9.16667 16.6667Z"
501
+ fill="currentColor"
502
+ />
503
+ </svg>`,tick:()=>Qe`<svg width="20" height="21" viewBox="0 0 20 21" fill="none" part="svg">
504
+ <path
505
+ d="M7.50016 14.0001L4.00016 10.5001L2.8335 11.6667L7.50016 16.3334L17.5002 6.33341L16.3335 5.16675L7.50016 14.0001Z"
506
+ fill="currentColor"
507
+ />
508
+ </svg>`,"volume-high":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
509
+ <path
510
+ d="M2.5 7.49998V12.5H5.83333L10 16.6667V3.33332L5.83333 7.49998H2.5ZM13.75 9.99998C13.75 8.52498 12.9 7.25832 11.6667 6.64165V13.35C12.9 12.7417 13.75 11.475 13.75 9.99998ZM11.6667 2.69165V4.40832C14.075 5.12498 15.8333 7.35832 15.8333 9.99998C15.8333 12.6417 14.075 14.875 11.6667 15.5917V17.3083C15.0083 16.55 17.5 13.5667 17.5 9.99998C17.5 6.43332 15.0083 3.44998 11.6667 2.69165Z"
511
+ fill="currentColor"
512
+ />
513
+ </svg>`,"volume-low":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
514
+ <path d="M5.83325 7.49998V12.5H9.16658L13.3333 16.6666V3.33331L9.16658 7.49998H5.83325Z" fill="currentColor" />
515
+ </svg>`,"volume-medium":()=>Qe`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" part="svg">
516
+ <path
517
+ d="M15.4167 9.99998C15.4167 8.52498 14.5667 7.25831 13.3334 6.64165V13.35C14.5667 12.7416 15.4167 11.475 15.4167 9.99998ZM4.16675 7.49998V12.5H7.50008L11.6667 16.6666V3.33331L7.50008 7.49998H4.16675Z"
518
+ fill="currentColor"
519
+ />
520
+ </svg>`,vouch:()=>Qe`<svg
521
+ xmlns="http://www.w3.org/2000/svg"
522
+ height="28"
523
+ width="105"
524
+ viewBox="0 0 105 28"
525
+ fill="currentColor"
526
+ part="svg"
527
+ >
528
+ <path
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
+ />
531
+ </svg>`};var $4=Object.defineProperty,F4=Object.getOwnPropertyDescriptor,Kp=(r,e,t,i)=>{for(var n=i>1?void 0:i?F4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&$4(e,t,n),n};let dl=class extends Rt{render(){return!this.icon||!Object.keys(jp).includes(this.icon)?null:jp[this.icon]()}};dl.styles=[Rt.styles??[],ai`
532
+ :host {
533
+ display: flex;
534
+ align-items: center;
535
+ justify-content: center;
536
+ flex-shrink: 0;
537
+ }
538
+ `],Kp([be({type:String})],dl.prototype,"icon",2),dl=Kp([Gi("vmp-icon")],dl);var M4=Object.defineProperty,N4=Object.getOwnPropertyDescriptor,Bn=(r,e,t,i)=>{for(var n=i>1?void 0:i?N4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&M4(e,t,n),n};let Ps=class extends Rt{constructor(){super(...arguments),this.active=!1,this.size="small",this.rounded="medium",this.weight="light"}render(){return Qe`
539
+ <vmp-button
540
+ ?active=${this.active}
541
+ size=${li(this.size)}
542
+ rounded=${li(this.rounded)}
543
+ weight=${li(this.weight)}
544
+ >
545
+ <vmp-icon
546
+ class=${Mt({tiny:this.size==="tiny",small:this.size==="small",large:this.size==="large"})}
547
+ icon=${li(this.icon)}
548
+ ></vmp-icon>
549
+ </vmp-button>
550
+ `}};Ps.styles=[Rt.styles??[],ai`
551
+ .tiny::part(svg) {
552
+ height: 12px;
553
+ width: 12px;
554
+ }
555
+
556
+ .small::part(svg) {
557
+ height: 20px;
558
+ width: 20px;
559
+ }
560
+
561
+ .large::part(svg) {
562
+ height: 32px;
563
+ width: 32px;
564
+ }
565
+ `],Bn([be({type:Boolean})],Ps.prototype,"active",2),Bn([be({type:String})],Ps.prototype,"size",2),Bn([be({type:String})],Ps.prototype,"rounded",2),Bn([be({type:String})],Ps.prototype,"weight",2),Bn([be({type:String})],Ps.prototype,"icon",2),Ps=Bn([Gi("vmp-icon-button")],Ps);var U4=Object.defineProperty,B4=Object.getOwnPropertyDescriptor,er=(r,e,t,i)=>{for(var n=i>1?void 0:i?B4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&U4(e,t,n),n};let us=class extends Rt{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=gc,this._currentTime=0,this._sceneController=new D4(this),this._canvasRef=ki(),this._previewRef=ki(),this._previewTimeRef=ki(),this._handleScrubberMouseEnter=({detail:{x:r,y:e,elementLeft:t,elementRight:i}})=>{var n,a;if((n=this._previewRef)!=null&&n.value){const l=this._previewRef.value.getBoundingClientRect(),h=(a=this._previewRef.value.getRootNode().host)==null?void 0:a.getBoundingClientRect();l&&h&&(this._previewRef.value.style.opacity="1",this._previewRef.value.style.transform=`translate3d(${Wp(t-h.left,r-h.left-l.width/2,i-h.left-l.width)}px, ${e-h.top-l.height-28}px, 0)`)}},this._handleScrubberMouseMove=({detail:{time:r,x:e,elementLeft:t,elementRight:i}})=>{var n,a,l,h,f,p,m,g;if(this._currentTime=r,(n=this._sceneController.scenes)!=null&&n.scenes.length){const A=(f=(h=(l=(a=this._sceneController.scenes)==null?void 0:a.scenes)==null?void 0:l.find(({start:b,duration:x,video:k})=>k&&r>=b&&r<=b+x))==null?void 0:h.video)==null?void 0:f.node;if(A&&(A.currentTime=r),this._draw(),(p=this._previewRef)!=null&&p.value){const b=this._previewRef.value.getBoundingClientRect(),x=(m=this._previewRef.value.getRootNode().host)==null?void 0:m.getBoundingClientRect();if(b&&x){const k=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[,w]=Array.from(k.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${Wp(t-x.left,e-x.left-b.width/2,i-x.left-b.width)}px, ${w[1]}px, 0)`}}this._previewTimeRef.value&&this._previewTimeRef.value.setAttribute("content",$u(Math.max(0,Math.min(this._currentTime,(g=this._sceneController.scenes)==null?void 0:g.duration))))}},this._handleScrubberMouseLeave=()=>{var r;(r=this._previewRef)!=null&&r.value&&(this._previewRef.value.style.opacity="0")},this._handleScrubberResize=({detail:{y:r}})=>{var e,t;if((e=this._previewRef)!=null&&e.value){const i=this._previewRef.value.getBoundingClientRect(),n=(t=this._previewRef.value.getRootNode().host)==null?void 0:t.getBoundingClientRect();if(i&&n){const a=this._previewRef.value.style.transform||"translate3d(0px, 0px, 0px)",[l]=Array.from(a.matchAll(/([+-]?([0-9]*[.])?[0-9]+)(?=px)\w+/g));this._previewRef.value.style.transform=`translate3d(${l[1]}px, ${r-n.top-i.height-28}px, 0)`}}}}_draw(r=this._currentTime){var e,t;this._sceneController.scenes&&this._canvasRef.value&&((t=this.compilation)==null||t.call(this,{currentTime:Math.max(0,Math.min(r,(e=this._sceneController.scenes)==null?void 0:e.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 r;const{height:e,width:t}=vc({resolution:180,aspectRatio:this.aspectRatio}),i=((r=this._sceneController.scenes)==null?void 0:r.scenes.length)??0;return!this.disabled&&(this.src||i>1)?Qe`
566
+ <div
567
+ ${Si(this._previewRef)}
568
+ class="preview"
569
+ style=${_o({width:this.aspectRatio>1?"140px":void 0,height:this.aspectRatio<=1?"140px":void 0,aspectRatio:this.aspectRatio})}
570
+ >
571
+ <canvas ${Si(this._canvasRef)} class="preview-canvas" width=${t} height=${e}></canvas>
572
+ <vmp-text ${Si(this._previewTimeRef)} class="preview-text" size="small"></vmp-text>
573
+ </div>
574
+ `:null}};us.styles=[Rt.styles??[],ai`
575
+ .preview {
576
+ position: absolute;
577
+ display: flex;
578
+ top: 0;
579
+ left: 0;
580
+ align-items: center;
581
+ flex-direction: column;
582
+ opacity: 0;
583
+ // Always on top
584
+ z-index: 2147483647;
585
+ pointer-events: none;
586
+ border: 3px solid var(--colors-light-1000);
587
+ background: var(--colors-dark-1000);
588
+ border-radius: var(--radii-medium);
589
+ transition: opacity 150ms ease-out;
590
+ }
591
+
592
+ .preview-canvas {
593
+ width: 100%;
594
+ height: 100%;
595
+ border-radius: var(--radii-small);
596
+ }
597
+
598
+ .preview-text {
599
+ position: absolute;
600
+ bottom: 0;
601
+ transform: translate3d(0, calc(100% + 9px), 0);
602
+ color: var(--colors-light-1000);
603
+ font-variant-numeric: tabular-nums;
604
+ }
605
+ `],er([be({type:String})],us.prototype,"src",2),er([be({type:Object})],us.prototype,"data",2),er([be({type:Object})],us.prototype,"template",2),er([be({type:Boolean})],us.prototype,"disabled",2),er([be({type:Number})],us.prototype,"aspectRatio",2),er([be({attribute:!1})],us.prototype,"compilation",2),us=er([Gi("vmp-video-preview-content")],us);let $s=class extends Rt{constructor(){super(...arguments),this.disabled=!1,this.aspectRatio=1,this.compilation=gc}render(){return Qe`
606
+ <vmp-video-preview-content
607
+ ?disabled=${this.disabled}
608
+ .src=${this.src}
609
+ .data=${this.data}
610
+ .template=${this.template}
611
+ .aspectRatio=${this.aspectRatio}
612
+ .compilation=${this.compilation}
613
+ ></vmp-video-preview-content>
614
+ `}};er([be({type:String})],$s.prototype,"src",2),er([be({type:Object})],$s.prototype,"data",2),er([be({type:Object})],$s.prototype,"template",2),er([be({type:Boolean})],$s.prototype,"disabled",2),er([be({type:Number})],$s.prototype,"aspectRatio",2),er([be({attribute:!1})],$s.prototype,"compilation",2),$s=er([Gi("vmp-video-preview")],$s);class G4 extends po{constructor(e){if(super(e),e.type!==Sn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}update(e,[t]){return t==null||t(e.element),Ts}}const zp=wn(G4);class V4{constructor(e){this.hiddenControls=[],this._measureRef=ki(),this._prevControlsWidth=0,this._hideables={},this._showables={},this._onResize=t=>{var i,n,a;const l=this._measureRef.value,h=(a=(n=(i=t==null?void 0:t[0])==null?void 0:i.borderBoxSize)==null?void 0:n[0])==null?void 0:a.inlineSize;if(l&&h&&h!==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(;l.scrollWidth>l.offsetWidth;){const p=Object.keys(this._hideables).find(g=>this._hideables[g].hideIndex===f.length);if(!p)break;const m=this._hideables[p].element;m&&(m.style.display="none"),f.push(p),Object.keys(this._showables).forEach(g=>{this._showables[g].showOn.some(A=>f.includes(A))&&(this._showables[g].element.style.display="flex")})}this.hiddenControls=f,this._prevControlsWidth=h,this.host.requestUpdate()}},this.host=e}measure(){return Si(this._measureRef)}contain(){return Pu(this._onResize)}hide(e,t){return zp(i=>{this._hideables[e]={element:i,hideIndex:t}})}show(e,t){return zp(i=>{this._showables[e]={element:i,showOn:t}})}}const Fu=".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:translateX(5px)}.tippy-box[data-animation=shift-away-subtle][data-state=hidden][data-placement^=right]{transform:translateX(-5px)}";var H4=Object.defineProperty,W4=Object.getOwnPropertyDescriptor,Wo=(r,e,t,i)=>{for(var n=i>1?void 0:i?W4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&H4(e,t,n),n};let vn=class extends Rt{constructor(){super(...arguments),this.semibold=!1,this.truncate=!1,this.size="medium",this.content=""}render(){return Qe`
615
+ <div
616
+ part="content"
617
+ class=${Mt({semibold:this.semibold,truncate:this.truncate,[this.size]:!0})}
618
+ style=${_o({fontFamily:Oa({text:this.content,font:"var(--fontFamilies-sans)"})})}
619
+ >
620
+ ${this.content}
621
+ </div>
622
+ `}};vn.styles=[Rt.styles??[],ai`
623
+ :host {
624
+ --text-size: var(--fontSizes-medium);
625
+ --text-line-height: var(--lineHeights-medium);
626
+ --text-weight: var(--fontWeights-regular);
627
+ }
628
+
629
+ div {
630
+ font-size: var(--text-size);
631
+ line-height: var(--text-line-height);
632
+ font-weight: var(--text-weight);
633
+ }
634
+
635
+ .small {
636
+ --text-size: var(--fontSizes-small);
637
+ --text-line-height: var(--lineHeights-small);
638
+ }
639
+
640
+ .medium {
641
+ --text-size: var(--fontSizes-medium);
642
+ --text-line-height: var(--lineHeights-medium);
643
+ }
644
+
645
+ .large {
646
+ --text-size: var(--fontSizes-large);
647
+ --text-line-height: var(--lineHeights-large);
648
+ }
649
+
650
+ .semibold {
651
+ --text-weight: var(--fontWeights-semibold);
652
+ }
653
+
654
+ .truncate {
655
+ white-space: nowrap;
656
+ text-overflow: ellipsis;
657
+ overflow: hidden;
658
+ }
659
+ `],Wo([be({type:Boolean})],vn.prototype,"semibold",2),Wo([be({type:Boolean})],vn.prototype,"truncate",2),Wo([be({type:String})],vn.prototype,"size",2),Wo([be({type:String})],vn.prototype,"content",2),vn=Wo([Gi("vmp-text")],vn);var j4=Object.defineProperty,K4=Object.getOwnPropertyDescriptor,jo=(r,e,t,i)=>{for(var n=i>1?void 0:i?K4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&j4(e,t,n),n};let yn=class extends Rt{constructor(){super(...arguments),this.activeItems=[],this.visibleItems=null,this.subItemsActive=null,this.tippy=null,this._contentRef=ki()}_handleBackClick(){this.subItemsActive=null,this.visibleItems=this.items??null}willUpdate(){this.visibleItems=this.visibleItems??this.items??null}updated(){var r,e;const t=(e=(r=this.items)==null?void 0:r.items.find(({id:i})=>this.subItemsActive===i))==null?void 0:e.subItems;this.visibleItems=t??this.items??null,t||(this.subItemsActive=null)}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var r;const e=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"),t=e==null?void 0:e.assignedElements()[0];t&&this._contentRef.value&&(this.tippy=gn(t,{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 r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}render(){var r,e;return Qe`
660
+ <slot></slot>
661
+ <div ${Si(this._contentRef)} class="content">
662
+ <div class="title">
663
+ ${this.subItemsActive?Qe`
664
+ <button class="back" @click=${this._handleBackClick}>
665
+ <vmp-icon icon="chevron-down"></vmp-icon>
666
+ </button>
667
+ `:null}
668
+ <vmp-text
669
+ ?bold=${!0}
670
+ ?truncate=${!0}
671
+ size="small"
672
+ .content=${((r=this.visibleItems)==null?void 0:r.title)??"Sub Menu"}
673
+ ></vmp-text>
674
+ </div>
675
+ ${sp(((e=this.visibleItems)==null?void 0:e.items)??[],({id:t})=>t,t=>Qe`
676
+ <button
677
+ class="item"
678
+ @click=${()=>{t.subItems&&(this.subItemsActive=t.id,this.visibleItems=t.subItems),t.event&&this.dispatchEvent(new CustomEvent(t.event,{detail:t,bubbles:!0,composed:!0}))}}
679
+ >
680
+ <vmp-text ?semibold=${!0} size="small" content=${t.label}></vmp-text>
681
+ ${t.subItems?Qe`<vmp-icon class="forward" icon="chevron-down"></vmp-icon>`:this.activeItems.includes(t.id)?Qe`<vmp-icon icon="tick"></vmp-icon>`:null}
682
+ </button>
683
+ `)}
684
+ </div>
685
+ `}};yn.styles=[Rt.styles??[],so(Fu),ai`
686
+ :host {
687
+ display: flex;
688
+ }
689
+
690
+ .content {
691
+ display: flex;
692
+ min-width: 140px;
693
+ overflow: hidden;
694
+ flex-direction: column;
695
+ color: var(--colors-dark-1000);
696
+ background: var(--colors-light-1000);
697
+ border-radius: var(--radii-medium);
698
+ transition: height 150ms ease-out;
699
+ }
700
+
701
+ .back {
702
+ padding: 0;
703
+ margin: 0;
704
+ border: 0;
705
+ cursor: pointer;
706
+ background: transparent;
707
+ color: var(--colors-dark-400);
708
+ /* TODO: Kinda eyeballing this one */
709
+ margin-left: calc(var(--space-xxs) * -1);
710
+ transform: rotate(90deg);
711
+ }
712
+
713
+ .forward {
714
+ transform: rotate(-90deg);
715
+ }
716
+
717
+ .title {
718
+ display: flex;
719
+ align-items: center;
720
+ gap: var(--space-xxs);
721
+ color: var(--colors-dark-400);
722
+ text-transform: uppercase;
723
+ height: 36px;
724
+ padding: var(--space-small) var(--space-small) var(--space-xxs) var(--space-small);
725
+ }
726
+
727
+ .item {
728
+ display: flex;
729
+ align-items: center;
730
+ justify-content: space-between;
731
+ height: 42px;
732
+ border: none;
733
+ cursor: pointer;
734
+ color: var(--colors-dark-1000);
735
+ background: transparent;
736
+ padding: 0 var(--space-small);
737
+ }
738
+
739
+ .item:hover {
740
+ background: var(--colors-dark-100);
741
+ }
742
+
743
+ vmp-icon::part(svg) {
744
+ height: 20px;
745
+ width: 20px;
746
+ }
747
+ `],jo([be({type:Object})],yn.prototype,"items",2),jo([be({type:Array})],yn.prototype,"activeItems",2),jo([mi()],yn.prototype,"visibleItems",2),jo([mi()],yn.prototype,"subItemsActive",2),yn=jo([Gi("vmp-menu")],yn);var z4=Object.defineProperty,Y4=Object.getOwnPropertyDescriptor,Mu=(r,e,t,i)=>{for(var n=i>1?void 0:i?Y4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&z4(e,t,n),n};let Ko=class extends Rt{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=ki()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var r;const e=(r=this.shadowRoot)==null?void 0:r.querySelector("slot"),t=e==null?void 0:e.assignedElements()[0];t&&this._contentRef.value&&(this.tippy=gn(t,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}updated(){var r,e;this.disabled?(r=this.tippy)==null||r.disable():(e=this.tippy)==null||e.enable()}render(){return Qe`
748
+ <slot></slot>
749
+ <div ${Si(this._contentRef)} class="content">
750
+ <vmp-text content=${this.content}></vmp-text>
751
+ </div>
752
+ `}};Ko.styles=[Rt.styles??[],so(Fu),ai`
753
+ :host {
754
+ display: flex;
755
+ }
756
+
757
+ .content {
758
+ display: flex;
759
+ align-items: center;
760
+ justify-content: center;
761
+ padding: var(--space-small);
762
+ color: var(--colors-light-1000);
763
+ background: var(--colors-dark-800);
764
+ border-radius: var(--radii-medium);
765
+ }
766
+ `],Mu([be({type:String})],Ko.prototype,"content",2),Mu([be({type:Boolean})],Ko.prototype,"disabled",2),Ko=Mu([Gi("vmp-tooltip")],Ko);var X4=Object.defineProperty,Z4=Object.getOwnPropertyDescriptor,Nu=(r,e,t,i)=>{for(var n=i>1?void 0:i?Z4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&X4(e,t,n),n};let zo=class extends Rt{constructor(){super(...arguments),this.volume=1,this.muted=!1,this.tippy=null,this._contentRef=ki(),this._anchorRef=ki(),this._menuOpen=!1}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{this._anchorRef.value&&this._contentRef.value&&(this.tippy=gn(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 r;super.disconnectedCallback(),(r=this.tippy)==null||r.destroy()}render(){return Qe`
767
+ <vmp-icon-button
768
+ ${Si(this._anchorRef)}
769
+ icon=${this.muted||this.volume===0?"muted":this.volume<1/3?"volume-low":this.volume<2/3?"volume-medium":"volume-high"}
770
+ weight="heavy"
771
+ rounded="full"
772
+ @pointerdown=${r=>{this._menuOpen&&r.preventDefault()}}
773
+ @click=${()=>{this._menuOpen&&this.dispatchEvent(new CustomEvent("volume:click",{bubbles:!0,composed:!0,detail:this.muted}))}}
774
+ ></vmp-icon-button>
775
+ <div ${Si(this._contentRef)} class="content">
776
+ <input
777
+ key="volume"
778
+ type="range"
779
+ min="0"
780
+ max="1"
781
+ step="0.01"
782
+ .value=${this.volume.toString()}
783
+ @blur=${()=>{var r;return(r=this.tippy)==null?void 0:r.hide()}}
784
+ />
785
+ </div>
786
+ `}};zo.styles=[Rt.styles??[],so(Fu),ai`
787
+ .content {
788
+ --volume-slider-height: 4px;
789
+ --volume-slider-width: 78px;
790
+
791
+ display: flex;
792
+ height: var(--volume-slider-width);
793
+ width: var(--volume-slider-height);
794
+ }
795
+
796
+ .spacer {
797
+ display: flex;
798
+ height: var(--volume-slider-width);
799
+ width: var(--volume-slider-height);
800
+ }
801
+
802
+ input {
803
+ position: absolute;
804
+ appearance: none !important;
805
+ height: var(--volume-slider-height);
806
+ width: var(--volume-slider-width);
807
+ overflow: hidden;
808
+ border-radius: 1000rem;
809
+ cursor: pointer;
810
+ background: var(--colors-light-200);
811
+ rotate: -90deg;
812
+ /* Minus the input margin */
813
+ translate: 0 calc(var(--volume-slider-width) - 4px);
814
+ transform-origin: left;
815
+ transition: height 100ms ease-out, transform 100ms ease-out;
816
+ }
817
+
818
+ input:hover {
819
+ height: calc(var(--volume-slider-height) * 2);
820
+ }
821
+
822
+ input::-webkit-slider-runnable-track {
823
+ appearance: none !important;
824
+ height: var(--volume-slider-height);
825
+ color: var(--colors-light-1000);
826
+ transition: height 100ms ease-out;
827
+ }
828
+
829
+ input::-moz-range-track {
830
+ appearance: none !important;
831
+ height: var(--volume-slider-height);
832
+ color: var(--colors-light-1000);
833
+ transition: height 100ms ease-out;
834
+ }
835
+
836
+ input::-ms-track {
837
+ appearance: none !important;
838
+ height: var(--volume-slider-height);
839
+ color: var(--colors-light-1000);
840
+ transition: height 100ms ease-out;
841
+ }
842
+
843
+ input:hover::-webkit-slider-runnable-track {
844
+ height: calc(var(--volume-slider-height) * 2);
845
+ }
846
+
847
+ input:hover::-moz-range-track {
848
+ height: calc(var(--volume-slider-height) * 2);
849
+ }
850
+
851
+ input:hover::-ms-track {
852
+ height: calc(var(--volume-slider-height) * 2);
853
+ }
854
+
855
+ input::-webkit-slider-thumb {
856
+ appearance: none !important;
857
+ height: var(--volume-slider-height) !important;
858
+ width: var(--volume-slider-height) !important;
859
+ color: var(--colors-light-1000);
860
+ border-radius: 50%;
861
+ border: none;
862
+ background: var(--colors-light-1000);
863
+ box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
864
+ var(--volume-slider-width),
865
+ calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
866
+ var(--colors-dark-640);
867
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
868
+ }
869
+
870
+ input::-moz-range-thumb {
871
+ appearance: none !important;
872
+ height: var(--volume-slider-height) !important;
873
+ width: var(--volume-slider-height) !important;
874
+ color: var(--colors-light-1000);
875
+ border-radius: 50%;
876
+ border: none;
877
+ background: var(--colors-light-1000);
878
+ box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
879
+ var(--volume-slider-width),
880
+ calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
881
+ var(--colors-dark-640);
882
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
883
+ }
884
+
885
+ input::-ms-thumb {
886
+ appearance: none !important;
887
+ height: var(--volume-slider-height) !important;
888
+ width: var(--volume-slider-height) !important;
889
+ color: var(--colors-light-1000);
890
+ border-radius: 50%;
891
+ border: none;
892
+ background: var(--colors-light-1000);
893
+ box-shadow: calc((var(--volume-slider-width) + var(--volume-slider-height) / 2) * -1) 0 0
894
+ var(--volume-slider-width),
895
+ calc((var(--volume-slider-width) + var(--volume-slider-height) / 2)) 0 0 var(--volume-slider-width)
896
+ var(--colors-dark-640);
897
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
898
+ }
899
+
900
+ input:hover::-webkit-slider-thumb {
901
+ --volume-slider-height: 8px;
902
+ color: var(--colors-light-800);
903
+ }
904
+
905
+ input:hover::-moz-range-thumb {
906
+ --volume-slider-height: 8px;
907
+ color: var(--colors-light-800);
908
+ }
909
+
910
+ input:hover::-ms-thumb {
911
+ --volume-slider-height: 8px;
912
+ color: var(--colors-light-800);
913
+ }
914
+ `],Nu([be({type:Number})],zo.prototype,"volume",2),Nu([be({type:Boolean})],zo.prototype,"muted",2),zo=Nu([Gi("vmp-volume-button")],zo);var q4=Object.defineProperty,Q4=Object.getOwnPropertyDescriptor,fl=(r,e,t,i)=>{for(var n=i>1?void 0:i?Q4(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&q4(e,t,n),n};let Gn=class extends Rt{constructor(){super(...arguments),this.duration=0,this.currentTime=0,this.buffer=[],this._containerRef=ki(),this._handleContainerResize=()=>{var r;const e=(r=this._containerRef.value)==null?void 0:r.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:resize",{detail:e,bubbles:!0,composed:!0}))},this._handleMouseEnter=r=>{var e;const t=(e=this._containerRef.value)==null?void 0:e.getBoundingClientRect();this.dispatchEvent(new CustomEvent("scrubber:mouseenter",{detail:{x:r.clientX,y:r.clientY,elementLeft:(t==null?void 0:t.left)??0,elementRight:(t==null?void 0:t.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseMove=r=>{var e;const t=(e=this._containerRef.value)==null?void 0:e.getBoundingClientRect(),n=(r.clientX-((t==null?void 0:t.left)??0))/((t==null?void 0:t.width)??1);this.dispatchEvent(new CustomEvent("scrubber:mousemove",{detail:{x:r.clientX,y:r.clientY,time:n*this.duration,elementLeft:(t==null?void 0:t.left)??0,elementRight:(t==null?void 0:t.right)??document.body.offsetWidth},bubbles:!0,composed:!0}))},this._handleMouseLeave=r=>{this.dispatchEvent(new CustomEvent("scrubber:mouseleave",{detail:{x:r.clientX,y:r.clientY},bubbles:!0,composed:!0}))}}render(){var r;const e=((r=this.buffer)==null?void 0:r.sort((t,i)=>t.start<i.start?-1:i.start<t.start?1:0).reduce((t,{start:i,end:n},a)=>{const l=t[a-1],h=Math.floor(i),f=Math.ceil(n);return t.push({id:i,start:Math.max(0,h),end:Math.min(f,100)}),l&&l.end>=i-1&&(t[a].start=l.end),t},[]))??[];return Qe`
915
+ <div
916
+ class="container"
917
+ ${Si(this._containerRef)}
918
+ ${Pu(this._handleContainerResize)}
919
+ @mouseenter=${this._handleMouseEnter}
920
+ @mousemove=${this._handleMouseMove}
921
+ @mouseleave=${this._handleMouseLeave}
922
+ >
923
+ <input
924
+ key="scrubber"
925
+ aria-label="Progress scrubber"
926
+ type="range"
927
+ min="0"
928
+ max=${this.duration}
929
+ step="0.01"
930
+ .value=${this.currentTime.toString()}
931
+ data-testid="scrubber"
932
+ />
933
+ ${sp(e,({id:t})=>t,t=>Qe`
934
+ <div class="buffer" style=${`left: ${t.start}%; width: ${t.end-t.start}%`}></div>
935
+ `)}
936
+ </div>
937
+ `}};Gn.styles=[Rt.styles??[],ai`
938
+ :host {
939
+ --player-scrubber-height: 8px;
940
+ --player-scrubber-shadow-width: 4000px;
941
+
942
+ display: flex;
943
+ }
944
+
945
+ .container {
946
+ position: relative;
947
+ display: flex;
948
+ width: 100%;
949
+ opacity: 1;
950
+ border-radius: 1000rem;
951
+ overflow: hidden;
952
+ transition: opacity 150ms ease-out;
953
+ }
954
+
955
+ input {
956
+ appearance: none !important;
957
+ height: var(--player-scrubber-height);
958
+ width: 100%;
959
+ margin: 0;
960
+ overflow: hidden;
961
+ cursor: pointer;
962
+ background: var(--colors-light-200);
963
+ transition: height 100ms ease-out, transform 100ms ease-out;
964
+ }
965
+
966
+ .buffer {
967
+ position: absolute;
968
+ height: var(--player-scrubber-height);
969
+ width: var(--player-buffered-percentage);
970
+ background: var(--colors-light-400);
971
+ pointer-events: none;
972
+ transition: height 100ms ease-out, width 250ms ease-out, left 250ms ease-out;
973
+ }
974
+
975
+ .container:hover .buffer {
976
+ height: calc(var(--player-scrubber-height) * 2);
977
+ }
978
+
979
+ .container:hover input {
980
+ height: calc(var(--player-scrubber-height) * 2);
981
+ }
982
+
983
+ input::-webkit-slider-runnable-track {
984
+ appearance: none !important;
985
+ height: var(--player-scrubber-height);
986
+ color: var(--colors-light-1000);
987
+ z-index: 2;
988
+ transition: height 100ms ease-out;
989
+ }
990
+
991
+ input::-moz-range-track {
992
+ appearance: none !important;
993
+ height: var(--player-scrubber-height);
994
+ color: var(--colors-light-1000);
995
+ transition: height 100ms ease-out;
996
+ }
997
+
998
+ input::-ms-track {
999
+ appearance: none !important;
1000
+ height: var(--player-scrubber-height);
1001
+ color: var(--colors-light-1000);
1002
+ transition: height 100ms ease-out;
1003
+ }
1004
+
1005
+ .container:hover input::-webkit-slider-runnable-track {
1006
+ height: calc(var(--player-scrubber-height) * 2);
1007
+ }
1008
+
1009
+ .container:hover input::-moz-range-track {
1010
+ height: calc(var(--player-scrubber-height) * 2);
1011
+ }
1012
+
1013
+ .container:hover input::-ms-track {
1014
+ height: calc(var(--player-scrubber-height) * 2);
1015
+ }
1016
+
1017
+ input::-webkit-slider-thumb {
1018
+ appearance: none !important;
1019
+ height: var(--player-scrubber-height) !important;
1020
+ width: var(--player-scrubber-height) !important;
1021
+ color: var(--colors-light-1000);
1022
+ border-radius: 50%;
1023
+ border: none;
1024
+ background: var(--colors-light-1000);
1025
+ box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
1026
+ var(--player-scrubber-shadow-width);
1027
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
1028
+ }
1029
+
1030
+ input::-moz-range-thumb {
1031
+ appearance: none !important;
1032
+ height: var(--player-scrubber-height) !important;
1033
+ width: var(--player-scrubber-height) !important;
1034
+ color: var(--colors-light-1000);
1035
+ border-radius: 50%;
1036
+ border: none;
1037
+ background: var(--colors-light-1000);
1038
+ box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
1039
+ var(--player-scrubber-shadow-width);
1040
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
1041
+ }
1042
+
1043
+ input::-ms-thumb {
1044
+ appearance: none !important;
1045
+ height: var(--player-scrubber-height) !important;
1046
+ width: var(--player-scrubber-height) !important;
1047
+ color: var(--colors-light-1000);
1048
+ border-radius: 50%;
1049
+ border: none;
1050
+ background: var(--colors-light-1000);
1051
+ box-shadow: calc((var(--player-scrubber-shadow-width) + var(--player-scrubber-height) / 2) * -1) 0 0
1052
+ var(--player-scrubber-shadow-width);
1053
+ transition: height 100ms ease-out, width 100ms ease-out, box-shadow 100ms ease-out, color 200ms ease-out;
1054
+ }
1055
+
1056
+ .container:hover input::-webkit-slider-thumb {
1057
+ --player-scrubber-height: 16px;
1058
+ color: var(--colors-light-800);
1059
+ }
1060
+
1061
+ .container:hover input::-moz-range-thumb {
1062
+ --player-scrubber-height: 16px;
1063
+ color: var(--colors-light-800);
1064
+ }
1065
+
1066
+ .container:hover input::-ms-thumb {
1067
+ --player-scrubber-height: 16px;
1068
+ color: var(--colors-light-800);
1069
+ }
1070
+ `],fl([be({type:Number})],Gn.prototype,"duration",2),fl([be({type:Number})],Gn.prototype,"currentTime",2),fl([be({type:Array})],Gn.prototype,"buffer",2),Gn=fl([Gi("vmp-progress-scrubber")],Gn);var J4=Object.defineProperty,ex=Object.getOwnPropertyDescriptor,_i=(r,e,t,i)=>{for(var n=i>1?void 0:i?ex(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&J4(e,t,n),n};let ui=class extends Rt{constructor(){super(...arguments),this.resizeHider=new V4(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=Ou,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:r}){this.volumeMenuOpen=r}_handleLevelsMenuOpen({detail:r}){this.levelsMenuOpen=r}_handlePlaybackMenuToggle({detail:r}){this.playbackRateMenuOpen=r}_handleSettingsMenuToggle({detail:r}){this.settingsMenuOpen=r}hideMenus(){var r,e;(e=Array.from((r=this.shadowRoot)==null?void 0:r.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||e.forEach(t=>{var i;(i=t.tippy)==null||i.hide()})}render(){var r,e,t,i,n,a,l,h,f,p,m,g,A;const b=((r=this.levels)==null?void 0:r.map((B,W)=>{const we=Math.min(B.width,B.height);return{id:`level-${W.toString()}`,event:"level:click",label:`${we}p`,value:{resolution:we,level:W}}}))??[],x={title:"Quality",items:[...b.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},k={id:"levels",label:"Quality",subItems:x},w=(e=x.items)==null?void 0:e.find(({value:B})=>B.level===this.level),P=["levels","playback-rate","captions","fullscreen"].filter(B=>{var W;return(W=this.controls)==null?void 0:W.includes(B)}),$={title:"Settings",items:[T4,k4,k,S4].filter(({id:B})=>P.includes(B)&&this.resizeHider.hiddenControls.includes(B))},N=(t=this.controls)==null?void 0:t.includes("progress"),I=(i=this.controls)==null?void 0:i.includes("navigation"),O=(n=this.controls)==null?void 0:n.includes("play"),K=(a=this.controls)==null?void 0:a.includes("volume"),U=(l=this.controls)==null?void 0:l.includes("current-time"),re=(h=this.controls)==null?void 0:h.includes("duration"),ne=(f=this.controls)==null?void 0:f.includes("levels"),Y=(p=this.controls)==null?void 0:p.includes("speed"),Ee=(m=this.controls)==null?void 0:m.includes("captions"),ce=(g=this.controls)==null?void 0:g.includes("fullscreen"),_e=O||K||U||re||ne||Y||Ee||ce,Oe=[`level-${(A=this.level)==null?void 0:A.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return Qe`
1071
+ <div
1072
+ ${this.resizeHider.measure()}
1073
+ ${this.resizeHider.contain()}
1074
+ class=${Mt({container:!0,hidden:!N&&!_e})}
1075
+ >
1076
+ <div
1077
+ class=${Mt({"scrubber-container":!0,hidden:!N})}
1078
+ >
1079
+ <vmp-progress-scrubber
1080
+ class=${Mt({scrubber:!0,invisible:this.volumeMenuOpen||this.levelsMenuOpen||this.playbackRateMenuOpen||this.settingsMenuOpen})}
1081
+ duration=${this.duration}
1082
+ currentTime=${this.currentTime}
1083
+ .buffer=${this.buffer}
1084
+ ></vmp-progress-scrubber>
1085
+ </div>
1086
+ <div
1087
+ ${this.resizeHider.contain()}
1088
+ class=${Mt({buttons:!0,hidden:!_e})}
1089
+ >
1090
+ <div class="section">
1091
+ <div
1092
+ ${this.resizeHider.hide("navigation",6)}
1093
+ class=${Mt({navigation:!0,hidden:!I})}
1094
+ >
1095
+ <vmp-icon-button
1096
+ icon="arrow-left"
1097
+ weight="heavy"
1098
+ rounded="full"
1099
+ @click=${this._handleNavigateBackClick}
1100
+ ></vmp-icon-button>
1101
+ <vmp-icon-button
1102
+ icon="arrow-right"
1103
+ weight="heavy"
1104
+ rounded="full"
1105
+ @click=${this._handleNavigateForwardClick}
1106
+ ></vmp-icon-button>
1107
+ </div>
1108
+ <vmp-icon-button
1109
+ class=${Mt({hidden:!O})}
1110
+ icon=${this.playing?"pause":"play"}
1111
+ weight="heavy"
1112
+ rounded="full"
1113
+ data-testid="play"
1114
+ @click=${this._handlePlayClick}
1115
+ ></vmp-icon-button>
1116
+ <vmp-volume-button
1117
+ class=${Mt({hidden:!K})}
1118
+ ?muted=${this.muted}
1119
+ volume=${this.volume}
1120
+ @menu:toggle=${this._handleVolumeMenuToggle}
1121
+ ></vmp-volume-button>
1122
+ <div class="time">
1123
+ <vmp-text
1124
+ ${this.resizeHider.hide("current-time",1)}
1125
+ class=${Mt({hidden:!U})}
1126
+ ?semibold=${!0}
1127
+ content="${$u(this.currentTime)}${re?"/":null}"
1128
+ ></vmp-text>
1129
+ <vmp-text
1130
+ ${this.resizeHider.hide("duration",5)}
1131
+ class=${Mt({hidden:!re})}
1132
+ ?semibold=${!0}
1133
+ content=${$u(this.duration)}
1134
+ ></vmp-text>
1135
+ </div>
1136
+ </div>
1137
+ <div class="section">
1138
+ <vmp-menu
1139
+ ${this.resizeHider.hide("levels",0)}
1140
+ class=${Mt({hidden:!ne||b.length<=0})}
1141
+ .items=${x}
1142
+ .activeItems=${Oe}
1143
+ @menu:toggle=${this._handleLevelsMenuOpen}
1144
+ >
1145
+ <vmp-tooltip content="Quality" ?disabled=${this.levelsMenuOpen}>
1146
+ <vmp-button ?active=${this.levelsMenuOpen} icon="chevron-down">${w==null?void 0:w.label}</vmp-button>
1147
+ </vmp-tooltip>
1148
+ </vmp-menu>
1149
+ <vmp-menu
1150
+ ${this.resizeHider.hide("playback-rate",4)}
1151
+ class=${Mt({hidden:!Y})}
1152
+ .items=${Vp}
1153
+ .activeItems=${Oe}
1154
+ @menu:toggle=${this._handlePlaybackMenuToggle}
1155
+ >
1156
+ <vmp-tooltip content="Playback speed" ?disabled=${this.playbackRateMenuOpen}>
1157
+ <vmp-button ?active=${this.playbackRateMenuOpen} icon="chevron-down"
1158
+ >${this.playbackRate.toFixed(1)}x</vmp-button
1159
+ >
1160
+ </vmp-tooltip>
1161
+ </vmp-menu>
1162
+ <vmp-tooltip
1163
+ ${this.resizeHider.hide("captions",3)}
1164
+ class=${Mt({hidden:!Ee})}
1165
+ content="Captions"
1166
+ >
1167
+ <vmp-icon-button
1168
+ ?active=${this.captions}
1169
+ icon=${this.captions?"captions":"captions-cross"}
1170
+ rounded="full"
1171
+ @click=${this._handleCaptionsClick}
1172
+ ></vmp-icon-button>
1173
+ </vmp-tooltip>
1174
+ <vmp-tooltip
1175
+ ${this.resizeHider.hide("fullscreen",2)}
1176
+ content="Fullscreen"
1177
+ class=${Mt({hidden:!ce})}
1178
+ >
1179
+ <vmp-icon-button
1180
+ ?active=${this.fullscreen}
1181
+ icon=${this.fullscreen?"minimize":"maximize"}
1182
+ rounded="full"
1183
+ data-testid="fullscreen"
1184
+ @click=${this._handleFullscreenClick}
1185
+ ></vmp-icon-button>
1186
+ </vmp-tooltip>
1187
+ <vmp-menu
1188
+ ${this.resizeHider.show("settings",["levels","playback-rate","captions","fullscreen"])}
1189
+ .items=${$}
1190
+ .activeItems=${Oe}
1191
+ @menu:toggle=${this._handleSettingsMenuToggle}
1192
+ >
1193
+ <vmp-tooltip content="Settings" ?disabled=${this.settingsMenuOpen}>
1194
+ <vmp-icon-button ?active=${this.settingsMenuOpen} icon="settings" rounded="full"></vmp-icon-button>
1195
+ </vmp-tooltip>
1196
+ </vmp-menu>
1197
+ </div>
1198
+ </div>
1199
+ </div>
1200
+ `}};ui.styles=[Rt.styles??[],ai`
1201
+ :host {
1202
+ --controls-border-radius: var(--player-border-radius, 0px);
1203
+
1204
+ display: flex;
1205
+ width: 100%;
1206
+ isolation: isolate;
1207
+ }
1208
+
1209
+ .container {
1210
+ display: flex;
1211
+ flex-direction: column;
1212
+ gap: var(--space-small);
1213
+ flex: 1;
1214
+ min-width: 0;
1215
+ overflow: auto;
1216
+ padding: var(--space-xl) var(--space-xs) var(--space-xs) var(--space-xs);
1217
+ background: linear-gradient(to bottom, transparent 20%, var(--colors-dark-800) 100%);
1218
+ border-radius: var(--controls-border-radius);
1219
+ border-top-left-radius: 0;
1220
+ border-top-right-radius: 0;
1221
+ }
1222
+
1223
+ .buttons {
1224
+ display: flex;
1225
+ justify-content: space-between;
1226
+ gap: var(--space-xs);
1227
+ width: max-content;
1228
+ min-width: 100%;
1229
+ }
1230
+
1231
+ .section {
1232
+ display: flex;
1233
+ gap: var(--space-xs);
1234
+ }
1235
+
1236
+ .scrubber-container {
1237
+ position: relative;
1238
+ display: flex;
1239
+ height: 8px;
1240
+ }
1241
+
1242
+ .scrubber {
1243
+ position: absolute;
1244
+ width: 100%;
1245
+ bottom: 0;
1246
+ transition: opacity 150ms ease-out;
1247
+ }
1248
+
1249
+ .invisible {
1250
+ opacity: 0;
1251
+ pointer-events: none;
1252
+ }
1253
+
1254
+ .navigation {
1255
+ display: flex;
1256
+ background: var(--colors-light-1000);
1257
+ border-radius: 1000rem;
1258
+ }
1259
+
1260
+ .time {
1261
+ display: flex;
1262
+ align-items: center;
1263
+ color: var(--colors-light-1000);
1264
+ white-space: nowrap;
1265
+ font-variant-numeric: tabular-nums;
1266
+ }
1267
+
1268
+ .hidden {
1269
+ display: none;
1270
+ }
1271
+ `],_i([be({type:Boolean})],ui.prototype,"playing",2),_i([be({type:Number})],ui.prototype,"volume",2),_i([be({type:Boolean})],ui.prototype,"muted",2),_i([be({type:Number})],ui.prototype,"currentTime",2),_i([be({type:Number})],ui.prototype,"duration",2),_i([be({type:Number})],ui.prototype,"level",2),_i([be({type:Number})],ui.prototype,"playbackRate",2),_i([be({type:Array})],ui.prototype,"buffer",2),_i([be({type:Array,attribute:!1})],ui.prototype,"levels",2),_i([be({type:Boolean})],ui.prototype,"captions",2),_i([be({type:Boolean})],ui.prototype,"fullscreen",2),_i([be({type:Array})],ui.prototype,"controls",2),_i([mi()],ui.prototype,"volumeMenuOpen",2),_i([mi()],ui.prototype,"levelsMenuOpen",2),_i([mi()],ui.prototype,"playbackRateMenuOpen",2),_i([mi()],ui.prototype,"settingsMenuOpen",2),ui=_i([Gi("vmp-player-controls")],ui);var tx=Object.defineProperty,ix=Object.getOwnPropertyDescriptor,rx=(r,e,t,i)=>{for(var n=i>1?void 0:i?ix(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&tx(e,t,n),n};let Uu=class extends Rt{render(){return Qe`<vmp-icon icon="loading"></vmp-icon>`}};Uu.styles=[Rt.styles??[],ai`
1272
+ :host {
1273
+ display: flex;
1274
+ align-items: center;
1275
+ justify-content: center;
1276
+ }
1277
+ `],Uu=rx([Gi("vmp-loading-spinner")],Uu);var sx=Object.defineProperty,nx=Object.getOwnPropertyDescriptor,Yp=(r,e,t,i)=>{for(var n=i>1?void 0:i?nx(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&sx(e,t,n),n};let pl=class extends Rt{constructor(){super(...arguments),this.caption=""}render(){return Qe`
1278
+ <div class="container">
1279
+ <vmp-text content=${this.caption} size="large"></vmp-text>
1280
+ </div>
1281
+ `}};pl.styles=[Rt.styles??[],ai`
1282
+ .container {
1283
+ display: block;
1284
+ margin: 0 var(--space-small);
1285
+ text-align: center;
1286
+ }
1287
+
1288
+ vmp-text::part(content) {
1289
+ display: inline;
1290
+ padding: var(--space-xxs) var(--space-xs);
1291
+ text-align: center;
1292
+ border-radius: var(--radii-small);
1293
+ box-decoration-break: clone;
1294
+ -webkit-box-decoration-break: clone;
1295
+ color: var(--colors-light-1000);
1296
+ background: var(--colors-dark-800);
1297
+ /* Line height controls the spacing between the cloned boxes so has to override the default */
1298
+ line-height: 2.2;
1299
+ }
1300
+ `],Yp([be({type:String})],pl.prototype,"caption",2),pl=Yp([Gi("vmp-captions")],pl);var ox=Object.defineProperty,ax=Object.getOwnPropertyDescriptor,Oi=(r,e,t,i)=>{for(var n=i>1?void 0:i?ax(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&ox(e,t,n),n};const lx=3e3;let vi=class extends Rt{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=Ou,this.showControls=!0,this._hasTouched=!1,this._playerControlsRef=ki()}_startHideControls(){clearTimeout(this._controlHideTimeout),this._controlHideTimeout=setTimeout(()=>{this.showControls=!1,this._hasTouched=!1},lx)}_immediateShowControls(){this.showControls=!0,clearTimeout(this._controlHideTimeout)}_immediateHideControls(){this.showControls=!1,this._hasTouched=!1,clearTimeout(this._controlHideTimeout)}willUpdate(r){var e;r.has("playing")&&this.playing&&this._startHideControls(),r.has("showControls")&&this.playing&&!this.showControls&&((e=this._playerControlsRef.value)==null||e.hideMenus())}render(){var r;const e=(r=this.controls)==null?void 0:r.includes("play-large"),t=this.playing&&!this.showControls,i=!!(e&&!this.playing);return Qe`
1301
+ <div
1302
+ class=${Mt({container:!0,hide:t})}
1303
+ @mousemove=${()=>{this._immediateShowControls(),this._startHideControls()}}
1304
+ @mouseleave=${this._immediateHideControls}
1305
+ @touchstart=${n=>{this.playing&&!this.showControls&&!this._hasTouched&&(n.preventDefault(),this._hasTouched=!0,this._immediateShowControls(),this._startHideControls())}}
1306
+ >
1307
+ <div
1308
+ class=${Mt({fixtures:!0,invisible:!this.loading&&!i})}
1309
+ @click=${()=>{this.showControls&&this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}}
1310
+ >
1311
+ <vmp-icon
1312
+ class=${Mt({hidden:!i})}
1313
+ icon="play-large"
1314
+ ></vmp-icon>
1315
+ <vmp-loading-spinner
1316
+ class=${Mt({hidden:!this.loading||i})}
1317
+ ></vmp-loading-spinner>
1318
+ </div>
1319
+ <div
1320
+ class=${Mt({controls:!0,hide:t})}
1321
+ @focusin=${this._immediateShowControls}
1322
+ @mousemove=${n=>{n.stopPropagation(),this._immediateShowControls()}}
1323
+ @click=${this._immediateShowControls}
1324
+ >
1325
+ ${this.captions?Qe`<vmp-captions
1326
+ class=${Mt({hidden:!this.caption,hiddenControls:t})}
1327
+ caption=${this.caption}
1328
+ ></vmp-captions>`:null}
1329
+ <vmp-player-controls
1330
+ ${Si(this._playerControlsRef)}
1331
+ ?playing=${this.playing}
1332
+ ?muted=${this.muted}
1333
+ volume=${this.volume}
1334
+ currentTime=${this.currentTime}
1335
+ duration=${this.duration}
1336
+ .levels=${this.levels}
1337
+ .level=${this.level}
1338
+ playbackRate=${this.playbackRate}
1339
+ .buffer=${this.buffer}
1340
+ .controls=${this.controls}
1341
+ ?captions=${this.captions}
1342
+ ?fullscreen=${this.fullscreen}
1343
+ ></vmp-player-controls>
1344
+ </div>
1345
+ </div>
1346
+ `}};vi.styles=[Rt.styles??[],ai`
1347
+ :host {
1348
+ --overlay-border-radius: var(--player-border-radius, 0px);
1349
+ }
1350
+
1351
+ .container {
1352
+ position: relative;
1353
+ display: flex;
1354
+ justify-content: space-between;
1355
+ height: 100%;
1356
+ width: 100%;
1357
+ overflow: hidden;
1358
+ border-radius: var(--overlay-border-radius);
1359
+ }
1360
+
1361
+ .container.hide {
1362
+ cursor: none;
1363
+ }
1364
+
1365
+ .fixtures {
1366
+ position: absolute;
1367
+ top: 0;
1368
+ left: 0;
1369
+ right: 0;
1370
+ bottom: 0;
1371
+ display: flex;
1372
+ align-items: center;
1373
+ justify-content: center;
1374
+ opacity: 1;
1375
+ color: var(--colors-light-1000);
1376
+ background: var(--colors-dark-200);
1377
+ border-radius: var(--overlay-border-radius);
1378
+ transition: opacity 150ms ease-out;
1379
+ }
1380
+
1381
+ .hidden {
1382
+ display: none;
1383
+ }
1384
+
1385
+ .invisible {
1386
+ opacity: 0;
1387
+ }
1388
+
1389
+ .controls {
1390
+ position: relative;
1391
+ display: flex;
1392
+ flex-direction: column;
1393
+ align-self: flex-end;
1394
+ flex: 1;
1395
+ min-width: 0;
1396
+ opacity: 1;
1397
+ isolation: isolate;
1398
+ transform: translateY(0%);
1399
+ transition: transform 200ms ease-out;
1400
+ }
1401
+
1402
+ .controls.hide {
1403
+ pointer-events: none;
1404
+ transform: translateY(100%);
1405
+ }
1406
+
1407
+ vmp-captions {
1408
+ position: absolute;
1409
+ bottom: calc(100%);
1410
+ width: 100%;
1411
+ transform: translateY(var(--space-medium));
1412
+ transition: transform 200ms ease-out;
1413
+ }
1414
+
1415
+ vmp-captions.hiddenControls {
1416
+ transform: translateY(calc(var(--space-small) * -1));
1417
+ }
1418
+ `],Oi([be({type:Boolean})],vi.prototype,"loading",2),Oi([be({type:Boolean})],vi.prototype,"playing",2),Oi([be({type:Number})],vi.prototype,"volume",2),Oi([be({type:Boolean})],vi.prototype,"muted",2),Oi([be({type:Number})],vi.prototype,"currentTime",2),Oi([be({type:Number})],vi.prototype,"duration",2),Oi([be({type:Array,attribute:!1})],vi.prototype,"levels",2),Oi([be({type:Number})],vi.prototype,"level",2),Oi([be({type:Number})],vi.prototype,"playbackRate",2),Oi([be({type:String})],vi.prototype,"caption",2),Oi([be({type:Array})],vi.prototype,"buffer",2),Oi([be({type:Boolean})],vi.prototype,"captions",2),Oi([be({type:Boolean})],vi.prototype,"fullscreen",2),Oi([be({type:Array})],vi.prototype,"controls",2),Oi([mi()],vi.prototype,"showControls",2),vi=Oi([Gi("vmp-player-overlay")],vi);var cx=Object.defineProperty,ux=Object.getOwnPropertyDescriptor,ri=(r,e,t,i)=>{for(var n=i>1?void 0:i?ux(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&cx(e,t,n),n};const hx=1e3/60;let ti=class extends Rt{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=gc,this._sceneController=new E4(this),this._drawController=new g4(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=ki(),this._canvasRef=ki(),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 r;(r=this.shadowRoot)!=null&&r.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,hx):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=(r=performance.now())=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:e})=>{if(e){const{key:t}=e,i=this.videoState[t];return!i||!i.initialised||i.waiting||e.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),r-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(r-(this._lastTimestamp??r))/1e3*this.playbackRate,this._lastTimestamp=r),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||this._loop()},this._handleError=r=>{this._errors=[...this.errors,r.error],r.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(r=>{const e=setInterval(()=>{!!this.errors.find(i=>i.fatal)&&r(!1),!this.loading&&!this.processing&&this.scenes.length>0&&r(!0)},500);setTimeout(()=>{clearInterval(e),r(!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 r;return((r=this._sceneController.scenes)==null?void 0:r.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((r,{video:e,start:t,duration:i})=>{const n=(e==null?void 0:e.key)??`${t}-${i}`;return r[n]=this.videoState[n],r},{})}set paused(r){r!==this._paused&&(this._paused=r,this.requestUpdate(),this.dispatchEvent(new CustomEvent(r?"pause":"play")))}get paused(){return this._paused}set playbackRate(r){r!==this._playbackRate&&(this._playbackRate=r,this.scenes.forEach(({video:e})=>{e&&(e.node.playbackRate=r)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:r})))}get playbackRate(){return this._playbackRate}set volume(r){const e=Math.min(1,Math.max(0,r));e!==this._volume&&(this.scenes.forEach(({video:t})=>{t&&(t.node.volume=e)}),localStorage.setItem("vmp-player-volume",e.toString()),this._volume=e,e>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:r})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(r){this.scenes.forEach(({video:e})=>{e&&(e.node.muted=r)}),r!==this._muted&&(this._muted=r,localStorage.setItem("vmp-player-muted",r.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:r?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(r){r!==this._videoResolution&&(this._videoResolution=r,this.scenes.forEach(({video:e})=>{if(e!=null&&e.hls){const t=e.hls.levels.findIndex(i=>Math.min(i.height,i.width)===r);e.hls.currentLevel=t??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(r){r!==this._drawController.currentTime&&(this._drawController.currentTime=r,this._sceneController.setVideosCurrentTime(r))}get currentTime(){return this._drawController.currentTime}reset(r=0,e=!1){this._lastTimestamp=null,this._drawController.currentTime=r,this._sceneController.setVideosCurrentTime(r),e?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:r})=>{r&&r.node.pause()})}draw(r){return this._drawController.draw(r)}setScene(r){var e,t;if((e=this._sceneController)!=null&&e.scenes){const i=(t=this.scenes)==null?void 0:t[r];if(!i){const n=new Vr(`No scene at index: ${r}`);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(r){r??this.fullscreen?x4():this._playerRef.value&&b4(this._playerRef.value)}connectedCallback(){var r;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),document.addEventListener("visibilitychange",this._handleVisibilityChange),(r=this.shadowRoot)!=null&&r.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(r){r.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&r.has("_processing")&&this.play()}disconnectedCallback(){var r;super.disconnectedCallback(),(r=this._observer)==null||r.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange),document.removeEventListener("visibilitychange",this._handleVisibilityChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?Qe`
1419
+ <style>
1420
+ :host {
1421
+ aspect-ratio: ${this.propAspectRatio};
1422
+ }
1423
+ </style>
1424
+ `:null:Qe`
1425
+ <style>
1426
+ :host {
1427
+ width: 100%;
1428
+ height: 100%;
1429
+ }
1430
+ </style>
1431
+ `}_renderError(){return Qe`<div class="error">
1432
+ <div class="error-icon">
1433
+ <vmp-icon icon="error"></vmp-icon>
1434
+ </div>
1435
+ <div class="error-text">
1436
+ <vmp-text semibold content="An error has occurred when attempting to play this video."></vmp-text>
1437
+ <vmp-text semibold content="Please try again later."></vmp-text>
1438
+ </div>
1439
+ </div>`}render(){var r,e,t,i,n,a;const l=this.loading||this.processing||!this.scenes||this.duration<=0,{height:h,width:f}=vc({resolution:((r=this.sceneConfig)==null?void 0:r.resolution)??720,aspectRatio:this.aspectRatio}),p=Object.keys(this.sceneVideoState).reduce(($,N)=>$.concat(this.sceneVideoState[N].buffered??[]),[]),m=l?[]:(e=this.controls??Ou)==null?void 0:e.filter($=>!($==="fullscreen"&&y4()||$==="navigation"&&(!this.scenes||this.scenes.length<=1))),g=!(m!=null&&m.includes("preview")),A=(((t=this.scenes)==null?void 0:t.length)??0)-1,b=((i=this.scenes)==null?void 0:i.findIndex($=>$===this._drawController.activeScenes[0]))??0,x=(a=(n=this._drawController.activeScenes[0])==null?void 0:n.video)==null?void 0:a.hls,k=this.loading||this.waiting||this.processing,w=!this.src&&!this.data,P=!!this.errors.find($=>$.fatal);return Qe`
1440
+ ${this._renderStyles()}
1441
+ <div
1442
+ ${Si(this._playerRef)}
1443
+ class=${Mt({player:!0,responsive:!this.propAspectRatio})}
1444
+ style=${_o({aspectRatio:this.aspectRatio})}
1445
+ >
1446
+ ${!k&&(w||P)?this._renderError():Qe`<canvas
1447
+ ${Si(this._canvasRef)}
1448
+ ${this._drawController.canvas()}
1449
+ ${Pu(this._handleCanvasResize)}
1450
+ height=${h}
1451
+ width=${f}
1452
+ ></canvas>
1453
+ <vmp-player-overlay
1454
+ ${this._drawController.controls()}
1455
+ .data=${this.data}
1456
+ .template=${this.template}
1457
+ ?disabled=${l}
1458
+ ?playing=${!this.paused}
1459
+ ?loading=${k}
1460
+ ?muted=${this.muted}
1461
+ volume=${this.volume}
1462
+ duration=${this.duration}
1463
+ .levels=${(x==null?void 0:x.levels)??[]}
1464
+ level=${li(x!=null&&x.autoLevelEnabled?-1:x==null?void 0:x.currentLevel)}
1465
+ playbackRate=${this.playbackRate}
1466
+ caption=${this._drawController.caption}
1467
+ .buffer=${p}
1468
+ .controls=${m}
1469
+ ?captions=${this.captions}
1470
+ ?fullscreen=${this.fullscreen}
1471
+ @navigate:back=${$=>{$.defaultPrevented||this.setScene(b<=0?A:b-1)}}
1472
+ @navigate:forward=${$=>{$.defaultPrevented||this.setScene(b>=A?0:b+1)}}
1473
+ @play:click=${({detail:$})=>{l||($?this.pause():(this.muted=this._manualMute,this.play()))}}
1474
+ @volume:click=${({detail:$})=>{this.muted=!$,this._manualMute=!$}}
1475
+ @level:click=${({detail:$})=>{this.videoResolution=$.value.resolution}}
1476
+ @playbackRate:click=${({detail:$})=>{this.playbackRate=$.value??1}}
1477
+ @captions:click=${()=>{this._captions=!this._captions}}
1478
+ @fullscreen:click=${()=>{this.toggleFullscreen()}}
1479
+ @input=${$=>{const N=$.composedPath()[0],I=N.getAttribute("key");if(I==="scrubber"){const O=parseFloat(N.value);this._drawController.currentTime=O,this._sceneController.setVideosCurrentTime(O),this.dispatchEvent(new CustomEvent("seeking",{detail:O}))}I==="volume"&&(this.volume=parseFloat(N.value))}}
1480
+ @pointerdown=${$=>{$.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!0,this._wasPlaying=!this.paused,this.paused||this.pause())}}
1481
+ @pointerup=${$=>{$.composedPath()[0].getAttribute("key")==="scrubber"&&(this._seeking=!1,this._wasPlaying&&(this.play(),this._wasPlaying=!1),this.dispatchEvent(new CustomEvent("seeked",{detail:this._drawController.currentTime})))}}
1482
+ ></vmp-player-overlay>
1483
+ <vmp-video-preview
1484
+ ?disabled=${g}
1485
+ .src=${this.src}
1486
+ .data=${this.data}
1487
+ .template=${this.template}
1488
+ .aspectRatio=${this.aspectRatio}
1489
+ .compilation=${this.compilation}
1490
+ ></vmp-video-preview>`}
1491
+ </div>
1492
+ `}};ti.styles=[Rt.styles??[],ai`
1493
+ :host {
1494
+ --player-border-radius: var(--vouch-media-player-border-radius, 0px);
1495
+
1496
+ display: flex;
1497
+ }
1498
+
1499
+ .player {
1500
+ position: relative;
1501
+ display: flex;
1502
+ align-items: center;
1503
+ justify-content: center;
1504
+ background: var(--colors-dark-1000);
1505
+ border-radius: var(--player-border-radius);
1506
+ }
1507
+
1508
+ .responsive {
1509
+ width: 100%;
1510
+ height: 100%;
1511
+ }
1512
+
1513
+ .error {
1514
+ display: flex;
1515
+ align-items: center;
1516
+ justify-content: center;
1517
+ gap: var(--space-xxs);
1518
+ padding: var(--space-medium);
1519
+ width: 100%;
1520
+ height: 100%;
1521
+ color: white;
1522
+ }
1523
+
1524
+ .error-icon {
1525
+ color: var(--colors-red-500);
1526
+ }
1527
+
1528
+ .error-text {
1529
+ display: flex;
1530
+ flex-direction: column;
1531
+ }
1532
+
1533
+ canvas {
1534
+ width: 100%;
1535
+ max-height: 100%;
1536
+ object-fit: contain;
1537
+ border-radius: var(--player-border-radius);
1538
+ }
1539
+
1540
+ vmp-player-overlay {
1541
+ position: absolute;
1542
+ top: 0;
1543
+ left: 0;
1544
+ right: 0;
1545
+ bottom: 0;
1546
+ }
1547
+
1548
+ vmp-video-preview {
1549
+ position: absolute;
1550
+ top: 0;
1551
+ left: 0;
1552
+ }
1553
+ `],ri([be({type:Object})],ti.prototype,"data",2),ri([be({type:Object})],ti.prototype,"template",2),ri([be({type:Boolean})],ti.prototype,"burnCaptions",2),ri([be({type:Boolean})],ti.prototype,"debug",2),ri([be({type:String})],ti.prototype,"src",2),ri([be({type:String})],ti.prototype,"track",2),ri([be({type:Number,attribute:"aspectratio"})],ti.prototype,"propAspectRatio",2),ri([be({type:String})],ti.prototype,"preload",2),ri([be({type:Boolean})],ti.prototype,"autoplay",2),ri([be({type:Boolean})],ti.prototype,"loading",2),ri([be({type:Array})],ti.prototype,"controls",2),ri([be({attribute:!1})],ti.prototype,"compilation",2),ri([mi()],ti.prototype,"_pageHidden",2),ri([mi()],ti.prototype,"_aspectRatio",2),ri([mi()],ti.prototype,"_processing",2),ri([mi()],ti.prototype,"_waiting",2),ri([mi()],ti.prototype,"_errors",2),ri([mi()],ti.prototype,"_seeking",2),ri([mi()],ti.prototype,"_captions",2),ri([mi()],ti.prototype,"_fullscreen",2),ti=ri([Gi("vmp-media-player")],ti);var dx=Object.defineProperty,fx=Object.getOwnPropertyDescriptor,Vi=(r,e,t,i)=>{for(var n=i>1?void 0:i?fx(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&dx(e,t,n),n};let Ri=class extends is{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new m2(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 F2(this),this._trackingController=new uv(this),this._mediaPlayerRef=ki()}get fetching(){return this._fetcherController.fetching}get waiting(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.waiting}get initialised(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.initialised}get seeking(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.seeking}get paused(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.paused}get captions(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.captions}get fullscreen(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.fullscreen}get duration(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.duration}set currentTime(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=r)}get currentTime(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.currentTime)??0}set playbackRate(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=r)}get playbackRate(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.playbackRate)??1}set volume(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=r)}get volume(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.volume)??1}set muted(r){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=r)}get muted(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.muted)??!1}get scene(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scene)??null}get scenes(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.scenes)??[]}get sceneConfig(){var r;return((r=this._mediaPlayerRef.value)==null?void 0:r.sceneConfig)??null}get videoState(){var r;return(r=this._mediaPlayerRef.value)==null?void 0:r.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var r;(r=this._mediaPlayerRef.value)==null||r.play()}pause(){var r;(r=this._mediaPlayerRef.value)==null||r.pause()}reset(r=0,e=!1){var t;(t=this._mediaPlayerRef.value)==null||t.reset(r,e)}setScene(r){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(r)}_renderStyles(){return this.aspectRatio?typeof this.aspectRatio=="number"?Qe`
1554
+ <style>
1555
+ :host {
1556
+ aspect-ratio: ${this.aspectRatio};
1557
+ }
1558
+ </style>
1559
+ `:null:Qe`
1560
+ <style>
1561
+ :host {
1562
+ width: 100%;
1563
+ height: 100%;
1564
+ }
1565
+ </style>
1566
+ `}render(){return Qe`
1567
+ ${this._renderStyles()}
1568
+ <vmp-media-player
1569
+ ${Si(this._mediaPlayerRef)}
1570
+ ${this.eventController.register()}
1571
+ ?autoplay=${this.autoplay}
1572
+ ?loading=${this.fetching}
1573
+ .data=${this.vouch}
1574
+ .template=${this.template}
1575
+ aspectRatio=${li(this.aspectRatio)}
1576
+ preload=${li(this.preload)}
1577
+ .controls=${this.controls}
1578
+ ></vmp-media-player>
1579
+ `}};Ri.styles=[ai`
1580
+ :host {
1581
+ display: flex;
1582
+ }
1583
+ `],Vi([be({type:Object})],Ri.prototype,"data",2),Vi([be({type:String})],Ri.prototype,"vouchId",2),Vi([be({type:String})],Ri.prototype,"templateId",2),Vi([be({type:Array})],Ri.prototype,"questions",2),Vi([be({type:String})],Ri.prototype,"env",2),Vi([be({type:String})],Ri.prototype,"apiKey",2),Vi([be({type:Boolean})],Ri.prototype,"disableTracking",2),Vi([be({type:String})],Ri.prototype,"trackingSource",2),Vi([be({type:Array})],Ri.prototype,"controls",2),Vi([be({type:String})],Ri.prototype,"preload",2),Vi([be({type:Boolean})],Ri.prototype,"autoplay",2),Vi([be({type:Number})],Ri.prototype,"aspectRatio",2),Vi([mi()],Ri.prototype,"vouch",2),Vi([mi()],Ri.prototype,"template",2),Ri=Vi([ua("vouch-embed-player")],Ri);function ml(r,e,t,i=20,n=0){let a=[];if(n>=i)return a;const l=f=>{const p=f.assignedNodes().filter(m=>m.nodeType===1);return p.length>0?ml(p[0].parentElement,e,t,i,n+1):[]},h=Array.from(r.children||[]);for(const f of h)e(f)||(t(f)&&a.push(f),f.shadowRoot!=null?a.push(...ml(f.shadowRoot,e,t,i,n+1)):f.tagName==="SLOT"?a.push(...l(f)):a.push(...ml(f,e,t,i,n+1)));return a}function Xp(r){return r.hasAttribute("hidden")||r.hasAttribute("aria-hidden")&&r.getAttribute("aria-hidden")!=="false"||r.style.display==="none"||r.style.opacity==="0"||r.style.visibility==="hidden"||r.style.visibility==="collapse"}function px(r){return r.hasAttribute("disabled")||r.hasAttribute("aria-disabled")&&r.getAttribute("aria-disabled")!=="false"}function mx(r){return r.getAttribute("tabindex")==="-1"||Xp(r)||px(r)?!1:r.hasAttribute("tabindex")||(r instanceof HTMLAnchorElement||r instanceof HTMLAreaElement)&&r.hasAttribute("href")||r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement||r instanceof HTMLIFrameElement}const Bu=new Map;function gx(r,e,t){const i=Bu.get(t);i!=null&&window.clearTimeout(i),Bu.set(t,window.setTimeout(()=>{r(),Bu.delete(t)},e))}const Zp=document.createElement("template");Zp.innerHTML=`
1584
+ <div id="start"></div>
1585
+ <div id="backup"></div>
1586
+ <slot></slot>
1587
+ <div id="end"></div>
1588
+ `;class vx extends HTMLElement{constructor(){super(),this.debounceId=Math.random().toString(),this._focused=!1;const e=this.attachShadow({mode:"open"});e.appendChild(Zp.content.cloneNode(!0)),this.$backup=e.querySelector("#backup"),this.$start=e.querySelector("#start"),this.$end=e.querySelector("#end"),this.focusLastElement=this.focusLastElement.bind(this),this.focusFirstElement=this.focusFirstElement.bind(this),this.onFocusIn=this.onFocusIn.bind(this),this.onFocusOut=this.onFocusOut.bind(this)}static get observedAttributes(){return["inactive"]}get inactive(){return this.hasAttribute("inactive")}set inactive(e){e?this.setAttribute("inactive",""):this.removeAttribute("inactive")}get focused(){return this._focused}connectedCallback(){this.$start.addEventListener("focus",this.focusLastElement),this.$end.addEventListener("focus",this.focusFirstElement),this.addEventListener("focusin",this.onFocusIn),this.addEventListener("focusout",this.onFocusOut),this.render()}disconnectedCallback(){this.$start.removeEventListener("focus",this.focusLastElement),this.$end.removeEventListener("focus",this.focusFirstElement),this.removeEventListener("focusin",this.onFocusIn),this.removeEventListener("focusout",this.onFocusOut)}attributeChangedCallback(){this.render()}focusFirstElement(){this.trapFocus()}focusLastElement(){this.trapFocus(!0)}getFocusableElements(){return ml(this,Xp,mx)}trapFocus(e){if(this.inactive)return;let t=this.getFocusableElements();t.length>0?(e?t[t.length-1].focus():t[0].focus(),this.$backup.setAttribute("tabindex","-1")):(this.$backup.setAttribute("tabindex","0"),this.$backup.focus())}onFocusIn(){this.updateFocused(!0)}onFocusOut(){this.updateFocused(!1)}updateFocused(e){gx(()=>{this.focused!==e&&(this._focused=e,this.render())},0,this.debounceId)}render(){this.$start.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.$end.setAttribute("tabindex",!this.focused||this.inactive?"-1":"0"),this.focused?this.setAttribute("focused",""):this.removeAttribute("focused")}}window.customElements.define("focus-trap",vx);var yx=Object.defineProperty,Ax=Object.getOwnPropertyDescriptor,Gu=(r,e,t,i)=>{for(var n=i>1?void 0:i?Ax(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&yx(e,t,n),n};let Yo=class extends is{constructor(){super(...arguments),this.open=!1,this.aspectRatio=0}render(){return Qe`
1589
+ <div
1590
+ class=${Mt({container:!0,hidden:!this.open})}
1591
+ >
1592
+ <div
1593
+ class="background"
1594
+ @click=${()=>this.dispatchEvent(new CustomEvent("overlay:click",{bubbles:!0,composed:!0}))}
1595
+ ></div>
1596
+ <focus-trap>
1597
+ <div
1598
+ class=${Mt({"video-frame":!0,grow:this.aspectRatio===0})}
1599
+ style=${_o({aspectRatio:this.aspectRatio})}
1600
+ >
1601
+ <slot></slot>
1602
+ <vmp-icon-button
1603
+ icon="close"
1604
+ rounded="full"
1605
+ weight="heavy"
1606
+ @click=${()=>this.dispatchEvent(new CustomEvent("close:click",{bubbles:!0,composed:!0}))}
1607
+ ></vmp-icon-button>
1608
+ </div>
1609
+ </focus-trap>
1610
+ </div>
1611
+ `}};Yo.styles=[ai`
1612
+ :host {
1613
+ --vouch-media-player-border-radius: var(--vu-media-player-border-radius, 12px);
1614
+ --overlay-background-color: var(--vu-overlay-background-color, black);
1615
+ --overlay-background-opacity: var(--vu-overlay-background-opacity, 0.4);
1616
+
1617
+ --dialog-width: var(--vu-dialog-width, 890px);
1618
+ --dialog-height: var(--vu-dialog-height, 500px);
1619
+ }
1620
+
1621
+ .container {
1622
+ position: fixed;
1623
+ display: flex;
1624
+ inset: 0;
1625
+ opacity: 1;
1626
+ z-index: 2147483647;
1627
+ align-items: center;
1628
+ justify-content: center;
1629
+ transition: opacity 100ms ease-in;
1630
+ }
1631
+
1632
+ .hidden {
1633
+ opacity: 0;
1634
+ pointer-events: none;
1635
+ }
1636
+
1637
+ .background {
1638
+ position: absolute;
1639
+ inset: 0;
1640
+ opacity: var(--overlay-background-opacity);
1641
+ background-color: var(--overlay-background-color);
1642
+ }
1643
+
1644
+ focus-trap {
1645
+ display: flex;
1646
+ align-items: center;
1647
+ justify-content: center;
1648
+ margin: 40px;
1649
+ width: var(--dialog-width);
1650
+ height: var(--dialog-height);
1651
+ max-width: calc(100% - 80px);
1652
+ max-height: calc(100% - 80px);
1653
+ }
1654
+
1655
+ .video-frame {
1656
+ position: relative;
1657
+ display: flex;
1658
+ align-items: center;
1659
+ justify-content: center;
1660
+ max-width: 100%;
1661
+ max-height: 100%;
1662
+ }
1663
+
1664
+ .video-frame.grow {
1665
+ width: 100%;
1666
+ height: 100%;
1667
+ }
1668
+
1669
+ vmp-icon-button {
1670
+ position: absolute;
1671
+ top: 0;
1672
+ right: 0;
1673
+ margin: 10px;
1674
+ }
1675
+ `],Gu([be({type:Boolean})],Yo.prototype,"open",2),Gu([be({type:Number})],Yo.prototype,"aspectRatio",2),Yo=Gu([ua("vouch-embed-dialog-overlay")],Yo);var Ex=Object.defineProperty,bx=Object.getOwnPropertyDescriptor,ar=(r,e,t,i)=>{for(var n=i>1?void 0:i?bx(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&Ex(e,t,n),n};let tr=class extends is{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._mediaPlayerRef=ki(),this.open=!1,this._handleToggle=({detail:r})=>{var e,t,i;this.id===r&&(this.open=!this.open,this.open?!this.disableAutoplay&&((e=this._mediaPlayerRef)!=null&&e.value)&&(this._mediaPlayerRef.value.muted=!1,this._mediaPlayerRef.value.play()):(i=(t=this._mediaPlayerRef)==null?void 0:t.value)==null||i.pause())},this._handleClose=()=>{var r,e;this.open=!1,(e=(r=this._mediaPlayerRef)==null?void 0:r.value)==null||e.pause()},this._handleDocumentKeyUp=r=>{r.key==="Escape"&&this._handleClose()}}connectedCallback(){super.connectedCallback(),document.addEventListener("dialogembed:click",this._handleToggle),document.addEventListener("keyup",this._handleDocumentKeyUp),document.addEventListener("close:click",this._handleClose),document.addEventListener("overlay:click",this._handleClose)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("dialogembed:click",this._handleToggle),document.removeEventListener("keyup",this._handleDocumentKeyUp),document.removeEventListener("close:click",this._handleClose),document.removeEventListener("overlay:click",this._handleClose)}createRenderRoot(){const r=document.createElement("div");return document.body.appendChild(r),r}render(){return Qe`
1676
+ <vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
1677
+ <vouch-embed-player
1678
+ ${Si(this._mediaPlayerRef)}
1679
+ style=${_o({maxWidth:"100%",maxHeight:"100%"})}
1680
+ ?autoplay=${!1}
1681
+ vouchId=${li(this.vouchId)}
1682
+ templateId=${li(this.templateId)}
1683
+ .questions=${this.questions}
1684
+ .controls=${this.controls}
1685
+ env=${li(this.env)}
1686
+ apiKey=${li(this.apiKey)}
1687
+ ?disableTracking=${this.disableTracking}
1688
+ trackingSource=${li(this.trackingSource)}
1689
+ preload=${li(this.preload)}
1690
+ aspectRatio=${this.aspectRatio}
1691
+ ></vouch-embed-player>
1692
+ </vouch-embed-dialog-overlay>
1693
+ `}};ar([be({type:String})],tr.prototype,"vouchId",2),ar([be({type:String})],tr.prototype,"templateId",2),ar([be({type:Array})],tr.prototype,"questions",2),ar([be({type:String})],tr.prototype,"env",2),ar([be({type:String})],tr.prototype,"apiKey",2),ar([be({type:Boolean})],tr.prototype,"disableTracking",2),ar([be({type:String})],tr.prototype,"trackingSource",2),ar([be({type:Array})],tr.prototype,"controls",2),ar([be({type:String})],tr.prototype,"preload",2),ar([be({type:Boolean})],tr.prototype,"disableAutoplay",2),ar([be({type:Number})],tr.prototype,"aspectRatio",2),ar([mi()],tr.prototype,"open",2),tr=ar([ua("vouch-embed-dialog-portal")],tr);var xx=Object.defineProperty,Tx=Object.getOwnPropertyDescriptor,yr=(r,e,t,i)=>{for(var n=i>1?void 0:i?Tx(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(i?l(e,t,n):l(n))||n);return i&&n&&xx(e,t,n),n};Qt.DialogEmbed=class extends is{constructor(){super(...arguments),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="none",this.disableAutoplay=!1,this.aspectRatio=0,this._id=ks(),this._handleRootClick=()=>{this.dispatchEvent(new CustomEvent("dialogembed:click",{detail:this._id,bubbles:!0,composed:!0}))}}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this._handleRootClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this._handleRootClick)}render(){return Qe`
1694
+ <slot>
1695
+ <vmp-button size="large">Play</vmp-button>
1696
+ </slot>
1697
+ <vouch-embed-dialog-portal
1698
+ id=${this._id}
1699
+ ?autoplay=${!1}
1700
+ vouchId=${li(this.vouchId)}
1701
+ templateId=${li(this.templateId)}
1702
+ .questions=${this.questions}
1703
+ .controls=${this.controls}
1704
+ env=${li(this.env)}
1705
+ apiKey=${li(this.apiKey)}
1706
+ ?disableTracking=${this.disableTracking}
1707
+ trackingSource=${li(this.trackingSource)}
1708
+ preload=${li(this.preload)}
1709
+ aspectRatio=${this.aspectRatio}
1710
+ ></vouch-embed-dialog-portal>
1711
+ `}},Qt.DialogEmbed.styles=[ai`
1712
+ :host {
1713
+ --vu-button-padding: 10px 20px;
1714
+ --vu-button-background: #287179;
1715
+ --vu-button-background-hover: #4faab2;
1716
+
1717
+ display: flex;
1718
+ width: fit-content;
1719
+ height: fit-content;
1720
+ }
1721
+ `],yr([be({type:String})],Qt.DialogEmbed.prototype,"vouchId",2),yr([be({type:String})],Qt.DialogEmbed.prototype,"templateId",2),yr([be({type:Array})],Qt.DialogEmbed.prototype,"questions",2),yr([be({type:String})],Qt.DialogEmbed.prototype,"env",2),yr([be({type:String})],Qt.DialogEmbed.prototype,"apiKey",2),yr([be({type:Boolean})],Qt.DialogEmbed.prototype,"disableTracking",2),yr([be({type:String})],Qt.DialogEmbed.prototype,"trackingSource",2),yr([be({type:Array})],Qt.DialogEmbed.prototype,"controls",2),yr([be({type:String})],Qt.DialogEmbed.prototype,"preload",2),yr([be({type:Boolean})],Qt.DialogEmbed.prototype,"disableAutoplay",2),yr([be({type:Number})],Qt.DialogEmbed.prototype,"aspectRatio",2),Qt.DialogEmbed=yr([ua("vouch-embed-dialog")],Qt.DialogEmbed);function Wr(r){if(typeof r!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(r))}function qp(r,e){for(var t="",i=0,n=-1,a=0,l,h=0;h<=r.length;++h){if(h<r.length)l=r.charCodeAt(h);else{if(l===47)break;l=47}if(l===47){if(!(n===h-1||a===1))if(n!==h-1&&a===2){if(t.length<2||i!==2||t.charCodeAt(t.length-1)!==46||t.charCodeAt(t.length-2)!==46){if(t.length>2){var f=t.lastIndexOf("/");if(f!==t.length-1){f===-1?(t="",i=0):(t=t.slice(0,f),i=t.length-1-t.lastIndexOf("/")),n=h,a=0;continue}}else if(t.length===2||t.length===1){t="",i=0,n=h,a=0;continue}}e&&(t.length>0?t+="/..":t="..",i=2)}else t.length>0?t+="/"+r.slice(n+1,h):t=r.slice(n+1,h),i=h-n-1;n=h,a=0}else l===46&&a!==-1?++a:a=-1}return t}function kx(r,e){var t=e.dir||e.root,i=e.base||(e.name||"")+(e.ext||"");return t?t===e.root?t+i:t+r+i:i}var Vn={resolve:function(){for(var e="",t=!1,i,n=arguments.length-1;n>=-1&&!t;n--){var a;n>=0?a=arguments[n]:(i===void 0&&(i=process.cwd()),a=i),Wr(a),a.length!==0&&(e=a+"/"+e,t=a.charCodeAt(0)===47)}return e=qp(e,!t),t?e.length>0?"/"+e:"/":e.length>0?e:"."},normalize:function(e){if(Wr(e),e.length===0)return".";var t=e.charCodeAt(0)===47,i=e.charCodeAt(e.length-1)===47;return e=qp(e,!t),e.length===0&&!t&&(e="."),e.length>0&&i&&(e+="/"),t?"/"+e:e},isAbsolute:function(e){return Wr(e),e.length>0&&e.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var e,t=0;t<arguments.length;++t){var i=arguments[t];Wr(i),i.length>0&&(e===void 0?e=i:e+="/"+i)}return e===void 0?".":Vn.normalize(e)},relative:function(e,t){if(Wr(e),Wr(t),e===t||(e=Vn.resolve(e),t=Vn.resolve(t),e===t))return"";for(var i=1;i<e.length&&e.charCodeAt(i)===47;++i);for(var n=e.length,a=n-i,l=1;l<t.length&&t.charCodeAt(l)===47;++l);for(var h=t.length,f=h-l,p=a<f?a:f,m=-1,g=0;g<=p;++g){if(g===p){if(f>p){if(t.charCodeAt(l+g)===47)return t.slice(l+g+1);if(g===0)return t.slice(l+g)}else a>p&&(e.charCodeAt(i+g)===47?m=g:g===0&&(m=0));break}var A=e.charCodeAt(i+g),b=t.charCodeAt(l+g);if(A!==b)break;A===47&&(m=g)}var x="";for(g=i+m+1;g<=n;++g)(g===n||e.charCodeAt(g)===47)&&(x.length===0?x+="..":x+="/..");return x.length>0?x+t.slice(l+m):(l+=m,t.charCodeAt(l)===47&&++l,t.slice(l))},_makeLong:function(e){return e},dirname:function(e){if(Wr(e),e.length===0)return".";for(var t=e.charCodeAt(0),i=t===47,n=-1,a=!0,l=e.length-1;l>=1;--l)if(t=e.charCodeAt(l),t===47){if(!a){n=l;break}}else a=!1;return n===-1?i?"/":".":i&&n===1?"//":e.slice(0,n)},basename:function(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Wr(e);var i=0,n=-1,a=!0,l;if(t!==void 0&&t.length>0&&t.length<=e.length){if(t.length===e.length&&t===e)return"";var h=t.length-1,f=-1;for(l=e.length-1;l>=0;--l){var p=e.charCodeAt(l);if(p===47){if(!a){i=l+1;break}}else f===-1&&(a=!1,f=l+1),h>=0&&(p===t.charCodeAt(h)?--h===-1&&(n=l):(h=-1,n=f))}return i===n?n=f:n===-1&&(n=e.length),e.slice(i,n)}else{for(l=e.length-1;l>=0;--l)if(e.charCodeAt(l)===47){if(!a){i=l+1;break}}else n===-1&&(a=!1,n=l+1);return n===-1?"":e.slice(i,n)}},extname:function(e){Wr(e);for(var t=-1,i=0,n=-1,a=!0,l=0,h=e.length-1;h>=0;--h){var f=e.charCodeAt(h);if(f===47){if(!a){i=h+1;break}continue}n===-1&&(a=!1,n=h+1),f===46?t===-1?t=h:l!==1&&(l=1):t!==-1&&(l=-1)}return t===-1||n===-1||l===0||l===1&&t===n-1&&t===i+1?"":e.slice(t,n)},format:function(e){if(e===null||typeof e!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof e);return kx("/",e)},parse:function(e){Wr(e);var t={root:"",dir:"",base:"",ext:"",name:""};if(e.length===0)return t;var i=e.charCodeAt(0),n=i===47,a;n?(t.root="/",a=1):a=0;for(var l=-1,h=0,f=-1,p=!0,m=e.length-1,g=0;m>=a;--m){if(i=e.charCodeAt(m),i===47){if(!p){h=m+1;break}continue}f===-1&&(p=!1,f=m+1),i===46?l===-1?l=m:g!==1&&(g=1):l!==-1&&(g=-1)}return l===-1||f===-1||g===0||g===1&&l===f-1&&l===h+1?f!==-1&&(h===0&&n?t.base=t.name=e.slice(1,f):t.base=t.name=e.slice(h,f)):(h===0&&n?(t.name=e.slice(1,l),t.base=e.slice(1,f)):(t.name=e.slice(h,l),t.base=e.slice(h,f)),t.ext=e.slice(l,f)),h>0?t.dir=e.slice(0,h-1):n&&(t.dir="/"),t},sep:"/",delimiter:":",win32:null,posix:null};Vn.posix=Vn;var Sx=Vn;const{basename:Qp,extname:wx}=Sx;class _x{constructor(){let e=(()=>typeof ga>"u")(),t="image/png",i="image/jpeg",n="image/jpeg",a="image/webp",l="application/pdf",h="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:e?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:e?{png:t,jpg:i,jpeg:n,webp:a}:{png:t,jpg:i,jpeg:n,pdf:l,svg:h},mimes:e?{[t]:"png",[i]:"jpg",[a]:"webp"}:{[t]:"png",[i]:"jpg",[l]:"pdf",[h]:"svg"}})}toMime(e){return this.formats[(e||"").replace(/^\./,"").toLowerCase()]}fromMime(e){return this.mimes[e]}}function Rx(r,{filename:e="",extension:t="",format:k,page:n,quality:a,matte:l,density:h,outline:f,archive:b}={}){var{fromMime:m,toMime:g,expected:A}=new _x,b=b||"canvas",x=k||t.replace(/@\d+x$/i,"")||wx(e),k=m(g(x)||x),w=g(k),P=r.length;if(!x)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!k)throw new Error(`Unsupported file format "${x}" (expected ${A})`);if(!P)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let $,N,I=e.replace(/{(\d*)}/g,(K,U)=>(N=!0,U=parseInt(U,10),$=isFinite(U)?U:isFinite($)?$:-1,"{}")),O=n>0?n-1:n<0?P+n:void 0;if(isFinite(O)&&O<0||O>=P)throw new RangeError(P==1?`Canvas only has a ‘page 1’ (${O} is out of bounds)`:`Canvas has pages 1–${P} (${O} is out of bounds)`);if(r=isFinite(O)?[r[O]]:N||k=="pdf"?r:r.slice(-1),a===void 0)a=.92;else if(typeof a!="number"||!isFinite(a)||a<0||a>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(h===void 0){let K=(t||Qp(e,x)).match(/@(\d+)x$/i);h=K?parseInt(K[1],10):1}else if(typeof h!="number"||!Number.isInteger(h)||h<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:k=="svg"&&(f=!!f),{filename:e,pattern:I,format:k,mime:w,pages:r,padding:$,quality:a,matte:l,density:h,outline:f,archive:b}}class gl{static for(e){return new gl().append(e).get()}constructor(){this.crc=-1}get(){return~this.crc}append(e){for(var t=this.crc|0,i=this.table,n=0,a=e.length|0;n<a;n++)t=t>>>8^i[(t^e[n])&255];return this.crc=t,this}}gl.prototype.table=(()=>{var r,e,t,i=[];for(r=0;r<256;r++){for(t=r,e=0;e<8;e++)t=t&1?t>>>1^3988292384:t>>>1;i[r]=t}return i})();function Vu(r){let e=new Uint8Array(r),t=new DataView(e.buffer),i={array:e,view:t,size:r,set8(n,a){return t.setUint8(n,a),i},set16(n,a){return t.setUint16(n,a,!0),i},set32(n,a){return t.setUint32(n,a,!0),i},bytes(n,a){return e.set(a,n),i}};return i}const vl=class vl{constructor(e){let t=new Date;Object.assign(this,{directory:e,offset:0,files:[],time:(t.getHours()<<6|t.getMinutes())<<5|t.getSeconds()/2,date:(t.getFullYear()-1980<<4|t.getMonth()+1)<<5|t.getDate()}),this.add(e)}async add(e,t){let i=!t,n=vl.encoder.encode(`${this.directory}/${i?"":e}`),a=new Uint8Array(i?0:await t.arrayBuffer()),l=30+n.length,h=l+a.length,f=16,{offset:p}=this,m=Vu(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,gl.for(a)).set32(14,a.length).set32(18,a.length).set16(22,n.length);p+=l;let g=Vu(l+a.length+f).set32(0,67324752).bytes(4,m.array).bytes(30,n).bytes(l,a);p+=a.length,g.set32(h,134695760).bytes(h+4,m.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:n,header:m,payload:g}),this.offset=p}toBuffer(){let e=this.files.reduce((g,{name:A})=>46+A.length+g,0),t=Vu(e+22),i=0;for(var{offset:n,name:a,header:l,folder:h}of this.files)t.set32(i,33639248).set16(i+4,20).bytes(i+6,l.array).set8(i+38,h?16:0).set32(i+42,n).bytes(i+46,a),i+=46+a.length;t.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,e).set32(i+16,this.offset);let f=new Uint8Array(this.offset+t.size),p=0;for(var{payload:m}of this.files)f.set(m.array,p),p+=m.size;return f.set(t.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};bg(vl,"encoder",new TextEncoder);let Hu=vl;const Wu=(r,e,t,i)=>{if(i){let{width:n,height:a}=r,l=Object.assign(document.createElement("canvas"),{width:n,height:a}),h=l.getContext("2d");h.fillStyle=i,h.fillRect(0,0,n,a),h.drawImage(r,0,0),r=l}return new Promise((n,a)=>r.toBlob(n,e,t))},Lx=(...r)=>Wu(...r).then(e=>e.arrayBuffer()),Cx=async(r,e,t,i,n)=>{Jp(n,await Wu(r,e,t,i))},Ix=async(r,e,t,i,n,a,l)=>{let h=m=>a.replace("{}",String(m+1).padStart(l,"0")),f=Qp(n,".zip")||"archive",p=new Hu(f);await Promise.all(r.map(async(m,g)=>{let A=h(g);await p.add(A,await Wu(m,e,t,i))})),Jp(`${f}.zip`,p.blob)},Jp=(r,e)=>{const t=window.URL.createObjectURL(e),i=document.createElement("a");i.style.display="none",i.href=t,i.setAttribute("download",r),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(t),100)};var Dx={asBuffer:Lx,asDownload:Cx,asZipDownload:Ix,atScale:(r,e,t)=>r.map(i=>{if(e==1&&!t)return i.canvas;let n=document.createElement("canvas"),a=n.getContext("2d"),l=i.canvas?i.canvas:i;return n.width=l.width*e,n.height=l.height*e,t&&(a.fillStyle=t,a.fillRect(0,0,n.width,n.height)),a.scale(e,e),a.drawImage(l,0,0),n}),options:Rx};const{asBuffer:ju,asDownload:Ox,asZipDownload:Px,atScale:Ku,options:zu}=Dx,em=Symbol.for("toDataURL"),$x=r=>{let e=Object.assign(new tm,{crossOrigin:"Anonymous",src:r});return e.decode().then(()=>e)};class Fx{constructor(e,t){let i=document.createElement("canvas"),n=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[a,l]of Object.entries({png:()=>ju(i,"image/png"),jpg:()=>ju(i,"image/jpeg"),pages:()=>n.concat(i).map(h=>h.getContext("2d"))}))Object.defineProperty(i,a,{get:l});return Object.assign(i,{width:e,height:t,newPage(...h){var{width:p,height:m}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:m});f.getContext("2d").drawImage(i,0,0),n.push(f);var[p,m]=h.length?h:[p,m];return Object.assign(i,{width:p,height:m}).getContext("2d")},saveAs(h,f){f=typeof f=="number"?{quality:f}:f;let p=zu(this.pages,{filename:h,...f}),{pattern:m,padding:g,mime:A,quality:b,matte:x,density:k,archive:w}=p,P=Ku(p.pages,k);return g==null?Ox(P[0],A,b,x,h):Px(P,A,b,x,w,m,g)},toBuffer(h="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=zu(this.pages,{extension:h,...f}),{mime:m,quality:g,matte:A,pages:b,density:x}=p,k=Ku(b,x,A)[0];return ju(k,m,g,A)},[em]:i.toDataURL.bind(i),toDataURL(h="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=zu(this.pages,{extension:h,...f}),{mime:m,quality:g,matte:A,pages:b,density:x}=p,k=Ku(b,x,A)[0],w=k[k===i?em:"toDataURL"](m,g);return Promise.resolve(w)}})}}const{CanvasRenderingContext2D:Mx,CanvasGradient:Nx,CanvasPattern:Ux,Image:tm,ImageData:Bx,Path2D:Gx,DOMMatrix:Vx,DOMRect:Hx,DOMPoint:Wx}=window;var im={Canvas:Fx,loadImage:$x,CanvasRenderingContext2D:Mx,CanvasGradient:Nx,CanvasPattern:Ux,Image:tm,ImageData:Bx,Path2D:Gx,DOMMatrix:Vx,DOMRect:Hx,DOMPoint:Wx};const rm=es({__proto__:null,default:va(im)},[im]);return Object.defineProperty(Qt,Symbol.toStringTag,{value:"Module"}),Qt}({});
1722
+ //# sourceMappingURL=embed.iife.js.map