@vouchfor/embeds 0.0.0-experiment.75edba9 → 0.0.0-experiment.77214cd

Sign up to get free protection for your applications and to get access to all the features.
@@ -42,7 +42,7 @@ var Ak=Object.defineProperty;var Ek=(Oe,zr,Lr)=>zr in Oe?Ak(Oe,zr,{enumerable:!0
42
42
  * @license
43
43
  * Copyright 2017 Google LLC
44
44
  * SPDX-License-Identifier: BSD-3-Clause
45
- */function bi(n){return It({...n,state:!0,attribute:!1})}/**
45
+ */function ki(n){return It({...n,state:!0,attribute:!1})}/**
46
46
  * @license
47
47
  * Copyright 2018 Google LLC
48
48
  * SPDX-License-Identifier: BSD-3-Clause
@@ -74,20 +74,20 @@ var Ak=Object.defineProperty;var Ek=(Oe,zr,Lr)=>zr in Oe?Ak(Oe,zr,{enumerable:!0
74
74
  * @license
75
75
  * Copyright 2017 Google LLC
76
76
  * SPDX-License-Identifier: BSD-3-Clause
77
- */const kg=Symbol();class qa{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??wg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===kg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const wg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!Cl(e,t[i]));let Qa;const Sg=new Uint8Array(16);function Rg(){if(!Qa&&(Qa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Qa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Qa(Sg)}const Ai=[];for(let n=0;n<256;++n)Ai.push((n+256).toString(16).slice(1));function _g(n,t=0){return Ai[n[t+0]]+Ai[n[t+1]]+Ai[n[t+2]]+Ai[n[t+3]]+"-"+Ai[n[t+4]]+Ai[n[t+5]]+"-"+Ai[n[t+6]]+Ai[n[t+7]]+"-"+Ai[n[t+8]]+Ai[n[t+9]]+"-"+Ai[n[t+10]]+Ai[n[t+11]]+Ai[n[t+12]]+Ai[n[t+13]]+Ai[n[t+14]]+Ai[n[t+15]]}const Md={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qs(n,t,e){if(Md.randomUUID&&!t&&!n)return Md.randomUUID();n=n||{};const i=n.random||(n.rng||Rg)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return _g(i)}const $d="https://d2rxhdlm2q91uk.cloudfront.net",Lg="https://d1ix11aj5kfygl.cloudfront.net",Cg="https://d157jlwnudd93d.cloudfront.net",Nd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Ig="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",xg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",Dg="http://localhost:6060/v2",Pg="https://embed-dev.vouchfor.com/v2",Og="https://embed-staging.vouchfor.com/v2",Mg="https://embed.vouchfor.com/v2";function Ja(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:$d,publicApiUrl:Nd,embedApiUrl:Dg};if(n==="dev")return{videoUrl:$d,publicApiUrl:Nd,embedApiUrl:Pg};if(n==="staging")return{videoUrl:Lg,publicApiUrl:Ig,embedApiUrl:Og};if(n==="prod")return{videoUrl:Cg,publicApiUrl:xg,embedApiUrl:Mg}}class $g{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=Ja(e),c=qs(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:f==null?void 0:f.id})),((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=Ja(e),c=qs(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new qa(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),this._vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);this._vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId]),new qa(this.host,([e,i])=>{t.vouch=e?{...e,questions:{items:e==null?void 0:e.questions.items.filter((s,o)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(o+1)))}}:void 0},()=>[this._vouch,t.questions])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const Ng=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Fg(s,o)&&i||Object.defineProperty(n,e,o)},Fg=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Ug=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},Bg=(n,t)=>`/* Wrapped ${n}*/
77
+ */const kg=Symbol();class qa{get taskComplete(){return this.t||(this.status===1?this.t=new Promise((t,e)=>{this.i=t,this.o=e}):this.status===3?this.t=Promise.reject(this.h):this.t=Promise.resolve(this.l)),this.t}constructor(t,e,i){var o;this.u=0,this.status=0,(this.p=t).addController(this);const s=typeof e=="object"?e:{task:e,args:i};this._=s.task,this.v=s.args,this.j=s.argsEqual??wg,this.m=s.onComplete,this.g=s.onError,this.autoRun=s.autoRun??!0,"initialValue"in s&&(this.l=s.initialValue,this.status=2,this.k=(o=this.A)==null?void 0:o.call(this))}hostUpdate(){this.autoRun===!0&&this.O()}hostUpdated(){this.autoRun==="afterUpdate"&&this.O()}A(){if(this.v===void 0)return;const t=this.v();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async O(){const t=this.A(),e=this.k;this.k=t,t===e||t===void 0||e!==void 0&&this.j(e,t)||await this.run(t)}async run(t){var c,d,f,p,g;let e,i;t??(t=this.A()),this.k=t,this.status===1?(c=this.T)==null||c.abort():(this.t=void 0,this.i=void 0,this.o=void 0),this.status=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this.p.requestUpdate()):this.p.requestUpdate();const s=++this.u;this.T=new AbortController;let o=!1;try{e=await this._(t,{signal:this.T.signal})}catch(v){o=!0,i=v}if(this.u===s){if(e===kg)this.status=0;else{if(o===!1){try{(d=this.m)==null||d.call(this,e)}catch{}this.status=2,(f=this.i)==null||f.call(this,e)}else{try{(p=this.g)==null||p.call(this,i)}catch{}this.status=3,(g=this.o)==null||g.call(this,i)}this.l=e,this.h=i}this.p.requestUpdate()}}abort(t){var e;this.status===1&&((e=this.T)==null||e.abort(t))}get value(){return this.l}get error(){return this.h}render(t){var e,i,s,o;switch(this.status){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(i=t.pending)==null?void 0:i.call(t);case 2:return(s=t.complete)==null?void 0:s.call(t,this.value);case 3:return(o=t.error)==null?void 0:o.call(t,this.error);default:throw Error("Unexpected status: "+this.status)}}}const wg=(n,t)=>n===t||n.length===t.length&&n.every((e,i)=>!Cl(e,t[i]));let Qa;const Sg=new Uint8Array(16);function Rg(){if(!Qa&&(Qa=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Qa))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Qa(Sg)}const bi=[];for(let n=0;n<256;++n)bi.push((n+256).toString(16).slice(1));function _g(n,t=0){return bi[n[t+0]]+bi[n[t+1]]+bi[n[t+2]]+bi[n[t+3]]+"-"+bi[n[t+4]]+bi[n[t+5]]+"-"+bi[n[t+6]]+bi[n[t+7]]+"-"+bi[n[t+8]]+bi[n[t+9]]+"-"+bi[n[t+10]]+bi[n[t+11]]+bi[n[t+12]]+bi[n[t+13]]+bi[n[t+14]]+bi[n[t+15]]}const Md={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function qs(n,t,e){if(Md.randomUUID&&!t&&!n)return Md.randomUUID();n=n||{};const i=n.random||(n.rng||Rg)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){e=e||0;for(let s=0;s<16;++s)t[e+s]=i[s];return t}return _g(i)}const $d="https://d2rxhdlm2q91uk.cloudfront.net",Lg="https://d1ix11aj5kfygl.cloudfront.net",Cg="https://d157jlwnudd93d.cloudfront.net",Nd="https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev",Ig="https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging",xg="https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod",Dg="http://localhost:6060/v2",Pg="https://embed-dev.vouchfor.com/v2",Og="https://embed-staging.vouchfor.com/v2",Mg="https://embed.vouchfor.com/v2";function Ja(n){if(!["local","dev","staging","prod"].includes(n))throw new Error(`Unknown environment: ${n}`);if(n==="local")return{videoUrl:$d,publicApiUrl:Nd,embedApiUrl:Dg};if(n==="dev")return{videoUrl:$d,publicApiUrl:Nd,embedApiUrl:Pg};if(n==="staging")return{videoUrl:Lg,publicApiUrl:Ig,embedApiUrl:Og};if(n==="prod")return{videoUrl:Cg,publicApiUrl:xg,embedApiUrl:Mg}}class $g{constructor(t){this._fetching=!1,this.getVouch=async(e,i,s)=>{var g;const{embedApiUrl:o}=Ja(e),c=qs(),d=await fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return this.host.dispatchEvent(new CustomEvent("vouch:loaded",{detail:f==null?void 0:f.id})),((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/vouches/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.getTemplate=async(e,i,s)=>{var g;const{embedApiUrl:o}=Ja(e),c=qs(),d=await fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["X-Cache-Check",c]]}),f=await d.json();return((g=d==null?void 0:d.headers)==null?void 0:g.get("X-Cache-Check"))!==c&&fetch(`${o}/templates/${s}`,{method:"GET",headers:[["X-Api-Key",i],["Cache-Control","max-age=0"]]}),f},this.host=t,new qa(this.host,async([e,i,s,o,c])=>{var d,f,p,g;try{if(t.vouch=void 0,t.template=void 0,s){let v;c&&(this.fetching=!0,v=await this.getTemplate(e,i,c)),this._vouch=s,t.template=v??((f=(d=s==null?void 0:s.settings)==null?void 0:d.template)==null?void 0:f.instance)}else if(o){this.fetching=!0;const[v,b]=await Promise.all([this.getVouch(e,i,o),c?this.getTemplate(e,i,c):null]);this._vouch=v,t.template=b??((g=(p=v==null?void 0:v.settings)==null?void 0:p.template)==null?void 0:g.instance)}}finally{this.fetching=!1}},()=>[t.env,t.apiKey,t.data,t.vouchId,t.templateId]),new qa(this.host,([e,i])=>{t.vouch=e?{...e,questions:{items:e==null?void 0:e.questions.items.filter((s,o)=>!(i!=null&&i.length)||(i==null?void 0:i.includes(o+1)))}}:void 0},()=>[this._vouch,t.questions])}set fetching(t){this._fetching!==t&&(this._fetching=t,this.host.requestUpdate())}get fetching(){return this._fetching}}const Ng=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Fg(s,o)&&i||Object.defineProperty(n,e,o)},Fg=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Ug=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},Bg=(n,t)=>`/* Wrapped ${n}*/
78
78
  ${t}`,Gg=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),Hg=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Vg=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=Bg.bind(null,i,t.toString());Object.defineProperty(s,"name",Hg),Object.defineProperty(n,"toString",{...Gg,value:s})};function Wg(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))Ng(n,t,s,e);return Ug(n,t),Vg(n,t,i),n}const jg=new WeakMap;function ys(n,{cacheKey:t=([i])=>i,cache:e=new Map}={}){const i=new Map,s=function(...o){const c=t(o);if(i.has(c))return i.get(c);const d=(async()=>{try{if(e&&await e.has(c))return await e.get(c);const p=await n.apply(this,o);try{return p}finally{e&&await e.set(c,p)}}finally{i.delete(c)}})();return i.set(c,d),d};return Wg(s,n,{ignoreNonConfigurable:!0}),jg.set(s,e),s}var to=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Il(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var xl={exports:{}};(function(n,t){(function(e,i){i(t)})(to,function(e){function i($){var U,Z,ft=new Error($);return U=ft,Z=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(U,Z):U.__proto__=Z,ft}function s($,U,Z){var ft=U.slice(0,Z).split(/\n/),bt=ft.length,xt=ft[bt-1].length+1;throw i($+=" at line "+bt+" col "+xt+`:
79
79
 
80
80
  `+U.split(/\n/)[bt-1]+`
81
81
  `+Array(xt).join(" ")+"^")}i.prototype=Object.create(Error.prototype,{name:{value:"Squirrelly Error",enumerable:!1}});var o=new Function("return this")().Promise,c=!1;try{c=new Function("return (async function(){}).constructor")()}catch($){if(!($ instanceof SyntaxError))throw $}function d($,U){return Object.prototype.hasOwnProperty.call($,U)}function f($,U,Z){for(var ft in U)d(U,ft)&&(U[ft]==null||typeof U[ft]!="object"||ft!=="storage"&&ft!=="prefixes"||Z?$[ft]=U[ft]:$[ft]=f({},U[ft]));return $}var p=/^async +/,g=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,v=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,b=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g,E=/[.*+\-?^${}()|[\]\\]/g;function T($){return E.test($)?$.replace(E,"\\$&"):$}function w($,U){U.rmWhitespace&&($=$.replace(/[\r\n]+/g,`
82
- `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,b.lastIndex=0;var Z=U.prefixes,ft=[Z.h,Z.b,Z.i,Z.r,Z.c,Z.e].reduce(function(be,jt){return be&&jt?be+"|"+T(jt):jt?T(jt):be},""),bt=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(U.tags[1])+")","g"),xt=new RegExp("([^]*?)"+T(U.tags[0])+"(-|_)?\\s*("+ft+")?\\s*","g"),Ut=0,Qt=!1;function ue(be,jt){var ge,oe={f:[]},Ce=0,Ft="c";function Ze(ei){var Xi=$.slice(Ut,ei),Ne=Xi.trim();if(Ft==="f")Ne==="safe"?oe.raw=!0:U.async&&p.test(Ne)?(Ne=Ne.replace(p,""),oe.f.push([Ne,"",!0])):oe.f.push([Ne,""]);else if(Ft==="fp")oe.f[oe.f.length-1][1]+=Ne;else if(Ft==="err"){if(Ne){var Ci=Xi.search(/\S/);s("invalid syntax",$,Ut+Ci)}}else oe[Ft]=Ne;Ut=ei+1}for(jt==="h"||jt==="b"||jt==="c"?Ft="n":jt==="r"&&(oe.raw=!0,jt="i"),bt.lastIndex=Ut;(ge=bt.exec($))!==null;){var qe=ge[1],$i=ge[2],Tr=ge[3],ke=ge[4],li=ge[5],me=ge.index;if(qe)qe==="("?(Ce===0&&(Ft==="n"?(Ze(me),Ft="p"):Ft==="f"&&(Ze(me),Ft="fp")),Ce++):qe===")"?--Ce===0&&Ft!=="c"&&(Ze(me),Ft="err"):Ce===0&&qe==="|"?(Ze(me),Ft="f"):qe==="=>"&&(Ze(me),Ut+=1,Ft="res");else if($i)if($i==="/*"){var ti=$.indexOf("*/",bt.lastIndex);ti===-1&&s("unclosed comment",$,ge.index),bt.lastIndex=ti+2}else $i==="'"?(v.lastIndex=ge.index,v.exec($)?bt.lastIndex=v.lastIndex:s("unclosed string",$,ge.index)):$i==='"'?(b.lastIndex=ge.index,b.exec($)?bt.lastIndex=b.lastIndex:s("unclosed string",$,ge.index)):$i==="`"&&(g.lastIndex=ge.index,g.exec($)?bt.lastIndex=g.lastIndex:s("unclosed string",$,ge.index));else if(Tr)return Ze(me),Ut=me+ge[0].length,xt.lastIndex=Ut,Qt=li,ke&&jt==="h"&&(jt="s"),oe.t=jt,oe}return s("unclosed tag",$,be),oe}var se=function be(jt,ge){jt.b=[],jt.d=[];var oe,Ce=!1,Ft=[];function Ze(Ci,ss){Ci&&(Ci=function(ci,kr,_s,Ls){var ir,ct;return typeof kr.autoTrim=="string"?ir=ct=kr.autoTrim:Array.isArray(kr.autoTrim)&&(ir=kr.autoTrim[1],ct=kr.autoTrim[0]),(_s||_s===!1)&&(ir=_s),(Ls||Ls===!1)&&(ct=Ls),ir==="slurp"&&ct==="slurp"?ci.trim():(ir==="_"||ir==="slurp"?ci=String.prototype.trimLeft?ci.trimLeft():ci.replace(/^[\s\uFEFF\xA0]+/,""):ir!=="-"&&ir!=="nl"||(ci=ci.replace(/^(?:\n|\r|\r\n)/,"")),ct==="_"||ct==="slurp"?ci=String.prototype.trimRight?ci.trimRight():ci.replace(/[\s\uFEFF\xA0]+$/,""):ct!=="-"&&ct!=="nl"||(ci=ci.replace(/(?:\n|\r|\r\n)$/,"")),ci)}(Ci,U,Qt,ss))&&(Ci=Ci.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ft.push(Ci))}for(;(oe=xt.exec($))!==null;){var qe,$i=oe[1],Tr=oe[2],ke=oe[3]||"";for(var li in Z)if(Z[li]===ke){qe=li;break}Ze($i,Tr),Ut=oe.index+oe[0].length,qe||s("unrecognized tag type: "+ke,$,Ut);var me=ue(oe.index,qe),ti=me.t;if(ti==="h"){var ei=me.n||"";U.async&&p.test(ei)&&(me.a=!0,me.n=ei.replace(p,"")),me=be(me),Ft.push(me)}else if(ti==="c"){if(jt.n===me.n)return Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft,jt;s("Helper start and end don't match",$,oe.index+oe[0].length)}else if(ti==="b"){Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft;var Xi=me.n||"";U.async&&p.test(Xi)&&(me.a=!0,me.n=Xi.replace(p,"")),Ce=me,Ft=[]}else if(ti==="s"){var Ne=me.n||"";U.async&&p.test(Ne)&&(me.a=!0,me.n=Ne.replace(p,"")),Ft.push(me)}else Ft.push(me)}if(!ge)throw i('unclosed helper "'+jt.n+'"');return Ze($.slice(Ut,$.length),!1),jt.d=Ft,jt}({f:[]},!0);if(U.plugins)for(var Yt=0;Yt<U.plugins.length;Yt++){var Me=U.plugins[Yt];Me.processAST&&(se.d=Me.processAST(se.d,U))}return se.d}function C($,U){var Z=w($,U),ft="var tR='';"+(U.useWith?"with("+U.varName+"||{}){":"")+N(Z,U)+"if(cb){cb(null,tR)} return tR"+(U.useWith?"}":"");if(U.plugins)for(var bt=0;bt<U.plugins.length;bt++){var xt=U.plugins[bt];xt.processFnString&&(ft=xt.processFnString(ft,U))}return ft}function D($,U){for(var Z=0;Z<U.length;Z++){var ft=U[Z][0],bt=U[Z][1];$=(U[Z][2]?"await ":"")+"c.l('F','"+ft+"')("+$,bt&&($+=","+bt),$+=")"}return $}function O($,U,Z,ft,bt,xt){var Ut="{exec:"+(bt?"async ":"")+x(Z,U,$)+",params:["+ft+"]";return xt&&(Ut+=",name:'"+xt+"'"),bt&&(Ut+=",async:true"),Ut+="}"}function F($,U){for(var Z="[",ft=0;ft<$.length;ft++){var bt=$[ft];Z+=O(U,bt.res||"",bt.d,bt.p||"",bt.a,bt.n),ft<$.length&&(Z+=",")}return Z+="]"}function x($,U,Z){return"function("+U+"){var tR='';"+N($,Z)+"return tR}"}function N($,U){for(var Z=0,ft=$.length,bt="";Z<ft;Z++){var xt=$[Z];if(typeof xt=="string")bt+="tR+='"+xt+"';";else{var Ut=xt.t,Qt=xt.c||"",ue=xt.f,se=xt.n||"",Yt=xt.p||"",Me=xt.res||"",be=xt.b,jt=!!xt.a;if(Ut==="i"){U.defaultFilter&&(Qt="c.l('F','"+U.defaultFilter+"')("+Qt+")");var ge=D(Qt,ue);!xt.raw&&U.autoEscape&&(ge="c.l('F','e')("+ge+")"),bt+="tR+="+ge+";"}else if(Ut==="h")if(U.storage.nativeHelpers.get(se))bt+=U.storage.nativeHelpers.get(se)(xt,U);else{var oe=(jt?"await ":"")+"c.l('H','"+se+"')("+O(U,Me,xt.d,Yt,jt);oe+=be?","+F(be,U):",[]",bt+="tR+="+D(oe+=",c)",ue)+";"}else Ut==="s"?bt+="tR+="+D((jt?"await ":"")+"c.l('H','"+se+"')({params:["+Yt+"]},[],c)",ue)+";":Ut==="e"&&(bt+=Qt+`
82
+ `).replace(/^\s+|\s+$/gm,"")),g.lastIndex=0,v.lastIndex=0,b.lastIndex=0;var Z=U.prefixes,ft=[Z.h,Z.b,Z.i,Z.r,Z.c,Z.e].reduce(function(be,jt){return be&&jt?be+"|"+T(jt):jt?T(jt):be},""),bt=new RegExp("([|()]|=>)|('|\"|`|\\/\\*)|\\s*((\\/)?(-|_)?"+T(U.tags[1])+")","g"),xt=new RegExp("([^]*?)"+T(U.tags[0])+"(-|_)?\\s*("+ft+")?\\s*","g"),Ut=0,Qt=!1;function ue(be,jt){var ge,oe={f:[]},Ce=0,Ft="c";function Xe(ti){var Xi=$.slice(Ut,ti),Ne=Xi.trim();if(Ft==="f")Ne==="safe"?oe.raw=!0:U.async&&p.test(Ne)?(Ne=Ne.replace(p,""),oe.f.push([Ne,"",!0])):oe.f.push([Ne,""]);else if(Ft==="fp")oe.f[oe.f.length-1][1]+=Ne;else if(Ft==="err"){if(Ne){var Ci=Xi.search(/\S/);s("invalid syntax",$,Ut+Ci)}}else oe[Ft]=Ne;Ut=ti+1}for(jt==="h"||jt==="b"||jt==="c"?Ft="n":jt==="r"&&(oe.raw=!0,jt="i"),bt.lastIndex=Ut;(ge=bt.exec($))!==null;){var qe=ge[1],$i=ge[2],Tr=ge[3],ke=ge[4],li=ge[5],me=ge.index;if(qe)qe==="("?(Ce===0&&(Ft==="n"?(Xe(me),Ft="p"):Ft==="f"&&(Xe(me),Ft="fp")),Ce++):qe===")"?--Ce===0&&Ft!=="c"&&(Xe(me),Ft="err"):Ce===0&&qe==="|"?(Xe(me),Ft="f"):qe==="=>"&&(Xe(me),Ut+=1,Ft="res");else if($i)if($i==="/*"){var Je=$.indexOf("*/",bt.lastIndex);Je===-1&&s("unclosed comment",$,ge.index),bt.lastIndex=Je+2}else $i==="'"?(v.lastIndex=ge.index,v.exec($)?bt.lastIndex=v.lastIndex:s("unclosed string",$,ge.index)):$i==='"'?(b.lastIndex=ge.index,b.exec($)?bt.lastIndex=b.lastIndex:s("unclosed string",$,ge.index)):$i==="`"&&(g.lastIndex=ge.index,g.exec($)?bt.lastIndex=g.lastIndex:s("unclosed string",$,ge.index));else if(Tr)return Xe(me),Ut=me+ge[0].length,xt.lastIndex=Ut,Qt=li,ke&&jt==="h"&&(jt="s"),oe.t=jt,oe}return s("unclosed tag",$,be),oe}var se=function be(jt,ge){jt.b=[],jt.d=[];var oe,Ce=!1,Ft=[];function Xe(Ci,ss){Ci&&(Ci=function(ci,kr,_s,Ls){var ir,ct;return typeof kr.autoTrim=="string"?ir=ct=kr.autoTrim:Array.isArray(kr.autoTrim)&&(ir=kr.autoTrim[1],ct=kr.autoTrim[0]),(_s||_s===!1)&&(ir=_s),(Ls||Ls===!1)&&(ct=Ls),ir==="slurp"&&ct==="slurp"?ci.trim():(ir==="_"||ir==="slurp"?ci=String.prototype.trimLeft?ci.trimLeft():ci.replace(/^[\s\uFEFF\xA0]+/,""):ir!=="-"&&ir!=="nl"||(ci=ci.replace(/^(?:\n|\r|\r\n)/,"")),ct==="_"||ct==="slurp"?ci=String.prototype.trimRight?ci.trimRight():ci.replace(/[\s\uFEFF\xA0]+$/,""):ct!=="-"&&ct!=="nl"||(ci=ci.replace(/(?:\n|\r|\r\n)$/,"")),ci)}(Ci,U,Qt,ss))&&(Ci=Ci.replace(/\\|'/g,"\\$&").replace(/\r\n|\n|\r/g,"\\n"),Ft.push(Ci))}for(;(oe=xt.exec($))!==null;){var qe,$i=oe[1],Tr=oe[2],ke=oe[3]||"";for(var li in Z)if(Z[li]===ke){qe=li;break}Xe($i,Tr),Ut=oe.index+oe[0].length,qe||s("unrecognized tag type: "+ke,$,Ut);var me=ue(oe.index,qe),Je=me.t;if(Je==="h"){var ti=me.n||"";U.async&&p.test(ti)&&(me.a=!0,me.n=ti.replace(p,"")),me=be(me),Ft.push(me)}else if(Je==="c"){if(jt.n===me.n)return Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft,jt;s("Helper start and end don't match",$,oe.index+oe[0].length)}else if(Je==="b"){Ce?(Ce.d=Ft,jt.b.push(Ce)):jt.d=Ft;var Xi=me.n||"";U.async&&p.test(Xi)&&(me.a=!0,me.n=Xi.replace(p,"")),Ce=me,Ft=[]}else if(Je==="s"){var Ne=me.n||"";U.async&&p.test(Ne)&&(me.a=!0,me.n=Ne.replace(p,"")),Ft.push(me)}else Ft.push(me)}if(!ge)throw i('unclosed helper "'+jt.n+'"');return Xe($.slice(Ut,$.length),!1),jt.d=Ft,jt}({f:[]},!0);if(U.plugins)for(var Yt=0;Yt<U.plugins.length;Yt++){var Me=U.plugins[Yt];Me.processAST&&(se.d=Me.processAST(se.d,U))}return se.d}function C($,U){var Z=w($,U),ft="var tR='';"+(U.useWith?"with("+U.varName+"||{}){":"")+N(Z,U)+"if(cb){cb(null,tR)} return tR"+(U.useWith?"}":"");if(U.plugins)for(var bt=0;bt<U.plugins.length;bt++){var xt=U.plugins[bt];xt.processFnString&&(ft=xt.processFnString(ft,U))}return ft}function D($,U){for(var Z=0;Z<U.length;Z++){var ft=U[Z][0],bt=U[Z][1];$=(U[Z][2]?"await ":"")+"c.l('F','"+ft+"')("+$,bt&&($+=","+bt),$+=")"}return $}function O($,U,Z,ft,bt,xt){var Ut="{exec:"+(bt?"async ":"")+x(Z,U,$)+",params:["+ft+"]";return xt&&(Ut+=",name:'"+xt+"'"),bt&&(Ut+=",async:true"),Ut+="}"}function F($,U){for(var Z="[",ft=0;ft<$.length;ft++){var bt=$[ft];Z+=O(U,bt.res||"",bt.d,bt.p||"",bt.a,bt.n),ft<$.length&&(Z+=",")}return Z+="]"}function x($,U,Z){return"function("+U+"){var tR='';"+N($,Z)+"return tR}"}function N($,U){for(var Z=0,ft=$.length,bt="";Z<ft;Z++){var xt=$[Z];if(typeof xt=="string")bt+="tR+='"+xt+"';";else{var Ut=xt.t,Qt=xt.c||"",ue=xt.f,se=xt.n||"",Yt=xt.p||"",Me=xt.res||"",be=xt.b,jt=!!xt.a;if(Ut==="i"){U.defaultFilter&&(Qt="c.l('F','"+U.defaultFilter+"')("+Qt+")");var ge=D(Qt,ue);!xt.raw&&U.autoEscape&&(ge="c.l('F','e')("+ge+")"),bt+="tR+="+ge+";"}else if(Ut==="h")if(U.storage.nativeHelpers.get(se))bt+=U.storage.nativeHelpers.get(se)(xt,U);else{var oe=(jt?"await ":"")+"c.l('H','"+se+"')("+O(U,Me,xt.d,Yt,jt);oe+=be?","+F(be,U):",[]",bt+="tR+="+D(oe+=",c)",ue)+";"}else Ut==="s"?bt+="tR+="+D((jt?"await ":"")+"c.l('H','"+se+"')({params:["+Yt+"]},[],c)",ue)+";":Ut==="e"&&(bt+=Qt+`
83
83
  `)}}return bt}var H=function(){function $(U){this.cache=U}return $.prototype.define=function(U,Z){this.cache[U]=Z},$.prototype.get=function(U){return this.cache[U]},$.prototype.remove=function(U){delete this.cache[U]},$.prototype.reset=function(){this.cache={}},$.prototype.load=function(U){f(this.cache,U,!0)},$}();function j($,U,Z,ft){if(U&&U.length>0)throw i((ft?"Native":"")+"Helper '"+$+"' doesn't accept blocks");if(Z&&Z.length>0)throw i((ft?"Native":"")+"Helper '"+$+"' doesn't accept filters")}var nt={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function st($){return nt[$]}var Q=new H({}),kt=new H({each:function($,U){var Z="",ft=$.params[0];if(j("each",U,!1),$.async)return new Promise(function(xt){(function Ut(Qt,ue,se,Yt,Me){se(Qt[ue],ue).then(function(be){Yt+=be,ue===Qt.length-1?Me(Yt):Ut(Qt,ue+1,se,Yt,Me)})})(ft,0,$.exec,Z,xt)});for(var bt=0;bt<ft.length;bt++)Z+=$.exec(ft[bt],bt);return Z},foreach:function($,U){var Z=$.params[0];if(j("foreach",U,!1),$.async)return new Promise(function(xt){(function Ut(Qt,ue,se,Yt,Me,be){Yt(ue[se],Qt[ue[se]]).then(function(jt){Me+=jt,se===ue.length-1?be(Me):Ut(Qt,ue,se+1,Yt,Me,be)})})(Z,Object.keys(Z),0,$.exec,"",xt)});var ft="";for(var bt in Z)d(Z,bt)&&(ft+=$.exec(bt,Z[bt]));return ft},include:function($,U,Z){j("include",U,!1);var ft=Z.storage.templates.get($.params[0]);if(!ft)throw i('Could not fetch template "'+$.params[0]+'"');return ft($.params[1],Z)},extends:function($,U,Z){var ft=$.params[1]||{};ft.content=$.exec();for(var bt=0;bt<U.length;bt++){var xt=U[bt];ft[xt.name]=xt.exec()}var Ut=Z.storage.templates.get($.params[0]);if(!Ut)throw i('Could not fetch template "'+$.params[0]+'"');return Ut(ft,Z)},useScope:function($,U){return j("useScope",U,!1),$.exec($.params[0])}}),gt=new H({if:function($,U){j("if",!1,$.f,!0);var Z="if("+$.p+"){"+N($.d,U)+"}";if($.b)for(var ft=0;ft<$.b.length;ft++){var bt=$.b[ft];bt.n==="else"?Z+="else{"+N(bt.d,U)+"}":bt.n==="elif"&&(Z+="else if("+bt.p+"){"+N(bt.d,U)+"}")}return Z},try:function($,U){if(j("try",!1,$.f,!0),!$.b||$.b.length!==1||$.b[0].n!=="catch")throw i("native helper 'try' only accepts 1 block, 'catch'");var Z="try{"+N($.d,U)+"}",ft=$.b[0];return Z+="catch"+(ft.res?"("+ft.res+")":"")+"{"+N(ft.d,U)+"}"},block:function($,U){return j("block",$.b,$.f,!0),"if(!"+U.varName+"["+$.p+"]){tR+=("+x($.d,"",U)+")()}else{tR+="+U.varName+"["+$.p+"]}"}}),Mt=new H({e:function($){var U=String($);return/[&<>"']/.test(U)?U.replace(/[&<>"']/g,st):U}}),Vt={varName:"it",autoTrim:[!1,"nl"],autoEscape:!0,defaultFilter:!1,tags:["{{","}}"],l:function($,U){if($==="H"){var Z=this.storage.helpers.get(U);if(Z)return Z;throw i("Can't find helper '"+U+"'")}if($==="F"){var ft=this.storage.filters.get(U);if(ft)return ft;throw i("Can't find filter '"+U+"'")}},async:!1,storage:{helpers:kt,nativeHelpers:gt,filters:Mt,templates:Q},prefixes:{h:"@",b:"#",i:"",r:"*",c:"/",e:"!"},cache:!1,plugins:[],useWith:!1};function V($,U){var Z={};return f(Z,Vt),U&&f(Z,U),$&&f(Z,$),Z.l.bind(Z),Z}function J($,U){var Z=V(U||{}),ft=Function;if(Z.async){if(!c)throw i("This environment doesn't support async/await");ft=c}try{return new ft(Z.varName,"c","cb",C($,Z))}catch(bt){throw bt instanceof SyntaxError?i(`Bad template syntax
84
84
 
85
85
  `+bt.message+`
86
86
  `+Array(bt.message.length+1).join("=")+`
87
87
  `+C($,Z)):bt}}function St($,U){var Z;return U.cache&&U.name&&U.storage.templates.get(U.name)?U.storage.templates.get(U.name):(Z=typeof $=="function"?$:J($,U),U.cache&&U.name&&U.storage.templates.define(U.name,Z),Z)}Vt.l.bind(Vt),e.compile=J,e.compileScope=N,e.compileScopeIntoFunction=x,e.compileToString=C,e.defaultConfig=Vt,e.filters=Mt,e.getConfig=V,e.helpers=kt,e.nativeHelpers=gt,e.parse=w,e.render=function($,U,Z,ft){var bt=V(Z||{});if(!bt.async)return St($,bt)(U,bt);if(!ft){if(typeof o=="function")return new o(function(xt,Ut){try{xt(St($,bt)(U,bt))}catch(Qt){Ut(Qt)}});throw i("Please provide a callback function, this env doesn't support Promises")}try{St($,bt)(U,bt,ft)}catch(xt){return ft(xt)}},e.templates=Q,Object.defineProperty(e,"__esModule",{value:!0})})})(xl,xl.exports);var Qs=xl.exports,Dl={exports:{}};(function(n,t){var e=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof to<"u"&&to,i=function(){function o(){this.fetch=!1,this.DOMException=e.DOMException}return o.prototype=e,new o}();(function(o){(function(c){var d=typeof o<"u"&&o||typeof self<"u"&&self||typeof d<"u"&&d,f={searchParams:"URLSearchParams"in d,iterable:"Symbol"in d&&"iterator"in Symbol,blob:"FileReader"in d&&"Blob"in d&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in d,arrayBuffer:"ArrayBuffer"in d};function p(V){return V&&DataView.prototype.isPrototypeOf(V)}if(f.arrayBuffer)var g=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(V){return V&&g.indexOf(Object.prototype.toString.call(V))>-1};function b(V){if(typeof V!="string"&&(V=String(V)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(V)||V==="")throw new TypeError('Invalid character in header field name: "'+V+'"');return V.toLowerCase()}function E(V){return typeof V!="string"&&(V=String(V)),V}function T(V){var J={next:function(){var St=V.shift();return{done:St===void 0,value:St}}};return f.iterable&&(J[Symbol.iterator]=function(){return J}),J}function w(V){this.map={},V instanceof w?V.forEach(function(J,St){this.append(St,J)},this):Array.isArray(V)?V.forEach(function(J){this.append(J[0],J[1])},this):V&&Object.getOwnPropertyNames(V).forEach(function(J){this.append(J,V[J])},this)}w.prototype.append=function(V,J){V=b(V),J=E(J);var St=this.map[V];this.map[V]=St?St+", "+J:J},w.prototype.delete=function(V){delete this.map[b(V)]},w.prototype.get=function(V){return V=b(V),this.has(V)?this.map[V]:null},w.prototype.has=function(V){return this.map.hasOwnProperty(b(V))},w.prototype.set=function(V,J){this.map[b(V)]=E(J)},w.prototype.forEach=function(V,J){for(var St in this.map)this.map.hasOwnProperty(St)&&V.call(J,this.map[St],St,this)},w.prototype.keys=function(){var V=[];return this.forEach(function(J,St){V.push(St)}),T(V)},w.prototype.values=function(){var V=[];return this.forEach(function(J){V.push(J)}),T(V)},w.prototype.entries=function(){var V=[];return this.forEach(function(J,St){V.push([St,J])}),T(V)},f.iterable&&(w.prototype[Symbol.iterator]=w.prototype.entries);function C(V){if(V.bodyUsed)return Promise.reject(new TypeError("Already read"));V.bodyUsed=!0}function D(V){return new Promise(function(J,St){V.onload=function(){J(V.result)},V.onerror=function(){St(V.error)}})}function O(V){var J=new FileReader,St=D(J);return J.readAsArrayBuffer(V),St}function F(V){var J=new FileReader,St=D(J);return J.readAsText(V),St}function x(V){for(var J=new Uint8Array(V),St=new Array(J.length),$=0;$<J.length;$++)St[$]=String.fromCharCode(J[$]);return St.join("")}function N(V){if(V.slice)return V.slice(0);var J=new Uint8Array(V.byteLength);return J.set(new Uint8Array(V)),J.buffer}function H(){return this.bodyUsed=!1,this._initBody=function(V){this.bodyUsed=this.bodyUsed,this._bodyInit=V,V?typeof V=="string"?this._bodyText=V:f.blob&&Blob.prototype.isPrototypeOf(V)?this._bodyBlob=V:f.formData&&FormData.prototype.isPrototypeOf(V)?this._bodyFormData=V:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)?this._bodyText=V.toString():f.arrayBuffer&&f.blob&&p(V)?(this._bodyArrayBuffer=N(V.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(V)||v(V))?this._bodyArrayBuffer=N(V):this._bodyText=V=Object.prototype.toString.call(V):this._bodyText="",this.headers.get("content-type")||(typeof V=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(V)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var V=C(this);if(V)return V;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var V=C(this);return V||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else return this.blob().then(O)}),this.text=function(){var V=C(this);if(V)return V;if(this._bodyBlob)return F(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(x(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(Q)}),this.json=function(){return this.text().then(JSON.parse)},this}var j=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function nt(V){var J=V.toUpperCase();return j.indexOf(J)>-1?J:V}function st(V,J){if(!(this instanceof st))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J=J||{};var St=J.body;if(V instanceof st){if(V.bodyUsed)throw new TypeError("Already read");this.url=V.url,this.credentials=V.credentials,J.headers||(this.headers=new w(V.headers)),this.method=V.method,this.mode=V.mode,this.signal=V.signal,!St&&V._bodyInit!=null&&(St=V._bodyInit,V.bodyUsed=!0)}else this.url=String(V);if(this.credentials=J.credentials||this.credentials||"same-origin",(J.headers||!this.headers)&&(this.headers=new w(J.headers)),this.method=nt(J.method||this.method||"GET"),this.mode=J.mode||this.mode||null,this.signal=J.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&St)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(St),(this.method==="GET"||this.method==="HEAD")&&(J.cache==="no-store"||J.cache==="no-cache")){var $=/([?&])_=[^&]*/;if($.test(this.url))this.url=this.url.replace($,"$1_="+new Date().getTime());else{var U=/\?/;this.url+=(U.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}st.prototype.clone=function(){return new st(this,{body:this._bodyInit})};function Q(V){var J=new FormData;return V.trim().split("&").forEach(function(St){if(St){var $=St.split("="),U=$.shift().replace(/\+/g," "),Z=$.join("=").replace(/\+/g," ");J.append(decodeURIComponent(U),decodeURIComponent(Z))}}),J}function kt(V){var J=new w,St=V.replace(/\r?\n[\t ]+/g," ");return St.split("\r").map(function($){return $.indexOf(`
88
88
  `)===0?$.substr(1,$.length):$}).forEach(function($){var U=$.split(":"),Z=U.shift().trim();if(Z){var ft=U.join(":").trim();J.append(Z,ft)}}),J}H.call(st.prototype);function gt(V,J){if(!(this instanceof gt))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');J||(J={}),this.type="default",this.status=J.status===void 0?200:J.status,this.ok=this.status>=200&&this.status<300,this.statusText=J.statusText===void 0?"":""+J.statusText,this.headers=new w(J.headers),this.url=J.url||"",this._initBody(V)}H.call(gt.prototype),gt.prototype.clone=function(){return new gt(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new w(this.headers),url:this.url})},gt.error=function(){var V=new gt(null,{status:0,statusText:""});return V.type="error",V};var Mt=[301,302,303,307,308];gt.redirect=function(V,J){if(Mt.indexOf(J)===-1)throw new RangeError("Invalid status code");return new gt(null,{status:J,headers:{location:V}})},c.DOMException=d.DOMException;try{new c.DOMException}catch{c.DOMException=function(J,St){this.message=J,this.name=St;var $=Error(J);this.stack=$.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function Vt(V,J){return new Promise(function(St,$){var U=new st(V,J);if(U.signal&&U.signal.aborted)return $(new c.DOMException("Aborted","AbortError"));var Z=new XMLHttpRequest;function ft(){Z.abort()}Z.onload=function(){var xt={status:Z.status,statusText:Z.statusText,headers:kt(Z.getAllResponseHeaders()||"")};xt.url="responseURL"in Z?Z.responseURL:xt.headers.get("X-Request-URL");var Ut="response"in Z?Z.response:Z.responseText;setTimeout(function(){St(new gt(Ut,xt))},0)},Z.onerror=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},Z.ontimeout=function(){setTimeout(function(){$(new TypeError("Network request failed"))},0)},Z.onabort=function(){setTimeout(function(){$(new c.DOMException("Aborted","AbortError"))},0)};function bt(xt){try{return xt===""&&d.location.href?d.location.href:xt}catch{return xt}}Z.open(U.method,bt(U.url),!0),U.credentials==="include"?Z.withCredentials=!0:U.credentials==="omit"&&(Z.withCredentials=!1),"responseType"in Z&&(f.blob?Z.responseType="blob":f.arrayBuffer&&U.headers.get("Content-Type")&&U.headers.get("Content-Type").indexOf("application/octet-stream")!==-1&&(Z.responseType="arraybuffer")),J&&typeof J.headers=="object"&&!(J.headers instanceof w)?Object.getOwnPropertyNames(J.headers).forEach(function(xt){Z.setRequestHeader(xt,E(J.headers[xt]))}):U.headers.forEach(function(xt,Ut){Z.setRequestHeader(Ut,xt)}),U.signal&&(U.signal.addEventListener("abort",ft),Z.onreadystatechange=function(){Z.readyState===4&&U.signal.removeEventListener("abort",ft)}),Z.send(typeof U._bodyInit>"u"?null:U._bodyInit)})}return Vt.polyfill=!0,d.fetch||(d.fetch=Vt,d.Headers=w,d.Request=st,d.Response=gt),c.Headers=w,c.Request=st,c.Response=gt,c.fetch=Vt,c})({})})(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var s=e.fetch?e:i;t=s.fetch,t.default=s.fetch,t.fetch=s.fetch,t.Headers=s.Headers,t.Request=s.Request,t.Response=s.Response,n.exports=t})(Dl,Dl.exports);var Kg=Dl.exports;const zg=Il(Kg);function Pl({canvas:n,scenes:t,currentTime:e}){if(t&&n){const i=t.scenes.filter(({start:o,duration:c})=>e>=o&&e<=o+c);if(i.length<=0)return;const s=n.getContext("2d");if(s){const o=t.transitionDuration,c=Math.max(...t.scenes.map(({start:d,duration:f})=>d+f));s.globalCompositeOperation="lighter",s.clearRect(0,0,n.width,n.height),i.forEach(({start:d,duration:f,draw:p,transitionCanvas:g})=>{s.globalAlpha=1,g.width=g.height=0,g.width=n.width,g.height=n.height;const v=g.getContext("2d");if(v){const b=d+f,E=d===0,T=b===c;p({currentTime:e,canvas:g,context:v}),!E&&e>=d&&e<=d+o/2?s.globalAlpha=Math.max(0,Math.min(1,(e-d)/(o/2))):!T&&e>=b-o/2&&e<=b&&(s.globalAlpha=Math.max(0,Math.min(1,(b-e)/(o/2)))),s.drawImage(g,0,0,n.width,n.height)}})}}}function Yg(n){if(typeof n=="string"){const[t,e]=n.split(":");return Math.min(parseFloat(t),parseFloat(e))}return n}function Xg(n){if(typeof n=="string"){const[t,e]=n.split(":"),i=parseFloat(t),s=parseFloat(e);return i/s}return n}function Ol({resolution:n,aspectRatio:t}){const e=Yg(n),i=Xg(t),s=i>=1,o=Math.min(s?e*i:e/i,e),c=Math.max(s?e*i:e/i,e);return{resolution:e,aspectRatio:i,height:s?o:c,width:s?c:o}}function Zg({format:n,resolution:t,aspectRatio:e,sourceWidth:i,sourceHeight:s}){const{width:o,height:c}=Ol({resolution:t,aspectRatio:e}),d=i/s,f=e>d;let p=1;if(n==="letterbox"||n==="letterbox-video")p=f?c/s:o/i;else if(n==="squarebox"){const T=Math.min(c,o);p=i>=s?T/s:T/i}else n==="crop"&&(p=f?o/i:c/s);const g=o/p,v=c/p,b=(i-g)/2,E=(s-v)/2;return{sx:b,sy:E,sWidth:g,sHeight:v,scale:p}}function ca({source:n,sx:t,sy:e,sw:i,sh:s,dx:o,dy:c,dw:d,dh:f}){const p=(n==null?void 0:n.naturalWidth)??(n==null?void 0:n.videoWidth)??(n==null?void 0:n.width),g=(n==null?void 0:n.naturalHeight)??(n==null?void 0:n.videoHeight)??(n==null?void 0:n.height);t=t??0,e=e??0,i=i??p,s=s??g,i<0&&(t+=i,i=Math.abs(i)),s<0&&(e+=s,s=Math.abs(s)),d<0&&(o+=d,d=Math.abs(d)),f<0&&(c+=f,f=Math.abs(f));const v=Math.max(t,0),b=Math.min(t+i,p),E=Math.max(e,0),T=Math.min(e+s,g),w=d/i,C=f/s;return[n,v,E,b-v,T-E,t<0?o-t*w:o,e<0?c-e*C:c,(b-v)*w,(T-E)*C]}function Fd({context:n,source:t,crop:e,format:i="letterbox",posX:s,posY:o,drawAreaWidth:c,drawAreaHeight:d,sourceWidth:f,sourceHeight:p,cropCanvas:g,letterboxCanvas:v}){const{x:b,y:E,width:T,height:w}=e??{},C=f*(b??0),D=p*(E??0),O=f*Math.min(1-(b??0),T??1),F=p*Math.min(1-(E??0),w??1),x=g.getContext("2d");if(x){g.width=O,g.height=F;const J=ca({source:t,sx:C,sy:D,sw:O,sh:F,dx:0,dy:0,dw:O,dh:F});x.drawImage(...J)}const N=O/F,{sx:H,sy:j,sWidth:nt,sHeight:st,scale:Q}=Zg({resolution:Math.min(c,d),aspectRatio:c/d,format:i,sourceWidth:O,sourceHeight:F}),kt=g&&typeof n.filter<"u";if(i==="letterbox"||i==="squarebox"||i==="letterbox-video"&&!kt){if(H<0){const J=Math.abs(H)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,J,d),n.rect(s+c-J,o,J,d),n.fill(),n.closePath()}if(j<0){const J=Math.abs(j)*Q;n.fillStyle="black",n.beginPath(),n.rect(s,o,c,J),n.rect(s,o+d-J,c,J),n.fill(),n.closePath()}}if(i==="letterbox-video"&&kt){const J=v.getContext("2d");if(J){v.width=O,v.height=F,n.save(),n.globalCompositeOperation="destination-out",n.fillRect(s,o,c,d);const St=ca({source:g,sx:H,sy:j,sw:nt,sh:st,dx:s,dy:o,dw:c,dh:d});n.globalCompositeOperation="source-over",n.drawImage(...St),J.save();const $=1.2,U=-(O*$-O)/2,Z=-(F*$-F)/2,ft=Math.min(O/20,F/20);if(J.filter=`blur(${ft}px) brightness(20%)`,J.translate(U,Z),J.scale($,$),J.drawImage(g,0,0,O,F),J.restore(),n.globalCompositeOperation="destination-over",H<0){const bt=c/N,xt=d/bt,Ut=ca({source:v,sy:(1-xt)*F/2,sh:xt*F,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}if(j<0){const bt=d*N,xt=c/bt,Ut=ca({source:v,sx:(1-xt)*O/2,sw:xt*O,dx:s,dy:o,dw:c,dh:d});n.drawImage(...Ut)}n.restore()}}else{const J=ca({source:g,sx:H,sy:j,sw:nt,sh:st,dx:s,dy:o,dw:c,dh:d});n.drawImage(...J)}const gt=H*-1*Q,Mt=j*-1*Q,Vt=c-gt*2,V=d-Mt*2;return{dx:gt,dy:Mt,dw:Vt,dh:V}}const qg=(n,t,e,i)=>{if(e==="length"||e==="prototype"||e==="arguments"||e==="caller")return;const s=Object.getOwnPropertyDescriptor(n,e),o=Object.getOwnPropertyDescriptor(t,e);!Qg(s,o)&&i||Object.defineProperty(n,e,o)},Qg=function(n,t){return n===void 0||n.configurable||n.writable===t.writable&&n.enumerable===t.enumerable&&n.configurable===t.configurable&&(n.writable||n.value===t.value)},Jg=(n,t)=>{const e=Object.getPrototypeOf(t);e!==Object.getPrototypeOf(n)&&Object.setPrototypeOf(n,e)},tm=(n,t)=>`/* Wrapped ${n}*/
89
- ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),rm=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=tm.bind(null,i,t.toString());Object.defineProperty(s,"name",im),Object.defineProperty(n,"toString",{...em,value:s})};function sm(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))qg(n,t,s,e);return Jg(n,t),rm(n,t,i),n}const nm=new WeakMap,Ud=new WeakMap;function Bd(n,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return n;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 s=function(...o){var c;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=n.apply(this,o);if(e.set(d,{data:p,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},i);(c=g.unref)==null||c.call(g);const v=Ud.get(n)??new Set;v.add(g),Ud.set(n,v)}return p};return sm(s,n,{ignoreNonConfigurable:!0}),nm.set(s,e),s}function Gd({context:n,word:t,maxW:e=1/0}){const i=[],s=n.measureText(t);if(s.width<e)return[{text:t,metrics:s}];for(let o=0;o<t.length;o++){const c=i[i.length-1],d=((c==null?void 0:c.text)??"")+t[o],f=n.measureText(d);f.width<e?i[c?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:n.measureText(t[o])})}return i}const Hd=Bd(({font:n,scale:t,context:e,maxW:i,maxH:s,text:o,minSize:c,maxSize:d})=>{var f,p;let g=0;if(d){g=(c??0)*t;let v=0;for(;d*t>g+1;){g+=1;const b=uo({context:e,font:n,fontSize:g,text:o,maxW:i});if(v=b.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||b.length*g>s){g-=1;break}}}else g=parseFloat(((p=(f=n.match(ho))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:n,text:t,minSize:e,maxSize:i,scale:s,maxW:o,maxH:c}])=>`${n}_${t}_${e}_${i}_${s}_${o}_${c}`});function am(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ee={},Ml={},re={};Object.defineProperty(re,"__esModule",{value:!0}),re.default=re.Wrap=re.Unit=re.PrintOptions=re.PositionType=re.Overflow=re.NodeType=re.MeasureMode=re.LogLevel=re.Justify=re.Gutter=re.FlexDirection=re.ExperimentalFeature=re.Errata=re.Edge=re.Display=re.Direction=re.Dimension=re.Align=void 0;let Xr=function(n){return n[n.Auto=0]="Auto",n[n.FlexStart=1]="FlexStart",n[n.Center=2]="Center",n[n.FlexEnd=3]="FlexEnd",n[n.Stretch=4]="Stretch",n[n.Baseline=5]="Baseline",n[n.SpaceBetween=6]="SpaceBetween",n[n.SpaceAround=7]="SpaceAround",n}({});re.Align=Xr;let $l=function(n){return n[n.Width=0]="Width",n[n.Height=1]="Height",n}({});re.Dimension=$l;let eo=function(n){return n[n.Inherit=0]="Inherit",n[n.LTR=1]="LTR",n[n.RTL=2]="RTL",n}({});re.Direction=eo;let Nl=function(n){return n[n.Flex=0]="Flex",n[n.None=1]="None",n}({});re.Display=Nl;let Cr=function(n){return n[n.Left=0]="Left",n[n.Top=1]="Top",n[n.Right=2]="Right",n[n.Bottom=3]="Bottom",n[n.Start=4]="Start",n[n.End=5]="End",n[n.Horizontal=6]="Horizontal",n[n.Vertical=7]="Vertical",n[n.All=8]="All",n}({});re.Edge=Cr;let ha=function(n){return n[n.None=0]="None",n[n.StretchFlexBasis=1]="StretchFlexBasis",n[n.All=2147483647]="All",n[n.Classic=2147483646]="Classic",n}({});re.Errata=ha;let io=function(n){return n[n.WebFlexBasis=0]="WebFlexBasis",n[n.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",n[n.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",n}({});re.ExperimentalFeature=io;let da=function(n){return n[n.Column=0]="Column",n[n.ColumnReverse=1]="ColumnReverse",n[n.Row=2]="Row",n[n.RowReverse=3]="RowReverse",n}({});re.FlexDirection=da;let ro=function(n){return n[n.Column=0]="Column",n[n.Row=1]="Row",n[n.All=2]="All",n}({});re.Gutter=ro;let Js=function(n){return n[n.FlexStart=0]="FlexStart",n[n.Center=1]="Center",n[n.FlexEnd=2]="FlexEnd",n[n.SpaceBetween=3]="SpaceBetween",n[n.SpaceAround=4]="SpaceAround",n[n.SpaceEvenly=5]="SpaceEvenly",n}({});re.Justify=Js;let tn=function(n){return n[n.Error=0]="Error",n[n.Warn=1]="Warn",n[n.Info=2]="Info",n[n.Debug=3]="Debug",n[n.Verbose=4]="Verbose",n[n.Fatal=5]="Fatal",n}({});re.LogLevel=tn;let so=function(n){return n[n.Undefined=0]="Undefined",n[n.Exactly=1]="Exactly",n[n.AtMost=2]="AtMost",n}({});re.MeasureMode=so;let Fl=function(n){return n[n.Default=0]="Default",n[n.Text=1]="Text",n}({});re.NodeType=Fl;let no=function(n){return n[n.Visible=0]="Visible",n[n.Hidden=1]="Hidden",n[n.Scroll=2]="Scroll",n}({});re.Overflow=no;let ao=function(n){return n[n.Static=0]="Static",n[n.Relative=1]="Relative",n[n.Absolute=2]="Absolute",n}({});re.PositionType=ao;let oo=function(n){return n[n.Layout=1]="Layout",n[n.Style=2]="Style",n[n.Children=4]="Children",n}({});re.PrintOptions=oo;let ua=function(n){return n[n.Undefined=0]="Undefined",n[n.Point=1]="Point",n[n.Percent=2]="Percent",n[n.Auto=3]="Auto",n}({});re.Unit=ua;let lo=function(n){return n[n.NoWrap=0]="NoWrap",n[n.Wrap=1]="Wrap",n[n.WrapReverse=2]="WrapReverse",n}({});re.Wrap=lo;var om={ALIGN_AUTO:Xr.Auto,ALIGN_FLEX_START:Xr.FlexStart,ALIGN_CENTER:Xr.Center,ALIGN_FLEX_END:Xr.FlexEnd,ALIGN_STRETCH:Xr.Stretch,ALIGN_BASELINE:Xr.Baseline,ALIGN_SPACE_BETWEEN:Xr.SpaceBetween,ALIGN_SPACE_AROUND:Xr.SpaceAround,DIMENSION_WIDTH:$l.Width,DIMENSION_HEIGHT:$l.Height,DIRECTION_INHERIT:eo.Inherit,DIRECTION_LTR:eo.LTR,DIRECTION_RTL:eo.RTL,DISPLAY_FLEX:Nl.Flex,DISPLAY_NONE:Nl.None,EDGE_LEFT:Cr.Left,EDGE_TOP:Cr.Top,EDGE_RIGHT:Cr.Right,EDGE_BOTTOM:Cr.Bottom,EDGE_START:Cr.Start,EDGE_END:Cr.End,EDGE_HORIZONTAL:Cr.Horizontal,EDGE_VERTICAL:Cr.Vertical,EDGE_ALL:Cr.All,ERRATA_NONE:ha.None,ERRATA_STRETCH_FLEX_BASIS:ha.StretchFlexBasis,ERRATA_ALL:ha.All,ERRATA_CLASSIC:ha.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:io.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:io.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:io.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:da.Column,FLEX_DIRECTION_COLUMN_REVERSE:da.ColumnReverse,FLEX_DIRECTION_ROW:da.Row,FLEX_DIRECTION_ROW_REVERSE:da.RowReverse,GUTTER_COLUMN:ro.Column,GUTTER_ROW:ro.Row,GUTTER_ALL:ro.All,JUSTIFY_FLEX_START:Js.FlexStart,JUSTIFY_CENTER:Js.Center,JUSTIFY_FLEX_END:Js.FlexEnd,JUSTIFY_SPACE_BETWEEN:Js.SpaceBetween,JUSTIFY_SPACE_AROUND:Js.SpaceAround,JUSTIFY_SPACE_EVENLY:Js.SpaceEvenly,LOG_LEVEL_ERROR:tn.Error,LOG_LEVEL_WARN:tn.Warn,LOG_LEVEL_INFO:tn.Info,LOG_LEVEL_DEBUG:tn.Debug,LOG_LEVEL_VERBOSE:tn.Verbose,LOG_LEVEL_FATAL:tn.Fatal,MEASURE_MODE_UNDEFINED:so.Undefined,MEASURE_MODE_EXACTLY:so.Exactly,MEASURE_MODE_AT_MOST:so.AtMost,NODE_TYPE_DEFAULT:Fl.Default,NODE_TYPE_TEXT:Fl.Text,OVERFLOW_VISIBLE:no.Visible,OVERFLOW_HIDDEN:no.Hidden,OVERFLOW_SCROLL:no.Scroll,POSITION_TYPE_STATIC:ao.Static,POSITION_TYPE_RELATIVE:ao.Relative,POSITION_TYPE_ABSOLUTE:ao.Absolute,PRINT_OPTIONS_LAYOUT:oo.Layout,PRINT_OPTIONS_STYLE:oo.Style,PRINT_OPTIONS_CHILDREN:oo.Children,UNIT_UNDEFINED:ua.Undefined,UNIT_POINT:ua.Point,UNIT_PERCENT:ua.Percent,UNIT_AUTO:ua.Auto,WRAP_NO_WRAP:lo.NoWrap,WRAP_WRAP:lo.Wrap,WRAP_WRAP_REVERSE:lo.WrapReverse};re.default=om,Object.defineProperty(Ml,"__esModule",{value:!0}),Ml.default=cm;var bs=lm(re);function Vd(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Vd=function(i){return i?e:t})(n)}function lm(n,t){if(!t&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var e=Vd(t);if(e&&e.has(n))return e.get(n);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in n)if(o!=="default"&&Object.prototype.hasOwnProperty.call(n,o)){var c=s?Object.getOwnPropertyDescriptor(n,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=n[o]}return i.default=n,e&&e.set(n,i),i}function cm(n){function t(s,o,c){const d=s[o];s[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return c.call(this,d,...p)}}for(const s of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[bs.Unit.Point]:n.Node.prototype[s],[bs.Unit.Percent]:n.Node.prototype[`${s}Percent`],[bs.Unit.Auto]:n.Node.prototype[`${s}Auto`]};t(n.Node.prototype,s,function(c){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,b;if(g==="auto")v=bs.Unit.Auto,b=void 0;else if(typeof g=="object")v=g.unit,b=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?bs.Unit.Percent:bs.Unit.Point,b=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(b))throw new Error(`Invalid value ${g} for ${s}`);if(!o[v])throw new Error(`Failed to execute "${s}": Unsupported unit '${g}'`);return b!==void 0?o[v].call(this,...f,b):o[v].call(this,...f)})}function e(s){return n.MeasureCallback.implement({measure:function(){const{width:o,height:c}=s(...arguments);return{width:o??NaN,height:c??NaN}}})}t(n.Node.prototype,"setMeasureFunc",function(s,o){return o?s.call(this,e(o)):this.unsetMeasureFunc()});function i(s){return n.DirtiedCallback.implement({dirtied:s})}return t(n.Node.prototype,"setDirtiedFunc",function(s,o){s.call(this,i(o))}),t(n.Config.prototype,"free",function(){n.Config.destroy(this)}),t(n.Node,"create",(s,o)=>o?n.Node.createWithConfig(o):n.Node.createDefault()),t(n.Node.prototype,"free",function(){n.Node.destroy(this)}),t(n.Node.prototype,"freeRecursive",function(){for(let s=0,o=this.getChildCount();s<o;++s)this.getChild(0).freeRecursive();this.free()}),t(n.Node.prototype,"calculateLayout",function(s){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:bs.Direction.LTR;return s.call(this,o,c,d)}),{Config:n.Config,Node:n.Node,...bs.default}}var Wd={exports:{}};(function(n,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(s){s=s||{};var o;o||(o=typeof s<"u"?s:{});var c,d;o.ready=new Promise(function(_,L){c=_,d=L});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),i&&(p=i),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var b;o.wasmBinary&&(b=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(V/65536*65536)}function T(){}function w(_){this.exports=function(L){function B(ii){return ii.set=function(le,rr){this[le]=rr},ii.get=function(le){return this[le]},ii}for(var G,it=new Uint8Array(123),vt=25;vt>=0;--vt)it[48+vt]=52+vt,it[65+vt]=vt,it[97+vt]=26+vt;it[43]=62,it[47]=63;function lt(ii,le,rr){for(var Ni,pt,Fr=0,l=le,At=rr.length,Nn=le+(At*3>>2)-(rr[At-2]=="=")-(rr[At-1]=="=");Fr<At;Fr+=4)Ni=it[rr.charCodeAt(Fr+1)],pt=it[rr.charCodeAt(Fr+2)],ii[l++]=it[rr.charCodeAt(Fr)]<<2|Ni>>4,l<Nn&&(ii[l++]=Ni<<4|pt>>2),l<Nn&&(ii[l++]=pt<<6|it[rr.charCodeAt(Fr+3)])}function Rt(ii){lt(G,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(G,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(G,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(G,4432,"xwAAAMgAAADJ"),lt(G,4452,"xwAAAMoAAADLAAAArBs="),lt(G,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(G,4552,"zAAAAM0AAADO"),lt(G,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(G,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(G,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(G,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(G,5179,"DA=="),lt(G,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(G,5237,"EA=="),lt(G,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(G,5295,"Eg=="),lt(G,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(G,5362,"GgAAABoaGgAAAAAAAAk="),lt(G,5411,"FA=="),lt(G,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(G,5469,"Fg=="),lt(G,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(G,5556,"1Q=="),lt(G,5596,"//////////8="),lt(G,5664,"8B8BAAAAAAAF"),lt(G,5684,"0A=="),lt(G,5708,"0QAAANIAAADUGw=="),lt(G,5732,"Ag=="),lt(G,5748,"//////////8="),lt(G,5816,"BQ=="),lt(G,5828,"0w=="),lt(G,5852,"0QAAANQAAADoGwAAAAQ="),lt(G,5876,"AQ=="),lt(G,5892,"/////wo="),lt(G,5960,"1g==")}var Lt=new ArrayBuffer(16),Ct=new Int32Array(Lt),Nt=new Float32Array(Lt),Kt=new Float64Array(Lt);function te(ii){return Ct[ii]}function Dt(ii,le){Ct[ii]=le}function Ae(){return Kt[0]}function pi(ii){Kt[0]=ii}function he(){throw new Error("abort")}function Zi(ii){Nt[2]=ii}function Bt(){return Nt[2]}function qo(ii){var le=ii.a,rr=le.a,Ni=rr.buffer;rr.grow=bk;var pt=new Int8Array(Ni),Fr=new Int16Array(Ni),l=new Int32Array(Ni),At=new Uint8Array(Ni),Nn=new Uint16Array(Ni),cp=new Uint32Array(Ni),I=new Float32Array(Ni),Fe=new Float64Array(Ni),Ue=Math.imul,m=Math.fround,Ge=Math.abs,mr=Math.clz32,gE=Math.min,mE=Math.max,zt=NaN,hp=1/0,wt=le.b,ki=le.c,os=le.d,ls=le.e,Ds=le.f,Fn=le.g,Ma=le.h,Qo=le.i,Ah=le.j,Eh=le.k,Th=le.l,dp=le.m,up=le.n,fp=le.o,pp=le.p,gp=le.q,vE=le.r,yE=le.s,bE=le.t,AE=le.u,EE=le.v,TE=le.w,kE=le.x,wE=le.y,SE=le.z,RE=le.A,_E=le.B,LE=le.C,CE=le.D,Et=73712,Fi=0;function mp(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var M=0,W=m(0),z=0,X=m(0),at=0,ot=m(0),mt=0,yt=m(0),_t=0,Ot=0,$t=m(0),Ht=0,Zt=0,ne=m(0),pe=m(0),_e=m(0),De=m(0),Pe=0,Be=m(0),Ve=m(0),ri=0,si=0,vi=m(0),Di=0,Qi=0,Pi=0,Gi=0,Ji=m(0),tr=0,Rr=0,_r=0,Vr=0,Wr=m(0),jr=0,Kr=0,cs=0,hs=0,ds=m(0),$s=0,Ns=0,Fs=0,Us=m(0),Bs=0,Gs=m(0),Fa=0,Ua=m(0),Ba=m(0),Ga=m(0),Ha=0,al=m(0),Nh=0,Fh=m(0),Uh=m(0),Bh=m(0),Gh=m(0),Hh=0,u2=0,f2=0,p2=0,g2=0,m2=0,v2=0,y2=0,We=0,je=m(0),Wn=m(0);M=Et-384|0,Et=M;t:{r:{i:{if(!(y&&a!=a)){if(!(A&&h!=h)){if(z=(P?0:4)+tt|0,l[z>>2]=l[z>>2]+1,z=l[r+24>>2]&3,Nh=(u|0)<=1?1:u,Gi=z||Nh,pt[r+300|0]=At[r+300|0]&252|Gi&3,z=r+252|0,u=((Gi|0)!=1)<<3,$s=(Gi|0)==2?3:2,ot=de(r,$s,k),I[z+u>>2]=ot,at=z,z=((Gi|0)==1)<<3,pe=we(r,$s,k),I[at+z>>2]=pe,yt=de(r,0,k),I[r+256>>2]=yt,De=we(r,0,k),I[r+264>>2]=De,at=r+268|0,We=at+u|0,je=fe(r,$s),I[We>>2]=je,We=z+at|0,je=Se(r,$s),I[We>>2]=je,W=fe(r,0),I[r+272>>2]=W,Be=Se(r,0),I[r+280>>2]=Be,at=u,u=r+284|0,We=at+u|0,je=Ie(r,$s,k),I[We>>2]=je,We=u+z|0,je=xe(r,$s,k),I[We>>2]=je,X=Ie(r,0,k),I[r+288>>2]=X,$t=xe(r,0,k),I[r+296>>2]=$t,ot=m(ot+pe),pe=m(yt+De),u=l[r+8>>2],u){yt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(A?h-pe:zt),W=m(m(X+$t)+W),X=m(y?a-ot:zt),a=X;e:{if(a!=a)break e;if(a=m(X-yt),a!=a){a=m(0);break e}a=ce(a,m(0))}ot=m(W+Be),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=ce(W,m(0))}if(!((y|0)!=1|(A|0)!=1)){a=He(r,2,X,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=He(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(At[r+4|0]&16){Pt[u|0](M+24|0,r,a,y,W,A,0);break e}Pt[u|0](M+24|0,r,a,y,W,A)}l[tt+20>>2]=l[tt+20>>2]+1,u=(et<<2)+tt|0,l[u+24>>2]=l[u+24>>2]+1,a=m(yt+I[M+24>>2]),a=He(r,2,y?(y|0)==2?a:X:a,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(ot+I[M+28>>2]),a=He(r,0,A?(A|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=l[r+556>>2],et=l[r+560>>2],(u|0)==(et|0)){pe=m(h-pe),a=He(r,2,y&-3?m(a-ot):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=He(r,0,A&-3?pe:m(m(m(X+$t)+W)+Be),S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-ot),X=m(h-pe),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(X<=m(0))|(A|0)!=2)&X==X)&((y|0)!=1|(A|0)!=1)))break e;a=He(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=He(r,0,X!=X||(A|0)==2&&X<m(0)?m(0):X,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(ri=et-u|0,Vr=ri>>2;z=l[u>>2],l[z+552>>2]!=(r|0)&&(at=l[r+568>>2],z=Ip(l[at>>2],At[at+8|0],z,r,_t,0),l[u>>2]=z,l[z+552>>2]=r),_t=_t+1|0,u=u+4|0,(et|0)!=(u|0););pt[r+300|0]=At[r+300|0]&251,_t=3,Di=l[r+24>>2],u=Di>>>2&3;e:{s:{n:{if((Gi|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}_t=2;break e}if(_t=2,et=0,u>>>0>1)break s}et=_t}_t=u}Fh=m(a-ot),Wr=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),Be=m(Ie(r,et,k)+fe(r,et)),Ji=m(Be+m(xe(r,et,k)+Se(r,et))),tr=_t>>>0>1,yt=Ep(r,0,Fh,tr?Wr:Ji,k),Uh=m(h-pe),Ve=Ep(r,1,Uh,tr?Ji:Wr,S),De=tr?Ve:yt,pe=tr?yt:Ve,jr=l[r+560>>2],z=l[r+556>>2],Qi=tr?y:A;e:{if((Qi|0)!=1)break e;if((z|0)==(jr|0))break i;for(u=z;;){at=l[u>>2];s:{if(!Bp(at))break s;if(Zt=0,mt)break e;n:{a:{if(!l[at+552>>2]){W=m(0);break a}if(h=I[at+32>>2],h!=h&&(W=m(0),h=I[at+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ge(W))<m(9999999747378752e-20))break e}if(a=Hn(at),a!=a){mt=at;break s}if(mt=at,m(Ge(a))<m(9999999747378752e-20))break e}if(Zt=mt,u=u+4|0,(jr|0)==(u|0))break}}if((z|0)==(jr|0))break i;for(Fa=(Gi|0)<=1?1:Gi,Ns=yt!=yt,Kr=Ns|(y|0)!=1,cs=Ve==Ve,Fs=yt==yt,W=m(0);;){Ht=l[z>>2],Ap(Ht),at=l[Ht+24>>2];e:{if(at&4194304){if(wp(Ht,0),u=At[Ht+4|0],at=u|1,pt[Ht+4|0]=at,!(u&4))break e;pt[Ht+4|0]=at&251;break e}if(P&&(u=at&3,xp(Ht,u||Fa,pe,De,yt),at=l[Ht+24>>2]),(at&196608)==131072)break e;s:{if((Ht|0)==(Zt|0)){l[Zt+308>>2]=0,l[Zt+304>>2]=q,h=m(0);break s}hs=l[r+24>>2],u=hs>>>2&3;n:{a:{if((Gi|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}Rr=mt>>>0>1,ot=Rr?yt:Ve,h=m(0),a=I[Ht+40>>2];n:{a:{Ot=l[Ht+40>>2];o:{if((Ot|0)==2139156720)break o;if((Ot|0)==2140081935)break a;u=4336;l:{if((Ot|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Ot=l[u+4>>2],Ot|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Ht+28>>2]>m(0)))break n;Ot=pt[l[Ht+568>>2]+8|0]&1,u=Ot?2143289344:0,Ot=Ot?3:1,h=(Dt(2,u),Bt())}switch(a=m(zt),Ot-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Dt(2,(Ot&-1073741825)+536870912|0),Bt()),!(Ot&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Ot=0;n:{a:switch(Pe=l[Ht+576>>2],Pe|0){case 0:case 3:break n;default:break a}if(X=I[Ht+572>>2],!((Pe|0)!=1|X!=X)){if(h<m(0))break n;Ot=1;break n}if(Ot=1,(Pe|0)!=2|X!=X||(Ot=0,h<m(0)))break n;Ot=Fs}X=I[Ht+580>>2],u=0;n:{a:switch(si=l[Ht+584>>2],si|0){case 0:case 3:break n;default:break a}if($t=I[Ht+580>>2],!((si|0)!=1|$t!=$t)){if(X<m(0))break n;u=1;break n}if(u=1,(si|0)!=2|$t!=$t||(u=0,X<m(0)))break n;u=cs}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Ht+308>>2],(!(pt[l[Ht+568>>2]+12|0]&1)|l[Ht+304>>2]==(q|0))&h==h)break n;if(h=m(m(Ie(Ht,mt,yt)+fe(Ht,mt))+m(xe(Ht,mt,yt)+Se(Ht,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Ot&Rr){X=m(m(Ie(Ht,2,yt)+fe(Ht,2))+m(xe(Ht,2,yt)+Se(Ht,2))),a=m(zt);o:switch(Pe-1|0){case 1:h=m(m(yt*h)*m(.009999999776482582));case 0:if(a=h,X<=a)break a;break;default:break o}if(!(a==a|X==X)){h=a;break a}if(a<X){h=X;break a}h=a!=a?X:a;break a}if(!(Rr|u^1)){a=m(m(Ie(Ht,0,yt)+fe(Ht,0))+m(xe(Ht,0,yt)+Se(Ht,0))),h=m(zt);o:switch(si-1|0){case 1:X=m(m(Ve*X)*m(.009999999776482582));case 0:if(h=X,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(l[M+360>>2]=2143289344,l[M+24>>2]=2143289344,Pi=0,l[M+356>>2]=0,l[M+352>>2]=0,$t=m(de(Ht,2,yt)+we(Ht,2,yt)),ne=de(Ht,0,yt),_e=we(Ht,0,yt),ot=m(zt),_r=0,a=m(zt),Ot){o:{l:switch(Pe-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(yt*h)*m(.009999999776482582))}l[M+356>>2]=1,a=m($t+a),I[M+24>>2]=a,_r=1}if(ne=m(ne+_e),u){h=m(zt);o:{l:switch(si-1|0){case 0:h=X;break o;case 1:break l;default:break o}h=m(m(Ve*X)*m(.009999999776482582))}l[M+352>>2]=1,ot=m(ne+h),I[M+360>>2]=ot,Pi=1}Pe=(hs&3145728)==2097152,si=mt>>>0<2;o:{l:{c:{if(!(Pe&si)){if(Pe|Ns)break l;if(a!=a)break c;break l}if(Ns|a==a)break o}_r=2,l[M+356>>2]=2,I[M+24>>2]=yt,a=yt}l:{if(!Pe||si){if(Pe|Ve!=Ve)break o;if(ot!=ot)break l;break o}if(ot==ot|Ve!=Ve)break o}Pi=2,l[M+352>>2]=2,I[M+360>>2]=Ve,ot=Ve}h=I[Ht+224>>2],Pe=h!=h;o:{if(Pe)break o;l:{if(!(Rr|(_r|0)!=1)){l[M+352>>2]=1,I[M+360>>2]=ne+m(m(a-$t)/h);break l}if(si|(Pi|0)!=1)break o;l[M+356>>2]=1,I[M+24>>2]=m(m(ot-ne)*h)+$t}Pi=1,_r=1}at=at>>>13&7,at=at||hs>>>10&7;o:{if((at|0)==5|(_r|0)==1|(Rr|(Ot|Kr))|(at|0)!=4||(l[M+356>>2]=1,I[M+24>>2]=yt,Pe))break o;Pi=1,l[M+352>>2]=1,I[M+360>>2]=m(yt-$t)/h}o:{if(si|(A|0)!=1|Ve!=Ve|u|(at|0)!=4|(Pi|0)==1||(l[M+352>>2]=1,I[M+360>>2]=Ve,Pe))break o;l[M+356>>2]=1,I[M+24>>2]=m(Ve-ne)*h}if(Un(Ht,2,yt,yt,M+356|0,M+24|0),Un(Ht,0,Ve,yt,M+352|0,M+360|0),un(Ht,I[M+24>>2],I[M+360>>2],Gi,l[M+356>>2],l[M+352>>2],yt,Ve,0,5,K,tt,dt,q),a=I[(Ht+(l[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Ht,mt,yt)+fe(Ht,mt))+m(xe(Ht,mt,yt)+Se(Ht,mt))),!(u|h!=h)){h=ce(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}l[Ht+304>>2]=q}W=m(W+m(h+m(de(Ht,_t,yt)+we(Ht,_t,yt))))}if(z=z+4|0,(jr|0)==(z|0))break}break r}l[M>>2]=3072,sr(r,M),qi(),he()}l[M+16>>2]=3154,sr(r,M+16|0),qi(),he()}W=m(0)}a=m(W+m(0)),Ua=tr?S:k,Us=tr?k:S,ri>>>0>=5&&(a=m(m(Jo(r,_t,De)*m(Vr-1>>>0))+a)),u=a>pe,jr=Di&786432,cs=(Qi|0)==2&&jr&&u?1:Qi,Ht=tr?A:y,Rr=(Ht|0)==1,u2=Rr&(P^1),tr=_t>>>0<2,f2=Ht&-3,Ns=r+208|0,A=et<<2,si=A+4288|0,p2=Rr&!jr,g2=(Ht|0)!=1|P,z=_t<<2,_r=z+4288|0,Fs=z+4320|0,hs=De==De,m2=hs<<1,Pe=A+4320|0,v2=!Qi|!u,Fa=M+52|0,Bh=Jo(r,et,De),at=0,u=0,Pi=0;r:{for(;;){Qi=u,Bi(M+24|0,0,44),u=l[r+560>>2],A=l[r+556>>2];i:{if((u|0)==(A|0))break i;if(u=u-A|0,(u|0)<0)break r;if(z=Na(M+360|0,u>>2,0,Fa),u=l[M+44>>2],A=l[M+48>>2]-u|0,A=Ps(l[M+364>>2]-A|0,u,A),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=A,mt=l[M+368>>2],Ot=l[M+372>>2],A=l[M+48>>2],l[M+368>>2]=A,Zt=l[M+52>>2],l[M+48>>2]=mt,l[M+52>>2]=Ot,l[M+372>>2]=Zt,l[z>>2]=u,(u|0)!=(A|0)&&(l[M+368>>2]=A+((u-A|0)+3&-4)),!u)break i;gi(u)}Zt=l[r+24>>2],u=Zt>>>2&3;i:{e:{if(A=Zt&3,((A||Nh)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}mt=2;break i}mt=u}W=Jo(r,mt,yt),z=at,Ot=l[r+560>>2],A=l[r+556>>2];i:{if(z>>>0>=Ot-A>>2>>>0)break i;for(Zt=Zt&786432,h=m(0);;){if(Ot-A>>2>>>0<=z>>>0)break r;if(u=l[(z<<2)+A>>2],ri=l[u+24>>2],!(ri&4194304|(ri&196608)==131072)){if(l[u+548>>2]=Qi,a=de(u,mt,yt),X=we(u,mt,yt),A=l[M+24>>2],ot=(z|0)==(at|0)?m(0):W,a=m(a+X),X=I[u+308>>2],$t=He(u,mt,X,Us),!(!A||!(m(ot+m(a+m(h+$t)))>pe)|!Zt))break i;if(l[M+24>>2]=A+1,ot=m(ot+m(a+$t)),I[M+28>>2]=ot+I[M+28>>2],Bp(u)){e:{if(!l[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[M+32>>2]=a+I[M+32>>2],We=M,je=m(I[M+36>>2]-m(Hn(u)*X)),I[We+36>>2]=je}A=l[M+48>>2];e:{if((A|0)!=l[M+52>>2]){l[A>>2]=u,l[M+48>>2]=A+4;break e}if(A=A-l[M+44>>2]|0,ri=A>>2,Ot=ri+1|0,Ot>>>0>=1073741824)break r;if(Di=A>>1,Ot=Na(M+360|0,A>>>0>=2147483644?1073741823:Ot>>>0<Di>>>0?Di:Ot,ri,Fa),l[l[M+368>>2]>>2]=u,l[M+368>>2]=l[M+368>>2]+4,u=l[M+44>>2],A=l[M+48>>2]-u|0,A=Ps(l[M+364>>2]-A|0,u,A),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=A,ri=l[M+368>>2],Di=l[M+372>>2],A=l[M+48>>2],l[M+368>>2]=A,Kr=l[M+52>>2],l[M+48>>2]=ri,l[M+52>>2]=Di,l[M+372>>2]=Kr,l[Ot>>2]=u,(u|0)!=(A|0)&&(l[M+368>>2]=A+((u-A|0)+3&-4)),!u)break e;gi(u)}A=l[r+556>>2],Ot=l[r+560>>2],h=m(h+ot)}if(z=z+1|0,!(z>>>0<Ot-A>>2>>>0))break}}_e=I[M+32>>2],!(_e>m(0))|!(_e<m(1))||(l[M+32>>2]=1065353216,_e=m(1)),vi=I[M+36>>2],!(vi>m(0))|!(vi<m(1))||(l[M+36>>2]=1065353216,vi=m(1)),l[M+40>>2]=z,$t=I[M+28>>2],mt=l[M+24>>2],Pi&&gi(Pi),X=I[M+56>>2],ri=l[M+48>>2],Pi=l[M+44>>2];i:{e:{s:{n:{if((cs|0)==1)break n;h=m(0),a=I[Ns>>2];a:{o:{u=l[Ns>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(a==a)break c;A=4344}switch(h=I[A>>2],a=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=I[r+216>>2];a:{o:{u=l[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(W==W)break c;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[r+212>>2];a:{o:{u=l[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;A=4344}switch(h=I[A>>2],ot=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),ne=I[r+220>>2];a:{o:{u=l[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ne==ne)break c;A=4344}switch(h=I[A>>2],ne=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ne=m(m(h*S)*m(.009999999776482582));break a}ne=h}if(u=_t>>>0>1,h=m((u?a:ot)-Wr),h==h&h>$t||(h=m((u?W:ne)-Wr),h==h&h<$t))break s;if(pt[l[r+568>>2]+16|0]&1)break n;if(h=$t,!l[r+552>>2]|_e==m(0))break e;a=I[r+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[r+28>>2],!(h>m(0)))break a}if(h!=h){h=pe;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=pe,a!=m(0)))break e;h=$t;break e}h=pe}if(h!=h)break e;X=m(h-$t);break i}if(!($t<m(0)))break i;X=m(-$t)}if(pe=h,!u2){i:{if((ri|0)==(Pi|0)){ot=m(0);break i}for(ne=m(0),A=Pi;;){u=l[A>>2],$t=I[u+308>>2],h=He(u,_t,$t,Us);e:{if(X<m(0)){if(a=m(h*m(-Hn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(X/vi)*a)+h),a=He(u,_t,W,pe),Ot=a!=a,ot=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|ot!=ot)){a=ce(a,ot);break s}a=Ot?ot:a}if(W!=W|a!=a|a==W)break e;ne=m(ne+m(a-h)),vi=m(m(Hn(u)*$t)+vi);break e}if(!(X>m(0))|!l[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(X/_e)*W)+h),a=He(u,_t,ot,pe),Ot=a!=a,$t=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|$t!=$t)){a=ce(a,$t);break s}a=Ot?$t:a}if(ot!=ot|a!=a|a==ot)break e;_e=m(_e-W),ne=m(ne+m(a-h))}if(A=A+4|0,(ri|0)==(A|0))break}for(ne=m(X-ne),Ba=m(ne/vi),Ga=m(ne/_e),Ha=Rr&(v2|!(At[r+26|0]&12)),Kr=!Ha,Di=l[Pe>>2],ot=m(0),Ot=Pi;;){u=l[Ot>>2],$t=He(u,_t,I[u+308>>2],Us);e:{s:{if(ne<m(0)){if(W=$t,a=m(W*m(-Hn(u))),a==m(0))break e;a=vi==m(0)?m($t+a):m(m(Ba*a)+$t);break s}if(W=$t,!(ne>m(0))|!l[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Ga*a)+$t)}if(a=He(u,_t,a,pe),A=a!=a,h=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t))),!(A|h!=h)){W=ce(a,h);break e}W=A?h:a}a=de(u,_t,yt),h=we(u,_t,yt),_e=de(u,et,yt),al=we(u,et,yt),h=m(a+h),Gh=m(W+h),I[M+352>>2]=Gh,l[M+344>>2]=1,_e=m(_e+al),a=I[u+224>>2];e:{if(a==a){l[M+348>>2]=1,h=m(Gh-h),I[M+356>>2]=_e+m(tr?h*a:h/a);break e}s:{if(Bs=De!=De,Bs)break s;Zt=(Di<<3)+u|0,a=I[Zt+572>>2];n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(h=I[Zt+572>>2],(A|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!Ha)break s;break n}if(Kr|(!(a<m(0))|((A|0)!=2|h!=h)))break s}if(A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(M+24|0,u,et),l[M+28>>2]==3)||(fn(M+360|0,u,et),l[M+364>>2]==3))break s;l[M+348>>2]=1,I[M+356>>2]=De;break e}Zt=(Di<<3)+u|0,h=I[Zt+572>>2];s:{n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(a=I[Zt+572>>2],!((A|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((A|0)!=2|a!=a)break a;if(Bs)break o;if(!(h<m(0)))break n}l[M+348>>2]=m2,I[M+356>>2]=De;break e}a=m(zt);a:switch(A-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(De*h)*m(.009999999776482582))}a=m(_e+a),I[M+356>>2]=a,l[M+348>>2]=(Rr|(A|0)!=2)&a==a}Un(u,_t,pe,yt,M+344|0,M+352|0),Un(u,et,De,yt,M+348|0,M+356|0),Zt=(Di<<3)+u|0,a=I[Zt+572>>2];e:{s:{n:{a:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break n;default:break a}if(h=I[Zt+572>>2],!((A|0)!=1|h!=h)){if(a<m(0))break n;break s}if((A|0)!=2|h!=h)break s;if(a<m(0))break n;if(Zt=0,hs)break e}if(Zt=0,A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(M+24|0,u,et),l[M+28>>2]==3))break e;fn(M+360|0,u,et),Zt=l[M+364>>2]!=3;break e}Zt=0}a=I[M+352>>2],h=I[M+356>>2],A=_t>>>0>1,_e=A?a:h,a=A?h:a,Bs=l[M+344>>2],Hh=l[M+348>>2],y2=A?Bs:Hh,Bs=A?Hh:Bs,A=(Zt^1)&P,un(u,_e,a,At[r+300|0]&3,y2,Bs,yt,Ve,A,A?4:7,K,tt,dt,q),ot=m(ot+m(W-$t)),A=At[r+300|0];e:{s:{if(A&4){Zt=A&251;break s}if(Zt=A&251,A=0,!(At[u+300|0]&4))break e}A=4}if(pt[r+300|0]=A|Zt,Ot=Ot+4|0,(ri|0)==(Ot|0))break}}X=m(X-ot)}u=At[r+300|0],pt[r+300|0]=u&251|(X<m(0)?4:u&4),ne=m(Ie(r,_t,k)+fe(r,_t)),Ba=m(xe(r,_t,k)+Se(r,_t)),$t=Jo(r,_t,k);i:{if(!(!(X>m(0))|(cs|0)!=2)){ot=m(0),h=m(0);e:{s:{u=Ns+(l[Fs>>2]<<2)|0,a=I[u>>2],u=l[u>>2],A=(u|0)==2139156720;n:{if(!A){if(Ot=(u|0)==2140081935,Ot)break s;if(Zt=(u|0)==2141891242,Zt|a!=a)break i;if(Ot)break s;if(Zt)break i;if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Us*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(A)break n;if((u|0)==2140081935)break s;A=4336;a:{if((u|0)!=2141891242){if(a==a)break a;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break s}W=m(m(Us*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-ne)-Ba)-m(pe-X)),a!=a)break i;ot=ce(a,m(0));break i}ot=X}Zt=z>>>0<=at>>>0;i:{if(!Zt){for(ri=l[r+556>>2],u=l[r+560>>2]-ri>>2,Di=u>>>0<at>>>0?at:u,Ot=0,u=at;;){if((u|0)==(Di|0))break r;if(A=l[ri+(u<<2)>>2],(l[A+24>>2]&196608)!=131072&&(Kr=M+24|0,pn(Kr,A,_t),Ha=l[M+28>>2],fn(Kr,A,_t),Ot=(((Ha|0)==3)+Ot|0)+(l[M+28>>2]==3)|0),u=u+1|0,(z|0)==(u|0))break}if(_e=m(0),h=$t,Ot)break i}_e=m(0),Ot=0,h=$t;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:_e=m(ot*m(.5));break i;case 1:_e=ot;break i;case 2:if(mt>>>0<2)break i;h=m($t+m((je=m(0),Wn=ce(ot,m(0)),We=ot!=ot,(We?je:Wn)/m(mt-1>>>0))));break i;case 4:_e=m(ot/m(mt+1>>>0)),h=m($t+_e);break i;case 3:break e;default:break i}_e=m(m(ot*m(.5))/m(mt>>>0)),h=m(m(_e+_e)+$t)}if(a=m(ne+_e),X=m(0),ri=Pp(r),Zt)h=m(0);else{for(Di=z-1|0,Ga=m(ot/m(Ot|0)),ne=m(0),W=m(0),u=at;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=u>>>0)break r;A=l[A+(u<<2)>>2],mt=A+228|0,Ui(M+24|0,mt,320),h=m(h-((u|0)==(Di|0)?$t:m(0))),Ot=l[A+24>>2];i:{if(Ot&4194304)break i;e:{if((Ot&196608)==131072){if(!nr(A,_t))break e;if(!P)break i;ot=Os(A,_t,pe),vi=fe(r,_t),al=de(A,_t,yt),I[mt+(l[_r>>2]<<2)>>2]=al+m(ot+vi);break i}if(pn(M+360|0,A,_t),a=m(a+(l[M+364>>2]==3?Ga:m(-0))),P&&(Ot=mt,mt=l[_r>>2]<<2,I[Ot+mt>>2]=a+I[mt+(M+24|0)>>2]),fn(M+360|0,A,_t),a=m(a+(l[M+364>>2]==3?Ga:m(-0))),!g2){a=m(a+m(m(h+m(de(A,_t,yt)+we(A,_t,yt)))+I[M+104>>2])),X=De;break i}if(mt=A+516|0,a=m(a+m(h+m(I[mt+(l[Fs>>2]<<2)>>2]+m(de(A,_t,yt)+we(A,_t,yt))))),ri){ot=tl(A),vi=de(A,0,yt),ot=m(ot+vi),vi=m(m(I[A+520>>2]+m(de(A,0,yt)+we(A,0,yt)))-ot),A=ne!=ne;s:{if(!(A|ot!=ot)){ne=ce(ne,ot);break s}ne=A?ot:ne}if(A=W!=W,!(A|vi!=vi)){W=ce(W,vi);break i}W=A?vi:W;break i}if(ot=m(I[mt+(l[Pe>>2]<<2)>>2]+m(de(A,et,yt)+we(A,et,yt))),A=X!=X,!(ot!=ot|A)){X=ce(X,ot);break i}X=A?ot:X;break i}if(!P)break i;A=l[_r>>2]<<2,ot=I[A+(M+24|0)>>2],We=A+mt|0,je=m(_e+m(ot+fe(r,_t))),I[We>>2]=je}if(u=u+1|0,(z|0)==(u|0))break}h=m(W+ne)}if(X=ri?h:X,ot=De,!f2){h=He(r,et,m(Ji+X),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}ot=m(h-Ji)}h=He(r,et,m(Ji+(p2?De:X)),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}if(W=m(h-Ji),!(Zt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=at>>>0)break r;mt=l[u+(at<<2)>>2],u=l[mt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!nr(mt,et)){A=l[si>>2];break e}if(h=Os(mt,et,De),X=fe(r,et),$t=de(mt,et,yt),A=l[si>>2],h=m($t+m(h+X)),I[(mt+(A<<2)|0)+228>>2]=h,h==h)break i}We=mt+(A<<2)|0,je=m(fe(r,et)+de(mt,et,yt)),I[We+228>>2]=je;break i}A=u>>>13&7,A||(A=l[r+24>>2]>>>10&7);e:{s:{if((A|0)==5){A=l[r+24>>2]&8?5:1;break s}if((A|0)!=4||(pn(M+24|0,mt,et),A=4,l[M+28>>2]==3)||(fn(M+360|0,mt,et),l[M+364>>2]==3))break s;A=mt+(l[Pe>>2]<<3)|0,X=I[A+572>>2];n:{a:switch(u=l[A+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[A+572>>2],!((u|0)!=1|$t!=$t)){if(h=Be,X<m(0))break n;break e}if(h=Be,hs&!(X<m(0))|((u|0)!=2|$t!=$t))break e}X=I[(mt+(l[Fs>>2]<<2)|0)+516>>2],h=W,$t=I[mt+224>>2],$t==$t&&(h=m(m(de(mt,et,yt)+we(mt,et,yt))+m(tr?X*$t:X/$t))),I[M+360>>2]=h,We=M,je=m(X+m(de(mt,_t,yt)+we(mt,_t,yt))),I[We+24>>2]=je,l[M+356>>2]=1,l[M+352>>2]=1,Un(mt,_t,pe,yt,M+356|0,M+24|0),Un(mt,et,De,yt,M+352|0,M+360|0),X=I[M+360>>2],$t=I[M+24>>2],u=_t>>>0>1,h=u?X:$t,X=u?$t:X,u=(jr|0)!=0&(l[r+24>>2]&896)!=512,un(mt,X,h,Gi,!(u&tr|X!=X),(!u|tr)&h==h,yt,Ve,1,2,K,tt,dt,q),h=Be;break e}h=I[(mt+(l[Pe>>2]<<2)|0)+516>>2],X=de(mt,et,yt),$t=we(mt,et,yt),pn(M+24|0,mt,et),X=m(ot-m(h+m(X+$t)));s:{if(l[M+28>>2]!=3||(fn(M+360|0,mt,et),l[M+364>>2]!=3))break s;h=m(X*m(.5)),h=m(Be+(je=m(0),Wn=ce(h,m(0)),We=h!=h,We?je:Wn));break e}if(fn(M+24|0,mt,et),h=Be,l[M+28>>2]==3)break e;if(pn(M+24|0,mt,et),l[M+28>>2]==3){h=m(Be+(je=m(0),Wn=ce(X,m(0)),We=X!=X,We?je:Wn));break e}s:switch(A-1|0){case 1:h=m(Be+m(X*m(.5)));break e;case 0:break e;default:break s}h=m(Be+X)}u=mt+(l[si>>2]<<2)|0,I[u+228>>2]=h+m(ds+I[u+228>>2])}if(at=at+1|0,(at|0)==(z|0))break}h=m((Qi?Bh:m(0))+W),u=Gs!=Gs,a=m(Ba+a);i:{if(!(u|a!=a)){Gs=ce(Gs,a);break i}Gs=u?a:Gs}if(ds=m(ds+h),u=Qi+1|0,at=z,!(Vr>>>0>z>>>0))break}i:{if(!P||!jr&&!Pp(r))break i;ne=m(0);e:{s:{if(De!=De)break s;a=m(De-ds);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:Be=m(Be+m(a*m(.5)));break s;case 2:if(!(De>ds))break s;ne=m(a/m(u>>>0));break s;case 5:if(De>ds){if(Be=m(Be+m(a/m(u<<1>>>0))),u>>>0<2)break s;ne=m(a/m(u>>>0));break e}Be=m(Be+m(a*m(.5)));break s;case 4:if(!(De>ds)|u>>>0<2)break s;ne=m(a/m(Qi>>>0));break e;case 1:break n;default:break s}Be=m(Be+a)}if(!u)break i}for(Ot=0,u=0,A=0;;){if(X=m(0),h=m(0),a=m(0),W=m(0),z=u,Vr>>>0>u>>>0){e:{for(;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=z>>>0)break r;at=l[A+(z<<2)>>2],mt=l[at+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(A=z,l[at+548>>2]!=(Ot|0))break e;a=I[(at+(l[Pe>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(A=h!=h,a=m(a+m(de(at,et,yt)+we(at,et,yt))),!(A|a!=a)){h=ce(h,a);break n}h=A?a:h}if(A=mt>>>13&7,A||(A=l[r+24>>2]>>>10&7),!(At[r+24|0]&8)|(A|0)!=5)break s;a=tl(at),ot=de(at,0,yt),a=m(a+ot),ot=m(m(I[at+520>>2]+m(de(at,0,yt)+we(at,0,yt)))-a),A=h!=h,at=W!=W;n:{if(!(at|a!=a)){W=ce(W,a);break n}W=at?a:W}at=X!=X;n:{if(!(at|ot!=ot)){X=ce(X,ot);break n}X=at?ot:X}if(a=m(W+X),!(A|a!=a)){h=ce(h,a);break s}h=A?a:h}if(z=z+1|0,(Vr|0)==(z|0))break}A=Vr}a=h}if(ot=m(Be+(Ot?Bh:m(0))),h=m(ne+a),Be=m(ot+h),u>>>0<A>>>0)for($t=m(ot+W);;){if(z=l[r+556>>2],l[r+560>>2]-z>>2>>>0<=u>>>0)break r;at=l[z+(u<<2)>>2],z=l[at+24>>2];e:{if(z&4194304|(z&196608)==131072)break e;z=z>>>13&7,z||(z=l[r+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(At[r+24|0]&8)break s;case 0:a=de(at,et,yt),I[(at+(l[si>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=we(at,et,yt),z=at+228|0,I[z+(l[si>>2]<<2)>>2]=m(Be-a)-I[(z+(l[Pe>>2]<<2)|0)+288>>2];break e;case 1:z=at+228|0,I[z+(l[si>>2]<<2)>>2]=ot+m(m(h-I[(z+(l[Pe>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=de(at,et,yt),I[(at+(l[si>>2]<<2)|0)+228>>2]=ot+a,mt=at+(l[Pe>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(z=l[mt+576>>2],z|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((z|0)!=1|W!=W)){if(a<m(0))break n;break e}if(hs&!(a<m(0))|((z|0)!=2|W!=W))break e}n:{if(_t>>>0>=2){X=h,a=I[at+516>>2],W=m(a+m(de(at,_t,yt)+we(at,_t,yt)));break n}X=m(I[at+520>>2]+m(de(at,et,yt)+we(at,et,yt))),a=I[at+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ge(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[at+520>>2],z=a!=a,!(z|X!=X)){if(!(m(Ge(m(X-a)))<m(9999999747378752e-20)))break n;break e}if(X==X)break n;if(z)break e}un(at,W,X,Gi,1,1,yt,Ve,1,3,K,tt,dt,q);break e}We=at,je=m(m($t-tl(at))+Os(at,0,De)),I[We+232>>2]=je}if(u=u+1|0,(A|0)==(u|0))break}if(z=(Ot|0)!=(Qi|0),Ot=Ot+1|0,u=A,!z)break}}mt=r+516|0,a=He(r,2,Fh,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[mt>>2]=a,a=He(r,0,Uh,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(cs&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(cs|0)!=2))break s;if(a=He(r,_t,Gs,Us),u=a!=a,h=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if((cs|0)!=2|(u|0)!=2)break i;h=m(Wr+pe),u=h!=h,a=He(r,_t,Gs,Us);s:{if(!(u|a!=a)){a=xh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Wr!=Wr)){a=ce(a,Wr);break e}a=u?Wr:a}I[mt+(l[Fs>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(A=(Ht|0)!=2,u=l[r+24>>2]>>>20&3,A|(u|0)==2))break s;if(a=He(r,et,m(Ji+ds),Ua),u=a!=a,h=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if(A|(u|0)!=2)break i;h=m(Ji+De),u=h!=h,a=He(r,et,m(Ji+ds),Ua);s:{if(!(u|a!=a)){a=xh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Ji!=Ji)){a=ce(a,Ji);break e}a=u?Ji:a}I[mt+(l[Pe>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(A=Vr>>>0<=1?1:Vr,P=l[r+556>>2],at=l[r+560>>2]-P>>2,u=0;z=0,z=u>>>0<at>>>0?l[P+(u<<2)>>2]:z,(l[z+24>>2]&196608)!=131072&&(z=z+228|0,Ot=z+(l[si>>2]<<2)|0,Zt=l[Pe>>2]<<2,I[Ot>>2]=m(I[Zt+mt>>2]-I[Ot>>2])-I[(z+Zt|0)+288>>2]),u=u+1|0,(A|0)!=(u|0););if(A=l[r+556>>2],P=l[r+560>>2],(A|0)!=(P|0))for(Ot=((_t>>>0>1?cs:y)|0)!=0;;){y=l[A>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=yt,pe=Ve,At[l[r+568>>2]+12|0]&2&&(pe=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Gi|0)==2){at=0,z=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}z=2;break s}if(at=0,u>>>0<=1)break n;z=u;break s}z=u,at=$s}S=m(de(y,2,W)+we(y,2,W)),k=de(y,0,W),X=we(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=l[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(zt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(zt),!nr(y,2)||!rl(y,2))break s;if(a=He(y,2,m(m(I[r+516>>2]-m(fe(r,2)+Se(r,2)))-m(Os(y,2,W)+$a(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+fe(y,2))+m(xe(y,2,W)+Se(y,2))),!(u|h!=h)){h=ce(a,h);break s}h=u?h:a}X=m(k+X);s:{n:{a:{o:{l:{c:{h:{Zt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=l[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(pe!=pe|k<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(pe*k)*m(.009999999776482582))}a=m(X+a);break f}d:{if(nr(y,0)&&rl(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=He(y,0,m(m(I[r+520>>2]-m(fe(r,0)+Se(r,0)))-m(Os(y,0,pe)+$a(y,0,pe))),pe),u=a!=a,k=m(m(Ie(y,0,W)+fe(y,0))+m(xe(y,0,W)+Se(y,0))),!(u|k!=k)){a=ce(a,k);break f}a=u?k:a}if((Zt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-X)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(X+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Zt=W>m(0),Qi=u&Ot&z>>>0<2,h=Qi&&Zt?W:h,u=u^1,un(y,h,a,Gi,Qi&&Zt?2:u,a==a,h,a,0,6,K,tt,dt,q),h=m(I[y+516>>2]+i2(y,2,W)),a=m(I[y+520>>2]+i2(y,0,W))}un(y,h,a,Gi,1,1,h,a,1,1,K,tt,dt,q);s:{n:{a:{if(!rl(y,z)||nr(y,z))break a;u=l[(z<<2)+4320>>2]<<2,a=z>>>0<2?pe:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,z))-we(y,z,a))-$a(y,z,a));break n}if(!(nr(y,z)|(l[r+24>>2]&112)!=16)){u=l[(z<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(nr(y,z)|(l[r+24>>2]&112)!=32)){u=l[(z<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,z))break s;a=I[mt+(l[(z<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,z,a)+fe(r,z))+de(y,z,a))}I[(y+(l[(z<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!rl(y,at)||nr(y,at))break n;u=l[(at<<2)+4320>>2]<<2,a=z>>>0<2?W:pe,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,at))-we(y,at,a))-$a(y,at,a));break s}n:{if(nr(y,at)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(at<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(nr(y,at))break n;z=l[y+24>>2]>>>13&7,u=l[r+24>>2],z=z||u>>>10&7;a:{if((z|0)==5){if((u&786432)==524288)break a;break n}if(((z|0)==3|0)==((u&786432)==524288|0))break n}u=l[(at<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,at))break e;a=I[mt+(l[(at<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,at,a)+fe(r,at))+de(y,at,a))}I[(y+(l[(at<<2)+4288>>2]<<2)|0)+228>>2]=a}if(A=A+4|0,(P|0)==(A|0))break}if(!((et|_t)&1))break i;for(A=et&1,P=_t&1,K=Vr>>>0<=1?1:Vr,tt=(et<<2)+4304|0,dt=(_t<<2)+4304|0,q=l[r+556>>2],et=l[r+560>>2]-q>>2,r=0;;){if((r|0)==(et|0))break r;u=l[q+(r<<2)>>2];e:{if(At[u+26|0]&64||(P&&(y=u+228|0,z=l[Fs>>2]<<2,I[y+(l[dt>>2]<<2)>>2]=m(I[z+mt>>2]-I[(y+z|0)+288>>2])-I[y+(l[_r>>2]<<2)>>2]),!A))break e;u=u+228|0,y=l[Pe>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(l[si>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Pi)break t;gi(Pi);break t}Ds(),he()}Et=M+384|0}function vp(){var r=0,a=0;Fn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7032,2922,6,4368,4392,19,r|0,1),Fn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ht(4),l[r>>2]=24,wt(7036,2359,2,4400,4408,25,r|0,0),os(7032,1398,2,4412,4420,26,27),os(7032,3027,3,4500,4512,28,29),Fn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7056,3293,2,4520,4408,32,r|0,1),Fn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ht(4),l[r>>2]=37,wt(7059,2359,2,4528,4408,38,r|0,0),os(7056,1398,2,4536,4420,39,40),os(7056,3027,3,4500,4512,28,41),Fn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),pp(7062,1,4584,4352,44,45),os(7062,2915,1,4584,4352,44,45),os(7062,1129,2,4588,4408,46,47),r=ht(8),l[r+4>>2]=0,l[r>>2]=48,wt(7062,3234,4,4608,4624,49,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=50,wt(7062,1981,3,4632,4644,51,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=52,wt(7062,1952,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=54,wt(7062,3389,3,4672,4664,55,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=56,wt(7062,1800,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=57,wt(7062,3264,3,4684,4512,58,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=59,wt(7062,1926,2,4696,4420,60,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=61,wt(7062,3399,2,4704,4420,62,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=63,wt(7062,1785,2,4696,4420,60,r|0,0),Th(7065,1271,4712,64,4357,65),Vn(1732,0),Vn(1612,8),Vn(2145,16),Vn(2455,24),Vn(2561,32),Vn(1618,40),Eh(7065),Th(7035,2898,4712,66,4357,67),zp(2561,0),zp(1618,8),Eh(7035),Th(7066,2909,4712,68,4357,69),r=ht(4),l[r>>2]=8,a=ht(4),l[a>>2]=8,Qo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ht(4),l[r>>2]=0,a=ht(4),l[a>>2]=0,Qo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),Eh(7066),Fn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),pp(7067,1,4724,4352,76,77),os(7067,1593,1,4724,4352,76,77),os(7067,2851,2,4728,4420,78,79),os(7067,1129,2,4736,4408,80,81),r=ht(8),l[r+4>>2]=0,l[r>>2]=82,wt(7067,1753,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=84,wt(7067,3005,3,4744,4664,85,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=86,wt(7067,2930,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=88,wt(7067,2335,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=90,wt(7067,1485,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=91,wt(7067,1356,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=92,wt(7067,1818,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=93,wt(7067,2872,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=94,wt(7067,2379,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=95,wt(7067,2164,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=96,wt(7067,1320,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=97,wt(7067,2413,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=98,wt(7067,1504,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=99,wt(7067,2236,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=100,wt(7067,1220,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=101,wt(7067,1137,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=102,wt(7067,1159,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=104,wt(7067,1846,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=105,wt(7067,1465,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=106,wt(7067,2219,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=107,wt(7067,1196,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=108,wt(7067,2501,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=109,wt(7067,2591,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=110,wt(7067,1540,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=111,wt(7067,2250,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=112,wt(7067,1651,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=113,wt(7067,1428,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=114,wt(7067,2205,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=115,wt(7067,2609,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=116,wt(7067,1556,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=117,wt(7067,1671,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=118,wt(7067,1445,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=119,wt(7067,2567,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=120,wt(7067,1521,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=121,wt(7067,1625,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=122,wt(7067,1408,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=123,wt(7067,2305,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=124,wt(7067,2093,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=125,wt(7067,2719,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=126,wt(7067,1575,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=127,wt(7067,2188,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=128,wt(7067,2946,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=130,wt(7067,2347,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=132,wt(7067,1372,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=133,wt(7067,1832,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=134,wt(7067,2885,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=135,wt(7067,2396,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=136,wt(7067,2176,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=137,wt(7067,1338,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=138,wt(7067,2423,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=139,wt(7067,1859,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=141,wt(7067,1208,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=143,wt(7067,2515,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=144,wt(7067,2600,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=145,wt(7067,1661,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=146,wt(7067,2621,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=147,wt(7067,1684,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=148,wt(7067,2579,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=149,wt(7067,1638,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=150,wt(7067,2320,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=151,wt(7067,2103,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=153,wt(7067,1232,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=154,wt(7067,1148,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=155,wt(7067,2730,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=156,wt(7067,2195,3,4860,4872,157,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=158,wt(7067,3034,4,4880,4624,159,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=160,wt(7067,3055,3,4896,4664,161,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=162,wt(7067,1293,2,4908,4420,163,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=164,wt(7067,1388,2,4916,4420,165,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=166,wt(7067,3046,3,4924,4512,167,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=168,wt(7067,2962,2,4936,4420,169,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=170,wt(7067,2982,3,4944,4664,171,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=172,wt(7067,3357,3,4956,4664,173,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=174,wt(7067,3355,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=175,wt(7067,3374,3,4968,4664,176,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=177,wt(7067,3372,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=178,wt(7067,1119,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=179,wt(7067,1111,2,4980,4420,180,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=181,wt(7067,1244,5,4992,5012,182,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=183,wt(7067,1737,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=184,wt(7067,1715,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=185,wt(7067,2149,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=186,wt(7067,2462,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=187,wt(7067,2633,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=188,wt(7067,1697,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=189,wt(7067,1260,2,5020,4420,190,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=191,wt(7067,2433,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=192,wt(7067,2113,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=193,wt(7067,2741,3,4840,4852,152,r|0,0)}function IE(r,a,h,u,y,A){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,A=A|0;var k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0,at=0,ot=0,mt=0,yt=0,_t=0,Ot=0,$t=0;q=Et-560|0,Et=q,l[q+44>>2]=0,pi(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){at=1,Ot=1177,a=-a,pi(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){at=1,Ot=1180;break t}at=y&1,Ot=at?1183:1178,$t=!at}t:{if((k&2146435072)==2146435072){k=at+3|0,mi(r,32,h,k,y&-65537),hi(r,Ot,at),u=A&32,hi(r,a!=a?u?2451:3459:u?2868:3463,3),mi(r,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=q+16|0;r:{i:{e:{if(a=$p(a,q+44|0),a=a+a,a!=0){if(k=l[q+44>>2],l[q+44>>2]=k-1,yt=A|32,(yt|0)!=97)break e;break r}if(yt=A|32,(yt|0)==97)break r;tt=l[q+44>>2],dt=(u|0)<0?6:u;break i}tt=k-29|0,l[q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(z=(q+48|0)+((tt|0)>=0?288:0)|0,S=z;a<4294967296&a>=0?u=~~a>>>0:u=0,l[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((tt|0)<=0){u=tt,k=S,P=z;break i}for(P=z,u=tt;;){M=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],_t=u,u=M&31,(M&63)>>>0>=32?(et=K<<u,u=0):(et=(1<<u)-1&K>>>32-u,u=K<<u),_t=_t+u|0,K=et+W|0,u=kp(_t,u>>>0>_t>>>0?K+1|0:K,1e9),K=Ih(u,Fi,-1e9,0)+_t|0,l[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,l[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!l[S>>2]););if(u=l[q+44>>2]-M|0,l[q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(yt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(M=1e9>>>et|0,K=-1<<et^-1,u=0,S=P;_t=u,u=l[S>>2],l[S>>2]=_t+(u>>>et|0),u=Ue(M,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=l[P>>2],!u)break i;l[k>>2]=u,k=k+4|0}if(u=et+l[q+44>>2]|0,l[q+44>>2]=u,P=(!S<<2)+P|0,S=W?z:P,k=k-S>>2>(ot|0)?S+(ot<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=Ue(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}if(S=(dt-((yt|0)!=102?u:0)|0)-((yt|0)==103&(dt|0)!=0)|0,(S|0)<(Ue(k-z>>2,9)-9|0)){if(M=S+9216|0,K=(M|0)/9|0,tt=((((tt|0)<0?4:292)+q|0)+(K<<2)|0)-4048|0,S=10,et=M+Ue(K,-9)|0,(et|0)<=7)for(;S=Ue(S,10),et=et+1|0,(et|0)!=8;);M=l[tt>>2],ot=(M>>>0)/(S>>>0)|0,W=Ue(ot,S),K=tt+4|0;i:{if((M|0)==(W|0)&(K|0)==(k|0))break i;M=M-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(pt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(X=(k|0)==(K|0)?1:1.5,K=S>>>1|0,X=K>>>0>M>>>0?.5:(K|0)==(M|0)?X:1.5,At[Ot|0]!=45|$t||(X=-X,a=-a),l[tt>>2]=W,a+X==a)break i;if(u=S+W|0,l[tt>>2]=u,u>>>0>=1e9)for(;l[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,l[P>>2]=0),u=l[tt>>2]+1|0,l[tt>>2]=u,u>>>0>999999999;);if(u=Ue(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,M=k>>>0<=P>>>0,!M&&(k=K-4|0,!l[k>>2]););i:{if((yt|0)!=103){tt=y&8;break i}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,A=(k?-1:-2)+A|0,tt=y&8,tt)break i;k=-9;e:{if(M||(tt=l[K-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=Ue(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=Ue(K-z>>2,9),(A&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break i}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(et=-1,M=tt|dt,((M?2147483645:2147483646)|0)<(dt|0))break t;W=(((M|0)!=0)+dt|0)+1|0,S=A&-33;i:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break i}if(k=u>>31,k=Bn((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,pt[k|0]=48,(mt-k|0)<2;);if(ot=k-2|0,pt[ot|0]=A,pt[k-1|0]=(u|0)<0?45:43,k=mt-ot|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(at^2147483647))break t;W=u+at|0,mi(r,32,h,W,y),hi(r,Ot,at),mi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(A=q+16|0,u=A|8,tt=A|9,S=P>>>0>z>>>0?z:P,P=S;;){k=Bn(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break n;for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;pt[q+24|0]=48,k=u}if(hi(r,k,tt-k|0),P=P+4|0,!(z>>>0>=P>>>0))break}if(M&&hi(r,4275,1),(dt|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Bn(l[P>>2],0,tt),k>>>0>q+16>>>0)for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);if(hi(r,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(z=P>>>0<K>>>0?K:P+4|0,A=q+16|0,u=A|8,K=A|9,S=P;;){k=Bn(l[S>>2],0,K),(K|0)==(k|0)&&(pt[q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break a;for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);break a}if(hi(r,k,1),k=k+1|0,!(tt|dt))break a;hi(r,4275,1)}if(A=K-k|0,hi(r,k,(A|0)>(dt|0)?dt:A),dt=dt-A|0,S=S+4|0,z>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}mi(r,48,dt+18|0,18,0),hi(r,ot,mt-ot|0);break i}k=dt}mi(r,48,k+9|0,9,0)}mi(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(A<<26>>31&9)+Ot|0;r:{if(u>>>0>11)break r;for(k=12-u|0,X=16;X=X*16,k=k-1|0,!!k;);if(At[tt|0]==45){a=-(X+(-a-X));break r}a=a+X-X}for(z=at|2,P=A&32,S=l[q+44>>2],k=S>>31,k=Bn((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(pt[q+15|0]=48,k=q+15|0),dt=k-2|0,pt[dt|0]=A+15,pt[k-1|0]=(S|0)<0?45:43,k=y&8,S=q+16|0;A=S,Ge(a)<2147483648?K=~~a:K=-2147483648,pt[S|0]=P|At[K+5504|0],a=(a-+(K|0))*16,S=A+1|0,!(k|(u|0)>0)&a==0|(S-(q+16|0)|0)!=1||(pt[A+1|0]=46,S=A+2|0),a!=0;);if(et=-1,k=mt-dt|0,A=k+z|0,(2147483645-A|0)<(u|0))break t;r:{i:{if(!u||(P=S-(q+16|0)|0,(P-2|0)>=(u|0)))break i;u=u+2|0;break r}P=S-(q+16|0)|0,u=P}A=u+A|0,mi(r,32,h,A,y),hi(r,tt,z),mi(r,48,h,A,y^65536),hi(r,q+16|0,P),mi(r,48,u-P|0,0,0),hi(r,dt,k),mi(r,32,h,A,y^8192),et=(h|0)<(A|0)?A:h}return Et=q+560|0,et|0}function yp(r,a,h,u,y,A,k){var S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0,at=0,ot=0,mt=0,yt=0,_t=0,Ot=0,$t=0,Ht=0,Zt=0;K=Et-80|0,Et=K,l[K+76>>2]=a,$t=K+55|0,ot=K+56|0;t:{r:{i:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=At[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(At[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=At[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Ot=W^2147483647,(S|0)>(Ot|0))break e;if(r&&hi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,X=-1,P=pt[a+1|0],!nl(P)|At[a+2|0]!=36||(X=P-48|0,mt=1,S=a+3|0),l[K+76>>2]=S,M=0,P=pt[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,l[K+76>>2]=dt,M=a|M,P=pt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=pt[dt+1|0];h:{if(!(!nl(a)|At[dt+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,mt=1,z=l[((pt[dt+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=dt+1|0,!r){l[K+76>>2]=P,mt=0,z=0;break c}a=l[h>>2],l[h>>2]=a+4,mt=0,z=l[a>>2]}if(l[K+76>>2]=P,(z|0)>=0)break c;z=0-z|0,M=M|8192;break c}if(z=Gp(K+76|0),(z|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(At[P|0]!=46){a=P,at=0;break c}if(At[P+1|0]==42){a=pt[P+2|0];h:{if(!(!nl(a)|At[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((pt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(a=P+2|0,et=0,!r)break h;P=l[h>>2],l[h>>2]=P+4,et=l[P>>2]}l[K+76>>2]=a,at=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Gp(K+76|0),a=l[K+76>>2],at=1}for(;;){if(q=S,dt=28,yt=a,S=pt[a|0],S-123>>>0<4294967238)break i;if(a=yt+1|0,S=At[(S+Ue(q,58)|0)+4975|0],!(S-1>>>0<8))break}l[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((X|0)>=0){l[(X<<2)+y>>2]=S,S=(X<<3)+u|0,P=l[S+4>>2],l[K+64>>2]=l[S>>2],l[K+68>>2]=P;break h}if(!r)break n;_p(K- -64|0,S,h,k);break c}if((X|0)>=0)break i}if(S=0,!r)continue s}P=M&-65537,M=M&8192?P:M,X=0,_t=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=pt[yt|0],S=q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break A;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break E}E:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break E}if((S|0)==83)break v;break a}P=l[K+64>>2],q=l[K+68>>2],S=1167;break g}S=0;A:switch(q&255){case 0:l[l[K+64>>2]>>2]=W;continue s;case 1:l[l[K+64>>2]>>2]=W;continue s;case 2:tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s;case 3:Fr[l[K+64>>2]>>1]=W;continue s;case 4:pt[l[K+64>>2]]=W;continue s;case 6:l[l[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,M=M|8,S=120}if(tt=ot,P=l[K+64>>2],q=l[K+68>>2],P|q)for(Ht=S&32;tt=tt-1|0,pt[tt|0]=Ht|At[(P&15)+5504|0],Zt=!q&P>>>0>15|(q|0)!=0,yt=q,q=q>>>4|0,P=(yt&15)<<28|P>>>4,!!Zt;);if(!(M&8)|!(l[K+64>>2]|l[K+68>>2]))break u;_t=(S>>>4|0)+1167|0,X=2;break u}if(S=ot,tt=l[K+68>>2],q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,pt[S|0]=P&7|48,yt=!q&P>>>0>7|(q|0)!=0,tt=q,q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!yt;);if(tt=S,!(M&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=l[K+64>>2],S=l[K+68>>2],q=S,(S|0)<0){tt=0-(q+((P|0)!=0)|0)|0,q=tt,P=0-P|0,l[K+64>>2]=P,l[K+68>>2]=tt,X=1,S=1167;break g}if(M&2048){X=1,S=1168;break g}X=M&1,S=X?1169:1167}_t=S,tt=Bn(P,q,ot)}if((et|0)<0&&at)break e;if(M=at?M&-65537:M,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}M=0,at=et>>>0>=2147483647?2147483647:et,q=at,dt=(q|0)!=0;y:{u:{S=l[K+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!q)break m;for(;;){if(M=At[S|0],!M)break b;if(q=q-1|0,dt=(q|0)!=0,S=S+1|0,!(S&3))break m;if(!q)break}}if(!dt)break u;m:{if(!(!At[S|0]|q>>>0<4))for(;;){if(dt=l[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,q=q-4|0,!(q>>>0>3))break}if(!q)break u}dt=0;break g}dt=1}for(;;){if(!dt){M=At[S|0],dt=1;continue}if(!M)break y;if(S=S+1|0,q=q-1|0,!q)break u;dt=0}}S=0}if(S=S?S-tt|0:at,dt=S+tt|0,(et|0)>=0){M=P,et=S;break a}if(M=P,et=S,At[dt|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,mi(r,32,z,0,M);break f}l[K+12>>2]=0,l[K+8>>2]=l[K+64>>2],P=K+8|0,l[K+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=l[P>>2],!tt)break d;if(tt=Kp(K+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break r}if(dt=61,(S|0)<0)break i;if(mi(r,32,z,S,M),!S){S=0;break f}for(dt=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=Kp(K+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(hi(r,K+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}mi(r,32,z,S,M^8192),S=(S|0)<(z|0)?z:S;continue s}if((et|0)<0&&at)break e;if(dt=61,S=Pt[A|0](r,Fe[K+64>>3],z,et,M,S)|0,(S|0)>=0)continue s;break i}pt[K+55|0]=l[K+64>>2],et=1,tt=$t,M=P;break a}P=At[S+1|0],S=S+1|0}if(r)break t;if(!mt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(_p((S<<3)+u|0,r,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(l[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break i}if(q=dt-tt|0,et=(et|0)>(q|0)?et:q,(et|0)>(X^2147483647))break e;if(dt=61,P=et+X|0,S=(P|0)<(z|0)?z:P,(Ot|0)<(S|0))break i;mi(r,32,S,P,M),hi(r,_t,X),mi(r,48,S,P,M^65536),mi(r,48,et,q,0),hi(r,tt,q),mi(r,32,S,P,M^8192);continue}break}W=0;break t}dt=61}l[1781]=dt}W=-1}return Et=K+80|0,W}function xE(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),A=m(0),k=0,S=m(0),P=0,K=m(0),tt=0,dt=m(0),q=0;q=Et+-64|0,Et=q,k=l[r>>2],Bi(q+8|0,0,56),l[1755]=l[1755]+1,Ap(k),S=m(a),A=I[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*S)*m(.009999999776482582))}dt=m(y+m(de(k,2,S)+we(k,2,S))),tt=1;break t}y=m(0),A=I[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(A==A)break n;tt=4344}switch(y=I[tt>>2],l[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],dt=m(zt),tt=2,l[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}K=m(h),A=I[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*K)*m(.009999999776482582))}A=m(y+m(de(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),A=I[k+220>>2];r:{i:{r=l[k+220>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;P=4336;n:{if((r|0)!=2141891242){if(A==A)break n;P=4344}switch(y=I[P>>2],l[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*K)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],A=m(zt),r=2,l[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}A=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,A=K;break t}r=2,A=y}un(k,dt,A,u,tt,r,S,K,1,0,l[k+568>>2],q+8|0,0,l[1755])&&(xp(k,At[k+300|0]&3,S,K,S),Lp(k,+I[l[k+568>>2]+20>>2],0,0)),Et=q- -64|0}function DE(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,A=0,k=m(0),S=0,P=0,K=0,tt=m(0);t:{P=l[a>>2],a=l[r>>2];r:{if((l[P+24>>2]^l[a+24>>2])&8388607)break r;tt=I[P+40>>2],y=l[P+40>>2],u=I[a+40>>2];i:{e:{if(h=l[a+40>>2],(h|0)!=2139156720){if(k=m(zt),r=3,(h|0)==2141891242)break i;if((h|0)!=2140081935)break e;k=m(0),r=1;break i}r=2;break i}if(r=0,u!=u)break i;k=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}i:{e:{if((y|0)!=2139156720){if(u=m(zt),h=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break e;u=m(0),h=1;break i}u=m(0),h=2;break i}if(h=0,tt!=tt)break i;u=(Dt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Ge(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,A=P+44|0,l[h>>2]!=l[A>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,A=P+80|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,A=P+116|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,A=P+152|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,A=P+188|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<2)break r}for(S=P+200|0,K=a+200|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0)||(k=I[P+28>>2],r=k!=k,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],r=k!=k,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&r))break t}for(Ui(a+24|0,P+24|0,204);;){if(r=At[a+4|0],r&4)break t;if(pt[a+4|0]=r|4,r=l[a+20>>2],r&&Pt[r|0](a),l[a+308>>2]=2143289344,a=l[a+552>>2],!a)break}}}function PE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,M=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],q=r,k=Et-32|0,Et=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=l[a+8>>2],a=h;t:{if((y|0)==(r|0)&a>>>0<a>>>0|r>>>0>y>>>0){if(r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){r=r+1073741824|0,a=a+1|0,r=a?r:r+1|0;break t}if(r=r+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,r=a>>>0<u>>>0?r+1|0:r;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h&524287|2146959360;break t}if(a=0,r=2146435072,S>>>0>1140785151||(r=0,et=S>>>16|0,et>>>0<15249))break t;a=P,r=u,y=q&65535|65536,S=y,dt=h,A=h,K=et-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,A=0):(r=(1<<a)-1&h>>>32-a|r<<a,A=h<<a),y=r,a=0,r=0;break r}if(!K)break r;tt=A,A=K&31,(K&63)>>>0>=32?(h=tt<<A,A=0):(h=(1<<A)-1&tt>>>32-A|y<<A,A=tt<<A),y=h,W=A,tt=a,h=64-K|0,A=h&31,(h&63)>>>0>=32?(h=0,a=r>>>A|0):(h=r>>>A|0,a=((1<<A)-1&r)<<32-A|tt>>>A),A=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|r<<a,a=tt<<a),r=h}l[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=A,l[k+28>>2]=y,a=15361-et|0;r:{if(a&64){u=dt,a=a+-64|0,r=a&31,(a&63)>>>0>=32?(h=0,P=S>>>r|0):(h=S>>>r|0,P=((1<<r)-1&S)<<32-r|u>>>r),u=h,dt=0,S=0;break r}if(!a)break r;y=dt,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,A=0):(r=(1<<h)-1&y>>>32-h|S<<h,A=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=A|y,u=r|h,y=dt,h=a&31,(a&63)>>>0>=32?(r=0,dt=S>>>h|0):(r=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=dt,l[k+12>>2]=S,a=l[k+8>>2],r=l[k+12>>2]<<4|a>>>28,a=a<<4,h=l[k>>2],S=l[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(l[k+16>>2]|l[k+24>>2]|(l[k+20>>2]|l[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,r=a?r:r+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,r=h>>>0>a>>>0?r+1|0:r}Et=k+32|0,Dt(0,a|0),Dt(1,q&-2147483648|r),z=M,X=+Ae(),Fe[z>>3]=X}function un(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var M=m(0),W=0,z=0,X=0,at=0,ot=m(0),mt=0,yt=0,_t=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&At[r+4|0]&4)&&(at=0,l[r+316>>2]==(u|0)))break t;l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+320>>2]=0,at=1}mt=q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(ot=de(r,2,k),_t=we(r,2,k),M=m(de(r,0,k)+we(r,0,k)),q=r+524|0,ot=m(ot+_t),Tp(y,a,A,h,l[r+532>>2],I[q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],ot,M,tt))break i;if(z=l[r+320>>2],!z)break e;for(W=r+324|0;;){if(q=W+Ue(X,24)|0,Tp(y,a,A,h,l[q+8>>2],I[q>>2],l[q+12>>2],I[q+4>>2],I[q+16>>2],I[q+20>>2],ot,M,tt))break i;if(X=X+1|0,(z|0)==(X|0))break}break e}if(!P){if(yt=l[r+320>>2],!yt)break e;for(z=r+324|0;;){W=Ue(X,24),q=W+z|0,M=I[q>>2];s:{n:{if(!(M!=M|a!=a)){if(m(Ge(m(M-a)))<m(9999999747378752e-20))break n;break s}if(M==M|a==a)break s}W=z+W|0,M=I[W+4>>2];n:{if(!(M!=M|h!=h)){if(m(Ge(m(M-h)))<m(9999999747378752e-20))break n;break s}if(M==M|h==h)break s}if(l[W+8>>2]!=(y|0))break s;if(l[W+12>>2]==(A|0))break i}if(X=X+1|0,(yt|0)==(X|0))break}break e}q=r+524|0,M=I[q>>2];s:{if(!(M!=M|a!=a)){if(m(Ge(m(M-a)))<m(9999999747378752e-20))break s;break e}if(M==M|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(A|0)?q:0,M=I[r+528>>2],q=M!=M,z=h!=h;s:{if(q|z){q=q&z;break s}q=m(Ge(m(M-h)))<m(9999999747378752e-20)}q=q?W:0;break i}mp(r,a,h,u,y,A,k,S,P,tt,dt,mt,et,K),l[r+316>>2]=u;break r}if(!(!q|at)){I[r+516>>2]=I[q+16>>2],I[r+520>>2]=I[q+20>>2],u=(P?12:16)+dt|0,l[u>>2]=l[u>>2]+1;break t}if(mp(r,a,h,u,y,A,k,S,P,tt,dt,mt,et,K),l[r+316>>2]=u,q)break t}q=l[r+320>>2],u=q+1|0,u>>>0>cp[dt+8>>2]&&(l[dt+8>>2]=u),(q|0)==8&&(l[r+320>>2]=0,q=0),P?u=r+524|0:(l[r+320>>2]=q+1,u=(Ue(q,24)+r|0)+324|0),l[u+12>>2]=A,l[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[r+516>>2],I[u+20>>2]=I[r+520>>2],q=0}t:{if(!P||(u=l[r+520>>2],l[r+244>>2]=l[r+516>>2],l[r+248>>2]=u,u=At[r+4|0],y=u|1,pt[r+4|0]=y,!(u&4)))break t;pt[r+4|0]=y&251}return l[r+312>>2]=et,!q|at}function kh(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=l[1751],A=a,y=l[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=mr(r),k=((r>>>29-u^4)-(u<<2)|0)+110|0,r>>>0<=4095)break i;u=((r>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;i:{if(a|u){h=u-1|0,P=h+1|0,A=h,h=a-1|0,A=(h|0)!=-1?P:A,u=mr(u^A),u=(u|0)==32?mr(a^h)+32|0:u,h=63-u|0,Fi=0-(u>>>0>63)|0;break i}Fi=0,h=64}A=h,h=A&31,(A&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=A+k|0,h=k<<4,a=l[h+5976>>2],A=h+5968|0;i:{if((a|0)!=(A|0)){if(y=Rh(a,S,r),y)break t;y=l[a+4>>2],l[y+8>>2]=l[a+8>>2],l[l[a+8>>2]+4>>2]=y,l[a+8>>2]=A,y=h+5972|0,l[a+4>>2]=l[y>>2],l[y>>2]=a,l[l[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=l[1751],A=k&63,a=A,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=A&31,A>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,A=0-k&63,h=A,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=A&31,A>>>0>=32?(A=0,a=a>>>h|0):(A=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Fi=y|A,l[1750]=l[1750]&a,l[1751]=Fi&K,a=P^1}if(!(a|u))break}A=l[1751],y=l[1750]}i:{if(y|A){u=mr(A),h=63-((u|0)==32?mr(y)+32|0:u)|0,a=h<<4,u=l[a+5976>>2];e:{if(!A&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=Rh(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(Sh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=Rh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!Sh(r+48|0))break r}if(y=0,S-1&S)break t;if(!(r>>>0<=4294967239))break}break t}y=0}return y|0}function OE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0;S=Et-80|0,Et=S,r=l[r>>2];t:{r:{if(P=l[a>>2],!l[P+552>>2]){if(l[r+8>>2])break r;a=l[r+556>>2],k=a+(h<<2)|0,u=l[r+560>>2],y=r+564|0,A=l[y>>2];i:{if(u>>>0<A>>>0){if((u|0)==(k|0)){l[k>>2]=P,l[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;l[h>>2]=l[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);l[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Ps(u-(a&-4)|0,k,a)),l[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=A-a|0,A=a>>1,y=Na(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<A>>>0?A:u,h,y),h=l[y+8>>2];e:{if((h|0)!=l[y+12>>2])break e;if(a=l[y+4>>2],u=l[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,A=a,a=h-a|0,h=Ps(K,A,a)+a|0,l[y+8>>2]=h,l[y+4>>2]=u+l[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,A=Na(S+56|0,a,a>>>2|0,l[y+16>>2]),u=l[A+8>>2],a=l[y+4>>2],h=l[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=l[y+8>>2],u=l[y+4>>2]}if(K=l[y>>2],l[y>>2]=l[A>>2],l[A>>2]=K,l[y+4>>2]=l[A+4>>2],l[A+4>>2]=u,l[y+8>>2]=h,l[A+8>>2]=a,tt=l[y+12>>2],l[y+12>>2]=l[A+12>>2],l[A+12>>2]=tt,(a|0)!=(u|0)&&(l[A+8>>2]=((u-a|0)+3&-4)+a),!K)break e;gi(K),h=l[y+8>>2]}if(l[h>>2]=P,l[y+8>>2]=l[y+8>>2]+4,a=l[r+556>>2],h=k-a|0,dt=y,q=Ps(l[y+4>>2]-h|0,a,h),l[dt+4>>2]=q,u=l[r+560>>2]-k|0,k=Ps(l[y+8>>2],k,u),a=l[r+556>>2],l[r+556>>2]=l[y+4>>2],l[y+4>>2]=a,h=l[r+560>>2],l[r+560>>2]=u+k,l[y+8>>2]=h,u=l[r+564>>2],l[r+564>>2]=l[y+12>>2],l[y>>2]=a,l[y+12>>2]=u,(a|0)!=(h|0)&&(l[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;gi(a)}for(l[P+552>>2]=r;a=At[r+4|0],!!(!(a&4)&&(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=S+80|0;return}l[S+16>>2]=4075,sr(r,S+16|0),qi(),he()}l[S>>2]=4208,sr(r,S),qi(),he()}Ds(),he()}function bp(r,a){var h=0,u=0;for(l[r>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r+24>>2]=0,l[r+36>>2]=2143289344,l[r+40>>2]=2141891242,l[r+28>>2]=2143289344,l[r+32>>2]=2143289344,pt[r+4|0]=At[r+4|0]&128,u=Bi(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+152|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,l[r+196>>2]=0,u=r+188|0,l[u>>2]=0,l[u+4>>2]=0;l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(l[r+24>>2]=4224,l[r+224>>2]=2143289344,l[r+216>>2]=2143289344,l[r+220>>2]=2143289344,l[r+208>>2]=2143289344,l[r+212>>2]=2143289344,l[r+200>>2]=2141891242,l[r+204>>2]=2141891242,Bi(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Bi(r+252|0,0,49),l[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return l[r+548>>2]=0,l[r+552>>2]=0,l[r+516>>2]=2143289344,l[r+520>>2]=2143289344,l[r+572>>2]=2143289344,l[r+576>>2]=0,l[r+568>>2]=a,l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+556>>2]=0,l[r+560>>2]=0,l[r+564>>2]=0,l[r+580>>2]=2143289344,l[r+584>>2]=0,Qp((a|0)!=0,2760),pt[r+4|0]=At[r+4|0]|1,pt[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function He(r,a,h,u){var y=m(0),A=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){A=I[r+212>>2],a=l[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(A==A)break o;k=4344}switch(y=I[k>>2],A=m(zt),l[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break n}A=m(m(y*u)*m(.009999999776482582));break s}A=I[r+208>>2];a:{o:{a=l[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(A==A)break c;k=4344}switch(y=I[k>>2],A=m(zt),l[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break o}A=m(m(y*u)*m(.009999999776482582));break a}A=y}y=m(0),S=I[r+216>>2],r=l[r+216>>2];a:{if((r|0)==2139156720)break a;if((r|0)==2140081935)break i;a=4336;o:{if((r|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}A=y}y=m(0),S=I[r+220>>2],r=l[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;a=4336;n:{if((r|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break r}if(h>y)break t}if(!(A>=m(0)))return h;y=h<A?A:h}return y}function Ap(r){var a=0,h=0,u=m(0),y=m(0),A=m(0),k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0;for(k=Et-16|0,l[k+8>>2]=0,l[k+12>>2]=1,tt=r+200|0,dt=r+572|0,q=r+208|0,et=r+216|0,r=0;;){M=r,K=l[(k+8|0)+(r<<2)>>2],S=K<<2,r=et+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=l[r>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;r=S+q|0,y=I[r>>2],h=l[r>>2];a:{o:{if((h|0)!=2139156720){if(A=m(zt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;A=m(0),r=1;break a}A=m(0),r=2;break a}if(r=0,y!=y)break a;A=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(zt),r=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),r=1;break a}y=m(0),r=2;break a}if(r=0,u!=u)break a;y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&A!=A|m(Ge(m(y-A)))<m(9999999747378752e-20)))break n;if(r=0,P)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(r=0,a=S+tt|0,u=I[a>>2],a=l[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}r=2143289344,a=0;break t}r=2143289344,a=3;break t}a=1}if(h=(K<<3)+dt|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(M&1))break}}function Ui(r,a,h){var u=0,y=0,A=0;if(h>>>0>=512)return wE(r|0,a|0,h|0),r;y=r+h|0;t:{if(!((r^a)&3)){r:{if(!(r&3)){h=r;break r}if(!h){h=r;break r}for(h=r;;){if(pt[h|0]=At[a|0],a=a+1|0,h=h+1|0,!(h&3))break r;if(!(h>>>0<y>>>0))break}}u=y&-4;r:{if(u>>>0<64||(A=u+-64|0,A>>>0<h>>>0))break r;for(;l[h>>2]=l[a>>2],l[h+4>>2]=l[a+4>>2],l[h+8>>2]=l[a+8>>2],l[h+12>>2]=l[a+12>>2],l[h+16>>2]=l[a+16>>2],l[h+20>>2]=l[a+20>>2],l[h+24>>2]=l[a+24>>2],l[h+28>>2]=l[a+28>>2],l[h+32>>2]=l[a+32>>2],l[h+36>>2]=l[a+36>>2],l[h+40>>2]=l[a+40>>2],l[h+44>>2]=l[a+44>>2],l[h+48>>2]=l[a+48>>2],l[h+52>>2]=l[a+52>>2],l[h+56>>2]=l[a+56>>2],l[h+60>>2]=l[a+60>>2],a=a- -64|0,h=h- -64|0,A>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;l[h>>2]=l[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=r;break t}if(u=y-4|0,u>>>0<r>>>0){h=r;break t}for(h=r;pt[h|0]=At[a|0],pt[h+1|0]=At[a+1|0],pt[h+2|0]=At[a+2|0],pt[h+3|0]=At[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;pt[h|0]=At[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Ep(r,a,h,u,y){var A=m(0),k=0,S=m(0),P=m(0),K=0,tt=0,dt=m(0),q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+r|0,A=I[k+208>>2];t:{r:{k=l[k+208>>2];i:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break r;K=4336;s:{if((k|0)!=2141891242){if(A==A)break s;K=4344}switch(h=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;break t}P=m(h-u)}h=m(0),r=(a<<2)+r|0,A=I[r+216>>2];t:{r:{a=l[r+216>>2];i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break r;r=4336;s:{if((a|0)!=2141891242){if(A==A)break s;r=4344}switch(h=I[r>>2],A=m(34028234663852886e22),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;A=m(34028234663852886e22);break t}A=m(h-u)}if(h=(dt=S,q=xh(S,A),et=A!=A|tt,et?dt:q),r=h!=h,!(r|P!=P))return ce(h,P);S=r?P:h}return S}function Tp(r,a,h,u,y,A,k,S,P,K,tt,dt,q){var et=m(0),M=m(0),W=0,z=0,X=m(0),at=m(0),ot=m(0),mt=0,yt=0;if(P<m(0)|K<m(0))r=0;else{X=A,at=a,ot=u,M=S;t:{if(!q||(et=I[q+20>>2],M=S,et==m(0)))break t;mt=+et,at=Gr(+a,mt,0,0),ot=Gr(+u,mt,0,0),X=Gr(+A,mt,0,0),M=Gr(+S,mt,0,0)}et=M,q=0;t:{if((r|0)!=(y|0))break t;if(yt=X!=X,q=at!=at,yt|q){q=q&yt;break t}q=m(Ge(m(X-at)))<m(9999999747378752e-20)}yt=q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,q=ot!=ot,W|q){W=q&W;break t}W=m(Ge(m(et-ot)))<m(9999999747378752e-20)}z=1,q=1;t:{if(yt)break t;a=m(a-tt);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(a>=P))break r;break t}if(q=0,!(a<A)|(r|(y|0)!=2|(a!=a|A!=A|P!=P))||(q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){q=r&y;break t}q=m(Ge(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(z=0,!(a<S)|(r|(k|0)!=2|(a!=a|S!=S|K!=K))||(z=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){z=r&h;break t}z=m(Ge(m(a-K)))<m(9999999747378752e-20)}r=q&z}return r}function wh(r){var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0;if(pi(+r),A=te(1)|0,u=te(0)|0,y=A>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=A<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?r*0:r;t:{if(!y){if(y=0,h=u<<12,a=A<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|A<<h,u=u<<h);break t}a=A&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=A&-2147483648,k=a+-1048576|y<<20,S=h,A=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=A>>>h|0):(a=A>>>h|0,u=((1<<h)-1&A)<<32-h|S>>>h),h=(y|0)>0,Dt(0,(h?S:u)|0),Dt(1,(h?k:a)|P),+Ae()}function Sh(r){var a=0,h=0,u=0,y=0,A=0;u=l[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>d2()<<16>>>0&&!(kE(h|0)|0))break r;l[1416]=h;break t}l[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,l[h+12>>2]=16,l[h>>2]=16,r=l[1748],r?A=l[r+8>>2]:A=0;t:{r:{if((A|0)==(u|0)){if(y=u-(l[u-4>>2]&-2)|0,A=l[y-4>>2],l[r+8>>2]=a,r=y-(A&-2)|0,a=-16,!(pt[(r+l[r>>2]|0)-4|0]&1))break r;a=l[r+4>>2],l[a+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=a,h=h-r|0,l[r>>2]=h;break t}l[u+12>>2]=16,l[u>>2]=16,l[u+8>>2]=a,l[u+4>>2]=r,l[1748]=u,a=16}r=a+u|0,h=h-r|0,l[r>>2]=h}l[((h&-4)+r|0)-4>>2]=h|1,a=l[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=mr(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,l[r+4>>2]=a+5968,a=a+5976|0,l[r+8>>2]=l[a>>2],l[a>>2]=r,l[l[r+8>>2]+4>>2]=r,a=l[1750],y=l[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,A=0):(A=1<<r,h=A-1&1>>>32-r),l[1750]=A|a,l[1751]=h|y}return(u|0)!=-1}function kp(r,a,h){var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;t:{r:{i:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}r=(r>>>0)/(h>>>0)|0,Fi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;A=(mr(h)+33|0)-mr(a)|0,k=0-A|0;break e}r=(a>>>0)/0|0,Fi=0;break t}if(u=32-mr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;A=h?31-mr(h-1^h)|0:32,h=A&31,(A&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Fi=u;break t}A=u+1|0,k=63-u|0}if(u=A&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|r>>>y),k=k&63,y=k&31,k>>>0>=32?(a=r<<y,r=0):(a=(1<<y)-1&r>>>32-y|a<<y,r=r<<y),A)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,K=h&y,S=u-K|0,u=P-(u>>>0<K>>>0)|0,a=a<<1|r>>>31,r=tt|r<<1,tt=y&1,A=A-1|0,!!A;);Fi=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Fi=a}return r}function Jo(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=l[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+196>>2],u=I[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break i;break r}if(a=l[r+192>>2],u=I[r+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[r+196>>2],a=l[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break i;if(u!=u)break r}u=m(0);i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function wp(r,a){var h=0,u=0,y=0,A=0,k=0,S=0;for(h=Et-320|0,Et=h,u=Bi(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Bi(h+24|0,0,49),l[h+80>>2]=2143289344,A=h+288|0,y=h+96|0;h=y,l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,y=h+24|0,(A|0)!=(y|0););if(l[u+312>>2]=-1082130432,l[u+316>>2]=-1082130432,l[u+304>>2]=0,l[u+308>>2]=0,l[u+296>>2]=-1082130432,l[u+300>>2]=-1082130432,l[u+288>>2]=2143289344,l[u+292>>2]=2143289344,Ui(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,pt[r+4|0]=At[r+4|0]|1,y=l[r+556>>2],k=l[r+560>>2],(y|0)!=(k|0))for(;h=l[y>>2],l[h+552>>2]!=(r|0)&&(A=l[r+568>>2],h=Ip(l[A>>2],At[A+8|0],h,r,S,a),l[y>>2]=h,l[h+552>>2]=r,h=l[y>>2]),wp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););Et=u+320|0}function Rh(r,a,h){var u=0,y=0,A=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=l[r>>2],y+h>>>0<=(a+r|0)-4>>>0){A=l[r+4>>2],l[A+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=A,(u|0)!=(y|0)&&(y=y-u|0,A=r-(l[r-4>>2]&-2)|0,u=y+l[A>>2]|0,l[A>>2]=u,l[(A+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,l[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,l[u>>2]=a,l[(u+(a&-4)|0)-4>>2]=a|1,y=l[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(A=mr(y),a=((y>>>29-A^4)-(A<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-A^2)-(A<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,l[u+4>>2]=y+5968,y=y+5976|0,l[u+8>>2]=l[y>>2],l[y>>2]=u,l[l[u+8>>2]+4>>2]=u,y=l[1750],A=l[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),l[1750]=u|y,l[1751]=a|A,a=h+8|0,l[r>>2]=a,l[((a&-4)+r|0)-4>>2]=a;break t}l[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function ME(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0;y=Et-320|0,Et=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!Mp(r,u)))break t;if((r|0)==(a|0)){for(h=Bi(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Bi(a+24|0,0,49),l[a+80>>2]=2143289344,A=a+288|0,a=a+96|0;l[a+16>>2]=-1082130432,l[a+20>>2]=-1082130432,l[a+8>>2]=0,l[a+12>>2]=0,l[a>>2]=-1082130432,l[a+4>>2]=-1082130432,a=a+24|0,(A|0)!=(a|0););l[h+312>>2]=-1082130432,l[h+316>>2]=-1082130432,l[h+304>>2]=0,l[h+308>>2]=0,l[h+296>>2]=-1082130432,l[h+300>>2]=-1082130432,l[h+288>>2]=2143289344,l[h+292>>2]=2143289344,Ui(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=y+320|0}function Sp(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0;if(r){if(k=Et-32|0,Et=k,a=l[r>>2],u=l[a+552>>2],u&&(Mp(u,a),l[a+552>>2]=0),u=l[a+556>>2],h=l[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;l[l[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););l[a+560>>2]=u,h=a+564|0;t:{if(l[h>>2]==(u|0)||(h=Na(k+8|0,0,0,h),y=l[a+556>>2],A=l[a+560>>2]-y|0,u=l[h+4>>2]-A|0,A=Ps(u,y,A),y=l[a+556>>2],l[a+556>>2]=A,l[h+4>>2]=y,A=l[a+560>>2],l[a+560>>2]=l[h+8>>2],l[h+8>>2]=A,S=l[a+564>>2],l[a+564>>2]=l[h+12>>2],l[h>>2]=y,l[h+12>>2]=S,(y|0)!=(A|0)&&(l[h+8>>2]=A+((y-A|0)+3&-4)),!y))break t;gi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,gi(u)),gi(a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Et=k+32|0,gi(r)}}function $E(r){r=r|0;var a=0,h=0,u=0;u=Et-624|0,Et=u,a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a);t:{if(r=l[r>>2],l[r+560>>2]==l[r+556>>2]){if(l[r+552>>2])break t;a=bp(u+32|0,l[r+568>>2]),h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h,h=l[a+20>>2],l[r+16>>2]=l[a+16>>2],l[r+20>>2]=h,h=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=h,Ui(r+24|0,a+24|0,204),Ui(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,gi(h)),l[r+556>>2]=l[a+556>>2],l[r+560>>2]=l[a+560>>2],l[r+564>>2]=l[a+564>>2],l[r+584>>2]=l[a+584>>2],h=l[a+580>>2],l[r+576>>2]=l[a+576>>2],l[r+580>>2]=h,h=l[a+572>>2],l[r+568>>2]=l[a+568>>2],l[r+572>>2]=h,Et=u+624|0;return}l[u+16>>2]=3301,sr(r,u+16|0),qi(),he()}l[u>>2]=2047,sr(r,u),qi(),he()}function Rp(){CE(7084,3067),LE(7085,2480,1,1,0),ls(7086,2140,1,-128,127),ls(7087,2133,1,-128,127),ls(7088,2131,1,0,255),ls(7089,1287,2,-32768,32767),ls(7090,1278,2,0,65535),ls(7091,1316,4,-2147483648,2147483647),ls(7092,1307,4,0,-1),ls(7093,2659,4,-2147483648,2147483647),ls(7094,2650,4,0,-1),r2(7095,1777,-2147483648,2147483647),r2(7096,1776,0,-1),up(7097,1770,4),up(7098,3015,8),fp(7099,2677),fp(7100,3904),Ah(7101,4,2664),Ah(7102,2,2689),Ah(7103,4,2704),_E(7104,2485),ki(7105,0,3835),ki(7106,0,3937),ki(7107,1,3865),ki(7108,2,3467),ki(7109,3,3498),ki(7110,4,3538),ki(7111,5,3567),ki(7112,4,3974),ki(7113,5,4004),ki(7106,0,3669),ki(7107,1,3636),ki(7108,2,3735),ki(7109,3,3701),ki(7110,4,3802),ki(7111,5,3768),ki(7114,6,3605),ki(7115,7,4043)}function Ps(r,a,h){var u=0,y=0;t:{if((r|0)==(a|0))break t;if(y=r+h|0,a-y>>>0<=0-(h<<1)>>>0)return Ui(r,a,h);u=(r^a)&3;r:{i:{if(r>>>0<a>>>0){if(u){u=r;break r}if(!(r&3)){u=r;break i}for(u=r;;){if(!h)break t;if(pt[u|0]=At[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break i}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+r|0,pt[u|0]=At[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,l[h+r>>2]=l[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,pt[h+r|0]=At[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;pt[u|0]=At[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function _p(r,a,h,u){t:switch(a-9|0){case 0:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2];return;case 6:a=l[h>>2],l[h>>2]=a+4,a=Fr[a>>1],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 7:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=Nn[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=pt[a|0],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 9:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=At[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Fe[r>>3]=Fe[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=l[h>>2],l[h>>2]=a+4,a=l[a>>2],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2],l[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=l[h>>2]+7&-8,l[h>>2]=a+8,h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h}function Lp(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=m(0),M=m(0),W=m(0),z=0,X=m(0);t:{if(a==0||(et=I[r+248>>2],M=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=At[r+4|0]&8,A=y>>>3|0,z=r,X=Gr(P,a,0,A),I[z+228>>2]=X,K=+W,z=r,X=Gr(K,a,0,A),I[z+232>>2]=X,tt=+M,k=wh(tt*a),A=k==k&Ge(k)<1e-4,S=!(A|k!=k?A:Ge(k+-1)<1e-4),dt=+et,k=wh(dt*a),A=k==k&Ge(k)<1e-4,q=!(A|k!=k?A:Ge(k+-1)<1e-4),A=0,h=P+h,y=(y|0)!=0,z=r,X=m(Gr(h+tt,a,y&S,y&!S)-Gr(h,a,0,y)),I[z+244>>2]=X,u=K+u,z=r,X=m(Gr(u+dt,a,y&q,y&!q)-Gr(u,a,0,y)),I[z+248>>2]=X,y=l[r+560>>2],S=l[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=l[r+556>>2],l[r+560>>2]-y>>2>>>0>A>>>0?y=l[y+(A<<2)>>2]:y=0,Lp(y,a,h,u),A=A+1|0,(S|0)!=(A|0););}}function Bi(r,a,h){var u=0,y=0,A=0,k=0;t:{if(!h||(pt[r|0]=a,u=r+h|0,pt[u-1|0]=a,h>>>0<3)||(pt[r+2|0]=a,pt[r+1|0]=a,pt[u-3|0]=a,pt[u-2|0]=a,h>>>0<7)||(pt[r+3|0]=a,pt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=Ue(a&255,16843009),l[y>>2]=a,u=h-u&-4,h=u+y|0,l[h-4>>2]=a,u>>>0<9)||(l[y+8>>2]=a,l[y+4>>2]=a,l[h-8>>2]=a,l[h-12>>2]=a,u>>>0<25)||(l[y+24>>2]=a,l[y+20>>2]=a,l[y+16>>2]=a,l[y+12>>2]=a,l[h-16>>2]=a,l[h-20>>2]=a,l[h-24>>2]=a,l[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=Ih(a,0,1,1),A=Fi,a=y+k|0;l[a+24>>2]=u,l[a+28>>2]=A,l[a+16>>2]=u,l[a+20>>2]=A,l[a+8>>2]=u,l[a+12>>2]=A,l[a>>2]=u,l[a+4>>2]=A,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function gi(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;if(r){a=r-4|0,y=l[a>>2],h=y,u=a,A=l[r-8>>2],r=A&-2,(r|0)!=(A|0)&&(u=a-r|0,h=l[u+4>>2],l[h+8>>2]=l[u+8>>2],l[l[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=l[r>>2],(a|0)!=l[(r+a|0)-4>>2]&&(y=l[r+4>>2],l[y+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=y,h=a+h|0),l[u>>2]=h,l[((h&-4)+u|0)-4>>2]=h|1,a=l[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=mr(a),r=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;r=((a>>>30-h^2)-(h<<1)|0)+71|0,r=r>>>0>=63?63:r}a=r<<4,l[u+4>>2]=a+5968,a=a+5976|0,l[u+8>>2]=l[a>>2],l[a>>2]=u,l[l[u+8>>2]+4>>2]=u,a=l[1750],h=l[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),l[1750]=y|a,l[1751]=r|h}}function NE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0;u=Et-32|0,Et=u,y=l[r+28>>2],l[u+16>>2]=y,A=l[r+20>>2],l[u+28>>2]=h,l[u+24>>2]=a,a=A-y|0,l[u+20>>2]=a,A=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!e2(SE(l[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=l[u+12>>2],(k|0)==(A|0))break e;if((k|0)>=0)break i;break r}if((A|0)!=-1)break r}a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],r=h;break t}S=l[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,l[y>>2]=S+l[y>>2],a=(K?12:4)+a|0,l[a>>2]=l[a>>2]-S,A=A-k|0,P=P-K|0,a=y;continue}break}if(l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r>>2]=l[r>>2]|32,r=0,(P|0)==2)break t;r=h-l[a+4>>2]|0}return Et=u+32|0,r|0}function FE(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;h=Et-96|0,Et=h,l[h>>2]=r,u=Et-16|0,Et=u,l[u+12>>2]=h,r=Et-144|0,Et=r,r=Ui(r,5520,144),A=h+16|0,a=A,l[r+44>>2]=a,l[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,l[r+48>>2]=y,a=a+y|0,l[r+28>>2]=a,l[r+16>>2]=a,Cp(r,2202,h,0,0),y&&(a=l[r+20>>2],pt[a-((a|0)==l[r+16>>2])|0]=0),Et=r+144|0,Et=u+16|0,r=A;t:{if(r&3)for(;;){if(!At[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=l[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!At[r|0];);}return r=(r-A|0)+1|0,a=kh(r),a?r=Ui(a,A,r):r=0,Et=h+96|0,r|0}function Cp(r,a,h,u,y){var A=0,k=0,S=0,P=0;A=Et-208|0,Et=A,l[A+204>>2]=h,h=A+160|0,Bi(h,0,40),l[A+200>>2]=l[A+204>>2];t:{if((yp(0,a,A+200|0,A+80|0,h,u,y)|0)<0){y=-1;break t}P=l[r+76>>2]>=0,k=l[r>>2],l[r+72>>2]<=0&&(l[r>>2]=k&-33);r:{i:{e:{if(!l[r+48>>2]){l[r+48>>2]=80,l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,S=l[r+44>>2],l[r+44>>2]=A;break e}if(l[r+16>>2])break i}if(h=-1,Hp(r))break r}h=yp(r,a,A+200|0,A+80|0,A+160|0,u,y)}if(S&&(Pt[l[r+36>>2]](r,0,0)|0,l[r+48>>2]=0,l[r+44>>2]=S,l[r+28>>2]=0,a=l[r+20>>2],l[r+16>>2]=0,l[r+20>>2]=0,h=a?h:-1),a=r,r=l[r>>2],l[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return Et=A+208|0,y}function tl(r){var a=0,h=m(0),u=0,y=0,A=0,k=0,S=0,P=m(0),K=0;A=Et-16|0,Et=A,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(At[r+4|0]&32){h=m(Pt[a|0](r,h,P,0));break r}h=m(Pt[a|0](r,h,P))}if(h==h)break t;l[A>>2]=3409,sr(r,A),qi(),he()}r:{i:{if(k=l[r+556>>2],a=l[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=l[(S<<2)+k>>2],!l[y+548>>2]){if(a=l[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=l[r+24>>2]>>>10&7),At[y+4|0]&2|(At[r+24|0]&8?(a|0)==5:0))break i;u=u||y}if(S=S+1|0,(K|0)!=(S|0))continue}break}if(u)break r}h=I[r+520>>2];break t}u=y}h=m(tl(u)+I[u+232>>2])}return Et=A+16|0,h}function Un(r,a,h,u,y,A){var k=0,S=m(0),P=0,K=m(0);k=(l[(a<<2)+4320>>2]<<2)+r|0,S=I[k+216>>2];t:{r:{k=l[k+216>>2];i:{if((k|0)==2139156720)break i;if((k|0)==2140081935)break r;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(K=I[P>>2],S=m(zt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(de(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[A>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;l[y>>2]=2}I[A>>2]=u}}function Ie(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Ur(r,4,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function xe(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Ur(r,5,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function Ip(r,a,h,u,y,A){var k=0;t:{r:{if(r){i:{if(a&4){A=Pt[r|0](h,u,y,A)|0;break i}A=Pt[r|0](h,u,y)|0}if(A)break r}if(A=ht(588),a=Ui(A,h,552),l[a+564>>2]=0,l[a+556>>2]=0,l[a+560>>2]=0,y=l[h+556>>2],u=l[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ht(k),l[a+556>>2]=r,l[a+564>>2]=r+k;l[r>>2]=l[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););l[a+560>>2]=r}r=l[h+572>>2],l[a+568>>2]=l[h+568>>2],l[a+572>>2]=r,l[a+584>>2]=l[h+584>>2],r=l[h+580>>2],l[a+576>>2]=l[h+576>>2],l[a+580>>2]=r,l[a+552>>2]=0}return A}Ds(),he()}function sr(r,a){var h=0,u=0,y=0;y=Et-16|0,Et=y,l[y+12>>2]=a;t:{r:{if(!r){a=l[y+12>>2];break r}if(a=l[y+12>>2],h=l[r+568>>2],!h)break r;if(u=l[h+4>>2],At[h+8|0]&8){Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0;break t}r:{if(!At[7016]){h=ht(28),l[h+20>>2]=1065353216,l[h+24>>2]=0,l[h+12>>2]=0,l[h+16>>2]=0,l[h>>2]=0,pt[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,pt[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(At[h+8|0]&8))break r;Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0}Et=y+16|0}function $a(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Ur(r,5,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Os(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Ur(r,4,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Ur(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+r|0,y=I[a>>2],a=l[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=l[r+24>>2],y=I[r+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function UE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Et-16|0,Et=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Et-16|0,Et=u,l[u+12>>2]=h;t:{if(r)break t;if(At[7016]){r=l[1753];break t}r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,pt[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,pt[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(At[r+8|0]&8){Pt[y|0](r,0,5,0,4284,h)|0;break t}Pt[y|0](r,0,5,4284,h)|0}Et=u+16|0,qi(),he()}I[r+20>>2]=a==m(0)?m(0):a,Et=h+16|0}function xp(r,a,h,u,y){var A=0,k=0,S=m(0),P=0;A=2,k=l[r+24>>2]>>>2&3;t:{r:{i:{if(!(!l[r+552>>2]|(a|0)!=2)){a=0,A=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}A=2;break t}if(a=0,k>>>0>1)break r}a=A}A=k}h=qp(r,A,h),u=qp(r,a,u),S=de(r,A,y),k=r+228|0,P=A<<2,I[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,A,y),I[k+(l[P+4304>>2]<<2)>>2]=h+S,h=de(r,a,y),A=a<<2,I[k+(l[A+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),I[k+(l[A+4304>>2]<<2)>>2]=u+h}function BE(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0,P=0;k=Et-48|0,Et=k,P=l[a+8>>2];t:{if(pt[7052]&1){a=l[1762];break t}a=dp(5,4480)|0,pt[7052]=1,l[1762]=a}l[k+40>>2]=A,I[k+32>>2]=y,l[k+24>>2]=u,I[k+16>>2]=h,S=+bE(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=l[k+12>>2],A=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=A,A=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=A,yE(u|0),Et=k+48|0}function GE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0;if(u=Et-32|0,Et=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){A=(y|15)+1|0,k=ht(A),l[u+16>>2]=A|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,A=y+k|0;break r}if(pt[u+19|0]=y,k=u+8|0,A=k+y|0,!y)break t}Ui(k,a+4|0,y)}return pt[A|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),vE(l[u+24>>2]),r=l[u+24>>2],Ma(r|0),Ma(l[u>>2]),pt[u+19|0]<0&&gi(l[u+8>>2]),Et=u+32|0,r|0}Ds(),he()}function hi(r,a,h){var u=0,y=0,A=0;if(!(At[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Hp(a))break r;r=l[a+16>>2]}if(A=l[a+20>>2],r-A>>>0<h>>>0){Pt[l[a+36>>2]](a,u,h)|0;break t}i:{if(l[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,At[u+r|0]==10)break}if(Pt[l[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,A=l[a+20>>2]}Ui(A,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function _h(r,a,h){var u=0,y=0,A=0;u=Et-16|0,Et=u,y=r+24|0,Pt[a|0](u+8|0,y),A=l[u+12>>2];t:{if((l[l[u+8>>2]>>2]&7<<A)>>A==(h|0))break t;for(Pt[a|0](u+8|0,y),a=l[u+8>>2],y=a,A=l[a>>2],a=l[u+12>>2],l[y>>2]=A&(7<<a^-1)|(h&7)<<a;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=u+16|0}function Br(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+28>>2],u=I[r+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function we(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function de(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function HE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0;return y=l[r+84>>2],A=l[y>>2],u=l[y+4>>2],S=l[r+28>>2],k=l[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Ui(A,S,k),A=k+l[y>>2]|0,l[y>>2]=A,u=l[y+4>>2]-k|0,l[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Ui(A,a,u),A=u+l[y>>2]|0,l[y>>2]=A,l[y+4>>2]=l[y+4>>2]-u),pt[A|0]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,h|0}function Se(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return ce(h,m(0))}function fe(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return ce(h,m(0))}function VE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+116>>2];t:{r:{if(a=l[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function WE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+80>>2];t:{r:{if(a=l[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function jE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+44>>2];t:{r:{if(a=l[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function Gr(r,a,h,u){var y=0,A=0,k=0;r=r*a,y=wh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Ge(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ge(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;A=0;r:{if(k||(A=1,y>.5))break r;A=Ge(y+-.5)<1e-4?1:0}r=r+A}return r!=r|a!=a?m(zt):m(r/a)}function Dp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;l[r>>2]=2143289344,l[r+4>>2]=3;return}l[r>>2]=0,l[r+4>>2]=1;return}l[r>>2]=0,l[r+4>>2]=2;return}if(h=(Dt(2,a),Bt()),h!=h){l[r>>2]=2143289344,l[r+4>>2]=0;return}l[r+4>>2]=a&1073741824?2:1,l[r>>2]=(a&-1073741825)+536870912}function Pp(r){var a=0,h=0,u=0;h=l[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=l[r+560>>2],h=l[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=l[l[h+(r<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(r=r+1|0,(u|0)==(r|0))break}}return a}function KE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+220>>2];t:{r:{if(a=l[a+220>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function zE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+200>>2];t:{r:{if(a=l[a+200>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function YE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+204>>2];t:{r:{if(a=l[a+204>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function XE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+208>>2];t:{r:{if(a=l[a+208>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function ZE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+212>>2];t:{r:{if(a=l[a+212>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function qE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+216>>2];t:{r:{if(a=l[a+216>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function QE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(At[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(At[r+300|0]&3)==2)break t;a=r+260|0;break t;default:break r}a=(r+(a<<2)|0)+252|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function JE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(At[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(At[r+300|0]&3)==2)break t;a=r+276|0;break t;default:break r}a=(r+(a<<2)|0)+268|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function tT(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(At[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(At[r+300|0]&3)==2)break t;a=r+292|0;break t;default:break r}a=(r+(a<<2)|0)+284|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function eT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=l[a>>2],y=I[a+40>>2],a=l[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),h=a&1073741824?2:1}l[r>>2]=h,Fe[r+8>>3]=u}function Hr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(hp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1602224127)),Bt()),a=(Zi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(hp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1610612735)),Bt()),a=(Zi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function iT(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=l[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(zt),(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return m((Dt(2,(r&-1073741825)+536870912|0),Bt()))}h=m(0)}return m(h)}function rT(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0;return k=Et-16|0,Et=k,S=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(S=l[S+l[a>>2]>>2]),Pt[S|0](k,a,h,u,y,A),r=ht(16),a=l[k+12>>2],l[r+8>>2]=l[k+8>>2],l[r+12>>2]=a,a=l[k+4>>2],l[r>>2]=l[k>>2],l[r+4>>2]=a,Et=k+16|0,r|0}function Op(r,a){t:{if(a){a=t2(l[a>>2]);break t}r:{if(At[7016]){a=l[1753];break r}a=ht(28),l[a+20>>2]=1065353216,l[a+24>>2]=0,l[a+12>>2]=0,l[a+16>>2]=0,l[a>>2]=0,pt[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,pt[7016]=1,l[1752]=l[1752]+1}a=t2(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function sT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+152>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function nT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+188>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function aT(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=l[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=zt,(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return Dt(2,(r&-1073741825)+536870912|0),+Bt()}h=0}return+h}function oT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>20&3)==(a|0))break t;for(l[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Bn(r,a,h){var u=0,y=0,A=0;t:{if(!a){u=r;break t}for(;u=kp(r,a,10),y=Fi,r=Ih(u,y,246,0)+r|0,h=h-1|0,pt[h|0]=r|48,A=a>>>0>9,r=u,a=y,!!A;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,pt[h|0]=Ue(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function lT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>22&1)==(a|0))break t;for(l[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function cT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>18&3)==(a|0))break t;for(l[r+24>>2]=h&-786433|a<<18&786432;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function hT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>16&3)==(a|0))break t;for(l[r+24>>2]=h&-196609|a<<16&196608;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function dT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function uT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function fT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function pT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function gT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>4&7)==(a|0))break t;for(l[r+24>>2]=h&-113|a<<4&112;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function mT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>2&3)==(a|0))break t;for(l[r+24>>2]=h&-13|a<<2&12;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function vT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=At[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(pt[r+4|0]=h&253|(a?2:0);;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function yT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Et-16|0,Et=u,y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](u,a,h),r=ht(16),a=l[u+12>>2],l[r+8>>2]=l[u+8>>2],l[r+12>>2]=a,a=l[u+4>>2],l[r>>2]=l[u>>2],l[r+4>>2]=a,Et=u+16|0,r|0}function Mp(r,a){var h=0,u=0;t:{r:{if(h=l[r+556>>2],u=l[r+560>>2],(h|0)==(u|0))break r;for(;;){if(l[h>>2]==(a|0))break r;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Ps(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function bT(r){r=r|0;var a=0,h=0;if(h=Et-16|0,Et=h,r=l[r>>2],l[r+8>>2]){for(;a=At[r+4|0],!!(!(a&4)&&(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=h+16|0;return}l[h>>2]=1024,sr(r,h),qi(),he()}function $p(r,a){var h=0,u=0,y=0;if(pi(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=$p(r*18446744073709552e3,a),h=l[a>>2]+-64|0),l[a>>2]=h,r;l[a>>2]=h-1022,Dt(0,y|0),Dt(1,u&-2146435073|1071644672),r=+Ae()}return r}function AT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-16|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=ht(16),a=l[h+12>>2],l[r+8>>2]=l[h+8>>2],l[r+12>>2]=a,a=l[h+4>>2],l[r>>2]=l[h>>2],l[r+4>>2]=a,Et=h+16|0,r|0}function el(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(l[((a<<2)+u|0)+184>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function il(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(l[((a<<2)+u|0)+192>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Gn(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(l[((a<<2)+u|0)+176>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Lh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,l[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,l[u+16>>2]=y;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Np(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(l[((a<<2)+u|0)+92>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Ch(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(l[((a<<2)+u|0)+20>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Fp(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(l[((a<<2)+u|0)+56>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function ET(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,l[a+5972>>2]=h,l[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);Sh(48),l[1756]=16,l[1757]=0,vp(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,Rp(),l[1770]=l[1768],l[1768]=7076}function nr(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function rl(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function Ih(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,A=r>>>16|0,K=Ue(y,A),k=h&65535,S=r&65535,P=Ue(k,S),A=(P>>>16|0)+Ue(A,k)|0,y=(A&65535)+Ue(y,S)|0,Fi=(Ue(a,h)+K|0)+Ue(r,u)+(A>>>16)+(y>>>16)|0,P&65535|y<<16}function Up(r,a){var h=0,u=0,y=0;u=Et-16|0,Et=u,h=At[r+4|0],y=h&-17,pt[r+4|0]=y;t:{if(a){if(l[r+560>>2]!=l[r+556>>2])break t;h=y|8}else h=h&231;l[r+8>>2]=a,pt[r+4|0]=h,Et=u+16|0;return}l[u>>2]=4128,sr(r,u),qi(),he()}function Bp(r){var a=0,h=m(0);a=0;t:{if((l[r+24>>2]&196608)==131072)break t;r:{if(!l[r+552>>2]||(h=I[r+32>>2],h!=h&&(h=I[r+28>>2],!(h>m(0)))))break r;if(a=1,h!=m(0))break t}a=Hn(r)!=m(0)}return a}function mi(r,a,h,u,y){var A=0;if(A=Et-256|0,Et=A,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Bi(A,a&255,h?u:256),!h)for(;hi(r,A,256),u=u-256|0,u>>>0>255;);hi(r,A,u)}Et=A+256|0}function fn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=l[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}Dp(r,u)}function pn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=l[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}Dp(r,u)}function Hn(r){var a=m(0),h=m(0);if(!l[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),pt[l[r+568>>2]+8|0]&1)||(a=m(0),h=I[r+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function Gp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=pt[u|0],nl(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ue(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Na(r,a,h,u){var y=0;l[r+12>>2]=0,l[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return l[r>>2]=y,h=(h<<2)+y|0,l[r+8>>2]=h,l[r+12>>2]=(a<<2)+y,l[r+4>>2]=h,r}$h(),he()}function Hp(r){var a=0;return a=l[r+72>>2],l[r+72>>2]=a-1|a,a=l[r>>2],a&8?(l[r>>2]=a|32,-1):(l[r+4>>2]=0,l[r+8>>2]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],0)}function TT(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0;k=Et-16|0,Et=k,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](k,a,h,u,y,A),I[r>>2]=Fe[k>>3],I[r+4>>2]=Fe[k+8>>3],Et=k+16|0}function kT(){var r=0,a=0;return a=ht(4),r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,pt[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function wT(r,a){r=r|0,a=a|0,a=l[a>>2],Fe[r>>3]=I[a+228>>2],Fe[r+8>>3]=I[a+236>>2],Fe[r+16>>3]=I[a+232>>2],Fe[r+24>>3]=I[a+240>>2],Fe[r+32>>3]=I[a+244>>2],Fe[r+40>>3]=I[a+248>>2]}function ST(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-48|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=Ui(ht(48),h,48),Et=h+48|0,r|0}function RT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Et-16|0,Et=y,r=e2(EE(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Et=y+16|0,Fi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function _T(r,a){r=r|0,a=a|0;var h=0,u=0;h=l[r>>2],r=l[h+556>>2];t:{if(l[h+560>>2]-r>>2>>>0<=a>>>0||(r=l[r+(a<<2)>>2],!r))break t;u=l[r>>2]}return u|0}function LT(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=l[r>>2],h?a=a|l[r+12>>2]:a=l[r+12>>2]&(a^-1),l[r+12>>2]=a;return}Ds(),he()}function CT(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var A=0;A=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(A=l[A+l[a>>2]>>2]),Pt[A|0](a,h,u,y)}function IT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function Vp(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function Wp(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)|0}function xT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function DT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),+Pt[u|0](a,h)}function ht(r){var a=0;r=r||1;t:{for(;;){if(a=kh(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}Ds(),he()}return a}function PT(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function Ms(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function gn(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)|0}function xh(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(gE(r,a))):a}function ce(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(mE(r,a))):a}function jp(r,a){r=r|0,a=a|0;var h=0;return h=Et-16|0,Et=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ma(l[h+8>>2]),Et=h+16|0,r|0}function OT(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function MT(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?n2(5816,u,y)|0:n2(5672,u,y)|0}function Kp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}pt[r|0]=a,r=1}return r}function $T(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),+Pt[h|0](a)}function zp(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Qo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Vn(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Qo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Dh(r,a){var h=0;t:{if(pt[7044]&1){h=l[1760];break t}h=dp(1,4464)|0,pt[7044]=1,l[1760]=h}AE(h|0,r|0,a|0,0)}function NT(r,a){r=r|0,a=a|0;var h=0;h=l[r+8>>2],l[r+8>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),l[l[r>>2]+20>>2]=15}function FT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=gp((pt[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function UT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=gp((pt[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Yp(r,a){r=r|0,a=a|0;var h=0;h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)}function BT(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=pt[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function GT(r,a){r=r|0,a=a|0;var h=0;h=l[r+4>>2],l[r+4>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),Up(l[r>>2],14)}function HT(r){r=r|0;var a=0;a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),l[l[r>>2]+20>>2]=0}function VT(r){r=r|0;var a=0;return a=ht(12),pt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function WT(r){r=r|0;var a=0;return a=ht(12),pt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function jT(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function KT(r){r=r|0;var a=0;a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Up(l[r>>2],0)}function Xp(r){return r=r|0,l[r>>2]=4572,At[r+4|0]&&Dh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function Zp(r){return r=r|0,l[r>>2]=4452,At[r+4|0]&&Dh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function zT(){var r=0;return r=ht(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function qp(r,a,h){return nr(r,a)?Os(r,a,h):(h=$a(r,a,h),h==h&&(h=m(-h)),h)}function Qp(r,a){var h=0;h=Et-16|0,Et=h,r||(l[h>>2]=a,sr(0,h),qi(),he()),Et=h+16|0}function Jp(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&gi(a),l[1752]=l[1752]-1,gi(r))}function YT(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Ds(),he()),l[l[r>>2]+12>>2]>>>a&1}function XT(r,a,h,u,y){return r=r|0,a=a|0,h=h|0,u=u|0,y=y|0,Pt[r|0](a,h,u,y)|0}function ZT(){var r=0;return r=ht(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function qT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(zt):a)}function QT(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function JT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function t2(r){var a=0;return a=bp(ht(588),r),Qp((r|0)!=0,2808),a}function t3(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function e3(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function i3(r,a){r=r|0,a=a|0,r=l[r>>2],pt[r+8|0]=At[r+8|0]&254|a}function r3(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function s3(r,a,h){r=r|0,a=a|0,h=+h,Ch(l[r>>2],a,vr(m(h)))}function n3(r,a,h){r=r|0,a=a|0,h=+h,Ch(l[r>>2],a,Hr(m(h)))}function a3(r,a,h,u){return Fi=0,0}function o3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,vr(m(h)))}function l3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,Hr(m(h)))}function c3(r,a,h){r=r|0,a=a|0,h=+h,Fp(l[r>>2],a,vr(m(h)))}function h3(r,a,h){r=r|0,a=a|0,h=+h,Fp(l[r>>2],a,Hr(m(h)))}function d3(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function u3(r,a){r=r|0,a=a|0,Ch(l[r>>2],a,2141891242)}function Ph(r,a,h){r=r|0,a=a|0,h=+h,Fe[l[r>>2]+a>>3]=h}function f3(r){return r=r|0,(At[l[r>>2]+4|0]&2)>>>1|0}function p3(r){return r=r|0,(At[l[r>>2]+4|0]&4)>>>2|0}function g3(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function m3(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function v3(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function y3(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function Oh(r,a){return r=r|0,a=a|0,+Fe[l[r>>2]+a>>3]}function b3(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function A3(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function E3(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function T3(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function k3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,vr(m(a)))}function w3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,Hr(m(a)))}function S3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,vr(m(a)))}function R3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,Hr(m(a)))}function _3(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function L3(r,a){r=r|0,a=+a,el(l[r>>2],0,vr(m(a)))}function C3(r,a){r=r|0,a=+a,el(l[r>>2],0,Hr(m(a)))}function I3(r,a){r=r|0,a=+a,el(l[r>>2],1,vr(m(a)))}function x3(r,a){r=r|0,a=+a,el(l[r>>2],1,Hr(m(a)))}function D3(r,a){r=r|0,a=+a,il(l[r>>2],0,vr(m(a)))}function P3(r,a){r=r|0,a=+a,il(l[r>>2],1,vr(m(a)))}function O3(r,a){r=r|0,a=+a,il(l[r>>2],1,Hr(m(a)))}function M3(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function $3(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function N3(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function sl(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function F3(r,a){r=r|0,a=+a,il(l[r>>2],0,Hr(m(a)))}function e2(r){return r?(l[1781]=r,-1):0}function U3(r,a){r=r|0,a=+a,Lh(l[r>>2],vr(m(a)))}function B3(r,a){r=r|0,a=+a,Lh(l[r>>2],Hr(m(a)))}function i2(r,a,h){return m(de(r,a,h)+we(r,a,h))}function G3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function r2(r,a,h,u){TE(r|0,a|0,8,0,h|0,-1,u|0)}function H3(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function V3(r){return r=r|0,l[l[r>>2]+16>>2]&1}function W3(r){return r=r|0,Nn[l[r>>2]+26>>1]&3}function j3(r){r=r|0,Gn(l[r>>2],0,2141891242)}function K3(r){r=r|0,Gn(l[r>>2],1,2141891242)}function z3(r){return r=r|0,+I[l[r>>2]+228>>2]}function Y3(r){return r=r|0,+I[l[r>>2]+236>>2]}function X3(r){return r=r|0,+I[l[r>>2]+232>>2]}function Z3(r){return r=r|0,+I[l[r>>2]+240>>2]}function q3(r){return r=r|0,+I[l[r>>2]+244>>2]}function Q3(r){return r=r|0,+I[l[r>>2]+248>>2]}function J3(r){return r=r|0,RE(l[r+60>>2])|0}function tk(r){return r=r|0,l[l[r>>2]+16>>2]}function ek(r){return r=r|0,pt[l[r>>2]+8|0]&1}function ik(r,a){r=r|0,a=a|0,_h(l[r>>2],5,a)}function rk(r,a){r=r|0,a=a|0,_h(l[r>>2],6,a)}function sk(r,a){r=r|0,a=a|0,_h(l[r>>2],7,a)}function nk(r){r=r|0,Lh(l[r>>2],2141891242)}function s2(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function ak(r){return r=r|0,Op(ht(12),r)|0}function ok(r){r=r|0,Dh(l[r+8>>2],3293)}function n2(r,a,h){return Cp(r,a,h,2,3)}function a2(r){return r=r|0,Pt[r|0]()|0}function o2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function lk(){return Bi(ht(48),0,48)|0}function qi(){Pt[l[1490]](),$h(),he()}function ck(){return Op(ht(12),0)|0}function Mh(r){r=r|0,r&&gi(r)}function nl(r){return r-48>>>0<10}function hk(r){return 7032}function dk(r){return 7036}function uk(r){return 7056}function fk(r){return 7059}function pk(r){return 7062}function gk(r){return 7067}function Sr(r){return r=r|0,r|0}function l2(r){r=r|0,pt[r+4|0]=1}function mk(r){r=r|0,gi(Xp(r))}function vk(r){r=r|0,gi(Zp(r))}function yk(r){return 0}function c2(r){he()}function h2(){$h(),he()}function $h(){Ds(),he()}G=At,Rt();var Pt=B([null,MT,IE,PE,Sr,_3,g3,m3,Sr,Sr,Sr,Sr,Sr,Sr,TT,r3,vp,hk,sl,rT,dk,Sr,Sr,sl,l2,s2,jp,VT,GE,FT,uk,sl,Yp,fk,Sr,Sr,sl,l2,s2,jp,WT,UT,pk,Jp,a2,kT,o2,Jp,LT,Vp,UE,PT,t3,Ms,H3,Ms,i3,YT,Wp,V3,gn,tk,gn,ek,lk,Mh,zT,Mh,ZT,Mh,Oh,Ph,T3,d3,gk,Sp,a2,ck,G3,ak,o2,Sp,$E,Yp,DE,Ms,hT,Ms,c3,xT,h3,ik,rk,sk,mT,cT,gT,s3,n3,u3,oT,lT,uT,OT,U3,B3,nk,fT,pT,k3,w3,j3,S3,R3,K3,L3,C3,I3,x3,D3,F3,P3,O3,dT,sT,o3,l3,nT,W3,gn,WE,yT,M3,v3,y3,$3,b3,N3,jE,eT,AT,JT,$T,BT,zE,YE,XE,ZE,qE,KE,qT,aT,DT,A3,E3,VE,iT,IT,OE,Vp,ME,Ms,e3,gn,QT,gn,_T,Wp,f3,gn,vT,Ms,GT,Ms,KT,NT,Ms,HT,bT,p3,gn,xE,CT,z3,Y3,X3,Z3,q3,Q3,wT,ST,QE,JE,tT,Oh,Ph,Oh,Ph,Rp,Zp,vk,BE,c2,h2,Xp,mk,ok,c2,J3,NE,RT,yk,a3,HE,h2]);function d2(){return Ni.byteLength/65536|0}function bk(r){r=r|0;var a=d2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ue(h,65536)),y=new Int8Array(u);y.set(pt),pt=new Int8Array(u),Fr=new Int16Array(u),l=new Int32Array(u),At=new Uint8Array(u),Nn=new Uint16Array(u),cp=new Uint32Array(u),I=new Float32Array(u),Fe=new Float64Array(u),Ni=u,rr.buffer=Ni,G=At}return a}return{E:ET,F:FE,G:jT,H:kh,I:Pt,J:gi,K:XT}}return qo(L)}(_)}var C=Error,D={};b=[],typeof D!="object"&&xt("no native wasm support detected");var O,F=!1;function x(_,L,B){B=L+B;for(var G="";!(L>=B);){var it=_[L++];if(!it)break;if(it&128){var vt=_[L++]&63;if((it&224)==192)G+=String.fromCharCode((it&31)<<6|vt);else{var lt=_[L++]&63;it=(it&240)==224?(it&15)<<12|vt<<6|lt:(it&7)<<18|vt<<12|lt<<6|_[L++]&63,65536>it?G+=String.fromCharCode(it):(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023))}}else G+=String.fromCharCode(it)}return G}var N,H,j,nt,st,Q,kt,gt,Mt;function Vt(_){N=_,o.HEAP8=H=new Int8Array(_),o.HEAP16=nt=new Int16Array(_),o.HEAP32=Q=new Int32Array(_),o.HEAPU8=j=new Uint8Array(_),o.HEAPU16=st=new Uint16Array(_),o.HEAPU32=kt=new Uint32Array(_),o.HEAPF32=gt=new Float32Array(_),o.HEAPF64=Mt=new Float64Array(_)}var V=o.INITIAL_MEMORY||16777216;o.wasmMemory?O=o.wasmMemory:O=new E,O&&(N=O.buffer),V=N.byteLength,Vt(N);var J,St=[],$=[],U=[];function Z(){var _=o.preRun.shift();St.unshift(_)}var ft=0,bt=null;function xt(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),F=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Ut(_){return _.startsWith("data:application/octet-stream;base64,")}var Qt;if(Qt="<<< WASM_BINARY_FILE >>>",!Ut(Qt)){var ue=Qt;Qt=o.locateFile?o.locateFile(ue,p):p+ue}function se(_){var L=Qt;try{try{if(L==Qt&&b)new Uint8Array(b);else{if(Ut(L)){try{var B=uE(L.slice(37)),G=new Uint8Array(B.length);for(L=0;L<B.length;++L)G[L]=B.charCodeAt(L);var it=G}catch{throw Error("Converting base64 string to bytes failed.")}var vt=it}else vt=void 0;if(!vt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(Lt){xt(Lt)}var lt=new T,Rt=new w(_)}catch(Lt){throw _=Lt.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),Lt}return[Rt,lt]}function Yt(_){for(;0<_.length;)_.shift()(o)}function Me(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function be(_,L){return _=Me(_),function(){return L.apply(this,arguments)}}var jt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],ge=[];function oe(_){var L=Error,B=be(_,function(G){this.name=_,this.message=G,G=Error(G).stack,G!==void 0&&(this.stack=this.toString()+`
90
- `+G.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(L.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Ce=void 0;function Ft(_){throw new Ce(_)}var Ze=_=>(_||Ft("Cannot use deleted val. handle = "+_),jt[_].value),qe=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=ge.length?ge.pop():jt.length;return jt[L]={fa:1,value:_},L}},$i=void 0,Tr=void 0;function ke(_){for(var L="";j[_];)L+=Tr[j[_++]];return L}var li=[];function me(){for(;li.length;){var _=li.pop();_.L.Z=!1,_.delete()}}var ti=void 0,ei={};function Xi(_,L){for(L===void 0&&Ft("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Ne={};function Ci(_){_=pE(_);var L=ke(_);return xs(_),L}function ss(_,L){var B=Ne[_];return B===void 0&&Ft(L+" has unknown type "+Ci(_)),B}function ci(){}var kr=!1;function _s(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function Ls(_,L,B){return L===B?_:B.P===void 0?null:(_=Ls(_,L,B.P),_===null?null:B.ma(_))}var ir={};function ct(_,L){return L=Xi(_,L),ei[L]}var Gt=void 0;function Xt(_){throw new Gt(_)}function ve(_,L){return L.O&&L.N||Xt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Xt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},ae(Object.create(_,{L:{value:L}}))}function ae(_){return typeof FinalizationRegistry>"u"?(ae=L=>L,_):(kr=new FinalizationRegistry(L=>{_s(L.L)}),ae=L=>{var B=L.L;return B.S&&kr.register(L,{L:B},L),L},ci=L=>{kr.unregister(L)},ae(_))}var ni={};function Ii(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function ur(_){return this.fromWireType(Q[_>>2])}var ns={},fr={};function pr(_,L,B){function G(Rt){Rt=B(Rt),Rt.length!==_.length&&Xt("Mismatched type converter count");for(var Lt=0;Lt<_.length;++Lt)xi(_[Lt],Rt[Lt])}_.forEach(function(Rt){fr[Rt]=L});var it=Array(L.length),vt=[],lt=0;L.forEach((Rt,Lt)=>{Ne.hasOwnProperty(Rt)?it[Lt]=Ne[Rt]:(vt.push(Rt),ns.hasOwnProperty(Rt)||(ns[Rt]=[]),ns[Rt].push(()=>{it[Lt]=Ne[Rt],++lt,lt===vt.length&&G(it)}))}),vt.length===0&&G(it)}function Cs(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function xi(_,L,B={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var G=L.name;if(_||Ft('type "'+G+'" must have a positive integer typeid pointer'),Ne.hasOwnProperty(_)){if(B.ta)return;Ft("Cannot register type '"+G+"' twice")}Ne[_]=L,delete fr[_],ns.hasOwnProperty(_)&&(L=ns[_],delete ns[_],L.forEach(it=>it()))}function Oa(_){Ft(_.L.O.M.name+" instance already deleted")}function gr(){}function Is(_,L,B){if(_[L].R===void 0){var G=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Ft("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[G.Y]=G}}function zA(_,L){o.hasOwnProperty(_)?(Ft("Cannot register public name '"+_+"' twice"),Is(o,_,_),o.hasOwnProperty(void 0)&&Ft("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function YA(_,L,B,G,it,vt,lt,Rt){this.name=_,this.constructor=L,this.W=B,this.V=G,this.P=it,this.oa=vt,this.aa=lt,this.ma=Rt,this.ia=[]}function gh(_,L,B){for(;L!==B;)L.aa||Ft("Expected null or instance of "+B.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function XA(_,L){return L===null?(this.da&&Ft("null is not a valid "+this.name),0):(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),gh(L.L.N,L.L.O.M,this.M))}function ZA(_,L){if(L===null){if(this.da&&Ft("null is not a valid "+this.name),this.ca){var B=this.ea();return _!==null&&_.push(this.V,B),B}return 0}if(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Ft("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),B=gh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Ft("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?B=L.L.S:Ft("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:B=L.L.S;break;case 2:if(L.L.T===this)B=L.L.S;else{var G=L.clone();B=this.wa(B,qe(function(){G.delete()})),_!==null&&_.push(this.V,B)}break;default:Ft("Unsupporting sharing policy")}return B}function qA(_,L){return L===null?(this.da&&Ft("null is not a valid "+this.name),0):(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Ft("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),gh(L.L.N,L.L.O.M,this.M))}function as(_,L,B,G){this.name=_,this.M=L,this.da=B,this.ba=G,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=ZA:(this.toWireType=G?XA:qA,this.U=null)}function QA(_,L){o.hasOwnProperty(_)||Xt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function JA(_,L){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),_.includes("j")){var G=o["dynCall_"+_];G=B&&B.length?G.apply(null,[L].concat(B)):G.call(null,L)}else G=J.get(L).apply(null,B);return G}}function wr(_,L){_=ke(_);var B=_.includes("j")?JA(_,L):J.get(L);return typeof B!="function"&&Ft("unknown function pointer with signature "+_+": "+L),B}var rp=void 0;function zo(_,L){function B(vt){it[vt]||Ne[vt]||(fr[vt]?fr[vt].forEach(B):(G.push(vt),it[vt]=!0))}var G=[],it={};throw L.forEach(B),new rp(_+": "+G.map(Ci).join([", "]))}function mh(_,L,B,G,it){var vt=L.length;2>vt&&Ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=L[1]!==null&&B!==null,Rt=!1;for(B=1;B<L.length;++B)if(L[B]!==null&&L[B].U===void 0){Rt=!0;break}var Lt=L[0].name!=="void",Ct=vt-2,Nt=Array(Ct),Kt=[],te=[];return function(){if(arguments.length!==Ct&&Ft("function "+_+" called with "+arguments.length+" arguments, expected "+Ct+" args!"),te.length=0,Kt.length=lt?2:1,Kt[0]=it,lt){var Dt=L[1].toWireType(te,this);Kt[1]=Dt}for(var Ae=0;Ae<Ct;++Ae)Nt[Ae]=L[Ae+2].toWireType(te,arguments[Ae]),Kt.push(Nt[Ae]);if(Ae=G.apply(null,Kt),Rt)Ii(te);else for(var pi=lt?1:2;pi<L.length;pi++){var he=pi===1?Dt:Nt[pi-2];L[pi].U!==null&&L[pi].U(he)}return Dt=Lt?L[0].fromWireType(Ae):void 0,Dt}}function vh(_,L){for(var B=[],G=0;G<_;G++)B.push(kt[L+4*G>>2]);return B}function yh(_){4<_&&--jt[_].fa===0&&(jt[_]=void 0,ge.push(_))}function bh(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function tE(_,L){switch(L){case 2:return function(B){return this.fromWireType(gt[B>>2])};case 3:return function(B){return this.fromWireType(Mt[B>>3])};default:throw new TypeError("Unknown float type: "+_)}}function eE(_,L,B){switch(L){case 0:return B?function(G){return H[G]}:function(G){return j[G]};case 1:return B?function(G){return nt[G>>1]}:function(G){return st[G>>1]};case 2:return B?function(G){return Q[G>>2]}:function(G){return kt[G>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function iE(_,L){for(var B="",G=0;!(G>=L/2);++G){var it=nt[_+2*G>>1];if(it==0)break;B+=String.fromCharCode(it)}return B}function rE(_,L,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var G=L;B=B<2*_.length?B/2:_.length;for(var it=0;it<B;++it)nt[L>>1]=_.charCodeAt(it),L+=2;return nt[L>>1]=0,L-G}function sE(_){return 2*_.length}function nE(_,L){for(var B=0,G="";!(B>=L/4);){var it=Q[_+4*B>>2];if(it==0)break;++B,65536<=it?(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023)):G+=String.fromCharCode(it)}return G}function aE(_,L,B){if(B===void 0&&(B=2147483647),4>B)return 0;var G=L;B=G+B-4;for(var it=0;it<_.length;++it){var vt=_.charCodeAt(it);if(55296<=vt&&57343>=vt){var lt=_.charCodeAt(++it);vt=65536+((vt&1023)<<10)|lt&1023}if(Q[L>>2]=vt,L+=4,L+4>B)break}return Q[L>>2]=0,L-G}function oE(_){for(var L=0,B=0;B<_.length;++B){var G=_.charCodeAt(B);55296<=G&&57343>=G&&++B,L+=4}return L}var lE={};function sp(_){var L=lE[_];return L===void 0?ke(_):L}var Yo=[];function cE(_){var L=Yo.length;return Yo.push(_),L}function hE(_,L){for(var B=Array(_),G=0;G<_;++G)B[G]=ss(kt[L+4*G>>2],"parameter "+G);return B}var np=[],dE=[null,[],[]];Ce=o.BindingError=oe("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<jt.length;++L)jt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<jt.length;++_)if(jt[_]!==void 0)return jt[_];return null},$i=o.PureVirtualError=oe("PureVirtualError");for(var ap=Array(256),Xo=0;256>Xo;++Xo)ap[Xo]=String.fromCharCode(Xo);Tr=ap,o.getInheritedInstanceCount=function(){return Object.keys(ei).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in ei)ei.hasOwnProperty(L)&&_.push(ei[L]);return _},o.flushPendingDeletes=me,o.setDelayFunction=function(_){ti=_,li.length&&ti&&ti(me)},Gt=o.InternalError=oe("InternalError"),gr.prototype.isAliasOf=function(_){if(!(this instanceof gr&&_ instanceof gr))return!1;var L=this.L.O.M,B=this.L.N,G=_.L.O.M;for(_=_.L.N;L.P;)B=L.aa(B),L=L.P;for(;G.P;)_=G.aa(_),G=G.P;return L===G&&B===_},gr.prototype.clone=function(){if(this.L.N||Oa(this),this.L.$)return this.L.count.value+=1,this;var _=ae,L=Object,B=L.create,G=Object.getPrototypeOf(this),it=this.L;return _=_(B.call(L,G,{L:{value:{count:it.count,Z:it.Z,$:it.$,N:it.N,O:it.O,S:it.S,T:it.T}}})),_.L.count.value+=1,_.L.Z=!1,_},gr.prototype.delete=function(){this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),ci(this),_s(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},gr.prototype.isDeleted=function(){return!this.L.N},gr.prototype.deleteLater=function(){return this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),li.push(this),li.length===1&&ti&&ti(me),this.L.Z=!0,this},as.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},as.prototype.ga=function(_){this.V&&this.V(_)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=ur,as.prototype.deleteObject=function(_){_!==null&&_.delete()},as.prototype.fromWireType=function(_){function L(){return this.ca?ve(this.M.W,{O:this.va,N:B,T:this,S:_}):ve(this.M.W,{O:this,N:_})}var B=this.pa(_);if(!B)return this.ga(_),null;var G=ct(this.M,B);if(G!==void 0)return G.L.count.value===0?(G.L.N=B,G.L.S=_,G.clone()):(G=G.clone(),this.ga(_),G);if(G=this.M.oa(B),G=ir[G],!G)return L.call(this);G=this.ba?G.ka:G.pointerType;var it=Ls(B,this.M,G.M);return it===null?L.call(this):this.ca?ve(G.M.W,{O:G,N:it,T:this,S:_}):ve(G.M.W,{O:G,N:it})},rp=o.UnboundTypeError=oe("UnboundTypeError");var uE=typeof atob=="function"?atob:function(_){var L="",B=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++));G=G<<2|it>>4,it=(it&15)<<4|vt>>2;var Rt=(vt&3)<<6|lt;L+=String.fromCharCode(G),vt!==64&&(L+=String.fromCharCode(it)),lt!==64&&(L+=String.fromCharCode(Rt))}while(B<_.length);return L},fE={q:function(_,L,B){_=ke(_),L=ss(L,"wrapper"),B=Ze(B);var G=[].slice,it=L.M,vt=it.W,lt=it.P.W,Rt=it.P.constructor;_=be(_,function(){it.P.ia.forEach((function(Ct){if(this[Ct]===lt[Ct])throw new $i("Pure virtual function "+Ct+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:vt}),this.__construct.apply(this,G.call(arguments))}),vt.__construct=function(){this===vt&&Ft("Pass correct 'this' to __construct");var Ct=Rt.implement.apply(void 0,[this].concat(G.call(arguments)));ci(Ct);var Nt=Ct.L;Ct.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),ae(this),Ct=Nt.N,Ct=Xi(it,Ct),ei.hasOwnProperty(Ct)?Ft("Tried to register registered instance: "+Ct):ei[Ct]=this},vt.__destruct=function(){this===vt&&Ft("Pass correct 'this' to __destruct"),ci(this);var Ct=this.L.N;Ct=Xi(it,Ct),ei.hasOwnProperty(Ct)?delete ei[Ct]:Ft("Tried to unregister unregistered instance: "+Ct)},_.prototype=Object.create(vt);for(var Lt in B)_.prototype[Lt]=B[Lt];return qe(_)},k:function(_){var L=ni[_];delete ni[_];var B=L.ea,G=L.V,it=L.ha,vt=it.map(lt=>lt.sa).concat(it.map(lt=>lt.ya));pr([_],vt,lt=>{var Rt={};return it.forEach((Lt,Ct)=>{var Nt=lt[Ct],Kt=Lt.qa,te=Lt.ra,Dt=lt[Ct+it.length],Ae=Lt.xa,pi=Lt.za;Rt[Lt.na]={read:he=>Nt.fromWireType(Kt(te,he)),write:(he,Zi)=>{var Bt=[];Ae(pi,he,Dt.toWireType(Bt,Zi)),Ii(Bt)}}}),[{name:L.name,fromWireType:function(Lt){var Ct={},Nt;for(Nt in Rt)Ct[Nt]=Rt[Nt].read(Lt);return G(Lt),Ct},toWireType:function(Lt,Ct){for(var Nt in Rt)if(!(Nt in Ct))throw new TypeError('Missing field: "'+Nt+'"');var Kt=B();for(Nt in Rt)Rt[Nt].write(Kt,Ct[Nt]);return Lt!==null&&Lt.push(G,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:G}]})},w:function(){},C:function(_,L,B,G,it){var vt=Cs(B);L=ke(L),xi(_,{name:L,fromWireType:function(lt){return!!lt},toWireType:function(lt,Rt){return Rt?G:it},argPackAdvance:8,readValueFromPointer:function(lt){if(B===1)var Rt=H;else if(B===2)Rt=nt;else if(B===4)Rt=Q;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(Rt[lt>>vt])},U:null})},g:function(_,L,B,G,it,vt,lt,Rt,Lt,Ct,Nt,Kt,te){Nt=ke(Nt),vt=wr(it,vt),Rt&&(Rt=wr(lt,Rt)),Ct&&(Ct=wr(Lt,Ct)),te=wr(Kt,te);var Dt=Me(Nt);zA(Dt,function(){zo("Cannot construct "+Nt+" due to unbound types",[G])}),pr([_,L,B],G?[G]:[],function(Ae){if(Ae=Ae[0],G)var pi=Ae.M,he=pi.W;else he=gr.prototype;Ae=be(Dt,function(){if(Object.getPrototypeOf(this)!==Zi)throw new Ce("Use 'new' to construct "+Nt);if(Bt.X===void 0)throw new Ce(Nt+" has no accessible constructor");var ii=Bt.X[arguments.length];if(ii===void 0)throw new Ce("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ii.apply(this,arguments)});var Zi=Object.create(he,{constructor:{value:Ae}});Ae.prototype=Zi;var Bt=new YA(Nt,Ae,Zi,te,pi,vt,Rt,Ct);pi=new as(Nt,Bt,!0,!1),he=new as(Nt+"*",Bt,!1,!1);var qo=new as(Nt+" const*",Bt,!1,!0);return ir[_]={pointerType:he,ka:qo},QA(Dt,Ae),[pi,he,qo]})},d:function(_,L,B,G,it,vt,lt){var Rt=vh(B,G);L=ke(L),vt=wr(it,vt),pr([],[_],function(Lt){function Ct(){zo("Cannot call "+Nt+" due to unbound types",Rt)}Lt=Lt[0];var Nt=Lt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Kt=Lt.M.constructor;return Kt[L]===void 0?(Ct.Y=B-1,Kt[L]=Ct):(Is(Kt,L,Nt),Kt[L].R[B-1]=Ct),pr([],Rt,function(te){return te=mh(Nt,[te[0],null].concat(te.slice(1)),null,vt,lt),Kt[L].R===void 0?(te.Y=B-1,Kt[L]=te):Kt[L].R[B-1]=te,[]}),[]})},p:function(_,L,B,G,it,vt){0<L||xt();var lt=vh(L,B);it=wr(G,it),pr([],[_],function(Rt){Rt=Rt[0];var Lt="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[L-1]!==void 0)throw new Ce("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[L-1]=()=>{zo("Cannot construct "+Rt.name+" due to unbound types",lt)},pr([],lt,function(Ct){return Ct.splice(1,0,null),Rt.M.X[L-1]=mh(Lt,Ct,null,it,vt),[]}),[]})},b:function(_,L,B,G,it,vt,lt,Rt){var Lt=vh(B,G);L=ke(L),vt=wr(it,vt),pr([],[_],function(Ct){function Nt(){zo("Cannot call "+Kt+" due to unbound types",Lt)}Ct=Ct[0];var Kt=Ct.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),Rt&&Ct.M.ia.push(L);var te=Ct.M.W,Dt=te[L];return Dt===void 0||Dt.R===void 0&&Dt.className!==Ct.name&&Dt.Y===B-2?(Nt.Y=B-2,Nt.className=Ct.name,te[L]=Nt):(Is(te,L,Kt),te[L].R[B-2]=Nt),pr([],Lt,function(Ae){return Ae=mh(Kt,Ae,Ct,vt,lt),te[L].R===void 0?(Ae.Y=B-2,te[L]=Ae):te[L].R[B-2]=Ae,[]}),[]})},B:function(_,L){L=ke(L),xi(_,{name:L,fromWireType:function(B){var G=Ze(B);return yh(B),G},toWireType:function(B,G){return qe(G)},argPackAdvance:8,readValueFromPointer:ur,U:null})},n:function(_,L,B){B=Cs(B),L=ke(L),xi(_,{name:L,fromWireType:function(G){return G},toWireType:function(G,it){return it},argPackAdvance:8,readValueFromPointer:tE(L,B),U:null})},e:function(_,L,B,G,it){L=ke(L),it===-1&&(it=4294967295),it=Cs(B);var vt=Rt=>Rt;if(G===0){var lt=32-8*B;vt=Rt=>Rt<<lt>>>lt}B=L.includes("unsigned")?function(Rt,Lt){return Lt>>>0}:function(Rt,Lt){return Lt},xi(_,{name:L,fromWireType:vt,toWireType:B,argPackAdvance:8,readValueFromPointer:eE(L,it,G!==0),U:null})},c:function(_,L,B){function G(vt){vt>>=2;var lt=kt;return new it(N,lt[vt+1],lt[vt])}var it=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];B=ke(B),xi(_,{name:B,fromWireType:G,argPackAdvance:8,readValueFromPointer:G},{ta:!0})},o:function(_,L){L=ke(L);var B=L==="std::string";xi(_,{name:L,fromWireType:function(G){var it=kt[G>>2],vt=G+4;if(B)for(var lt=vt,Rt=0;Rt<=it;++Rt){var Lt=vt+Rt;if(Rt==it||j[Lt]==0){if(lt=lt?x(j,lt,Lt-lt):"",Ct===void 0)var Ct=lt;else Ct+=String.fromCharCode(0),Ct+=lt;lt=Lt+1}}else{for(Ct=Array(it),Rt=0;Rt<it;++Rt)Ct[Rt]=String.fromCharCode(j[vt+Rt]);Ct=Ct.join("")}return xs(G),Ct},toWireType:function(G,it){it instanceof ArrayBuffer&&(it=new Uint8Array(it));var vt,lt=typeof it=="string";if(lt||it instanceof Uint8Array||it instanceof Uint8ClampedArray||it instanceof Int8Array||Ft("Cannot pass non-string to std::string"),B&&lt){var Rt=0;for(vt=0;vt<it.length;++vt){var Lt=it.charCodeAt(vt);127>=Lt?Rt++:2047>=Lt?Rt+=2:55296<=Lt&&57343>=Lt?(Rt+=4,++vt):Rt+=3}vt=Rt}else vt=it.length;if(Rt=op(4+vt+1),Lt=Rt+4,kt[Rt>>2]=vt,B&&lt){if(lt=Lt,Lt=vt+1,vt=j,0<Lt){Lt=lt+Lt-1;for(var Ct=0;Ct<it.length;++Ct){var Nt=it.charCodeAt(Ct);if(55296<=Nt&&57343>=Nt){var Kt=it.charCodeAt(++Ct);Nt=65536+((Nt&1023)<<10)|Kt&1023}if(127>=Nt){if(lt>=Lt)break;vt[lt++]=Nt}else{if(2047>=Nt){if(lt+1>=Lt)break;vt[lt++]=192|Nt>>6}else{if(65535>=Nt){if(lt+2>=Lt)break;vt[lt++]=224|Nt>>12}else{if(lt+3>=Lt)break;vt[lt++]=240|Nt>>18,vt[lt++]=128|Nt>>12&63}vt[lt++]=128|Nt>>6&63}vt[lt++]=128|Nt&63}}vt[lt]=0}}else if(lt)for(lt=0;lt<vt;++lt)Ct=it.charCodeAt(lt),255<Ct&&(xs(Lt),Ft("String has UTF-16 code units that do not fit in 8 bits")),j[Lt+lt]=Ct;else for(lt=0;lt<vt;++lt)j[Lt+lt]=it[lt];return G!==null&&G.push(xs,Rt),Rt},argPackAdvance:8,readValueFromPointer:ur,U:function(G){xs(G)}})},j:function(_,L,B){if(B=ke(B),L===2)var G=iE,it=rE,vt=sE,lt=()=>st,Rt=1;else L===4&&(G=nE,it=aE,vt=oE,lt=()=>kt,Rt=2);xi(_,{name:B,fromWireType:function(Lt){for(var Ct=kt[Lt>>2],Nt=lt(),Kt,te=Lt+4,Dt=0;Dt<=Ct;++Dt){var Ae=Lt+4+Dt*L;(Dt==Ct||Nt[Ae>>Rt]==0)&&(te=G(te,Ae-te),Kt===void 0?Kt=te:(Kt+=String.fromCharCode(0),Kt+=te),te=Ae+L)}return xs(Lt),Kt},toWireType:function(Lt,Ct){typeof Ct!="string"&&Ft("Cannot pass non-string to C++ string type "+B);var Nt=vt(Ct),Kt=op(4+Nt+L);return kt[Kt>>2]=Nt>>Rt,it(Ct,Kt+4,Nt+L),Lt!==null&&Lt.push(xs,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:function(Lt){xs(Lt)}})},l:function(_,L,B,G,it,vt){ni[_]={name:ke(L),ea:wr(B,G),V:wr(it,vt),ha:[]}},i:function(_,L,B,G,it,vt,lt,Rt,Lt,Ct){ni[_].ha.push({na:ke(L),sa:B,qa:wr(G,it),ra:vt,ya:lt,xa:wr(Rt,Lt),za:Ct})},D:function(_,L){L=ke(L),xi(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,B,G,it){_=Yo[_],L=Ze(L),B=sp(B);var vt=[];return kt[G>>2]=qe(vt),_(L,B,vt,it)},u:function(_,L,B,G){_=Yo[_],L=Ze(L),B=sp(B),_(L,B,null,G)},h:yh,m:function(_,L){var B=hE(_,L),G=B[0];L=G.name+"_$"+B.slice(1).map(function(lt){return lt.name}).join("_")+"$";var it=np[L];if(it!==void 0)return it;var vt=Array(_-1);return it=cE((lt,Rt,Lt,Ct)=>{for(var Nt=0,Kt=0;Kt<_-1;++Kt)vt[Kt]=B[Kt+1].readValueFromPointer(Ct+Nt),Nt+=B[Kt+1].argPackAdvance;for(lt=lt[Rt].apply(lt,vt),Kt=0;Kt<_-1;++Kt)B[Kt+1].la&&B[Kt+1].la(vt[Kt]);if(!G.ua)return G.toWireType(Lt,lt)}),np[L]=it},r:function(_){4<_&&(jt[_].fa+=1)},s:function(_){var L=Ze(_);Ii(L),yh(_)},f:function(){xt("")},y:function(_,L,B){j.copyWithin(_,L,L+B)},x:function(_){var L=j.length;if(_>>>=0,2147483648<_)return!1;for(var B=1;4>=B;B*=2){var G=L*(1+.2/B);G=Math.min(G,_+100663296);var it=Math;G=Math.max(_,G),it=it.min.call(it,2147483648,G+(65536-G%65536)%65536);t:{try{O.grow(it-N.byteLength+65535>>>16),Vt(O.buffer);var vt=1;break t}catch{}vt=void 0}if(vt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,B,G){for(var it=0,vt=0;vt<B;vt++){var lt=kt[L>>2],Rt=kt[L+4>>2];L+=8;for(var Lt=0;Lt<Rt;Lt++){var Ct=j[lt+Lt],Nt=dE[_];Ct===0||Ct===10?((_===1?g:v)(x(Nt,0)),Nt.length=0):Nt.push(Ct)}it+=Rt}return kt[G>>2]=it,0},a:O},$n=function(){function _(B){o.asm=B.exports,J=o.asm.I,$.unshift(o.asm.E),ft--,o.monitorRunDependencies&&o.monitorRunDependencies(ft),ft==0&&bt&&(B=bt,bt=null,B())}var L={a:fE};if(ft++,o.monitorRunDependencies&&o.monitorRunDependencies(ft),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return L=se(L),_(L[0]),o.asm}();o.___wasm_call_ctors=$n.E;var pE=o.___getTypeName=$n.F;o.__embind_initialize_bindings=$n.G;var op=o._malloc=$n.H,xs=o._free=$n.J;o.dynCall_jiji=$n.K;var Zo;bt=function _(){Zo||lp(),Zo||(bt=_)};function lp(){function _(){if(!Zo&&(Zo=!0,o.calledRun=!0,!F)){if(Yt($),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();U.unshift(L)}Yt(U)}}if(!(0<ft)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Z();Yt(St),0<ft||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return lp(),s}})();n.exports=e})(Wd);var hm=Wd.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var e=s(Ml),i=re;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in n&&n[d]===i[d]||Object.defineProperty(n,d,{enumerable:!0,get:function(){return i[d]}})});function s(d){return d&&d.__esModule?d:{default:d}}const o=hm;var c=(0,e.default)(o());n.default=c})(Ee);const jd=am(Ee),Zr=1.8;function dm(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:typeof n.top=="number"?n.top*t:n.top,right:typeof n.right=="number"?n.right*t:n.right,bottom:typeof n.bottom=="number"?n.bottom*t:n.bottom,left:typeof n.left=="number"?n.left*t:n.left}}function Kd(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:(typeof n.top=="number"?n.top*t:n.top)??0,right:(typeof n.right=="number"?n.right*t:n.right)??0,bottom:(typeof n.bottom=="number"?n.bottom*t:n.bottom)??0,left:(typeof n.left=="number"?n.left*t:n.left)??0}}function um(n,t=1){return typeof n=="number"?{topLeft:n*t,topRight:n*t,bottomRight:n*t,bottomLeft:n*t}:{topLeft:((n==null?void 0:n.topLeft)??0)*t,topRight:((n==null?void 0:n.topRight)??0)*t,bottomRight:((n==null?void 0:n.bottomRight)??0)*t,bottomLeft:((n==null?void 0:n.bottomLeft)??0)*t}}function zd(n,{layout:t,scale:e=1}){const{position:i="static",inset:s,width:o,height:c,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:b,margin:E,padding:T,direction:w="column",align:C="start",justify:D="start"}=t,O={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(n.setPositionType(O[i]),s){const{top:H,right:j,bottom:nt,left:st}=dm(s,e);H&&n.setPosition(Ee.Edge.Top,H),j&&n.setPosition(Ee.Edge.Right,j),nt&&n.setPosition(Ee.Edge.Bottom,nt),st&&n.setPosition(Ee.Edge.Left,st)}const F={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};n.setFlexDirection(F[w]);const x={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};n.setAlignItems(x[C]);const N={start:Ee.Justify.FlexStart,end:Ee.Justify.FlexEnd,center:Ee.Justify.Center,"space-between":Ee.Justify.SpaceBetween,"space-around":Ee.Justify.SpaceAround,"space-evenly":Ee.Justify.SpaceEvenly};if(n.setJustifyContent(N[D]),E){const{top:H,right:j,bottom:nt,left:st}=Kd(E,e);n.setMargin(Ee.Edge.Top,H),n.setMargin(Ee.Edge.Right,j),n.setMargin(Ee.Edge.Bottom,nt),n.setMargin(Ee.Edge.Left,st)}if(T){const{top:H,right:j,bottom:nt,left:st}=Kd(T,e);n.setPadding(Ee.Edge.Top,H),n.setPadding(Ee.Edge.Right,j),n.setPadding(Ee.Edge.Bottom,nt),n.setPadding(Ee.Edge.Left,st)}v&&n.setFlex(v),n.setGap(Ee.Gutter.All,(b??0)*e),o&&n.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?n.setHeight("100%"):n.setHeight(typeof c=="number"?c*e:c)),d&&n.setMinWidth(typeof d=="number"?d*e:d),f&&n.setMinHeight(typeof f=="number"?f*e:f),p&&n.setMaxWidth(typeof p=="number"?p*e:p),g&&n.setMaxHeight(typeof g=="number"?g*e:g)}function Yd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i=!1,scale:s=1,position:o=[]}){o.forEach(({x:c,y:d,width:f,height:p,childNodes:g,element:v})=>{const b=n.getContext("2d",{alpha:!1});if(b){const{radius:E,draw:T}=v;if(T){if(b.save(),E){const{topLeft:w,topRight:C,bottomRight:D,bottomLeft:O}=um(E,s);b.beginPath(),b.moveTo(c+Math.min(p/Zr,w),d),b.lineTo(c+f-Math.min(p/Zr,C),d),b.quadraticCurveTo(c+f,d,c+f,d+Math.min(p/Zr,C)),b.lineTo(c+f,d+p-Math.min(p/Zr,D)),b.quadraticCurveTo(c+f,d+p,c+f-Math.min(p/Zr,D),d+p),b.lineTo(c+Math.min(p/Zr,O),d+p),b.quadraticCurveTo(c,d+p,c,d+p-Math.min(p/Zr,O)),b.lineTo(c,d+Math.min(p/Zr,w)),b.quadraticCurveTo(c,d,c+Math.min(p/Zr,w),d),b.closePath(),i&&(b.strokeStyle="blue",b.stroke()),b.clip()}T({scale:s,canvas:n,context:b,cropCanvas:t,letterboxCanvas:e,dx:c,dy:d,dw:f,dh:p}),i&&(b.strokeStyle="red",b.strokeRect(c,d,f,p)),b.restore()}}Yd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i,scale:s,position:g})})}function Xd(n,t,e){const i=t.map((s,o)=>{const c=jd.Node.create(),{radius:d,elements:f=[],draw:p,...g}=s;return zd(c,{layout:g,scale:e}),n.insertChild(c,o),{node:c,element:s,childNodes:Xd(c,f,e)}});return n.calculateLayout(),i}function Zd(n,t,e=0,i=0){const{top:s,left:o}=n.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:b}=c.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:s+T,width:v,height:b,element:d,childNodes:Zd(n,f,E,T)}})}function qd(n,t){n.forEach(({node:e,element:i,childNodes:s})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:c,maxHeight:d,scale:t});e.setHeight(f)}qd(s,t)})}function fm({canvas:n,origin:t,elements:e,...i}){const s={inset:{top:0,left:0},width:n.width,height:n.height,...t},o=jd.Node.create();zd(o,{layout:s}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=Xd(o,e,f);qd(p,f),o.calculateLayout();const g=Zd(o,p);return Yd({...i,scale:f,canvas:n,position:g})}const Qd=[{family:"Noto Arabic",regex:/\p{Script=Arabic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansArabic-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Chinese",regex:/\p{Script=Han}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansSC-VariableFont_wght.woff2",style:"normal"},{family:"Noto Hebrew",regex:/\p{Script=Hebrew}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansHebrew-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Hindi",regex:/\p{Script=Devanagari}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansDevanagari-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Japanese",regex:/\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansJP-VariableFont_wght.woff2",style:"normal"},{family:"Noto Korean",regex:/\p{Script=Hangul}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansKR-VariableFont_wght.woff2",style:"normal"},{family:"Noto Color Emoji",regex:/\p{Extended_Pictographic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoColorEmoji-Regular.woff2",style:"normal"}];function co({text:n,font:t}){let e=t;return Qd.forEach(({family:i,regex:s})=>{s.exec(n)&&(e+=`, ${i}`)}),e}const ho=/(?<value>\d+\.?\d*)(?=px)/;function Jd(n){const{visible:t=!0,node:e}=n,i=[...(e==null?void 0:e.elements)??[],...(n==null?void 0:n.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>Jd(s)):!1}function tu({canvas:n,debug:t=!1,elements:e=[],currentTime:i,relativeTime:s}){return e.map(o=>{var c,d,f,p,g,v,b,E;const{node:T}=o,w=n.getContext("2d");if(w&&Jd(o)){let C=o.width,D=o.height;if((T==null?void 0:T.type)==="text"&&T.value){const O=co({text:T.value,font:T.font});w.save(),T.wrap?D=({width:F,maxHeight:x,scale:N})=>{var H,j;const nt=Hd({font:O,scale:N,context:w,maxW:F,maxH:x,text:T.value??"",minSize:(H=T.fill)==null?void 0:H.minSize,maxSize:(j=T.fill)==null?void 0:j.maxSize});return uo({context:w,font:O,fontSize:nt,text:T.value??"",maxW:F}).length*nt}:(w.font=O,C=w.measureText(T.value).width,D=parseFloat(((d=(c=O.match(ho))==null?void 0:c.groups)==null?void 0:d.value)??"0")),w.restore()}if((T==null?void 0:T.type)==="image"&&T.image&&T.size){const O=((f=T.image)==null?void 0:f.naturalWidth)??((p=T.image)==null?void 0:p.width),F=((g=T.image)==null?void 0:g.naturalHeight)??((v=T.image)==null?void 0:v.height),x=O/F,N=(b=T.size)==null?void 0:b.width,H=(E=T.size)==null?void 0:E.height;C=N??(x>=1?(H??0)*x:(H??0)/x),D=H??(x<1?(N??0)*x:(N??0)/x)}return{...o,width:C,height:D,elements:tu({canvas:n,debug:t,elements:o.elements,currentTime:i,relativeTime:s}),draw:({canvas:O,cropCanvas:F,letterboxCanvas:x,context:N,dx:H,dy:j,dw:nt,dh:st,scale:Q})=>{var kt,gt,Mt,Vt,V,J,St,$,U,Z,ft,bt,xt;if(T){const{type:Ut,from:Qt=0,to:ue=1/0}=T;if(s>=Qt&&s<=ue){if(N.save(),s&&ue-.3333333333333333<=s&&(N.globalAlpha=1-(.16666666666666666-(ue-s))/.16666666666666666),Ut==="box"&&(N.fillStyle=T.background,N.fillRect(H,j,nt,st)),Ut==="text"&&T.value){const se=co({text:T.value,font:T.font}),Yt=Hd({font:se,scale:Q,context:N,maxW:nt,maxH:st,text:T.value??"",minSize:(kt=T.fill)==null?void 0:kt.minSize,maxSize:(gt=T.fill)==null?void 0:gt.maxSize});N.font=se.replace(ho,Yt.toString()),N.textBaseline="top",N.fillStyle=T.color,T.wrap?uo({context:N,font:se,fontSize:Yt,text:T.value,maxW:nt}).forEach((Me,be)=>{N.fillText(Me.text,H,j+Yt*be)}):N.fillText(T.value,H,j)}if(Ut==="image"&&T.image&&N.drawImage(T.image,H,j,nt,st),Ut==="video"&&((Mt=T.video)!=null&&Mt.node||(Vt=T.video)!=null&&Vt.getSource)){const se=T.format??"letterbox",Yt=((J=(V=T.video)==null?void 0:V.getSource)==null?void 0:J.call(V,s))??T.video.node,Me=(Yt==null?void 0:Yt.videoWidth)??(Yt==null?void 0:Yt.naturalWidth)??(Yt==null?void 0:Yt.width),be=(Yt==null?void 0:Yt.videoHeight)??(Yt==null?void 0:Yt.naturalHeight)??(Yt==null?void 0:Yt.height);if(Me&&be){const{dx:ge,dy:oe,dw:Ce,dh:Ft}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:Yt,format:se,crop:(St=T==null?void 0:T.value)==null?void 0:St.crop,sourceWidth:Me,sourceHeight:be,posX:H,posY:j,drawAreaWidth:nt,drawAreaHeight:st});T.elements&&Ul({debug:t,canvas:O,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+oe),left:Math.max(H,H+ge)},width:Math.min(nt,Ce),height:Math.min(st,Ft)},elements:T.elements})}const jt=1/3;if(T.poster&&i>=0&&i<=jt){N.save(),N.globalAlpha=1-i/jt;const ge=(($=T.poster)==null?void 0:$.naturalWidth)??((U=T.poster)==null?void 0:U.width),oe=((Z=T.poster)==null?void 0:Z.naturalHeight)??((ft=T.poster)==null?void 0:ft.height);if(ge&&oe){const{dx:Ce,dy:Ft,dw:Ze,dh:qe}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:T.poster,format:se,crop:(bt=T==null?void 0:T.value)==null?void 0:bt.crop,sourceWidth:ge,sourceHeight:oe,posX:H,posY:j,drawAreaWidth:nt,drawAreaHeight:st});T.elements&&Ul({debug:t,canvas:O,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+Ft),left:Math.max(H,H+Ce)},width:Math.min(nt,Ze),height:Math.min(st,qe)},elements:T.elements})}N.restore()}}if(Ut==="gradient"&&T.value){const se=N.createLinearGradient(H+nt,j,H+nt,j+st);(xt=T.value)==null||xt.forEach(Yt=>{se.addColorStop(Yt.percent,Yt.color)}),N.fillStyle=se,N.fillRect(H,j,nt,st)}N.restore()}}}}}}).filter(Boolean)}function Ul({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s,...o}){return fm({...o,debug:t,canvas:n,elements:tu({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s})})}const uo=Bd(({context:n,font:t,fontSize:e,text:i,maxW:s=1/0})=>{try{return n.save(),n.font=t.replace(ho,e.toString()),i.split(`
89
+ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),rm=(n,t,e)=>{const i=e===""?"":`with ${e.trim()}() `,s=tm.bind(null,i,t.toString());Object.defineProperty(s,"name",im),Object.defineProperty(n,"toString",{...em,value:s})};function sm(n,t,{ignoreNonConfigurable:e=!1}={}){const{name:i}=n;for(const s of Reflect.ownKeys(t))qg(n,t,s,e);return Jg(n,t),rm(n,t,i),n}const nm=new WeakMap,Ud=new WeakMap;function Bd(n,{cacheKey:t,cache:e=new Map,maxAge:i}={}){if(i===0)return n;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 s=function(...o){var c;const d=t?t(o):o[0],f=e.get(d);if(f)return f.data;const p=n.apply(this,o);if(e.set(d,{data:p,maxAge:i?Date.now()+i:Number.POSITIVE_INFINITY}),typeof i=="number"&&i!==Number.POSITIVE_INFINITY){const g=setTimeout(()=>{e.delete(d)},i);(c=g.unref)==null||c.call(g);const v=Ud.get(n)??new Set;v.add(g),Ud.set(n,v)}return p};return sm(s,n,{ignoreNonConfigurable:!0}),nm.set(s,e),s}function Gd({context:n,word:t,maxW:e=1/0}){const i=[],s=n.measureText(t);if(s.width<e)return[{text:t,metrics:s}];for(let o=0;o<t.length;o++){const c=i[i.length-1],d=((c==null?void 0:c.text)??"")+t[o],f=n.measureText(d);f.width<e?i[c?i.length-1:0]={text:d,metrics:f}:i.push({text:t[o],metrics:n.measureText(t[o])})}return i}const Hd=Bd(({font:n,scale:t,context:e,maxW:i,maxH:s,text:o,minSize:c,maxSize:d})=>{var f,p;let g=0;if(d){g=(c??0)*t;let v=0;for(;d*t>g+1;){g+=1;const b=uo({context:e,font:n,fontSize:g,text:o,maxW:i});if(v=b.reduce((E,T)=>(T.metrics.width>E&&(E=T.metrics.width),E),0),v>i||b.length*g>s){g-=1;break}}}else g=parseFloat(((p=(f=n.match(ho))==null?void 0:f.groups)==null?void 0:p.value)??"0")*t;return g},{cacheKey:([{font:n,text:t,minSize:e,maxSize:i,scale:s,maxW:o,maxH:c}])=>`${n}_${t}_${e}_${i}_${s}_${o}_${c}`});function am(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ee={},Ml={},re={};Object.defineProperty(re,"__esModule",{value:!0}),re.default=re.Wrap=re.Unit=re.PrintOptions=re.PositionType=re.Overflow=re.NodeType=re.MeasureMode=re.LogLevel=re.Justify=re.Gutter=re.FlexDirection=re.ExperimentalFeature=re.Errata=re.Edge=re.Display=re.Direction=re.Dimension=re.Align=void 0;let Xr=function(n){return n[n.Auto=0]="Auto",n[n.FlexStart=1]="FlexStart",n[n.Center=2]="Center",n[n.FlexEnd=3]="FlexEnd",n[n.Stretch=4]="Stretch",n[n.Baseline=5]="Baseline",n[n.SpaceBetween=6]="SpaceBetween",n[n.SpaceAround=7]="SpaceAround",n}({});re.Align=Xr;let $l=function(n){return n[n.Width=0]="Width",n[n.Height=1]="Height",n}({});re.Dimension=$l;let eo=function(n){return n[n.Inherit=0]="Inherit",n[n.LTR=1]="LTR",n[n.RTL=2]="RTL",n}({});re.Direction=eo;let Nl=function(n){return n[n.Flex=0]="Flex",n[n.None=1]="None",n}({});re.Display=Nl;let Cr=function(n){return n[n.Left=0]="Left",n[n.Top=1]="Top",n[n.Right=2]="Right",n[n.Bottom=3]="Bottom",n[n.Start=4]="Start",n[n.End=5]="End",n[n.Horizontal=6]="Horizontal",n[n.Vertical=7]="Vertical",n[n.All=8]="All",n}({});re.Edge=Cr;let ha=function(n){return n[n.None=0]="None",n[n.StretchFlexBasis=1]="StretchFlexBasis",n[n.All=2147483647]="All",n[n.Classic=2147483646]="Classic",n}({});re.Errata=ha;let io=function(n){return n[n.WebFlexBasis=0]="WebFlexBasis",n[n.AbsolutePercentageAgainstPaddingEdge=1]="AbsolutePercentageAgainstPaddingEdge",n[n.FixJNILocalRefOverflows=2]="FixJNILocalRefOverflows",n}({});re.ExperimentalFeature=io;let da=function(n){return n[n.Column=0]="Column",n[n.ColumnReverse=1]="ColumnReverse",n[n.Row=2]="Row",n[n.RowReverse=3]="RowReverse",n}({});re.FlexDirection=da;let ro=function(n){return n[n.Column=0]="Column",n[n.Row=1]="Row",n[n.All=2]="All",n}({});re.Gutter=ro;let Js=function(n){return n[n.FlexStart=0]="FlexStart",n[n.Center=1]="Center",n[n.FlexEnd=2]="FlexEnd",n[n.SpaceBetween=3]="SpaceBetween",n[n.SpaceAround=4]="SpaceAround",n[n.SpaceEvenly=5]="SpaceEvenly",n}({});re.Justify=Js;let tn=function(n){return n[n.Error=0]="Error",n[n.Warn=1]="Warn",n[n.Info=2]="Info",n[n.Debug=3]="Debug",n[n.Verbose=4]="Verbose",n[n.Fatal=5]="Fatal",n}({});re.LogLevel=tn;let so=function(n){return n[n.Undefined=0]="Undefined",n[n.Exactly=1]="Exactly",n[n.AtMost=2]="AtMost",n}({});re.MeasureMode=so;let Fl=function(n){return n[n.Default=0]="Default",n[n.Text=1]="Text",n}({});re.NodeType=Fl;let no=function(n){return n[n.Visible=0]="Visible",n[n.Hidden=1]="Hidden",n[n.Scroll=2]="Scroll",n}({});re.Overflow=no;let ao=function(n){return n[n.Static=0]="Static",n[n.Relative=1]="Relative",n[n.Absolute=2]="Absolute",n}({});re.PositionType=ao;let oo=function(n){return n[n.Layout=1]="Layout",n[n.Style=2]="Style",n[n.Children=4]="Children",n}({});re.PrintOptions=oo;let ua=function(n){return n[n.Undefined=0]="Undefined",n[n.Point=1]="Point",n[n.Percent=2]="Percent",n[n.Auto=3]="Auto",n}({});re.Unit=ua;let lo=function(n){return n[n.NoWrap=0]="NoWrap",n[n.Wrap=1]="Wrap",n[n.WrapReverse=2]="WrapReverse",n}({});re.Wrap=lo;var om={ALIGN_AUTO:Xr.Auto,ALIGN_FLEX_START:Xr.FlexStart,ALIGN_CENTER:Xr.Center,ALIGN_FLEX_END:Xr.FlexEnd,ALIGN_STRETCH:Xr.Stretch,ALIGN_BASELINE:Xr.Baseline,ALIGN_SPACE_BETWEEN:Xr.SpaceBetween,ALIGN_SPACE_AROUND:Xr.SpaceAround,DIMENSION_WIDTH:$l.Width,DIMENSION_HEIGHT:$l.Height,DIRECTION_INHERIT:eo.Inherit,DIRECTION_LTR:eo.LTR,DIRECTION_RTL:eo.RTL,DISPLAY_FLEX:Nl.Flex,DISPLAY_NONE:Nl.None,EDGE_LEFT:Cr.Left,EDGE_TOP:Cr.Top,EDGE_RIGHT:Cr.Right,EDGE_BOTTOM:Cr.Bottom,EDGE_START:Cr.Start,EDGE_END:Cr.End,EDGE_HORIZONTAL:Cr.Horizontal,EDGE_VERTICAL:Cr.Vertical,EDGE_ALL:Cr.All,ERRATA_NONE:ha.None,ERRATA_STRETCH_FLEX_BASIS:ha.StretchFlexBasis,ERRATA_ALL:ha.All,ERRATA_CLASSIC:ha.Classic,EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS:io.WebFlexBasis,EXPERIMENTAL_FEATURE_ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE:io.AbsolutePercentageAgainstPaddingEdge,EXPERIMENTAL_FEATURE_FIX_JNILOCAL_REF_OVERFLOWS:io.FixJNILocalRefOverflows,FLEX_DIRECTION_COLUMN:da.Column,FLEX_DIRECTION_COLUMN_REVERSE:da.ColumnReverse,FLEX_DIRECTION_ROW:da.Row,FLEX_DIRECTION_ROW_REVERSE:da.RowReverse,GUTTER_COLUMN:ro.Column,GUTTER_ROW:ro.Row,GUTTER_ALL:ro.All,JUSTIFY_FLEX_START:Js.FlexStart,JUSTIFY_CENTER:Js.Center,JUSTIFY_FLEX_END:Js.FlexEnd,JUSTIFY_SPACE_BETWEEN:Js.SpaceBetween,JUSTIFY_SPACE_AROUND:Js.SpaceAround,JUSTIFY_SPACE_EVENLY:Js.SpaceEvenly,LOG_LEVEL_ERROR:tn.Error,LOG_LEVEL_WARN:tn.Warn,LOG_LEVEL_INFO:tn.Info,LOG_LEVEL_DEBUG:tn.Debug,LOG_LEVEL_VERBOSE:tn.Verbose,LOG_LEVEL_FATAL:tn.Fatal,MEASURE_MODE_UNDEFINED:so.Undefined,MEASURE_MODE_EXACTLY:so.Exactly,MEASURE_MODE_AT_MOST:so.AtMost,NODE_TYPE_DEFAULT:Fl.Default,NODE_TYPE_TEXT:Fl.Text,OVERFLOW_VISIBLE:no.Visible,OVERFLOW_HIDDEN:no.Hidden,OVERFLOW_SCROLL:no.Scroll,POSITION_TYPE_STATIC:ao.Static,POSITION_TYPE_RELATIVE:ao.Relative,POSITION_TYPE_ABSOLUTE:ao.Absolute,PRINT_OPTIONS_LAYOUT:oo.Layout,PRINT_OPTIONS_STYLE:oo.Style,PRINT_OPTIONS_CHILDREN:oo.Children,UNIT_UNDEFINED:ua.Undefined,UNIT_POINT:ua.Point,UNIT_PERCENT:ua.Percent,UNIT_AUTO:ua.Auto,WRAP_NO_WRAP:lo.NoWrap,WRAP_WRAP:lo.Wrap,WRAP_WRAP_REVERSE:lo.WrapReverse};re.default=om,Object.defineProperty(Ml,"__esModule",{value:!0}),Ml.default=cm;var bs=lm(re);function Vd(n){if(typeof WeakMap!="function")return null;var t=new WeakMap,e=new WeakMap;return(Vd=function(i){return i?e:t})(n)}function lm(n,t){if(!t&&n&&n.__esModule)return n;if(n===null||typeof n!="object"&&typeof n!="function")return{default:n};var e=Vd(t);if(e&&e.has(n))return e.get(n);var i={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in n)if(o!=="default"&&Object.prototype.hasOwnProperty.call(n,o)){var c=s?Object.getOwnPropertyDescriptor(n,o):null;c&&(c.get||c.set)?Object.defineProperty(i,o,c):i[o]=n[o]}return i.default=n,e&&e.set(n,i),i}function cm(n){function t(s,o,c){const d=s[o];s[o]=function(){for(var f=arguments.length,p=new Array(f),g=0;g<f;g++)p[g]=arguments[g];return c.call(this,d,...p)}}for(const s of["setPosition","setMargin","setFlexBasis","setWidth","setHeight","setMinWidth","setMinHeight","setMaxWidth","setMaxHeight","setPadding"]){const o={[bs.Unit.Point]:n.Node.prototype[s],[bs.Unit.Percent]:n.Node.prototype[`${s}Percent`],[bs.Unit.Auto]:n.Node.prototype[`${s}Auto`]};t(n.Node.prototype,s,function(c){for(var d=arguments.length,f=new Array(d>1?d-1:0),p=1;p<d;p++)f[p-1]=arguments[p];const g=f.pop();let v,b;if(g==="auto")v=bs.Unit.Auto,b=void 0;else if(typeof g=="object")v=g.unit,b=g.valueOf();else if(v=typeof g=="string"&&g.endsWith("%")?bs.Unit.Percent:bs.Unit.Point,b=parseFloat(g),!Number.isNaN(g)&&Number.isNaN(b))throw new Error(`Invalid value ${g} for ${s}`);if(!o[v])throw new Error(`Failed to execute "${s}": Unsupported unit '${g}'`);return b!==void 0?o[v].call(this,...f,b):o[v].call(this,...f)})}function e(s){return n.MeasureCallback.implement({measure:function(){const{width:o,height:c}=s(...arguments);return{width:o??NaN,height:c??NaN}}})}t(n.Node.prototype,"setMeasureFunc",function(s,o){return o?s.call(this,e(o)):this.unsetMeasureFunc()});function i(s){return n.DirtiedCallback.implement({dirtied:s})}return t(n.Node.prototype,"setDirtiedFunc",function(s,o){s.call(this,i(o))}),t(n.Config.prototype,"free",function(){n.Config.destroy(this)}),t(n.Node,"create",(s,o)=>o?n.Node.createWithConfig(o):n.Node.createDefault()),t(n.Node.prototype,"free",function(){n.Node.destroy(this)}),t(n.Node.prototype,"freeRecursive",function(){for(let s=0,o=this.getChildCount();s<o;++s)this.getChild(0).freeRecursive();this.free()}),t(n.Node.prototype,"calculateLayout",function(s){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:NaN,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:NaN,d=arguments.length>3&&arguments[3]!==void 0?arguments[3]:bs.Direction.LTR;return s.call(this,o,c,d)}),{Config:n.Config,Node:n.Node,...bs.default}}var Wd={exports:{}};(function(n,t){var e=(()=>{var i=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return function(s){s=s||{};var o;o||(o=typeof s<"u"?s:{});var c,d;o.ready=new Promise(function(_,L){c=_,d=L});var f=Object.assign({},o),p="";typeof document<"u"&&document.currentScript&&(p=document.currentScript.src),i&&(p=i),p.indexOf("blob:")!==0?p=p.substr(0,p.replace(/[?#].*/,"").lastIndexOf("/")+1):p="";var g=o.print||console.log.bind(console),v=o.printErr||console.warn.bind(console);Object.assign(o,f),f=null;var b;o.wasmBinary&&(b=o.wasmBinary),o.noExitRuntime;function E(){this.buffer=new ArrayBuffer(V/65536*65536)}function T(){}function w(_){this.exports=function(L){function B(ei){return ei.set=function(le,rr){this[le]=rr},ei.get=function(le){return this[le]},ei}for(var G,it=new Uint8Array(123),vt=25;vt>=0;--vt)it[48+vt]=52+vt,it[65+vt]=vt,it[97+vt]=26+vt;it[43]=62,it[47]=63;function lt(ei,le,rr){for(var Ni,pt,Fr=0,l=le,At=rr.length,Nn=le+(At*3>>2)-(rr[At-2]=="=")-(rr[At-1]=="=");Fr<At;Fr+=4)Ni=it[rr.charCodeAt(Fr+1)],pt=it[rr.charCodeAt(Fr+2)],ei[l++]=it[rr.charCodeAt(Fr)]<<2|Ni>>4,l<Nn&&(ei[l++]=Ni<<4|pt>>2),l<Nn&&(ei[l++]=pt<<6|it[rr.charCodeAt(Fr+3)])}function Rt(ei){lt(G,1024,"T25seSBsZWFmIG5vZGVzIHdpdGggY3VzdG9tIG1lYXN1cmUgZnVuY3Rpb25zIHNob3VsZCBtYW51YWxseSBtYXJrIHRoZW1zZWx2ZXMgYXMgZGlydHkAaXNEaXJ0eQBtYXJrRGlydHkAZGVzdHJveQBzZXREaXNwbGF5AGdldERpc3BsYXkAc2V0RmxleAAtKyAgIDBYMHgALTBYKzBYIDBYLTB4KzB4IDB4AHNldEZsZXhHcm93AGdldEZsZXhHcm93AHNldE92ZXJmbG93AGdldE92ZXJmbG93AGNhbGN1bGF0ZUxheW91dABnZXRDb21wdXRlZExheW91dAB1bnNpZ25lZCBzaG9ydABnZXRDaGlsZENvdW50AHVuc2lnbmVkIGludABzZXRKdXN0aWZ5Q29udGVudABnZXRKdXN0aWZ5Q29udGVudABzZXRBbGlnbkNvbnRlbnQAZ2V0QWxpZ25Db250ZW50AGdldFBhcmVudABpbXBsZW1lbnQAc2V0TWF4SGVpZ2h0UGVyY2VudABzZXRIZWlnaHRQZXJjZW50AHNldE1pbkhlaWdodFBlcmNlbnQAc2V0RmxleEJhc2lzUGVyY2VudABzZXRQb3NpdGlvblBlcmNlbnQAc2V0TWFyZ2luUGVyY2VudABzZXRNYXhXaWR0aFBlcmNlbnQAc2V0V2lkdGhQZXJjZW50AHNldE1pbldpZHRoUGVyY2VudABzZXRQYWRkaW5nUGVyY2VudABjcmVhdGVEZWZhdWx0AHVuaXQAcmlnaHQAaGVpZ2h0AHNldE1heEhlaWdodABnZXRNYXhIZWlnaHQAc2V0SGVpZ2h0AGdldEhlaWdodABzZXRNaW5IZWlnaHQAZ2V0TWluSGVpZ2h0AGdldENvbXB1dGVkSGVpZ2h0AGdldENvbXB1dGVkUmlnaHQAbGVmdABnZXRDb21wdXRlZExlZnQAcmVzZXQAX19kZXN0cnVjdABmbG9hdAB1aW50NjRfdAB1c2VXZWJEZWZhdWx0cwBzZXRVc2VXZWJEZWZhdWx0cwBzZXRBbGlnbkl0ZW1zAGdldEFsaWduSXRlbXMAc2V0RmxleEJhc2lzAGdldEZsZXhCYXNpcwBDYW5ub3QgZ2V0IGxheW91dCBwcm9wZXJ0aWVzIG9mIG11bHRpLWVkZ2Ugc2hvcnRoYW5kcwB1c2VMZWdhY3lTdHJldGNoQmVoYXZpb3VyAHNldFVzZUxlZ2FjeVN0cmV0Y2hCZWhhdmlvdXIAc2V0UG9pbnRTY2FsZUZhY3RvcgBNZWFzdXJlQ2FsbGJhY2tXcmFwcGVyAERpcnRpZWRDYWxsYmFja1dyYXBwZXIAQ2Fubm90IHJlc2V0IGEgbm9kZSBzdGlsbCBhdHRhY2hlZCB0byBhIG93bmVyAHNldEJvcmRlcgBnZXRCb3JkZXIAZ2V0Q29tcHV0ZWRCb3JkZXIAdW5zaWduZWQgY2hhcgB0b3AAZ2V0Q29tcHV0ZWRUb3AAc2V0RmxleFdyYXAAZ2V0RmxleFdyYXAAc2V0R2FwAGdldEdhcAAlcABzZXRIZWlnaHRBdXRvAHNldEZsZXhCYXNpc0F1dG8Ac2V0TWFyZ2luQXV0bwBzZXRXaWR0aEF1dG8AU2NhbGUgZmFjdG9yIHNob3VsZCBub3QgYmUgbGVzcyB0aGFuIHplcm8Ac2V0QXNwZWN0UmF0aW8AZ2V0QXNwZWN0UmF0aW8Ac2V0UG9zaXRpb24AZ2V0UG9zaXRpb24Abm90aWZ5T25EZXN0cnVjdGlvbgBzZXRGbGV4RGlyZWN0aW9uAGdldEZsZXhEaXJlY3Rpb24Ac2V0TWFyZ2luAGdldE1hcmdpbgBnZXRDb21wdXRlZE1hcmdpbgBuYW4AYm90dG9tAGdldENvbXB1dGVkQm90dG9tAGJvb2wAZW1zY3JpcHRlbjo6dmFsAHNldEZsZXhTaHJpbmsAZ2V0RmxleFNocmluawBNZWFzdXJlQ2FsbGJhY2sARGlydGllZENhbGxiYWNrAHdpZHRoAHNldE1heFdpZHRoAGdldE1heFdpZHRoAHNldFdpZHRoAGdldFdpZHRoAHNldE1pbldpZHRoAGdldE1pbldpZHRoAGdldENvbXB1dGVkV2lkdGgAdW5zaWduZWQgbG9uZwBzdGQ6OndzdHJpbmcAc3RkOjpzdHJpbmcAc3RkOjp1MTZzdHJpbmcAc3RkOjp1MzJzdHJpbmcAc2V0UGFkZGluZwBnZXRQYWRkaW5nAGdldENvbXB1dGVkUGFkZGluZwBBdHRlbXB0aW5nIHRvIGNvbnN0cnVjdCBZR05vZGUgd2l0aCBudWxsIGNvbmZpZwBUcmllZCB0byBjb25zdHJ1Y3QgWUdOb2RlIHdpdGggbnVsbCBjb25maWcAY3JlYXRlV2l0aENvbmZpZwBpbmYAc2V0QWxpZ25TZWxmAGdldEFsaWduU2VsZgBTaXplAHZhbHVlAFZhbHVlAGNyZWF0ZQBtZWFzdXJlAHNldFBvc2l0aW9uVHlwZQBnZXRQb3NpdGlvblR5cGUAaXNSZWZlcmVuY2VCYXNlbGluZQBzZXRJc1JlZmVyZW5jZUJhc2VsaW5lAGNvcHlTdHlsZQBkb3VibGUATm9kZQBleHRlbmQAaW5zZXJ0Q2hpbGQAZ2V0Q2hpbGQAcmVtb3ZlQ2hpbGQAdm9pZABhdmFpbGFibGVIZWlnaHQgaXMgaW5kZWZpbml0ZSBzbyBoZWlnaHRNZWFzdXJlTW9kZSBtdXN0IGJlIFlHTWVhc3VyZU1vZGVVbmRlZmluZWQAYXZhaWxhYmxlV2lkdGggaXMgaW5kZWZpbml0ZSBzbyB3aWR0aE1lYXN1cmVNb2RlIG11c3QgYmUgWUdNZWFzdXJlTW9kZVVuZGVmaW5lZABzZXRFeHBlcmltZW50YWxGZWF0dXJlRW5hYmxlZABpc0V4cGVyaW1lbnRhbEZlYXR1cmVFbmFibGVkAGRpcnRpZWQAQ2Fubm90IHJlc2V0IGEgbm9kZSB3aGljaCBzdGlsbCBoYXMgY2hpbGRyZW4gYXR0YWNoZWQAdW5zZXRNZWFzdXJlRnVuYwB1bnNldERpcnRpZWRGdW5jAHNldEVycmF0YQBnZXRFcnJhdGEARXhwZWN0IGN1c3RvbSBiYXNlbGluZSBmdW5jdGlvbiB0byBub3QgcmV0dXJuIE5hTgBOQU4ASU5GAGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHNob3J0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBzaG9ydD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1bnNpZ25lZCBpbnQ+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGZsb2F0PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50OF90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQ4X3Q+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzxpbnQxNl90PgBlbXNjcmlwdGVuOjptZW1vcnlfdmlldzx1aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8aW50MzJfdD4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8Y2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8dW5zaWduZWQgY2hhcj4Ac3RkOjpiYXNpY19zdHJpbmc8dW5zaWduZWQgY2hhcj4AZW1zY3JpcHRlbjo6bWVtb3J5X3ZpZXc8c2lnbmVkIGNoYXI+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PHVuc2lnbmVkIGxvbmc+AGVtc2NyaXB0ZW46Om1lbW9yeV92aWV3PGRvdWJsZT4AQ2hpbGQgYWxyZWFkeSBoYXMgYSBvd25lciwgaXQgbXVzdCBiZSByZW1vdmVkIGZpcnN0LgBDYW5ub3Qgc2V0IG1lYXN1cmUgZnVuY3Rpb246IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAENhbm5vdCBhZGQgY2hpbGQ6IE5vZGVzIHdpdGggbWVhc3VyZSBmdW5jdGlvbnMgY2Fubm90IGhhdmUgY2hpbGRyZW4uAChudWxsKQAlcwoAAQAAAAMAAAAAAAAAAgAAAAMAAAABAAAAAgAAAAAAAAABAAAAAQ=="),lt(G,4338,"wH8DAAAAAADAfwAAAABpaQB2AHZp"),lt(G,4368,"exsAAHkbAAC5GwAAsxsAALkbAACzGwAAaWlpZmlmaQCsGwAAfBsAAHZpaQB9GwAAwBsAAGlpaQ=="),lt(G,4432,"xwAAAMgAAADJ"),lt(G,4452,"xwAAAMoAAADLAAAArBs="),lt(G,4480,"exsAALkbAACzGwAAuRsAALMbAADAGwAAuxsAAMAbAABpaWlpAAAAAKwbAACRGwAArBsAAJMbAACUGwAAwBs="),lt(G,4552,"zAAAAM0AAADO"),lt(G,4572,"zAAAAM8AAADLAAAAlxsAAKwbAACXGw=="),lt(G,4608,"rBsAAJcbAACzGwAArRsAAHZpaWlpAAAArBsAAJcbAAC5GwAAdmlpZgAAAACsGwAAlxsAAK0bAAB2aWlpAAAAAKwbAACXGwAAsxsAAK0bAACYGwAAsxsAAK0bAACYGwAAsxsAAJgbAABpAGRpaQB2aWlkAACcGwAAnBsAAJcbAACsGwAAnBsAAKwbAACcGwAAmxsAAKwbAACcGwAAsxsAAKwbAACcGwAAsxsAALobAAB2aWlpZAAAAKwbAACcGwAAuhsAALMbAACdGwAAmhsAAJ0bAACzGwAAmhsAAJ0bAAC6GwAAnRsAALobAACdGwAAsxsAAGRpaWkAAAAAuRsAAJwbAACzGwAAZmlpaQAAAACsGwAAnBsAAJwbAAC0GwAArBsAAJwbAACcGwAAtBsAAJ0bAACcGwAAnBsAAJwbAACcGwAAtBsAAK0bAACcGwAArBsAAJwbAACtGwAArBsAAJwbAAB5GwAArBsAAJwbAACRGwAArRsAAJ0bAAAAAAAArBsAAJwbAAC6GwAAuhsAALMbAAB2aWlkZGkAAJkbAACdGw=="),lt(G,5040,"GQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),lt(G,5121,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),lt(G,5179,"DA=="),lt(G,5191,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),lt(G,5237,"EA=="),lt(G,5249,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),lt(G,5295,"Eg=="),lt(G,5307,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),lt(G,5362,"GgAAABoaGgAAAAAAAAk="),lt(G,5411,"FA=="),lt(G,5423,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),lt(G,5469,"Fg=="),lt(G,5481,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVG"),lt(G,5556,"1Q=="),lt(G,5596,"//////////8="),lt(G,5664,"8B8BAAAAAAAF"),lt(G,5684,"0A=="),lt(G,5708,"0QAAANIAAADUGw=="),lt(G,5732,"Ag=="),lt(G,5748,"//////////8="),lt(G,5816,"BQ=="),lt(G,5828,"0w=="),lt(G,5852,"0QAAANQAAADoGwAAAAQ="),lt(G,5876,"AQ=="),lt(G,5892,"/////wo="),lt(G,5960,"1g==")}var Lt=new ArrayBuffer(16),Ct=new Int32Array(Lt),Nt=new Float32Array(Lt),Kt=new Float64Array(Lt);function te(ei){return Ct[ei]}function Dt(ei,le){Ct[ei]=le}function Ae(){return Kt[0]}function pi(ei){Kt[0]=ei}function he(){throw new Error("abort")}function Zi(ei){Nt[2]=ei}function Bt(){return Nt[2]}function qo(ei){var le=ei.a,rr=le.a,Ni=rr.buffer;rr.grow=bk;var pt=new Int8Array(Ni),Fr=new Int16Array(Ni),l=new Int32Array(Ni),At=new Uint8Array(Ni),Nn=new Uint16Array(Ni),cp=new Uint32Array(Ni),I=new Float32Array(Ni),Fe=new Float64Array(Ni),Ue=Math.imul,m=Math.fround,Ge=Math.abs,mr=Math.clz32,gE=Math.min,mE=Math.max,zt=NaN,hp=1/0,wt=le.b,Ti=le.c,os=le.d,ls=le.e,Ds=le.f,Fn=le.g,Ma=le.h,Qo=le.i,Ah=le.j,Eh=le.k,Th=le.l,dp=le.m,up=le.n,fp=le.o,pp=le.p,gp=le.q,vE=le.r,yE=le.s,bE=le.t,AE=le.u,EE=le.v,TE=le.w,kE=le.x,wE=le.y,SE=le.z,RE=le.A,_E=le.B,LE=le.C,CE=le.D,Et=73712,Fi=0;function mp(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var M=0,W=m(0),z=0,X=m(0),at=0,ot=m(0),mt=0,yt=m(0),_t=0,Ot=0,$t=m(0),Ht=0,Zt=0,ne=m(0),pe=m(0),_e=m(0),De=m(0),Pe=0,Be=m(0),Ve=m(0),ii=0,ri=0,vi=m(0),Di=0,Qi=0,Pi=0,Gi=0,Ji=m(0),tr=0,Rr=0,_r=0,Vr=0,Wr=m(0),jr=0,Kr=0,cs=0,hs=0,ds=m(0),$s=0,Ns=0,Fs=0,Us=m(0),Bs=0,Gs=m(0),Fa=0,Ua=m(0),Ba=m(0),Ga=m(0),Ha=0,al=m(0),Nh=0,Fh=m(0),Uh=m(0),Bh=m(0),Gh=m(0),Hh=0,u2=0,f2=0,p2=0,g2=0,m2=0,v2=0,y2=0,We=0,je=m(0),Wn=m(0);M=Et-384|0,Et=M;t:{r:{i:{if(!(y&&a!=a)){if(!(A&&h!=h)){if(z=(P?0:4)+tt|0,l[z>>2]=l[z>>2]+1,z=l[r+24>>2]&3,Nh=(u|0)<=1?1:u,Gi=z||Nh,pt[r+300|0]=At[r+300|0]&252|Gi&3,z=r+252|0,u=((Gi|0)!=1)<<3,$s=(Gi|0)==2?3:2,ot=de(r,$s,k),I[z+u>>2]=ot,at=z,z=((Gi|0)==1)<<3,pe=we(r,$s,k),I[at+z>>2]=pe,yt=de(r,0,k),I[r+256>>2]=yt,De=we(r,0,k),I[r+264>>2]=De,at=r+268|0,We=at+u|0,je=fe(r,$s),I[We>>2]=je,We=z+at|0,je=Se(r,$s),I[We>>2]=je,W=fe(r,0),I[r+272>>2]=W,Be=Se(r,0),I[r+280>>2]=Be,at=u,u=r+284|0,We=at+u|0,je=Ie(r,$s,k),I[We>>2]=je,We=u+z|0,je=xe(r,$s,k),I[We>>2]=je,X=Ie(r,0,k),I[r+288>>2]=X,$t=xe(r,0,k),I[r+296>>2]=$t,ot=m(ot+pe),pe=m(yt+De),u=l[r+8>>2],u){yt=m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),h=m(A?h-pe:zt),W=m(m(X+$t)+W),X=m(y?a-ot:zt),a=X;e:{if(a!=a)break e;if(a=m(X-yt),a!=a){a=m(0);break e}a=ce(a,m(0))}ot=m(W+Be),W=h;e:{if(h!=h)break e;if(W=m(h-ot),W!=W){W=m(0);break e}W=ce(W,m(0))}if(!((y|0)!=1|(A|0)!=1)){a=He(r,2,X,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=He(r,0,h,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(At[r+4|0]&16){Pt[u|0](M+24|0,r,a,y,W,A,0);break e}Pt[u|0](M+24|0,r,a,y,W,A)}l[tt+20>>2]=l[tt+20>>2]+1,u=(et<<2)+tt|0,l[u+24>>2]=l[u+24>>2]+1,a=m(yt+I[M+24>>2]),a=He(r,2,y?(y|0)==2?a:X:a,k),u=a!=a,W=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|W!=W)){a=ce(a,W);break e}a=u?W:a}I[r+516>>2]=a,a=m(ot+I[M+28>>2]),a=He(r,0,A?(A|0)==2?a:h:a,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}if(u=l[r+556>>2],et=l[r+560>>2],(u|0)==(et|0)){pe=m(h-pe),a=He(r,2,y&-3?m(a-ot):m(m(m(I[r+284>>2]+I[r+292>>2])+I[r+268>>2])+I[r+276>>2]),k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+516>>2]=a,a=He(r,0,A&-3?pe:m(m(m(X+$t)+W)+Be),S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));e:{if(!(u|h!=h)){a=ce(a,h);break e}a=u?h:a}I[r+520>>2]=a;break t}e:{if(P||(W=m(a-ot),X=m(h-pe),!(!(!(W<=m(0))|(y|0)!=2)&W==W|!(!(X<=m(0))|(A|0)!=2)&X==X)&((y|0)!=1|(A|0)!=1)))break e;a=He(r,2,W!=W||(y|0)==2&&W<m(0)?m(0):W,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+516>>2]=a,a=He(r,0,X!=X||(A|0)==2&&X<m(0)?m(0):X,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));s:{if(!(u|h!=h)){a=ce(a,h);break s}a=u?h:a}I[r+520>>2]=a;break t}for(ii=et-u|0,Vr=ii>>2;z=l[u>>2],l[z+552>>2]!=(r|0)&&(at=l[r+568>>2],z=Ip(l[at>>2],At[at+8|0],z,r,_t,0),l[u>>2]=z,l[z+552>>2]=r),_t=_t+1|0,u=u+4|0,(et|0)!=(u|0););pt[r+300|0]=At[r+300|0]&251,_t=3,Di=l[r+24>>2],u=Di>>>2&3;e:{s:{n:{if((Gi|0)==2){et=0;a:switch(u-2|0){case 0:break e;case 1:break a;default:break n}_t=2;break e}if(_t=2,et=0,u>>>0>1)break s}et=_t}_t=u}Fh=m(a-ot),Wr=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),Be=m(Ie(r,et,k)+fe(r,et)),Ji=m(Be+m(xe(r,et,k)+Se(r,et))),tr=_t>>>0>1,yt=Ep(r,0,Fh,tr?Wr:Ji,k),Uh=m(h-pe),Ve=Ep(r,1,Uh,tr?Ji:Wr,S),De=tr?Ve:yt,pe=tr?yt:Ve,jr=l[r+560>>2],z=l[r+556>>2],Qi=tr?y:A;e:{if((Qi|0)!=1)break e;if((z|0)==(jr|0))break i;for(u=z;;){at=l[u>>2];s:{if(!Bp(at))break s;if(Zt=0,mt)break e;n:{a:{if(!l[at+552>>2]){W=m(0);break a}if(h=I[at+32>>2],h!=h&&(W=m(0),h=I[at+28>>2],!(h>m(0))))break a;if(W=h,h!=h)break n}if(m(Ge(W))<m(9999999747378752e-20))break e}if(a=Hn(at),a!=a){mt=at;break s}if(mt=at,m(Ge(a))<m(9999999747378752e-20))break e}if(Zt=mt,u=u+4|0,(jr|0)==(u|0))break}}if((z|0)==(jr|0))break i;for(Fa=(Gi|0)<=1?1:Gi,Ns=yt!=yt,Kr=Ns|(y|0)!=1,cs=Ve==Ve,Fs=yt==yt,W=m(0);;){Ht=l[z>>2],Ap(Ht),at=l[Ht+24>>2];e:{if(at&4194304){if(wp(Ht,0),u=At[Ht+4|0],at=u|1,pt[Ht+4|0]=at,!(u&4))break e;pt[Ht+4|0]=at&251;break e}if(P&&(u=at&3,xp(Ht,u||Fa,pe,De,yt),at=l[Ht+24>>2]),(at&196608)==131072)break e;s:{if((Ht|0)==(Zt|0)){l[Zt+308>>2]=0,l[Zt+304>>2]=q,h=m(0);break s}hs=l[r+24>>2],u=hs>>>2&3;n:{a:{if((Gi|0)!=2)break a;mt=3;o:switch(u-2|0){case 0:break n;case 1:break o;default:break a}mt=2;break n}mt=u}Rr=mt>>>0>1,ot=Rr?yt:Ve,h=m(0),a=I[Ht+40>>2];n:{a:{Ot=l[Ht+40>>2];o:{if((Ot|0)==2139156720)break o;if((Ot|0)==2140081935)break a;u=4336;l:{if((Ot|0)!=2141891242){if(a==a)break l;u=4344}h=I[u>>2];c:{h:switch(Ot=l[u+4>>2],Ot|0){case 0:case 3:break h;default:break c}if(a=m(zt),!(I[Ht+28>>2]>m(0)))break n;Ot=pt[l[Ht+568>>2]+8|0]&1,u=Ot?2143289344:0,Ot=Ot?3:1,h=(Dt(2,u),Bt())}switch(a=m(zt),Ot-1|0){case 0:break a;case 1:break o;default:break n}}if(h=(Dt(2,(Ot&-1073741825)+536870912|0),Bt()),!(Ot&1073741824))break a}a=m(m(ot*h)*m(.009999999776482582));break n}a=h}h=I[Ht+572>>2],Ot=0;n:{a:switch(Pe=l[Ht+576>>2],Pe|0){case 0:case 3:break n;default:break a}if(X=I[Ht+572>>2],!((Pe|0)!=1|X!=X)){if(h<m(0))break n;Ot=1;break n}if(Ot=1,(Pe|0)!=2|X!=X||(Ot=0,h<m(0)))break n;Ot=Fs}X=I[Ht+580>>2],u=0;n:{a:switch(ri=l[Ht+584>>2],ri|0){case 0:case 3:break n;default:break a}if($t=I[Ht+580>>2],!((ri|0)!=1|$t!=$t)){if(X<m(0))break n;u=1;break n}if(u=1,(ri|0)!=2|$t!=$t||(u=0,X<m(0)))break n;u=cs}n:{a:{if(!(a!=a|ot!=ot)){if(h=I[Ht+308>>2],(!(pt[l[Ht+568>>2]+12|0]&1)|l[Ht+304>>2]==(q|0))&h==h)break n;if(h=m(m(Ie(Ht,mt,yt)+fe(Ht,mt))+m(xe(Ht,mt,yt)+Se(Ht,mt))),!(h<=a)&a<h)break a;h=a;break a}if(Ot&Rr){X=m(m(Ie(Ht,2,yt)+fe(Ht,2))+m(xe(Ht,2,yt)+Se(Ht,2))),a=m(zt);o:switch(Pe-1|0){case 1:h=m(m(yt*h)*m(.009999999776482582));case 0:if(a=h,X<=a)break a;break;default:break o}if(!(a==a|X==X)){h=a;break a}if(a<X){h=X;break a}h=a!=a?X:a;break a}if(!(Rr|u^1)){a=m(m(Ie(Ht,0,yt)+fe(Ht,0))+m(xe(Ht,0,yt)+Se(Ht,0))),h=m(zt);o:switch(ri-1|0){case 1:X=m(m(Ve*X)*m(.009999999776482582));case 0:if(h=X,a<=h)break a;break;default:break o}if(h!=h&a!=a)break a;if(a>h){h=a;break a}h=h!=h?a:h;break a}if(l[M+360>>2]=2143289344,l[M+24>>2]=2143289344,Pi=0,l[M+356>>2]=0,l[M+352>>2]=0,$t=m(de(Ht,2,yt)+we(Ht,2,yt)),ne=de(Ht,0,yt),_e=we(Ht,0,yt),ot=m(zt),_r=0,a=m(zt),Ot){o:{l:switch(Pe-1|0){case 0:a=h;break o;case 1:break l;default:break o}a=m(m(yt*h)*m(.009999999776482582))}l[M+356>>2]=1,a=m($t+a),I[M+24>>2]=a,_r=1}if(ne=m(ne+_e),u){h=m(zt);o:{l:switch(ri-1|0){case 0:h=X;break o;case 1:break l;default:break o}h=m(m(Ve*X)*m(.009999999776482582))}l[M+352>>2]=1,ot=m(ne+h),I[M+360>>2]=ot,Pi=1}Pe=(hs&3145728)==2097152,ri=mt>>>0<2;o:{l:{c:{if(!(Pe&ri)){if(Pe|Ns)break l;if(a!=a)break c;break l}if(Ns|a==a)break o}_r=2,l[M+356>>2]=2,I[M+24>>2]=yt,a=yt}l:{if(!Pe||ri){if(Pe|Ve!=Ve)break o;if(ot!=ot)break l;break o}if(ot==ot|Ve!=Ve)break o}Pi=2,l[M+352>>2]=2,I[M+360>>2]=Ve,ot=Ve}h=I[Ht+224>>2],Pe=h!=h;o:{if(Pe)break o;l:{if(!(Rr|(_r|0)!=1)){l[M+352>>2]=1,I[M+360>>2]=ne+m(m(a-$t)/h);break l}if(ri|(Pi|0)!=1)break o;l[M+356>>2]=1,I[M+24>>2]=m(m(ot-ne)*h)+$t}Pi=1,_r=1}at=at>>>13&7,at=at||hs>>>10&7;o:{if((at|0)==5|(_r|0)==1|(Rr|(Ot|Kr))|(at|0)!=4||(l[M+356>>2]=1,I[M+24>>2]=yt,Pe))break o;Pi=1,l[M+352>>2]=1,I[M+360>>2]=m(yt-$t)/h}o:{if(ri|(A|0)!=1|Ve!=Ve|u|(at|0)!=4|(Pi|0)==1||(l[M+352>>2]=1,I[M+360>>2]=Ve,Pe))break o;l[M+356>>2]=1,I[M+24>>2]=m(Ve-ne)*h}if(Un(Ht,2,yt,yt,M+356|0,M+24|0),Un(Ht,0,Ve,yt,M+352|0,M+360|0),un(Ht,I[M+24>>2],I[M+360>>2],Gi,l[M+356>>2],l[M+352>>2],yt,Ve,0,5,K,tt,dt,q),a=I[(Ht+(l[(mt<<2)+4320>>2]<<2)|0)+516>>2],u=a!=a,h=m(m(Ie(Ht,mt,yt)+fe(Ht,mt))+m(xe(Ht,mt,yt)+Se(Ht,mt))),!(u|h!=h)){h=ce(a,h);break a}h=u?h:a}I[Ht+308>>2]=h}l[Ht+304>>2]=q}W=m(W+m(h+m(de(Ht,_t,yt)+we(Ht,_t,yt))))}if(z=z+4|0,(jr|0)==(z|0))break}break r}l[M>>2]=3072,sr(r,M),qi(),he()}l[M+16>>2]=3154,sr(r,M+16|0),qi(),he()}W=m(0)}a=m(W+m(0)),Ua=tr?S:k,Us=tr?k:S,ii>>>0>=5&&(a=m(m(Jo(r,_t,De)*m(Vr-1>>>0))+a)),u=a>pe,jr=Di&786432,cs=(Qi|0)==2&&jr&&u?1:Qi,Ht=tr?A:y,Rr=(Ht|0)==1,u2=Rr&(P^1),tr=_t>>>0<2,f2=Ht&-3,Ns=r+208|0,A=et<<2,ri=A+4288|0,p2=Rr&!jr,g2=(Ht|0)!=1|P,z=_t<<2,_r=z+4288|0,Fs=z+4320|0,hs=De==De,m2=hs<<1,Pe=A+4320|0,v2=!Qi|!u,Fa=M+52|0,Bh=Jo(r,et,De),at=0,u=0,Pi=0;r:{for(;;){Qi=u,Bi(M+24|0,0,44),u=l[r+560>>2],A=l[r+556>>2];i:{if((u|0)==(A|0))break i;if(u=u-A|0,(u|0)<0)break r;if(z=Na(M+360|0,u>>2,0,Fa),u=l[M+44>>2],A=l[M+48>>2]-u|0,A=Ps(l[M+364>>2]-A|0,u,A),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=A,mt=l[M+368>>2],Ot=l[M+372>>2],A=l[M+48>>2],l[M+368>>2]=A,Zt=l[M+52>>2],l[M+48>>2]=mt,l[M+52>>2]=Ot,l[M+372>>2]=Zt,l[z>>2]=u,(u|0)!=(A|0)&&(l[M+368>>2]=A+((u-A|0)+3&-4)),!u)break i;gi(u)}Zt=l[r+24>>2],u=Zt>>>2&3;i:{e:{if(A=Zt&3,((A||Nh)|0)!=2)break e;mt=3;s:switch(u-2|0){case 0:break i;case 1:break s;default:break e}mt=2;break i}mt=u}W=Jo(r,mt,yt),z=at,Ot=l[r+560>>2],A=l[r+556>>2];i:{if(z>>>0>=Ot-A>>2>>>0)break i;for(Zt=Zt&786432,h=m(0);;){if(Ot-A>>2>>>0<=z>>>0)break r;if(u=l[(z<<2)+A>>2],ii=l[u+24>>2],!(ii&4194304|(ii&196608)==131072)){if(l[u+548>>2]=Qi,a=de(u,mt,yt),X=we(u,mt,yt),A=l[M+24>>2],ot=(z|0)==(at|0)?m(0):W,a=m(a+X),X=I[u+308>>2],$t=He(u,mt,X,Us),!(!A||!(m(ot+m(a+m(h+$t)))>pe)|!Zt))break i;if(l[M+24>>2]=A+1,ot=m(ot+m(a+$t)),I[M+28>>2]=ot+I[M+28>>2],Bp(u)){e:{if(!l[u+552>>2]){a=m(0);break e}if(a=I[u+32>>2],a==a)break e;a=I[u+28>>2],a=a>m(0)?a:m(0)}I[M+32>>2]=a+I[M+32>>2],We=M,je=m(I[M+36>>2]-m(Hn(u)*X)),I[We+36>>2]=je}A=l[M+48>>2];e:{if((A|0)!=l[M+52>>2]){l[A>>2]=u,l[M+48>>2]=A+4;break e}if(A=A-l[M+44>>2]|0,ii=A>>2,Ot=ii+1|0,Ot>>>0>=1073741824)break r;if(Di=A>>1,Ot=Na(M+360|0,A>>>0>=2147483644?1073741823:Ot>>>0<Di>>>0?Di:Ot,ii,Fa),l[l[M+368>>2]>>2]=u,l[M+368>>2]=l[M+368>>2]+4,u=l[M+44>>2],A=l[M+48>>2]-u|0,A=Ps(l[M+364>>2]-A|0,u,A),u=l[M+44>>2],l[M+364>>2]=u,l[M+44>>2]=A,ii=l[M+368>>2],Di=l[M+372>>2],A=l[M+48>>2],l[M+368>>2]=A,Kr=l[M+52>>2],l[M+48>>2]=ii,l[M+52>>2]=Di,l[M+372>>2]=Kr,l[Ot>>2]=u,(u|0)!=(A|0)&&(l[M+368>>2]=A+((u-A|0)+3&-4)),!u)break e;gi(u)}A=l[r+556>>2],Ot=l[r+560>>2],h=m(h+ot)}if(z=z+1|0,!(z>>>0<Ot-A>>2>>>0))break}}_e=I[M+32>>2],!(_e>m(0))|!(_e<m(1))||(l[M+32>>2]=1065353216,_e=m(1)),vi=I[M+36>>2],!(vi>m(0))|!(vi<m(1))||(l[M+36>>2]=1065353216,vi=m(1)),l[M+40>>2]=z,$t=I[M+28>>2],mt=l[M+24>>2],Pi&&gi(Pi),X=I[M+56>>2],ii=l[M+48>>2],Pi=l[M+44>>2];i:{e:{s:{n:{if((cs|0)==1)break n;h=m(0),a=I[Ns>>2];a:{o:{u=l[Ns>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(a==a)break c;A=4344}switch(h=I[A>>2],a=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}a=m(m(h*k)*m(.009999999776482582));break a}a=h}h=m(0),W=I[r+216>>2];a:{o:{u=l[r+216>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(W==W)break c;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}W=m(m(h*k)*m(.009999999776482582));break a}W=h}h=m(0),ot=I[r+212>>2];a:{o:{u=l[r+212>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ot==ot)break c;A=4344}switch(h=I[A>>2],ot=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ot=m(m(h*S)*m(.009999999776482582));break a}ot=h}h=m(0),ne=I[r+220>>2];a:{o:{u=l[r+220>>2];l:{if((u|0)==2139156720)break l;if((u|0)==2140081935)break o;A=4336;c:{if((u|0)!=2141891242){if(ne==ne)break c;A=4344}switch(h=I[A>>2],ne=m(zt),l[A+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break o}ne=m(m(h*S)*m(.009999999776482582));break a}ne=h}if(u=_t>>>0>1,h=m((u?a:ot)-Wr),h==h&h>$t||(h=m((u?W:ne)-Wr),h==h&h<$t))break s;if(pt[l[r+568>>2]+16|0]&1)break n;if(h=$t,!l[r+552>>2]|_e==m(0))break e;a=I[r+32>>2];a:{o:{if(a==a){h=a;break o}if(h=I[r+28>>2],!(h>m(0)))break a}if(h!=h){h=pe;break e}a=I[r+32>>2]}if(a!=a&&(h=$t,a=I[r+28>>2],!(a>m(0)))||(h=pe,a!=m(0)))break e;h=$t;break e}h=pe}if(h!=h)break e;X=m(h-$t);break i}if(!($t<m(0)))break i;X=m(-$t)}if(pe=h,!u2){i:{if((ii|0)==(Pi|0)){ot=m(0);break i}for(ne=m(0),A=Pi;;){u=l[A>>2],$t=I[u+308>>2],h=He(u,_t,$t,Us);e:{if(X<m(0)){if(a=m(h*m(-Hn(u))),!(a>m(0)|a<m(0)))break e;W=m(m(m(X/vi)*a)+h),a=He(u,_t,W,pe),Ot=a!=a,ot=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|ot!=ot)){a=ce(a,ot);break s}a=Ot?ot:a}if(W!=W|a!=a|a==W)break e;ne=m(ne+m(a-h)),vi=m(m(Hn(u)*$t)+vi);break e}if(!(X>m(0))|!l[u+552>>2]||(W=I[u+32>>2],W!=W&&(W=I[u+28>>2],!(W>m(0))))||!(W<m(0)|W>m(0)))break e;ot=m(m(m(X/_e)*W)+h),a=He(u,_t,ot,pe),Ot=a!=a,$t=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t)));s:{if(!(Ot|$t!=$t)){a=ce(a,$t);break s}a=Ot?$t:a}if(ot!=ot|a!=a|a==ot)break e;_e=m(_e-W),ne=m(ne+m(a-h))}if(A=A+4|0,(ii|0)==(A|0))break}for(ne=m(X-ne),Ba=m(ne/vi),Ga=m(ne/_e),Ha=Rr&(v2|!(At[r+26|0]&12)),Kr=!Ha,Di=l[Pe>>2],ot=m(0),Ot=Pi;;){u=l[Ot>>2],$t=He(u,_t,I[u+308>>2],Us);e:{s:{if(ne<m(0)){if(W=$t,a=m(W*m(-Hn(u))),a==m(0))break e;a=vi==m(0)?m($t+a):m(m(Ba*a)+$t);break s}if(W=$t,!(ne>m(0))|!l[u+552>>2]||(a=I[u+32>>2],a!=a&&(a=I[u+28>>2],!(a>m(0))))||!(a<m(0)|a>m(0)))break e;a=m(m(Ga*a)+$t)}if(a=He(u,_t,a,pe),A=a!=a,h=m(m(Ie(u,_t,yt)+fe(u,_t))+m(xe(u,_t,yt)+Se(u,_t))),!(A|h!=h)){W=ce(a,h);break e}W=A?h:a}a=de(u,_t,yt),h=we(u,_t,yt),_e=de(u,et,yt),al=we(u,et,yt),h=m(a+h),Gh=m(W+h),I[M+352>>2]=Gh,l[M+344>>2]=1,_e=m(_e+al),a=I[u+224>>2];e:{if(a==a){l[M+348>>2]=1,h=m(Gh-h),I[M+356>>2]=_e+m(tr?h*a:h/a);break e}s:{if(Bs=De!=De,Bs)break s;Zt=(Di<<3)+u|0,a=I[Zt+572>>2];n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(h=I[Zt+572>>2],(A|0)!=1|h!=h)break a;if(!(Kr|!(a<m(0))))break n;break s}if(!Ha)break s;break n}if(Kr|(!(a<m(0))|((A|0)!=2|h!=h)))break s}if(A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(M+24|0,u,et),l[M+28>>2]==3)||(fn(M+360|0,u,et),l[M+364>>2]==3))break s;l[M+348>>2]=1,I[M+356>>2]=De;break e}Zt=(Di<<3)+u|0,h=I[Zt+572>>2];s:{n:{a:{o:{l:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break o;default:break l}if(a=I[Zt+572>>2],!((A|0)!=1|a!=a)){if(a=h,a<m(0))break o;break s}if((A|0)!=2|a!=a)break a;if(Bs)break o;if(!(h<m(0)))break n}l[M+348>>2]=m2,I[M+356>>2]=De;break e}a=m(zt);a:switch(A-1|0){case 1:break n;case 0:break a;default:break s}a=h;break s}a=m(m(De*h)*m(.009999999776482582))}a=m(_e+a),I[M+356>>2]=a,l[M+348>>2]=(Rr|(A|0)!=2)&a==a}Un(u,_t,pe,yt,M+344|0,M+352|0),Un(u,et,De,yt,M+348|0,M+356|0),Zt=(Di<<3)+u|0,a=I[Zt+572>>2];e:{s:{n:{a:switch(A=l[Zt+576>>2],A|0){case 0:case 3:break n;default:break a}if(h=I[Zt+572>>2],!((A|0)!=1|h!=h)){if(a<m(0))break n;break s}if((A|0)!=2|h!=h)break s;if(a<m(0))break n;if(Zt=0,hs)break e}if(Zt=0,A=l[u+24>>2]>>>13&7,A||(A=l[r+24>>2]>>>10&7),(A|0)!=4||(pn(M+24|0,u,et),l[M+28>>2]==3))break e;fn(M+360|0,u,et),Zt=l[M+364>>2]!=3;break e}Zt=0}a=I[M+352>>2],h=I[M+356>>2],A=_t>>>0>1,_e=A?a:h,a=A?h:a,Bs=l[M+344>>2],Hh=l[M+348>>2],y2=A?Bs:Hh,Bs=A?Hh:Bs,A=(Zt^1)&P,un(u,_e,a,At[r+300|0]&3,y2,Bs,yt,Ve,A,A?4:7,K,tt,dt,q),ot=m(ot+m(W-$t)),A=At[r+300|0];e:{s:{if(A&4){Zt=A&251;break s}if(Zt=A&251,A=0,!(At[u+300|0]&4))break e}A=4}if(pt[r+300|0]=A|Zt,Ot=Ot+4|0,(ii|0)==(Ot|0))break}}X=m(X-ot)}u=At[r+300|0],pt[r+300|0]=u&251|(X<m(0)?4:u&4),ne=m(Ie(r,_t,k)+fe(r,_t)),Ba=m(xe(r,_t,k)+Se(r,_t)),$t=Jo(r,_t,k);i:{if(!(!(X>m(0))|(cs|0)!=2)){ot=m(0),h=m(0);e:{s:{u=Ns+(l[Fs>>2]<<2)|0,a=I[u>>2],u=l[u>>2],A=(u|0)==2139156720;n:{if(!A){if(Ot=(u|0)==2140081935,Ot)break s;if(Zt=(u|0)==2141891242,Zt|a!=a)break i;if(Ot)break s;if(Zt)break i;if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break n}h=m(m(Us*h)*m(.009999999776482582))}if(h!=h)break i;h=m(0);n:{if(A)break n;if((u|0)==2140081935)break s;A=4336;a:{if((u|0)!=2141891242){if(a==a)break a;A=4344}switch(h=I[A>>2],W=m(zt),l[A+4>>2]-1|0){case 0:break s;case 1:break n;default:break e}}if(h=(Dt(2,(u&-1073741825)+536870912|0),Bt()),!(u&1073741824))break s}W=m(m(Us*h)*m(.009999999776482582));break e}W=h}if(a=m(m(m(W-ne)-Ba)-m(pe-X)),a!=a)break i;ot=ce(a,m(0));break i}ot=X}Zt=z>>>0<=at>>>0;i:{if(!Zt){for(ii=l[r+556>>2],u=l[r+560>>2]-ii>>2,Di=u>>>0<at>>>0?at:u,Ot=0,u=at;;){if((u|0)==(Di|0))break r;if(A=l[ii+(u<<2)>>2],(l[A+24>>2]&196608)!=131072&&(Kr=M+24|0,pn(Kr,A,_t),Ha=l[M+28>>2],fn(Kr,A,_t),Ot=(((Ha|0)==3)+Ot|0)+(l[M+28>>2]==3)|0),u=u+1|0,(z|0)==(u|0))break}if(_e=m(0),h=$t,Ot)break i}_e=m(0),Ot=0,h=$t;e:switch((l[r+24>>2]>>>4&7)-1|0){case 0:_e=m(ot*m(.5));break i;case 1:_e=ot;break i;case 2:if(mt>>>0<2)break i;h=m($t+m((je=m(0),Wn=ce(ot,m(0)),We=ot!=ot,(We?je:Wn)/m(mt-1>>>0))));break i;case 4:_e=m(ot/m(mt+1>>>0)),h=m($t+_e);break i;case 3:break e;default:break i}_e=m(m(ot*m(.5))/m(mt>>>0)),h=m(m(_e+_e)+$t)}if(a=m(ne+_e),X=m(0),ii=Pp(r),Zt)h=m(0);else{for(Di=z-1|0,Ga=m(ot/m(Ot|0)),ne=m(0),W=m(0),u=at;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=u>>>0)break r;A=l[A+(u<<2)>>2],mt=A+228|0,Ui(M+24|0,mt,320),h=m(h-((u|0)==(Di|0)?$t:m(0))),Ot=l[A+24>>2];i:{if(Ot&4194304)break i;e:{if((Ot&196608)==131072){if(!nr(A,_t))break e;if(!P)break i;ot=Os(A,_t,pe),vi=fe(r,_t),al=de(A,_t,yt),I[mt+(l[_r>>2]<<2)>>2]=al+m(ot+vi);break i}if(pn(M+360|0,A,_t),a=m(a+(l[M+364>>2]==3?Ga:m(-0))),P&&(Ot=mt,mt=l[_r>>2]<<2,I[Ot+mt>>2]=a+I[mt+(M+24|0)>>2]),fn(M+360|0,A,_t),a=m(a+(l[M+364>>2]==3?Ga:m(-0))),!g2){a=m(a+m(m(h+m(de(A,_t,yt)+we(A,_t,yt)))+I[M+104>>2])),X=De;break i}if(mt=A+516|0,a=m(a+m(h+m(I[mt+(l[Fs>>2]<<2)>>2]+m(de(A,_t,yt)+we(A,_t,yt))))),ii){ot=tl(A),vi=de(A,0,yt),ot=m(ot+vi),vi=m(m(I[A+520>>2]+m(de(A,0,yt)+we(A,0,yt)))-ot),A=ne!=ne;s:{if(!(A|ot!=ot)){ne=ce(ne,ot);break s}ne=A?ot:ne}if(A=W!=W,!(A|vi!=vi)){W=ce(W,vi);break i}W=A?vi:W;break i}if(ot=m(I[mt+(l[Pe>>2]<<2)>>2]+m(de(A,et,yt)+we(A,et,yt))),A=X!=X,!(ot!=ot|A)){X=ce(X,ot);break i}X=A?ot:X;break i}if(!P)break i;A=l[_r>>2]<<2,ot=I[A+(M+24|0)>>2],We=A+mt|0,je=m(_e+m(ot+fe(r,_t))),I[We>>2]=je}if(u=u+1|0,(z|0)==(u|0))break}h=m(W+ne)}if(X=ii?h:X,ot=De,!f2){h=He(r,et,m(Ji+X),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}ot=m(h-Ji)}h=He(r,et,m(Ji+(p2?De:X)),Ua),u=h!=h,W=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et)));i:{if(!(u|W!=W)){h=ce(h,W);break i}h=u?W:h}if(W=m(h-Ji),!(Zt|!P))for(;;){if(u=l[r+556>>2],l[r+560>>2]-u>>2>>>0<=at>>>0)break r;mt=l[u+(at<<2)>>2],u=l[mt+24>>2];i:{if(u&4194304)break i;if((u&196608)==131072){e:{if(!nr(mt,et)){A=l[ri>>2];break e}if(h=Os(mt,et,De),X=fe(r,et),$t=de(mt,et,yt),A=l[ri>>2],h=m($t+m(h+X)),I[(mt+(A<<2)|0)+228>>2]=h,h==h)break i}We=mt+(A<<2)|0,je=m(fe(r,et)+de(mt,et,yt)),I[We+228>>2]=je;break i}A=u>>>13&7,A||(A=l[r+24>>2]>>>10&7);e:{s:{if((A|0)==5){A=l[r+24>>2]&8?5:1;break s}if((A|0)!=4||(pn(M+24|0,mt,et),A=4,l[M+28>>2]==3)||(fn(M+360|0,mt,et),l[M+364>>2]==3))break s;A=mt+(l[Pe>>2]<<3)|0,X=I[A+572>>2];n:{a:switch(u=l[A+576>>2],u|0){case 0:case 3:break n;default:break a}if($t=I[A+572>>2],!((u|0)!=1|$t!=$t)){if(h=Be,X<m(0))break n;break e}if(h=Be,hs&!(X<m(0))|((u|0)!=2|$t!=$t))break e}X=I[(mt+(l[Fs>>2]<<2)|0)+516>>2],h=W,$t=I[mt+224>>2],$t==$t&&(h=m(m(de(mt,et,yt)+we(mt,et,yt))+m(tr?X*$t:X/$t))),I[M+360>>2]=h,We=M,je=m(X+m(de(mt,_t,yt)+we(mt,_t,yt))),I[We+24>>2]=je,l[M+356>>2]=1,l[M+352>>2]=1,Un(mt,_t,pe,yt,M+356|0,M+24|0),Un(mt,et,De,yt,M+352|0,M+360|0),X=I[M+360>>2],$t=I[M+24>>2],u=_t>>>0>1,h=u?X:$t,X=u?$t:X,u=(jr|0)!=0&(l[r+24>>2]&896)!=512,un(mt,X,h,Gi,!(u&tr|X!=X),(!u|tr)&h==h,yt,Ve,1,2,K,tt,dt,q),h=Be;break e}h=I[(mt+(l[Pe>>2]<<2)|0)+516>>2],X=de(mt,et,yt),$t=we(mt,et,yt),pn(M+24|0,mt,et),X=m(ot-m(h+m(X+$t)));s:{if(l[M+28>>2]!=3||(fn(M+360|0,mt,et),l[M+364>>2]!=3))break s;h=m(X*m(.5)),h=m(Be+(je=m(0),Wn=ce(h,m(0)),We=h!=h,We?je:Wn));break e}if(fn(M+24|0,mt,et),h=Be,l[M+28>>2]==3)break e;if(pn(M+24|0,mt,et),l[M+28>>2]==3){h=m(Be+(je=m(0),Wn=ce(X,m(0)),We=X!=X,We?je:Wn));break e}s:switch(A-1|0){case 1:h=m(Be+m(X*m(.5)));break e;case 0:break e;default:break s}h=m(Be+X)}u=mt+(l[ri>>2]<<2)|0,I[u+228>>2]=h+m(ds+I[u+228>>2])}if(at=at+1|0,(at|0)==(z|0))break}h=m((Qi?Bh:m(0))+W),u=Gs!=Gs,a=m(Ba+a);i:{if(!(u|a!=a)){Gs=ce(Gs,a);break i}Gs=u?a:Gs}if(ds=m(ds+h),u=Qi+1|0,at=z,!(Vr>>>0>z>>>0))break}i:{if(!P||!jr&&!Pp(r))break i;ne=m(0);e:{s:{if(De!=De)break s;a=m(De-ds);n:switch((l[r+24>>2]>>>7&7)-2|0){case 0:Be=m(Be+m(a*m(.5)));break s;case 2:if(!(De>ds))break s;ne=m(a/m(u>>>0));break s;case 5:if(De>ds){if(Be=m(Be+m(a/m(u<<1>>>0))),u>>>0<2)break s;ne=m(a/m(u>>>0));break e}Be=m(Be+m(a*m(.5)));break s;case 4:if(!(De>ds)|u>>>0<2)break s;ne=m(a/m(Qi>>>0));break e;case 1:break n;default:break s}Be=m(Be+a)}if(!u)break i}for(Ot=0,u=0,A=0;;){if(X=m(0),h=m(0),a=m(0),W=m(0),z=u,Vr>>>0>u>>>0){e:{for(;;){if(A=l[r+556>>2],l[r+560>>2]-A>>2>>>0<=z>>>0)break r;at=l[A+(z<<2)>>2],mt=l[at+24>>2];s:{if(mt&4194304|(mt&196608)==131072)break s;if(A=z,l[at+548>>2]!=(Ot|0))break e;a=I[(at+(l[Pe>>2]<<2)|0)+516>>2];n:{if(!(a>=m(0)))break n;if(A=h!=h,a=m(a+m(de(at,et,yt)+we(at,et,yt))),!(A|a!=a)){h=ce(h,a);break n}h=A?a:h}if(A=mt>>>13&7,A||(A=l[r+24>>2]>>>10&7),!(At[r+24|0]&8)|(A|0)!=5)break s;a=tl(at),ot=de(at,0,yt),a=m(a+ot),ot=m(m(I[at+520>>2]+m(de(at,0,yt)+we(at,0,yt)))-a),A=h!=h,at=W!=W;n:{if(!(at|a!=a)){W=ce(W,a);break n}W=at?a:W}at=X!=X;n:{if(!(at|ot!=ot)){X=ce(X,ot);break n}X=at?ot:X}if(a=m(W+X),!(A|a!=a)){h=ce(h,a);break s}h=A?a:h}if(z=z+1|0,(Vr|0)==(z|0))break}A=Vr}a=h}if(ot=m(Be+(Ot?Bh:m(0))),h=m(ne+a),Be=m(ot+h),u>>>0<A>>>0)for($t=m(ot+W);;){if(z=l[r+556>>2],l[r+560>>2]-z>>2>>>0<=u>>>0)break r;at=l[z+(u<<2)>>2],z=l[at+24>>2];e:{if(z&4194304|(z&196608)==131072)break e;z=z>>>13&7,z||(z=l[r+24>>2]>>>10&7);s:{n:switch(z-1|0){case 4:if(At[r+24|0]&8)break s;case 0:a=de(at,et,yt),I[(at+(l[ri>>2]<<2)|0)+228>>2]=ot+a;break e;case 2:a=we(at,et,yt),z=at+228|0,I[z+(l[ri>>2]<<2)>>2]=m(Be-a)-I[(z+(l[Pe>>2]<<2)|0)+288>>2];break e;case 1:z=at+228|0,I[z+(l[ri>>2]<<2)>>2]=ot+m(m(h-I[(z+(l[Pe>>2]<<2)|0)+288>>2])*m(.5));break e;case 3:break n;default:break e}a=de(at,et,yt),I[(at+(l[ri>>2]<<2)|0)+228>>2]=ot+a,mt=at+(l[Pe>>2]<<3)|0,a=I[mt+572>>2];n:{a:switch(z=l[mt+576>>2],z|0){case 0:case 3:break n;default:break a}if(W=I[mt+572>>2],!((z|0)!=1|W!=W)){if(a<m(0))break n;break e}if(hs&!(a<m(0))|((z|0)!=2|W!=W))break e}n:{if(_t>>>0>=2){X=h,a=I[at+516>>2],W=m(a+m(de(at,_t,yt)+we(at,_t,yt)));break n}X=m(I[at+520>>2]+m(de(at,et,yt)+we(at,et,yt))),a=I[at+516>>2],W=h}n:{a:{if(!(W!=W|a!=a)){if(m(Ge(m(W-a)))<m(9999999747378752e-20))break a;break n}if(W==W|a==a)break n}if(a=I[at+520>>2],z=a!=a,!(z|X!=X)){if(!(m(Ge(m(X-a)))<m(9999999747378752e-20)))break n;break e}if(X==X)break n;if(z)break e}un(at,W,X,Gi,1,1,yt,Ve,1,3,K,tt,dt,q);break e}We=at,je=m(m($t-tl(at))+Os(at,0,De)),I[We+232>>2]=je}if(u=u+1|0,(A|0)==(u|0))break}if(z=(Ot|0)!=(Qi|0),Ot=Ot+1|0,u=A,!z)break}}mt=r+516|0,a=He(r,2,Fh,k),u=a!=a,h=m(m(Ie(r,2,k)+fe(r,2))+m(xe(r,2,k)+Se(r,2)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[mt>>2]=a,a=He(r,0,Uh,S),u=a!=a,h=m(m(Ie(r,0,k)+fe(r,0))+m(xe(r,0,k)+Se(r,0)));i:{if(!(u|h!=h)){a=ce(a,h);break i}a=u?h:a}I[r+520>>2]=a;i:{e:{s:{if(cs&&(u=l[r+24>>2]>>>20&3,(u|0)==2|(cs|0)!=2))break s;if(a=He(r,_t,Gs,Us),u=a!=a,h=m(m(Ie(r,_t,k)+fe(r,_t))+m(xe(r,_t,k)+Se(r,_t))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if((cs|0)!=2|(u|0)!=2)break i;h=m(Wr+pe),u=h!=h,a=He(r,_t,Gs,Us);s:{if(!(u|a!=a)){a=xh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Wr!=Wr)){a=ce(a,Wr);break e}a=u?Wr:a}I[mt+(l[Fs>>2]<<2)>>2]=a}i:{e:{s:{if(Ht&&(A=(Ht|0)!=2,u=l[r+24>>2]>>>20&3,A|(u|0)==2))break s;if(a=He(r,et,m(Ji+ds),Ua),u=a!=a,h=m(m(Ie(r,et,k)+fe(r,et))+m(xe(r,et,k)+Se(r,et))),!(u|h!=h)){a=ce(a,h);break e}a=u?h:a;break e}if(A|(u|0)!=2)break i;h=m(Ji+De),u=h!=h,a=He(r,et,m(Ji+ds),Ua);s:{if(!(u|a!=a)){a=xh(h,a);break s}a=u?a:h}if(u=a!=a,!(u|Ji!=Ji)){a=ce(a,Ji);break e}a=u?Ji:a}I[mt+(l[Pe>>2]<<2)>>2]=a}i:{if(!P)break i;if((l[r+24>>2]&786432)==524288)for(A=Vr>>>0<=1?1:Vr,P=l[r+556>>2],at=l[r+560>>2]-P>>2,u=0;z=0,z=u>>>0<at>>>0?l[P+(u<<2)>>2]:z,(l[z+24>>2]&196608)!=131072&&(z=z+228|0,Ot=z+(l[ri>>2]<<2)|0,Zt=l[Pe>>2]<<2,I[Ot>>2]=m(I[Zt+mt>>2]-I[Ot>>2])-I[(z+Zt|0)+288>>2]),u=u+1|0,(A|0)!=(u|0););if(A=l[r+556>>2],P=l[r+560>>2],(A|0)!=(P|0))for(Ot=((_t>>>0>1?cs:y)|0)!=0;;){y=l[A>>2];e:{if((l[y+24>>2]&4390912)!=131072)break e;W=yt,pe=Ve,At[l[r+568>>2]+12|0]&2&&(pe=I[r+520>>2],W=I[r+516>>2]),u=l[r+24>>2]>>>2&3;s:{n:{if((Gi|0)==2){at=0,z=3;a:switch(u-2|0){case 0:break s;case 1:break a;default:break n}z=2;break s}if(at=0,u>>>0<=1)break n;z=u;break s}z=u,at=$s}S=m(de(y,2,W)+we(y,2,W)),k=de(y,0,W),X=we(y,0,W),a=I[y+572>>2];s:{n:{a:switch(u=l[y+576>>2],u|0){case 0:case 3:break n;default:break a}h=I[y+572>>2];a:{if(!((u|0)!=1|h!=h)){if(h=a,!(a<m(0)))break a;break n}o:{if(!((u|0)!=2|h!=h)){if(W!=W|a<m(0))break n;break o}h=m(zt);l:switch(u-1|0){case 1:break o;case 0:break l;default:break a}h=a;break a}h=m(m(W*a)*m(.009999999776482582))}h=m(S+h);break s}if(h=m(zt),!nr(y,2)||!rl(y,2))break s;if(a=He(y,2,m(m(I[r+516>>2]-m(fe(r,2)+Se(r,2)))-m(Os(y,2,W)+$a(y,2,W))),W),u=a!=a,h=m(m(Ie(y,2,W)+fe(y,2))+m(xe(y,2,W)+Se(y,2))),!(u|h!=h)){h=ce(a,h);break s}h=u?h:a}X=m(k+X);s:{n:{a:{o:{l:{c:{h:{Zt=h!=h,k=I[y+580>>2];f:{d:{p:switch(u=l[y+584>>2],u|0){case 0:case 3:break d;default:break p}a=I[y+580>>2];p:{if(!((u|0)!=1|a!=a)){if(a=k,!(a<m(0)))break p;break d}v:{if(!((u|0)!=2|a!=a)){if(pe!=pe|k<m(0))break d;break v}a=m(zt);y:switch(u-1|0){case 1:break v;case 0:break y;default:break p}a=k;break p}a=m(m(pe*k)*m(.009999999776482582))}a=m(X+a);break f}d:{if(nr(y,0)&&rl(y,0))break d;if(a=m(zt),h==h)break h;break a}if(a=He(y,0,m(m(I[r+520>>2]-m(fe(r,0)+Se(r,0)))-m(Os(y,0,pe)+$a(y,0,pe))),pe),u=a!=a,k=m(m(Ie(y,0,W)+fe(y,0))+m(xe(y,0,W)+Se(y,0))),!(u|k!=k)){a=ce(a,k);break f}a=u?k:a}if((Zt|0)==(a!=a|0)||(ot=I[y+224>>2],ot!=ot))break l;if(h!=h){h=m(m(m(a-X)*ot)+S);break l}if(a==a)break l;break c}if(ot=I[y+224>>2],ot!=ot)break o}a=m(X+m(m(h-S)/ot))}if(h!=h)break a;if(a==a)break s}u=0;break n}u=1}Zt=W>m(0),Qi=u&Ot&z>>>0<2,h=Qi&&Zt?W:h,u=u^1,un(y,h,a,Gi,Qi&&Zt?2:u,a==a,h,a,0,6,K,tt,dt,q),h=m(I[y+516>>2]+i2(y,2,W)),a=m(I[y+520>>2]+i2(y,0,W))}un(y,h,a,Gi,1,1,h,a,1,1,K,tt,dt,q);s:{n:{a:{if(!rl(y,z)||nr(y,z))break a;u=l[(z<<2)+4320>>2]<<2,a=z>>>0<2?pe:W,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,z))-we(y,z,a))-$a(y,z,a));break n}if(!(nr(y,z)|(l[r+24>>2]&112)!=16)){u=l[(z<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break n}if(!(nr(y,z)|(l[r+24>>2]&112)!=32)){u=l[(z<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break n}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,z))break s;a=I[mt+(l[(z<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,z,a)+fe(r,z))+de(y,z,a))}I[(y+(l[(z<<2)+4288>>2]<<2)|0)+228>>2]=a}s:{n:{if(!rl(y,at)||nr(y,at))break n;u=l[(at<<2)+4320>>2]<<2,a=z>>>0<2?W:pe,a=m(m(m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])-Se(r,at))-we(y,at,a))-$a(y,at,a));break s}n:{if(nr(y,at)||(u=l[y+24>>2]>>>13&7,u||(u=l[r+24>>2]>>>10&7),(u|0)!=2))break n;u=l[(at<<2)+4320>>2]<<2,a=m(m(I[u+mt>>2]-I[(u+y|0)+516>>2])*m(.5));break s}n:{if(nr(y,at))break n;z=l[y+24>>2]>>>13&7,u=l[r+24>>2],z=z||u>>>10&7;a:{if((z|0)==5){if((u&786432)==524288)break a;break n}if(((z|0)==3|0)==((u&786432)==524288|0))break n}u=l[(at<<2)+4320>>2]<<2,a=m(I[u+mt>>2]-I[(u+y|0)+516>>2]);break s}if(!(At[l[r+568>>2]+12|0]&2)||!nr(y,at))break e;a=I[mt+(l[(at<<2)+4320>>2]<<2)>>2],a=m(m(Os(y,at,a)+fe(r,at))+de(y,at,a))}I[(y+(l[(at<<2)+4288>>2]<<2)|0)+228>>2]=a}if(A=A+4|0,(P|0)==(A|0))break}if(!((et|_t)&1))break i;for(A=et&1,P=_t&1,K=Vr>>>0<=1?1:Vr,tt=(et<<2)+4304|0,dt=(_t<<2)+4304|0,q=l[r+556>>2],et=l[r+560>>2]-q>>2,r=0;;){if((r|0)==(et|0))break r;u=l[q+(r<<2)>>2];e:{if(At[u+26|0]&64||(P&&(y=u+228|0,z=l[Fs>>2]<<2,I[y+(l[dt>>2]<<2)>>2]=m(I[z+mt>>2]-I[(y+z|0)+288>>2])-I[y+(l[_r>>2]<<2)>>2]),!A))break e;u=u+228|0,y=l[Pe>>2]<<2,I[u+(l[tt>>2]<<2)>>2]=m(I[y+mt>>2]-I[(u+y|0)+288>>2])-I[u+(l[ri>>2]<<2)>>2]}if(r=r+1|0,(K|0)==(r|0))break}}if(!Pi)break t;gi(Pi);break t}Ds(),he()}Et=M+384|0}function vp(){var r=0,a=0;Fn(7032,7033,7034,0,4352,17,4355,0,4355,0,2529,4357,18),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7032,2922,6,4368,4392,19,r|0,1),Fn(7036,7037,7038,7032,4352,20,4352,21,4352,22,2001,4357,23),r=ht(4),l[r>>2]=24,wt(7036,2359,2,4400,4408,25,r|0,0),os(7032,1398,2,4412,4420,26,27),os(7032,3027,3,4500,4512,28,29),Fn(7056,7057,7058,0,4352,30,4355,0,4355,0,2545,4357,31),r=ht(8),l[r>>2]=8,l[r+4>>2]=1,wt(7056,3293,2,4520,4408,32,r|0,1),Fn(7059,7060,7061,7056,4352,33,4352,34,4352,35,2024,4357,36),r=ht(4),l[r>>2]=37,wt(7059,2359,2,4528,4408,38,r|0,0),os(7056,1398,2,4536,4420,39,40),os(7056,3027,3,4500,4512,28,41),Fn(7062,7063,7064,0,4352,42,4355,0,4355,0,2861,4357,43),pp(7062,1,4584,4352,44,45),os(7062,2915,1,4584,4352,44,45),os(7062,1129,2,4588,4408,46,47),r=ht(8),l[r+4>>2]=0,l[r>>2]=48,wt(7062,3234,4,4608,4624,49,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=50,wt(7062,1981,3,4632,4644,51,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=52,wt(7062,1952,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=54,wt(7062,3389,3,4672,4664,55,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=56,wt(7062,1800,3,4652,4664,53,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=57,wt(7062,3264,3,4684,4512,58,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=59,wt(7062,1926,2,4696,4420,60,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=61,wt(7062,3399,2,4704,4420,62,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=63,wt(7062,1785,2,4696,4420,60,r|0,0),Th(7065,1271,4712,64,4357,65),Vn(1732,0),Vn(1612,8),Vn(2145,16),Vn(2455,24),Vn(2561,32),Vn(1618,40),Eh(7065),Th(7035,2898,4712,66,4357,67),zp(2561,0),zp(1618,8),Eh(7035),Th(7066,2909,4712,68,4357,69),r=ht(4),l[r>>2]=8,a=ht(4),l[a>>2]=8,Qo(7066,2903,7098,4714,70,r|0,7098,4718,71,a|0),r=ht(4),l[r>>2]=0,a=ht(4),l[a>>2]=0,Qo(7066,1607,7091,4420,72,r|0,7091,4664,73,a|0),Eh(7066),Fn(7067,7068,7069,0,4352,74,4355,0,4355,0,3022,4357,75),pp(7067,1,4724,4352,76,77),os(7067,1593,1,4724,4352,76,77),os(7067,2851,2,4728,4420,78,79),os(7067,1129,2,4736,4408,80,81),r=ht(8),l[r+4>>2]=0,l[r>>2]=82,wt(7067,1753,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=84,wt(7067,3005,3,4744,4664,85,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=86,wt(7067,2930,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=88,wt(7067,2335,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=90,wt(7067,1485,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=91,wt(7067,1356,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=92,wt(7067,1818,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=93,wt(7067,2872,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=94,wt(7067,2379,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=95,wt(7067,2164,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=96,wt(7067,1320,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=97,wt(7067,2413,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=98,wt(7067,1504,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=99,wt(7067,2236,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=100,wt(7067,1220,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=101,wt(7067,1137,3,4756,4664,87,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=102,wt(7067,1159,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=104,wt(7067,1846,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=105,wt(7067,1465,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=106,wt(7067,2219,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=107,wt(7067,1196,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=108,wt(7067,2501,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=109,wt(7067,2591,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=110,wt(7067,1540,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=111,wt(7067,2250,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=112,wt(7067,1651,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=113,wt(7067,1428,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=114,wt(7067,2205,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=115,wt(7067,2609,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=116,wt(7067,1556,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=117,wt(7067,1671,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=118,wt(7067,1445,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=119,wt(7067,2567,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=120,wt(7067,1521,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=121,wt(7067,1625,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=122,wt(7067,1408,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=123,wt(7067,2305,3,4792,4718,103,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=124,wt(7067,2093,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=125,wt(7067,2719,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=126,wt(7067,1575,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=127,wt(7067,2188,4,4768,4784,89,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=128,wt(7067,2946,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=130,wt(7067,2347,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=132,wt(7067,1372,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=133,wt(7067,1832,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=134,wt(7067,2885,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=135,wt(7067,2396,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=136,wt(7067,2176,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=137,wt(7067,1338,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=138,wt(7067,2423,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=139,wt(7067,1859,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=141,wt(7067,1208,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=143,wt(7067,2515,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=144,wt(7067,2600,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=145,wt(7067,1661,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=146,wt(7067,2621,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=147,wt(7067,1684,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=148,wt(7067,2579,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=149,wt(7067,1638,2,4824,4420,140,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=150,wt(7067,2320,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=151,wt(7067,2103,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=153,wt(7067,1232,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=154,wt(7067,1148,2,4804,4420,129,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=155,wt(7067,2730,3,4812,4512,131,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=156,wt(7067,2195,3,4860,4872,157,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=158,wt(7067,3034,4,4880,4624,159,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=160,wt(7067,3055,3,4896,4664,161,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=162,wt(7067,1293,2,4908,4420,163,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=164,wt(7067,1388,2,4916,4420,165,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=166,wt(7067,3046,3,4924,4512,167,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=168,wt(7067,2962,2,4936,4420,169,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=170,wt(7067,2982,3,4944,4664,171,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=172,wt(7067,3357,3,4956,4664,173,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=174,wt(7067,3355,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=175,wt(7067,3374,3,4968,4664,176,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=177,wt(7067,3372,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=178,wt(7067,1119,2,4736,4408,83,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=179,wt(7067,1111,2,4980,4420,180,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=181,wt(7067,1244,5,4992,5012,182,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=183,wt(7067,1737,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=184,wt(7067,1715,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=185,wt(7067,2149,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=186,wt(7067,2462,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=187,wt(7067,2633,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=188,wt(7067,1697,2,4832,4714,142,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=189,wt(7067,1260,2,5020,4420,190,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=191,wt(7067,2433,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=192,wt(7067,2113,3,4840,4852,152,r|0,0),r=ht(8),l[r+4>>2]=0,l[r>>2]=193,wt(7067,2741,3,4840,4852,152,r|0,0)}function IE(r,a,h,u,y,A){r=r|0,a=+a,h=h|0,u=u|0,y=y|0,A=A|0;var k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0,at=0,ot=0,mt=0,yt=0,_t=0,Ot=0,$t=0;q=Et-560|0,Et=q,l[q+44>>2]=0,pi(+a),k=te(1)|0,te(0)|0;t:{if((k|0)<0){at=1,Ot=1177,a=-a,pi(+a),k=te(1)|0,te(0)|0;break t}if(y&2048){at=1,Ot=1180;break t}at=y&1,Ot=at?1183:1178,$t=!at}t:{if((k&2146435072)==2146435072){k=at+3|0,mi(r,32,h,k,y&-65537),hi(r,Ot,at),u=A&32,hi(r,a!=a?u?2451:3459:u?2868:3463,3),mi(r,32,h,k,y^8192),et=(h|0)<(k|0)?k:h;break t}mt=q+16|0;r:{i:{e:{if(a=$p(a,q+44|0),a=a+a,a!=0){if(k=l[q+44>>2],l[q+44>>2]=k-1,yt=A|32,(yt|0)!=97)break e;break r}if(yt=A|32,(yt|0)==97)break r;tt=l[q+44>>2],dt=(u|0)<0?6:u;break i}tt=k-29|0,l[q+44>>2]=tt,a=a*268435456,dt=(u|0)<0?6:u}for(z=(q+48|0)+((tt|0)>=0?288:0)|0,S=z;a<4294967296&a>=0?u=~~a>>>0:u=0,l[S>>2]=u,S=S+4|0,a=(a-+(u>>>0))*1e9,a!=0;);i:{if((tt|0)<=0){u=tt,k=S,P=z;break i}for(P=z,u=tt;;){M=(u|0)>=29?29:u,k=S-4|0;e:{if(P>>>0>k>>>0)break e;for(u=0;K=l[k>>2],_t=u,u=M&31,(M&63)>>>0>=32?(et=K<<u,u=0):(et=(1<<u)-1&K>>>32-u,u=K<<u),_t=_t+u|0,K=et+W|0,u=kp(_t,u>>>0>_t>>>0?K+1|0:K,1e9),K=Ih(u,Fi,-1e9,0)+_t|0,l[k>>2]=K,k=k-4|0,P>>>0<=k>>>0;);if(!u)break e;P=P-4|0,l[P>>2]=u}for(;k=S,P>>>0<k>>>0&&(S=k-4|0,!l[S>>2]););if(u=l[q+44>>2]-M|0,l[q+44>>2]=u,S=k,!((u|0)>0))break}}if((u|0)<0)for(ot=((dt+25>>>0)/9|0)+1|0,W=(yt|0)==102;;){u=0-u|0,et=(u|0)>=9?9:u;i:{if(k>>>0<=P>>>0){S=l[P>>2];break i}for(M=1e9>>>et|0,K=-1<<et^-1,u=0,S=P;_t=u,u=l[S>>2],l[S>>2]=_t+(u>>>et|0),u=Ue(M,u&K),S=S+4|0,S>>>0<k>>>0;);if(S=l[P>>2],!u)break i;l[k>>2]=u,k=k+4|0}if(u=et+l[q+44>>2]|0,l[q+44>>2]=u,P=(!S<<2)+P|0,S=W?z:P,k=k-S>>2>(ot|0)?S+(ot<<2)|0:k,!((u|0)<0))break}u=0;i:{if(k>>>0<=P>>>0||(u=Ue(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10))break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}if(S=(dt-((yt|0)!=102?u:0)|0)-((yt|0)==103&(dt|0)!=0)|0,(S|0)<(Ue(k-z>>2,9)-9|0)){if(M=S+9216|0,K=(M|0)/9|0,tt=((((tt|0)<0?4:292)+q|0)+(K<<2)|0)-4048|0,S=10,et=M+Ue(K,-9)|0,(et|0)<=7)for(;S=Ue(S,10),et=et+1|0,(et|0)!=8;);M=l[tt>>2],ot=(M>>>0)/(S>>>0)|0,W=Ue(ot,S),K=tt+4|0;i:{if((M|0)==(W|0)&(K|0)==(k|0))break i;M=M-W|0;e:{if(!(ot&1)&&(a=9007199254740992,!(pt[tt-4|0]&1)|((S|0)!=1e9|P>>>0>=tt>>>0)))break e;a=9007199254740994}if(X=(k|0)==(K|0)?1:1.5,K=S>>>1|0,X=K>>>0>M>>>0?.5:(K|0)==(M|0)?X:1.5,At[Ot|0]!=45|$t||(X=-X,a=-a),l[tt>>2]=W,a+X==a)break i;if(u=S+W|0,l[tt>>2]=u,u>>>0>=1e9)for(;l[tt>>2]=0,tt=tt-4|0,tt>>>0<P>>>0&&(P=P-4|0,l[P>>2]=0),u=l[tt>>2]+1|0,l[tt>>2]=u,u>>>0>999999999;);if(u=Ue(z-P>>2,9),S=10,K=l[P>>2],K>>>0<10)break i;for(;u=u+1|0,S=Ue(S,10),K>>>0>=S>>>0;);}S=tt+4|0,k=k>>>0>S>>>0?S:k}for(;K=k,M=k>>>0<=P>>>0,!M&&(k=K-4|0,!l[k>>2]););i:{if((yt|0)!=103){tt=y&8;break i}if(S=dt||1,k=(S|0)>(u|0)&(u|0)>-5,dt=(k?u^-1:-1)+S|0,A=(k?-1:-2)+A|0,tt=y&8,tt)break i;k=-9;e:{if(M||(tt=l[K-4>>2],!tt)||(et=10,k=0,(tt>>>0)%10|0))break e;for(;S=k,k=k+1|0,et=Ue(et,10),!((tt>>>0)%(et>>>0)|0););k=S^-1}if(S=Ue(K-z>>2,9),(A&-33)==70){tt=0,k=(k+S|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k;break i}tt=0,k=((u+S|0)+k|0)-9|0,k=(k|0)>0?k:0,dt=(k|0)>(dt|0)?dt:k}if(et=-1,M=tt|dt,((M?2147483645:2147483646)|0)<(dt|0))break t;W=(((M|0)!=0)+dt|0)+1|0,S=A&-33;i:{if((S|0)==70){if((W^2147483647)<(u|0))break t;k=(u|0)>0?u:0;break i}if(k=u>>31,k=Bn((k^u)-k|0,0,mt),(mt-k|0)<=1)for(;k=k-1|0,pt[k|0]=48,(mt-k|0)<2;);if(ot=k-2|0,pt[ot|0]=A,pt[k-1|0]=(u|0)<0?45:43,k=mt-ot|0,(k|0)>(W^2147483647))break t}if(u=k+W|0,(u|0)>(at^2147483647))break t;W=u+at|0,mi(r,32,h,W,y),hi(r,Ot,at),mi(r,48,h,W,y^65536);i:{e:{s:{if((S|0)==70){for(A=q+16|0,u=A|8,tt=A|9,S=P>>>0>z>>>0?z:P,P=S;;){k=Bn(l[P>>2],0,tt);n:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break n;for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);break n}if((k|0)!=(tt|0))break n;pt[q+24|0]=48,k=u}if(hi(r,k,tt-k|0),P=P+4|0,!(z>>>0>=P>>>0))break}if(M&&hi(r,4275,1),(dt|0)<=0|P>>>0>=K>>>0)break s;for(;;){if(k=Bn(l[P>>2],0,tt),k>>>0>q+16>>>0)for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);if(hi(r,k,(dt|0)>=9?9:dt),k=dt-9|0,P=P+4|0,K>>>0<=P>>>0)break e;if(u=(dt|0)>9,dt=k,!u)break}break e}n:{if((dt|0)<0)break n;for(z=P>>>0<K>>>0?K:P+4|0,A=q+16|0,u=A|8,K=A|9,S=P;;){k=Bn(l[S>>2],0,K),(K|0)==(k|0)&&(pt[q+24|0]=48,k=u);a:{if((S|0)!=(P|0)){if(q+16>>>0>=k>>>0)break a;for(;k=k-1|0,pt[k|0]=48,q+16>>>0<k>>>0;);break a}if(hi(r,k,1),k=k+1|0,!(tt|dt))break a;hi(r,4275,1)}if(A=K-k|0,hi(r,k,(A|0)>(dt|0)?dt:A),dt=dt-A|0,S=S+4|0,z>>>0<=S>>>0)break n;if(!((dt|0)>=0))break}}mi(r,48,dt+18|0,18,0),hi(r,ot,mt-ot|0);break i}k=dt}mi(r,48,k+9|0,9,0)}mi(r,32,h,W,y^8192),et=(h|0)<(W|0)?W:h;break t}tt=(A<<26>>31&9)+Ot|0;r:{if(u>>>0>11)break r;for(k=12-u|0,X=16;X=X*16,k=k-1|0,!!k;);if(At[tt|0]==45){a=-(X+(-a-X));break r}a=a+X-X}for(z=at|2,P=A&32,S=l[q+44>>2],k=S>>31,k=Bn((k^S)-k|0,0,mt),(mt|0)==(k|0)&&(pt[q+15|0]=48,k=q+15|0),dt=k-2|0,pt[dt|0]=A+15,pt[k-1|0]=(S|0)<0?45:43,k=y&8,S=q+16|0;A=S,Ge(a)<2147483648?K=~~a:K=-2147483648,pt[S|0]=P|At[K+5504|0],a=(a-+(K|0))*16,S=A+1|0,!(k|(u|0)>0)&a==0|(S-(q+16|0)|0)!=1||(pt[A+1|0]=46,S=A+2|0),a!=0;);if(et=-1,k=mt-dt|0,A=k+z|0,(2147483645-A|0)<(u|0))break t;r:{i:{if(!u||(P=S-(q+16|0)|0,(P-2|0)>=(u|0)))break i;u=u+2|0;break r}P=S-(q+16|0)|0,u=P}A=u+A|0,mi(r,32,h,A,y),hi(r,tt,z),mi(r,48,h,A,y^65536),hi(r,q+16|0,P),mi(r,48,u-P|0,0,0),hi(r,dt,k),mi(r,32,h,A,y^8192),et=(h|0)<(A|0)?A:h}return Et=q+560|0,et|0}function yp(r,a,h,u,y,A,k){var S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0,at=0,ot=0,mt=0,yt=0,_t=0,Ot=0,$t=0,Ht=0,Zt=0;K=Et-80|0,Et=K,l[K+76>>2]=a,$t=K+55|0,ot=K+56|0;t:{r:{i:{e:{s:for(;;){if(tt=a,(W^2147483647)<(S|0))break e;W=S+W|0;n:{a:{o:{if(S=tt,P=At[S|0],P)for(;;){l:{a=P&255;c:{if(!a){a=S;break c}if((a|0)!=37)break l;for(P=S;;){if(At[P+1|0]!=37){a=P;break c}if(S=S+1|0,dt=At[P+2|0],a=P+2|0,P=a,(dt|0)!=37)break}}if(S=S-tt|0,Ot=W^2147483647,(S|0)>(Ot|0))break e;if(r&&hi(r,tt,S),S)continue s;l[K+76>>2]=a,S=a+1|0,X=-1,P=pt[a+1|0],!nl(P)|At[a+2|0]!=36||(X=P-48|0,mt=1,S=a+3|0),l[K+76>>2]=S,M=0,P=pt[S|0],a=P-32|0;c:{if(a>>>0>31){dt=S;break c}if(dt=S,a=1<<a,!(a&75913))break c;for(;;){if(dt=S+1|0,l[K+76>>2]=dt,M=a|M,P=pt[S+1|0],a=P-32|0,a>>>0>=32)break c;if(S=dt,a=1<<a,!(a&75913))break}}c:{if((P|0)==42){a=pt[dt+1|0];h:{if(!(!nl(a)|At[dt+2|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,P=dt+3|0,mt=1,z=l[((pt[dt+1|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(P=dt+1|0,!r){l[K+76>>2]=P,mt=0,z=0;break c}a=l[h>>2],l[h>>2]=a+4,mt=0,z=l[a>>2]}if(l[K+76>>2]=P,(z|0)>=0)break c;z=0-z|0,M=M|8192;break c}if(z=Gp(K+76|0),(z|0)<0)break e;P=l[K+76>>2]}S=0,et=-1;c:{if(At[P|0]!=46){a=P,at=0;break c}if(At[P+1|0]==42){a=pt[P+2|0];h:{if(!(!nl(a)|At[P+3|0]!=36)){l[((a<<2)+y|0)-192>>2]=10,a=P+4|0,et=l[((pt[P+2|0]<<3)+u|0)-384>>2];break h}if(mt)break o;if(a=P+2|0,et=0,!r)break h;P=l[h>>2],l[h>>2]=P+4,et=l[P>>2]}l[K+76>>2]=a,at=(et^-1)>>>31|0;break c}l[K+76>>2]=P+1,et=Gp(K+76|0),a=l[K+76>>2],at=1}for(;;){if(q=S,dt=28,yt=a,S=pt[a|0],S-123>>>0<4294967238)break i;if(a=yt+1|0,S=At[(S+Ue(q,58)|0)+4975|0],!(S-1>>>0<8))break}l[K+76>>2]=a;c:{h:{if((S|0)!=27){if(!S)break i;if((X|0)>=0){l[(X<<2)+y>>2]=S,S=(X<<3)+u|0,P=l[S+4>>2],l[K+64>>2]=l[S>>2],l[K+68>>2]=P;break h}if(!r)break n;_p(K- -64|0,S,h,k);break c}if((X|0)>=0)break i}if(S=0,!r)continue s}P=M&-65537,M=M&8192?P:M,X=0,_t=1167,dt=ot;c:{h:{f:{d:{p:{v:{y:{u:{g:{b:{m:{T:{k:{A:{w:{E:switch(S=pt[yt|0],S=q&&(S&15)==3?S&-33:S,S-88|0){case 11:break c;case 9:case 13:case 14:case 15:break h;case 27:break y;case 12:case 17:break b;case 23:break m;case 0:case 32:break T;case 24:break k;case 22:break A;case 29:break w;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break a;default:break E}E:switch(S-65|0){case 0:case 4:case 5:case 6:break h;case 2:break p;case 1:case 3:break a;default:break E}if((S|0)==83)break v;break a}P=l[K+64>>2],q=l[K+68>>2],S=1167;break g}S=0;A:switch(q&255){case 0:l[l[K+64>>2]>>2]=W;continue s;case 1:l[l[K+64>>2]>>2]=W;continue s;case 2:tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s;case 3:Fr[l[K+64>>2]>>1]=W;continue s;case 4:pt[l[K+64>>2]]=W;continue s;case 6:l[l[K+64>>2]>>2]=W;continue s;case 7:break A;default:continue s}tt=l[K+64>>2],l[tt>>2]=W,l[tt+4>>2]=W>>31;continue s}et=et>>>0<=8?8:et,M=M|8,S=120}if(tt=ot,P=l[K+64>>2],q=l[K+68>>2],P|q)for(Ht=S&32;tt=tt-1|0,pt[tt|0]=Ht|At[(P&15)+5504|0],Zt=!q&P>>>0>15|(q|0)!=0,yt=q,q=q>>>4|0,P=(yt&15)<<28|P>>>4,!!Zt;);if(!(M&8)|!(l[K+64>>2]|l[K+68>>2]))break u;_t=(S>>>4|0)+1167|0,X=2;break u}if(S=ot,tt=l[K+68>>2],q=tt,P=l[K+64>>2],tt|P)for(;S=S-1|0,pt[S|0]=P&7|48,yt=!q&P>>>0>7|(q|0)!=0,tt=q,q=tt>>>3|0,P=(tt&7)<<29|P>>>3,!!yt;);if(tt=S,!(M&8))break u;S=ot-tt|0,et=(S|0)<(et|0)?et:S+1|0;break u}if(P=l[K+64>>2],S=l[K+68>>2],q=S,(S|0)<0){tt=0-(q+((P|0)!=0)|0)|0,q=tt,P=0-P|0,l[K+64>>2]=P,l[K+68>>2]=tt,X=1,S=1167;break g}if(M&2048){X=1,S=1168;break g}X=M&1,S=X?1169:1167}_t=S,tt=Bn(P,q,ot)}if((et|0)<0&&at)break e;if(M=at?M&-65537:M,S=l[K+64>>2],P=l[K+68>>2],!((S|P)!=0|et)){tt=ot,et=0;break a}S=!(S|P)+(ot-tt|0)|0,et=(S|0)<(et|0)?et:S;break a}M=0,at=et>>>0>=2147483647?2147483647:et,q=at,dt=(q|0)!=0;y:{u:{S=l[K+64>>2],tt=S||4277,S=tt;g:{b:{m:{if(!(S&3)|!q)break m;for(;;){if(M=At[S|0],!M)break b;if(q=q-1|0,dt=(q|0)!=0,S=S+1|0,!(S&3))break m;if(!q)break}}if(!dt)break u;m:{if(!(!At[S|0]|q>>>0<4))for(;;){if(dt=l[S>>2],(dt^-1)&dt-16843009&-2139062144)break m;if(S=S+4|0,q=q-4|0,!(q>>>0>3))break}if(!q)break u}dt=0;break g}dt=1}for(;;){if(!dt){M=At[S|0],dt=1;continue}if(!M)break y;if(S=S+1|0,q=q-1|0,!q)break u;dt=0}}S=0}if(S=S?S-tt|0:at,dt=S+tt|0,(et|0)>=0){M=P,et=S;break a}if(M=P,et=S,At[dt|0])break e;break a}if(et){P=l[K+64>>2];break d}S=0,mi(r,32,z,0,M);break f}l[K+12>>2]=0,l[K+8>>2]=l[K+64>>2],P=K+8|0,l[K+64>>2]=P,et=-1}S=0;d:{for(;;){if(tt=l[P>>2],!tt)break d;if(tt=Kp(K+4|0,tt),dt=(tt|0)<0,!(dt|tt>>>0>et-S>>>0)){if(P=P+4|0,S=S+tt|0,et>>>0>S>>>0)continue;break d}break}if(dt)break r}if(dt=61,(S|0)<0)break i;if(mi(r,32,z,S,M),!S){S=0;break f}for(dt=0,P=l[K+64>>2];;){if(tt=l[P>>2],!tt||(tt=Kp(K+4|0,tt),dt=tt+dt|0,dt>>>0>S>>>0))break f;if(hi(r,K+4|0,tt),P=P+4|0,!(S>>>0>dt>>>0))break}}mi(r,32,z,S,M^8192),S=(S|0)<(z|0)?z:S;continue s}if((et|0)<0&&at)break e;if(dt=61,S=Pt[A|0](r,Fe[K+64>>3],z,et,M,S)|0,(S|0)>=0)continue s;break i}pt[K+55|0]=l[K+64>>2],et=1,tt=$t,M=P;break a}P=At[S+1|0],S=S+1|0}if(r)break t;if(!mt)break n;for(S=1;;){if(r=l[(S<<2)+y>>2],r){if(_p((S<<3)+u|0,r,h,k),W=1,S=S+1|0,(S|0)!=10)continue;break t}break}if(W=1,S>>>0>=10)break t;for(;;){if(l[(S<<2)+y>>2])break o;if(S=S+1|0,(S|0)==10)break}break t}dt=28;break i}if(q=dt-tt|0,et=(et|0)>(q|0)?et:q,(et|0)>(X^2147483647))break e;if(dt=61,P=et+X|0,S=(P|0)<(z|0)?z:P,(Ot|0)<(S|0))break i;mi(r,32,S,P,M),hi(r,_t,X),mi(r,48,S,P,M^65536),mi(r,48,et,q,0),hi(r,tt,q),mi(r,32,S,P,M^8192);continue}break}W=0;break t}dt=61}l[1781]=dt}W=-1}return Et=K+80|0,W}function xE(r,a,h,u){r=r|0,a=+a,h=+h,u=u|0;var y=m(0),A=m(0),k=0,S=m(0),P=0,K=m(0),tt=0,dt=m(0),q=0;q=Et+-64|0,Et=q,k=l[r>>2],Bi(q+8|0,0,56),l[1755]=l[1755]+1,Ap(k),S=m(a),A=I[k+572>>2];t:{r:{i:switch(r=l[k+576>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+572>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(S!=S|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*S)*m(.009999999776482582))}dt=m(y+m(de(k,2,S)+we(k,2,S))),tt=1;break t}y=m(0),A=I[k+216>>2];r:{i:{r=l[k+216>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;tt=4336;n:{if((r|0)!=2141891242){if(A==A)break n;tt=4344}switch(y=I[tt>>2],l[tt+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*S)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],dt=m(zt),tt=2,l[P+4>>2]-1|0){case 1:break e;case 0:break r;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}dt=m(m(y*S)*m(.009999999776482582)),tt=2;break t}tt=S==S,dt=S;break t}tt=2,dt=y}K=m(h),A=I[k+580>>2];t:{r:{i:switch(r=l[k+584>>2],r|0){case 0:case 3:break r;default:break i}y=I[k+580>>2];i:{if(!((r|0)!=1|y!=y)){if(y=A,!(y<m(0)))break i;break r}e:{if(!((r|0)!=2|y!=y)){if(K!=K|A<m(0))break r;break e}y=m(zt);s:switch(r-1|0){case 1:break e;case 0:break s;default:break i}y=A;break i}y=m(m(A*K)*m(.009999999776482582))}A=m(y+m(de(k,0,S)+we(k,0,S))),r=1;break t}y=m(0),A=I[k+220>>2];r:{i:{r=l[k+220>>2];e:{s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break r;P=4336;n:{if((r|0)!=2141891242){if(A==A)break n;P=4344}switch(y=I[P>>2],l[P+4>>2]-1|0){case 0:break e;case 1:break s;default:break i}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*K)*m(.009999999776482582))}if(y!=y)break i;y=m(0);e:{if((r|0)==2139156720)break e;if((r|0)==2140081935)break r;P=4336;s:{if((r|0)!=2141891242){if(A==A)break s;P=4344}switch(y=I[P>>2],A=m(zt),r=2,l[P+4>>2]-1|0){case 0:break r;case 1:break e;default:break t}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break r}A=m(m(y*K)*m(.009999999776482582)),r=2;break t}r=K==K,A=K;break t}r=2,A=y}un(k,dt,A,u,tt,r,S,K,1,0,l[k+568>>2],q+8|0,0,l[1755])&&(xp(k,At[k+300|0]&3,S,K,S),Lp(k,+I[l[k+568>>2]+20>>2],0,0)),Et=q- -64|0}function DE(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=0,A=0,k=m(0),S=0,P=0,K=0,tt=m(0);t:{P=l[a>>2],a=l[r>>2];r:{if((l[P+24>>2]^l[a+24>>2])&8388607)break r;tt=I[P+40>>2],y=l[P+40>>2],u=I[a+40>>2];i:{e:{if(h=l[a+40>>2],(h|0)!=2139156720){if(k=m(zt),r=3,(h|0)==2141891242)break i;if((h|0)!=2140081935)break e;k=m(0),r=1;break i}r=2;break i}if(r=0,u!=u)break i;k=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}i:{e:{if((y|0)!=2139156720){if(u=m(zt),h=3,(y|0)==2141891242)break i;if((y|0)!=2140081935)break e;u=m(0),h=1;break i}u=m(0),h=2;break i}if(h=0,tt!=tt)break i;u=(Dt(2,(y&-1073741825)+536870912|0),Bt()),h=y&1073741824?2:1}if((h|0)!=(r|0)|!(!r|k!=k&u!=u|m(Ge(m(k-u)))<m(9999999747378752e-20))||(h=a+44|0,A=P+44|0,l[h>>2]!=l[A>>2]))break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+80|0,A=P+80|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+116|0,A=P+116|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+152|0,A=P+152|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==9)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<8)break r}if(h=a+188|0,A=P+188|0,l[h>>2]!=l[A>>2])break r;r=0;i:{for(;;){if(y=r,r=r+1|0,(r|0)==3)break i;if(S=r<<2,l[S+h>>2]!=l[A+S>>2])break}if(y>>>0<2)break r}for(S=P+200|0,K=a+200|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+208|0,K=a+208|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0))break r;for(S=P+216|0,K=a+216|0,r=0,y=1;;){i:{if(r=r<<2,h=l[r+S>>2],A=l[r+K>>2],!y)break i;if(y=0,r=1,(h|0)==(A|0))continue}break}if((h|0)!=(A|0)||(k=I[P+28>>2],r=k!=k,u=I[a+28>>2],(r|0)==(u==u|0)|!(r|u!=u)&u!=k)||(u=I[a+32>>2],k=I[P+32>>2],(u==u|0)==(k!=k|0)|u==u&u!=k)||(k=I[P+36>>2],r=k!=k,u=I[a+36>>2],(r|0)==(u==u|0)|!r&u!=k))break r;if(r=0,u=I[a+224>>2],u!=u&&(r=1,k=I[P+224>>2],k!=k)||(k=u,u=I[P+224>>2],k==u|u!=u&r))break t}for(Ui(a+24|0,P+24|0,204);;){if(r=At[a+4|0],r&4)break t;if(pt[a+4|0]=r|4,r=l[a+20>>2],r&&Pt[r|0](a),l[a+308>>2]=2143289344,a=l[a+552>>2],!a)break}}}function PE(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0,W=0,z=0,X=0;h=a,a=l[a>>2]+7&-8,l[h>>2]=a+16,M=r,P=l[a>>2],u=l[a+4>>2],r=l[a+12>>2],q=r,k=Et-32|0,Et=k,r=r&2147483647,S=r,y=r-1006698496|0,r=r-1140785152|0,h=l[a+8>>2],a=h;t:{if((y|0)==(r|0)&a>>>0<a>>>0|r>>>0>y>>>0){if(r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h,u=u&268435455,(u|0)==134217728&(P|0)!=0|u>>>0>134217728){r=r+1073741824|0,a=a+1|0,r=a?r:r+1|0;break t}if(r=r+1073741824|0,P|(u|0)!=134217728)break t;u=a&1,a=u+a|0,r=a>>>0<u>>>0?r+1|0:r;break t}if(!(!a&(S|0)==2147418112?!(u|P):S>>>0<2147418112)){r=h,h=q<<4|r>>>28,a=r<<4|u>>>28,r=h&524287|2146959360;break t}if(a=0,r=2146435072,S>>>0>1140785151||(r=0,et=S>>>16|0,et>>>0<15249))break t;a=P,r=u,y=q&65535|65536,S=y,dt=h,A=h,K=et-15233|0;r:{if(K&64){h=a,y=K+-64|0,a=y&31,(y&63)>>>0>=32?(r=h<<a,A=0):(r=(1<<a)-1&h>>>32-a|r<<a,A=h<<a),y=r,a=0,r=0;break r}if(!K)break r;tt=A,A=K&31,(K&63)>>>0>=32?(h=tt<<A,A=0):(h=(1<<A)-1&tt>>>32-A|y<<A,A=tt<<A),y=h,W=A,tt=a,h=64-K|0,A=h&31,(h&63)>>>0>=32?(h=0,a=r>>>A|0):(h=r>>>A|0,a=((1<<A)-1&r)<<32-A|tt>>>A),A=W|a,y=h|y,a=K&31,(K&63)>>>0>=32?(h=tt<<a,a=0):(h=(1<<a)-1&tt>>>32-a|r<<a,a=tt<<a),r=h}l[k+16>>2]=a,l[k+20>>2]=r,l[k+24>>2]=A,l[k+28>>2]=y,a=15361-et|0;r:{if(a&64){u=dt,a=a+-64|0,r=a&31,(a&63)>>>0>=32?(h=0,P=S>>>r|0):(h=S>>>r|0,P=((1<<r)-1&S)<<32-r|u>>>r),u=h,dt=0,S=0;break r}if(!a)break r;y=dt,r=64-a|0,h=r&31,(r&63)>>>0>=32?(r=y<<h,A=0):(r=(1<<h)-1&y>>>32-h|S<<h,A=y<<h),y=P,P=a&31,(a&63)>>>0>=32?(h=0,y=u>>>P|0):(h=u>>>P|0,y=((1<<P)-1&u)<<32-P|y>>>P),P=A|y,u=r|h,y=dt,h=a&31,(a&63)>>>0>=32?(r=0,dt=S>>>h|0):(r=S>>>h|0,dt=((1<<h)-1&S)<<32-h|y>>>h),S=r}if(l[k>>2]=P,l[k+4>>2]=u,l[k+8>>2]=dt,l[k+12>>2]=S,a=l[k+8>>2],r=l[k+12>>2]<<4|a>>>28,a=a<<4,h=l[k>>2],S=l[k+4>>2],a=S>>>28|a,u=S&268435455,h=h|(l[k+16>>2]|l[k+24>>2]|(l[k+20>>2]|l[k+28>>2]))!=0,(u|0)==134217728&(h|0)!=0|u>>>0>134217728){a=a+1|0,r=a?r:r+1|0;break t}if(h|(u|0)!=134217728)break t;h=a,a=a+(a&1)|0,r=h>>>0>a>>>0?r+1|0:r}Et=k+32|0,Dt(0,a|0),Dt(1,q&-2147483648|r),z=M,X=+Ae(),Fe[z>>3]=X}function un(r,a,h,u,y,A,k,S,P,K,tt,dt,q,et){var M=m(0),W=0,z=0,X=0,at=0,ot=m(0),mt=0,yt=0,_t=m(0);t:{if(!(l[r+312>>2]!=(et|0)&&At[r+4|0]&4)&&(at=0,l[r+316>>2]==(u|0)))break t;l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+320>>2]=0,at=1}mt=q+1|0;t:{r:{i:{e:{if(l[r+8>>2]){if(ot=de(r,2,k),_t=we(r,2,k),M=m(de(r,0,k)+we(r,0,k)),q=r+524|0,ot=m(ot+_t),Tp(y,a,A,h,l[r+532>>2],I[q>>2],l[r+536>>2],I[r+528>>2],I[r+540>>2],I[r+544>>2],ot,M,tt))break i;if(z=l[r+320>>2],!z)break e;for(W=r+324|0;;){if(q=W+Ue(X,24)|0,Tp(y,a,A,h,l[q+8>>2],I[q>>2],l[q+12>>2],I[q+4>>2],I[q+16>>2],I[q+20>>2],ot,M,tt))break i;if(X=X+1|0,(z|0)==(X|0))break}break e}if(!P){if(yt=l[r+320>>2],!yt)break e;for(z=r+324|0;;){W=Ue(X,24),q=W+z|0,M=I[q>>2];s:{n:{if(!(M!=M|a!=a)){if(m(Ge(m(M-a)))<m(9999999747378752e-20))break n;break s}if(M==M|a==a)break s}W=z+W|0,M=I[W+4>>2];n:{if(!(M!=M|h!=h)){if(m(Ge(m(M-h)))<m(9999999747378752e-20))break n;break s}if(M==M|h==h)break s}if(l[W+8>>2]!=(y|0))break s;if(l[W+12>>2]==(A|0))break i}if(X=X+1|0,(yt|0)==(X|0))break}break e}q=r+524|0,M=I[q>>2];s:{if(!(M!=M|a!=a)){if(m(Ge(m(M-a)))<m(9999999747378752e-20))break s;break e}if(M==M|a==a)break e}W=l[r+532>>2]==(y|0)&&l[r+536>>2]==(A|0)?q:0,M=I[r+528>>2],q=M!=M,z=h!=h;s:{if(q|z){q=q&z;break s}q=m(Ge(m(M-h)))<m(9999999747378752e-20)}q=q?W:0;break i}mp(r,a,h,u,y,A,k,S,P,tt,dt,mt,et,K),l[r+316>>2]=u;break r}if(!(!q|at)){I[r+516>>2]=I[q+16>>2],I[r+520>>2]=I[q+20>>2],u=(P?12:16)+dt|0,l[u>>2]=l[u>>2]+1;break t}if(mp(r,a,h,u,y,A,k,S,P,tt,dt,mt,et,K),l[r+316>>2]=u,q)break t}q=l[r+320>>2],u=q+1|0,u>>>0>cp[dt+8>>2]&&(l[dt+8>>2]=u),(q|0)==8&&(l[r+320>>2]=0,q=0),P?u=r+524|0:(l[r+320>>2]=q+1,u=(Ue(q,24)+r|0)+324|0),l[u+12>>2]=A,l[u+8>>2]=y,I[u+4>>2]=h,I[u>>2]=a,I[u+16>>2]=I[r+516>>2],I[u+20>>2]=I[r+520>>2],q=0}t:{if(!P||(u=l[r+520>>2],l[r+244>>2]=l[r+516>>2],l[r+248>>2]=u,u=At[r+4|0],y=u|1,pt[r+4|0]=y,!(u&4)))break t;pt[r+4|0]=y&251}return l[r+312>>2]=et,!q|at}function kh(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;S=8;t:{if(r>>>0>4294967239)break t;r:{for(;;){S=S>>>0<=8?8:S,a=l[1751],A=a,y=l[1750],r=r>>>0<=8?8:r+3&-4;i:{if(r>>>0<=127){k=(r>>>3|0)-1|0;break i}if(u=mr(r),k=((r>>>29-u^4)-(u<<2)|0)+110|0,r>>>0<=4095)break i;u=((r>>>30-u^2)-(u<<1)|0)+71|0,k=u>>>0>=63?63:u}if(h=k&31,(k&63)>>>0>=32?(u=0,a=a>>>h|0):(u=a>>>h|0,a=((1<<h)-1&a)<<32-h|y>>>h),a|u){for(;;){y=u;i:{if(a|u){h=u-1|0,P=h+1|0,A=h,h=a-1|0,A=(h|0)!=-1?P:A,u=mr(u^A),u=(u|0)==32?mr(a^h)+32|0:u,h=63-u|0,Fi=0-(u>>>0>63)|0;break i}Fi=0,h=64}A=h,h=A&31,(A&63)>>>0>=32?(u=0,a=y>>>h|0):(u=y>>>h|0,a=((1<<h)-1&y)<<32-h|a>>>h),P=a,k=A+k|0,h=k<<4,a=l[h+5976>>2],A=h+5968|0;i:{if((a|0)!=(A|0)){if(y=Rh(a,S,r),y)break t;y=l[a+4>>2],l[y+8>>2]=l[a+8>>2],l[l[a+8>>2]+4>>2]=y,l[a+8>>2]=A,y=h+5972|0,l[a+4>>2]=l[y>>2],l[y>>2]=a,l[l[a+4>>2]+8>>2]=a,k=k+1|0,a=(u&1)<<31|P>>>1,u=u>>>1|0;break i}K=l[1751],A=k&63,a=A,y=a&31,a>>>0>=32?(a=0,h=-1>>>y|0):(a=-1>>>y|0,h=a|(1<<y)-1<<32-y),h=h&-2,y=A&31,A>>>0>=32?(a=h<<y,h=0):(a=(1<<y)-1&h>>>32-y|a<<y,h=h<<y),tt=h,y=a,A=0-k&63,h=A,a=h&31,h>>>0>=32?(a=-1<<a,h=0):(h=-1<<a,a=h|(1<<a)-1&-1>>>32-a),dt=h&-2,h=A&31,A>>>0>=32?(A=0,a=a>>>h|0):(A=a>>>h|0,a=((1<<h)-1&a)<<32-h|dt>>>h),a=a|tt,Fi=y|A,l[1750]=l[1750]&a,l[1751]=Fi&K,a=P^1}if(!(a|u))break}A=l[1751],y=l[1750]}i:{if(y|A){u=mr(A),h=63-((u|0)==32?mr(y)+32|0:u)|0,a=h<<4,u=l[a+5976>>2];e:{if(!A&y>>>0<1073741824||(k=99,a=a+5968|0,(a|0)==(u|0)))break e;for(;;){if(!k)break e;if(y=Rh(u,S,r),y)break t;if(k=k-1|0,u=l[u+8>>2],(a|0)==(u|0))break}u=a}if(Sh(r+48|0))break i;if(!u||(a=(h<<4)+5968|0,(a|0)==(u|0)))break r;for(;;){if(y=Rh(u,S,r),y)break t;if(u=l[u+8>>2],(a|0)==(u|0))break}break r}if(!Sh(r+48|0))break r}if(y=0,S-1&S)break t;if(!(r>>>0<=4294967239))break}break t}y=0}return y|0}function OE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0;S=Et-80|0,Et=S,r=l[r>>2];t:{r:{if(P=l[a>>2],!l[P+552>>2]){if(l[r+8>>2])break r;a=l[r+556>>2],k=a+(h<<2)|0,u=l[r+560>>2],y=r+564|0,A=l[y>>2];i:{if(u>>>0<A>>>0){if((u|0)==(k|0)){l[k>>2]=P,l[r+560>>2]=k+4;break i}if(h=u,a=u-4|0,u>>>0>a>>>0)for(;l[h>>2]=l[a>>2],h=h+4|0,a=a+4|0,u>>>0>a>>>0;);l[r+560>>2]=h,a=k+4|0,(a|0)!=(u|0)&&(a=u-a|0,Ps(u-(a&-4)|0,k,a)),l[k>>2]=P;break i}if(u=(u-a>>2)+1|0,u>>>0>=1073741824)break t;a=A-a|0,A=a>>1,y=Na(S+32|0,a>>>0>=2147483644?1073741823:u>>>0<A>>>0?A:u,h,y),h=l[y+8>>2];e:{if((h|0)!=l[y+12>>2])break e;if(a=l[y+4>>2],u=l[y>>2],a>>>0>u>>>0){u=((a-u>>2)+1|0)/-2<<2,K=u+a|0,A=a,a=h-a|0,h=Ps(K,A,a)+a|0,l[y+8>>2]=h,l[y+4>>2]=u+l[y+4>>2];break e}a=(h|0)==(u|0)?1:h-u>>1,A=Na(S+56|0,a,a>>>2|0,l[y+16>>2]),u=l[A+8>>2],a=l[y+4>>2],h=l[y+8>>2];s:{if((a|0)==(h|0)){h=u,u=a;break s}for(h=(h-a|0)+u|0;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,(u|0)!=(h|0););a=l[y+8>>2],u=l[y+4>>2]}if(K=l[y>>2],l[y>>2]=l[A>>2],l[A>>2]=K,l[y+4>>2]=l[A+4>>2],l[A+4>>2]=u,l[y+8>>2]=h,l[A+8>>2]=a,tt=l[y+12>>2],l[y+12>>2]=l[A+12>>2],l[A+12>>2]=tt,(a|0)!=(u|0)&&(l[A+8>>2]=((u-a|0)+3&-4)+a),!K)break e;gi(K),h=l[y+8>>2]}if(l[h>>2]=P,l[y+8>>2]=l[y+8>>2]+4,a=l[r+556>>2],h=k-a|0,dt=y,q=Ps(l[y+4>>2]-h|0,a,h),l[dt+4>>2]=q,u=l[r+560>>2]-k|0,k=Ps(l[y+8>>2],k,u),a=l[r+556>>2],l[r+556>>2]=l[y+4>>2],l[y+4>>2]=a,h=l[r+560>>2],l[r+560>>2]=u+k,l[y+8>>2]=h,u=l[r+564>>2],l[r+564>>2]=l[y+12>>2],l[y>>2]=a,l[y+12>>2]=u,(a|0)!=(h|0)&&(l[y+8>>2]=h+((a-h|0)+3&-4)),!a)break i;gi(a)}for(l[P+552>>2]=r;a=At[r+4|0],!!(!(a&4)&&(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=S+80|0;return}l[S+16>>2]=4075,sr(r,S+16|0),qi(),he()}l[S>>2]=4208,sr(r,S),qi(),he()}Ds(),he()}function bp(r,a){var h=0,u=0;for(l[r>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r+24>>2]=0,l[r+36>>2]=2143289344,l[r+40>>2]=2141891242,l[r+28>>2]=2143289344,l[r+32>>2]=2143289344,pt[r+4|0]=At[r+4|0]&128,u=Bi(r+44|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+80|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+116|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,u=Bi(r+152|0,0,36);l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=9;);for(h=0,l[r+196>>2]=0,u=r+188|0,l[u>>2]=0,l[u+4>>2]=0;l[u+(h<<2)>>2]=2143289344,h=h+1|0,(h|0)!=3;);for(l[r+24>>2]=4224,l[r+224>>2]=2143289344,l[r+216>>2]=2143289344,l[r+220>>2]=2143289344,l[r+208>>2]=2143289344,l[r+212>>2]=2143289344,l[r+200>>2]=2141891242,l[r+204>>2]=2141891242,Bi(r+228|0,0,288),l[r+244>>2]=2143289344,l[r+248>>2]=2143289344,Bi(r+252|0,0,49),l[r+308>>2]=2143289344,u=r+516|0,h=r+324|0;l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,h=h+24|0,(u|0)!=(h|0););return l[r+548>>2]=0,l[r+552>>2]=0,l[r+516>>2]=2143289344,l[r+520>>2]=2143289344,l[r+572>>2]=2143289344,l[r+576>>2]=0,l[r+568>>2]=a,l[r+540>>2]=-1082130432,l[r+544>>2]=-1082130432,l[r+532>>2]=0,l[r+536>>2]=0,l[r+524>>2]=-1082130432,l[r+528>>2]=-1082130432,l[r+556>>2]=0,l[r+560>>2]=0,l[r+564>>2]=0,l[r+580>>2]=2143289344,l[r+584>>2]=0,Qp((a|0)!=0,2760),pt[r+4|0]=At[r+4|0]|1,pt[a+8|0]&1&&(l[r+24>>2]=l[r+24>>2]&-909|520),r}function He(r,a,h,u){var y=m(0),A=m(0),k=0,S=m(0);t:{r:{i:{e:{s:{n:{if(a>>>0<=1){A=I[r+212>>2],a=l[r+212>>2];a:{if((a|0)==2139156720)break a;if((a|0)==2140081935)break n;k=4336;o:{if((a|0)!=2141891242){if(A==A)break o;k=4344}switch(y=I[k>>2],A=m(zt),l[k+4>>2]-1|0){case 0:break n;case 1:break a;default:break s}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break n}A=m(m(y*u)*m(.009999999776482582));break s}A=I[r+208>>2];a:{o:{a=l[r+208>>2];l:{if((a|0)==2139156720)break l;if((a|0)==2140081935)break o;k=4336;c:{if((a|0)!=2141891242){if(A==A)break c;k=4344}switch(y=I[k>>2],A=m(zt),l[k+4>>2]-1|0){case 0:break o;case 1:break l;default:break a}}if(y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break o}A=m(m(y*u)*m(.009999999776482582));break a}A=y}y=m(0),S=I[r+216>>2],r=l[r+216>>2];a:{if((r|0)==2139156720)break a;if((r|0)==2140081935)break i;a=4336;o:{if((r|0)!=2141891242){if(S==S)break o;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break a;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582));break e}A=y}y=m(0),S=I[r+220>>2],r=l[r+220>>2];s:{if((r|0)==2139156720)break s;if((r|0)==2140081935)break i;a=4336;n:{if((r|0)!=2141891242){if(S==S)break n;a=4344}switch(y=I[a>>2],l[a+4>>2]-1|0){case 1:break s;case 0:break e;default:break r}}if(y=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break e}y=m(m(y*u)*m(.009999999776482582))}if(!(y>=m(0)))break r}if(h>y)break t}if(!(A>=m(0)))return h;y=h<A?A:h}return y}function Ap(r){var a=0,h=0,u=m(0),y=m(0),A=m(0),k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=0,M=0;for(k=Et-16|0,l[k+8>>2]=0,l[k+12>>2]=1,tt=r+200|0,dt=r+572|0,q=r+208|0,et=r+216|0,r=0;;){M=r,K=l[(k+8|0)+(r<<2)>>2],S=K<<2,r=et+S|0,u=I[r>>2];t:{r:{i:{e:{s:{n:{if(a=l[r>>2],P=(a|0)==2139156720,!(P|(a|0)==2140081935|(a|0)==2141891242)&u!=u)break n;r=S+q|0,y=I[r>>2],h=l[r>>2];a:{o:{if((h|0)!=2139156720){if(A=m(zt),r=3,(h|0)==2141891242)break a;if((h|0)!=2140081935)break o;A=m(0),r=1;break a}A=m(0),r=2;break a}if(r=0,y!=y)break a;A=(Dt(2,(h&-1073741825)+536870912|0),Bt()),r=h&1073741824?2:1}h=r;a:{o:{if(!P){if(y=m(zt),r=3,(a|0)==2141891242)break a;if((a|0)!=2140081935)break o;y=m(0),r=1;break a}y=m(0),r=2;break a}if(r=0,u!=u)break a;y=(Dt(2,(a&-1073741825)+536870912|0),Bt()),r=a&1073741824?2:1}if((h|0)!=(r|0)|!(!r|y!=y&A!=A|m(Ge(m(y-A)))<m(9999999747378752e-20)))break n;if(r=0,P)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}if(r=0,a=S+tt|0,u=I[a>>2],a=l[a>>2],(a|0)==2139156720)break s;if((a|0)==2140081935)break r;if((a|0)==2141891242)break i;if(u!=u)break e;r=(a&-1073741825)+536870912|0,a=a&1073741824?2:1;break t}a=2;break t}r=2143289344,a=0;break t}r=2143289344,a=3;break t}a=1}if(h=(K<<3)+dt|0,l[h+4>>2]=a,l[h>>2]=r,r=1,!!(M&1))break}}function Ui(r,a,h){var u=0,y=0,A=0;if(h>>>0>=512)return wE(r|0,a|0,h|0),r;y=r+h|0;t:{if(!((r^a)&3)){r:{if(!(r&3)){h=r;break r}if(!h){h=r;break r}for(h=r;;){if(pt[h|0]=At[a|0],a=a+1|0,h=h+1|0,!(h&3))break r;if(!(h>>>0<y>>>0))break}}u=y&-4;r:{if(u>>>0<64||(A=u+-64|0,A>>>0<h>>>0))break r;for(;l[h>>2]=l[a>>2],l[h+4>>2]=l[a+4>>2],l[h+8>>2]=l[a+8>>2],l[h+12>>2]=l[a+12>>2],l[h+16>>2]=l[a+16>>2],l[h+20>>2]=l[a+20>>2],l[h+24>>2]=l[a+24>>2],l[h+28>>2]=l[a+28>>2],l[h+32>>2]=l[a+32>>2],l[h+36>>2]=l[a+36>>2],l[h+40>>2]=l[a+40>>2],l[h+44>>2]=l[a+44>>2],l[h+48>>2]=l[a+48>>2],l[h+52>>2]=l[a+52>>2],l[h+56>>2]=l[a+56>>2],l[h+60>>2]=l[a+60>>2],a=a- -64|0,h=h- -64|0,A>>>0>=h>>>0;);}if(h>>>0>=u>>>0)break t;for(;l[h>>2]=l[a>>2],a=a+4|0,h=h+4|0,u>>>0>h>>>0;);break t}if(y>>>0<4){h=r;break t}if(u=y-4|0,u>>>0<r>>>0){h=r;break t}for(h=r;pt[h|0]=At[a|0],pt[h+1|0]=At[a+1|0],pt[h+2|0]=At[a+2|0],pt[h+3|0]=At[a+3|0],a=a+4|0,h=h+4|0,u>>>0>=h>>>0;);}if(h>>>0<y>>>0)for(;pt[h|0]=At[a|0],a=a+1|0,h=h+1|0,(y|0)!=(h|0););return r}function Ep(r,a,h,u,y){var A=m(0),k=0,S=m(0),P=m(0),K=0,tt=0,dt=m(0),q=m(0),et=0;if(S=m(h-u),tt=S!=S,!tt){h=m(0),k=(a<<2)+r|0,A=I[k+208>>2];t:{r:{k=l[k+208>>2];i:{e:{if((k|0)==2139156720)break e;if((k|0)==2140081935)break r;K=4336;s:{if((k|0)!=2141891242){if(A==A)break s;K=4344}switch(h=I[K>>2],l[K+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;break t}P=m(h-u)}h=m(0),r=(a<<2)+r|0,A=I[r+216>>2];t:{r:{a=l[r+216>>2];i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break r;r=4336;s:{if((a|0)!=2141891242){if(A==A)break s;r=4344}switch(h=I[r>>2],A=m(34028234663852886e22),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break t}}if(h=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}h=m(m(h*y)*m(.009999999776482582))}if(h==h)break r;A=m(34028234663852886e22);break t}A=m(h-u)}if(h=(dt=S,q=xh(S,A),et=A!=A|tt,et?dt:q),r=h!=h,!(r|P!=P))return ce(h,P);S=r?P:h}return S}function Tp(r,a,h,u,y,A,k,S,P,K,tt,dt,q){var et=m(0),M=m(0),W=0,z=0,X=m(0),at=m(0),ot=m(0),mt=0,yt=0;if(P<m(0)|K<m(0))r=0;else{X=A,at=a,ot=u,M=S;t:{if(!q||(et=I[q+20>>2],M=S,et==m(0)))break t;mt=+et,at=Gr(+a,mt,0,0),ot=Gr(+u,mt,0,0),X=Gr(+A,mt,0,0),M=Gr(+S,mt,0,0)}et=M,q=0;t:{if((r|0)!=(y|0))break t;if(yt=X!=X,q=at!=at,yt|q){q=q&yt;break t}q=m(Ge(m(X-at)))<m(9999999747378752e-20)}yt=q;t:{if((h|0)!=(k|0))break t;if(W=et!=et,q=ot!=ot,W|q){W=q&W;break t}W=m(Ge(m(et-ot)))<m(9999999747378752e-20)}z=1,q=1;t:{if(yt)break t;a=m(a-tt);r:{if((r|0)==1)break r;if(r=(r|0)!=2,!(r|y)){if(!(a>=P))break r;break t}if(q=0,!(a<A)|(r|(y|0)!=2|(a!=a|A!=A|P!=P))||(q=1,a>=P))break t}if(y=a!=a,r=P!=P,y|r){q=r&y;break t}q=m(Ge(m(a-P)))<m(9999999747378752e-20)}t:{if(W)break t;a=m(u-dt);r:{if((h|0)==1)break r;if(r=(h|0)!=2,!(r|k)){if(!(a>=K))break r;break t}if(z=0,!(a<S)|(r|(k|0)!=2|(a!=a|S!=S|K!=K))||(z=1,a>=K))break t}if(h=a!=a,r=K!=K,h|r){z=r&h;break t}z=m(Ge(m(a-K)))<m(9999999747378752e-20)}r=q&z}return r}function wh(r){var a=0,h=0,u=0,y=0,A=0,k=0,S=0,P=0;if(pi(+r),A=te(1)|0,u=te(0)|0,y=A>>>20&2047,(y|0)==2047)return r=r*1,r/r;if(a=u<<1,k=A<<1|u>>>31,!a&(k|0)==2145386496|k>>>0<2145386496)return!a&(k|0)==2145386496?r*0:r;t:{if(!y){if(y=0,h=u<<12,a=A<<12|u>>>20,(a|0)>0|(a|0)>=0)for(;y=y-1|0,a=a<<1|h>>>31,h=h<<1,!!((a|0)>0|(a|0)>=0););a=1-y|0,h=a&31,(a&63)>>>0>=32?(a=u<<h,u=0):(a=(1<<h)-1&u>>>32-h|A<<h,u=u<<h);break t}a=A&1048575|1048576}if(h=u,(y|0)>1023){for(;;){t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if(a=a<<1|h>>>31,h=h<<1,y=y-1|0,!((y|0)>1023))break}y=1023}t:{if(u=a+-1048576|0,(u|0)<0||(a=u,a|h))break t;return r*0}if((a|0)==1048575|a>>>0<1048575)for(;y=y-1|0,u=a>>>0<524288,k=a<<1|h>>>31,h=h<<1,a=k,!!u;);return P=A&-2147483648,k=a+-1048576|y<<20,S=h,A=a,S=h,u=1-y|0,h=u&31,(u&63)>>>0>=32?(a=0,u=A>>>h|0):(a=A>>>h|0,u=((1<<h)-1&A)<<32-h|S>>>h),h=(y|0)>0,Dt(0,(h?S:u)|0),Dt(1,(h?k:a)|P),+Ae()}function Sh(r){var a=0,h=0,u=0,y=0,A=0;u=l[1416],a=r+7&-8,h=u+a|0;t:{r:{if(h>>>0<=u>>>0&&a||h>>>0>d2()<<16>>>0&&!(kE(h|0)|0))break r;l[1416]=h;break t}l[1781]=48,u=-1}if((u|0)!=-1){a=r+u|0,h=a-16|0,l[h+12>>2]=16,l[h>>2]=16,r=l[1748],r?A=l[r+8>>2]:A=0;t:{r:{if((A|0)==(u|0)){if(y=u-(l[u-4>>2]&-2)|0,A=l[y-4>>2],l[r+8>>2]=a,r=y-(A&-2)|0,a=-16,!(pt[(r+l[r>>2]|0)-4|0]&1))break r;a=l[r+4>>2],l[a+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=a,h=h-r|0,l[r>>2]=h;break t}l[u+12>>2]=16,l[u>>2]=16,l[u+8>>2]=a,l[u+4>>2]=r,l[1748]=u,a=16}r=a+u|0,h=h-r|0,l[r>>2]=h}l[((h&-4)+r|0)-4>>2]=h|1,a=l[r>>2]-8|0;t:{if(a>>>0<=127){h=(a>>>3|0)-1|0;break t}if(y=mr(a),h=((a>>>29-y^4)-(y<<2)|0)+110|0,a>>>0<=4095)break t;h=((a>>>30-y^2)-(y<<1)|0)+71|0,h=h>>>0>=63?63:h}a=h<<4,l[r+4>>2]=a+5968,a=a+5976|0,l[r+8>>2]=l[a>>2],l[a>>2]=r,l[l[r+8>>2]+4>>2]=r,a=l[1750],y=l[1751],r=h&31,(h&63)>>>0>=32?(h=1<<r,A=0):(A=1<<r,h=A-1&1>>>32-r),l[1750]=A|a,l[1751]=h|y}return(u|0)!=-1}function kp(r,a,h){var u=0,y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0;t:{r:{i:{e:{s:{n:{a:{o:{l:{c:{if(a){if(!h)break c;break l}r=(r>>>0)/(h>>>0)|0,Fi=0;break t}if(!r)break o;break a}if(!(h-1&h))break n;A=(mr(h)+33|0)-mr(a)|0,k=0-A|0;break e}r=(a>>>0)/0|0,Fi=0;break t}if(u=32-mr(a)|0,u>>>0<31)break s;break i}if((h|0)==1)break r;A=h?31-mr(h-1^h)|0:32,h=A&31,(A&63)>>>0>=32?r=a>>>h|0:(u=a>>>h|0,r=((1<<h)-1&a)<<32-h|r>>>h),Fi=u;break t}A=u+1|0,k=63-u|0}if(u=A&63,y=u&31,u>>>0>=32?(u=0,S=a>>>y|0):(u=a>>>y|0,S=((1<<y)-1&a)<<32-y|r>>>y),k=k&63,y=k&31,k>>>0>=32?(a=r<<y,r=0):(a=(1<<y)-1&r>>>32-y|a<<y,r=r<<y),A)for(k=h-1|0,dt=(k|0)==-1?-1:0;P=u<<1|S>>>31,u=S<<1|a>>>31,y=dt-(P+(u>>>0>k>>>0)|0)>>31,K=h&y,S=u-K|0,u=P-(u>>>0<K>>>0)|0,a=a<<1|r>>>31,r=tt|r<<1,tt=y&1,A=A-1|0,!!A;);Fi=a<<1|r>>>31,r=tt|r<<1;break t}r=0,a=0}Fi=a}return r}function Jo(r,a,h){var u=m(0),y=m(0);t:{r:{i:{if((a&-2)==2){if(a=l[r+188>>2],u=I[r+188>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+196>>2],u=I[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u))break i;break r}if(a=l[r+192>>2],u=I[r+192>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(u=I[r+196>>2],a=l[r+196>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242))break i;if(u!=u)break r}u=m(0);i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break e;default:break i}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}y=m(m(u*h)*m(.009999999776482582))}return y}u=m(0)}return u}function wp(r,a){var h=0,u=0,y=0,A=0,k=0,S=0;for(h=Et-320|0,Et=h,u=Bi(h,0,288),h=u,l[h+16>>2]=2143289344,l[h+20>>2]=2143289344,Bi(h+24|0,0,49),l[h+80>>2]=2143289344,A=h+288|0,y=h+96|0;h=y,l[h+16>>2]=-1082130432,l[h+20>>2]=-1082130432,l[h+8>>2]=0,l[h+12>>2]=0,l[h>>2]=-1082130432,l[h+4>>2]=-1082130432,y=h+24|0,(A|0)!=(y|0););if(l[u+312>>2]=-1082130432,l[u+316>>2]=-1082130432,l[u+304>>2]=0,l[u+308>>2]=0,l[u+296>>2]=-1082130432,l[u+300>>2]=-1082130432,l[u+288>>2]=2143289344,l[u+292>>2]=2143289344,Ui(r+228|0,u,320),l[r+244>>2]=0,l[r+248>>2]=0,pt[r+4|0]=At[r+4|0]|1,y=l[r+556>>2],k=l[r+560>>2],(y|0)!=(k|0))for(;h=l[y>>2],l[h+552>>2]!=(r|0)&&(A=l[r+568>>2],h=Ip(l[A>>2],At[A+8|0],h,r,S,a),l[y>>2]=h,l[h+552>>2]=r,h=l[y>>2]),wp(h,a),S=S+1|0,y=y+4|0,(k|0)!=(y|0););Et=u+320|0}function Rh(r,a,h){var u=0,y=0,A=0,k=0;if(u=r+4|0,y=(u+a|0)-1&0-a,a=l[r>>2],y+h>>>0<=(a+r|0)-4>>>0){A=l[r+4>>2],l[A+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=A,(u|0)!=(y|0)&&(y=y-u|0,A=r-(l[r-4>>2]&-2)|0,u=y+l[A>>2]|0,l[A>>2]=u,l[(A+(u&-4)|0)-4>>2]=u,r=r+y|0,a=a-y|0,l[r>>2]=a);t:{if(h+24>>>0<=a>>>0){u=(r+h|0)+8|0,a=(a-h|0)-8|0,l[u>>2]=a,l[(u+(a&-4)|0)-4>>2]=a|1,y=l[u>>2]-8|0;r:{if(y>>>0<=127){a=(y>>>3|0)-1|0;break r}if(A=mr(y),a=((y>>>29-A^4)-(A<<2)|0)+110|0,y>>>0<=4095)break r;a=((y>>>30-A^2)-(A<<1)|0)+71|0,a=a>>>0>=63?63:a}y=a<<4,l[u+4>>2]=y+5968,y=y+5976|0,l[u+8>>2]=l[y>>2],l[y>>2]=u,l[l[u+8>>2]+4>>2]=u,y=l[1750],A=l[1751],u=a&31,(a&63)>>>0>=32?(a=1<<u,u=0):(k=1<<u,a=k-1&1>>>32-u,u=k),l[1750]=u|y,l[1751]=a|A,a=h+8|0,l[r>>2]=a,l[((a&-4)+r|0)-4>>2]=a;break t}l[(r+a|0)-4>>2]=a}r=r+4|0}else r=0;return r}function ME(r,a){r=r|0,a=a|0;var h=0,u=0,y=0,A=0;y=Et-320|0,Et=y,r=l[r>>2];t:{if(l[r+560>>2]==l[r+556>>2]||(u=l[a>>2],a=l[u+552>>2],!Mp(r,u)))break t;if((r|0)==(a|0)){for(h=Bi(y,0,288),a=h,l[a+16>>2]=2143289344,l[a+20>>2]=2143289344,Bi(a+24|0,0,49),l[a+80>>2]=2143289344,A=a+288|0,a=a+96|0;l[a+16>>2]=-1082130432,l[a+20>>2]=-1082130432,l[a+8>>2]=0,l[a+12>>2]=0,l[a>>2]=-1082130432,l[a+4>>2]=-1082130432,a=a+24|0,(A|0)!=(a|0););l[h+312>>2]=-1082130432,l[h+316>>2]=-1082130432,l[h+304>>2]=0,l[h+308>>2]=0,l[h+296>>2]=-1082130432,l[h+300>>2]=-1082130432,l[h+288>>2]=2143289344,l[h+292>>2]=2143289344,Ui(u+228|0,h,320),l[u+552>>2]=0}for(;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=y+320|0}function Sp(r){r=r|0;var a=0,h=0,u=0,y=0,A=0,k=0,S=0;if(r){if(k=Et-32|0,Et=k,a=l[r>>2],u=l[a+552>>2],u&&(Mp(u,a),l[a+552>>2]=0),u=l[a+556>>2],h=l[a+560>>2],(u|0)!=(h|0))for(h=h-u>>2,y=h>>>0<=1?1:h,h=0;l[l[(h<<2)+u>>2]+552>>2]=0,h=h+1|0,(y|0)!=(h|0););l[a+560>>2]=u,h=a+564|0;t:{if(l[h>>2]==(u|0)||(h=Na(k+8|0,0,0,h),y=l[a+556>>2],A=l[a+560>>2]-y|0,u=l[h+4>>2]-A|0,A=Ps(u,y,A),y=l[a+556>>2],l[a+556>>2]=A,l[h+4>>2]=y,A=l[a+560>>2],l[a+560>>2]=l[h+8>>2],l[h+8>>2]=A,S=l[a+564>>2],l[a+564>>2]=l[h+12>>2],l[h>>2]=y,l[h+12>>2]=S,(y|0)!=(A|0)&&(l[h+8>>2]=A+((y-A|0)+3&-4)),!y))break t;gi(y),u=l[a+556>>2]}u&&(l[a+560>>2]=u,gi(u)),gi(a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Et=k+32|0,gi(r)}}function $E(r){r=r|0;var a=0,h=0,u=0;u=Et-624|0,Et=u,a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a);t:{if(r=l[r>>2],l[r+560>>2]==l[r+556>>2]){if(l[r+552>>2])break t;a=bp(u+32|0,l[r+568>>2]),h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h,h=l[a+20>>2],l[r+16>>2]=l[a+16>>2],l[r+20>>2]=h,h=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=h,Ui(r+24|0,a+24|0,204),Ui(r+228|0,a+228|0,328),h=l[r+556>>2],h&&(l[r+560>>2]=h,gi(h)),l[r+556>>2]=l[a+556>>2],l[r+560>>2]=l[a+560>>2],l[r+564>>2]=l[a+564>>2],l[r+584>>2]=l[a+584>>2],h=l[a+580>>2],l[r+576>>2]=l[a+576>>2],l[r+580>>2]=h,h=l[a+572>>2],l[r+568>>2]=l[a+568>>2],l[r+572>>2]=h,Et=u+624|0;return}l[u+16>>2]=3301,sr(r,u+16|0),qi(),he()}l[u>>2]=2047,sr(r,u),qi(),he()}function Rp(){CE(7084,3067),LE(7085,2480,1,1,0),ls(7086,2140,1,-128,127),ls(7087,2133,1,-128,127),ls(7088,2131,1,0,255),ls(7089,1287,2,-32768,32767),ls(7090,1278,2,0,65535),ls(7091,1316,4,-2147483648,2147483647),ls(7092,1307,4,0,-1),ls(7093,2659,4,-2147483648,2147483647),ls(7094,2650,4,0,-1),r2(7095,1777,-2147483648,2147483647),r2(7096,1776,0,-1),up(7097,1770,4),up(7098,3015,8),fp(7099,2677),fp(7100,3904),Ah(7101,4,2664),Ah(7102,2,2689),Ah(7103,4,2704),_E(7104,2485),Ti(7105,0,3835),Ti(7106,0,3937),Ti(7107,1,3865),Ti(7108,2,3467),Ti(7109,3,3498),Ti(7110,4,3538),Ti(7111,5,3567),Ti(7112,4,3974),Ti(7113,5,4004),Ti(7106,0,3669),Ti(7107,1,3636),Ti(7108,2,3735),Ti(7109,3,3701),Ti(7110,4,3802),Ti(7111,5,3768),Ti(7114,6,3605),Ti(7115,7,4043)}function Ps(r,a,h){var u=0,y=0;t:{if((r|0)==(a|0))break t;if(y=r+h|0,a-y>>>0<=0-(h<<1)>>>0)return Ui(r,a,h);u=(r^a)&3;r:{i:{if(r>>>0<a>>>0){if(u){u=r;break r}if(!(r&3)){u=r;break i}for(u=r;;){if(!h)break t;if(pt[u|0]=At[a|0],a=a+1|0,h=h-1|0,u=u+1|0,!(u&3))break}break i}e:{if(u)break e;if(y&3)for(;;){if(!h)break t;if(h=h-1|0,u=h+r|0,pt[u|0]=At[a+h|0],!(u&3))break}if(h>>>0<=3)break e;for(;h=h-4|0,l[h+r>>2]=l[a+h>>2],h>>>0>3;);}if(!h)break t;for(;h=h-1|0,pt[h+r|0]=At[a+h|0],!!h;);break t}if(h>>>0<=3)break r;for(;l[u>>2]=l[a>>2],a=a+4|0,u=u+4|0,h=h-4|0,h>>>0>3;);}if(!h)break t;for(;pt[u|0]=At[a|0],u=u+1|0,a=a+1|0,h=h-1|0,!!h;);}return r}function _p(r,a,h,u){t:switch(a-9|0){case 0:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2];return;case 6:a=l[h>>2],l[h>>2]=a+4,a=Fr[a>>1],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 7:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=Nn[a>>1],l[r+4>>2]=0;return;case 8:a=l[h>>2],l[h>>2]=a+4,a=pt[a|0],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 9:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=At[a|0],l[r+4>>2]=0;return;case 16:a=l[h>>2]+7&-8,l[h>>2]=a+8,Fe[r>>3]=Fe[a>>3];return;case 17:Pt[u|0](r,h);default:return;case 1:case 4:case 14:a=l[h>>2],l[h>>2]=a+4,a=l[a>>2],l[r>>2]=a,l[r+4>>2]=a>>31;return;case 2:case 5:case 11:case 15:a=l[h>>2],l[h>>2]=a+4,l[r>>2]=l[a>>2],l[r+4>>2]=0;return;case 3:case 10:case 12:case 13:break t}a=l[h>>2]+7&-8,l[h>>2]=a+8,h=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=h}function Lp(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0,tt=0,dt=0,q=0,et=m(0),M=m(0),W=m(0),z=0,X=m(0);t:{if(a==0||(et=I[r+248>>2],M=I[r+244>>2],W=I[r+232>>2],P=+I[r+228>>2],y=At[r+4|0]&8,A=y>>>3|0,z=r,X=Gr(P,a,0,A),I[z+228>>2]=X,K=+W,z=r,X=Gr(K,a,0,A),I[z+232>>2]=X,tt=+M,k=wh(tt*a),A=k==k&Ge(k)<1e-4,S=!(A|k!=k?A:Ge(k+-1)<1e-4),dt=+et,k=wh(dt*a),A=k==k&Ge(k)<1e-4,q=!(A|k!=k?A:Ge(k+-1)<1e-4),A=0,h=P+h,y=(y|0)!=0,z=r,X=m(Gr(h+tt,a,y&S,y&!S)-Gr(h,a,0,y)),I[z+244>>2]=X,u=K+u,z=r,X=m(Gr(u+dt,a,y&q,y&!q)-Gr(u,a,0,y)),I[z+248>>2]=X,y=l[r+560>>2],S=l[r+556>>2],(y|0)==(S|0)))break t;for(y=y-S>>2,S=y>>>0<=1?1:y;y=l[r+556>>2],l[r+560>>2]-y>>2>>>0>A>>>0?y=l[y+(A<<2)>>2]:y=0,Lp(y,a,h,u),A=A+1|0,(S|0)!=(A|0););}}function Bi(r,a,h){var u=0,y=0,A=0,k=0;t:{if(!h||(pt[r|0]=a,u=r+h|0,pt[u-1|0]=a,h>>>0<3)||(pt[r+2|0]=a,pt[r+1|0]=a,pt[u-3|0]=a,pt[u-2|0]=a,h>>>0<7)||(pt[r+3|0]=a,pt[u-4|0]=a,h>>>0<9)||(u=0-r&3,y=u+r|0,a=Ue(a&255,16843009),l[y>>2]=a,u=h-u&-4,h=u+y|0,l[h-4>>2]=a,u>>>0<9)||(l[y+8>>2]=a,l[y+4>>2]=a,l[h-8>>2]=a,l[h-12>>2]=a,u>>>0<25)||(l[y+24>>2]=a,l[y+20>>2]=a,l[y+16>>2]=a,l[y+12>>2]=a,l[h-16>>2]=a,l[h-20>>2]=a,l[h-24>>2]=a,l[h-28>>2]=a,k=y&4|24,h=u-k|0,h>>>0<32))break t;for(u=Ih(a,0,1,1),A=Fi,a=y+k|0;l[a+24>>2]=u,l[a+28>>2]=A,l[a+16>>2]=u,l[a+20>>2]=A,l[a+8>>2]=u,l[a+12>>2]=A,l[a>>2]=u,l[a+4>>2]=A,a=a+32|0,h=h-32|0,h>>>0>31;);}return r}function gi(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;if(r){a=r-4|0,y=l[a>>2],h=y,u=a,A=l[r-8>>2],r=A&-2,(r|0)!=(A|0)&&(u=a-r|0,h=l[u+4>>2],l[h+8>>2]=l[u+8>>2],l[l[u+8>>2]+4>>2]=h,h=r+y|0),r=a+y|0,a=l[r>>2],(a|0)!=l[(r+a|0)-4>>2]&&(y=l[r+4>>2],l[y+8>>2]=l[r+8>>2],l[l[r+8>>2]+4>>2]=y,h=a+h|0),l[u>>2]=h,l[((h&-4)+u|0)-4>>2]=h|1,a=l[u>>2]-8|0;t:{if(a>>>0<=127){r=(a>>>3|0)-1|0;break t}if(h=mr(a),r=((a>>>29-h^4)-(h<<2)|0)+110|0,a>>>0<=4095)break t;r=((a>>>30-h^2)-(h<<1)|0)+71|0,r=r>>>0>=63?63:r}a=r<<4,l[u+4>>2]=a+5968,a=a+5976|0,l[u+8>>2]=l[a>>2],l[a>>2]=u,l[l[u+8>>2]+4>>2]=u,a=l[1750],h=l[1751],u=r&31,(r&63)>>>0>=32?(r=1<<u,y=0):(y=1<<u,r=y-1&1>>>32-u),l[1750]=y|a,l[1751]=r|h}}function NE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0,P=0,K=0;u=Et-32|0,Et=u,y=l[r+28>>2],l[u+16>>2]=y,A=l[r+20>>2],l[u+28>>2]=h,l[u+24>>2]=a,a=A-y|0,l[u+20>>2]=a,A=a+h|0,P=2,a=u+16|0;t:{for(;;){r:{i:{e:{if(!e2(SE(l[r+60>>2],a|0,P|0,u+12|0)|0)){if(k=l[u+12>>2],(k|0)==(A|0))break e;if((k|0)>=0)break i;break r}if((A|0)!=-1)break r}a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],r=h;break t}S=l[a+4>>2],K=S>>>0<k>>>0,y=(K<<3)+a|0,S=k-(K?S:0)|0,l[y>>2]=S+l[y>>2],a=(K?12:4)+a|0,l[a>>2]=l[a>>2]-S,A=A-k|0,P=P-K|0,a=y;continue}break}if(l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,l[r>>2]=l[r>>2]|32,r=0,(P|0)==2)break t;r=h-l[a+4>>2]|0}return Et=u+32|0,r|0}function FE(r){r=r|0;var a=0,h=0,u=0,y=0,A=0;h=Et-96|0,Et=h,l[h>>2]=r,u=Et-16|0,Et=u,l[u+12>>2]=h,r=Et-144|0,Et=r,r=Ui(r,5520,144),A=h+16|0,a=A,l[r+44>>2]=a,l[r+20>>2]=a,y=-2-a|0,y=y>>>0>=2147483647?2147483647:y,l[r+48>>2]=y,a=a+y|0,l[r+28>>2]=a,l[r+16>>2]=a,Cp(r,2202,h,0,0),y&&(a=l[r+20>>2],pt[a-((a|0)==l[r+16>>2])|0]=0),Et=r+144|0,Et=u+16|0,r=A;t:{if(r&3)for(;;){if(!At[r|0])break t;if(r=r+1|0,!(r&3))break}for(;a=r,r=r+4|0,u=l[a>>2],!((u^-1)&u-16843009&-2139062144););for(;r=a,a=r+1|0,!!At[r|0];);}return r=(r-A|0)+1|0,a=kh(r),a?r=Ui(a,A,r):r=0,Et=h+96|0,r|0}function Cp(r,a,h,u,y){var A=0,k=0,S=0,P=0;A=Et-208|0,Et=A,l[A+204>>2]=h,h=A+160|0,Bi(h,0,40),l[A+200>>2]=l[A+204>>2];t:{if((yp(0,a,A+200|0,A+80|0,h,u,y)|0)<0){y=-1;break t}P=l[r+76>>2]>=0,k=l[r>>2],l[r+72>>2]<=0&&(l[r>>2]=k&-33);r:{i:{e:{if(!l[r+48>>2]){l[r+48>>2]=80,l[r+28>>2]=0,l[r+16>>2]=0,l[r+20>>2]=0,S=l[r+44>>2],l[r+44>>2]=A;break e}if(l[r+16>>2])break i}if(h=-1,Hp(r))break r}h=yp(r,a,A+200|0,A+80|0,A+160|0,u,y)}if(S&&(Pt[l[r+36>>2]](r,0,0)|0,l[r+48>>2]=0,l[r+44>>2]=S,l[r+28>>2]=0,a=l[r+20>>2],l[r+16>>2]=0,l[r+20>>2]=0,h=a?h:-1),a=r,r=l[r>>2],l[a>>2]=r|k&32,y=r&32?-1:h,!P)break t}return Et=A+208|0,y}function tl(r){var a=0,h=m(0),u=0,y=0,A=0,k=0,S=0,P=m(0),K=0;A=Et-16|0,Et=A,a=l[r+12>>2];t:{if(a){P=I[r+520>>2],h=I[r+516>>2];r:{if(At[r+4|0]&32){h=m(Pt[a|0](r,h,P,0));break r}h=m(Pt[a|0](r,h,P))}if(h==h)break t;l[A>>2]=3409,sr(r,A),qi(),he()}r:{i:{if(k=l[r+556>>2],a=l[r+560>>2],(k|0)!=(a|0)){for(a=a-k>>2,K=a>>>0<=1?1:a;;){if(y=l[(S<<2)+k>>2],!l[y+548>>2]){if(a=l[y+24>>2],(a&196608)!=131072){if(a=a>>>13&7,a||(a=l[r+24>>2]>>>10&7),At[y+4|0]&2|(At[r+24|0]&8?(a|0)==5:0))break i;u=u||y}if(S=S+1|0,(K|0)!=(S|0))continue}break}if(u)break r}h=I[r+520>>2];break t}u=y}h=m(tl(u)+I[u+232>>2])}return Et=A+16|0,h}function Un(r,a,h,u,y,A){var k=0,S=m(0),P=0,K=m(0);k=(l[(a<<2)+4320>>2]<<2)+r|0,S=I[k+216>>2];t:{r:{k=l[k+216>>2];i:{if((k|0)==2139156720)break i;if((k|0)==2140081935)break r;P=4336;e:{if((k|0)!=2141891242){if(S==S)break e;P=4344}switch(K=I[P>>2],S=m(zt),l[P+4>>2]-1|0){case 0:break r;case 1:break i;default:break t}}if(K=(Dt(2,(k&-1073741825)+536870912|0),Bt()),!(k&1073741824))break r}S=m(m(K*h)*m(.009999999776482582));break t}S=K}u=m(S+m(de(r,a,u)+we(r,a,u)));t:{r:{i:switch(l[y>>2]){case 1:case 2:h=I[A>>2],u=u!=u||h<u?h:u;break r;case 0:break i;default:break t}if(u!=u)break t;l[y>>2]=2}I[A>>2]=u}}function Ie(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4288>>2];t:{if((a&-2)==2){a=Ur(r,4,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function xe(r,a,h){var u=m(0),y=m(0),A=0,k=m(0);r=r+116|0,A=l[(a<<2)+4304>>2];t:{if((a&-2)==2){a=Ur(r,5,A,2140081935);break t}a=Br(r,A,2140081935)}t:{r:{i:{e:{if((a|0)==2139156720)break e;if((a|0)==2140081935)break t;r=4336;s:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break s;r=4344}switch(u=I[r>>2],y=m(zt),l[r+4>>2]-1|0){case 0:break i;case 1:break e;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break i}u=m(m(u*h)*m(.009999999776482582))}if(u>=m(0))return u;if(y=u,u<m(0))break t}k=y==y?y:m(0)}return k}function Ip(r,a,h,u,y,A){var k=0;t:{r:{if(r){i:{if(a&4){A=Pt[r|0](h,u,y,A)|0;break i}A=Pt[r|0](h,u,y)|0}if(A)break r}if(A=ht(588),a=Ui(A,h,552),l[a+564>>2]=0,l[a+556>>2]=0,l[a+560>>2]=0,y=l[h+556>>2],u=l[h+560>>2],(y|0)!=(u|0)){if(k=u-y|0,(k|0)<0)break t;for(r=ht(k),l[a+556>>2]=r,l[a+564>>2]=r+k;l[r>>2]=l[y>>2],r=r+4|0,y=y+4|0,(u|0)!=(y|0););l[a+560>>2]=r}r=l[h+572>>2],l[a+568>>2]=l[h+568>>2],l[a+572>>2]=r,l[a+584>>2]=l[h+584>>2],r=l[h+580>>2],l[a+576>>2]=l[h+576>>2],l[a+580>>2]=r,l[a+552>>2]=0}return A}Ds(),he()}function sr(r,a){var h=0,u=0,y=0;y=Et-16|0,Et=y,l[y+12>>2]=a;t:{r:{if(!r){a=l[y+12>>2];break r}if(a=l[y+12>>2],h=l[r+568>>2],!h)break r;if(u=l[h+4>>2],At[h+8|0]&8){Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0;break t}r:{if(!At[7016]){h=ht(28),l[h+20>>2]=1065353216,l[h+24>>2]=0,l[h+12>>2]=0,l[h+16>>2]=0,l[h>>2]=0,pt[h+8|0]=0,u=1,l[h+4>>2]=1,l[1753]=h,pt[7016]=1,l[1752]=l[1752]+1;break r}if(h=l[1753],u=l[h+4>>2],!(At[h+8|0]&8))break r;Pt[u|0](h,r,5,0,4284,a)|0;break t}Pt[u|0](h,r,5,4284,a)|0}Et=y+16|0}function $a(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4304>>2];t:{r:{if((a&-2)==2){a=Ur(r,5,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Os(r,a,h){var u=m(0),y=0,A=m(0);r=r+80|0,y=l[(a<<2)+4288>>2];t:{r:{if((a&-2)==2){a=Ur(r,4,y,2140081935);break r}a=Br(r,y,2140081935)}r:{i:{if((a|0)==2139156720)break i;if((a|0)==2140081935)break t;r=4336;e:{if((a|0)!=2141891242){if(u=(Dt(2,a),Bt()),u==u)break e;r=4344}switch(u=I[r>>2],A=m(zt),l[r+4>>2]-1|0){case 0:break t;case 1:break i;default:break r}}if(u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),!(a&1073741824))break t}A=m(m(u*h)*m(.009999999776482582))}return A}return u}function Ur(r,a,h,u){var y=m(0);a=(a<<2)+r|0,y=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y||(a=(h<<2)+r|0,y=I[a>>2],a=l[a>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(a=l[r+24>>2],y=I[r+24>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|y==y)||(y=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=u,y!=y)))break t;a=r}return a}function UE(r,a){r=r|0,a=m(a);var h=0,u=0,y=0;if(h=Et-16|0,Et=h,r=l[r>>2],!(a>=m(0))){l[h>>2]=2263,u=Et-16|0,Et=u,l[u+12>>2]=h;t:{if(r)break t;if(At[7016]){r=l[1753];break t}r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,pt[r+8|0]=0,l[r+4>>2]=1,l[1753]=r,pt[7016]=1,l[1752]=l[1752]+1}y=l[r+4>>2];t:{if(At[r+8|0]&8){Pt[y|0](r,0,5,0,4284,h)|0;break t}Pt[y|0](r,0,5,4284,h)|0}Et=u+16|0,qi(),he()}I[r+20>>2]=a==m(0)?m(0):a,Et=h+16|0}function xp(r,a,h,u,y){var A=0,k=0,S=m(0),P=0;A=2,k=l[r+24>>2]>>>2&3;t:{r:{i:{if(!(!l[r+552>>2]|(a|0)!=2)){a=0,A=3;e:switch(k-2|0){case 0:break t;case 1:break e;default:break i}A=2;break t}if(a=0,k>>>0>1)break r}a=A}A=k}h=qp(r,A,h),u=qp(r,a,u),S=de(r,A,y),k=r+228|0,P=A<<2,I[k+(l[P+4288>>2]<<2)>>2]=h+S,S=we(r,A,y),I[k+(l[P+4304>>2]<<2)>>2]=h+S,h=de(r,a,y),A=a<<2,I[k+(l[A+4288>>2]<<2)>>2]=u+h,h=we(r,a,y),I[k+(l[A+4304>>2]<<2)>>2]=u+h}function BE(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0,P=0;k=Et-48|0,Et=k,P=l[a+8>>2];t:{if(pt[7052]&1){a=l[1762];break t}a=dp(5,4480)|0,pt[7052]=1,l[1762]=a}l[k+40>>2]=A,I[k+32>>2]=y,l[k+24>>2]=u,I[k+16>>2]=h,S=+bE(a|0,P|0,2922,k+12|0,k+16|0);t:{if(S<4294967296&S>=0){a=~~S>>>0;break t}a=0}u=l[k+12>>2],A=l[a+4>>2],l[r>>2]=l[a>>2],l[r+4>>2]=A,A=l[a+12>>2],l[r+8>>2]=l[a+8>>2],l[r+12>>2]=A,yE(u|0),Et=k+48|0}function GE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0;if(u=Et-32|0,Et=u,y=l[a>>2],y>>>0<2147483632){t:{r:{if(y>>>0>=11){A=(y|15)+1|0,k=ht(A),l[u+16>>2]=A|-2147483648,l[u+8>>2]=k,l[u+12>>2]=y,A=y+k|0;break r}if(pt[u+19|0]=y,k=u+8|0,A=k+y|0,!y)break t}Ui(k,a+4|0,y)}return pt[A|0]=0,l[u>>2]=h,Pt[r|0](u+24|0,u+8|0,u),vE(l[u+24>>2]),r=l[u+24>>2],Ma(r|0),Ma(l[u>>2]),pt[u+19|0]<0&&gi(l[u+8>>2]),Et=u+32|0,r|0}Ds(),he()}function hi(r,a,h){var u=0,y=0,A=0;if(!(At[r|0]&32))t:{u=a,a=r,r=l[a+16>>2];r:{if(!r){if(Hp(a))break r;r=l[a+16>>2]}if(A=l[a+20>>2],r-A>>>0<h>>>0){Pt[l[a+36>>2]](a,u,h)|0;break t}i:{if(l[a+80>>2]<0)break i;for(r=h;;){if(y=r,!r)break i;if(r=y-1|0,At[u+r|0]==10)break}if(Pt[l[a+36>>2]](a,u,y)>>>0<y>>>0)break r;u=u+y|0,h=h-y|0,A=l[a+20>>2]}Ui(A,u,h),l[a+20>>2]=l[a+20>>2]+h}}}function _h(r,a,h){var u=0,y=0,A=0;u=Et-16|0,Et=u,y=r+24|0,Pt[a|0](u+8|0,y),A=l[u+12>>2];t:{if((l[l[u+8>>2]>>2]&7<<A)>>A==(h|0))break t;for(Pt[a|0](u+8|0,y),a=l[u+8>>2],y=a,A=l[a>>2],a=l[u+12>>2],l[y>>2]=A&(7<<a^-1)|(h&7)<<a;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}Et=u+16|0}function Br(r,a,h){var u=m(0);a=(a<<2)+r|0,u=I[a>>2],a=l[a>>2];t:{if((a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u||(a=l[r+28>>2],u=I[r+28>>2],(a|0)==2139156720|(a|0)==2140081935|(a|0)==2141891242|u==u)||(u=I[r+32>>2],r=l[r+32>>2],!((r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242)&&(a=h,u!=u)))break t;a=r}return a}function we(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function de(r,a,h){var u=m(0),y=0;r=r+44|0,y=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,y,2140081935);break t}r=Br(r,y,2140081935)}t:{if((r|0)!=2139156720){if((r|0)==2140081935|(r|0)==2141891242)break t;if(u=(Dt(2,r),Bt()),u!=u)return m(zt);if(u=(Dt(2,(r&-1073741825)+536870912|0),Bt()),!(r&1073741824))break t}u=m(m(u*h)*m(.009999999776482582))}return u}function HE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=0,k=0,S=0;return y=l[r+84>>2],A=l[y>>2],u=l[y+4>>2],S=l[r+28>>2],k=l[r+20>>2]-S|0,k=u>>>0<k>>>0?u:k,k&&(Ui(A,S,k),A=k+l[y>>2]|0,l[y>>2]=A,u=l[y+4>>2]-k|0,l[y+4>>2]=u),u=h>>>0>u>>>0?u:h,u&&(Ui(A,a,u),A=u+l[y>>2]|0,l[y>>2]=A,l[y+4>>2]=l[y+4>>2]-u),pt[A|0]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,h|0}function Se(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return ce(h,m(0))}function fe(r,a){var h=m(0),u=0;r=r+152|0,u=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,u,2140081935);break t}r=Br(r,u,2140081935)}h=m(0);t:{if((r|0)==2139156720||(h=m(0),(r|0)==2140081935))break t;r:{if((r|0)==2141891242||(h=(Dt(2,r),Bt()),h!=h))break r;h=(Dt(2,(r&-1073741825)+536870912|0),Bt());break t}h=m(zt)}return ce(h,m(0))}function VE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+116>>2];t:{r:{if(a=l[a+116>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function WE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+80>>2];t:{r:{if(a=l[a+80>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function jE(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0,A=m(0);u=2,a=l[a>>2]+(h<<2)|0,A=I[a+44>>2];t:{r:{if(a=l[a+44>>2],(a|0)!=2139156720){if(y=zt,(a|0)==2141891242){u=3;break t}if((a|0)!=2140081935)break r;y=0,u=1;break t}break t}if(A!=A){u=0;break t}u=a&1073741824?2:1,y=(Dt(2,(a&-1073741825)+536870912|0),+Bt())}Fe[r+8>>3]=y,l[r>>2]=u}function Gr(r,a,h,u){var y=0,A=0,k=0;r=r*a,y=wh(r),y=y<0?y+1:y,k=y!=y;t:{if(!(k|!(Ge(y)<1e-4))){r=r-y;break t}r:{if(y!=y){r=r-y;break r}if(r=r-y,!(Ge(y+-1)<1e-4))break r;r=r+1;break t}if(h){r=r+1;break t}if(u)break t;A=0;r:{if(k||(A=1,y>.5))break r;A=Ge(y+-.5)<1e-4?1:0}r=r+A}return r!=r|a!=a?m(zt):m(r/a)}function Dp(r,a){var h=m(0);t:{if((a|0)!=2139156720){if((a|0)!=2140081935){if((a|0)!=2141891242)break t;l[r>>2]=2143289344,l[r+4>>2]=3;return}l[r>>2]=0,l[r+4>>2]=1;return}l[r>>2]=0,l[r+4>>2]=2;return}if(h=(Dt(2,a),Bt()),h!=h){l[r>>2]=2143289344,l[r+4>>2]=0;return}l[r+4>>2]=a&1073741824?2:1,l[r>>2]=(a&-1073741825)+536870912}function Pp(r){var a=0,h=0,u=0;h=l[r+24>>2];t:{if(!(h&8)||(a=1,(h&7168)==5120)||(a=0,u=l[r+560>>2],h=l[r+556>>2],(u|0)==(h|0)))break t;for(r=u-h>>2,u=r>>>0<=1?1:r,r=0;;){if(a=l[l[h+(r<<2)>>2]+24>>2],a=(a&196608)!=131072&(a&57344)==40960,a)break t;if(r=r+1|0,(u|0)==(r|0))break}}return a}function KE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+220>>2];t:{r:{if(a=l[a+220>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function zE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+200>>2];t:{r:{if(a=l[a+200>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function YE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+204>>2];t:{r:{if(a=l[a+204>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function XE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+208>>2];t:{r:{if(a=l[a+208>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function ZE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+212>>2];t:{r:{if(a=l[a+212>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function qE(r,a){r=r|0,a=a|0;var h=0,u=0,y=m(0);a=l[a>>2],y=I[a+216>>2];t:{r:{if(a=l[a+216>>2],(a|0)!=2139156720){if(u=zt,h=3,(a|0)==2141891242)break t;if((a|0)!=2140081935)break r;u=0,h=1;break t}h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),+Bt()),h=a&1073741824?2:1}a=h,Fe[r+8>>3]=u,l[r>>2]=a}function QE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+260|0,(At[r+300|0]&3)==2)break t;a=r+252|0;break t;case 1:if(a=r+252|0,(At[r+300|0]&3)==2)break t;a=r+260|0;break t;default:break r}a=(r+(a<<2)|0)+252|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function JE(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+276|0,(At[r+300|0]&3)==2)break t;a=r+268|0;break t;case 1:if(a=r+268|0,(At[r+300|0]&3)==2)break t;a=r+276|0;break t;default:break r}a=(r+(a<<2)|0)+268|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function tT(r,a){r=r|0,a=a|0;var h=0;if(h=Et-16|0,Et=h,r=l[r>>2],(a|0)<6){Et=h+16|0;t:{r:switch(a-4|0){case 0:if(a=r+292|0,(At[r+300|0]&3)==2)break t;a=r+284|0;break t;case 1:if(a=r+284|0,(At[r+300|0]&3)==2)break t;a=r+292|0;break t;default:break r}a=(r+(a<<2)|0)+284|0}return+I[a>>2]}l[h>>2]=1872,sr(r,h),qi(),he()}function eT(r,a){r=r|0,a=a|0;var h=0,u=m(0),y=m(0);u=m(zt),a=l[a>>2],y=I[a+40>>2],a=l[a+40>>2],h=3;t:{if((a|0)==2141891242)break t;if((a|0)==2140081935){u=m(0),h=1;break t}if((a|0)==2139156720){u=m(0),h=2;break t}if(h=0,y!=y)break t;u=(Dt(2,(a&-1073741825)+536870912|0),Bt()),h=a&1073741824?2:1}l[r>>2]=h,Fe[r+8>>3]=u}function Hr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(hp)|r!=r||(a=2139156720,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1602224127)),Bt()),a=(Zi(r>m(0xffffff0000000000)||r<m(-0xffffff0000000000)?h:r),te(2)-536870912|1073741824)}return a}function vr(r){var a=0,h=m(0);a=2143289344;t:{if(m(Ge(r))==m(hp)|r!=r||(a=2140081935,r<m(10842021724855044e-35)&r>m(-10842021724855044e-35)|r==m(0)))break t;h=(Dt(2,(Zi(r),te(2)&-2147483648|1610612735)),Bt()),a=(Zi(r>m(36893485948395848e3)||r<m(-36893485948395848e3)?h:r),te(2)-536870912|0)}return a}function iT(r,a){r=r|0,a=a|0;var h=m(0),u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+188>>2];t:{r:{if(r=l[r+188>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=m(zt),(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return m((Dt(2,(r&-1073741825)+536870912|0),Bt()))}h=m(0)}return m(h)}function rT(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0,S=0;return k=Et-16|0,Et=k,S=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(S=l[S+l[a>>2]>>2]),Pt[S|0](k,a,h,u,y,A),r=ht(16),a=l[k+12>>2],l[r+8>>2]=l[k+8>>2],l[r+12>>2]=a,a=l[k+4>>2],l[r>>2]=l[k>>2],l[r+4>>2]=a,Et=k+16|0,r|0}function Op(r,a){t:{if(a){a=t2(l[a>>2]);break t}r:{if(At[7016]){a=l[1753];break r}a=ht(28),l[a+20>>2]=1065353216,l[a+24>>2]=0,l[a+12>>2]=0,l[a+16>>2]=0,l[a>>2]=0,pt[a+8|0]=0,l[a+4>>2]=1,l[1753]=a,pt[7016]=1,l[1752]=l[1752]+1}a=t2(a)}return l[r+4>>2]=0,l[r+8>>2]=0,l[r>>2]=a,l[a>>2]=r,r}function sT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+152>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+152>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function nT(r,a,h){r=r|0,a=a|0,h=+h;var u=0,y=0;t:{if(r=l[r>>2],a=r+(a<<2)|0,y=l[a+188>>2],u=vr(m(h)),(y|0)==(u|0))break t;for(l[a+188>>2]=u;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function aT(r,a){r=r|0,a=a|0;var h=0,u=m(0);r=l[r>>2]+(a<<2)|0,u=I[r+152>>2];t:{r:{if(r=l[r+152>>2],(r|0)==2139156720|(r|0)==2140081935)break r;if(h=zt,(r|0)==2141891242|u!=u)break t;if((r|0)==2139156720)break r;return Dt(2,(r&-1073741825)+536870912|0),+Bt()}h=0}return+h}function oT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>20&3)==(a|0))break t;for(l[r+24>>2]=h&-3145729|a<<20&3145728;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Bn(r,a,h){var u=0,y=0,A=0;t:{if(!a){u=r;break t}for(;u=kp(r,a,10),y=Fi,r=Ih(u,y,246,0)+r|0,h=h-1|0,pt[h|0]=r|48,A=a>>>0>9,r=u,a=y,!!A;);}if(u)for(;h=h-1|0,r=(u>>>0)/10|0,pt[h|0]=Ue(r,246)+u|48,a=u>>>0>9,u=r,!!a;);return h}function lT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>22&1)==(a|0))break t;for(l[r+24>>2]=h&-4194305|a<<22&4194304;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function cT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>18&3)==(a|0))break t;for(l[r+24>>2]=h&-786433|a<<18&786432;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function hT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>16&3)==(a|0))break t;for(l[r+24>>2]=h&-196609|a<<16&196608;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function dT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+224>>2],u==y|u!=u&y!=y)break t;for(I[r+224>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function uT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+28>>2],u==y|u!=u&y!=y)break t;for(I[r+28>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function fT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+32>>2],u==y|u!=u&y!=y)break t;for(I[r+32>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function pT(r,a){r=r|0,a=+a;var h=0,u=m(0),y=m(0);t:{if(u=m(a),r=l[r>>2],y=I[r+36>>2],u==y|u!=u&y!=y)break t;for(I[r+36>>2]=u;;){if(h=At[r+4|0],h&4)break t;if(pt[r+4|0]=h|4,h=l[r+20>>2],h&&Pt[h|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function gT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>4&7)==(a|0))break t;for(l[r+24>>2]=h&-113|a<<4&112;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function mT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=l[r+24>>2],(h>>>2&3)==(a|0))break t;for(l[r+24>>2]=h&-13|a<<2&12;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function vT(r,a){r=r|0,a=a|0;var h=0;t:{if(r=l[r>>2],h=At[r+4|0],((h&2)>>>1|0)==(a|0))break t;for(pt[r+4|0]=h&253|(a?2:0);;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function yT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;return u=Et-16|0,Et=u,y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](u,a,h),r=ht(16),a=l[u+12>>2],l[r+8>>2]=l[u+8>>2],l[r+12>>2]=a,a=l[u+4>>2],l[r>>2]=l[u>>2],l[r+4>>2]=a,Et=u+16|0,r|0}function Mp(r,a){var h=0,u=0;t:{r:{if(h=l[r+556>>2],u=l[r+560>>2],(h|0)==(u|0))break r;for(;;){if(l[h>>2]==(a|0))break r;if(h=h+4|0,(u|0)==(h|0))break}break t}if((h|0)==(u|0))break t;return a=h+4|0,Ps(h,a,u-a|0),l[r+560>>2]=u-4,1}return 0}function bT(r){r=r|0;var a=0,h=0;if(h=Et-16|0,Et=h,r=l[r>>2],l[r+8>>2]){for(;a=At[r+4|0],!!(!(a&4)&&(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],r)););Et=h+16|0;return}l[h>>2]=1024,sr(r,h),qi(),he()}function $p(r,a){var h=0,u=0,y=0;if(pi(+r),u=te(1)|0,y=te(0)|0,h=u>>>20&2047,(h|0)!=2047){if(!h)return r==0?h=0:(r=$p(r*18446744073709552e3,a),h=l[a>>2]+-64|0),l[a>>2]=h,r;l[a>>2]=h-1022,Dt(0,y|0),Dt(1,u&-2146435073|1071644672),r=+Ae()}return r}function AT(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-16|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=ht(16),a=l[h+12>>2],l[r+8>>2]=l[h+8>>2],l[r+12>>2]=a,a=l[h+4>>2],l[r>>2]=l[h>>2],l[r+4>>2]=a,Et=h+16|0,r|0}function el(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+184>>2]==(h|0))break t;for(l[((a<<2)+u|0)+184>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function il(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+192>>2]==(h|0))break t;for(l[((a<<2)+u|0)+192>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Gn(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+176>>2]==(h|0))break t;for(l[((a<<2)+u|0)+176>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Lh(r,a){var h=0,u=0,y=0;t:{if(h=r+24|0,l[h+16>>2]==(a|0))break t;for(u=Pt[9](h)|0,y=a,l[u+16>>2]=y;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Np(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+92>>2]==(h|0))break t;for(l[((a<<2)+u|0)+92>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Ch(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+20>>2]==(h|0))break t;for(l[((a<<2)+u|0)+20>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function Fp(r,a,h){var u=0;t:{if(u=r+24|0,l[(u+(a<<2)|0)+56>>2]==(h|0))break t;for(l[((a<<2)+u|0)+56>>2]=h;;){if(a=At[r+4|0],a&4)break t;if(pt[r+4|0]=a|4,a=l[r+20>>2],a&&Pt[a|0](r),l[r+308>>2]=2143289344,r=l[r+552>>2],!r)break}}}function ET(){for(var r=0,a=0,h=0;a=r<<4,h=a+5968|0,l[a+5972>>2]=h,l[a+5976>>2]=h,r=r+1|0,(r|0)!=64;);Sh(48),l[1756]=16,l[1757]=0,vp(),l[1757]=l[1768],l[1768]=7024,l[1769]=198,l[1770]=0,Rp(),l[1770]=l[1768],l[1768]=7076}function nr(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4288>>2];t:{if((a&-2)==2){r=Ur(r,4,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function rl(r,a){var h=0,u=m(0);r=r+80|0,h=l[(a<<2)+4304>>2];t:{if((a&-2)==2){r=Ur(r,5,h,2143289344);break t}r=Br(r,h,2143289344)}return(r|0)==2139156720|(r|0)==2140081935|(r|0)==2141891242?r=1:(u=(Dt(2,r),Bt()),r=u==u),r}function Ih(r,a,h,u){var y=0,A=0,k=0,S=0,P=0,K=0;return y=h>>>16|0,A=r>>>16|0,K=Ue(y,A),k=h&65535,S=r&65535,P=Ue(k,S),A=(P>>>16|0)+Ue(A,k)|0,y=(A&65535)+Ue(y,S)|0,Fi=(Ue(a,h)+K|0)+Ue(r,u)+(A>>>16)+(y>>>16)|0,P&65535|y<<16}function Up(r,a){var h=0,u=0,y=0;u=Et-16|0,Et=u,h=At[r+4|0],y=h&-17,pt[r+4|0]=y;t:{if(a){if(l[r+560>>2]!=l[r+556>>2])break t;h=y|8}else h=h&231;l[r+8>>2]=a,pt[r+4|0]=h,Et=u+16|0;return}l[u>>2]=4128,sr(r,u),qi(),he()}function Bp(r){var a=0,h=m(0);a=0;t:{if((l[r+24>>2]&196608)==131072)break t;r:{if(!l[r+552>>2]||(h=I[r+32>>2],h!=h&&(h=I[r+28>>2],!(h>m(0)))))break r;if(a=1,h!=m(0))break t}a=Hn(r)!=m(0)}return a}function mi(r,a,h,u,y){var A=0;if(A=Et-256|0,Et=A,!(y&73728|(h|0)<=(u|0))){if(u=h-u|0,h=u>>>0<256,Bi(A,a&255,h?u:256),!h)for(;hi(r,A,256),u=u-256|0,u>>>0>255;);hi(r,A,u)}Et=A+256|0}function fn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=a- -64|0,y=I[u>>2],u=l[u>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4304>>2]<<2)+a|0)+44>>2]}Dp(r,u)}function pn(r,a,h){var u=0,y=m(0);t:{if((h&-2)==2&&(u=l[a+60>>2],y=I[a+60>>2],(u|0)==2139156720|(u|0)==2140081935|(u|0)==2141891242|y==y))break t;u=l[((l[(h<<2)+4288>>2]<<2)+a|0)+44>>2]}Dp(r,u)}function Hn(r){var a=m(0),h=m(0);if(!l[r+552>>2])return m(0);a=I[r+36>>2];t:{if(a==a||(a=m(1),pt[l[r+568>>2]+8|0]&1)||(a=m(0),h=I[r+28>>2],!(h<m(0))))break t;a=m(-h)}return a}function Gp(r){var a=0,h=0,u=0;for(u=l[r>>2];;){if(h=pt[u|0],nl(h)){u=u+1|0,l[r>>2]=u,a>>>0<=214748364?(h=h-48|0,a=Ue(a,10),a=(h|0)>(a^2147483647)?-1:h+a|0):a=-1;continue}break}return a}function Na(r,a,h,u){var y=0;l[r+12>>2]=0,l[r+16>>2]=u;t:{if(a){if(a>>>0>=1073741824)break t;y=ht(a<<2)}return l[r>>2]=y,h=(h<<2)+y|0,l[r+8>>2]=h,l[r+12>>2]=(a<<2)+y,l[r+4>>2]=h,r}$h(),he()}function Hp(r){var a=0;return a=l[r+72>>2],l[r+72>>2]=a-1|a,a=l[r>>2],a&8?(l[r>>2]=a|32,-1):(l[r+4>>2]=0,l[r+8>>2]=0,a=l[r+44>>2],l[r+28>>2]=a,l[r+20>>2]=a,l[r+16>>2]=a+l[r+48>>2],0)}function TT(r,a,h,u,y,A){r=r|0,a=a|0,h=m(h),u=u|0,y=m(y),A=A|0;var k=0;k=Et-16|0,Et=k,a=l[l[a>>2]+4>>2],Pt[l[l[a>>2]+8>>2]](k,a,h,u,y,A),I[r>>2]=Fe[k>>3],I[r+4>>2]=Fe[k+8>>3],Et=k+16|0}function kT(){var r=0,a=0;return a=ht(4),r=ht(28),l[r+20>>2]=1065353216,l[r+24>>2]=0,l[r+12>>2]=0,l[r+16>>2]=0,l[r>>2]=0,pt[r+8|0]=0,l[r+4>>2]=1,l[1752]=l[1752]+1,l[a>>2]=r,a|0}function wT(r,a){r=r|0,a=a|0,a=l[a>>2],Fe[r>>3]=I[a+228>>2],Fe[r+8>>3]=I[a+236>>2],Fe[r+16>>3]=I[a+232>>2],Fe[r+24>>3]=I[a+240>>2],Fe[r+32>>3]=I[a+244>>2],Fe[r+40>>3]=I[a+248>>2]}function ST(r,a){r=r|0,a=a|0;var h=0,u=0;return h=Et-48|0,Et=h,u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](h,a),r=Ui(ht(48),h,48),Et=h+48|0,r|0}function RT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;return y=Et-16|0,Et=y,r=e2(EE(l[r+60>>2],a|0,h|0,u&255,y+8|0)|0),Et=y+16|0,Fi=r?-1:l[y+12>>2],(r?-1:l[y+8>>2])|0}function _T(r,a){r=r|0,a=a|0;var h=0,u=0;h=l[r>>2],r=l[h+556>>2];t:{if(l[h+560>>2]-r>>2>>>0<=a>>>0||(r=l[r+(a<<2)>>2],!r))break t;u=l[r>>2]}return u|0}function LT(r,a,h){if(r=r|0,a=a|0,h=h|0,a>>>0<3){a=1<<a,r=l[r>>2],h?a=a|l[r+12>>2]:a=l[r+12>>2]&(a^-1),l[r+12>>2]=a;return}Ds(),he()}function CT(r,a,h,u,y){r=r|0,a=a|0,h=+h,u=+u,y=y|0;var A=0;A=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(A=l[A+l[a>>2]>>2]),Pt[A|0](a,h,u,y)}function IT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),m(m(Pt[u|0](a,h)))}function Vp(r,a,h,u){r=r|0,a=a|0,h=h|0,u=u|0;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function Wp(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)|0}function xT(r,a,h,u){r=r|0,a=a|0,h=h|0,u=+u;var y=0;y=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(y=l[y+l[a>>2]>>2]),Pt[y|0](a,h,u)}function DT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;return u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),+Pt[u|0](a,h)}function ht(r){var a=0;r=r||1;t:{for(;;){if(a=kh(r),a)break t;if(a=l[2042],a){Pt[a|0]();continue}break}Ds(),he()}return a}function PT(r,a,h){r=r|0,a=a|0,h=m(h);var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function Ms(r,a,h){r=r|0,a=a|0,h=h|0;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function gn(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)|0}function xh(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(gE(r,a))):a}function ce(r,a){return Zi(r),(te(2)&2147483647)>>>0<=2139095040?(Zi(a),(te(2)&2147483647)>>>0>2139095040?r:m(mE(r,a))):a}function jp(r,a){r=r|0,a=a|0;var h=0;return h=Et-16|0,Et=h,l[h+8>>2]=a,r=Pt[r|0](h+8|0)|0,Ma(l[h+8>>2]),Et=h+16|0,r|0}function OT(r,a,h){r=r|0,a=a|0,h=+h;var u=0;u=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(u=l[u+l[a>>2]>>2]),Pt[u|0](a,h)}function MT(r,a,h,u,y){return h=h|0,u=u|0,y=y|0,h&&(h|0)!=5?n2(5816,u,y)|0:n2(5672,u,y)|0}function Kp(r,a){if(!r)return 0;t:{if(!((a&-128)==57216|a>>>0<=127)){l[1781]=25,r=-1;break t}pt[r|0]=a,r=1}return r}function $T(r,a){r=r|0,a=a|0;var h=0;return h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),+Pt[h|0](a)}function zp(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Qo(7035,r|0,7098,4714,196,h|0,7098,4718,197,u|0)}function Vn(r,a){var h=0,u=0;h=ht(4),l[h>>2]=a,u=ht(4),l[u>>2]=a,Qo(7065,r|0,7098,4714,194,h|0,7098,4718,195,u|0)}function Dh(r,a){var h=0;t:{if(pt[7044]&1){h=l[1760];break t}h=dp(1,4464)|0,pt[7044]=1,l[1760]=h}AE(h|0,r|0,a|0,0)}function NT(r,a){r=r|0,a=a|0;var h=0;h=l[r+8>>2],l[r+8>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),l[l[r>>2]+20>>2]=15}function FT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=gp((pt[a+11|0]<0?l[a>>2]:a)|0,7036,l[h>>2])|0,l[u>>2]=y}function UT(r,a,h){r=r|0,a=a|0,h=h|0;var u=0,y=0;u=r,y=gp((pt[a+11|0]<0?l[a>>2]:a)|0,7059,l[h>>2])|0,l[u>>2]=y}function Yp(r,a){r=r|0,a=a|0;var h=0;h=l[r>>2],r=l[r+4>>2],a=(r>>1)+a|0,r&1&&(h=l[h+l[a>>2]>>2]),Pt[h|0](a)}function BT(r){r=r|0;var a=m(0);return r=l[r>>2],a=I[r+36>>2],a!=a&&(a=pt[l[r+568>>2]+8|0]&1?m(1):m(0)),+a}function GT(r,a){r=r|0,a=a|0;var h=0;h=l[r+4>>2],l[r+4>>2]=a,h&&Pt[l[l[h>>2]+4>>2]](h),Up(l[r>>2],14)}function HT(r){r=r|0;var a=0;a=l[r+8>>2],l[r+8>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),l[l[r>>2]+20>>2]=0}function VT(r){r=r|0;var a=0;return a=ht(12),pt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4432,a|0}function WT(r){r=r|0;var a=0;return a=ht(12),pt[a+4|0]=0,l[a+8>>2]=l[r>>2],l[r>>2]=0,l[a>>2]=4552,a|0}function jT(){var r=0;if(r=l[1768],r)for(;Pt[l[r>>2]](),r=l[r+4>>2],!!r;);}function KT(r){r=r|0;var a=0;a=l[r+4>>2],l[r+4>>2]=0,a&&Pt[l[l[a>>2]+4>>2]](a),Up(l[r>>2],0)}function Xp(r){return r=r|0,l[r>>2]=4572,At[r+4|0]&&Dh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function Zp(r){return r=r|0,l[r>>2]=4452,At[r+4|0]&&Dh(l[r+8>>2],1759),Ma(l[r+8>>2]),r|0}function zT(){var r=0;return r=ht(16),l[r>>2]=0,l[r+4>>2]=0,l[r+8>>2]=0,l[r+12>>2]=0,r|0}function qp(r,a,h){return nr(r,a)?Os(r,a,h):(h=$a(r,a,h),h==h&&(h=m(-h)),h)}function Qp(r,a){var h=0;h=Et-16|0,Et=h,r||(l[h>>2]=a,sr(0,h),qi(),he()),Et=h+16|0}function Jp(r){r=r|0;var a=0;r&&(a=l[r>>2],a&&gi(a),l[1752]=l[1752]-1,gi(r))}function YT(r,a){return r=r|0,a=a|0,a>>>0>=3&&(Ds(),he()),l[l[r>>2]+12>>2]>>>a&1}function XT(r,a,h,u,y){return r=r|0,a=a|0,h=h|0,u=u|0,y=y|0,Pt[r|0](a,h,u,y)|0}function ZT(){var r=0;return r=ht(16),l[r+8>>2]=0,l[r+12>>2]=0,l[r>>2]=0,r|0}function qT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+224>>2],+(a!=a?m(zt):a)}function QT(r){return r=r|0,r=l[l[r>>2]+552>>2],r?l[r>>2]:0}function JT(r){r=r|0;var a=m(0);return a=I[l[r>>2]+32>>2],+(a==a?a:m(0))}function t2(r){var a=0;return a=bp(ht(588),r),Qp((r|0)!=0,2808),a}function t3(r,a){r=r|0,a=a|0,r=l[r>>2],l[r+16>>2]=l[r+16>>2]&-2|a}function e3(r){return r=r|0,r=l[r>>2],l[r+560>>2]-l[r+556>>2]>>2}function i3(r,a){r=r|0,a=a|0,r=l[r>>2],pt[r+8|0]=At[r+8|0]&254|a}function r3(r){r=r|0,r=l[l[r>>2]+8>>2],Pt[l[l[r>>2]+8>>2]](r)}function s3(r,a,h){r=r|0,a=a|0,h=+h,Ch(l[r>>2],a,vr(m(h)))}function n3(r,a,h){r=r|0,a=a|0,h=+h,Ch(l[r>>2],a,Hr(m(h)))}function a3(r,a,h,u){return Fi=0,0}function o3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,vr(m(h)))}function l3(r,a,h){r=r|0,a=a|0,h=+h,Np(l[r>>2],a,Hr(m(h)))}function c3(r,a,h){r=r|0,a=a|0,h=+h,Fp(l[r>>2],a,vr(m(h)))}function h3(r,a,h){r=r|0,a=a|0,h=+h,Fp(l[r>>2],a,Hr(m(h)))}function d3(r,a,h){r=r|0,a=a|0,h=h|0,l[l[r>>2]+a>>2]=h}function u3(r,a){r=r|0,a=a|0,Ch(l[r>>2],a,2141891242)}function Ph(r,a,h){r=r|0,a=a|0,h=+h,Fe[l[r>>2]+a>>3]=h}function f3(r){return r=r|0,(At[l[r>>2]+4|0]&2)>>>1|0}function p3(r){return r=r|0,(At[l[r>>2]+4|0]&4)>>>2|0}function g3(r,a){r=r|0,a=a|0,l[r+4>>2]=10,l[r>>2]=a}function m3(r,a){r=r|0,a=a|0,l[r+4>>2]=13,l[r>>2]=a}function v3(r){return r=r|0,l[l[r>>2]+24>>2]>>>10&7}function y3(r){return r=r|0,l[l[r>>2]+24>>2]>>>13&7}function Oh(r,a){return r=r|0,a=a|0,+Fe[l[r>>2]+a>>3]}function b3(r){return r=r|0,l[l[r>>2]+24>>2]>>>18&3}function A3(r){return r=r|0,l[l[r>>2]+24>>2]>>>20&3}function E3(r){return r=r|0,l[l[r>>2]+24>>2]>>>22&1}function T3(r,a){return r=r|0,a=a|0,l[l[r>>2]+a>>2]}function k3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,vr(m(a)))}function w3(r,a){r=r|0,a=+a,Gn(l[r>>2],0,Hr(m(a)))}function S3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,vr(m(a)))}function R3(r,a){r=r|0,a=+a,Gn(l[r>>2],1,Hr(m(a)))}function _3(r,a){r=r|0,a=a|0,l[r+4>>2]=7,l[r>>2]=a}function L3(r,a){r=r|0,a=+a,el(l[r>>2],0,vr(m(a)))}function C3(r,a){r=r|0,a=+a,el(l[r>>2],0,Hr(m(a)))}function I3(r,a){r=r|0,a=+a,el(l[r>>2],1,vr(m(a)))}function x3(r,a){r=r|0,a=+a,el(l[r>>2],1,Hr(m(a)))}function D3(r,a){r=r|0,a=+a,il(l[r>>2],0,vr(m(a)))}function P3(r,a){r=r|0,a=+a,il(l[r>>2],1,vr(m(a)))}function O3(r,a){r=r|0,a=+a,il(l[r>>2],1,Hr(m(a)))}function M3(r){return r=r|0,l[l[r>>2]+24>>2]>>>7&7}function $3(r){return r=r|0,l[l[r>>2]+24>>2]>>>2&3}function N3(r){return r=r|0,l[l[r>>2]+24>>2]>>>4&7}function sl(r){r=r|0,r&&Pt[l[l[r>>2]+4>>2]](r)}function F3(r,a){r=r|0,a=+a,il(l[r>>2],0,Hr(m(a)))}function e2(r){return r?(l[1781]=r,-1):0}function U3(r,a){r=r|0,a=+a,Lh(l[r>>2],vr(m(a)))}function B3(r,a){r=r|0,a=+a,Lh(l[r>>2],Hr(m(a)))}function i2(r,a,h){return m(de(r,a,h)+we(r,a,h))}function G3(r,a){return r=r|0,a=a|0,Pt[r|0](a)|0}function r2(r,a,h,u){TE(r|0,a|0,8,0,h|0,-1,u|0)}function H3(r,a){r=r|0,a=a|0,l[l[r>>2]+16>>2]=a}function V3(r){return r=r|0,l[l[r>>2]+16>>2]&1}function W3(r){return r=r|0,Nn[l[r>>2]+26>>1]&3}function j3(r){r=r|0,Gn(l[r>>2],0,2141891242)}function K3(r){r=r|0,Gn(l[r>>2],1,2141891242)}function z3(r){return r=r|0,+I[l[r>>2]+228>>2]}function Y3(r){return r=r|0,+I[l[r>>2]+236>>2]}function X3(r){return r=r|0,+I[l[r>>2]+232>>2]}function Z3(r){return r=r|0,+I[l[r>>2]+240>>2]}function q3(r){return r=r|0,+I[l[r>>2]+244>>2]}function Q3(r){return r=r|0,+I[l[r>>2]+248>>2]}function J3(r){return r=r|0,RE(l[r+60>>2])|0}function tk(r){return r=r|0,l[l[r>>2]+16>>2]}function ek(r){return r=r|0,pt[l[r>>2]+8|0]&1}function ik(r,a){r=r|0,a=a|0,_h(l[r>>2],5,a)}function rk(r,a){r=r|0,a=a|0,_h(l[r>>2],6,a)}function sk(r,a){r=r|0,a=a|0,_h(l[r>>2],7,a)}function nk(r){r=r|0,Lh(l[r>>2],2141891242)}function s2(r,a){r=r|0,a=a|0,Pt[l[r>>2]](a)}function ak(r){return r=r|0,Op(ht(12),r)|0}function ok(r){r=r|0,Dh(l[r+8>>2],3293)}function n2(r,a,h){return Cp(r,a,h,2,3)}function a2(r){return r=r|0,Pt[r|0]()|0}function o2(r,a){r=r|0,a=a|0,Pt[r|0](a)}function lk(){return Bi(ht(48),0,48)|0}function qi(){Pt[l[1490]](),$h(),he()}function ck(){return Op(ht(12),0)|0}function Mh(r){r=r|0,r&&gi(r)}function nl(r){return r-48>>>0<10}function hk(r){return 7032}function dk(r){return 7036}function uk(r){return 7056}function fk(r){return 7059}function pk(r){return 7062}function gk(r){return 7067}function Sr(r){return r=r|0,r|0}function l2(r){r=r|0,pt[r+4|0]=1}function mk(r){r=r|0,gi(Xp(r))}function vk(r){r=r|0,gi(Zp(r))}function yk(r){return 0}function c2(r){he()}function h2(){$h(),he()}function $h(){Ds(),he()}G=At,Rt();var Pt=B([null,MT,IE,PE,Sr,_3,g3,m3,Sr,Sr,Sr,Sr,Sr,Sr,TT,r3,vp,hk,sl,rT,dk,Sr,Sr,sl,l2,s2,jp,VT,GE,FT,uk,sl,Yp,fk,Sr,Sr,sl,l2,s2,jp,WT,UT,pk,Jp,a2,kT,o2,Jp,LT,Vp,UE,PT,t3,Ms,H3,Ms,i3,YT,Wp,V3,gn,tk,gn,ek,lk,Mh,zT,Mh,ZT,Mh,Oh,Ph,T3,d3,gk,Sp,a2,ck,G3,ak,o2,Sp,$E,Yp,DE,Ms,hT,Ms,c3,xT,h3,ik,rk,sk,mT,cT,gT,s3,n3,u3,oT,lT,uT,OT,U3,B3,nk,fT,pT,k3,w3,j3,S3,R3,K3,L3,C3,I3,x3,D3,F3,P3,O3,dT,sT,o3,l3,nT,W3,gn,WE,yT,M3,v3,y3,$3,b3,N3,jE,eT,AT,JT,$T,BT,zE,YE,XE,ZE,qE,KE,qT,aT,DT,A3,E3,VE,iT,IT,OE,Vp,ME,Ms,e3,gn,QT,gn,_T,Wp,f3,gn,vT,Ms,GT,Ms,KT,NT,Ms,HT,bT,p3,gn,xE,CT,z3,Y3,X3,Z3,q3,Q3,wT,ST,QE,JE,tT,Oh,Ph,Oh,Ph,Rp,Zp,vk,BE,c2,h2,Xp,mk,ok,c2,J3,NE,RT,yk,a3,HE,h2]);function d2(){return Ni.byteLength/65536|0}function bk(r){r=r|0;var a=d2()|0,h=a+r|0;if(a<h&&h<65536){var u=new ArrayBuffer(Ue(h,65536)),y=new Int8Array(u);y.set(pt),pt=new Int8Array(u),Fr=new Int16Array(u),l=new Int32Array(u),At=new Uint8Array(u),Nn=new Uint16Array(u),cp=new Uint32Array(u),I=new Float32Array(u),Fe=new Float64Array(u),Ni=u,rr.buffer=Ni,G=At}return a}return{E:ET,F:FE,G:jT,H:kh,I:Pt,J:gi,K:XT}}return qo(L)}(_)}var C=Error,D={};b=[],typeof D!="object"&&xt("no native wasm support detected");var O,F=!1;function x(_,L,B){B=L+B;for(var G="";!(L>=B);){var it=_[L++];if(!it)break;if(it&128){var vt=_[L++]&63;if((it&224)==192)G+=String.fromCharCode((it&31)<<6|vt);else{var lt=_[L++]&63;it=(it&240)==224?(it&15)<<12|vt<<6|lt:(it&7)<<18|vt<<12|lt<<6|_[L++]&63,65536>it?G+=String.fromCharCode(it):(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023))}}else G+=String.fromCharCode(it)}return G}var N,H,j,nt,st,Q,kt,gt,Mt;function Vt(_){N=_,o.HEAP8=H=new Int8Array(_),o.HEAP16=nt=new Int16Array(_),o.HEAP32=Q=new Int32Array(_),o.HEAPU8=j=new Uint8Array(_),o.HEAPU16=st=new Uint16Array(_),o.HEAPU32=kt=new Uint32Array(_),o.HEAPF32=gt=new Float32Array(_),o.HEAPF64=Mt=new Float64Array(_)}var V=o.INITIAL_MEMORY||16777216;o.wasmMemory?O=o.wasmMemory:O=new E,O&&(N=O.buffer),V=N.byteLength,Vt(N);var J,St=[],$=[],U=[];function Z(){var _=o.preRun.shift();St.unshift(_)}var ft=0,bt=null;function xt(_){throw o.onAbort&&o.onAbort(_),_="Aborted("+_+")",v(_),F=!0,_=new C(_+". Build with -sASSERTIONS for more info."),d(_),_}function Ut(_){return _.startsWith("data:application/octet-stream;base64,")}var Qt;if(Qt="<<< WASM_BINARY_FILE >>>",!Ut(Qt)){var ue=Qt;Qt=o.locateFile?o.locateFile(ue,p):p+ue}function se(_){var L=Qt;try{try{if(L==Qt&&b)new Uint8Array(b);else{if(Ut(L)){try{var B=uE(L.slice(37)),G=new Uint8Array(B.length);for(L=0;L<B.length;++L)G[L]=B.charCodeAt(L);var it=G}catch{throw Error("Converting base64 string to bytes failed.")}var vt=it}else vt=void 0;if(!vt)throw"sync fetching of the wasm failed: you can preload it to Module['wasmBinary'] manually, or emcc.py will do that for you when generating HTML (but not JS)"}}catch(Lt){xt(Lt)}var lt=new T,Rt=new w(_)}catch(Lt){throw _=Lt.toString(),v("failed to compile wasm module: "+_),(_.includes("imported Memory")||_.includes("memory import"))&&v("Memory size incompatibility issues may be due to changing INITIAL_MEMORY at runtime to something too large. Use ALLOW_MEMORY_GROWTH to allow any size memory (and also make sure not to set INITIAL_MEMORY at runtime to something smaller than it was at compile time)."),Lt}return[Rt,lt]}function Yt(_){for(;0<_.length;)_.shift()(o)}function Me(_){if(_===void 0)return"_unknown";_=_.replace(/[^a-zA-Z0-9_]/g,"$");var L=_.charCodeAt(0);return 48<=L&&57>=L?"_"+_:_}function be(_,L){return _=Me(_),function(){return L.apply(this,arguments)}}var jt=[{},{value:void 0},{value:null},{value:!0},{value:!1}],ge=[];function oe(_){var L=Error,B=be(_,function(G){this.name=_,this.message=G,G=Error(G).stack,G!==void 0&&(this.stack=this.toString()+`
90
+ `+G.replace(/^Error(:[^\n]*)?\n/,""))});return B.prototype=Object.create(L.prototype),B.prototype.constructor=B,B.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},B}var Ce=void 0;function Ft(_){throw new Ce(_)}var Xe=_=>(_||Ft("Cannot use deleted val. handle = "+_),jt[_].value),qe=_=>{switch(_){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var L=ge.length?ge.pop():jt.length;return jt[L]={fa:1,value:_},L}},$i=void 0,Tr=void 0;function ke(_){for(var L="";j[_];)L+=Tr[j[_++]];return L}var li=[];function me(){for(;li.length;){var _=li.pop();_.L.Z=!1,_.delete()}}var Je=void 0,ti={};function Xi(_,L){for(L===void 0&&Ft("ptr should not be undefined");_.P;)L=_.aa(L),_=_.P;return L}var Ne={};function Ci(_){_=pE(_);var L=ke(_);return xs(_),L}function ss(_,L){var B=Ne[_];return B===void 0&&Ft(L+" has unknown type "+Ci(_)),B}function ci(){}var kr=!1;function _s(_){--_.count.value,_.count.value===0&&(_.S?_.T.V(_.S):_.O.M.V(_.N))}function Ls(_,L,B){return L===B?_:B.P===void 0?null:(_=Ls(_,L,B.P),_===null?null:B.ma(_))}var ir={};function ct(_,L){return L=Xi(_,L),ti[L]}var Gt=void 0;function Xt(_){throw new Gt(_)}function ve(_,L){return L.O&&L.N||Xt("makeClassHandle requires ptr and ptrType"),!!L.T!=!!L.S&&Xt("Both smartPtrType and smartPtr must be specified"),L.count={value:1},ae(Object.create(_,{L:{value:L}}))}function ae(_){return typeof FinalizationRegistry>"u"?(ae=L=>L,_):(kr=new FinalizationRegistry(L=>{_s(L.L)}),ae=L=>{var B=L.L;return B.S&&kr.register(L,{L:B},L),L},ci=L=>{kr.unregister(L)},ae(_))}var ni={};function Ii(_){for(;_.length;){var L=_.pop();_.pop()(L)}}function ur(_){return this.fromWireType(Q[_>>2])}var ns={},fr={};function pr(_,L,B){function G(Rt){Rt=B(Rt),Rt.length!==_.length&&Xt("Mismatched type converter count");for(var Lt=0;Lt<_.length;++Lt)xi(_[Lt],Rt[Lt])}_.forEach(function(Rt){fr[Rt]=L});var it=Array(L.length),vt=[],lt=0;L.forEach((Rt,Lt)=>{Ne.hasOwnProperty(Rt)?it[Lt]=Ne[Rt]:(vt.push(Rt),ns.hasOwnProperty(Rt)||(ns[Rt]=[]),ns[Rt].push(()=>{it[Lt]=Ne[Rt],++lt,lt===vt.length&&G(it)}))}),vt.length===0&&G(it)}function Cs(_){switch(_){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+_)}}function xi(_,L,B={}){if(!("argPackAdvance"in L))throw new TypeError("registerType registeredInstance requires argPackAdvance");var G=L.name;if(_||Ft('type "'+G+'" must have a positive integer typeid pointer'),Ne.hasOwnProperty(_)){if(B.ta)return;Ft("Cannot register type '"+G+"' twice")}Ne[_]=L,delete fr[_],ns.hasOwnProperty(_)&&(L=ns[_],delete ns[_],L.forEach(it=>it()))}function Oa(_){Ft(_.L.O.M.name+" instance already deleted")}function gr(){}function Is(_,L,B){if(_[L].R===void 0){var G=_[L];_[L]=function(){return _[L].R.hasOwnProperty(arguments.length)||Ft("Function '"+B+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+_[L].R+")!"),_[L].R[arguments.length].apply(this,arguments)},_[L].R=[],_[L].R[G.Y]=G}}function zA(_,L){o.hasOwnProperty(_)?(Ft("Cannot register public name '"+_+"' twice"),Is(o,_,_),o.hasOwnProperty(void 0)&&Ft("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),o[_].R[void 0]=L):o[_]=L}function YA(_,L,B,G,it,vt,lt,Rt){this.name=_,this.constructor=L,this.W=B,this.V=G,this.P=it,this.oa=vt,this.aa=lt,this.ma=Rt,this.ia=[]}function gh(_,L,B){for(;L!==B;)L.aa||Ft("Expected null or instance of "+B.name+", got an instance of "+L.name),_=L.aa(_),L=L.P;return _}function XA(_,L){return L===null?(this.da&&Ft("null is not a valid "+this.name),0):(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),gh(L.L.N,L.L.O.M,this.M))}function ZA(_,L){if(L===null){if(this.da&&Ft("null is not a valid "+this.name),this.ca){var B=this.ea();return _!==null&&_.push(this.V,B),B}return 0}if(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),!this.ba&&L.L.O.ba&&Ft("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name),B=gh(L.L.N,L.L.O.M,this.M),this.ca)switch(L.L.S===void 0&&Ft("Passing raw pointer to smart pointer is illegal"),this.Aa){case 0:L.L.T===this?B=L.L.S:Ft("Cannot convert argument of type "+(L.L.T?L.L.T.name:L.L.O.name)+" to parameter type "+this.name);break;case 1:B=L.L.S;break;case 2:if(L.L.T===this)B=L.L.S;else{var G=L.clone();B=this.wa(B,qe(function(){G.delete()})),_!==null&&_.push(this.V,B)}break;default:Ft("Unsupporting sharing policy")}return B}function qA(_,L){return L===null?(this.da&&Ft("null is not a valid "+this.name),0):(L.L||Ft('Cannot pass "'+bh(L)+'" as a '+this.name),L.L.N||Ft("Cannot pass deleted object as a pointer of type "+this.name),L.L.O.ba&&Ft("Cannot convert argument of type "+L.L.O.name+" to parameter type "+this.name),gh(L.L.N,L.L.O.M,this.M))}function as(_,L,B,G){this.name=_,this.M=L,this.da=B,this.ba=G,this.ca=!1,this.V=this.wa=this.ea=this.ja=this.Aa=this.va=void 0,L.P!==void 0?this.toWireType=ZA:(this.toWireType=G?XA:qA,this.U=null)}function QA(_,L){o.hasOwnProperty(_)||Xt("Replacing nonexistant public symbol"),o[_]=L,o[_].Y=void 0}function JA(_,L){var B=[];return function(){if(B.length=0,Object.assign(B,arguments),_.includes("j")){var G=o["dynCall_"+_];G=B&&B.length?G.apply(null,[L].concat(B)):G.call(null,L)}else G=J.get(L).apply(null,B);return G}}function wr(_,L){_=ke(_);var B=_.includes("j")?JA(_,L):J.get(L);return typeof B!="function"&&Ft("unknown function pointer with signature "+_+": "+L),B}var rp=void 0;function zo(_,L){function B(vt){it[vt]||Ne[vt]||(fr[vt]?fr[vt].forEach(B):(G.push(vt),it[vt]=!0))}var G=[],it={};throw L.forEach(B),new rp(_+": "+G.map(Ci).join([", "]))}function mh(_,L,B,G,it){var vt=L.length;2>vt&&Ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var lt=L[1]!==null&&B!==null,Rt=!1;for(B=1;B<L.length;++B)if(L[B]!==null&&L[B].U===void 0){Rt=!0;break}var Lt=L[0].name!=="void",Ct=vt-2,Nt=Array(Ct),Kt=[],te=[];return function(){if(arguments.length!==Ct&&Ft("function "+_+" called with "+arguments.length+" arguments, expected "+Ct+" args!"),te.length=0,Kt.length=lt?2:1,Kt[0]=it,lt){var Dt=L[1].toWireType(te,this);Kt[1]=Dt}for(var Ae=0;Ae<Ct;++Ae)Nt[Ae]=L[Ae+2].toWireType(te,arguments[Ae]),Kt.push(Nt[Ae]);if(Ae=G.apply(null,Kt),Rt)Ii(te);else for(var pi=lt?1:2;pi<L.length;pi++){var he=pi===1?Dt:Nt[pi-2];L[pi].U!==null&&L[pi].U(he)}return Dt=Lt?L[0].fromWireType(Ae):void 0,Dt}}function vh(_,L){for(var B=[],G=0;G<_;G++)B.push(kt[L+4*G>>2]);return B}function yh(_){4<_&&--jt[_].fa===0&&(jt[_]=void 0,ge.push(_))}function bh(_){if(_===null)return"null";var L=typeof _;return L==="object"||L==="array"||L==="function"?_.toString():""+_}function tE(_,L){switch(L){case 2:return function(B){return this.fromWireType(gt[B>>2])};case 3:return function(B){return this.fromWireType(Mt[B>>3])};default:throw new TypeError("Unknown float type: "+_)}}function eE(_,L,B){switch(L){case 0:return B?function(G){return H[G]}:function(G){return j[G]};case 1:return B?function(G){return nt[G>>1]}:function(G){return st[G>>1]};case 2:return B?function(G){return Q[G>>2]}:function(G){return kt[G>>2]};default:throw new TypeError("Unknown integer type: "+_)}}function iE(_,L){for(var B="",G=0;!(G>=L/2);++G){var it=nt[_+2*G>>1];if(it==0)break;B+=String.fromCharCode(it)}return B}function rE(_,L,B){if(B===void 0&&(B=2147483647),2>B)return 0;B-=2;var G=L;B=B<2*_.length?B/2:_.length;for(var it=0;it<B;++it)nt[L>>1]=_.charCodeAt(it),L+=2;return nt[L>>1]=0,L-G}function sE(_){return 2*_.length}function nE(_,L){for(var B=0,G="";!(B>=L/4);){var it=Q[_+4*B>>2];if(it==0)break;++B,65536<=it?(it-=65536,G+=String.fromCharCode(55296|it>>10,56320|it&1023)):G+=String.fromCharCode(it)}return G}function aE(_,L,B){if(B===void 0&&(B=2147483647),4>B)return 0;var G=L;B=G+B-4;for(var it=0;it<_.length;++it){var vt=_.charCodeAt(it);if(55296<=vt&&57343>=vt){var lt=_.charCodeAt(++it);vt=65536+((vt&1023)<<10)|lt&1023}if(Q[L>>2]=vt,L+=4,L+4>B)break}return Q[L>>2]=0,L-G}function oE(_){for(var L=0,B=0;B<_.length;++B){var G=_.charCodeAt(B);55296<=G&&57343>=G&&++B,L+=4}return L}var lE={};function sp(_){var L=lE[_];return L===void 0?ke(_):L}var Yo=[];function cE(_){var L=Yo.length;return Yo.push(_),L}function hE(_,L){for(var B=Array(_),G=0;G<_;++G)B[G]=ss(kt[L+4*G>>2],"parameter "+G);return B}var np=[],dE=[null,[],[]];Ce=o.BindingError=oe("BindingError"),o.count_emval_handles=function(){for(var _=0,L=5;L<jt.length;++L)jt[L]!==void 0&&++_;return _},o.get_first_emval=function(){for(var _=5;_<jt.length;++_)if(jt[_]!==void 0)return jt[_];return null},$i=o.PureVirtualError=oe("PureVirtualError");for(var ap=Array(256),Xo=0;256>Xo;++Xo)ap[Xo]=String.fromCharCode(Xo);Tr=ap,o.getInheritedInstanceCount=function(){return Object.keys(ti).length},o.getLiveInheritedInstances=function(){var _=[],L;for(L in ti)ti.hasOwnProperty(L)&&_.push(ti[L]);return _},o.flushPendingDeletes=me,o.setDelayFunction=function(_){Je=_,li.length&&Je&&Je(me)},Gt=o.InternalError=oe("InternalError"),gr.prototype.isAliasOf=function(_){if(!(this instanceof gr&&_ instanceof gr))return!1;var L=this.L.O.M,B=this.L.N,G=_.L.O.M;for(_=_.L.N;L.P;)B=L.aa(B),L=L.P;for(;G.P;)_=G.aa(_),G=G.P;return L===G&&B===_},gr.prototype.clone=function(){if(this.L.N||Oa(this),this.L.$)return this.L.count.value+=1,this;var _=ae,L=Object,B=L.create,G=Object.getPrototypeOf(this),it=this.L;return _=_(B.call(L,G,{L:{value:{count:it.count,Z:it.Z,$:it.$,N:it.N,O:it.O,S:it.S,T:it.T}}})),_.L.count.value+=1,_.L.Z=!1,_},gr.prototype.delete=function(){this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),ci(this),_s(this.L),this.L.$||(this.L.S=void 0,this.L.N=void 0)},gr.prototype.isDeleted=function(){return!this.L.N},gr.prototype.deleteLater=function(){return this.L.N||Oa(this),this.L.Z&&!this.L.$&&Ft("Object already scheduled for deletion"),li.push(this),li.length===1&&Je&&Je(me),this.L.Z=!0,this},as.prototype.pa=function(_){return this.ja&&(_=this.ja(_)),_},as.prototype.ga=function(_){this.V&&this.V(_)},as.prototype.argPackAdvance=8,as.prototype.readValueFromPointer=ur,as.prototype.deleteObject=function(_){_!==null&&_.delete()},as.prototype.fromWireType=function(_){function L(){return this.ca?ve(this.M.W,{O:this.va,N:B,T:this,S:_}):ve(this.M.W,{O:this,N:_})}var B=this.pa(_);if(!B)return this.ga(_),null;var G=ct(this.M,B);if(G!==void 0)return G.L.count.value===0?(G.L.N=B,G.L.S=_,G.clone()):(G=G.clone(),this.ga(_),G);if(G=this.M.oa(B),G=ir[G],!G)return L.call(this);G=this.ba?G.ka:G.pointerType;var it=Ls(B,this.M,G.M);return it===null?L.call(this):this.ca?ve(G.M.W,{O:G,N:it,T:this,S:_}):ve(G.M.W,{O:G,N:it})},rp=o.UnboundTypeError=oe("UnboundTypeError");var uE=typeof atob=="function"?atob:function(_){var L="",B=0;_=_.replace(/[^A-Za-z0-9\+\/=]/g,"");do{var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),it="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),vt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++)),lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(_.charAt(B++));G=G<<2|it>>4,it=(it&15)<<4|vt>>2;var Rt=(vt&3)<<6|lt;L+=String.fromCharCode(G),vt!==64&&(L+=String.fromCharCode(it)),lt!==64&&(L+=String.fromCharCode(Rt))}while(B<_.length);return L},fE={q:function(_,L,B){_=ke(_),L=ss(L,"wrapper"),B=Xe(B);var G=[].slice,it=L.M,vt=it.W,lt=it.P.W,Rt=it.P.constructor;_=be(_,function(){it.P.ia.forEach((function(Ct){if(this[Ct]===lt[Ct])throw new $i("Pure virtual function "+Ct+" must be implemented in JavaScript")}).bind(this)),Object.defineProperty(this,"__parent",{value:vt}),this.__construct.apply(this,G.call(arguments))}),vt.__construct=function(){this===vt&&Ft("Pass correct 'this' to __construct");var Ct=Rt.implement.apply(void 0,[this].concat(G.call(arguments)));ci(Ct);var Nt=Ct.L;Ct.notifyOnDestruction(),Nt.$=!0,Object.defineProperties(this,{L:{value:Nt}}),ae(this),Ct=Nt.N,Ct=Xi(it,Ct),ti.hasOwnProperty(Ct)?Ft("Tried to register registered instance: "+Ct):ti[Ct]=this},vt.__destruct=function(){this===vt&&Ft("Pass correct 'this' to __destruct"),ci(this);var Ct=this.L.N;Ct=Xi(it,Ct),ti.hasOwnProperty(Ct)?delete ti[Ct]:Ft("Tried to unregister unregistered instance: "+Ct)},_.prototype=Object.create(vt);for(var Lt in B)_.prototype[Lt]=B[Lt];return qe(_)},k:function(_){var L=ni[_];delete ni[_];var B=L.ea,G=L.V,it=L.ha,vt=it.map(lt=>lt.sa).concat(it.map(lt=>lt.ya));pr([_],vt,lt=>{var Rt={};return it.forEach((Lt,Ct)=>{var Nt=lt[Ct],Kt=Lt.qa,te=Lt.ra,Dt=lt[Ct+it.length],Ae=Lt.xa,pi=Lt.za;Rt[Lt.na]={read:he=>Nt.fromWireType(Kt(te,he)),write:(he,Zi)=>{var Bt=[];Ae(pi,he,Dt.toWireType(Bt,Zi)),Ii(Bt)}}}),[{name:L.name,fromWireType:function(Lt){var Ct={},Nt;for(Nt in Rt)Ct[Nt]=Rt[Nt].read(Lt);return G(Lt),Ct},toWireType:function(Lt,Ct){for(var Nt in Rt)if(!(Nt in Ct))throw new TypeError('Missing field: "'+Nt+'"');var Kt=B();for(Nt in Rt)Rt[Nt].write(Kt,Ct[Nt]);return Lt!==null&&Lt.push(G,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:G}]})},w:function(){},C:function(_,L,B,G,it){var vt=Cs(B);L=ke(L),xi(_,{name:L,fromWireType:function(lt){return!!lt},toWireType:function(lt,Rt){return Rt?G:it},argPackAdvance:8,readValueFromPointer:function(lt){if(B===1)var Rt=H;else if(B===2)Rt=nt;else if(B===4)Rt=Q;else throw new TypeError("Unknown boolean type size: "+L);return this.fromWireType(Rt[lt>>vt])},U:null})},g:function(_,L,B,G,it,vt,lt,Rt,Lt,Ct,Nt,Kt,te){Nt=ke(Nt),vt=wr(it,vt),Rt&&(Rt=wr(lt,Rt)),Ct&&(Ct=wr(Lt,Ct)),te=wr(Kt,te);var Dt=Me(Nt);zA(Dt,function(){zo("Cannot construct "+Nt+" due to unbound types",[G])}),pr([_,L,B],G?[G]:[],function(Ae){if(Ae=Ae[0],G)var pi=Ae.M,he=pi.W;else he=gr.prototype;Ae=be(Dt,function(){if(Object.getPrototypeOf(this)!==Zi)throw new Ce("Use 'new' to construct "+Nt);if(Bt.X===void 0)throw new Ce(Nt+" has no accessible constructor");var ei=Bt.X[arguments.length];if(ei===void 0)throw new Ce("Tried to invoke ctor of "+Nt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(Bt.X).toString()+") parameters instead!");return ei.apply(this,arguments)});var Zi=Object.create(he,{constructor:{value:Ae}});Ae.prototype=Zi;var Bt=new YA(Nt,Ae,Zi,te,pi,vt,Rt,Ct);pi=new as(Nt,Bt,!0,!1),he=new as(Nt+"*",Bt,!1,!1);var qo=new as(Nt+" const*",Bt,!1,!0);return ir[_]={pointerType:he,ka:qo},QA(Dt,Ae),[pi,he,qo]})},d:function(_,L,B,G,it,vt,lt){var Rt=vh(B,G);L=ke(L),vt=wr(it,vt),pr([],[_],function(Lt){function Ct(){zo("Cannot call "+Nt+" due to unbound types",Rt)}Lt=Lt[0];var Nt=Lt.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]);var Kt=Lt.M.constructor;return Kt[L]===void 0?(Ct.Y=B-1,Kt[L]=Ct):(Is(Kt,L,Nt),Kt[L].R[B-1]=Ct),pr([],Rt,function(te){return te=mh(Nt,[te[0],null].concat(te.slice(1)),null,vt,lt),Kt[L].R===void 0?(te.Y=B-1,Kt[L]=te):Kt[L].R[B-1]=te,[]}),[]})},p:function(_,L,B,G,it,vt){0<L||xt();var lt=vh(L,B);it=wr(G,it),pr([],[_],function(Rt){Rt=Rt[0];var Lt="constructor "+Rt.name;if(Rt.M.X===void 0&&(Rt.M.X=[]),Rt.M.X[L-1]!==void 0)throw new Ce("Cannot register multiple constructors with identical number of parameters ("+(L-1)+") for class '"+Rt.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Rt.M.X[L-1]=()=>{zo("Cannot construct "+Rt.name+" due to unbound types",lt)},pr([],lt,function(Ct){return Ct.splice(1,0,null),Rt.M.X[L-1]=mh(Lt,Ct,null,it,vt),[]}),[]})},b:function(_,L,B,G,it,vt,lt,Rt){var Lt=vh(B,G);L=ke(L),vt=wr(it,vt),pr([],[_],function(Ct){function Nt(){zo("Cannot call "+Kt+" due to unbound types",Lt)}Ct=Ct[0];var Kt=Ct.name+"."+L;L.startsWith("@@")&&(L=Symbol[L.substring(2)]),Rt&&Ct.M.ia.push(L);var te=Ct.M.W,Dt=te[L];return Dt===void 0||Dt.R===void 0&&Dt.className!==Ct.name&&Dt.Y===B-2?(Nt.Y=B-2,Nt.className=Ct.name,te[L]=Nt):(Is(te,L,Kt),te[L].R[B-2]=Nt),pr([],Lt,function(Ae){return Ae=mh(Kt,Ae,Ct,vt,lt),te[L].R===void 0?(Ae.Y=B-2,te[L]=Ae):te[L].R[B-2]=Ae,[]}),[]})},B:function(_,L){L=ke(L),xi(_,{name:L,fromWireType:function(B){var G=Xe(B);return yh(B),G},toWireType:function(B,G){return qe(G)},argPackAdvance:8,readValueFromPointer:ur,U:null})},n:function(_,L,B){B=Cs(B),L=ke(L),xi(_,{name:L,fromWireType:function(G){return G},toWireType:function(G,it){return it},argPackAdvance:8,readValueFromPointer:tE(L,B),U:null})},e:function(_,L,B,G,it){L=ke(L),it===-1&&(it=4294967295),it=Cs(B);var vt=Rt=>Rt;if(G===0){var lt=32-8*B;vt=Rt=>Rt<<lt>>>lt}B=L.includes("unsigned")?function(Rt,Lt){return Lt>>>0}:function(Rt,Lt){return Lt},xi(_,{name:L,fromWireType:vt,toWireType:B,argPackAdvance:8,readValueFromPointer:eE(L,it,G!==0),U:null})},c:function(_,L,B){function G(vt){vt>>=2;var lt=kt;return new it(N,lt[vt+1],lt[vt])}var it=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][L];B=ke(B),xi(_,{name:B,fromWireType:G,argPackAdvance:8,readValueFromPointer:G},{ta:!0})},o:function(_,L){L=ke(L);var B=L==="std::string";xi(_,{name:L,fromWireType:function(G){var it=kt[G>>2],vt=G+4;if(B)for(var lt=vt,Rt=0;Rt<=it;++Rt){var Lt=vt+Rt;if(Rt==it||j[Lt]==0){if(lt=lt?x(j,lt,Lt-lt):"",Ct===void 0)var Ct=lt;else Ct+=String.fromCharCode(0),Ct+=lt;lt=Lt+1}}else{for(Ct=Array(it),Rt=0;Rt<it;++Rt)Ct[Rt]=String.fromCharCode(j[vt+Rt]);Ct=Ct.join("")}return xs(G),Ct},toWireType:function(G,it){it instanceof ArrayBuffer&&(it=new Uint8Array(it));var vt,lt=typeof it=="string";if(lt||it instanceof Uint8Array||it instanceof Uint8ClampedArray||it instanceof Int8Array||Ft("Cannot pass non-string to std::string"),B&&lt){var Rt=0;for(vt=0;vt<it.length;++vt){var Lt=it.charCodeAt(vt);127>=Lt?Rt++:2047>=Lt?Rt+=2:55296<=Lt&&57343>=Lt?(Rt+=4,++vt):Rt+=3}vt=Rt}else vt=it.length;if(Rt=op(4+vt+1),Lt=Rt+4,kt[Rt>>2]=vt,B&&lt){if(lt=Lt,Lt=vt+1,vt=j,0<Lt){Lt=lt+Lt-1;for(var Ct=0;Ct<it.length;++Ct){var Nt=it.charCodeAt(Ct);if(55296<=Nt&&57343>=Nt){var Kt=it.charCodeAt(++Ct);Nt=65536+((Nt&1023)<<10)|Kt&1023}if(127>=Nt){if(lt>=Lt)break;vt[lt++]=Nt}else{if(2047>=Nt){if(lt+1>=Lt)break;vt[lt++]=192|Nt>>6}else{if(65535>=Nt){if(lt+2>=Lt)break;vt[lt++]=224|Nt>>12}else{if(lt+3>=Lt)break;vt[lt++]=240|Nt>>18,vt[lt++]=128|Nt>>12&63}vt[lt++]=128|Nt>>6&63}vt[lt++]=128|Nt&63}}vt[lt]=0}}else if(lt)for(lt=0;lt<vt;++lt)Ct=it.charCodeAt(lt),255<Ct&&(xs(Lt),Ft("String has UTF-16 code units that do not fit in 8 bits")),j[Lt+lt]=Ct;else for(lt=0;lt<vt;++lt)j[Lt+lt]=it[lt];return G!==null&&G.push(xs,Rt),Rt},argPackAdvance:8,readValueFromPointer:ur,U:function(G){xs(G)}})},j:function(_,L,B){if(B=ke(B),L===2)var G=iE,it=rE,vt=sE,lt=()=>st,Rt=1;else L===4&&(G=nE,it=aE,vt=oE,lt=()=>kt,Rt=2);xi(_,{name:B,fromWireType:function(Lt){for(var Ct=kt[Lt>>2],Nt=lt(),Kt,te=Lt+4,Dt=0;Dt<=Ct;++Dt){var Ae=Lt+4+Dt*L;(Dt==Ct||Nt[Ae>>Rt]==0)&&(te=G(te,Ae-te),Kt===void 0?Kt=te:(Kt+=String.fromCharCode(0),Kt+=te),te=Ae+L)}return xs(Lt),Kt},toWireType:function(Lt,Ct){typeof Ct!="string"&&Ft("Cannot pass non-string to C++ string type "+B);var Nt=vt(Ct),Kt=op(4+Nt+L);return kt[Kt>>2]=Nt>>Rt,it(Ct,Kt+4,Nt+L),Lt!==null&&Lt.push(xs,Kt),Kt},argPackAdvance:8,readValueFromPointer:ur,U:function(Lt){xs(Lt)}})},l:function(_,L,B,G,it,vt){ni[_]={name:ke(L),ea:wr(B,G),V:wr(it,vt),ha:[]}},i:function(_,L,B,G,it,vt,lt,Rt,Lt,Ct){ni[_].ha.push({na:ke(L),sa:B,qa:wr(G,it),ra:vt,ya:lt,xa:wr(Rt,Lt),za:Ct})},D:function(_,L){L=ke(L),xi(_,{ua:!0,name:L,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},t:function(_,L,B,G,it){_=Yo[_],L=Xe(L),B=sp(B);var vt=[];return kt[G>>2]=qe(vt),_(L,B,vt,it)},u:function(_,L,B,G){_=Yo[_],L=Xe(L),B=sp(B),_(L,B,null,G)},h:yh,m:function(_,L){var B=hE(_,L),G=B[0];L=G.name+"_$"+B.slice(1).map(function(lt){return lt.name}).join("_")+"$";var it=np[L];if(it!==void 0)return it;var vt=Array(_-1);return it=cE((lt,Rt,Lt,Ct)=>{for(var Nt=0,Kt=0;Kt<_-1;++Kt)vt[Kt]=B[Kt+1].readValueFromPointer(Ct+Nt),Nt+=B[Kt+1].argPackAdvance;for(lt=lt[Rt].apply(lt,vt),Kt=0;Kt<_-1;++Kt)B[Kt+1].la&&B[Kt+1].la(vt[Kt]);if(!G.ua)return G.toWireType(Lt,lt)}),np[L]=it},r:function(_){4<_&&(jt[_].fa+=1)},s:function(_){var L=Xe(_);Ii(L),yh(_)},f:function(){xt("")},y:function(_,L,B){j.copyWithin(_,L,L+B)},x:function(_){var L=j.length;if(_>>>=0,2147483648<_)return!1;for(var B=1;4>=B;B*=2){var G=L*(1+.2/B);G=Math.min(G,_+100663296);var it=Math;G=Math.max(_,G),it=it.min.call(it,2147483648,G+(65536-G%65536)%65536);t:{try{O.grow(it-N.byteLength+65535>>>16),Vt(O.buffer);var vt=1;break t}catch{}vt=void 0}if(vt)return!0}return!1},A:function(){return 52},v:function(){return 70},z:function(_,L,B,G){for(var it=0,vt=0;vt<B;vt++){var lt=kt[L>>2],Rt=kt[L+4>>2];L+=8;for(var Lt=0;Lt<Rt;Lt++){var Ct=j[lt+Lt],Nt=dE[_];Ct===0||Ct===10?((_===1?g:v)(x(Nt,0)),Nt.length=0):Nt.push(Ct)}it+=Rt}return kt[G>>2]=it,0},a:O},$n=function(){function _(B){o.asm=B.exports,J=o.asm.I,$.unshift(o.asm.E),ft--,o.monitorRunDependencies&&o.monitorRunDependencies(ft),ft==0&&bt&&(B=bt,bt=null,B())}var L={a:fE};if(ft++,o.monitorRunDependencies&&o.monitorRunDependencies(ft),o.instantiateWasm)try{return o.instantiateWasm(L,_)}catch(B){v("Module.instantiateWasm callback failed with error: "+B),d(B)}return L=se(L),_(L[0]),o.asm}();o.___wasm_call_ctors=$n.E;var pE=o.___getTypeName=$n.F;o.__embind_initialize_bindings=$n.G;var op=o._malloc=$n.H,xs=o._free=$n.J;o.dynCall_jiji=$n.K;var Zo;bt=function _(){Zo||lp(),Zo||(bt=_)};function lp(){function _(){if(!Zo&&(Zo=!0,o.calledRun=!0,!F)){if(Yt($),c(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;){var L=o.postRun.shift();U.unshift(L)}Yt(U)}}if(!(0<ft)){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)Z();Yt(St),0<ft||(o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),_()},1)):_())}}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);0<o.preInit.length;)o.preInit.pop()();return lp(),s}})();n.exports=e})(Wd);var hm=Wd.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t={};n.default=void 0;var e=s(Ml),i=re;Object.keys(i).forEach(function(d){d==="default"||d==="__esModule"||Object.prototype.hasOwnProperty.call(t,d)||d in n&&n[d]===i[d]||Object.defineProperty(n,d,{enumerable:!0,get:function(){return i[d]}})});function s(d){return d&&d.__esModule?d:{default:d}}const o=hm;var c=(0,e.default)(o());n.default=c})(Ee);const jd=am(Ee),Zr=1.8;function dm(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:typeof n.top=="number"?n.top*t:n.top,right:typeof n.right=="number"?n.right*t:n.right,bottom:typeof n.bottom=="number"?n.bottom*t:n.bottom,left:typeof n.left=="number"?n.left*t:n.left}}function Kd(n,t){return typeof n=="number"?{top:n*t,right:n*t,bottom:n*t,left:n*t}:{top:(typeof n.top=="number"?n.top*t:n.top)??0,right:(typeof n.right=="number"?n.right*t:n.right)??0,bottom:(typeof n.bottom=="number"?n.bottom*t:n.bottom)??0,left:(typeof n.left=="number"?n.left*t:n.left)??0}}function um(n,t=1){return typeof n=="number"?{topLeft:n*t,topRight:n*t,bottomRight:n*t,bottomLeft:n*t}:{topLeft:((n==null?void 0:n.topLeft)??0)*t,topRight:((n==null?void 0:n.topRight)??0)*t,bottomRight:((n==null?void 0:n.bottomRight)??0)*t,bottomLeft:((n==null?void 0:n.bottomLeft)??0)*t}}function zd(n,{layout:t,scale:e=1}){const{position:i="static",inset:s,width:o,height:c,minWidth:d,minHeight:f,maxWidth:p,maxHeight:g,flex:v,gap:b,margin:E,padding:T,direction:w="column",align:C="start",justify:D="start"}=t,O={static:Ee.PositionType.Static,relative:Ee.PositionType.Relative,absolute:Ee.PositionType.Absolute};if(n.setPositionType(O[i]),s){const{top:H,right:j,bottom:nt,left:st}=dm(s,e);H&&n.setPosition(Ee.Edge.Top,H),j&&n.setPosition(Ee.Edge.Right,j),nt&&n.setPosition(Ee.Edge.Bottom,nt),st&&n.setPosition(Ee.Edge.Left,st)}const F={row:Ee.FlexDirection.Row,column:Ee.FlexDirection.Column,"row-reverse":Ee.FlexDirection.RowReverse,"column-reverse":Ee.FlexDirection.ColumnReverse};n.setFlexDirection(F[w]);const x={start:Ee.Align.FlexStart,end:Ee.Align.FlexEnd,center:Ee.Align.Center,stretch:Ee.Align.Stretch};n.setAlignItems(x[C]);const N={start:Ee.Justify.FlexStart,end:Ee.Justify.FlexEnd,center:Ee.Justify.Center,"space-between":Ee.Justify.SpaceBetween,"space-around":Ee.Justify.SpaceAround,"space-evenly":Ee.Justify.SpaceEvenly};if(n.setJustifyContent(N[D]),E){const{top:H,right:j,bottom:nt,left:st}=Kd(E,e);n.setMargin(Ee.Edge.Top,H),n.setMargin(Ee.Edge.Right,j),n.setMargin(Ee.Edge.Bottom,nt),n.setMargin(Ee.Edge.Left,st)}if(T){const{top:H,right:j,bottom:nt,left:st}=Kd(T,e);n.setPadding(Ee.Edge.Top,H),n.setPadding(Ee.Edge.Right,j),n.setPadding(Ee.Edge.Bottom,nt),n.setPadding(Ee.Edge.Left,st)}v&&n.setFlex(v),n.setGap(Ee.Gutter.All,(b??0)*e),o&&n.setWidth(typeof o=="number"?o*e:o),c&&(typeof c=="function"?n.setHeight("100%"):n.setHeight(typeof c=="number"?c*e:c)),d&&n.setMinWidth(typeof d=="number"?d*e:d),f&&n.setMinHeight(typeof f=="number"?f*e:f),p&&n.setMaxWidth(typeof p=="number"?p*e:p),g&&n.setMaxHeight(typeof g=="number"?g*e:g)}function Yd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i=!1,scale:s=1,position:o=[]}){o.forEach(({x:c,y:d,width:f,height:p,childNodes:g,element:v})=>{const b=n.getContext("2d",{alpha:!1});if(b){const{radius:E,draw:T}=v;if(T){if(b.save(),E){const{topLeft:w,topRight:C,bottomRight:D,bottomLeft:O}=um(E,s);b.beginPath(),b.moveTo(c+Math.min(p/Zr,w),d),b.lineTo(c+f-Math.min(p/Zr,C),d),b.quadraticCurveTo(c+f,d,c+f,d+Math.min(p/Zr,C)),b.lineTo(c+f,d+p-Math.min(p/Zr,D)),b.quadraticCurveTo(c+f,d+p,c+f-Math.min(p/Zr,D),d+p),b.lineTo(c+Math.min(p/Zr,O),d+p),b.quadraticCurveTo(c,d+p,c,d+p-Math.min(p/Zr,O)),b.lineTo(c,d+Math.min(p/Zr,w)),b.quadraticCurveTo(c,d,c+Math.min(p/Zr,w),d),b.closePath(),i&&(b.strokeStyle="blue",b.stroke()),b.clip()}T({scale:s,canvas:n,context:b,cropCanvas:t,letterboxCanvas:e,dx:c,dy:d,dw:f,dh:p}),i&&(b.strokeStyle="red",b.strokeRect(c,d,f,p)),b.restore()}}Yd({canvas:n,cropCanvas:t,letterboxCanvas:e,debug:i,scale:s,position:g})})}function Xd(n,t,e){const i=t.map((s,o)=>{const c=jd.Node.create(),{radius:d,elements:f=[],draw:p,...g}=s;return zd(c,{layout:g,scale:e}),n.insertChild(c,o),{node:c,element:s,childNodes:Xd(c,f,e)}});return n.calculateLayout(),i}function Zd(n,t,e=0,i=0){const{top:s,left:o}=n.getComputedLayout();return t.map(({node:c,element:d,childNodes:f})=>{const{top:p,left:g,width:v,height:b}=c.getComputedLayout(),E=e+g,T=i+p;return{x:o+E,y:s+T,width:v,height:b,element:d,childNodes:Zd(n,f,E,T)}})}function qd(n,t){n.forEach(({node:e,element:i,childNodes:s})=>{const{height:o}=i;if(o&&typeof o=="function"){const c=e.getComputedWidth(),d=e.getComputedHeight(),f=o({width:c,maxHeight:d,scale:t});e.setHeight(f)}qd(s,t)})}function fm({canvas:n,origin:t,elements:e,...i}){const s={inset:{top:0,left:0},width:n.width,height:n.height,...t},o=jd.Node.create();zd(o,{layout:s}),o.calculateLayout();const{width:c,height:d}=o.getComputedLayout(),f=Math.min(c,d)/1080,p=Xd(o,e,f);qd(p,f),o.calculateLayout();const g=Zd(o,p);return Yd({...i,scale:f,canvas:n,position:g})}const Qd=[{family:"Noto Arabic",regex:/\p{Script=Arabic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansArabic-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Chinese",regex:/\p{Script=Han}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansSC-VariableFont_wght.woff2",style:"normal"},{family:"Noto Hebrew",regex:/\p{Script=Hebrew}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansHebrew-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Hindi",regex:/\p{Script=Devanagari}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansDevanagari-VariableFont_wdth%2Cwght.woff2",style:"normal"},{family:"Noto Japanese",regex:/\p{Script=Han}|\p{Script=Katakana}|\p{Script=Hiragana}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansJP-VariableFont_wght.woff2",style:"normal"},{family:"Noto Korean",regex:/\p{Script=Hangul}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoSansKR-VariableFont_wght.woff2",style:"normal"},{family:"Noto Color Emoji",regex:/\p{Extended_Pictographic}/u,url:"https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/NotoColorEmoji-Regular.woff2",style:"normal"}];function co({text:n,font:t}){let e=t;return Qd.forEach(({family:i,regex:s})=>{s.exec(n)&&(e+=`, ${i}`)}),e}const ho=/(?<value>\d+\.?\d*)(?=px)/;function Jd(n){const{visible:t=!0,node:e}=n,i=[...(e==null?void 0:e.elements)??[],...(n==null?void 0:n.elements)??[]];return t?e&&e.type!=="box"&&e.type!=="gradient"?!!e.value:i==null?void 0:i.some(s=>Jd(s)):!1}function tu({canvas:n,debug:t=!1,elements:e=[],currentTime:i,relativeTime:s}){return e.map(o=>{var c,d,f,p,g,v,b,E;const{node:T}=o,w=n.getContext("2d");if(w&&Jd(o)){let C=o.width,D=o.height;if((T==null?void 0:T.type)==="text"&&T.value){const O=co({text:T.value,font:T.font});w.save(),T.wrap?D=({width:F,maxHeight:x,scale:N})=>{var H,j;const nt=Hd({font:O,scale:N,context:w,maxW:F,maxH:x,text:T.value??"",minSize:(H=T.fill)==null?void 0:H.minSize,maxSize:(j=T.fill)==null?void 0:j.maxSize});return uo({context:w,font:O,fontSize:nt,text:T.value??"",maxW:F}).length*nt}:(w.font=O,C=w.measureText(T.value).width,D=parseFloat(((d=(c=O.match(ho))==null?void 0:c.groups)==null?void 0:d.value)??"0")),w.restore()}if((T==null?void 0:T.type)==="image"&&T.image&&T.size){const O=((f=T.image)==null?void 0:f.naturalWidth)??((p=T.image)==null?void 0:p.width),F=((g=T.image)==null?void 0:g.naturalHeight)??((v=T.image)==null?void 0:v.height),x=O/F,N=(b=T.size)==null?void 0:b.width,H=(E=T.size)==null?void 0:E.height;C=N??(x>=1?(H??0)*x:(H??0)/x),D=H??(x<1?(N??0)*x:(N??0)/x)}return{...o,width:C,height:D,elements:tu({canvas:n,debug:t,elements:o.elements,currentTime:i,relativeTime:s}),draw:({canvas:O,cropCanvas:F,letterboxCanvas:x,context:N,dx:H,dy:j,dw:nt,dh:st,scale:Q})=>{var kt,gt,Mt,Vt,V,J,St,$,U,Z,ft,bt,xt;if(T){const{type:Ut,from:Qt=0,to:ue=1/0}=T;if(s>=Qt&&s<=ue){if(N.save(),s&&ue-.3333333333333333<=s&&(N.globalAlpha=1-(.16666666666666666-(ue-s))/.16666666666666666),Ut==="box"&&(N.fillStyle=T.background,N.fillRect(H,j,nt,st)),Ut==="text"&&T.value){const se=co({text:T.value,font:T.font}),Yt=Hd({font:se,scale:Q,context:N,maxW:nt,maxH:st,text:T.value??"",minSize:(kt=T.fill)==null?void 0:kt.minSize,maxSize:(gt=T.fill)==null?void 0:gt.maxSize});N.font=se.replace(ho,Yt.toString()),N.textBaseline="top",N.fillStyle=T.color,T.wrap?uo({context:N,font:se,fontSize:Yt,text:T.value,maxW:nt}).forEach((Me,be)=>{N.fillText(Me.text,H,j+Yt*be)}):N.fillText(T.value,H,j)}if(Ut==="image"&&T.image&&N.drawImage(T.image,H,j,nt,st),Ut==="video"&&((Mt=T.video)!=null&&Mt.node||(Vt=T.video)!=null&&Vt.getSource)){const se=T.format??"letterbox",Yt=((J=(V=T.video)==null?void 0:V.getSource)==null?void 0:J.call(V,s))??T.video.node,Me=(Yt==null?void 0:Yt.videoWidth)??(Yt==null?void 0:Yt.naturalWidth)??(Yt==null?void 0:Yt.width),be=(Yt==null?void 0:Yt.videoHeight)??(Yt==null?void 0:Yt.naturalHeight)??(Yt==null?void 0:Yt.height);if(Me&&be){const{dx:ge,dy:oe,dw:Ce,dh:Ft}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:Yt,format:se,crop:(St=T==null?void 0:T.value)==null?void 0:St.crop,sourceWidth:Me,sourceHeight:be,posX:H,posY:j,drawAreaWidth:nt,drawAreaHeight:st});T.elements&&Ul({debug:t,canvas:O,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+oe),left:Math.max(H,H+ge)},width:Math.min(nt,Ce),height:Math.min(st,Ft)},elements:T.elements})}const jt=1/3;if(T.poster&&i>=0&&i<=jt){N.save(),N.globalAlpha=1-i/jt;const ge=(($=T.poster)==null?void 0:$.naturalWidth)??((U=T.poster)==null?void 0:U.width),oe=((Z=T.poster)==null?void 0:Z.naturalHeight)??((ft=T.poster)==null?void 0:ft.height);if(ge&&oe){const{dx:Ce,dy:Ft,dw:Xe,dh:qe}=Fd({context:N,cropCanvas:F,letterboxCanvas:x,source:T.poster,format:se,crop:(bt=T==null?void 0:T.value)==null?void 0:bt.crop,sourceWidth:ge,sourceHeight:oe,posX:H,posY:j,drawAreaWidth:nt,drawAreaHeight:st});T.elements&&Ul({debug:t,canvas:O,cropCanvas:F,letterboxCanvas:x,currentTime:i,relativeTime:s,origin:{inset:{top:Math.max(j,j+Ft),left:Math.max(H,H+Ce)},width:Math.min(nt,Xe),height:Math.min(st,qe)},elements:T.elements})}N.restore()}}if(Ut==="gradient"&&T.value){const se=N.createLinearGradient(H+nt,j,H+nt,j+st);(xt=T.value)==null||xt.forEach(Yt=>{se.addColorStop(Yt.percent,Yt.color)}),N.fillStyle=se,N.fillRect(H,j,nt,st)}N.restore()}}}}}}).filter(Boolean)}function Ul({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s,...o}){return fm({...o,debug:t,canvas:n,elements:tu({canvas:n,debug:t,elements:e,currentTime:i,relativeTime:s})})}const uo=Bd(({context:n,font:t,fontSize:e,text:i,maxW:s=1/0})=>{try{return n.save(),n.font=t.replace(ho,e.toString()),i.split(`
91
91
  `).flatMap(o=>{const c=o.split(" ").filter(Boolean);return c.length?c.slice(1).reduce((d,f)=>{const p=`${d[d.length-1].text} ${f}`.trim(),g=n.measureText(p);return g.width>s?d=[...d,...Gd({context:n,word:f,maxW:s})]:d[d.length-1]={text:p,metrics:g},d},Gd({context:n,word:c[0],maxW:s})):{text:"",metrics:n.measureText("")}})}finally{n.restore()}},{cacheKey:([{font:n,fontSize:t,text:e,maxW:i}])=>`${n}_${t}_${e}_${i}`}),pm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}\s-->\s\d{0,2}:?\d{2}:\d{2}\.\d{3}\s{1,2}.*/g,gm=/\d{0,2}:?\d{2}:\d{2}\.\d{3}/g;function eu(n){if(!n)return[];const t=n.match(pm);return t?t==null?void 0:t.map(e=>{const[i,s]=e.replace(`\r
92
92
  `,`
93
93
  `).split(`
@@ -168,7 +168,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
168
168
  "width": {{@ parse(it.root?.answer?.settings?.crop?.width) /}},
169
169
  "height": {{@ parse(it.root?.answer?.settings?.crop?.height) /}}
170
170
  }
171
- }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]}],meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function ym(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>ep);return new n.Image}return new Image}const iu=ys(async function(n){return n?new Promise((t,e)=>{ym().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=n})}):null});async function Bl({element:n},t,e){var i,s,o;let c={...n};const{node:d}=n;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(s=d==null?void 0:d.value)!=null&&s.playlist)){const f=await t(d.value);let p;try{p=await iu(d.value.poster)}catch{p=null}c={...c,node:{...d,video:f,poster:p,meta:await e(d.value,f.node)}}}if((d==null?void 0:d.type)==="image"&&d.value){let f;try{f=await iu(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=n.node)!=null&&o.elements&&(c.node.elements=await Promise.all(n.node.elements.map(f=>Bl({element:f},t,e)))),n.elements&&(c.elements=await Promise.all(n.elements.map(f=>Bl({element:f},t,e)))),c}async function Gl(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>ep),t=new n.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function bm(n){var t;try{if((t=await zg(n,{method:"HEAD"}))!=null&&t.ok)return n}catch{return}}async function Am({sources:n}){let t=null;if(n){const e=n.filter(Boolean).map(i=>bm(i));t=(await Promise.all(e)).find(Boolean)}return t}Qs.filters.define("stringify",n=>JSON.stringify(n)),Qs.filters.define("nullify",n=>typeof n>"u"?null:n),Qs.filters.define("filter",(n,t)=>{if(!t)return n;if(!Array.isArray(n))throw new Error("Data for filter must be an array");return n.filter((e,i)=>t.includes(i))}),Qs.helpers.define("parse",n=>{const t=n.params[0];if(typeof t=="string"){let e=t;return e=e.replace(/\n/g,"\\n"),e=e.replace(/\r/g,"\\r"),e=e.replace(/"/g,'\\"'),`"${e}"`}return typeof t>"u"?null:t}),Qs.helpers.define("resolve-source",ys(async n=>{const{sources:t}=n.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),s=e==null?void 0:e.find(c=>!c.includes("http")),o=i??s??await Am({sources:t});return o?`"${o}"`:"null"},{cacheKey:([n])=>JSON.stringify(n.params[0]??{})}));const fa=(n,t,e)=>Qs.render(n,t,Qs.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function Hl(n=[]){var t;for(const e of n){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Hl(e==null?void 0:e.elements);if(i)return i}}async function po({data:n,template:t,burnCaptions:e=!1,debug:i=!1},s,o){var c,d,f,p;const g=t??vm;if(!((c=g.templates)!=null&&c.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:D})=>D===Vl);if(!v){const D=g.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Vl}" but got ${D}`)}v=g.templates[g.templates.length-1];const b=(await Promise.all(v.content.map(async({scenes:D,root:O})=>{const F={...g.options,...n,intro:g.intro,outro:g.outro};async function x(N,H){return Promise.all(D.map(async({layout:j,duration:nt,data:st,options:Q})=>{var kt,gt,Mt;const Vt={...F,index:H,root:N},V=st?JSON.parse(await fa(st,Vt)):{},J=Q?JSON.parse(await fa(Q,Vt)):{},St=nt?parseFloat(await fa(nt,Vt)):NaN,$=(kt=v.layouts.find(bt=>bt.name===j))==null?void 0:kt.tree;if(!$)throw new Error(`Layout tree "${j}" not found in template "${v.id}" layouts.`);const U=JSON.parse(await fa($,{...V,...J})),Z=await Promise.all(U.flatMap(bt=>Bl({element:bt},s,o))),ft=Hl(Z);return{duration:(isNaN(St)?null:St)??((gt=ft==null?void 0:ft.meta)==null?void 0:gt.duration)??0,captions:(Mt=ft==null?void 0:ft.meta)==null?void 0:Mt.captions,elements:Z}}))}if(O){const N=JSON.parse(await fa(O,F));return Array.isArray(N)?(await Promise.all(N.map(async(H,j)=>x(H,j)))).flatMap(H=>H):x(N,null)}return x(n,null)}))).flatMap(D=>D).filter(D=>D.duration>0),E=((d=g.meta)==null?void 0:d.frameRate)??30,T=((f=g.meta)==null?void 0:f.resolution)??720,w=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,C=await Promise.all(b.map(async({duration:D,captions:O,elements:F},x)=>{var N,H;const j=await Gl(),nt=await Gl(),st=await Gl(),Q=Hl(F),kt=b.reduce((gt,Mt,Vt)=>(Vt<x&&(gt+=Mt.duration-w/2),gt),0);return{draw:({canvas:gt,currentTime:Mt})=>{const Vt=Math.max(0,Mt-kt);Ul({debug:i,canvas:gt,elements:F,currentTime:Mt,relativeTime:Vt,cropCanvas:j,letterboxCanvas:nt}),O&&e&&mm({canvas:gt,dx:0,dy:0,dw:gt.width,dh:gt.height,vttCaptions:O,relativeTime:Vt+((Q==null?void 0:Q.meta.start)??0)})},duration:D,transitionCanvas:st,start:kt,video:Q==null?void 0:Q.video,videoMeta:Q==null?void 0:Q.meta,audio:{duration:D,src:(N=Q==null?void 0:Q.value)==null?void 0:N.src,start:(H=Q==null?void 0:Q.meta)==null?void 0:H.start}}}));return{scenes:C,frameRate:E,resolution:T,transitionDuration:w,fonts:v.fonts??[],duration:Math.max(0,...C.map(({start:D,duration:O})=>D+O))}}const Vl="1",Em={name:"@vouchfor/embeds",version:"0.0.0-experiment.75edba9",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"experiment",access:"public"},scripts:{build:"rm -rf dist && tsc && vite build --mode iife && vite build --mode es","build:deps":"yarn --cwd ../media-player build","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"true"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"0.0.0-experiment.75edba9",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1","lint-staged":"^14.0.1",lit:"^3.1.0",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}},ru=1;class Tm{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=Ja(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Em.version,templateVersion:Vl,...s}},this._sendTrackingEvent=(e,i)=>{const s=this._findVouchId(i);if(!s||this.host.disableTracking)return;const{publicApiUrl:o}=Ja(this.host.env),{client:c,tab:d,request:f,visitor:p}=this._getUids();navigator.sendBeacon(`${o}/api/v2/events`,JSON.stringify({event:e,payload:{...i,vouchId:s},context:{"x-uid-client":c,"x-uid-tab":d,"x-uid-request":f,"x-uid-visitor":p,"x-reporting-metadata":this._getReportingMetadata()}}))},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+ru&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0),this._streamStartTime[i]||(this._streamStartTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var o,c;!this.host.paused&&e===((c=(o=this.host.scene)==null?void 0:o.video)==null?void 0:c.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:s},this._streamLatestTime[i]=s.currentTime)},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+ru&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this.host.pause()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}_findVouchId(t){return t&&"vouchId"in t?t.vouchId:this.host.vouch?this.host.vouch.id:null}_getUids(){var o,c,d,f,p,g,v,b,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:qs()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(qs()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||qs(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||qs(),s=qs();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this._streamEnded(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}/**
171
+ }`}],root:"{{ it.outro?.questions?.items | stringify }}"}]}],meta:{frameRate:30,resolution:720,transitionDuration:1/3}};async function ym(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>ep);return new n.Image}return new Image}const iu=ys(async function(n){return n?new Promise((t,e)=>{ym().then(i=>{i.onload=()=>{t(i)},i.onerror=s=>{e(s)},i.src=n})}):null});async function Bl({element:n},t,e){var i,s,o;let c={...n};const{node:d}=n;if((d==null?void 0:d.type)==="video"&&((i=d==null?void 0:d.value)!=null&&i.src||(s=d==null?void 0:d.value)!=null&&s.playlist)){const f=await t(d.value);let p;try{p=await iu(d.value.poster)}catch{p=null}c={...c,node:{...d,video:f,poster:p,meta:await e(d.value,f.node)}}}if((d==null?void 0:d.type)==="image"&&d.value){let f;try{f=await iu(d.value)}catch{f=null}c={...c,node:{...d,image:f}}}return c.node&&(o=n.node)!=null&&o.elements&&(c.node.elements=await Promise.all(n.node.elements.map(f=>Bl({element:f},t,e)))),n.elements&&(c.elements=await Promise.all(n.elements.map(f=>Bl({element:f},t,e)))),c}async function Gl(){if(typeof window>"u"){const n=await Promise.resolve().then(()=>ep),t=new n.Canvas;return t.gpu=!1,t}return document.createElement("canvas")}async function bm(n){var t;try{if((t=await zg(n,{method:"HEAD"}))!=null&&t.ok)return n}catch{return}}async function Am({sources:n}){let t=null;if(n){const e=n.filter(Boolean).map(i=>bm(i));t=(await Promise.all(e)).find(Boolean)}return t}Qs.filters.define("stringify",n=>JSON.stringify(n)),Qs.filters.define("nullify",n=>typeof n>"u"?null:n),Qs.filters.define("filter",(n,t)=>{if(!t)return n;if(!Array.isArray(n))throw new Error("Data for filter must be an array");return n.filter((e,i)=>t.includes(i))}),Qs.helpers.define("parse",n=>{const t=n.params[0];if(typeof t=="string"){let e=t;return e=e.replace(/\n/g,"\\n"),e=e.replace(/\r/g,"\\r"),e=e.replace(/"/g,'\\"'),`"${e}"`}return typeof t>"u"?null:t}),Qs.helpers.define("resolve-source",ys(async n=>{const{sources:t}=n.params[0]??{},e=t==null?void 0:t.filter(Boolean),i=e==null?void 0:e.find(c=>c.includes("blob:")),s=e==null?void 0:e.find(c=>!c.includes("http")),o=i??s??await Am({sources:t});return o?`"${o}"`:"null"},{cacheKey:([n])=>JSON.stringify(n.params[0]??{})}));const fa=(n,t,e)=>Qs.render(n,t,Qs.getConfig({autoEscape:!1,defaultFilter:"nullify",async:!0,asyncHelpers:["resolve-source"],...e}));function Hl(n=[]){var t;for(const e of n){if(((t=e==null?void 0:e.node)==null?void 0:t.type)==="video")return e.node;const i=Hl(e==null?void 0:e.elements);if(i)return i}}async function po({data:n,template:t,burnCaptions:e=!1,debug:i=!1},s,o){var c,d,f,p;const g=t??vm;if(!((c=g.templates)!=null&&c.length))throw new Error(`No templates found for template instance: ${g.id}`);let v=g.templates.find(({version:D})=>D===Vl);if(!v){const D=g.templates.map(({version:O})=>`"${O}"`).join(", ");console.warn(`Template renderer expects template version "${Vl}" but got ${D}`)}v=g.templates[g.templates.length-1];const b=(await Promise.all(v.content.map(async({scenes:D,root:O})=>{const F={...g.options,...n,intro:g.intro,outro:g.outro};async function x(N,H){return Promise.all(D.map(async({layout:j,duration:nt,data:st,options:Q})=>{var kt,gt,Mt;const Vt={...F,index:H,root:N},V=st?JSON.parse(await fa(st,Vt)):{},J=Q?JSON.parse(await fa(Q,Vt)):{},St=nt?parseFloat(await fa(nt,Vt)):NaN,$=(kt=v.layouts.find(bt=>bt.name===j))==null?void 0:kt.tree;if(!$)throw new Error(`Layout tree "${j}" not found in template "${v.id}" layouts.`);const U=JSON.parse(await fa($,{...V,...J})),Z=await Promise.all(U.flatMap(bt=>Bl({element:bt},s,o))),ft=Hl(Z);return{duration:(isNaN(St)?null:St)??((gt=ft==null?void 0:ft.meta)==null?void 0:gt.duration)??0,captions:(Mt=ft==null?void 0:ft.meta)==null?void 0:Mt.captions,elements:Z}}))}if(O){const N=JSON.parse(await fa(O,F));return Array.isArray(N)?(await Promise.all(N.map(async(H,j)=>x(H,j)))).flatMap(H=>H):x(N,null)}return x(n,null)}))).flatMap(D=>D).filter(D=>D.duration>0),E=((d=g.meta)==null?void 0:d.frameRate)??30,T=((f=g.meta)==null?void 0:f.resolution)??720,w=((p=g.meta)==null?void 0:p.transitionDuration)??1/3,C=await Promise.all(b.map(async({duration:D,captions:O,elements:F},x)=>{var N,H;const j=await Gl(),nt=await Gl(),st=await Gl(),Q=Hl(F),kt=b.reduce((gt,Mt,Vt)=>(Vt<x&&(gt+=Mt.duration-w/2),gt),0);return{draw:({canvas:gt,currentTime:Mt})=>{const Vt=Math.max(0,Mt-kt);Ul({debug:i,canvas:gt,elements:F,currentTime:Mt,relativeTime:Vt,cropCanvas:j,letterboxCanvas:nt}),O&&e&&mm({canvas:gt,dx:0,dy:0,dw:gt.width,dh:gt.height,vttCaptions:O,relativeTime:Vt+((Q==null?void 0:Q.meta.start)??0)})},duration:D,transitionCanvas:st,start:kt,video:Q==null?void 0:Q.video,videoMeta:Q==null?void 0:Q.meta,audio:{duration:D,src:(N=Q==null?void 0:Q.value)==null?void 0:N.src,start:(H=Q==null?void 0:Q.meta)==null?void 0:H.start}}}));return{scenes:C,frameRate:E,resolution:T,transitionDuration:w,fonts:v.fonts??[],duration:Math.max(0,...C.map(({start:D,duration:O})=>D+O))}}const Vl="1",Em={name:"@vouchfor/embeds",version:"0.0.0-experiment.77214cd",license:"MIT",author:"Aaron Williams",main:"dist/es/embeds.js",module:"dist/es/embeds.js",type:"module",types:"dist/es/index.d.ts",exports:{".":"./dist/es/embeds.js"},files:["dist","src"],publishConfig:{tag:"experiment",access:"public"},scripts:{build:"rm -rf dist && tsc && vite build --mode iife && vite build --mode es","build:deps":"yarn --cwd ../media-player build","build:package":"yarn build","build:storybook":"yarn prebuild && storybook build","generate:manifest":"wca src --outFile custom-elements.json",lint:"eslint . --quiet","lint:fix":"eslint . --fix","lint:staged":"lint-staged",prepublishOnly:"yarn build",size:"size-limit",storybook:"yarn prebuild && storybook dev -p 6007",prebuild:"yarn build:deps && yarn generate:manifest",test:"rm -rf test/lib && yarn prebuild && vite build --mode test && web-test-runner","test:ci":"yarn test"},"lint-staged":{"**/*.{ts,tsx,js}":"eslint --fix --quiet","**/*.{md,json,yml}":"prettier --write"},dependencies:{"@lit/task":"^1.0.0","@vouchfor/media-player":"0.0.0-experiment.77214cd",uuid:"^9.0.1"},peerDependencies:{lit:"^3.1.0"},devDependencies:{"@esm-bundle/chai":"^4.3.4-fix.0","@open-wc/testing":"^3.2.0","@storybook/addon-essentials":"^7.4.5","@storybook/addon-links":"^7.4.5","@storybook/blocks":"^7.4.5","@storybook/web-components":"^7.4.5","@storybook/web-components-vite":"^7.4.5","@types/mocha":"^10.0.1","@vouchfor/eslint-config":"^1.0.0","@vouchfor/prettier-config":"^1.0.0","@web/dev-server-esbuild":"^0.4.1","@web/test-runner":"^0.17.1","@web/test-runner-browserstack":"^0.6.1","@web/test-runner-mocha":"^0.8.1","@web/test-runner-playwright":"^0.10.1",dotenv:"^16.3.1",eslint:"^8.50.0","eslint-plugin-import":"^2.28.1","lint-staged":"^14.0.1",lit:"^3.1.0",prettier:"^3.0.3",react:"^18.2.0","react-dom":"^18.2.0",storybook:"^7.4.5",typescript:"^5.1.3",vite:"^4.4.9","vite-plugin-commonjs":"^0.10.0","vite-plugin-dts":"^3.6.0","web-component-analyzer":"^1.1.7"}},ru=1;class Tm{constructor(t){this._tabId=void 0,this._clientId=void 0,this._visitorId=void 0,this._hasPlayed=!1,this._hasLoaded={},this._answersViewed={},this._streamStartTime={},this._streamLatestTime={},this._currentlyPlayingVideo=null,this._createVisitor=e=>{var s,o;const{publicApiUrl:i}=Ja(this.host.env);return(o=(s=window.localStorage)==null?void 0:s.setItem)==null||o.call(s,"vouch-uid-visitor",e),navigator.sendBeacon(`${i}/api/visitor`,JSON.stringify({visitorId:e})),e},this._getReportingMetadata=()=>{var o,c;const[e,i]=((c=(o=Intl.DateTimeFormat().resolvedOptions().timeZone)==null?void 0:o.split)==null?void 0:c.call(o,"/"))??[],s={};return[...new URLSearchParams(location.search).entries()].forEach(([d,f])=>{if(/utm/.test(d)){const p=d.toLowerCase().replace(/[-_][a-z0-9]/g,g=>g.slice(-1).toUpperCase());s[p]=f}}),{source:this.host.trackingSource,time:new Date,region:i,country:e,screenHeight:window.screen.height,screenWidth:window.screen.width,referrer:document.referrer,currentUrl:location.href,embedType:"media-player-embed",embedVersion:Em.version,templateVersion:Vl,...s}},this._sendTrackingEvent=(e,i)=>{const s=this._findVouchId(i);if(!s||this.host.disableTracking)return;const{publicApiUrl:o}=Ja(this.host.env),{client:c,tab:d,request:f,visitor:p}=this._getUids();navigator.sendBeacon(`${o}/api/v2/events`,JSON.stringify({event:e,payload:{...i,vouchId:s},context:{"x-uid-client":c,"x-uid-tab":d,"x-uid-request":f,"x-uid-visitor":p,"x-reporting-metadata":this._getReportingMetadata()}}))},this._streamEnded=()=>{if(this._currentlyPlayingVideo){const{id:e,key:i}=this._currentlyPlayingVideo;this._streamLatestTime[i]>this._streamStartTime[i]+ru&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]}},this._handleVouchLoaded=({detail:e})=>{e&&(this._hasLoaded[e]||(this._sendTrackingEvent("VOUCH_LOADED",{vouchId:e}),this._hasLoaded[e]=!0))},this._handlePlay=()=>{this._hasPlayed||(this._sendTrackingEvent("VIDEO_PLAYED",{streamStart:this.host.currentTime}),this._hasPlayed=!0)},this._handleVideoPlay=({detail:{id:e,key:i,node:s}})=>{this._answersViewed[i]||(this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED",{answerId:e}),this._answersViewed[i]=!0),this._streamStartTime[i]||(this._streamStartTime[i]=s.currentTime,this._streamLatestTime[i]=s.currentTime)},this._handleVideoTimeUpdate=({detail:{id:e,key:i,node:s}})=>{var o,c;!this.host.paused&&e===((c=(o=this.host.scene)==null?void 0:o.video)==null?void 0:c.id)&&(this._currentlyPlayingVideo={id:e,key:i,node:s},this._streamLatestTime[i]=s.currentTime)},this._handleVideoPause=({detail:{id:e,key:i}})=>{this._streamLatestTime[i]>this._streamStartTime[i]+ru&&this._sendTrackingEvent("VIDEO_STREAMED",{answerId:e,streamStart:this._streamStartTime[i],streamEnd:this._streamLatestTime[i]}),delete this._streamStartTime[i],delete this._streamLatestTime[i]},this._pageUnloading=()=>{this._streamEnded(),this.host.pause()},this._handleVisibilityChange=()=>{document.visibilityState==="hidden"&&this._pageUnloading()},this._handlePageHide=()=>{this._pageUnloading()},this.host=t,t.addController(this)}_findVouchId(t){return t&&"vouchId"in t?t.vouchId:this.host.vouch?this.host.vouch.id:null}_getUids(){var o,c,d,f,p,g,v,b,E,T,w,C;if(typeof window>"u")return{client:null,tab:null,request:qs()};const t=this._visitorId||((c=(o=window.localStorage)==null?void 0:o.getItem)==null?void 0:c.call(o,"vouch-uid-visitor"))||this._createVisitor(qs()),e=this._clientId||((f=(d=window.localStorage)==null?void 0:d.getItem)==null?void 0:f.call(d,"vouch-uid-client"))||qs(),i=this._tabId||((g=(p=window.sessionStorage)==null?void 0:p.getItem)==null?void 0:g.call(p,"vouch-uid-tab"))||qs(),s=qs();return t!==this._visitorId&&(this._visitorId=t,(b=(v=window.localStorage)==null?void 0:v.setItem)==null||b.call(v,"vouch-uid-visitor",t)),e!==this._clientId&&(this._clientId=e,(T=(E=window.localStorage)==null?void 0:E.setItem)==null||T.call(E,"vouch-uid-client",e)),i!==this._tabId&&(this._tabId=i,(C=(w=window.sessionStorage)==null?void 0:w.setItem)==null||C.call(w,"vouch-uid-tab",i)),{client:e,tab:i,request:s,visitor:t}}hostConnected(){requestAnimationFrame(()=>{var t,e,i,s;"onvisibilitychange"in document?document.addEventListener("visibilitychange",this._handleVisibilityChange):window.addEventListener("pagehide",this._handlePageHide),this.host.addEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.addEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.addEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.addEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.addEventListener("video:timeupdate",this._handleVideoTimeUpdate)})}hostDisconnected(){var t,e,i,s;this._streamEnded(),"onvisibilitychange"in document?document.removeEventListener("visibilitychange",this._handleVisibilityChange):window.removeEventListener("pagehide",this._handlePageHide),this.host.removeEventListener("vouch:loaded",this._handleVouchLoaded),(t=this.host.mediaPlayer)==null||t.removeEventListener("play",this._handlePlay),(e=this.host.mediaPlayer)==null||e.removeEventListener("video:play",this._handleVideoPlay),(i=this.host.mediaPlayer)==null||i.removeEventListener("video:pause",this._handleVideoPause),(s=this.host.mediaPlayer)==null||s.removeEventListener("video:timeupdate",this._handleVideoTimeUpdate)}}/**
172
172
  * @license
173
173
  * Copyright 2018 Google LLC
174
174
  * SPDX-License-Identifier: BSD-3-Clause
@@ -180,7 +180,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
180
180
  * @license
181
181
  * Copyright 2017 Google LLC
182
182
  * SPDX-License-Identifier: BSD-3-Clause
183
- */const lu=(n,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(n[s],s);return i},cu=An(class extends na{constructor(n){if(super(n),n.type!==bn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(n,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],o=[];let c=0;for(const d of n)s[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:s}}render(n,t,e){return this.ht(n,t,e).values}update(n,[t,e,i]){const s=ag(n),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(s))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,b=s.length-1,E=0,T=o.length-1;for(;v<=b&&E<=T;)if(s[v]===null)v++;else if(s[b]===null)b--;else if(d[v]===c[E])f[E]=Zs(s[v],o[E]),v++,E++;else if(d[b]===c[T])f[T]=Zs(s[b],o[T]),b--,T--;else if(d[v]===c[T])f[T]=Zs(s[v],o[T]),sa(n,f[T+1],s[v]),v++,T--;else if(d[b]===c[E])f[E]=Zs(s[b],o[E]),sa(n,s[v],s[b]),b--,E++;else if(p===void 0&&(p=lu(c,E,T),g=lu(d,v,b)),p.has(d[v]))if(p.has(d[b])){const w=g.get(c[E]),C=w!==void 0?s[w]:null;if(C===null){const D=sa(n,s[v]);Zs(D,o[E]),f[E]=D}else f[E]=Zs(C,o[E]),sa(n,s[v],C),s[w]=null;E++}else wl(s[b]),b--;else wl(s[v]),v++;for(;E<=T;){const w=sa(n,f[T+1]);Zs(w,o[E]),f[E++]=w}for(;v<=b;){const w=s[v++];w!==null&&wl(w)}return this.dt=c,ng(n,f),fs}});var Hi="top",ar="bottom",or="right",Vi="left",jl="auto",ga=[Hi,ar,or,Vi],En="start",ma="end",Rm="clippingParents",hu="viewport",va="popper",_m="reference",du=ga.reduce(function(n,t){return n.concat([t+"-"+En,t+"-"+ma])},[]),uu=[].concat(ga,[jl]).reduce(function(n,t){return n.concat([t,t+"-"+En,t+"-"+ma])},[]),Lm="beforeRead",Cm="read",Im="afterRead",xm="beforeMain",Dm="main",Pm="afterMain",Om="beforeWrite",Mm="write",$m="afterWrite",Nm=[Lm,Cm,Im,xm,Dm,Pm,Om,Mm,$m];function Ir(n){return n?(n.nodeName||"").toLowerCase():null}function er(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function en(n){var t=er(n).Element;return n instanceof t||n instanceof Element}function lr(n){var t=er(n).HTMLElement;return n instanceof t||n instanceof HTMLElement}function Kl(n){if(typeof ShadowRoot>"u")return!1;var t=er(n).ShadowRoot;return n instanceof t||n instanceof ShadowRoot}function Fm(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},o=t.elements[e];!lr(o)||!Ir(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(c){var d=s[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function Um(n){var t=n.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var s=t.elements[i],o=t.attributes[i]||{},c=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=c.reduce(function(f,p){return f[p]="",f},{});!lr(s)||!Ir(s)||(Object.assign(s.style,d),Object.keys(o).forEach(function(f){s.removeAttribute(f)}))})}}const fu={name:"applyStyles",enabled:!0,phase:"write",fn:Fm,effect:Um,requires:["computeStyles"]};function xr(n){return n.split("-")[0]}var rn=Math.max,go=Math.min,Tn=Math.round;function zl(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function pu(){return!/^((?!chrome|android).)*safari/i.test(zl())}function kn(n,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=n.getBoundingClientRect(),s=1,o=1;t&&lr(n)&&(s=n.offsetWidth>0&&Tn(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&Tn(i.height)/n.offsetHeight||1);var c=en(n)?er(n):window,d=c.visualViewport,f=!pu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/s,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/s,b=i.height/o;return{width:v,height:b,top:g,right:p+v,bottom:g+b,left:p,x:p,y:g}}function Yl(n){var t=kn(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function gu(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&Kl(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function qr(n){return er(n).getComputedStyle(n)}function Bm(n){return["table","td","th"].indexOf(Ir(n))>=0}function As(n){return((en(n)?n.ownerDocument:n.document)||window.document).documentElement}function mo(n){return Ir(n)==="html"?n:n.assignedSlot||n.parentNode||(Kl(n)?n.host:null)||As(n)}function mu(n){return!lr(n)||qr(n).position==="fixed"?null:n.offsetParent}function Gm(n){var t=/firefox/i.test(zl()),e=/Trident/i.test(zl());if(e&&lr(n)){var i=qr(n);if(i.position==="fixed")return null}var s=mo(n);for(Kl(s)&&(s=s.host);lr(s)&&["html","body"].indexOf(Ir(s))<0;){var o=qr(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function ya(n){for(var t=er(n),e=mu(n);e&&Bm(e)&&qr(e).position==="static";)e=mu(e);return e&&(Ir(e)==="html"||Ir(e)==="body"&&qr(e).position==="static")?t:e||Gm(n)||t}function Xl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function ba(n,t,e){return rn(n,go(t,e))}function Hm(n,t,e){var i=ba(n,t,e);return i>e?e:i}function vu(){return{top:0,right:0,bottom:0,left:0}}function yu(n){return Object.assign({},vu(),n)}function bu(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}var Vm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,yu(typeof t!="number"?t:bu(t,ga))};function Wm(n){var t,e=n.state,i=n.name,s=n.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=xr(e.placement),f=Xl(d),p=[Vi,or].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Vm(s.padding,e),b=Yl(o),E=f==="y"?Hi:Vi,T=f==="y"?ar:or,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],C=c[f]-e.rects.reference[f],D=ya(o),O=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,F=w/2-C/2,x=v[E],N=O-b[g]-v[T],H=O/2-b[g]/2+F,j=ba(x,H,N),nt=f;e.modifiersData[i]=(t={},t[nt]=j,t.centerOffset=j-H,t)}}function jm(n){var t=n.state,e=n.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||gu(t.elements.popper,s)&&(t.elements.arrow=s))}const Km={name:"arrow",enabled:!0,phase:"main",fn:Wm,effect:jm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wn(n){return n.split("-")[1]}var zm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ym(n,t){var e=n.x,i=n.y,s=t.devicePixelRatio||1;return{x:Tn(e*s)/s||0,y:Tn(i*s)/s||0}}function Au(n){var t,e=n.popper,i=n.popperRect,s=n.placement,o=n.variation,c=n.offsets,d=n.position,f=n.gpuAcceleration,p=n.adaptive,g=n.roundOffsets,v=n.isFixed,b=c.x,E=b===void 0?0:b,T=c.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var D=c.hasOwnProperty("x"),O=c.hasOwnProperty("y"),F=Vi,x=Hi,N=window;if(p){var H=ya(e),j="clientHeight",nt="clientWidth";if(H===er(e)&&(H=As(e),qr(H).position!=="static"&&d==="absolute"&&(j="scrollHeight",nt="scrollWidth")),H=H,s===Hi||(s===Vi||s===or)&&o===ma){x=ar;var st=v&&H===N&&N.visualViewport?N.visualViewport.height:H[j];w-=st-i.height,w*=f?1:-1}if(s===Vi||(s===Hi||s===ar)&&o===ma){F=or;var Q=v&&H===N&&N.visualViewport?N.visualViewport.width:H[nt];E-=Q-i.width,E*=f?1:-1}}var kt=Object.assign({position:d},p&&zm),gt=g===!0?Ym({x:E,y:w},er(e)):{x:E,y:w};if(E=gt.x,w=gt.y,f){var Mt;return Object.assign({},kt,(Mt={},Mt[x]=O?"0":"",Mt[F]=D?"0":"",Mt.transform=(N.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Mt))}return Object.assign({},kt,(t={},t[x]=O?w+"px":"",t[F]=D?E+"px":"",t.transform="",t))}function Xm(n){var t=n.state,e=n.options,i=e.gpuAcceleration,s=i===void 0?!0:i,o=e.adaptive,c=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:xr(t.placement),variation:wn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Au(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Au(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Zm={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Xm,data:{}};var vo={passive:!0};function qm(n){var t=n.state,e=n.instance,i=n.options,s=i.scroll,o=s===void 0?!0:s,c=i.resize,d=c===void 0?!0:c,f=er(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,vo)}),d&&f.addEventListener("resize",e.update,vo),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,vo)}),d&&f.removeEventListener("resize",e.update,vo)}}const Qm={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:qm,data:{}};var Jm={left:"right",right:"left",bottom:"top",top:"bottom"};function yo(n){return n.replace(/left|right|bottom|top/g,function(t){return Jm[t]})}var t1={start:"end",end:"start"};function Eu(n){return n.replace(/start|end/g,function(t){return t1[t]})}function Zl(n){var t=er(n),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function ql(n){return kn(As(n)).left+Zl(n).scrollLeft}function e1(n,t){var e=er(n),i=As(n),s=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(s){o=s.width,c=s.height;var p=pu();(p||!p&&t==="fixed")&&(d=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:d+ql(n),y:f}}function i1(n){var t,e=As(n),i=Zl(n),s=(t=n.ownerDocument)==null?void 0:t.body,o=rn(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),c=rn(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),d=-i.scrollLeft+ql(n),f=-i.scrollTop;return qr(s||e).direction==="rtl"&&(d+=rn(e.clientWidth,s?s.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Ql(n){var t=qr(n),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function Tu(n){return["html","body","#document"].indexOf(Ir(n))>=0?n.ownerDocument.body:lr(n)&&Ql(n)?n:Tu(mo(n))}function Aa(n,t){var e;t===void 0&&(t=[]);var i=Tu(n),s=i===((e=n.ownerDocument)==null?void 0:e.body),o=er(i),c=s?[o].concat(o.visualViewport||[],Ql(i)?i:[]):i,d=t.concat(c);return s?d:d.concat(Aa(mo(c)))}function Jl(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function r1(n,t){var e=kn(n,!1,t==="fixed");return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}function ku(n,t,e){return t===hu?Jl(e1(n,e)):en(t)?r1(t,e):Jl(i1(As(n)))}function s1(n){var t=Aa(mo(n)),e=["absolute","fixed"].indexOf(qr(n).position)>=0,i=e&&lr(n)?ya(n):n;return en(i)?t.filter(function(s){return en(s)&&gu(s,i)&&Ir(s)!=="body"}):[]}function n1(n,t,e,i){var s=t==="clippingParents"?s1(n):[].concat(t),o=[].concat(s,[e]),c=o[0],d=o.reduce(function(f,p){var g=ku(n,p,i);return f.top=rn(g.top,f.top),f.right=go(g.right,f.right),f.bottom=go(g.bottom,f.bottom),f.left=rn(g.left,f.left),f},ku(n,c,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function wu(n){var t=n.reference,e=n.element,i=n.placement,s=i?xr(i):null,o=i?wn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(s){case Hi:f={x:c,y:t.y-e.height};break;case ar:f={x:c,y:t.y+t.height};break;case or:f={x:t.x+t.width,y:d};break;case Vi:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=s?Xl(s):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case En:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ma:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Ea(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?n.placement:i,o=e.strategy,c=o===void 0?n.strategy:o,d=e.boundary,f=d===void 0?Rm:d,p=e.rootBoundary,g=p===void 0?hu:p,v=e.elementContext,b=v===void 0?va:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,D=yu(typeof C!="number"?C:bu(C,ga)),O=b===va?_m:va,F=n.rects.popper,x=n.elements[T?O:b],N=n1(en(x)?x:x.contextElement||As(n.elements.popper),f,g,c),H=kn(n.elements.reference),j=wu({reference:H,element:F,strategy:"absolute",placement:s}),nt=Jl(Object.assign({},F,j)),st=b===va?nt:H,Q={top:N.top-st.top+D.top,bottom:st.bottom-N.bottom+D.bottom,left:N.left-st.left+D.left,right:st.right-N.right+D.right},kt=n.modifiersData.offset;if(b===va&&kt){var gt=kt[s];Object.keys(Q).forEach(function(Mt){var Vt=[or,ar].indexOf(Mt)>=0?1:-1,V=[Hi,ar].indexOf(Mt)>=0?"y":"x";Q[Mt]+=gt[V]*Vt})}return Q}function a1(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?uu:f,g=wn(i),v=g?d?du:du.filter(function(T){return wn(T)===g}):ga,b=v.filter(function(T){return p.indexOf(T)>=0});b.length===0&&(b=v);var E=b.reduce(function(T,w){return T[w]=Ea(n,{placement:w,boundary:s,rootBoundary:o,padding:c})[xr(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function o1(n){if(xr(n)===jl)return[];var t=yo(n);return[Eu(n),t,Eu(t)]}function l1(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,b=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,D=xr(C),O=D===C,F=f||(O||!T?[yo(C)]:o1(C)),x=[C].concat(F).reduce(function(Ut,Qt){return Ut.concat(xr(Qt)===jl?a1(t,{placement:Qt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):Qt)},[]),N=t.rects.reference,H=t.rects.popper,j=new Map,nt=!0,st=x[0],Q=0;Q<x.length;Q++){var kt=x[Q],gt=xr(kt),Mt=wn(kt)===En,Vt=[Hi,ar].indexOf(gt)>=0,V=Vt?"width":"height",J=Ea(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:b,padding:p}),St=Vt?Mt?or:Vi:Mt?ar:Hi;N[V]>H[V]&&(St=yo(St));var $=yo(St),U=[];if(o&&U.push(J[gt]<=0),d&&U.push(J[St]<=0,J[$]<=0),U.every(function(Ut){return Ut})){st=kt,nt=!1;break}j.set(kt,U)}if(nt)for(var Z=T?3:1,ft=function(Qt){var ue=x.find(function(se){var Yt=j.get(se);if(Yt)return Yt.slice(0,Qt).every(function(Me){return Me})});if(ue)return st=ue,"break"},bt=Z;bt>0;bt--){var xt=ft(bt);if(xt==="break")break}t.placement!==st&&(t.modifiersData[i]._skip=!0,t.placement=st,t.reset=!0)}}const c1={name:"flip",enabled:!0,phase:"main",fn:l1,requiresIfExists:["offset"],data:{_skip:!1}};function Su(n,t,e){return e===void 0&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function Ru(n){return[Hi,or,ar,Vi].some(function(t){return n[t]>=0})}function h1(n){var t=n.state,e=n.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,c=Ea(t,{elementContext:"reference"}),d=Ea(t,{altBoundary:!0}),f=Su(c,i),p=Su(d,s,o),g=Ru(f),v=Ru(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const d1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:h1};function u1(n,t,e){var i=xr(n),s=[Vi,Hi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:n})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*s,[Vi,or].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function f1(n){var t=n.state,e=n.options,i=n.name,s=e.offset,o=s===void 0?[0,0]:s,c=uu.reduce(function(g,v){return g[v]=u1(v,t.rects,o),g},{}),d=c[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[i]=c}const p1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:f1};function g1(n){var t=n.state,e=n.name;t.modifiersData[e]=wu({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const m1={name:"popperOffsets",enabled:!0,phase:"read",fn:g1,data:{}};function v1(n){return n==="x"?"y":"x"}function y1(n){var t=n.state,e=n.options,i=n.name,s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,b=e.tether,E=b===void 0?!0:b,T=e.tetherOffset,w=T===void 0?0:T,C=Ea(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=xr(t.placement),O=wn(t.placement),F=!O,x=Xl(D),N=v1(x),H=t.modifiersData.popperOffsets,j=t.rects.reference,nt=t.rects.popper,st=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,Q=typeof st=="number"?{mainAxis:st,altAxis:st}:Object.assign({mainAxis:0,altAxis:0},st),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,gt={x:0,y:0};if(H){if(o){var Mt,Vt=x==="y"?Hi:Vi,V=x==="y"?ar:or,J=x==="y"?"height":"width",St=H[x],$=St+C[Vt],U=St-C[V],Z=E?-nt[J]/2:0,ft=O===En?j[J]:nt[J],bt=O===En?-nt[J]:-j[J],xt=t.elements.arrow,Ut=E&&xt?Yl(xt):{width:0,height:0},Qt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:vu(),ue=Qt[Vt],se=Qt[V],Yt=ba(0,j[J],Ut[J]),Me=F?j[J]/2-Z-Yt-ue-Q.mainAxis:ft-Yt-ue-Q.mainAxis,be=F?-j[J]/2+Z+Yt+se+Q.mainAxis:bt+Yt+se+Q.mainAxis,jt=t.elements.arrow&&ya(t.elements.arrow),ge=jt?x==="y"?jt.clientTop||0:jt.clientLeft||0:0,oe=(Mt=kt==null?void 0:kt[x])!=null?Mt:0,Ce=St+Me-oe-ge,Ft=St+be-oe,Ze=ba(E?go($,Ce):$,St,E?rn(U,Ft):U);H[x]=Ze,gt[x]=Ze-St}if(d){var qe,$i=x==="x"?Hi:Vi,Tr=x==="x"?ar:or,ke=H[N],li=N==="y"?"height":"width",me=ke+C[$i],ti=ke-C[Tr],ei=[Hi,Vi].indexOf(D)!==-1,Xi=(qe=kt==null?void 0:kt[N])!=null?qe:0,Ne=ei?me:ke-j[li]-nt[li]-Xi+Q.altAxis,Ci=ei?ke+j[li]+nt[li]-Xi-Q.altAxis:ti,ss=E&&ei?Hm(Ne,ke,Ci):ba(E?Ne:me,ke,E?Ci:ti);H[N]=ss,gt[N]=ss-ke}t.modifiersData[i]=gt}}const b1={name:"preventOverflow",enabled:!0,phase:"main",fn:y1,requiresIfExists:["offset"]};function A1(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function E1(n){return n===er(n)||!lr(n)?Zl(n):A1(n)}function T1(n){var t=n.getBoundingClientRect(),e=Tn(t.width)/n.offsetWidth||1,i=Tn(t.height)/n.offsetHeight||1;return e!==1||i!==1}function k1(n,t,e){e===void 0&&(e=!1);var i=lr(t),s=lr(t)&&T1(t),o=As(t),c=kn(n,s,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Ir(t)!=="body"||Ql(o))&&(d=E1(t)),lr(t)?(f=kn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=ql(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function w1(n){var t=new Map,e=new Set,i=[];n.forEach(function(o){t.set(o.name,o)});function s(o){e.add(o.name);var c=[].concat(o.requires||[],o.requiresIfExists||[]);c.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&s(f)}}),i.push(o)}return n.forEach(function(o){e.has(o.name)||s(o)}),i}function S1(n){var t=w1(n);return Nm.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function R1(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}function _1(n){var t=n.reduce(function(e,i){var s=e[i.name];return e[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var _u={placement:"bottom",modifiers:[],strategy:"absolute"};function Lu(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function L1(n){n===void 0&&(n={});var t=n,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,o=s===void 0?_u:s;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},_u,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],b=!1,E={state:g,setOptions:function(D){var O=typeof D=="function"?D(g.options):D;w(),g.options=Object.assign({},o,g.options,O),g.scrollParents={reference:en(d)?Aa(d):d.contextElement?Aa(d.contextElement):[],popper:Aa(f)};var F=S1(_1([].concat(i,g.options.modifiers)));return g.orderedModifiers=F.filter(function(x){return x.enabled}),T(),E.update()},forceUpdate:function(){if(!b){var D=g.elements,O=D.reference,F=D.popper;if(Lu(O,F)){g.rects={reference:k1(O,ya(F),g.options.strategy==="fixed"),popper:Yl(F)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(Q){return g.modifiersData[Q.name]=Object.assign({},Q.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var N=g.orderedModifiers[x],H=N.fn,j=N.options,nt=j===void 0?{}:j,st=N.name;typeof H=="function"&&(g=H({state:g,options:nt,name:st,instance:E})||g)}}}},update:R1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),b=!0}};if(!Lu(d,f))return E;E.setOptions(p).then(function(C){!b&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var D=C.name,O=C.options,F=O===void 0?{}:O,x=C.effect;if(typeof x=="function"){var N=x({state:g,name:D,instance:E,options:F}),H=function(){};v.push(N||H)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var C1=[Qm,m1,Zm,fu,p1,c1,b1,Km,d1],I1=L1({defaultModifiers:C1}),x1="tippy-box",Cu="tippy-content",D1="tippy-backdrop",Iu="tippy-arrow",xu="tippy-svg-arrow",sn={passive:!0,capture:!0},Du=function(){return document.body};function tc(n,t,e){if(Array.isArray(n)){var i=n[t];return i??(Array.isArray(e)?e[t]:e)}return n}function ec(n,t){var e={}.toString.call(n);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Pu(n,t){return typeof n=="function"?n.apply(void 0,t):n}function Ou(n,t){if(t===0)return n;var e;return function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)}}function P1(n){return n.split(/\s+/).filter(Boolean)}function Sn(n){return[].concat(n)}function Mu(n,t){n.indexOf(t)===-1&&n.push(t)}function O1(n){return n.filter(function(t,e){return n.indexOf(t)===e})}function M1(n){return n.split("-")[0]}function bo(n){return[].slice.call(n)}function $u(n){return Object.keys(n).reduce(function(t,e){return n[e]!==void 0&&(t[e]=n[e]),t},{})}function Ta(){return document.createElement("div")}function Ao(n){return["Element","Fragment"].some(function(t){return ec(n,t)})}function $1(n){return ec(n,"NodeList")}function N1(n){return ec(n,"MouseEvent")}function F1(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function U1(n){return Ao(n)?[n]:$1(n)?bo(n):Array.isArray(n)?n:bo(document.querySelectorAll(n))}function ic(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Nu(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function B1(n){var t,e=Sn(n),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function G1(n,t){var e=t.clientX,i=t.clientY;return n.every(function(s){var o=s.popperRect,c=s.popperState,d=s.props,f=d.interactiveBorder,p=M1(c.placement),g=c.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,b=p==="top"?g.bottom.y:0,E=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-i+v>f,C=i-o.bottom-b>f,D=o.left-e+E>f,O=e-o.right-T>f;return w||C||D||O})}function rc(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[i](s,e)})}function Fu(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Dr={isTouch:!1},Uu=0;function H1(){Dr.isTouch||(Dr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Bu))}function Bu(){var n=performance.now();n-Uu<20&&(Dr.isTouch=!1,document.removeEventListener("mousemove",Bu)),Uu=n}function V1(){var n=document.activeElement;if(F1(n)){var t=n._tippy;n.blur&&!t.state.isVisible&&n.blur()}}function W1(){document.addEventListener("touchstart",H1,sn),window.addEventListener("blur",V1)}var j1=typeof window<"u"&&typeof document<"u",K1=j1?!!window.msCrypto:!1,z1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Y1={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},yr=Object.assign({appendTo:Du,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},z1,Y1),X1=Object.keys(yr),Z1=function(t){var e=Object.keys(t);e.forEach(function(i){yr[i]=t[i]})};function Gu(n){var t=n.plugins||[],e=t.reduce(function(i,s){var o=s.name,c=s.defaultValue;if(o){var d;i[o]=n[o]!==void 0?n[o]:(d=yr[o])!=null?d:c}return i},{});return Object.assign({},n,e)}function q1(n,t){var e=t?Object.keys(Gu(Object.assign({},yr,{plugins:t}))):X1,i=e.reduce(function(s,o){var c=(n.getAttribute("data-tippy-"+o)||"").trim();if(!c)return s;if(o==="content")s[o]=c;else try{s[o]=JSON.parse(c)}catch{s[o]=c}return s},{});return i}function Hu(n,t){var e=Object.assign({},t,{content:Pu(t.content,[n])},t.ignoreAttributes?{}:q1(n,t.plugins));return e.aria=Object.assign({},yr.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Q1=function(){return"innerHTML"};function sc(n,t){n[Q1()]=t}function Vu(n){var t=Ta();return n===!0?t.className=Iu:(t.className=xu,Ao(n)?t.appendChild(n):sc(t,n)),t}function Wu(n,t){Ao(t.content)?(sc(n,""),n.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?sc(n,t.content):n.textContent=t.content)}function nc(n){var t=n.firstElementChild,e=bo(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Cu)}),arrow:e.find(function(i){return i.classList.contains(Iu)||i.classList.contains(xu)}),backdrop:e.find(function(i){return i.classList.contains(D1)})}}function ju(n){var t=Ta(),e=Ta();e.className=x1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ta();i.className=Cu,i.setAttribute("data-state","hidden"),Wu(i,n.props),t.appendChild(e),e.appendChild(i),s(n.props,n.props);function s(o,c){var d=nc(t),f=d.box,p=d.content,g=d.arrow;c.theme?f.setAttribute("data-theme",c.theme):f.removeAttribute("data-theme"),typeof c.animation=="string"?f.setAttribute("data-animation",c.animation):f.removeAttribute("data-animation"),c.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof c.maxWidth=="number"?c.maxWidth+"px":c.maxWidth,c.role?f.setAttribute("role",c.role):f.removeAttribute("role"),(o.content!==c.content||o.allowHTML!==c.allowHTML)&&Wu(p,n.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(Vu(c.arrow))):f.appendChild(Vu(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:s}}ju.$$tippy=!0;var J1=1,Eo=[],ac=[];function tv(n,t){var e=Hu(n,Object.assign({},yr,Gu($u(t)))),i,s,o,c=!1,d=!1,f=!1,p=!1,g,v,b,E=[],T=Ou(Ce,e.interactiveDebounce),w,C=J1++,D=null,O=O1(e.plugins),F={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:C,reference:n,popper:Ta(),popperInstance:D,props:e,state:F,plugins:O,clearDelayTimeouts:Ne,setProps:Ci,setContent:ss,show:ci,hide:kr,hideWithInteractivity:_s,enable:ei,disable:Xi,unmount:Ls,destroy:ir};if(!e.render)return x;var N=e.render(x),H=N.popper,j=N.onUpdate;H.setAttribute("data-tippy-root",""),H.id="tippy-"+x.id,x.popper=H,n._tippy=x,H._tippy=x;var nt=O.map(function(ct){return ct.fn(x)}),st=n.hasAttribute("aria-expanded");return jt(),Z(),St(),$("onCreate",[x]),e.showOnCreate&&me(),H.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),H.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Vt().addEventListener("mousemove",T)}),x;function Q(){var ct=x.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return Q()[0]==="hold"}function gt(){var ct;return!!((ct=x.props.render)!=null&&ct.$$tippy)}function Mt(){return w||n}function Vt(){var ct=Mt().parentNode;return ct?B1(ct):document}function V(){return nc(H)}function J(ct){return x.state.isMounted&&!x.state.isVisible||Dr.isTouch||g&&g.type==="focus"?0:tc(x.props.delay,ct?0:1,yr.delay)}function St(ct){ct===void 0&&(ct=!1),H.style.pointerEvents=x.props.interactive&&!ct?"":"none",H.style.zIndex=""+x.props.zIndex}function $(ct,Gt,Xt){if(Xt===void 0&&(Xt=!0),nt.forEach(function(ae){ae[ct]&&ae[ct].apply(ae,Gt)}),Xt){var ve;(ve=x.props)[ct].apply(ve,Gt)}}function U(){var ct=x.props.aria;if(ct.content){var Gt="aria-"+ct.content,Xt=H.id,ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){var ni=ae.getAttribute(Gt);if(x.state.isVisible)ae.setAttribute(Gt,ni?ni+" "+Xt:Xt);else{var Ii=ni&&ni.replace(Xt,"").trim();Ii?ae.setAttribute(Gt,Ii):ae.removeAttribute(Gt)}})}}function Z(){if(!(st||!x.props.aria.expanded)){var ct=Sn(x.props.triggerTarget||n);ct.forEach(function(Gt){x.props.interactive?Gt.setAttribute("aria-expanded",x.state.isVisible&&Gt===Mt()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function ft(){Vt().removeEventListener("mousemove",T),Eo=Eo.filter(function(ct){return ct!==T})}function bt(ct){if(!(Dr.isTouch&&(f||ct.type==="mousedown"))){var Gt=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(x.props.interactive&&Fu(H,Gt))){if(Sn(x.props.triggerTarget||n).some(function(Xt){return Fu(Xt,Gt)})){if(Dr.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[x,ct]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||ue())}}}function xt(){f=!0}function Ut(){f=!1}function Qt(){var ct=Vt();ct.addEventListener("mousedown",bt,!0),ct.addEventListener("touchend",bt,sn),ct.addEventListener("touchstart",Ut,sn),ct.addEventListener("touchmove",xt,sn)}function ue(){var ct=Vt();ct.removeEventListener("mousedown",bt,!0),ct.removeEventListener("touchend",bt,sn),ct.removeEventListener("touchstart",Ut,sn),ct.removeEventListener("touchmove",xt,sn)}function se(ct,Gt){Me(ct,function(){!x.state.isVisible&&H.parentNode&&H.parentNode.contains(H)&&Gt()})}function Yt(ct,Gt){Me(ct,Gt)}function Me(ct,Gt){var Xt=V().box;function ve(ae){ae.target===Xt&&(rc(Xt,"remove",ve),Gt())}if(ct===0)return Gt();rc(Xt,"remove",v),rc(Xt,"add",ve),v=ve}function be(ct,Gt,Xt){Xt===void 0&&(Xt=!1);var ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){ae.addEventListener(ct,Gt,Xt),E.push({node:ae,eventType:ct,handler:Gt,options:Xt})})}function jt(){kt()&&(be("touchstart",oe,{passive:!0}),be("touchend",Ft,{passive:!0})),P1(x.props.trigger).forEach(function(ct){if(ct!=="manual")switch(be(ct,oe),ct){case"mouseenter":be("mouseleave",Ft);break;case"focus":be(K1?"focusout":"blur",Ze);break;case"focusin":be("focusout",Ze);break}})}function ge(){E.forEach(function(ct){var Gt=ct.node,Xt=ct.eventType,ve=ct.handler,ae=ct.options;Gt.removeEventListener(Xt,ve,ae)}),E=[]}function oe(ct){var Gt,Xt=!1;if(!(!x.state.isEnabled||qe(ct)||d)){var ve=((Gt=g)==null?void 0:Gt.type)==="focus";g=ct,w=ct.currentTarget,Z(),!x.state.isVisible&&N1(ct)&&Eo.forEach(function(ae){return ae(ct)}),ct.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||c)&&x.props.hideOnClick!==!1&&x.state.isVisible?Xt=!0:me(ct),ct.type==="click"&&(c=!Xt),Xt&&!ve&&ti(ct)}}function Ce(ct){var Gt=ct.target,Xt=Mt().contains(Gt)||H.contains(Gt);if(!(ct.type==="mousemove"&&Xt)){var ve=li().concat(H).map(function(ae){var ni,Ii=ae._tippy,ur=(ni=Ii.popperInstance)==null?void 0:ni.state;return ur?{popperRect:ae.getBoundingClientRect(),popperState:ur,props:e}:null}).filter(Boolean);G1(ve,ct)&&(ft(),ti(ct))}}function Ft(ct){var Gt=qe(ct)||x.props.trigger.indexOf("click")>=0&&c;if(!Gt){if(x.props.interactive){x.hideWithInteractivity(ct);return}ti(ct)}}function Ze(ct){x.props.trigger.indexOf("focusin")<0&&ct.target!==Mt()||x.props.interactive&&ct.relatedTarget&&H.contains(ct.relatedTarget)||ti(ct)}function qe(ct){return Dr.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function $i(){Tr();var ct=x.props,Gt=ct.popperOptions,Xt=ct.placement,ve=ct.offset,ae=ct.getReferenceClientRect,ni=ct.moveTransition,Ii=gt()?nc(H).arrow:null,ur=ae?{getBoundingClientRect:ae,contextElement:ae.contextElement||Mt()}:n,ns={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Cs){var xi=Cs.state;if(gt()){var Oa=V(),gr=Oa.box;["placement","reference-hidden","escaped"].forEach(function(Is){Is==="placement"?gr.setAttribute("data-placement",xi.placement):xi.attributes.popper["data-popper-"+Is]?gr.setAttribute("data-"+Is,""):gr.removeAttribute("data-"+Is)}),xi.attributes.popper={}}}},fr=[{name:"offset",options:{offset:ve}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ni}},ns];gt()&&Ii&&fr.push({name:"arrow",options:{element:Ii,padding:3}}),fr.push.apply(fr,(Gt==null?void 0:Gt.modifiers)||[]),x.popperInstance=I1(ur,H,Object.assign({},Gt,{placement:Xt,onFirstUpdate:b,modifiers:fr}))}function Tr(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ke(){var ct=x.props.appendTo,Gt,Xt=Mt();x.props.interactive&&ct===Du||ct==="parent"?Gt=Xt.parentNode:Gt=Pu(ct,[Xt]),Gt.contains(H)||Gt.appendChild(H),x.state.isMounted=!0,$i()}function li(){return bo(H.querySelectorAll("[data-tippy-root]"))}function me(ct){x.clearDelayTimeouts(),ct&&$("onTrigger",[x,ct]),Qt();var Gt=J(!0),Xt=Q(),ve=Xt[0],ae=Xt[1];Dr.isTouch&&ve==="hold"&&ae&&(Gt=ae),Gt?i=setTimeout(function(){x.show()},Gt):x.show()}function ti(ct){if(x.clearDelayTimeouts(),$("onUntrigger",[x,ct]),!x.state.isVisible){ue();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&c)){var Gt=J(!1);Gt?s=setTimeout(function(){x.state.isVisible&&x.hide()},Gt):o=requestAnimationFrame(function(){x.hide()})}}function ei(){x.state.isEnabled=!0}function Xi(){x.hide(),x.state.isEnabled=!1}function Ne(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(o)}function Ci(ct){if(!x.state.isDestroyed){$("onBeforeUpdate",[x,ct]),ge();var Gt=x.props,Xt=Hu(n,Object.assign({},Gt,$u(ct),{ignoreAttributes:!0}));x.props=Xt,jt(),Gt.interactiveDebounce!==Xt.interactiveDebounce&&(ft(),T=Ou(Ce,Xt.interactiveDebounce)),Gt.triggerTarget&&!Xt.triggerTarget?Sn(Gt.triggerTarget).forEach(function(ve){ve.removeAttribute("aria-expanded")}):Xt.triggerTarget&&n.removeAttribute("aria-expanded"),Z(),St(),j&&j(Gt,Xt),x.popperInstance&&($i(),li().forEach(function(ve){requestAnimationFrame(ve._tippy.popperInstance.forceUpdate)})),$("onAfterUpdate",[x,ct])}}function ss(ct){x.setProps({content:ct})}function ci(){var ct=x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=Dr.isTouch&&!x.props.touch,ae=tc(x.props.duration,0,yr.duration);if(!(ct||Gt||Xt||ve)&&!Mt().hasAttribute("disabled")&&($("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,gt()&&(H.style.visibility="visible"),St(),Qt(),x.state.isMounted||(H.style.transition="none"),gt()){var ni=V(),Ii=ni.box,ur=ni.content;ic([Ii,ur],0)}b=function(){var fr;if(!(!x.state.isVisible||p)){if(p=!0,H.offsetHeight,H.style.transition=x.props.moveTransition,gt()&&x.props.animation){var pr=V(),Cs=pr.box,xi=pr.content;ic([Cs,xi],ae),Nu([Cs,xi],"visible")}U(),Z(),Mu(ac,x),(fr=x.popperInstance)==null||fr.forceUpdate(),$("onMount",[x]),x.props.animation&&gt()&&Yt(ae,function(){x.state.isShown=!0,$("onShown",[x])})}},ke()}}function kr(){var ct=!x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=tc(x.props.duration,1,yr.duration);if(!(ct||Gt||Xt)&&($("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,c=!1,gt()&&(H.style.visibility="hidden"),ft(),ue(),St(!0),gt()){var ae=V(),ni=ae.box,Ii=ae.content;x.props.animation&&(ic([ni,Ii],ve),Nu([ni,Ii],"hidden"))}U(),Z(),x.props.animation?gt()&&se(ve,x.unmount):x.unmount()}}function _s(ct){Vt().addEventListener("mousemove",T),Mu(Eo,T),T(ct)}function Ls(){x.state.isVisible&&x.hide(),x.state.isMounted&&(Tr(),li().forEach(function(ct){ct._tippy.unmount()}),H.parentNode&&H.parentNode.removeChild(H),ac=ac.filter(function(ct){return ct!==x}),x.state.isMounted=!1,$("onHidden",[x]))}function ir(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),ge(),delete n._tippy,x.state.isDestroyed=!0,$("onDestroy",[x]))}}function nn(n,t){t===void 0&&(t={});var e=yr.plugins.concat(t.plugins||[]);W1();var i=Object.assign({},t,{plugins:e}),s=U1(n),o=s.reduce(function(c,d){var f=d&&tv(d,i);return f&&c.push(f),c},[]);return Ao(n)?o[0]:o}nn.defaultProps=yr,nn.setDefaultProps=Z1,nn.currentInput=Dr,Object.assign({},fu,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),nn.setDefaultProps({render:ju});class Qr extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const ev=5;class iv{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wi(),this._controls=wi(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,s,o,c;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<=g+v))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:g})=>d>=g-ev&&d<g))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=eu((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var b;const E=d-f.start+(((b=f.videoMeta)==null?void 0:b.start)??0);return g&&v&&E>=fo(g)&&E<=fo(v)}))==null?void 0:c.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Si(this._canvas)}controls(){return Si(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,s;const{start:o,duration:c,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:b}=d,{start:E,duration:T}=f,w=this.host.videoState[g];b&&w&&(b.currentTime>=E+T||b.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,b.currentTime):w.initialised||(i=b.startLoadOnce)==null||i.call(b)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((s=v==null?void 0:v.buffered)!=null&&s.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+c)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:s}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(s&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&o.initialised)try{return s.play()}catch(d){throw new Qr(`Video play error: ${d.message}`,!0)}}else s.paused||s.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function rv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ku={exports:{}};(function(n,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var b=d.parseURL(p);if(!b)throw new Error("Error trying to parse relative URL.");if(b.scheme)return g.alwaysNormalize?(b.path=d.normalizePath(b.path),d.buildURLFromParts(b)):p;var E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var T=s.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:b.netLoc,path:null,params:b.params,query:b.query,fragment:b.fragment};if(!b.netLoc&&(w.netLoc=E.netLoc,b.path[0]!=="/"))if(!b.path)w.path=E.path,b.params||(w.params=E.params,b.query||(w.query=E.query));else{var C=E.path,D=C.substring(0,C.lastIndexOf("/")+1)+b.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(b.path):b.path),d.buildURLFromParts(w)},parseURL:function(f){var p=i.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(c,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};n.exports=d})()})(Ku);var oc=Ku.exports;function zu(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Wi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?zu(Object(e),!0).forEach(function(i){sv(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):zu(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function sv(n,t,e){return t=av(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function ai(){return ai=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},ai.apply(this,arguments)}function nv(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function av(n){var t=nv(n,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)};let R=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n}({}),qt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),ut=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const an=function(){},lc={trace:an,debug:an,log:an,warn:an,info:an,error:an};let ka=lc;function ov(n){const t=self.console[n];return t?t.bind(self.console,`[${n}] >`):an}function lv(n,...t){t.forEach(function(e){ka[e]=n[e]?n[e].bind(n):ov(e)})}function cv(n,t){if(self.console&&n===!0||typeof n=="object"){lv(n,"debug","log","info","warn","error");try{ka.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{ka=lc}}else ka=lc}const Y=ka,hv=/^(\d+)x(\d+)$/,Yu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ze{constructor(t){typeof t=="string"&&(t=ze.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let s=0;s<e.length/2;s++)i[s]=parseInt(e.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=hv.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},s='"';for(Yu.lastIndex=0;(e=Yu.exec(t))!==null;){let o=e[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function dv(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function uv(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class Xu{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){Y.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=ai(new ze({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);Wt(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(Wt(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class To{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 Le={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Zu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Le.AUDIO]:null,[Le.VIDEO]:null,[Le.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),s=[];i.length===1?s[0]=e?e.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=oc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class cc extends Zu{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new To,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Wt(this.programDateTime))return null;const t=Wt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,s,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:o,partial:c};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,s),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Le.AUDIO]=null,t[Le.VIDEO]=null,t[Le.AUDIOVIDEO]=null}}class fv extends Zu{constructor(t,e,i,s,o){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new To,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const pv=10;class gv{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||pv}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function hc(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function mv(n){const t=qu(n).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function vv(n){const t=function(e,i,s){const o=e[i];e[i]=e[s],e[s]=o};t(n,0,3),t(n,1,2),t(n,4,5),t(n,6,7)}function yv(n){const t=n.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const o=s[0]==="base64",c=s[1];o?(i.splice(-1,1),e=hc(c)):e=mv(c)}}return e}function qu(n){return Uint8Array.from(unescape(encodeURIComponent(n)),t=>t.charCodeAt(0))}var Ye={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ji={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Qu(n){switch(n){case ji.FAIRPLAY:return Ye.FAIRPLAY;case ji.PLAYREADY:return Ye.PLAYREADY;case ji.WIDEVINE:return Ye.WIDEVINE;case ji.CLEARKEY:return Ye.CLEARKEY}}var Ju={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function bv(n){if(n===Ju.WIDEVINE)return Ye.WIDEVINE}function t0(n){switch(n){case Ye.FAIRPLAY:return ji.FAIRPLAY;case Ye.PLAYREADY:return ji.PLAYREADY;case Ye.WIDEVINE:return ji.WIDEVINE;case Ye.CLEARKEY:return ji.CLEARKEY}}function dc(n){const{drmSystems:t,widevineLicenseUrl:e}=n,i=t?[Ye.FAIRPLAY,Ye.WIDEVINE,Ye.PLAYREADY,Ye.CLEARKEY].filter(s=>!!t[s]):[];return!i[Ye.WIDEVINE]&&e&&i.push(Ye.WIDEVINE),i}const e0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Av(n,t,e,i){let s;switch(n){case Ye.FAIRPLAY:s=["cenc","sinf"];break;case Ye.WIDEVINE:case Ye.PLAYREADY:s=["cenc"];break;case Ye.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return Ev(s,t,e,i)}function Ev(n,t,e,i){return[{initDataTypes:n,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function on(n,t,e){return Uint8Array.prototype.slice?n.slice(t,e):new Uint8Array(Array.prototype.slice.call(n,t,e))}const uc=(n,t)=>t+10<=n.length&&n[t]===73&&n[t+1]===68&&n[t+2]===51&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,i0=(n,t)=>t+10<=n.length&&n[t]===51&&n[t+1]===68&&n[t+2]===73&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,ko=(n,t)=>{const e=t;let i=0;for(;uc(n,t);){i+=10;const s=wo(n,t+6);i+=s,i0(n,t+10)&&(i+=10),t+=i}if(i>0)return n.subarray(e,e+i)},wo=(n,t)=>{let e=0;return e=(n[t]&127)<<21,e|=(n[t+1]&127)<<14,e|=(n[t+2]&127)<<7,e|=n[t+3]&127,e},Tv=(n,t)=>uc(n,t)&&wo(n,t+6)+10<=n.length-t,kv=n=>{const t=s0(n);for(let e=0;e<t.length;e++){const i=t[e];if(r0(i))return Cv(i)}},r0=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",wv=n=>{const t=String.fromCharCode(n[0],n[1],n[2],n[3]),e=wo(n,4),i=10;return{type:t,size:e,data:n.subarray(i,i+e)}},s0=n=>{let t=0;const e=[];for(;uc(n,t);){const i=wo(n,t+6);t+=10;const s=t+i;for(;t+8<s;){const o=wv(n.subarray(t)),c=Sv(o);c&&e.push(c),t+=o.size+10}i0(n,t)&&(t+=10)}return e},Sv=n=>n.type==="PRIV"?Rv(n):n.type[0]==="W"?Lv(n):_v(n),Rv=n=>{if(n.size<2)return;const t=Pr(n.data,!0),e=new Uint8Array(n.data.subarray(t.length+1));return{key:n.type,info:t,data:e.buffer}},_v=n=>{if(n.size<2)return;if(n.type==="TXXX"){let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data.subarray(1));return{key:n.type,data:t}},Lv=n=>{if(n.type==="WXXX"){if(n.size<2)return;let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data);return{key:n.type,data:t}},Cv=n=>{if(n.data.byteLength===8){const t=new Uint8Array(n.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},Pr=(n,t=!1)=>{const e=Iv();if(e){const p=e.decode(n);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=n.length;let s,o,c,d="",f=0;for(;f<i;){if(s=n[f++],s===0&&t)return d;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(s);break;case 12:case 13:o=n[f++],d+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=n[f++],c=n[f++],d+=String.fromCharCode((s&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let fc;function Iv(){return!fc&&typeof self.TextDecoder<"u"&&(fc=new self.TextDecoder("utf-8")),fc}const Or={hexDump:function(n){let t="";for(let e=0;e<n.length;e++){let i=n[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},So=Math.pow(2,32)-1,xv=[].push,n0={video:1,audio:2,id3:3,text:4};function Ei(n){return String.fromCharCode.apply(null,n)}function a0(n,t){const e=n[t]<<8|n[t+1];return e<0?65536+e:e}function ie(n,t){const e=o0(n,t);return e<0?4294967296+e:e}function o0(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function pc(n,t,e){n[t]=e>>24,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255}function ye(n,t){const e=[];if(!t.length)return e;const i=n.byteLength;for(let s=0;s<i;){const o=ie(n,s),c=Ei(n.subarray(s+4,s+8)),d=o>1?s+o:i;if(c===t[0])if(t.length===1)e.push(n.subarray(s+8,d));else{const f=ye(n.subarray(s+8,d),t.slice(1));f.length&&xv.apply(e,f)}s=d}return e}function Dv(n){const t=[],e=n[0];let i=8;const s=ie(n,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=n.length+c;const f=a0(n,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ie(n,g);g+=4;const b=v&2147483647;if((v&2147483648)>>>31===1)return Y.warn("SIDX has hierarchical references (not supported)"),null;const E=ie(n,g);g+=4,t.push({referenceSize:b,subsegmentDuration:E,info:{duration:E/s,start:d,end:d+b-1}}),d+=b,g+=4,i=g}return{earliestPresentationTime:o,timescale:s,version:e,referencesCount:f,references:t}}function l0(n){const t=[],e=ye(n,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],o=ye(s,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ie(o,d),p=ye(s,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ie(p,d),v=ye(s,["mdia","hdlr"])[0];if(v){const b=Ei(v.subarray(8,12)),E={soun:Le.AUDIO,vide:Le.VIDEO}[b];if(E){const T=ye(s,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=Ei(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return ye(n,["moov","mvex","trex"]).forEach(i=>{const s=ie(i,4),o=t[s];o&&(o.default={duration:ie(i,12),flags:ie(i,20)})}),t}function Pv(n,t){if(!n||!t)return n;const e=t.keyId;return e&&t.isCommonEncryption&&ye(n,["moov","trak"]).forEach(i=>{const s=ye(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=ye(s,["enca"]);const c=o.length>0;c||(o=ye(s,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);ye(f,["sinf"]).forEach(p=>{const g=c0(p);if(g){const v=g.subarray(8,24);v.some(b=>b!==0)||(Y.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Or.hexDump(v)} -> ${Or.hexDump(e)}`),g.set(e,8))}})})}),n}function c0(n){const t=ye(n,["schm"])[0];if(t){const e=Ei(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ye(n,["schi","tenc"])[0]}return Y.error("[eme] missing 'schm' box"),null}function Ov(n,t){return ye(t,["moof","traf"]).reduce((e,i)=>{const s=ye(i,["tfdt"])[0],o=s[0],c=ye(i,["tfhd"]).reduce((d,f)=>{const p=ie(f,4),g=n[p];if(g){let v=ie(s,4);if(o===1){if(v===So)return Y.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=So+1,v+=ie(s,8)}const b=g.timescale||9e4,E=v/b;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return c!==null&&isFinite(c)&&(e===null||c<e)?c:e},null)}function Mv(n,t){let e=0,i=0,s=0;const o=ye(n,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=ye(d,["tfhd"])[0],p=ie(f,4),g=t[p];if(!g)continue;const v=g.default,b=ie(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;b&8&&(b&2?E=ie(f,12):E=ie(f,8));const T=g.timescale||9e4,w=ye(d,["trun"]);for(let C=0;C<w.length;C++){if(e=$v(w[C]),!e&&E){const D=ie(w[C],4);e=E*D}g.type===Le.VIDEO?i+=e/T:g.type===Le.AUDIO&&(s+=e/T)}}if(i===0&&s===0){let c=0;const d=ye(n,["sidx"]);for(let f=0;f<d.length;f++){const p=Dv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||s}function $v(n){const t=ie(n,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=ie(n,4);for(let o=0;o<s;o++){if(t&256){const c=ie(n,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function Nv(n,t,e){ye(t,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(s=>{const o=ie(s,4),c=n[o];if(!c)return;const d=c.timescale||9e4;ye(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ie(f,4);if(p===0)g-=e*d,g=Math.max(g,0),pc(f,4,g);else{g*=Math.pow(2,32),g+=ie(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(So+1)),b=Math.floor(g%(So+1));pc(f,4,v),pc(f,8,b)}})})})}function Fv(n){const t={valid:null,remainder:null},e=ye(n,["moof"]);if(e){if(e.length<2)return t.remainder=n,t}else return t;const i=e[e.length-1];return t.valid=on(n,0,i.byteOffset-8),t.remainder=on(n,i.byteOffset-8),t}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function h0(n,t){const e=[],i=t.samples,s=t.timescale,o=t.id;let c=!1;return ye(i,["moof"]).map(d=>{const f=d.byteOffset-8;ye(d,["traf"]).map(p=>{const g=ye(p,["tfdt"]).map(v=>{const b=v[0];let E=ie(v,4);return b===1&&(E*=Math.pow(2,32),E+=ie(v,8)),E/s})[0];return g!==void 0&&(n=g),ye(p,["tfhd"]).map(v=>{const b=ie(v,4),E=ie(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let D=0;const O=(E&16)!==0;let F=0;const x=(E&32)!==0;let N=8;b===o&&(T&&(N+=8),w&&(N+=4),C&&(D=ie(v,N),N+=4),O&&(F=ie(v,N),N+=4),x&&(N+=4),t.type==="video"&&(c=Uv(t.codec)),ye(p,["trun"]).map(H=>{const j=H[0],nt=ie(H,0)&16777215,st=(nt&1)!==0;let Q=0;const kt=(nt&4)!==0,gt=(nt&256)!==0;let Mt=0;const Vt=(nt&512)!==0;let V=0;const J=(nt&1024)!==0,St=(nt&2048)!==0;let $=0;const U=ie(H,4);let Z=8;st&&(Q=ie(H,Z),Z+=4),kt&&(Z+=4);let ft=Q+f;for(let bt=0;bt<U;bt++){if(gt?(Mt=ie(H,Z),Z+=4):Mt=D,Vt?(V=ie(H,Z),Z+=4):V=F,J&&(Z+=4),St&&(j===0?$=ie(H,Z):$=o0(H,Z),Z+=4),t.type===Le.VIDEO){let xt=0;for(;xt<V;){const Ut=ie(i,ft);if(ft+=4,Bv(c,i[ft])){const Qt=i.subarray(ft,ft+Ut);d0(Qt,c?2:1,n+$/s,e)}ft+=Ut,xt+=Ut+4}}n+=Mt/s}}))})})}),e}function Uv(n){if(!n)return!1;const t=n.indexOf("."),e=t<0?n:n.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Bv(n,t){if(n){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function d0(n,t,e,i){const s=u0(n);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<s.length;){c=0;do{if(o>=s.length)break;p=s[o++],c+=p}while(p===255);d=0;do{if(o>=s.length)break;p=s[o++],d+=p}while(p===255);const g=s.length-o;if(!f&&c===4&&o<s.length){if(f=!0,s[o++]===181){const v=a0(s,o);if(o+=2,v===49){const b=ie(s,o);if(o+=4,b===1195456820){const E=s[o++];if(E===3){const T=s[o++],w=31&T,C=64&T,D=C?2+w*3:0,O=new Uint8Array(D);if(C){O[0]=T;for(let F=1;F<D;F++)O[F]=s[o++]}i.push({type:E,payloadType:c,pts:e,bytes:O})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=s[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const b=d-16,E=new Uint8Array(b);for(let T=0;T<b;T++)E[T]=s[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:Pr(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function u0(n){const t=n.byteLength,e=[];let i=1;for(;i<t-2;)n[i]===0&&n[i+1]===0&&n[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return n;const s=t-e.length,o=new Uint8Array(s);let c=0;for(i=0;i<s;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=n[c];return o}function Gv(n){const t=n[0];let e="",i="",s=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;Ei(n.subarray(p,p+1))!=="\0";)e+=Ei(n.subarray(p,p+1)),p+=1;for(e+=Ei(n.subarray(p,p+1)),p+=1;Ei(n.subarray(p,p+1))!=="\0";)i+=Ei(n.subarray(p,p+1)),p+=1;i+=Ei(n.subarray(p,p+1)),p+=1,s=ie(n,12),o=ie(n,16),d=ie(n,20),f=ie(n,24),p=28}else if(t===1){p+=4,s=ie(n,p),p+=4;const v=ie(n,p);p+=4;const b=ie(n,p);for(p+=4,c=4294967296*v+b,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,Y.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ie(n,p),p+=4,f=ie(n,p),p+=4;Ei(n.subarray(p,p+1))!=="\0";)e+=Ei(n.subarray(p,p+1)),p+=1;for(e+=Ei(n.subarray(p,p+1)),p+=1;Ei(n.subarray(p,p+1))!=="\0";)i+=Ei(n.subarray(p,p+1)),p+=1;i+=Ei(n.subarray(p,p+1)),p+=1}const g=n.subarray(p,n.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Hv(n,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(n,4),s=0,i=8;s<e;s++)o.set(t[s],i),i+=t[s].byteLength;return o}function Vv(n,t,e){if(n.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");s.set(f,d*16)}}else i=0,s=new Uint8Array;let o;i>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),Hv([112,115,115,104],new Uint8Array([i,0,0,0]),n,o,s,c,e||new Uint8Array)}function Wv(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(n),i=e.getUint32(0);if(n.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Or.hexDump(new Uint8Array(n,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(n,32,s)}else if(t.version===1){t.kids=[];for(let o=0;o<s;o++)t.kids.push(new Uint8Array(n,32+o*16,16))}return t}let Ro={};class wa{static clearKeyUriToKeyIdMap(){Ro={}}constructor(t,e,i,s=[1],o=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ji.FAIRPLAY:case ji.WIDEVINE:case ji.PLAYREADY:case ji.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&Y.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=jv(t);return new wa(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=yv(this.uri);if(e)switch(this.keyFormat){case ji.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case ji.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Vv(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),c=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=hc(f).subarray(0,16);vv(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Ro[this.uri];if(!i){const s=Object.keys(Ro).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),Ro[this.uri]=i}this.keyId=i}return this}}function jv(n){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=n>>8*(15-e)&255;return t}const f0=/\{\$([a-zA-Z0-9-_]+)\}/g;function p0(n){return f0.test(n)}function Ki(n,t,e){if(n.variableList!==null||n.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],o=t[s];o&&(t[s]=gc(n,o))}}function gc(n,t){if(n.variableList!==null||n.hasVariableRefs){const e=n.variableList;return t.replace(f0,i=>{const s=i.substring(2,i.length-1),o=e==null?void 0:e[s];return o===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):o})}return t}function g0(n,t,e){let i=n.variableList;i||(n.variableList=i={});let s,o;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(s))o=c.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(c){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else s=t.NAME,o=t.VALUE;s in i?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=o||""}function Kv(n,t,e){const i=t.IMPORT;if(e&&i in e){let s=n.variableList;s||(n.variableList=s={}),s[i]=e[i]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function _o(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const zv={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}},m0=_o();function Yv(n,t){const e=zv[t];return!!e&&e[n.slice(0,4)]===!0}function mc(n,t){var e;return(e=m0==null?void 0:m0.isTypeSupported(`${t||"video"}/mp4;codecs="${n}"`))!=null?e:!1}const v0=/#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,y0=/#EXT-X-MEDIA:(.*)/g,Xv=/^#EXT(?:INF|-X-TARGETDURATION):/m,b0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Zv=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class br{static findGroup(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.id===e)return s}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return oc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Xv.test(t)}static parseMasterPlaylist(t,e){const i=p0(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];v0.lastIndex=0;let c;for(;(c=v0.exec(t))!=null;)if(c[1]){var d;const p=new ze(c[1]);Ki(s,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=gc(s,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:br.resolve(g,e)},b=p.decimalResolution("RESOLUTION");b&&(v.width=b.width,v.height=b.height),qv((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=br.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),s.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ze(g);Ki(s,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const b=v["DATA-ID"];b&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[b]=v);break}case"SESSION-KEY":{const v=A0(g,e,s);v.encrypted&&v.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(v)):Y.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ze(g);Ki(s,v,["NAME","VALUE","QUERYPARAM"]),g0(s,v,e)}break}case"CONTENT-STEERING":{const v=new ze(g);Ki(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:br.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=E0(g);break}}}const f=o.length>0&&o.length<s.levels.length;return s.levels=f?o:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const o={},c=i.levels,d={AUDIO:c.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:c.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(y0.lastIndex=0;(s=y0.exec(t))!==null;){const p=new ze(s[1]),g=p.TYPE;if(g){const v=d[g],b=o[g]||[];o[g]=b,Ki(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const E={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?br.resolve(p.URI,e):""};if(v!=null&&v.length){const T=br.findGroup(v,E.groupId)||v[0];T0(E,T,"audioCodec"),T0(E,T,"textCodec")}b.push(E)}}return o}static parseLevelPlaylist(t,e,i,s,o,c){const d=new gv(e),f=d.fragments;let p=null,g=0,v=0,b=0,E=0,T=null,w=new cc(s,e),C,D,O,F=-1,x=!1;for(b0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=p0(t);(C=b0.exec(t))!==null;){x&&(x=!1,w=new cc(s,e),w.start=b,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const nt=C[1];if(nt){w.duration=parseFloat(nt);const st=(" "+C[2]).slice(1);w.title=st||null,w.tagList.push(st?["INF",nt,st]:["INF",nt])}else if(C[3]){if(Wt(w.duration)){w.start=b,O&&S0(w,O,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const st=(" "+C[3]).slice(1);w.relurl=gc(d,st),k0(w,T),T=w,b+=w.duration,g++,v=0,x=!0}}else if(C[4]){const st=(" "+C[4]).slice(1);T?w.setByteRange(st,T):w.setByteRange(st)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),F===-1&&(F=f.length);else{if(C=C[0].match(Zv),!C){Y.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<C.length&&!(typeof C[D]<"u");D++);const st=(" "+C[D]).slice(1),Q=(" "+C[D+1]).slice(1),kt=C[D+2]?(" "+C[D+2]).slice(1):"";switch(st){case"PLAYLIST-TYPE":d.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(Q);break;case"SKIP":{const gt=new ze(Q);Ki(d,gt,["RECENTLY-REMOVED-DATERANGES"]);const Mt=gt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Mt)){d.skippedSegments=Mt;for(let V=Mt;V--;)f.unshift(null);g+=Mt}const Vt=gt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Vt&&(d.recentlyRemovedDateranges=Vt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":d.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(Q||kt)&&w.tagList.push(kt?[Q,kt]:[Q]);break;case"DISCONTINUITY":E++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([st]);break;case"BITRATE":w.tagList.push([st,Q]);break;case"DATERANGE":{const gt=new ze(Q);Ki(d,gt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Ki(d,gt,gt.clientAttrs);const Mt=new Xu(gt,d.dateRanges[gt.ID]);Mt.isValid||d.skippedSegments?d.dateRanges[Mt.id]=Mt:Y.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),w.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const gt=new ze(Q);Ki(d,gt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in gt?Kv(d,gt,c):g0(d,gt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(Q);break;case"KEY":{const gt=A0(Q,e,d);if(gt.isSupported()){if(gt.method==="NONE"){O=void 0;break}O||(O={}),O[gt.keyFormat]&&(O=ai({},O)),O[gt.keyFormat]=gt}else Y.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":d.startTimeOffset=E0(Q);break;case"MAP":{const gt=new ze(Q);if(Ki(d,gt,["BYTERANGE","URI"]),w.duration){const Mt=new cc(s,e);w0(Mt,gt,i,O),p=Mt,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else w0(w,gt,i,O),p=w,x=!0;break}case"SERVER-CONTROL":{const gt=new ze(Q);d.canBlockReload=gt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=gt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&gt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=gt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=gt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const gt=new ze(Q);d.partTarget=gt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let gt=d.partList;gt||(gt=d.partList=[]);const Mt=v>0?gt[gt.length-1]:void 0,Vt=v++,V=new ze(Q);Ki(d,V,["BYTERANGE","URI"]);const J=new fv(V,w,e,Vt,Mt);gt.push(J),w.duration+=J.duration;break}case"PRELOAD-HINT":{const gt=new ze(Q);Ki(d,gt,["URI"]),d.preloadHint=gt;break}case"RENDITION-REPORT":{const gt=new ze(Q);Ki(d,gt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(gt);break}default:Y.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),b-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(k0(w,T),w.cc=E,d.fragmentHint=w,O&&S0(w,O,d));const N=f.length,H=f[0],j=f[N-1];if(b+=d.skippedSegments*d.targetduration,b>0&&N&&j){d.averagetargetduration=b/N;const nt=j.sn;d.endSN=nt!=="initSegment"?nt:0,d.live||(j.endList=!0),H&&(d.startCC=H.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(b+=d.fragmentHint.duration),d.totalduration=b,d.endCC=E,F>0&&Qv(f,F),d}}function A0(n,t,e){var i,s;const o=new ze(n);Ki(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const c=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(s=o.KEYFORMAT)!=null?s:"identity";d&&o.IV&&!f&&Y.error(`Invalid IV: ${o.IV}`);const v=d?br.resolve(d,t):"",b=(p||"1").split("/").map(Number).filter(Number.isFinite);return new wa(c,v,g,b,f)}function E0(n){const t=new ze(n).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function qv(n,t){["video","audio","text"].forEach(e=>{const i=n.filter(s=>Yv(s,e));if(i.length){const s=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],n=n.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=n}function T0(n,t,e){const i=t[e];i&&(n[e]=i)}function Qv(n,t){let e=n[t];for(let i=t;i--;){const s=n[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function k0(n,t){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):t!=null&&t.programDateTime&&(n.programDateTime=t.endProgramDateTime),Wt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function w0(n,t,e,i){n.relurl=t.URI,t.BYTERANGE&&n.setByteRange(t.BYTERANGE),n.level=e,n.sn="initSegment",i&&(n.levelkeys=i),n.initSegment=null}function S0(n,t,e){n.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(n)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function R0(n){const{type:t}=n;switch(t){case Te.AUDIO_TRACK:return Jt.AUDIO;case Te.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function vc(n,t){let e=n.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Jv{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,o=i||s,c=new o(e);return this.loaders[t.type]=c,c}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Te.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:o,deliveryDirectives:c}=e;this.load({id:i,level:s,responseType:"text",type:Te.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const p=s.context;if(p&&p.url===t.url){Y.trace("[playlist-loader]: playlist request ongoing");return}Y.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let o;if(t.type===Te.MANIFEST?o=i.manifestLoadPolicy.default:o=ai({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Te.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Te.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const b=Math.max(g*3,v*.8)*1e3;o=ai({},o,{maxTimeToFirstByteMs:Math.min(b,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(b,o.maxTimeToFirstByteMs)})}}}const c=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},f={onSuccess:(p,g,v,b)=>{const E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),b||null,g);return}g.parsing.start=performance.now(),br.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,b||null,E):this.handleMasterPlaylist(p,g,v,b)},onError:(p,g,v,b)=>{this.handleNetworkError(g,v,!1,p,b)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};s.load(t,d,f)}handleMasterPlaylist(t,e,i,s){const o=this.hls,c=t.data,d=vc(t,i),f=br.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,s,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":D}=br.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(O=>!O.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(Y.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ze({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:D,contentSteering:p,url:d,stats:e,networkDetails:s,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,s,o){const c=this.hls,{id:d,level:f,type:p}=i,g=vc(t,i),v=Wt(d)?d:0,b=Wt(f)?f:v,E=R0(i),T=br.parseLevelPlaylist(t.data,g,b,E,v,this.variableList);if(p===Te.MANIFEST){const w={attrs:new ze({}),bitrate:0,details:T,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,s,o)}handleManifestParsingError(t,e,i,s,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Te.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:o})}handleNetworkError(t,e,i=!1,s,o){let c=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);Y.warn(`[playlist-loader]: ${c}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:f=i?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Te.LEVEL:f=i?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Te.AUDIO_TRACK:f=i?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Te.SUBTITLE_TRACK:f=i?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(s){const b=(e==null?void 0:e.url)||t.url;v.response=Wi({url:b,data:void 0},s)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,s,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:b}=s,E=vc(e,s),T=R0(s),w=typeof s.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:D,reason:D.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Te.MANIFEST:case Te.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break}}}function _0(n,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=n,t.dispatchEvent(e)}function L0(n,t){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(t.id))try{if(n.addCue(t),!n.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){Y.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,n.addCue(s)}catch(s){Y.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(n.mode=e)}function Rn(n){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let e=n.cues.length;e--;)n.removeCue(n.cues[e]);t==="disabled"&&(n.mode=t)}function yc(n,t,e,i){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const o=ey(n.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&n.removeCue(o[c])}s==="disabled"&&(n.mode=s)}function ty(n,t){if(t<n[0].startTime)return 0;const e=n.length-1;if(t>n[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const o=Math.floor((s+i)/2);if(t<n[o].startTime)s=o-1;else if(t>n[o].startTime&&i<e)i=o+1;else return o}return n[i].startTime-t<t-n[s].startTime?i:s}function ey(n,t,e){const i=[],s=ty(n,t);if(s>-1)for(let o=s,c=n.length;o<c;o++){const d=n[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Ar={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const iy=.25;function bc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Lo=(()=>{const n=bc();try{new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ac(n,t){return n.getTime()/1e3-t}function ry(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class sy{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Rn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return _0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=bc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Ar.emsg&&!i||!s)continue;const p=s0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Lo&&(v=Lo),v-g<=0&&(v=g+iy);for(let b=0;b<p.length;b++){const E=p[b];if(!r0(E)){this.updateId3CueEnds(g,f);const T=new c(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let o=s.length;o--;){const c=s[o];c.type===e&&c.startTime<t&&c.endTime===Lo&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;s==="audio"?p=g=>g.type===Ar.audioId3&&f:s==="video"?p=g=>g.type===Ar.emsg&&d:p=g=>g.type===Ar.audioId3&&f||g.type===Ar.emsg&&d,yc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:o}=e,c=Object.keys(o);if(s){const g=Object.keys(i).filter(v=>!c.includes(v));for(let v=g.length;v--;){const b=g[v];Object.keys(i[b].cues).forEach(E=>{s.removeCue(i[b].cues[E])}),delete i[b]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=bc();for(let g=0;g<c.length;g++){const v=c[g],b=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=Ac(b.startDate,f);let D=Lo;const O=b.endDate;if(O)D=Ac(O,f),w=!0;else if(b.endOnNext&&!w){const x=c.reduce((N,H)=>{const j=o[H];return j.class===b.class&&j.id!==H&&j.startDate>b.startDate&&N.push(j),N},[]).sort((N,H)=>N.startDate.getTime()-H.startDate.getTime())[0];x&&(D=Ac(x.startDate,f),w=!0)}const F=Object.keys(b.attr);for(let x=0;x<F.length;x++){const N=F[x];if(!dv(N))continue;let H=T[N];if(H)w&&!E.durationKnown&&(H.endTime=D);else{let j=b.attr[N];H=new p(C,D,""),uv(N)&&(j=ry(j)),H.value={key:N,data:j},H.type=Ar.dateRange,H.id=v,this.id3Track.addCue(H),T[N]=H}}i[v]={cues:T,dateRange:b,durationKnown:w}}}}class ny{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:o,liveSyncDurationCount:c,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:c*s);const g=s,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const s=i.edge,o=t-e-this.edgeStalled,c=s-i.totalduration,d=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(c,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&Y.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:o}=this.config;if(!s||o===1)return;const c=this.targetLatency;if(c===null)return;const d=i-c,f=Math.min(this.maxLatency,c+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const Ec=["NONE","TYPE-0","TYPE-1",null];var Sa={No:"",Yes:"YES",v2:"v2"};function ay(n,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=n,o=t!==void 0?t-s:0;return e&&o<e?i?Sa.v2:Sa.Yes:Sa.No}class C0{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Ra{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Tc(n,t){const e=t.startPTS;if(Wt(e)){let i=0,s;t.sn>n.sn?(i=e-n.start,s=n):(i=n.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>n.sn?n.cc===t.cc&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration:t.start=Math.max(n.start-t.duration,0)}function I0(n,t,e,i,s,o){i-e<=0&&(Y.warn("Fragment should have a positive duration",t),i=e+t.duration,o=s+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),s=Math.min(s,t.startDTS),d=Math.min(i,p),i=Math.max(i,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=c,t.startDTS=s,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!n||v<n.startSN||v>n.endSN)return 0;let b;const E=v-n.startSN,T=n.fragments;for(T[E]=t,b=E;b>0;b--)Tc(T[b],T[b-1]);for(b=E;b<T.length-1;b++)Tc(T[b],T[b+1]);return n.fragmentHint&&Tc(T[T.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,g}function oy(n,t){let e=null;const i=n.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,o;if(hy(n,t,(f,p)=>{f.relurl&&(s=f.cc-p.cc),Wt(f.startPTS)&&Wt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){Y.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=ly(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(s){Y.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),cy(n.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?I0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):x0(n,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function ly(n,t,e){const i=ai({},n);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const o=new Xu(t[s].attr,i[s]);o.isValid?i[s]=o:Y.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function cy(n,t,e){if(n&&t){let i=0;for(let s=0,o=n.length;s<=o;s++){const c=n[s],d=t[s+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function hy(n,t,e){const i=t.skippedSegments,s=Math.max(n.startSN,t.startSN)-t.startSN,o=(n.fragmentHint?1:0)+(i?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let p=s;p<=o;p++){const g=f[c+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function x0(n,t){const e=t.startSN+t.skippedSegments-n.startSN,i=n.fragments;e<0||e>=i.length||kc(t,i[e].start)}function kc(n,t){if(t){const e=n.fragments;for(let i=n.skippedSegments;i<e.length;i++)e[i].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function dy(n,t=1/0){let e=1e3*n.targetduration;if(n.updated){const i=n.fragments,s=4;if(i.length&&e*s>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function uy(n,t,e){if(!(n!=null&&n.details))return null;const i=n.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t)?s:t<i.startSN&&e&&e.sn===t?e:null}function D0(n,t,e){var i;return n!=null&&n.details?P0((i=n.details)==null?void 0:i.partList,t,e):null}function P0(n,t,e){if(n)for(let i=n.length;i--;){const s=n[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function Co(n){switch(n.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function O0(n,t){const e=Co(t);return n.default[`${e?"timeout":"error"}Retry`]}function wc(n,t){const e=n.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function M0(n){return Wi(Wi({},n),{errorRetry:null,timeoutRetry:null})}function Io(n,t,e,i){return!!n&&t<n.maxNumRetry&&(fy(i)||!!e)}function fy(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const $0={search:function(n,t){let e=0,i=n.length-1,s=null,o=null;for(;e<=i;){s=(e+i)/2|0,o=n[s];const c=t(o);if(c>0)e=s+1;else if(c<0)i=s-1;else return o}return null}};function py(n,t,e){if(t===null||!Array.isArray(n)||!n.length||!Wt(t))return null;const i=n[0].programDateTime;if(t<(i||0))return null;const s=n[n.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let o=0;o<n.length;++o){const c=n[o];if(gy(t,e,c))return c}return null}function _a(n,t,e=0,i=0){let s=null;if(n?s=t[n.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&Sc(e,i,s)===0)return s;const o=$0.search(t,Sc.bind(null,e,i));return o&&(o!==n||!s)?o:s}function Sc(n=0,t=0,e){if(e.start<=n&&e.start+e.duration>n)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=n?1:e.start-i>n&&e.start?-1:0}function gy(n,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>n}function my(n,t){return $0.search(n,e=>e.cc<t?1:e.cc>t?-1:0)}const vy=3e5;var Ri={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},cr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class yy{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=Y.log.bind(Y,"[info]:"),this.warn=Y.warn.bind(Y,"[warning]:"),this.error=Y.error.bind(Y,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Jt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,s;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ri.DoNothing,flags:cr.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ri.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Te.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Te.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ri.SendAlternateToPenaltyBox,e.errorAction.flags=cr.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ri.DoNothing,flags:cr.None};return}if(e.type===qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,o=O0(s.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Io(o,c,Co(t),d))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:o,retryCount:c};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=c),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=O0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,b)=>v+b.fragmentError,0);if(s){var p;t.details!==ut.FRAG_GAP&&s.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Io(d,f,Co(t),v))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,i);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const s=this.hls.levels[e];if(s&&(s.loadError++,i.autoLevelEnabled)){var o,c;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,b=(o=t.frag)==null?void 0:o.type,{type:E,groupId:T}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const D=f[C];if(t.details===ut.FRAG_GAP&&t.frag){const O=f[C].details;if(O){const F=_a(t.frag,O.fragments,t.frag.start);if(F!=null&&F.gap)continue}}else if(E===Te.AUDIO_TRACK&&T===D.audioGroupId||E===Te.SUBTITLE_TRACK&&T===D.textGroupId||b===Jt.AUDIO&&s.audioGroupId===D.audioGroupId||b===Jt.SUBTITLE&&s.textGroupId===D.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ri.SendAlternateToPenaltyBox,flags:cr.None,nextAutoLevel:d}}return{action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ri.DoNothing:break;case Ri.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:o,nextAutoLevel:c}=i;switch(s){case cr.None:this.switchLevel(t,c);break;case cr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case cr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Ec[Ec.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,c)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,s=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[s],c=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<c;f++){const p=(d+f)%c,g=i[p];if(!g||by(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${c}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,s=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(e),s.details=t.details,i[t.urlId]=s}}function by(n,t,e){if(performance.now()-n.lastErrorPerfMs>vy)return!0;const i=n.details;if(t.details===ut.FRAG_GAP&&i&&t.frag){const s=t.frag.start,o=_a(null,i.fragments,s);if(o&&!o.gap)return!0}if(e&&n.errors.length<e.errors.length){const s=n.errors[n.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Rc{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Y.log.bind(Y,`${e}:`),this.warn=Y.warn.bind(Y,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let s=-1;for(let o=0;o<i.length;o++){const c=i[o];let d;try{d=new self.URL(c.URI,e.url).href}catch(f){Y.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){s=o;break}else d===t.substring(0,d.length)&&(s=o)}if(s!==-1){const o=i[s],c=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new C0(c,d>=0?d:void 0,Sa.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:s,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(s.advancedDateTime=Date.now()-d,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${t} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&oy(i,s),!this.canLoad||!s.live)return;let f,p,g;if(s.canBlockReload&&s.endSN&&s.advanced){const C=this.hls.config.lowLatencyMode,D=s.lastPartSn,O=s.endSN,F=s.lastPartIndex,x=F!==-1,N=D===O,H=C?0:F;x?(p=N?O+1:D,g=N?H:F+1):p=O+1;const j=s.age,nt=j+s.ageHeader;let st=Math.min(nt-s.partTarget,s.targetduration*1.5);if(st>0){if(i&&st>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${st} with playlist age: ${s.age}`),st=0;else{const Q=Math.floor(st/s.targetduration);if(p+=Q,g!==void 0){const kt=Math.round(st%s.targetduration/s.partTarget);g+=kt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${j.toFixed(2)}s goal: ${st} skip sn ${Q} to part ${g}`)}s.tuneInGoal=st}if(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g),C||!N){this.loadPlaylist(f);return}}else(s.canBlockReload||s.canSkipUntil)&&(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,b=v?v.end-v.len:0,E=(s.edge-b)*1e3,T=dy(s,E);s.updated&&c>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&s.canBlockReload?this.requestScheduled=o.loading.first+T-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-c;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let o=ay(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,o=Sa.No),new C0(i,s,o)}checkRetry(t){const e=t.details,i=Co(t),s=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=s||{},f=!!s&&!!d&&(o===Ri.RetryRequest||!s.resolved&&o===Ri.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,c>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=wc(d,c);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,s.resolved=!0}return f}}let _c;class Ay extends Rc{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],s={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(_c||(_c=/chrome|firefox/i.test(navigator.userAgent)),_c&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":b,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${b||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=s[w],o?o.addFallback(c):(o=new Ra(c),s[w]=o,i.push(o)),xo(o,"audio",p),xo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:D})=>(o||(o=!!(w&&C)),c||(c=!!T),d||(d=!!E),!(D!=null&&D.length)&&(!E||mc(E,"audio"))&&(!T||mc(T,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:T,height:w})=>!!E||!!(T&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const E=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||mc(E.audioCodec,"audio")),N0(i)),e.subtitles&&(s=e.subtitles,N0(s));const p=f.slice(0);f.sort((E,T)=>E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==T.bitrate?E.bitrate-T.bitrate:E.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==T.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==T.height?E.height-T.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let E=0;E<p.length;E++)if(p[E].pathwayId===f[0].pathwayId){g=p[E];break}}this._levels=f;for(let E=0;E<f.length;E++)if(f[E]===g){this._firstLevel=E,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!c,b={levels:f,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:c,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&s&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ai({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=c.details;if(!p||p.live){const g=this.switchParams(c.uri,s==null?void 0:s.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===Te.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:o}=e,c=this._levels[s];if(!c){var d;this.warn(`Invalid level index ${s}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(s,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===s){o=c;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const c=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${c?" Pathway "+c:""} URI ${s+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:s,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(o,c)=>c!==e,s=this._levels.filter((o,c)=>c!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(i),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(i)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(i)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=s})}),this._levels=e}}function xo(n,t,e){e&&(t==="audio"?(n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds[n.url.length-1]=e):t==="text"&&(n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds[n.url.length-1]=e))}function N0(n){const t={};n.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var ui={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ey{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let s=i.length;s--;){const o=i[s];if(!o)break;const c=o.end;if(o.start<=t&&c!==null&&t<=c)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let o=s.length;o--;){const c=i[s[o]];if((c==null?void 0:c.body.type)===e&&c.buffered){const d=c.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const o=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===i&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const o=_n(i),c=this.fragments[o];if(!c||c.buffered&&i.gap)return;const d=!i.relurl;Object.keys(e).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;c.range[f]=this.getBufferedTimes(i,s,v,g)}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,(c.body.endList=i.endList||c.body.endList)&&(this.endListFragments[c.body.type]=c),Do(c)||this.removeParts(i.sn-1,i.type)):this.removeFragment(c.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(s=>s.fragment.sn>=t))}fragBuffered(t,e){const i=_n(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<s.length;g++){const v=s.start(g)-this.bufferPadding,b=s.end(g)+this.bufferPadding;if(p>=v&&f<=b){o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});break}else if(c<b&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,s,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Do(g)&&(s=g.body.start-d,o=g.body.end+d,t>=s&&t<=o&&(i=Math.min(t-s,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Do(e))}getState(t){const e=_n(t),i=this.fragments[e];return i?i.buffered?Do(i)?ui.PARTIAL:ui.OK:ui.APPENDING:ui.NOT_LOADED}isTimeBuffered(t,e,i){let s,o;for(let c=0;c<i.length;c++){if(s=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=s&&e<=o)return!0;if(e<=s)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:s}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=s?null:e,c=_n(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(s){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(s)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=_n(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,o){s&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||s&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=_n(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const s=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==s)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Do(n){var t,e,i;return n.buffered&&(n.body.gap||((t=n.range.video)==null?void 0:t.partial)||((e=n.range.audio)==null?void 0:e.partial)||((i=n.range.audiovideo)==null?void 0:i.partial))}function _n(n){return`${n.type}_${n.level}_${n.urlId}_${n.sn}`}const F0=Math.pow(2,17);class Ty{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(B0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(s):new c(s),g=U0(t),v=M0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:F0};t.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p);let D=E.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:t,part:null,payload:D,networkDetails:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Wi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(B0(t,e));return}const p=this.loader=t.loader=o?new o(s):new c(s),g=U0(t,e),v=M0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:F0};e.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:E.data,networkDetails:C};i(D),d(D)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Wi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,o=s.total;if(i.loaded+=s.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(i.loaded/o),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const c=i.loading,d=s.loading;c.start?c.first+=d.first-d.start:(c.start=d.start,c.first=d.first),c.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function U0(n,t=null){const e=t||n,i={frag:n,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(s)&&Wt(o)){var c;let d=s,f=o;if(n.sn==="initSegment"&&((c=n.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-s;p%16&&(f=o+(16-p%16)),s!==0&&(i.resetIV=!0,d=s-16)}i.rangeStart=d,i.rangeEnd=f}return i}function B0(n,t){const e=new Error(`GAP ${n.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return t&&(i.part=t),(t||n).stats.aborted=!0,new Jr(i)}class Jr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class ky{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,i,s,o){return new Jr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let o=0;o<e.length;o++){const c=e[o];if(s<=c.cc&&(i==="initSegment"||c.sn==="initSegment"||i<c.sn)){this.emeController.selectKeySystemFormat(c).then(d=>{c.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));let d=this.keyUriToKeyInfo[c];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[c]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(t.keyLoadPromise=s.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,o=new s(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((c,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=i.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{const{frag:C,keyInfo:D,url:O}=T;if(!C.decryptdata||D!==this.keyUriToKeyInfo[O])return d(this.createKeyLoadError(C,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=C.decryptdata.key=new Uint8Array(b.data),C.keyLoader=null,D.loader=null,c({frag:C,keyInfo:D})},onError:(b,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${b.code} loading key ${b.text}`),T,Wi({url:f.url,data:void 0},b)))},onTimeout:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()}}class wy{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Sy={length:0,start:()=>0,end:()=>0};class $e{static isBuffered(t,e){try{if(t){const i=$e.getBuffered(t);for(let s=0;s<i.length;s++)if(e>=i.start(s)&&e<=i.end(s))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const s=$e.getBuffered(t),o=[];let c;for(c=0;c<s.length;c++)o.push({start:s.start(c),end:s.end(c)});return this.bufferedInfo(o,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let s=[];if(i)for(let p=0;p<t.length;p++){const g=s.length;if(g){const v=s[g-1].end;t[p].start-v<i?t[p].end>v&&(s[g-1].end=t[p].end):s.push(t[p])}else s.push(t[p])}else s=t;let o=0,c,d=e,f=e;for(let p=0;p<s.length;p++){const g=s[p].start,v=s[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){c=g;break}}return{len:o,start:d||0,end:f||0,nextStart:c}}static getBuffered(t){try{return t.buffered}catch(e){return Y.log("failed to get media.buffered",e),Sy}}}class Lc{constructor(t,e,i,s=0,o=-1,c=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Po(),this.buffering={audio:Po(),video:Po(),audiovideo:Po()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=o,this.partial=c}}function Po(){return{start:0,executeStart:0,executeEnd:0,end:0}}function G0(n,t){let e=null;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o&&o.cc===t){e=o;break}}return e}function Ry(n,t,e){return!!(t.details&&(e.endCC>e.startCC||n&&n.cc<e.startCC))}function _y(n,t,e=0){const i=n.fragments,s=t.fragments;if(!s.length||!i.length){Y.log("No fragments to align");return}const o=G0(i,s[0].cc);if(!o||o&&!o.startPTS){Y.log("No frag in previous level to align on");return}return o}function H0(n,t){if(n){const e=n.start+t;n.start=n.startPTS=e,n.endPTS=e+n.duration}}function Cc(n,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)H0(e[i],n);t.fragmentHint&&H0(t.fragmentHint,n),t.alignedSliding=!0}function Ly(n,t,e){t&&(Cy(n,e,t),!e.alignedSliding&&t.details&&Iy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&x0(t.details,e))}function Cy(n,t,e){if(Ry(n,e,t)){const i=_y(e.details,t);i&&Wt(i.start)&&(Y.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Cc(i.start,t))}}function Iy(n,t){if(!t.fragments.length||!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=n.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&Wt(s)&&(Y.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${n.url} `),Cc(s,n))}function V0(n,t){if(!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=n.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,o=i[s],c=G0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=c.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(c.start-o.start);Cc(p,n)}class xy{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class Dy{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Py(n){const t=n.byteLength,e=t&&new DataView(n.buffer).getUint8(t-1);return e?on(n,0,t-e):n}class Oy{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=e.getUint32(s*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],o=i[1],c=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],b=f[3],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){let D=w^w<<1^w<<2^w<<3^w<<4;D=D>>>8^D&255^99,t[T]=D,e[D]=T;const O=E[T],F=E[O],x=E[F];let N=E[D]*257^D*16843008;s[T]=N<<24|N>>>8,o[T]=N<<16|N>>>16,c[T]=N<<8|N>>>24,d[T]=N,N=x*16843009^F*65537^O*257^T*16843008,p[D]=N<<24|N>>>8,g[D]=N<<16|N>>>16,v[D]=N<<8|N>>>24,b[D]=N,T?(T=O^E[E[E[x^O]]],w^=E[E[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s<e.length&&i;)i=e[s]===this.key[s],s++;if(i)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const c=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(c),g=this.invKeySchedule=new Uint32Array(c),v=this.sBox,b=this.rcon,E=this.invSubMix,T=E[0],w=E[1],C=E[2],D=E[3];let O,F;for(d=0;d<c;d++){if(d<o){O=p[d]=e[d];continue}F=O,d%o===0?(F=F<<8|F>>>24,F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255],F^=b[d/o|0]<<24):o>6&&d%o===4&&(F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255]),p[d]=O=(p[d-o]^F)>>>0}for(f=0;f<c;f++)d=c-f,f&3?F=p[d]:F=p[d-4],f<4||d<=4?g[f]=F:g[f]=T[v[F>>>24]]^w[v[F>>>16&255]]^C[v[F>>>8&255]]^D[v[F&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,o=this.invKeySchedule,c=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],b=this.uint8ArrayToUint32Array_(i);let E=b[0],T=b[1],w=b[2],C=b[3];const D=new Int32Array(t),O=new Int32Array(D.length);let F,x,N,H,j,nt,st,Q,kt,gt,Mt,Vt,V,J;const St=this.networkToHostOrderSwap;for(;e<D.length;){for(kt=St(D[e]),gt=St(D[e+1]),Mt=St(D[e+2]),Vt=St(D[e+3]),j=kt^o[0],nt=Vt^o[1],st=Mt^o[2],Q=gt^o[3],V=4,J=1;J<s;J++)F=f[j>>>24]^p[nt>>16&255]^g[st>>8&255]^v[Q&255]^o[V],x=f[nt>>>24]^p[st>>16&255]^g[Q>>8&255]^v[j&255]^o[V+1],N=f[st>>>24]^p[Q>>16&255]^g[j>>8&255]^v[nt&255]^o[V+2],H=f[Q>>>24]^p[j>>16&255]^g[nt>>8&255]^v[st&255]^o[V+3],j=F,nt=x,st=N,Q=H,V=V+4;F=c[j>>>24]<<24^c[nt>>16&255]<<16^c[st>>8&255]<<8^c[Q&255]^o[V],x=c[nt>>>24]<<24^c[st>>16&255]<<16^c[Q>>8&255]<<8^c[j&255]^o[V+1],N=c[st>>>24]<<24^c[Q>>16&255]<<16^c[j>>8&255]<<8^c[nt&255]^o[V+2],H=c[Q>>>24]<<24^c[j>>16&255]<<16^c[nt>>8&255]<<8^c[st&255]^o[V+3],O[e]=St(F^E),O[e+1]=St(H^T),O[e+2]=St(N^w),O[e+3]=St(x^C),E=kt,T=gt,w=Mt,C=Vt,e=e+4}return O.buffer}}const My=16;class Ic{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Py(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((s,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?s(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=ln(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;s&&(i=s);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new Oy),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=on(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new Dy(s,e)),this.fastAesKey.expandKey().then(o=>s?(this.logOnce("WebCrypto AES decrypt"),new xy(s,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(Y.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%My;return i!==t.length&&(e=on(t,0,i),this.remainderData=on(t,i)),e}logOnce(t){this.logEnabled&&(Y.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const $y={toString:function(n){let t="";const e=n.length;for(let i=0;i<e;i++)t+=`[${n.start(i).toFixed(3)}-${n.end(i).toFixed(3)}]`;return t}},Tt={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class xc extends wy{constructor(t,e,i,s,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Tt.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=o,this.logPrefix=s,this.log=Y.log.bind(Y,`${s}:`),this.warn=Y.warn.bind(Y,`${s}:`),this.hls=t,this.fragmentLoader=new Ty(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Ic(t.config),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Tt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const o=i[i.length-1];return $e.isBuffered(this.media,o.start+o.duration/2)}const s=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Tt.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:s,state:o}=this,c=i?i.currentTime:0,d=$e.bufferInfo(s||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Wt(c)?c.toFixed(3):c}, state: ${o}`),this.state===Tt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=c>g;(c<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=c),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Tt.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const s=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,i,s).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===Tt.FRAG_LOADING||!this.fragCurrent&&c===Tt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Tt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===ui.APPENDING){const s=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,s),c=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===ui.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:o}=i,c=t.decryptdata;if(o&&o.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),c.key.buffer,c.iv.buffer).catch(f=>{throw s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return s.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:s,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Tt.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),i.frag===s&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,s,o,c;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${d?$y.toString($e.getBuffered(d)):"(detached)"})`),this.state=Tt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Lc(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var o;const c=e==null?void 0:e.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Tt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===Tt.KEY_LOADING&&(this.state=Tt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(t,c.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=c.partList;if(g&&s){i>t.end&&c.fragmentHint&&(t=c.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const b=g[v];this.log(`Loading part sn: ${t.sn} p: ${b.index} cc: ${t.cc} of playlist [${c.startSN}-${c.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=Tt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,b,e,s)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,b,e,s).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!t.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${c?"of ["+c.startSN+"-"+c.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Tt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,s)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?s:void 0),d]).then(([g])=>(!f&&g&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,i,s){return new Promise((o,c)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,s).then(b=>{f[v.index]=b;const E=b.part;this.hls.trigger(R.FRAG_LOADED,b);const T=D0(i,t.sn,v.index+1)||P0(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:E,partsLoaded:f})}).catch(c)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Tt.PARSING){!this.fragCurrent&&this.state!==Tt.STOPPED&&this.state!==Tt.ERROR&&(this.state=Tt.IDLE);return}const{frag:i,part:s,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,s&&(s.stats.parsing.end=c),this.updateLevelTiming(i,s,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:o,part:c}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${s}. The current chunk will not be buffered.`),null;const d=e[s],f=c>-1?D0(d,o,c):null,p=f?f.fragment:uy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,s,o){var c;if(!t||this.state!==Tt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=ln(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!$e.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=$e.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,s.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,o=$e.bufferInfo(t,e,s);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return $e.bufferInfo(t,e,Math.max(o.nextStart,s))}return o}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Jt.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Jt.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,i),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=c&&(d=i[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===ui.OK||i===ui.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,o){const c=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,c&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let s=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,s>-1&&i<p.start)break;const g=p.loaded;g?s=-1:(o||p.independent||c)&&p.fragment===e&&(s=d),o=g}return s}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let s=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=py(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(s=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=my(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(s=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=s.maxFragLookUpTolerance,g=i.partList,v=!!(s.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let b;if(t<e){const E=t>e-p?0:p;b=_a(o,c,t,E)}else b=c[c.length-1];if(b){const E=b.sn-i.startSN,T=this.fragmentTracker.getState(b);if((T===ui.OK||T===ui.PARTIAL&&b.gap)&&(o=b),o&&b.sn===o.sn&&(!v||g[0].fragment.sn>b.sn)&&o&&b.level===o.level){const w=c[E+1];b.sn<d&&this.fragmentTracker.getState(w)!==ui.OK?b=w:b=null}}return b}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(s!==null&&i.duration>s&&(o<s||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:o}=this,c=s!==null?i[s]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&Wt(f);if(p||!g&&!f){Ly(o,c,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,o=s?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(o)?(i=e+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${o} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Tt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Tt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ri.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=wc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),c.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Tt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):Y.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ri.SendAlternateToPenaltyBox?this.state=Tt.WAITING_LEVEL:this.state=Tt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Tt.PARSING||this.state===Tt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const o=!s;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=$e.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===Tt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Tt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){var o;const c=i.details;if(!c){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=s?0:I0(c,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:c,level:i,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Tt.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(s=this.fragCurrent)==null?void 0:s.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function W0(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ny(){const n=_o();if(!n)return!1;const t=W0(),e=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function Fy(){var n;const t=W0();return typeof(t==null||(n=t.prototype)==null?void 0:n.changeType)=="function"}function Uy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function By(){const n=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(n);return{worker:new self.Worker(t),objectURL:t}}function Gy(n){const t=new self.URL(n,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Mr(n="",t=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class j0{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=ln(this.cachedData,t),this.cachedData=null);let i=ko(t,0),s=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?kv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=Hy(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY});s<p;){if(this.canParse(t,s)){const g=this.appendFrame(c,t,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,o=s):s=p}else Tv(t,s)?(i=ko(t,s),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,o=s):s++;if(s===p&&o!==p){const g=on(t,o);this.cachedData?this.cachedData=ln(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:Mr(),id3Track:d,textTrack:Mr()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Mr(),id3Track:this._id3Track,textTrack:Mr()}}destroy(){}}const Hy=(n,t,e)=>{if(Wt(n))return n*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Vy(n,t,e,i){let s,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return c=(t[e+2]&1)<<2,c|=(t[e+3]&192)>>>6,Y.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(s=5,d=new Array(4),o=v-3):(s=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(s=2,d=new Array(2),o=v):(s=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?o=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(f))||!i&&c===1)&&(s=2,d=new Array(2)),o=v)),d[0]=s<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,s===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:c,codec:"mp4a.40."+s,manifestCodec:p}}function K0(n,t){return n[t]===255&&(n[t+1]&246)===240}function z0(n,t){return n[t+1]&1?7:9}function Dc(n,t){return(n[t+3]&3)<<11|n[t+4]<<3|(n[t+5]&224)>>>5}function Wy(n,t){return t+5<n.length}function Oo(n,t){return t+1<n.length&&K0(n,t)}function jy(n,t){return Wy(n,t)&&K0(n,t)&&Dc(n,t)<=n.length-t}function Ky(n,t){if(Oo(n,t)){const e=z0(n,t);if(t+e>=n.length)return!1;const i=Dc(n,t);if(i<=e)return!1;const s=t+i;return s===n.length||Oo(n,s)}return!1}function Y0(n,t,e,i,s){if(!n.samplerate){const o=Vy(t,e,i,s);if(!o)return;n.config=o.config,n.samplerate=o.samplerate,n.channelCount=o.channelCount,n.codec=o.codec,n.manifestCodec=o.manifestCodec,Y.log(`parsed codec:${n.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function X0(n){return 9216e4/n}function zy(n,t){const e=z0(n,t);if(t+e<=n.length){const i=Dc(n,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Z0(n,t,e,i,s){const o=X0(n.samplerate),c=i+s*o,d=zy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,b=v+g,E=Math.max(0,e+b-t.length);E?(f=new Uint8Array(b-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+b);const T={unit:f,pts:c};return E||n.samples.push(T),{sample:T,length:b,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:c},length:p,missing:-1}}class Yy extends j0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ko(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Ky(t,e))return Y.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return jy(t,e)}appendFrame(t,e,i){Y0(t,this.observer,e,i,t.manifestCodec);const s=Z0(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Xy=/\/emsg[-/]ID3/i;class Zy{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const o=this.videoTrack=Mr("video",1),c=this.audioTrack=Mr("audio",1),d=this.txtTrack=Mr("text",1);if(this.id3Track=Mr("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=l0(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;c.id=p,c.timescale=g,c.codec=v}d.id=n0.text,o.sampleDuration=0,o.duration=c.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,ye(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ln(this.remainderData,t));const d=Fv(i);this.remainderData=d.remainder,s.samples=d.valid||new Uint8Array}else s.samples=i;const c=this.extractID3Track(s,e);return o.samples=h0(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=h0(t,e),{videoTrack:e,audioTrack:Mr(),id3Track:s,textTrack:Mr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=ye(t.samples,["emsg"]);s&&s.forEach(o=>{const c=Gv(o);if(Xy.test(c.schemeIdUri)){const d=Wt(c.presentationTime)?c.presentationTime/c.timeScale:e+c.presentationTimeDelta/c.timeScale;let f=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=c.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Ar.emsg,duration:f})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Mo=null;const qy=[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],Qy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Jy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],tb=[0,1,1,4];function q0(n,t,e,i,s){if(e+24>t.length)return;const o=Q0(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+s*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return n.config=[],n.channelCount=o.channelCount,n.samplerate=o.sampleRate,n.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function Q0(n,t){const e=n[t+1]>>3&3,i=n[t+1]>>1&3,s=n[t+2]>>4&15,o=n[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&o!==3){const c=n[t+2]>>1&1,d=n[t+3]>>6,f=e===3?3-i:i===3?3:4,p=qy[f*14+s-1]*1e3,g=Qy[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,b=Jy[e][i],E=tb[i],T=b*8*E,w=Math.floor(b*p/g+c)*E;if(Mo===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Mo=C?parseInt(C[1]):0}return Mo&&Mo<=87&&i===2&&p>=224e3&&d===0&&(n[t+3]=n[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Pc(n,t){return n[t]===255&&(n[t+1]&224)===224&&(n[t+1]&6)!==0}function J0(n,t){return t+1<n.length&&Pc(n,t)}function eb(n,t){return Pc(n,t)&&4<=n.length-t}function ib(n,t){if(t+1<n.length&&Pc(n,t)){const e=Q0(n,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===n.length||J0(n,s)}return!1}class tf{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");s.set(t.subarray(i,i+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&Y.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,s;for(let o=0;o<t;o++)i!==0&&(s=this.readEG(),i=(e+s+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,s=0,o,c,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),b=this.skipBits.bind(this),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),b(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const H=g();if(H===3&&b(1),T(),T(),b(1),v())for(c=H!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(b(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),b(1);const O=g(),F=g(),x=p(1);x===0&&b(1),b(1),v()&&(t=g(),e=g(),i=g(),s=g());let N=[1,1];if(v()&&v())switch(f()){case 1:N=[1,1];break;case 2:N=[12,11];break;case 3:N=[10,11];break;case 4:N=[16,11];break;case 5:N=[40,33];break;case 6:N=[24,11];break;case 7:N=[20,11];break;case 8:N=[32,11];break;case 9:N=[80,33];break;case 10:N=[18,11];break;case 11:N=[15,11];break;case 12:N=[64,33];break;case 13:N=[160,99];break;case 14:N=[4,3];break;case 15:N=[3,2];break;case 16:N=[2,1];break;case 255:{N=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((O+1)*16-t*2-e*2),height:(2-x)*(F+1)*16-(x?2:4)*(i+s),pixelRatio:N}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class rb{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ic(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const o=s.subarray(16,s.length-s.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);s.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)i.set(t.subarray(o,o+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)t.set(i.subarray(s,s+16),o);return t}decryptAvcSample(t,e,i,s,o){const c=u0(o.data),d=this.getAvcEncryptedData(c);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(c,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)})}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){s();return}const o=t[e].units;for(;!(i>=o.length);i++){const c=o[i];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,e,i,s,c),!this.decrypter.isSync()))return}}}}const _i=188;class Es{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=Es.syncOffset(t);return e>0&&Y.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(_i*5,t.length-_i)+1,s=0;for(;s<i;){let o=!1,c=-1,d=0;for(let f=s;f<e;f+=_i)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+_i*99,t.length-_i)+1)),o||(o=Oc(t,f)===0),o&&d>1&&(c===0&&d>2||f+_i>i))return c}else{if(d)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:n0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Es.createTrack("video"),this._audioTrack=Es.createTrack("audio",s),this._id3Track=Es.createTrack("id3"),this._txtTrack=Es.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,s=!1){i||(this.sampleAes=null);let o;const c=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=c.pid,v=c.pesData,b=d.pid,E=f.pid,T=d.pesData,w=f.pesData,C=null,D=this.pmtParsed,O=this._pmtId,F=t.length;if(this.remainderData&&(t=ln(this.remainderData,t),F=t.length,this.remainderData=null),F<_i&&!s)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const x=Math.max(0,Es.syncOffset(t));F-=(F-x)%_i,F<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,F,t.buffer.byteLength-F));let N=0;for(let j=x;j<F;j+=_i)if(t[j]===71){const nt=!!(t[j+1]&64),st=Oc(t,j),Q=(t[j+3]&48)>>4;let kt;if(Q>1){if(kt=j+5+t[j+4],kt===j+_i)continue}else kt=j+4;switch(st){case g:nt&&(v&&(o=Ln(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,j+_i)),v.size+=j+_i-kt);break;case b:if(nt){if(T&&(o=Ln(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(kt,j+_i)),T.size+=j+_i-kt);break;case E:nt&&(w&&(o=Ln(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,j+_i)),w.size+=j+_i-kt);break;case 0:nt&&(kt+=t[kt]+1),O=this._pmtId=sb(t,kt);break;case O:{nt&&(kt+=t[kt]+1);const gt=nb(t,kt,this.typeSupported,i);g=gt.avc,g>0&&(c.pid=g),b=gt.audio,b>0&&(d.pid=b,d.segmentCodec=gt.segmentCodec),E=gt.id3,E>0&&(f.pid=E),C!==null&&!D&&(Y.warn(`MPEG-TS PMT found at ${j} after unknown PID '${C}'. Backtracking to sync byte @${x} to parse all TS packets.`),C=null,j=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=st;break}}else N++;if(N>0){const j=new Error(`Found ${N} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:j,reason:j.message})}c.pesData=v,d.pesData=T,f.pesData=w;const H={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return s&&this.extractRemainingSamples(H),H}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:o}=t,c=i.pesData,d=e.pesData,f=s.pesData;let p;if(c&&(p=Ln(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=Ln(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&Y.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Ln(f))?(this.parseID3PES(s,p),s.pesData=null):s.pesData=f}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new rb(this.observer,this.config,e);return this.decrypt(s,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:o}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{i(t)}):i(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(La(c,t),c=this.avcSample=$o(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let b=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new tf(E).readSliceType();(T===2||T===4||T===7||T===9)&&(b=!0)}if(b){var v;(v=c)!=null&&v.frame&&!c.key&&(La(c,t),c=this.avcSample=null)}c||(c=this.avcSample=$o(!0,i.pts,i.dts,"")),c.frame=!0,c.key=b;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(La(c,t),c=this.avcSample=null),c||(c=this.avcSample=$o(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,d0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const b=p.data,E=new tf(b).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[b],t.duration=this._duration;const T=b.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let D=T[C].toString(16);D.length<2&&(D="0"+D),w+=D}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,c&&La(c,t),c=this.avcSample=$o(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,c&&(c.debug+="unknown NAL "+p.type+" ");break}c&&d&&c.units.push(p)}),s&&c&&(La(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;s=o[o.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const o=s,c=[];let d=0,f,p,g,v=-1,b=0;for(s===-1&&(v=0,b=e[0]&31,s=0,d=1);d<i;){if(f=e[d++],!s){s=f?0:1;continue}if(s===1){s=f?0:2;continue}if(!f)s=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-s-1),type:b};c.push(E)}else{const E=this.getLastNalUnit(t.samples);if(E&&(o&&d<=4-o&&E.state&&(E.data=E.data.subarray(0,E.data.byteLength-o)),p=d-s-1,p>0)){const T=new Uint8Array(E.data.byteLength+p);T.set(E.data,0),T.set(e.subarray(0,p),E.data.byteLength),E.data=T,E.state=0}}d<i?(g=e[d]&31,v=d,b=g,s=0):s=-1}else s=0}if(v>=0&&s>=0){const E={data:e.subarray(v,i),type:b,state:s};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const T=new Uint8Array(E.data.byteLength+e.byteLength);T.set(E.data,0),T.set(e,E.data.byteLength),E.data=T}}return t.naluState=s,c}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let o=e.data;if(s){this.aacOverFlow=null;const v=s.missing,b=s.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(b+o.byteLength);E.set(s.sample.unit,0),E.set(o,b),o=E}else{const E=b-v;s.sample.unit.set(o.subarray(0,v),E),t.samples.push(s.sample),i=s.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Oo(o,c);c++);if(c!==i){let v;const b=c<d-1;b?v=`AAC PES did not start with ADTS header,offset:${c}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(Y.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:b,error:E,reason:v}),!b)return}Y0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(s){const v=X0(t.samplerate);f=s.sample.pts+v}else{Y.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=Z0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Oo(o,c);c++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){Y.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<s;)if(J0(i,c)){const f=q0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){Y.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ai({},e,{type:this._avcTrack?Ar.emsg:Ar.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function $o(n,t,e,i){return{key:n,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Oc(n,t){return((n[t+1]&31)<<8)+n[t+2]}function sb(n,t){return(n[t+10]&31)<<8|n[t+11]}function nb(n,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(n[t+1]&15)<<8|n[t+2],c=t+3+o-4,d=(n[t+10]&15)<<8|n[t+11];for(t+=12+d;t<c;){const f=Oc(n,t);switch(n[t]){case 207:if(!i){Y.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=f);break;case 21:s.id3===-1&&(s.id3=f);break;case 219:if(!i){Y.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?Y.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=f,s.segmentCodec="mp3");break;case 36:Y.warn("Unsupported HEVC stream type found");break}t+=((n[t+3]&15)<<8|n[t+4])+5}return s}function Ln(n){let t=0,e,i,s,o,c;const d=n.data;if(!n||n.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>n.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(c=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-c>54e5&&(Y.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),s=e[8];let p=s+9;if(n.size<=p)return null;n.size-=p;const g=new Uint8Array(n.size);for(let v=0,b=d.length;v<b;v++){e=d[v];let E=e.byteLength;if(p)if(p>E){p-=E;continue}else e=e.subarray(p),E-=p,p=0;g.set(e,t),t+=E}return i&&(i-=s+3),{data:g,pts:o,dts:c,len:i}}return null}function La(n,t){if(n.units.length&&n.frame){if(n.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];n.pts=s.pts,n.dts=s.dts}else{t.dropped++;return}}t.samples.push(n)}n.debug.length&&Y.log(n.pts+"/"+n.dts+":"+n.debug)}class ab extends j0{resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ko(t,0)||[]).length;for(let i=t.length;e<i;e++)if(ib(t,e))return Y.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return eb(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return q0(t,e,i,this.basePTS,this.frameIndex)}}class ef{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Ts=Math.pow(2,32)-1;class rt{static init(){rt.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in rt.types)rt.types.hasOwnProperty(t)&&(rt.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);rt.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);rt.STTS=rt.STSC=rt.STCO=o,rt.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),rt.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),rt.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),rt.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);rt.FTYP=rt.box(rt.types.ftyp,c,f,c,d),rt.DINF=rt.box(rt.types.dinf,rt.box(rt.types.dref,s))}static box(t,...e){let i=8,s=e.length;const o=s;for(;s--;)i+=e[s].byteLength;const c=new Uint8Array(i);for(c[0]=i>>24&255,c[1]=i>>16&255,c[2]=i>>8&255,c[3]=i&255,c.set(t,4),s=0,i=8;s<o;s++)c.set(e[s],i),i+=e[s].byteLength;return c}static hdlr(t){return rt.box(rt.types.hdlr,rt.HDLR_TYPES[t])}static mdat(t){return rt.box(rt.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1));return rt.box(rt.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(t){return rt.box(rt.types.mdia,rt.mdhd(t.timescale,t.duration),rt.hdlr(t.type),rt.minf(t))}static mfhd(t){return rt.box(rt.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?rt.box(rt.types.minf,rt.box(rt.types.smhd,rt.SMHD),rt.DINF,rt.stbl(t)):rt.box(rt.types.minf,rt.box(rt.types.vmhd,rt.VMHD),rt.DINF,rt.stbl(t))}static moof(t,e,i){return rt.box(rt.types.moof,rt.mfhd(t),rt.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trak(t[e]);return rt.box.apply(null,[rt.types.moov,rt.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(rt.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trex(t[e]);return rt.box.apply(null,[rt.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return rt.box(rt.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,o;for(s=0;s<e.length;s++)o=e[s].flags,i[s+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return rt.box(rt.types.sdtp,i)}static stbl(t){return rt.box(rt.types.stbl,rt.stsd(t),rt.box(rt.types.stts,rt.STTS),rt.box(rt.types.stsc,rt.STSC),rt.box(rt.types.stsz,rt.STSZ),rt.box(rt.types.stco,rt.STCO))}static avc1(t){let e=[],i=[],s,o,c;for(s=0;s<t.sps.length;s++)o=t.sps[s],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(s=0;s<t.pps.length;s++)o=t.pps[s],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=rt.box(rt.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return rt.box(rt.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,rt.box(rt.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),rt.box(rt.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return rt.box(rt.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),rt.box(rt.types.esds,rt.esds(t)))}static mp3(t){const e=t.samplerate;return rt.box(rt.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?rt.box(rt.types.stsd,rt.STSD,rt.mp3(t)):rt.box(rt.types.stsd,rt.STSD,rt.mp4a(t)):rt.box(rt.types.stsd,rt.STSD,rt.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,o=t.height,c=Math.floor(i/(Ts+1)),d=Math.floor(i%(Ts+1));return rt.box(rt.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=rt.sdtp(t),s=t.id,o=Math.floor(e/(Ts+1)),c=Math.floor(e%(Ts+1));return rt.box(rt.types.traf,rt.box(rt.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),rt.box(rt.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,c>>24,c>>16&255,c>>8&255,c&255])),rt.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,rt.box(rt.types.trak,rt.tkhd(t),rt.mdia(t))}static trex(t){const e=t.id;return rt.box(rt.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,o=12+16*s,c=new Uint8Array(o);let d,f,p,g,v,b;for(e+=8+o,c.set([t.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<s;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,b=f.cts,c.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,b>>>24&255,b>>>16&255,b>>>8&255,b&255],12+16*d);return rt.box(rt.types.trun,c)}static initSegment(t){rt.types||rt.init();const e=rt.moov(t),i=new Uint8Array(rt.FTYP.byteLength+e.byteLength);return i.set(rt.FTYP),i.set(e,rt.FTYP.byteLength),i}}rt.types=void 0,rt.HDLR_TYPES=void 0,rt.STTS=void 0,rt.STSC=void 0,rt.STCO=void 0,rt.STSZ=void 0,rt.VMHD=void 0,rt.SMHD=void 0,rt.STSD=void 0,rt.FTYP=void 0,rt.DINF=void 0;const rf=9e4;function Mc(n,t,e=1,i=!1){const s=n*t*e;return i?Math.round(s):s}function ob(n,t,e=1,i=!1){return Mc(n,t,1/e,i)}function Ca(n,t=!1){return Mc(n,1e3,1/rf,t)}function lb(n,t=1){return Mc(n,rf,1/t)}const cb=10*1e3,sf=1024,hb=1152;let No=null,$c=null;class Nc{constructor(t,e,i,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,No===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);No=o?parseInt(o[1]):0}if($c===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);$c=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){Y.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Y.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Y.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,o)=>{const c=o.pts-s;return c<-4294967296?(e=!0,hr(s,o.pts)):c>0?s:o.pts},t[0].pts);return e&&Y.debug("PTS rollover detected"),i}remux(t,e,i,s,o,c,d,f){let p,g,v,b,E,T,w=o,C=o;const D=t.pid>-1,O=e.pid>-1,F=e.samples.length,x=t.samples.length>0,N=d&&F>0||F>1;if((!D||x)&&(!O||N)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const H=this.isVideoContiguous;let j=-1,nt;if(N&&(j=db(e.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,j>0){Y.warn(`[mp4-remuxer]: Dropped ${j} out of ${F} video samples due to a missing keyframe`);const st=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(j),e.dropped+=j,C+=(e.samples[0].pts-st)/e.inputTimeScale,nt=C}else j===-1&&(Y.warn(`[mp4-remuxer]: No keyframe found out of ${F} video samples`),T=!1);if(this.ISGenerated){if(x&&N){const st=this.getVideoStartPts(e.samples),Q=(hr(t.samples[0].pts,st)-st)/e.inputTimeScale;w+=Math.max(0,Q),C+=Math.max(0,-Q)}if(x){if(t.samplerate||(Y.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,O||N||f===Jt.AUDIO?C:void 0),N){const st=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(Y.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,C,H,st)}}else N&&(p=this.remuxVideo(e,C,H,0));p&&(p.firstKeyFrame=j,p.independent=j!==-1,p.firstKeyFramePTS=nt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=nf(i,o,this._initPTS,this._initDTS)),s.samples.length&&(b=af(s,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:b,id3:E}}generateIS(t,e,i,s){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||s,v="audio/mp4",b,E,T;if(g&&(b=E=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):rt.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?b=E=o[0].pts-Math.round(T*i):g=!1)}if(e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:rt.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(c),C=Math.round(T*i);E=Math.min(E,hr(c[0].dts,w)-C),b=Math.min(b,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:b,timescale:T},this._initDTS={baseTime:E,timescale:T}):b=T=void 0,{tracks:f,initPTS:b,timescale:T}}remuxVideo(t,e,i,s){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,b=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,D=!1;if(!i||g===null){const $=e*o,U=c[0].pts-hr(c[0].dts,c[0].pts);g=$-U}const O=p.baseTime*o/p.timescale;for(let $=0;$<f;$++){const U=c[$];U.pts=hr(U.pts-O,g),U.dts=hr(U.dts-O,g),U.dts<c[$>0?$-1:$].dts&&(D=!0)}D&&c.sort(function($,U){const Z=$.dts-U.dts,ft=$.pts-U.pts;return Z||ft}),E=c[0].dts,T=c[c.length-1].dts;const F=T-E,x=F?Math.round(F/(f-1)):b||t.inputTimeScale/30;if(i){const $=E-g,U=$>x,Z=$<-1;if((U||Z)&&(U?Y.warn(`AVC: ${Ca($,!0)} ms (${$}dts) hole between fragments detected, filling it`):Y.warn(`AVC: ${Ca(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!Z||g>=c[0].pts)){E=g;const ft=c[0].pts-$;c[0].dts=E,c[0].pts=ft,Y.log(`Video: First PTS/DTS adjusted: ${Ca(ft,!0)}/${Ca(E,!0)}, delta: ${Ca($,!0)} ms`)}}E=Math.max(0,E);let N=0,H=0;for(let $=0;$<f;$++){const U=c[$],Z=U.units,ft=Z.length;let bt=0;for(let xt=0;xt<ft;xt++)bt+=Z[xt].data.length;H+=bt,N+=ft,U.length=bt,U.dts=Math.max(U.dts,E),w=Math.min(U.pts,w),C=Math.max(U.pts,C)}T=c[f-1].dts;const j=H+4*N+8;let nt;try{nt=new Uint8Array(j)}catch($){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:j,reason:`fail allocating video mdat ${j}`});return}const st=new DataView(nt.buffer);st.setUint32(0,j),nt.set(rt.types.mdat,4);let Q=!1,kt=Number.POSITIVE_INFINITY,gt=Number.POSITIVE_INFINITY,Mt=Number.NEGATIVE_INFINITY,Vt=Number.NEGATIVE_INFINITY;for(let $=0;$<f;$++){const U=c[$],Z=U.units;let ft=0;for(let Ut=0,Qt=Z.length;Ut<Qt;Ut++){const ue=Z[Ut],se=ue.data,Yt=ue.data.byteLength;st.setUint32(v,Yt),v+=4,nt.set(se,v),v+=Yt,ft+=4+Yt}let bt;if($<f-1)b=c[$+1].dts-U.dts,bt=c[$+1].pts-U.pts;else{const Ut=this.config,Qt=$>0?U.dts-c[$-1].dts:x;if(bt=$>0?U.pts-c[$-1].pts:x,Ut.stretchShortVideoTrack&&this.nextAudioPts!==null){const ue=Math.floor(Ut.maxBufferHole*o),se=(s?w+s*o:this.nextAudioPts)-U.pts;se>ue?(b=se-Qt,b<0?b=Qt:Q=!0,Y.log(`[mp4-remuxer]: It is approximately ${se/90} ms to the next segment; using duration ${b/90} ms for the last video frame.`)):b=Qt}else b=Qt}const xt=Math.round(U.pts-U.dts);kt=Math.min(kt,b),Mt=Math.max(Mt,b),gt=Math.min(gt,bt),Vt=Math.max(Vt,bt),d.push(new of(U.key,b,ft,xt))}if(d.length){if(No){if(No<70){const $=d[0].flags;$.dependsOn=2,$.isNonSync=0}}else if($c&&Vt-gt<Mt-kt&&x/Mt<.025&&d[0].cts===0){Y.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=E;for(let U=0,Z=d.length;U<Z;U++){const ft=$+d[U].duration,bt=$+d[U].cts;if(U<Z-1){const xt=ft+d[U+1].cts;d[U].duration=xt-bt}else d[U].duration=U?d[U-1].duration:x;d[U].cts=0,$=ft}}}b=Q||!b?x:b,this.nextAvcDts=g=T+b,this.videoSampleDuration=b,this.isVideoContiguous=!0;const V=rt.moof(t.sequenceNumber++,E,ai({},t,{samples:d})),J="video",St={data1:V,data2:nt,startPTS:w/o,endPTS:(C+b)/o,startDTS:E/o,endDTS:g/o,type:J,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,St}remuxAudio(t,e,i,s,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?sf:hb,g=p*f,v=this._initPTS,b=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=b?0:8,D=this.nextAudioPts||-1;const O=e*c,F=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&D>0&&(s&&Math.abs(O-D)<9e3||Math.abs(hr(w[0].pts-F,O)-D)<20*g),w.forEach(function(V){V.pts=hr(V.pts-F,O)}),!i||D<0){if(w=w.filter(V=>V.pts>=0),!w.length)return;o===0?D=0:s&&!T?D=Math.max(0,O):D=w[0].pts}if(t.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let J=0,St=D;J<w.length;J++){const $=w[J],U=$.pts,Z=U-St,ft=Math.abs(1e3*Z/c);if(Z<=-V*g&&T)J===0&&(Y.warn(`Audio frame @ ${(U/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Z/c)} ms.`),this.nextAudioPts=D=St=U);else if(Z>=V*g&&ft<cb&&T){let bt=Math.round(Z/g);St=U-bt*g,St<0&&(bt--,St+=g),J===0&&(this.nextAudioPts=D=St),Y.warn(`[mp4-remuxer]: Injecting ${bt} audio frame @ ${(St/c).toFixed(3)}s due to ${Math.round(1e3*Z/c)} ms gap.`);for(let xt=0;xt<bt;xt++){const Ut=Math.max(St,0);let Qt=ef.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Qt||(Y.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Qt=$.unit.subarray()),w.splice(J,0,{unit:Qt,pts:Ut}),St+=g,J++}}$.pts=St,St+=g}}let x=null,N=null,H,j=0,nt=w.length;for(;nt--;)j+=w[nt].unit.byteLength;for(let V=0,J=w.length;V<J;V++){const St=w[V],$=St.unit;let U=St.pts;if(N!==null){const ft=E[V-1];ft.duration=Math.round((U-N)/f)}else if(i&&t.segmentCodec==="aac"&&(U=D),x=U,j>0){j+=C;try{H=new Uint8Array(j)}catch(ft){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:ft,bytes:j,reason:`fail allocating audio mdat ${j}`});return}b||(new DataView(H.buffer).setUint32(0,j),H.set(rt.types.mdat,4))}else return;H.set($,C);const Z=$.byteLength;C+=Z,E.push(new of(!0,p,Z,0)),N=U}const st=E.length;if(!st)return;const Q=E[E.length-1];this.nextAudioPts=D=N+f*Q.duration;const kt=b?new Uint8Array(0):rt.moof(t.sequenceNumber++,x/f,ai({},t,{samples:E}));t.samples=[];const gt=x/c,Mt=D/c,Vt={data1:kt,data2:H,startPTS:gt,endPTS:Mt,startDTS:gt,endDTS:Mt,type:"audio",hasAudio:!0,hasVideo:!1,nb:st};return this.isAudioContiguous=!0,Vt}remuxEmptyAudio(t,e,i,s){const o=t.inputTimeScale,c=t.samplerate?t.samplerate:o,d=o/c,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:s.startDTS*o)+g,b=s.endDTS*o+g,E=d*sf,T=Math.ceil((b-v)/E),w=ef.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Y.warn("[mp4-remuxer]: remux empty Audio"),!w){Y.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let D=0;D<T;D++){const O=v+D*E;C.push({unit:w,pts:O,dts:O})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function hr(n,t){let e;if(t===null)return n;for(t<n?e=-8589934592:e=8589934592;Math.abs(n-t)>4294967296;)n+=e;return n}function db(n){for(let t=0;t<n.length;t++)if(n[t].key)return t;return-1}function nf(n,t,e,i){const s=n.samples.length;if(!s)return;const o=n.inputTimeScale;for(let d=0;d<s;d++){const f=n.samples[d];f.pts=hr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=hr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=n.samples;return n.samples=[],{samples:c}}function af(n,t,e){const i=n.samples.length;if(!i)return;const s=n.inputTimeScale;for(let c=0;c<i;c++){const d=n.samples[c];d.pts=hr(d.pts-e.baseTime*s/e.timescale,t*s)/s}n.samples.sort((c,d)=>c.pts-d.pts);const o=n.samples;return n.samples=[],{samples:o}}class of{constructor(t,e,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=s,this.flags=new ub(t)}}class ub{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class fb{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Pv(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=l0(t);e||(e=lf(s.audio,Le.AUDIO)),i||(i=lf(s.video,Le.VIDEO));const o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:Y.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,s,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const b=e.samples;if(!(b!=null&&b.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(b),T=this.initData),!((f=T)!=null&&f.length))return Y.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Mv(b,T),C=Ov(T,b),D=C===null?o:C;(pb(p,D,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=D-o,p&&p.timescale===1&&Y.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const O=t?D-p.baseTime/p.timescale:g,F=O+w;Nv(T,b,p.baseTime/p.timescale),w>0?this.lastEndTime=F:(Y.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,N=!!T.video;let H="";x&&(H+="audio"),N&&(H+="video");const j={data1:b,startPTS:O,startDTS:O,endPTS:F,endDTS:F,type:H,hasAudio:x,hasVideo:N,nb:1,dropped:0};return v.audio=j.type==="audio"?j:void 0,v.video=j.type!=="audio"?j:void 0,v.initSegment=E,v.id3=nf(i,o,p,p),s.samples.length&&(v.text=af(s,o,p)),v}}function pb(n,t,e,i){if(n===null)return!0;const s=Math.max(i,1),o=t-n.baseTime/n.timescale;return Math.abs(o-e)>s}function lf(n,t){const e=n==null?void 0:n.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===Le.VIDEO?"avc1.42e01e":"mp4a.40.5"}let ts;try{ts=self.performance.now.bind(self.performance)}catch{Y.debug("Unable to use Performance API on this environment"),ts=typeof self<"u"&&self.Date.now}const Fc=[{demux:Zy,remux:fb},{demux:Es,remux:Nc},{demux:Yy,remux:Nc},{demux:ab,remux:Nc}];class cf{constructor(t,e,i,s,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=s,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const o=i.transmuxing;o.executeStart=ts();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;s&&(this.currentTransmuxState=s);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:b,timeOffset:E,initSegmentChange:T}=s||d,{audioCodec:w,videoCodec:C,defaultInitPts:D,duration:O,initSegmentData:F}=f,x=gb(c,e);if(x&&x.method==="AES-128"){const nt=this.getDecrypter();if(nt.isSync()){let st=nt.softwareDecrypt(c,x.key.buffer,x.iv.buffer);if(i.part>-1&&(st=nt.flush()),!st)return o.executeEnd=ts(),Uc(i);c=new Uint8Array(st)}else return this.decryptionPromise=nt.webCryptoDecrypt(c,x.key.buffer,x.iv.buffer).then(st=>{const Q=this.push(st,null,i);return this.decryptionPromise=null,Q}),this.decryptionPromise}const N=this.needsProbing(g,v);if(N){const nt=this.configureTransmuxer(c);if(nt)return Y.warn(`[transmuxer] ${nt.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:nt,reason:nt.message}),o.executeEnd=ts(),Uc(i)}(g||v||T||N)&&this.resetInitSegment(F,w,C,O,e),(g||T||N)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const H=this.transmux(c,x,E,b,i),j=this.currentTransmuxState;return j.contiguous=!0,j.discontinuity=!1,j.trackSwitch=!1,o.executeEnd=ts(),H}flush(t){const e=t.transmuxing;e.executeStart=ts();const{decrypter:i,currentTransmuxState:s,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=s;if(i){const v=i.flush();v&&c.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=ts(),[Uc(t)];const g=f.flush(d);return Fo(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;Y.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(s,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=ts()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,s),d.resetInitSegment(t,e,i,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,s,o):c=this.transmuxUnencrypted(t,i,s,o),c}transmuxUnencrypted(t,e,i,s){const{audioTrack:o,videoTrack:c,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,c,d,f,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,s,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:o}=this;let c;for(let v=0,b=Fc.length;v<b;v++)if(Fc[v].demux.probe(t)){c=Fc[v];break}if(!c)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=c.remux,g=c.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,s,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,s),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Ic(this.config)),t}}function gb(n,t){let e=null;return n.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Uc=n=>({remuxResult:{},chunkMeta:n});function Fo(n){return"then"in n&&n.then instanceof Function}class mb{constructor(t,e,i,s,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=o||null}}class vb{constructor(t,e,i,s,o,c){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=o,this.initSegmentChange=c}}var hf={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,b){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new s(g,v||f,b),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],E]:f._events[T].push(E):(f._events[T]=E,f._eventsCount++),f}function c(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,b=g.length,E=new Array(b);v<b;v++)E[v]=g[v].fn;return E},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,b,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,D,O;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,b),!0;case 6:return w.fn.call(w.context,p,g,v,b,E),!0}for(O=1,D=new Array(C-1);O<C;O++)D[O-1]=arguments[O];w.fn.apply(w.context,D)}else{var F=w.length,x;for(O=0;O<F;O++)switch(w[O].once&&this.removeListener(f,w[O].fn,void 0,!0),C){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,p);break;case 3:w[O].fn.call(w[O].context,p,g);break;case 4:w[O].fn.call(w[O].context,p,g,v);break;default:if(!D)for(x=1,D=new Array(C-1);x<C;x++)D[x-1]=arguments[x];w[O].fn.apply(w[O].context,D)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var b=e?e+f:f;if(!this._events[b])return this;if(!p)return c(this,b),this;var E=this._events[b];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,b);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);w.length?this._events[b]=w.length===1?w[0]:w:c(this,b)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&c(this,p)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,n.exports=d})(hf);var yb=hf.exports,Bc=rv(yb);const Gc=_o()||{isTypeSupported:()=>!1};class df{constructor(t,e,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const c=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new Bc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Gc.isTypeSupported("video/mp4"),mpeg:Gc.isTypeSupported("audio/mpeg"),mp3:Gc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||Uy())){try{o.workerPath?(Y.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=Gy(o.workerPath)):(Y.log(`injecting Web Worker for "${e}"`),this.workerContext=By()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,Y.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){Y.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new cf(this.observer,d,o,f,e)}return}this.transmuxer=new cf(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,s,o,c,d,f,p,g){var v,b;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=c?c.start:o.start,w=o.decryptdata,C=this.frag,D=!(C&&o.cc===C.cc),O=!(C&&p.level===C.level),F=C?p.sn-C.sn:-1,x=this.part?p.part-this.part.index:-1,N=F===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),H=!O&&(F===1||F===0&&(x===1||N&&x<=0)),j=self.performance.now();(O||F||o.stats.parsing.start===0)&&(o.stats.parsing.start=j),c&&(x||!H)&&(c.stats.parsing.start=j);const nt=!(C&&((v=o.initSegment)==null?void 0:v.url)===((b=C.initSegment)==null?void 0:b.url)),st=new vb(D,H,f,O,T,nt);if(!H||D||nt){Y.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
183
+ */const lu=(n,t,e)=>{const i=new Map;for(let s=t;s<=e;s++)i.set(n[s],s);return i},cu=An(class extends na{constructor(n){if(super(n),n.type!==bn.CHILD)throw Error("repeat() can only be used in text expressions")}ht(n,t,e){let i;e===void 0?e=t:t!==void 0&&(i=t);const s=[],o=[];let c=0;for(const d of n)s[c]=i?i(d,c):c,o[c]=e(d,c),c++;return{values:o,keys:s}}render(n,t,e){return this.ht(n,t,e).values}update(n,[t,e,i]){const s=ag(n),{values:o,keys:c}=this.ht(t,e,i);if(!Array.isArray(s))return this.dt=c,o;const d=this.dt??(this.dt=[]),f=[];let p,g,v=0,b=s.length-1,E=0,T=o.length-1;for(;v<=b&&E<=T;)if(s[v]===null)v++;else if(s[b]===null)b--;else if(d[v]===c[E])f[E]=Zs(s[v],o[E]),v++,E++;else if(d[b]===c[T])f[T]=Zs(s[b],o[T]),b--,T--;else if(d[v]===c[T])f[T]=Zs(s[v],o[T]),sa(n,f[T+1],s[v]),v++,T--;else if(d[b]===c[E])f[E]=Zs(s[b],o[E]),sa(n,s[v],s[b]),b--,E++;else if(p===void 0&&(p=lu(c,E,T),g=lu(d,v,b)),p.has(d[v]))if(p.has(d[b])){const w=g.get(c[E]),C=w!==void 0?s[w]:null;if(C===null){const D=sa(n,s[v]);Zs(D,o[E]),f[E]=D}else f[E]=Zs(C,o[E]),sa(n,s[v],C),s[w]=null;E++}else wl(s[b]),b--;else wl(s[v]),v++;for(;E<=T;){const w=sa(n,f[T+1]);Zs(w,o[E]),f[E++]=w}for(;v<=b;){const w=s[v++];w!==null&&wl(w)}return this.dt=c,ng(n,f),fs}});var Hi="top",ar="bottom",or="right",Vi="left",jl="auto",ga=[Hi,ar,or,Vi],En="start",ma="end",Rm="clippingParents",hu="viewport",va="popper",_m="reference",du=ga.reduce(function(n,t){return n.concat([t+"-"+En,t+"-"+ma])},[]),uu=[].concat(ga,[jl]).reduce(function(n,t){return n.concat([t,t+"-"+En,t+"-"+ma])},[]),Lm="beforeRead",Cm="read",Im="afterRead",xm="beforeMain",Dm="main",Pm="afterMain",Om="beforeWrite",Mm="write",$m="afterWrite",Nm=[Lm,Cm,Im,xm,Dm,Pm,Om,Mm,$m];function Ir(n){return n?(n.nodeName||"").toLowerCase():null}function er(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var t=n.ownerDocument;return t&&t.defaultView||window}return n}function en(n){var t=er(n).Element;return n instanceof t||n instanceof Element}function lr(n){var t=er(n).HTMLElement;return n instanceof t||n instanceof HTMLElement}function Kl(n){if(typeof ShadowRoot>"u")return!1;var t=er(n).ShadowRoot;return n instanceof t||n instanceof ShadowRoot}function Fm(n){var t=n.state;Object.keys(t.elements).forEach(function(e){var i=t.styles[e]||{},s=t.attributes[e]||{},o=t.elements[e];!lr(o)||!Ir(o)||(Object.assign(o.style,i),Object.keys(s).forEach(function(c){var d=s[c];d===!1?o.removeAttribute(c):o.setAttribute(c,d===!0?"":d)}))})}function Um(n){var t=n.state,e={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,e.popper),t.styles=e,t.elements.arrow&&Object.assign(t.elements.arrow.style,e.arrow),function(){Object.keys(t.elements).forEach(function(i){var s=t.elements[i],o=t.attributes[i]||{},c=Object.keys(t.styles.hasOwnProperty(i)?t.styles[i]:e[i]),d=c.reduce(function(f,p){return f[p]="",f},{});!lr(s)||!Ir(s)||(Object.assign(s.style,d),Object.keys(o).forEach(function(f){s.removeAttribute(f)}))})}}const fu={name:"applyStyles",enabled:!0,phase:"write",fn:Fm,effect:Um,requires:["computeStyles"]};function xr(n){return n.split("-")[0]}var rn=Math.max,go=Math.min,Tn=Math.round;function zl(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(t){return t.brand+"/"+t.version}).join(" "):navigator.userAgent}function pu(){return!/^((?!chrome|android).)*safari/i.test(zl())}function kn(n,t,e){t===void 0&&(t=!1),e===void 0&&(e=!1);var i=n.getBoundingClientRect(),s=1,o=1;t&&lr(n)&&(s=n.offsetWidth>0&&Tn(i.width)/n.offsetWidth||1,o=n.offsetHeight>0&&Tn(i.height)/n.offsetHeight||1);var c=en(n)?er(n):window,d=c.visualViewport,f=!pu()&&e,p=(i.left+(f&&d?d.offsetLeft:0))/s,g=(i.top+(f&&d?d.offsetTop:0))/o,v=i.width/s,b=i.height/o;return{width:v,height:b,top:g,right:p+v,bottom:g+b,left:p,x:p,y:g}}function Yl(n){var t=kn(n),e=n.offsetWidth,i=n.offsetHeight;return Math.abs(t.width-e)<=1&&(e=t.width),Math.abs(t.height-i)<=1&&(i=t.height),{x:n.offsetLeft,y:n.offsetTop,width:e,height:i}}function gu(n,t){var e=t.getRootNode&&t.getRootNode();if(n.contains(t))return!0;if(e&&Kl(e)){var i=t;do{if(i&&n.isSameNode(i))return!0;i=i.parentNode||i.host}while(i)}return!1}function qr(n){return er(n).getComputedStyle(n)}function Bm(n){return["table","td","th"].indexOf(Ir(n))>=0}function As(n){return((en(n)?n.ownerDocument:n.document)||window.document).documentElement}function mo(n){return Ir(n)==="html"?n:n.assignedSlot||n.parentNode||(Kl(n)?n.host:null)||As(n)}function mu(n){return!lr(n)||qr(n).position==="fixed"?null:n.offsetParent}function Gm(n){var t=/firefox/i.test(zl()),e=/Trident/i.test(zl());if(e&&lr(n)){var i=qr(n);if(i.position==="fixed")return null}var s=mo(n);for(Kl(s)&&(s=s.host);lr(s)&&["html","body"].indexOf(Ir(s))<0;){var o=qr(s);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||t&&o.willChange==="filter"||t&&o.filter&&o.filter!=="none")return s;s=s.parentNode}return null}function ya(n){for(var t=er(n),e=mu(n);e&&Bm(e)&&qr(e).position==="static";)e=mu(e);return e&&(Ir(e)==="html"||Ir(e)==="body"&&qr(e).position==="static")?t:e||Gm(n)||t}function Xl(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function ba(n,t,e){return rn(n,go(t,e))}function Hm(n,t,e){var i=ba(n,t,e);return i>e?e:i}function vu(){return{top:0,right:0,bottom:0,left:0}}function yu(n){return Object.assign({},vu(),n)}function bu(n,t){return t.reduce(function(e,i){return e[i]=n,e},{})}var Vm=function(t,e){return t=typeof t=="function"?t(Object.assign({},e.rects,{placement:e.placement})):t,yu(typeof t!="number"?t:bu(t,ga))};function Wm(n){var t,e=n.state,i=n.name,s=n.options,o=e.elements.arrow,c=e.modifiersData.popperOffsets,d=xr(e.placement),f=Xl(d),p=[Vi,or].indexOf(d)>=0,g=p?"height":"width";if(!(!o||!c)){var v=Vm(s.padding,e),b=Yl(o),E=f==="y"?Hi:Vi,T=f==="y"?ar:or,w=e.rects.reference[g]+e.rects.reference[f]-c[f]-e.rects.popper[g],C=c[f]-e.rects.reference[f],D=ya(o),O=D?f==="y"?D.clientHeight||0:D.clientWidth||0:0,F=w/2-C/2,x=v[E],N=O-b[g]-v[T],H=O/2-b[g]/2+F,j=ba(x,H,N),nt=f;e.modifiersData[i]=(t={},t[nt]=j,t.centerOffset=j-H,t)}}function jm(n){var t=n.state,e=n.options,i=e.element,s=i===void 0?"[data-popper-arrow]":i;s!=null&&(typeof s=="string"&&(s=t.elements.popper.querySelector(s),!s)||gu(t.elements.popper,s)&&(t.elements.arrow=s))}const Km={name:"arrow",enabled:!0,phase:"main",fn:Wm,effect:jm,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function wn(n){return n.split("-")[1]}var zm={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Ym(n,t){var e=n.x,i=n.y,s=t.devicePixelRatio||1;return{x:Tn(e*s)/s||0,y:Tn(i*s)/s||0}}function Au(n){var t,e=n.popper,i=n.popperRect,s=n.placement,o=n.variation,c=n.offsets,d=n.position,f=n.gpuAcceleration,p=n.adaptive,g=n.roundOffsets,v=n.isFixed,b=c.x,E=b===void 0?0:b,T=c.y,w=T===void 0?0:T,C=typeof g=="function"?g({x:E,y:w}):{x:E,y:w};E=C.x,w=C.y;var D=c.hasOwnProperty("x"),O=c.hasOwnProperty("y"),F=Vi,x=Hi,N=window;if(p){var H=ya(e),j="clientHeight",nt="clientWidth";if(H===er(e)&&(H=As(e),qr(H).position!=="static"&&d==="absolute"&&(j="scrollHeight",nt="scrollWidth")),H=H,s===Hi||(s===Vi||s===or)&&o===ma){x=ar;var st=v&&H===N&&N.visualViewport?N.visualViewport.height:H[j];w-=st-i.height,w*=f?1:-1}if(s===Vi||(s===Hi||s===ar)&&o===ma){F=or;var Q=v&&H===N&&N.visualViewport?N.visualViewport.width:H[nt];E-=Q-i.width,E*=f?1:-1}}var kt=Object.assign({position:d},p&&zm),gt=g===!0?Ym({x:E,y:w},er(e)):{x:E,y:w};if(E=gt.x,w=gt.y,f){var Mt;return Object.assign({},kt,(Mt={},Mt[x]=O?"0":"",Mt[F]=D?"0":"",Mt.transform=(N.devicePixelRatio||1)<=1?"translate("+E+"px, "+w+"px)":"translate3d("+E+"px, "+w+"px, 0)",Mt))}return Object.assign({},kt,(t={},t[x]=O?w+"px":"",t[F]=D?E+"px":"",t.transform="",t))}function Xm(n){var t=n.state,e=n.options,i=e.gpuAcceleration,s=i===void 0?!0:i,o=e.adaptive,c=o===void 0?!0:o,d=e.roundOffsets,f=d===void 0?!0:d,p={placement:xr(t.placement),variation:wn(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:s,isFixed:t.options.strategy==="fixed"};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,Au(Object.assign({},p,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:c,roundOffsets:f})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,Au(Object.assign({},p,{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:f})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}const Zm={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:Xm,data:{}};var vo={passive:!0};function qm(n){var t=n.state,e=n.instance,i=n.options,s=i.scroll,o=s===void 0?!0:s,c=i.resize,d=c===void 0?!0:c,f=er(t.elements.popper),p=[].concat(t.scrollParents.reference,t.scrollParents.popper);return o&&p.forEach(function(g){g.addEventListener("scroll",e.update,vo)}),d&&f.addEventListener("resize",e.update,vo),function(){o&&p.forEach(function(g){g.removeEventListener("scroll",e.update,vo)}),d&&f.removeEventListener("resize",e.update,vo)}}const Qm={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:qm,data:{}};var Jm={left:"right",right:"left",bottom:"top",top:"bottom"};function yo(n){return n.replace(/left|right|bottom|top/g,function(t){return Jm[t]})}var t1={start:"end",end:"start"};function Eu(n){return n.replace(/start|end/g,function(t){return t1[t]})}function Zl(n){var t=er(n),e=t.pageXOffset,i=t.pageYOffset;return{scrollLeft:e,scrollTop:i}}function ql(n){return kn(As(n)).left+Zl(n).scrollLeft}function e1(n,t){var e=er(n),i=As(n),s=e.visualViewport,o=i.clientWidth,c=i.clientHeight,d=0,f=0;if(s){o=s.width,c=s.height;var p=pu();(p||!p&&t==="fixed")&&(d=s.offsetLeft,f=s.offsetTop)}return{width:o,height:c,x:d+ql(n),y:f}}function i1(n){var t,e=As(n),i=Zl(n),s=(t=n.ownerDocument)==null?void 0:t.body,o=rn(e.scrollWidth,e.clientWidth,s?s.scrollWidth:0,s?s.clientWidth:0),c=rn(e.scrollHeight,e.clientHeight,s?s.scrollHeight:0,s?s.clientHeight:0),d=-i.scrollLeft+ql(n),f=-i.scrollTop;return qr(s||e).direction==="rtl"&&(d+=rn(e.clientWidth,s?s.clientWidth:0)-o),{width:o,height:c,x:d,y:f}}function Ql(n){var t=qr(n),e=t.overflow,i=t.overflowX,s=t.overflowY;return/auto|scroll|overlay|hidden/.test(e+s+i)}function Tu(n){return["html","body","#document"].indexOf(Ir(n))>=0?n.ownerDocument.body:lr(n)&&Ql(n)?n:Tu(mo(n))}function Aa(n,t){var e;t===void 0&&(t=[]);var i=Tu(n),s=i===((e=n.ownerDocument)==null?void 0:e.body),o=er(i),c=s?[o].concat(o.visualViewport||[],Ql(i)?i:[]):i,d=t.concat(c);return s?d:d.concat(Aa(mo(c)))}function Jl(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function r1(n,t){var e=kn(n,!1,t==="fixed");return e.top=e.top+n.clientTop,e.left=e.left+n.clientLeft,e.bottom=e.top+n.clientHeight,e.right=e.left+n.clientWidth,e.width=n.clientWidth,e.height=n.clientHeight,e.x=e.left,e.y=e.top,e}function ku(n,t,e){return t===hu?Jl(e1(n,e)):en(t)?r1(t,e):Jl(i1(As(n)))}function s1(n){var t=Aa(mo(n)),e=["absolute","fixed"].indexOf(qr(n).position)>=0,i=e&&lr(n)?ya(n):n;return en(i)?t.filter(function(s){return en(s)&&gu(s,i)&&Ir(s)!=="body"}):[]}function n1(n,t,e,i){var s=t==="clippingParents"?s1(n):[].concat(t),o=[].concat(s,[e]),c=o[0],d=o.reduce(function(f,p){var g=ku(n,p,i);return f.top=rn(g.top,f.top),f.right=go(g.right,f.right),f.bottom=go(g.bottom,f.bottom),f.left=rn(g.left,f.left),f},ku(n,c,i));return d.width=d.right-d.left,d.height=d.bottom-d.top,d.x=d.left,d.y=d.top,d}function wu(n){var t=n.reference,e=n.element,i=n.placement,s=i?xr(i):null,o=i?wn(i):null,c=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,f;switch(s){case Hi:f={x:c,y:t.y-e.height};break;case ar:f={x:c,y:t.y+t.height};break;case or:f={x:t.x+t.width,y:d};break;case Vi:f={x:t.x-e.width,y:d};break;default:f={x:t.x,y:t.y}}var p=s?Xl(s):null;if(p!=null){var g=p==="y"?"height":"width";switch(o){case En:f[p]=f[p]-(t[g]/2-e[g]/2);break;case ma:f[p]=f[p]+(t[g]/2-e[g]/2);break}}return f}function Ea(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=i===void 0?n.placement:i,o=e.strategy,c=o===void 0?n.strategy:o,d=e.boundary,f=d===void 0?Rm:d,p=e.rootBoundary,g=p===void 0?hu:p,v=e.elementContext,b=v===void 0?va:v,E=e.altBoundary,T=E===void 0?!1:E,w=e.padding,C=w===void 0?0:w,D=yu(typeof C!="number"?C:bu(C,ga)),O=b===va?_m:va,F=n.rects.popper,x=n.elements[T?O:b],N=n1(en(x)?x:x.contextElement||As(n.elements.popper),f,g,c),H=kn(n.elements.reference),j=wu({reference:H,element:F,strategy:"absolute",placement:s}),nt=Jl(Object.assign({},F,j)),st=b===va?nt:H,Q={top:N.top-st.top+D.top,bottom:st.bottom-N.bottom+D.bottom,left:N.left-st.left+D.left,right:st.right-N.right+D.right},kt=n.modifiersData.offset;if(b===va&&kt){var gt=kt[s];Object.keys(Q).forEach(function(Mt){var Vt=[or,ar].indexOf(Mt)>=0?1:-1,V=[Hi,ar].indexOf(Mt)>=0?"y":"x";Q[Mt]+=gt[V]*Vt})}return Q}function a1(n,t){t===void 0&&(t={});var e=t,i=e.placement,s=e.boundary,o=e.rootBoundary,c=e.padding,d=e.flipVariations,f=e.allowedAutoPlacements,p=f===void 0?uu:f,g=wn(i),v=g?d?du:du.filter(function(T){return wn(T)===g}):ga,b=v.filter(function(T){return p.indexOf(T)>=0});b.length===0&&(b=v);var E=b.reduce(function(T,w){return T[w]=Ea(n,{placement:w,boundary:s,rootBoundary:o,padding:c})[xr(w)],T},{});return Object.keys(E).sort(function(T,w){return E[T]-E[w]})}function o1(n){if(xr(n)===jl)return[];var t=yo(n);return[Eu(n),t,Eu(t)]}function l1(n){var t=n.state,e=n.options,i=n.name;if(!t.modifiersData[i]._skip){for(var s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!0:c,f=e.fallbackPlacements,p=e.padding,g=e.boundary,v=e.rootBoundary,b=e.altBoundary,E=e.flipVariations,T=E===void 0?!0:E,w=e.allowedAutoPlacements,C=t.options.placement,D=xr(C),O=D===C,F=f||(O||!T?[yo(C)]:o1(C)),x=[C].concat(F).reduce(function(Ut,Qt){return Ut.concat(xr(Qt)===jl?a1(t,{placement:Qt,boundary:g,rootBoundary:v,padding:p,flipVariations:T,allowedAutoPlacements:w}):Qt)},[]),N=t.rects.reference,H=t.rects.popper,j=new Map,nt=!0,st=x[0],Q=0;Q<x.length;Q++){var kt=x[Q],gt=xr(kt),Mt=wn(kt)===En,Vt=[Hi,ar].indexOf(gt)>=0,V=Vt?"width":"height",J=Ea(t,{placement:kt,boundary:g,rootBoundary:v,altBoundary:b,padding:p}),St=Vt?Mt?or:Vi:Mt?ar:Hi;N[V]>H[V]&&(St=yo(St));var $=yo(St),U=[];if(o&&U.push(J[gt]<=0),d&&U.push(J[St]<=0,J[$]<=0),U.every(function(Ut){return Ut})){st=kt,nt=!1;break}j.set(kt,U)}if(nt)for(var Z=T?3:1,ft=function(Qt){var ue=x.find(function(se){var Yt=j.get(se);if(Yt)return Yt.slice(0,Qt).every(function(Me){return Me})});if(ue)return st=ue,"break"},bt=Z;bt>0;bt--){var xt=ft(bt);if(xt==="break")break}t.placement!==st&&(t.modifiersData[i]._skip=!0,t.placement=st,t.reset=!0)}}const c1={name:"flip",enabled:!0,phase:"main",fn:l1,requiresIfExists:["offset"],data:{_skip:!1}};function Su(n,t,e){return e===void 0&&(e={x:0,y:0}),{top:n.top-t.height-e.y,right:n.right-t.width+e.x,bottom:n.bottom-t.height+e.y,left:n.left-t.width-e.x}}function Ru(n){return[Hi,or,ar,Vi].some(function(t){return n[t]>=0})}function h1(n){var t=n.state,e=n.name,i=t.rects.reference,s=t.rects.popper,o=t.modifiersData.preventOverflow,c=Ea(t,{elementContext:"reference"}),d=Ea(t,{altBoundary:!0}),f=Su(c,i),p=Su(d,s,o),g=Ru(f),v=Ru(p);t.modifiersData[e]={referenceClippingOffsets:f,popperEscapeOffsets:p,isReferenceHidden:g,hasPopperEscaped:v},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":g,"data-popper-escaped":v})}const d1={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:h1};function u1(n,t,e){var i=xr(n),s=[Vi,Hi].indexOf(i)>=0?-1:1,o=typeof e=="function"?e(Object.assign({},t,{placement:n})):e,c=o[0],d=o[1];return c=c||0,d=(d||0)*s,[Vi,or].indexOf(i)>=0?{x:d,y:c}:{x:c,y:d}}function f1(n){var t=n.state,e=n.options,i=n.name,s=e.offset,o=s===void 0?[0,0]:s,c=uu.reduce(function(g,v){return g[v]=u1(v,t.rects,o),g},{}),d=c[t.placement],f=d.x,p=d.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=p),t.modifiersData[i]=c}const p1={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:f1};function g1(n){var t=n.state,e=n.name;t.modifiersData[e]=wu({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})}const m1={name:"popperOffsets",enabled:!0,phase:"read",fn:g1,data:{}};function v1(n){return n==="x"?"y":"x"}function y1(n){var t=n.state,e=n.options,i=n.name,s=e.mainAxis,o=s===void 0?!0:s,c=e.altAxis,d=c===void 0?!1:c,f=e.boundary,p=e.rootBoundary,g=e.altBoundary,v=e.padding,b=e.tether,E=b===void 0?!0:b,T=e.tetherOffset,w=T===void 0?0:T,C=Ea(t,{boundary:f,rootBoundary:p,padding:v,altBoundary:g}),D=xr(t.placement),O=wn(t.placement),F=!O,x=Xl(D),N=v1(x),H=t.modifiersData.popperOffsets,j=t.rects.reference,nt=t.rects.popper,st=typeof w=="function"?w(Object.assign({},t.rects,{placement:t.placement})):w,Q=typeof st=="number"?{mainAxis:st,altAxis:st}:Object.assign({mainAxis:0,altAxis:0},st),kt=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,gt={x:0,y:0};if(H){if(o){var Mt,Vt=x==="y"?Hi:Vi,V=x==="y"?ar:or,J=x==="y"?"height":"width",St=H[x],$=St+C[Vt],U=St-C[V],Z=E?-nt[J]/2:0,ft=O===En?j[J]:nt[J],bt=O===En?-nt[J]:-j[J],xt=t.elements.arrow,Ut=E&&xt?Yl(xt):{width:0,height:0},Qt=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:vu(),ue=Qt[Vt],se=Qt[V],Yt=ba(0,j[J],Ut[J]),Me=F?j[J]/2-Z-Yt-ue-Q.mainAxis:ft-Yt-ue-Q.mainAxis,be=F?-j[J]/2+Z+Yt+se+Q.mainAxis:bt+Yt+se+Q.mainAxis,jt=t.elements.arrow&&ya(t.elements.arrow),ge=jt?x==="y"?jt.clientTop||0:jt.clientLeft||0:0,oe=(Mt=kt==null?void 0:kt[x])!=null?Mt:0,Ce=St+Me-oe-ge,Ft=St+be-oe,Xe=ba(E?go($,Ce):$,St,E?rn(U,Ft):U);H[x]=Xe,gt[x]=Xe-St}if(d){var qe,$i=x==="x"?Hi:Vi,Tr=x==="x"?ar:or,ke=H[N],li=N==="y"?"height":"width",me=ke+C[$i],Je=ke-C[Tr],ti=[Hi,Vi].indexOf(D)!==-1,Xi=(qe=kt==null?void 0:kt[N])!=null?qe:0,Ne=ti?me:ke-j[li]-nt[li]-Xi+Q.altAxis,Ci=ti?ke+j[li]+nt[li]-Xi-Q.altAxis:Je,ss=E&&ti?Hm(Ne,ke,Ci):ba(E?Ne:me,ke,E?Ci:Je);H[N]=ss,gt[N]=ss-ke}t.modifiersData[i]=gt}}const b1={name:"preventOverflow",enabled:!0,phase:"main",fn:y1,requiresIfExists:["offset"]};function A1(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function E1(n){return n===er(n)||!lr(n)?Zl(n):A1(n)}function T1(n){var t=n.getBoundingClientRect(),e=Tn(t.width)/n.offsetWidth||1,i=Tn(t.height)/n.offsetHeight||1;return e!==1||i!==1}function k1(n,t,e){e===void 0&&(e=!1);var i=lr(t),s=lr(t)&&T1(t),o=As(t),c=kn(n,s,e),d={scrollLeft:0,scrollTop:0},f={x:0,y:0};return(i||!i&&!e)&&((Ir(t)!=="body"||Ql(o))&&(d=E1(t)),lr(t)?(f=kn(t,!0),f.x+=t.clientLeft,f.y+=t.clientTop):o&&(f.x=ql(o))),{x:c.left+d.scrollLeft-f.x,y:c.top+d.scrollTop-f.y,width:c.width,height:c.height}}function w1(n){var t=new Map,e=new Set,i=[];n.forEach(function(o){t.set(o.name,o)});function s(o){e.add(o.name);var c=[].concat(o.requires||[],o.requiresIfExists||[]);c.forEach(function(d){if(!e.has(d)){var f=t.get(d);f&&s(f)}}),i.push(o)}return n.forEach(function(o){e.has(o.name)||s(o)}),i}function S1(n){var t=w1(n);return Nm.reduce(function(e,i){return e.concat(t.filter(function(s){return s.phase===i}))},[])}function R1(n){var t;return function(){return t||(t=new Promise(function(e){Promise.resolve().then(function(){t=void 0,e(n())})})),t}}function _1(n){var t=n.reduce(function(e,i){var s=e[i.name];return e[i.name]=s?Object.assign({},s,i,{options:Object.assign({},s.options,i.options),data:Object.assign({},s.data,i.data)}):i,e},{});return Object.keys(t).map(function(e){return t[e]})}var _u={placement:"bottom",modifiers:[],strategy:"absolute"};function Lu(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return!t.some(function(i){return!(i&&typeof i.getBoundingClientRect=="function")})}function L1(n){n===void 0&&(n={});var t=n,e=t.defaultModifiers,i=e===void 0?[]:e,s=t.defaultOptions,o=s===void 0?_u:s;return function(d,f,p){p===void 0&&(p=o);var g={placement:"bottom",orderedModifiers:[],options:Object.assign({},_u,o),modifiersData:{},elements:{reference:d,popper:f},attributes:{},styles:{}},v=[],b=!1,E={state:g,setOptions:function(D){var O=typeof D=="function"?D(g.options):D;w(),g.options=Object.assign({},o,g.options,O),g.scrollParents={reference:en(d)?Aa(d):d.contextElement?Aa(d.contextElement):[],popper:Aa(f)};var F=S1(_1([].concat(i,g.options.modifiers)));return g.orderedModifiers=F.filter(function(x){return x.enabled}),T(),E.update()},forceUpdate:function(){if(!b){var D=g.elements,O=D.reference,F=D.popper;if(Lu(O,F)){g.rects={reference:k1(O,ya(F),g.options.strategy==="fixed"),popper:Yl(F)},g.reset=!1,g.placement=g.options.placement,g.orderedModifiers.forEach(function(Q){return g.modifiersData[Q.name]=Object.assign({},Q.data)});for(var x=0;x<g.orderedModifiers.length;x++){if(g.reset===!0){g.reset=!1,x=-1;continue}var N=g.orderedModifiers[x],H=N.fn,j=N.options,nt=j===void 0?{}:j,st=N.name;typeof H=="function"&&(g=H({state:g,options:nt,name:st,instance:E})||g)}}}},update:R1(function(){return new Promise(function(C){E.forceUpdate(),C(g)})}),destroy:function(){w(),b=!0}};if(!Lu(d,f))return E;E.setOptions(p).then(function(C){!b&&p.onFirstUpdate&&p.onFirstUpdate(C)});function T(){g.orderedModifiers.forEach(function(C){var D=C.name,O=C.options,F=O===void 0?{}:O,x=C.effect;if(typeof x=="function"){var N=x({state:g,name:D,instance:E,options:F}),H=function(){};v.push(N||H)}})}function w(){v.forEach(function(C){return C()}),v=[]}return E}}var C1=[Qm,m1,Zm,fu,p1,c1,b1,Km,d1],I1=L1({defaultModifiers:C1}),x1="tippy-box",Cu="tippy-content",D1="tippy-backdrop",Iu="tippy-arrow",xu="tippy-svg-arrow",sn={passive:!0,capture:!0},Du=function(){return document.body};function tc(n,t,e){if(Array.isArray(n)){var i=n[t];return i??(Array.isArray(e)?e[t]:e)}return n}function ec(n,t){var e={}.toString.call(n);return e.indexOf("[object")===0&&e.indexOf(t+"]")>-1}function Pu(n,t){return typeof n=="function"?n.apply(void 0,t):n}function Ou(n,t){if(t===0)return n;var e;return function(i){clearTimeout(e),e=setTimeout(function(){n(i)},t)}}function P1(n){return n.split(/\s+/).filter(Boolean)}function Sn(n){return[].concat(n)}function Mu(n,t){n.indexOf(t)===-1&&n.push(t)}function O1(n){return n.filter(function(t,e){return n.indexOf(t)===e})}function M1(n){return n.split("-")[0]}function bo(n){return[].slice.call(n)}function $u(n){return Object.keys(n).reduce(function(t,e){return n[e]!==void 0&&(t[e]=n[e]),t},{})}function Ta(){return document.createElement("div")}function Ao(n){return["Element","Fragment"].some(function(t){return ec(n,t)})}function $1(n){return ec(n,"NodeList")}function N1(n){return ec(n,"MouseEvent")}function F1(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function U1(n){return Ao(n)?[n]:$1(n)?bo(n):Array.isArray(n)?n:bo(document.querySelectorAll(n))}function ic(n,t){n.forEach(function(e){e&&(e.style.transitionDuration=t+"ms")})}function Nu(n,t){n.forEach(function(e){e&&e.setAttribute("data-state",t)})}function B1(n){var t,e=Sn(n),i=e[0];return i!=null&&(t=i.ownerDocument)!=null&&t.body?i.ownerDocument:document}function G1(n,t){var e=t.clientX,i=t.clientY;return n.every(function(s){var o=s.popperRect,c=s.popperState,d=s.props,f=d.interactiveBorder,p=M1(c.placement),g=c.modifiersData.offset;if(!g)return!0;var v=p==="bottom"?g.top.y:0,b=p==="top"?g.bottom.y:0,E=p==="right"?g.left.x:0,T=p==="left"?g.right.x:0,w=o.top-i+v>f,C=i-o.bottom-b>f,D=o.left-e+E>f,O=e-o.right-T>f;return w||C||D||O})}function rc(n,t,e){var i=t+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(s){n[i](s,e)})}function Fu(n,t){for(var e=t;e;){var i;if(n.contains(e))return!0;e=e.getRootNode==null||(i=e.getRootNode())==null?void 0:i.host}return!1}var Dr={isTouch:!1},Uu=0;function H1(){Dr.isTouch||(Dr.isTouch=!0,window.performance&&document.addEventListener("mousemove",Bu))}function Bu(){var n=performance.now();n-Uu<20&&(Dr.isTouch=!1,document.removeEventListener("mousemove",Bu)),Uu=n}function V1(){var n=document.activeElement;if(F1(n)){var t=n._tippy;n.blur&&!t.state.isVisible&&n.blur()}}function W1(){document.addEventListener("touchstart",H1,sn),window.addEventListener("blur",V1)}var j1=typeof window<"u"&&typeof document<"u",K1=j1?!!window.msCrypto:!1,z1={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Y1={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},yr=Object.assign({appendTo:Du,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},z1,Y1),X1=Object.keys(yr),Z1=function(t){var e=Object.keys(t);e.forEach(function(i){yr[i]=t[i]})};function Gu(n){var t=n.plugins||[],e=t.reduce(function(i,s){var o=s.name,c=s.defaultValue;if(o){var d;i[o]=n[o]!==void 0?n[o]:(d=yr[o])!=null?d:c}return i},{});return Object.assign({},n,e)}function q1(n,t){var e=t?Object.keys(Gu(Object.assign({},yr,{plugins:t}))):X1,i=e.reduce(function(s,o){var c=(n.getAttribute("data-tippy-"+o)||"").trim();if(!c)return s;if(o==="content")s[o]=c;else try{s[o]=JSON.parse(c)}catch{s[o]=c}return s},{});return i}function Hu(n,t){var e=Object.assign({},t,{content:Pu(t.content,[n])},t.ignoreAttributes?{}:q1(n,t.plugins));return e.aria=Object.assign({},yr.aria,e.aria),e.aria={expanded:e.aria.expanded==="auto"?t.interactive:e.aria.expanded,content:e.aria.content==="auto"?t.interactive?null:"describedby":e.aria.content},e}var Q1=function(){return"innerHTML"};function sc(n,t){n[Q1()]=t}function Vu(n){var t=Ta();return n===!0?t.className=Iu:(t.className=xu,Ao(n)?t.appendChild(n):sc(t,n)),t}function Wu(n,t){Ao(t.content)?(sc(n,""),n.appendChild(t.content)):typeof t.content!="function"&&(t.allowHTML?sc(n,t.content):n.textContent=t.content)}function nc(n){var t=n.firstElementChild,e=bo(t.children);return{box:t,content:e.find(function(i){return i.classList.contains(Cu)}),arrow:e.find(function(i){return i.classList.contains(Iu)||i.classList.contains(xu)}),backdrop:e.find(function(i){return i.classList.contains(D1)})}}function ju(n){var t=Ta(),e=Ta();e.className=x1,e.setAttribute("data-state","hidden"),e.setAttribute("tabindex","-1");var i=Ta();i.className=Cu,i.setAttribute("data-state","hidden"),Wu(i,n.props),t.appendChild(e),e.appendChild(i),s(n.props,n.props);function s(o,c){var d=nc(t),f=d.box,p=d.content,g=d.arrow;c.theme?f.setAttribute("data-theme",c.theme):f.removeAttribute("data-theme"),typeof c.animation=="string"?f.setAttribute("data-animation",c.animation):f.removeAttribute("data-animation"),c.inertia?f.setAttribute("data-inertia",""):f.removeAttribute("data-inertia"),f.style.maxWidth=typeof c.maxWidth=="number"?c.maxWidth+"px":c.maxWidth,c.role?f.setAttribute("role",c.role):f.removeAttribute("role"),(o.content!==c.content||o.allowHTML!==c.allowHTML)&&Wu(p,n.props),c.arrow?g?o.arrow!==c.arrow&&(f.removeChild(g),f.appendChild(Vu(c.arrow))):f.appendChild(Vu(c.arrow)):g&&f.removeChild(g)}return{popper:t,onUpdate:s}}ju.$$tippy=!0;var J1=1,Eo=[],ac=[];function tv(n,t){var e=Hu(n,Object.assign({},yr,Gu($u(t)))),i,s,o,c=!1,d=!1,f=!1,p=!1,g,v,b,E=[],T=Ou(Ce,e.interactiveDebounce),w,C=J1++,D=null,O=O1(e.plugins),F={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:C,reference:n,popper:Ta(),popperInstance:D,props:e,state:F,plugins:O,clearDelayTimeouts:Ne,setProps:Ci,setContent:ss,show:ci,hide:kr,hideWithInteractivity:_s,enable:ti,disable:Xi,unmount:Ls,destroy:ir};if(!e.render)return x;var N=e.render(x),H=N.popper,j=N.onUpdate;H.setAttribute("data-tippy-root",""),H.id="tippy-"+x.id,x.popper=H,n._tippy=x,H._tippy=x;var nt=O.map(function(ct){return ct.fn(x)}),st=n.hasAttribute("aria-expanded");return jt(),Z(),St(),$("onCreate",[x]),e.showOnCreate&&me(),H.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),H.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&Vt().addEventListener("mousemove",T)}),x;function Q(){var ct=x.props.touch;return Array.isArray(ct)?ct:[ct,0]}function kt(){return Q()[0]==="hold"}function gt(){var ct;return!!((ct=x.props.render)!=null&&ct.$$tippy)}function Mt(){return w||n}function Vt(){var ct=Mt().parentNode;return ct?B1(ct):document}function V(){return nc(H)}function J(ct){return x.state.isMounted&&!x.state.isVisible||Dr.isTouch||g&&g.type==="focus"?0:tc(x.props.delay,ct?0:1,yr.delay)}function St(ct){ct===void 0&&(ct=!1),H.style.pointerEvents=x.props.interactive&&!ct?"":"none",H.style.zIndex=""+x.props.zIndex}function $(ct,Gt,Xt){if(Xt===void 0&&(Xt=!0),nt.forEach(function(ae){ae[ct]&&ae[ct].apply(ae,Gt)}),Xt){var ve;(ve=x.props)[ct].apply(ve,Gt)}}function U(){var ct=x.props.aria;if(ct.content){var Gt="aria-"+ct.content,Xt=H.id,ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){var ni=ae.getAttribute(Gt);if(x.state.isVisible)ae.setAttribute(Gt,ni?ni+" "+Xt:Xt);else{var Ii=ni&&ni.replace(Xt,"").trim();Ii?ae.setAttribute(Gt,Ii):ae.removeAttribute(Gt)}})}}function Z(){if(!(st||!x.props.aria.expanded)){var ct=Sn(x.props.triggerTarget||n);ct.forEach(function(Gt){x.props.interactive?Gt.setAttribute("aria-expanded",x.state.isVisible&&Gt===Mt()?"true":"false"):Gt.removeAttribute("aria-expanded")})}}function ft(){Vt().removeEventListener("mousemove",T),Eo=Eo.filter(function(ct){return ct!==T})}function bt(ct){if(!(Dr.isTouch&&(f||ct.type==="mousedown"))){var Gt=ct.composedPath&&ct.composedPath()[0]||ct.target;if(!(x.props.interactive&&Fu(H,Gt))){if(Sn(x.props.triggerTarget||n).some(function(Xt){return Fu(Xt,Gt)})){if(Dr.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else $("onClickOutside",[x,ct]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),d=!0,setTimeout(function(){d=!1}),x.state.isMounted||ue())}}}function xt(){f=!0}function Ut(){f=!1}function Qt(){var ct=Vt();ct.addEventListener("mousedown",bt,!0),ct.addEventListener("touchend",bt,sn),ct.addEventListener("touchstart",Ut,sn),ct.addEventListener("touchmove",xt,sn)}function ue(){var ct=Vt();ct.removeEventListener("mousedown",bt,!0),ct.removeEventListener("touchend",bt,sn),ct.removeEventListener("touchstart",Ut,sn),ct.removeEventListener("touchmove",xt,sn)}function se(ct,Gt){Me(ct,function(){!x.state.isVisible&&H.parentNode&&H.parentNode.contains(H)&&Gt()})}function Yt(ct,Gt){Me(ct,Gt)}function Me(ct,Gt){var Xt=V().box;function ve(ae){ae.target===Xt&&(rc(Xt,"remove",ve),Gt())}if(ct===0)return Gt();rc(Xt,"remove",v),rc(Xt,"add",ve),v=ve}function be(ct,Gt,Xt){Xt===void 0&&(Xt=!1);var ve=Sn(x.props.triggerTarget||n);ve.forEach(function(ae){ae.addEventListener(ct,Gt,Xt),E.push({node:ae,eventType:ct,handler:Gt,options:Xt})})}function jt(){kt()&&(be("touchstart",oe,{passive:!0}),be("touchend",Ft,{passive:!0})),P1(x.props.trigger).forEach(function(ct){if(ct!=="manual")switch(be(ct,oe),ct){case"mouseenter":be("mouseleave",Ft);break;case"focus":be(K1?"focusout":"blur",Xe);break;case"focusin":be("focusout",Xe);break}})}function ge(){E.forEach(function(ct){var Gt=ct.node,Xt=ct.eventType,ve=ct.handler,ae=ct.options;Gt.removeEventListener(Xt,ve,ae)}),E=[]}function oe(ct){var Gt,Xt=!1;if(!(!x.state.isEnabled||qe(ct)||d)){var ve=((Gt=g)==null?void 0:Gt.type)==="focus";g=ct,w=ct.currentTarget,Z(),!x.state.isVisible&&N1(ct)&&Eo.forEach(function(ae){return ae(ct)}),ct.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||c)&&x.props.hideOnClick!==!1&&x.state.isVisible?Xt=!0:me(ct),ct.type==="click"&&(c=!Xt),Xt&&!ve&&Je(ct)}}function Ce(ct){var Gt=ct.target,Xt=Mt().contains(Gt)||H.contains(Gt);if(!(ct.type==="mousemove"&&Xt)){var ve=li().concat(H).map(function(ae){var ni,Ii=ae._tippy,ur=(ni=Ii.popperInstance)==null?void 0:ni.state;return ur?{popperRect:ae.getBoundingClientRect(),popperState:ur,props:e}:null}).filter(Boolean);G1(ve,ct)&&(ft(),Je(ct))}}function Ft(ct){var Gt=qe(ct)||x.props.trigger.indexOf("click")>=0&&c;if(!Gt){if(x.props.interactive){x.hideWithInteractivity(ct);return}Je(ct)}}function Xe(ct){x.props.trigger.indexOf("focusin")<0&&ct.target!==Mt()||x.props.interactive&&ct.relatedTarget&&H.contains(ct.relatedTarget)||Je(ct)}function qe(ct){return Dr.isTouch?kt()!==ct.type.indexOf("touch")>=0:!1}function $i(){Tr();var ct=x.props,Gt=ct.popperOptions,Xt=ct.placement,ve=ct.offset,ae=ct.getReferenceClientRect,ni=ct.moveTransition,Ii=gt()?nc(H).arrow:null,ur=ae?{getBoundingClientRect:ae,contextElement:ae.contextElement||Mt()}:n,ns={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Cs){var xi=Cs.state;if(gt()){var Oa=V(),gr=Oa.box;["placement","reference-hidden","escaped"].forEach(function(Is){Is==="placement"?gr.setAttribute("data-placement",xi.placement):xi.attributes.popper["data-popper-"+Is]?gr.setAttribute("data-"+Is,""):gr.removeAttribute("data-"+Is)}),xi.attributes.popper={}}}},fr=[{name:"offset",options:{offset:ve}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ni}},ns];gt()&&Ii&&fr.push({name:"arrow",options:{element:Ii,padding:3}}),fr.push.apply(fr,(Gt==null?void 0:Gt.modifiers)||[]),x.popperInstance=I1(ur,H,Object.assign({},Gt,{placement:Xt,onFirstUpdate:b,modifiers:fr}))}function Tr(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function ke(){var ct=x.props.appendTo,Gt,Xt=Mt();x.props.interactive&&ct===Du||ct==="parent"?Gt=Xt.parentNode:Gt=Pu(ct,[Xt]),Gt.contains(H)||Gt.appendChild(H),x.state.isMounted=!0,$i()}function li(){return bo(H.querySelectorAll("[data-tippy-root]"))}function me(ct){x.clearDelayTimeouts(),ct&&$("onTrigger",[x,ct]),Qt();var Gt=J(!0),Xt=Q(),ve=Xt[0],ae=Xt[1];Dr.isTouch&&ve==="hold"&&ae&&(Gt=ae),Gt?i=setTimeout(function(){x.show()},Gt):x.show()}function Je(ct){if(x.clearDelayTimeouts(),$("onUntrigger",[x,ct]),!x.state.isVisible){ue();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(ct.type)>=0&&c)){var Gt=J(!1);Gt?s=setTimeout(function(){x.state.isVisible&&x.hide()},Gt):o=requestAnimationFrame(function(){x.hide()})}}function ti(){x.state.isEnabled=!0}function Xi(){x.hide(),x.state.isEnabled=!1}function Ne(){clearTimeout(i),clearTimeout(s),cancelAnimationFrame(o)}function Ci(ct){if(!x.state.isDestroyed){$("onBeforeUpdate",[x,ct]),ge();var Gt=x.props,Xt=Hu(n,Object.assign({},Gt,$u(ct),{ignoreAttributes:!0}));x.props=Xt,jt(),Gt.interactiveDebounce!==Xt.interactiveDebounce&&(ft(),T=Ou(Ce,Xt.interactiveDebounce)),Gt.triggerTarget&&!Xt.triggerTarget?Sn(Gt.triggerTarget).forEach(function(ve){ve.removeAttribute("aria-expanded")}):Xt.triggerTarget&&n.removeAttribute("aria-expanded"),Z(),St(),j&&j(Gt,Xt),x.popperInstance&&($i(),li().forEach(function(ve){requestAnimationFrame(ve._tippy.popperInstance.forceUpdate)})),$("onAfterUpdate",[x,ct])}}function ss(ct){x.setProps({content:ct})}function ci(){var ct=x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=Dr.isTouch&&!x.props.touch,ae=tc(x.props.duration,0,yr.duration);if(!(ct||Gt||Xt||ve)&&!Mt().hasAttribute("disabled")&&($("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,gt()&&(H.style.visibility="visible"),St(),Qt(),x.state.isMounted||(H.style.transition="none"),gt()){var ni=V(),Ii=ni.box,ur=ni.content;ic([Ii,ur],0)}b=function(){var fr;if(!(!x.state.isVisible||p)){if(p=!0,H.offsetHeight,H.style.transition=x.props.moveTransition,gt()&&x.props.animation){var pr=V(),Cs=pr.box,xi=pr.content;ic([Cs,xi],ae),Nu([Cs,xi],"visible")}U(),Z(),Mu(ac,x),(fr=x.popperInstance)==null||fr.forceUpdate(),$("onMount",[x]),x.props.animation&&gt()&&Yt(ae,function(){x.state.isShown=!0,$("onShown",[x])})}},ke()}}function kr(){var ct=!x.state.isVisible,Gt=x.state.isDestroyed,Xt=!x.state.isEnabled,ve=tc(x.props.duration,1,yr.duration);if(!(ct||Gt||Xt)&&($("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,p=!1,c=!1,gt()&&(H.style.visibility="hidden"),ft(),ue(),St(!0),gt()){var ae=V(),ni=ae.box,Ii=ae.content;x.props.animation&&(ic([ni,Ii],ve),Nu([ni,Ii],"hidden"))}U(),Z(),x.props.animation?gt()&&se(ve,x.unmount):x.unmount()}}function _s(ct){Vt().addEventListener("mousemove",T),Mu(Eo,T),T(ct)}function Ls(){x.state.isVisible&&x.hide(),x.state.isMounted&&(Tr(),li().forEach(function(ct){ct._tippy.unmount()}),H.parentNode&&H.parentNode.removeChild(H),ac=ac.filter(function(ct){return ct!==x}),x.state.isMounted=!1,$("onHidden",[x]))}function ir(){x.state.isDestroyed||(x.clearDelayTimeouts(),x.unmount(),ge(),delete n._tippy,x.state.isDestroyed=!0,$("onDestroy",[x]))}}function nn(n,t){t===void 0&&(t={});var e=yr.plugins.concat(t.plugins||[]);W1();var i=Object.assign({},t,{plugins:e}),s=U1(n),o=s.reduce(function(c,d){var f=d&&tv(d,i);return f&&c.push(f),c},[]);return Ao(n)?o[0]:o}nn.defaultProps=yr,nn.setDefaultProps=Z1,nn.currentInput=Dr,Object.assign({},fu,{effect:function(t){var e=t.state,i={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(e.elements.popper.style,i.popper),e.styles=i,e.elements.arrow&&Object.assign(e.elements.arrow.style,i.arrow)}}),nn.setDefaultProps({render:ju});class Qr extends Error{constructor(t,e=!1){super(),this.fatal=!1,this.message=t,this.fatal=e}}const ev=5;class iv{constructor(t){this._caption="",this._currentTime=0,this._activeScenes=[],this._upcomingScenes=[],this._canvas=wi(),this._controls=wi(),this.host=t}set activeScenes(t){if(t!==this._activeScenes){const e=t[0],i=this._activeScenes[0];this._activeScenes=t,e!==i&&(this.host.dispatchEvent(new CustomEvent("scenechange",{detail:t[0]})),this.host.requestUpdate())}}get activeScenes(){return this._activeScenes}set currentTime(t){var e,i,s,o,c;const d=Math.min(this.host.duration,Math.max(0,t));this._currentTime=d,this.activeScenes=((e=this.host.scenes)==null?void 0:e.filter(({start:g,duration:v})=>d>=g&&d<=g+v))??[],this._upcomingScenes=((i=this.host.scenes)==null?void 0:i.filter(({start:g})=>d>=g-ev&&d<g))??[],this.loadScenes(),this.syncVideoState(),(s=this._controls.value)==null||s.setAttribute("currentTime",d.toString());const f=this.activeScenes[0],p=eu((o=f==null?void 0:f.videoMeta)==null?void 0:o.captions);this.caption=((c=p.find(({start:g,end:v})=>{var b;const E=d-f.start+(((b=f.videoMeta)==null?void 0:b.start)??0);return g&&v&&E>=fo(g)&&E<=fo(v)}))==null?void 0:c.text)??"",this.draw(d),!this.host.paused&&!this.host.loading&&!this.host.processing&&!this.host.waiting&&this.host.dispatchEvent(new CustomEvent("timeupdate",{detail:d}))}get currentTime(){return this._currentTime}set caption(t){t!==this._caption&&(this._caption=t,this.host.requestUpdate())}get caption(){return this._caption}canvas(){return Si(this._canvas)}controls(){return Si(this._controls)}loadScenes(){[...this.activeScenes,...this._upcomingScenes].forEach(t=>{var e,i,s;const{start:o,duration:c,video:d,videoMeta:f}=t,p=this.host.currentTime>0||this.host.preload==="auto"||!this.host.paused;if(d&&f){const{key:g,hls:v,node:b}=d,{start:E,duration:T}=f,w=this.host.videoState[g];b&&w&&(b.currentTime>=E+T||b.ended||p&&(v?(e=v.startLoadOnce)==null||e.call(v,b.currentTime):w.initialised||(i=b.startLoadOnce)==null||i.call(b)))}else if(p){const g=`${o}-${c}`,v=this.host._sceneController.videoState[g];this.host.duration&&!((s=v==null?void 0:v.buffered)!=null&&s.length)&&(this.host._sceneController.videoState={...this.host._sceneController.videoState,[g]:{...v,buffered:[{start:Math.max(0,o/this.host.duration*100),end:Math.min((o+c)/this.host.duration*100,100)}]}})}})}syncVideoState(){var t;(t=this.host.scenes)==null||t.forEach(e=>{if(e.video){const{key:i,node:s}=e.video,o=this.host.videoState[i],c=this.activeScenes.includes(e);if(s&&o)if(c&&!this.host.waiting&&!this.host.loading&&!this.host.paused){if(s.paused&&o.initialised)try{return s.play()}catch(d){throw new Qr(`Video play error: ${d.message}`,!0)}}else s.paused||s.pause()}})}draw(t=this.currentTime){var e,i;this.host.sceneConfig&&this._canvas.value&&((i=(e=this.host).compilation)==null||i.call(e,{currentTime:t,scenes:this.host.sceneConfig,canvas:this._canvas.value}))}clear(){var t;const e=this._canvas.value;(t=e==null?void 0:e.getContext("2d"))==null||t.clearRect(0,0,e.width,e.height)}}function rv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ku={exports:{}};(function(n,t){(function(e){var i=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,o=/(?:\/|^)\.(?=\/)/g,c=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,d={buildAbsoluteURL:function(f,p,g){if(g=g||{},f=f.trim(),p=p.trim(),!p){if(!g.alwaysNormalize)return f;var v=d.parseURL(f);if(!v)throw new Error("Error trying to parse base URL.");return v.path=d.normalizePath(v.path),d.buildURLFromParts(v)}var b=d.parseURL(p);if(!b)throw new Error("Error trying to parse relative URL.");if(b.scheme)return g.alwaysNormalize?(b.path=d.normalizePath(b.path),d.buildURLFromParts(b)):p;var E=d.parseURL(f);if(!E)throw new Error("Error trying to parse base URL.");if(!E.netLoc&&E.path&&E.path[0]!=="/"){var T=s.exec(E.path);E.netLoc=T[1],E.path=T[2]}E.netLoc&&!E.path&&(E.path="/");var w={scheme:E.scheme,netLoc:b.netLoc,path:null,params:b.params,query:b.query,fragment:b.fragment};if(!b.netLoc&&(w.netLoc=E.netLoc,b.path[0]!=="/"))if(!b.path)w.path=E.path,b.params||(w.params=E.params,b.query||(w.query=E.query));else{var C=E.path,D=C.substring(0,C.lastIndexOf("/")+1)+b.path;w.path=d.normalizePath(D)}return w.path===null&&(w.path=g.alwaysNormalize?d.normalizePath(b.path):b.path),d.buildURLFromParts(w)},parseURL:function(f){var p=i.exec(f);return p?{scheme:p[1]||"",netLoc:p[2]||"",path:p[3]||"",params:p[4]||"",query:p[5]||"",fragment:p[6]||""}:null},normalizePath:function(f){for(f=f.split("").reverse().join("").replace(o,"");f.length!==(f=f.replace(c,"")).length;);return f.split("").reverse().join("")},buildURLFromParts:function(f){return f.scheme+f.netLoc+f.path+f.params+f.query+f.fragment}};n.exports=d})()})(Ku);var oc=Ku.exports;function zu(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(n,s).enumerable})),e.push.apply(e,i)}return e}function Wi(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?zu(Object(e),!0).forEach(function(i){sv(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):zu(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function sv(n,t,e){return t=av(t),t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function ai(){return ai=Object.assign?Object.assign.bind():function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i])}return n},ai.apply(this,arguments)}function nv(n,t){if(typeof n!="object"||n===null)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function av(n){var t=nv(n,"string");return typeof t=="symbol"?t:String(t)}const Wt=Number.isFinite||function(n){return typeof n=="number"&&isFinite(n)};let R=function(n){return n.MEDIA_ATTACHING="hlsMediaAttaching",n.MEDIA_ATTACHED="hlsMediaAttached",n.MEDIA_DETACHING="hlsMediaDetaching",n.MEDIA_DETACHED="hlsMediaDetached",n.BUFFER_RESET="hlsBufferReset",n.BUFFER_CODECS="hlsBufferCodecs",n.BUFFER_CREATED="hlsBufferCreated",n.BUFFER_APPENDING="hlsBufferAppending",n.BUFFER_APPENDED="hlsBufferAppended",n.BUFFER_EOS="hlsBufferEos",n.BUFFER_FLUSHING="hlsBufferFlushing",n.BUFFER_FLUSHED="hlsBufferFlushed",n.MANIFEST_LOADING="hlsManifestLoading",n.MANIFEST_LOADED="hlsManifestLoaded",n.MANIFEST_PARSED="hlsManifestParsed",n.LEVEL_SWITCHING="hlsLevelSwitching",n.LEVEL_SWITCHED="hlsLevelSwitched",n.LEVEL_LOADING="hlsLevelLoading",n.LEVEL_LOADED="hlsLevelLoaded",n.LEVEL_UPDATED="hlsLevelUpdated",n.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",n.LEVELS_UPDATED="hlsLevelsUpdated",n.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",n.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",n.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",n.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",n.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",n.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",n.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",n.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",n.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",n.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",n.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",n.CUES_PARSED="hlsCuesParsed",n.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",n.INIT_PTS_FOUND="hlsInitPtsFound",n.FRAG_LOADING="hlsFragLoading",n.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",n.FRAG_LOADED="hlsFragLoaded",n.FRAG_DECRYPTED="hlsFragDecrypted",n.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",n.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",n.FRAG_PARSING_METADATA="hlsFragParsingMetadata",n.FRAG_PARSED="hlsFragParsed",n.FRAG_BUFFERED="hlsFragBuffered",n.FRAG_CHANGED="hlsFragChanged",n.FPS_DROP="hlsFpsDrop",n.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",n.ERROR="hlsError",n.DESTROYING="hlsDestroying",n.KEY_LOADING="hlsKeyLoading",n.KEY_LOADED="hlsKeyLoaded",n.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",n.BACK_BUFFER_REACHED="hlsBackBufferReached",n}({}),qt=function(n){return n.NETWORK_ERROR="networkError",n.MEDIA_ERROR="mediaError",n.KEY_SYSTEM_ERROR="keySystemError",n.MUX_ERROR="muxError",n.OTHER_ERROR="otherError",n}({}),ut=function(n){return n.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",n.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",n.KEY_SYSTEM_NO_SESSION="keySystemNoSession",n.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",n.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",n.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",n.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",n.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",n.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",n.MANIFEST_LOAD_ERROR="manifestLoadError",n.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",n.MANIFEST_PARSING_ERROR="manifestParsingError",n.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",n.LEVEL_EMPTY_ERROR="levelEmptyError",n.LEVEL_LOAD_ERROR="levelLoadError",n.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",n.LEVEL_PARSING_ERROR="levelParsingError",n.LEVEL_SWITCH_ERROR="levelSwitchError",n.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",n.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",n.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",n.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",n.FRAG_LOAD_ERROR="fragLoadError",n.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",n.FRAG_DECRYPT_ERROR="fragDecryptError",n.FRAG_PARSING_ERROR="fragParsingError",n.FRAG_GAP="fragGap",n.REMUX_ALLOC_ERROR="remuxAllocError",n.KEY_LOAD_ERROR="keyLoadError",n.KEY_LOAD_TIMEOUT="keyLoadTimeOut",n.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",n.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",n.BUFFER_APPEND_ERROR="bufferAppendError",n.BUFFER_APPENDING_ERROR="bufferAppendingError",n.BUFFER_STALLED_ERROR="bufferStalledError",n.BUFFER_FULL_ERROR="bufferFullError",n.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",n.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",n.INTERNAL_EXCEPTION="internalException",n.INTERNAL_ABORTED="aborted",n.UNKNOWN="unknown",n}({});const an=function(){},lc={trace:an,debug:an,log:an,warn:an,info:an,error:an};let ka=lc;function ov(n){const t=self.console[n];return t?t.bind(self.console,`[${n}] >`):an}function lv(n,...t){t.forEach(function(e){ka[e]=n[e]?n[e].bind(n):ov(e)})}function cv(n,t){if(self.console&&n===!0||typeof n=="object"){lv(n,"debug","log","info","warn","error");try{ka.log(`Debug logs enabled for "${t}" in hls.js version 1.4.12`)}catch{ka=lc}}else ka=lc}const Y=ka,hv=/^(\d+)x(\d+)$/,Yu=/(.+?)=(".*?"|.*?)(?:,|$)/g;class ze{constructor(t){typeof t=="string"&&(t=ze.parseAttrList(t));for(const e in t)t.hasOwnProperty(e)&&(e.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(e)),this[e]=t[e])}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(e.length&1?"0":"")+e;const i=new Uint8Array(e.length/2);for(let s=0;s<e.length/2;s++)i[s]=parseInt(e.slice(s*2,s*2+2),16);return i}else return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const i=this[t];return i?parseFloat(i):e}enumeratedString(t){return this[t]}bool(t){return this[t]==="YES"}decimalResolution(t){const e=hv.exec(this[t]);if(e!==null)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t){let e;const i={},s='"';for(Yu.lastIndex=0;(e=Yu.exec(t))!==null;){let o=e[2];o.indexOf(s)===0&&o.lastIndexOf(s)===o.length-1&&(o=o.slice(1,-1));const c=e[1].trim();i[c]=o}return i}}function dv(n){return n!=="ID"&&n!=="CLASS"&&n!=="START-DATE"&&n!=="DURATION"&&n!=="END-DATE"&&n!=="END-ON-NEXT"}function uv(n){return n==="SCTE35-OUT"||n==="SCTE35-IN"}class Xu{constructor(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){const i=e.attr;for(const s in i)if(Object.prototype.hasOwnProperty.call(t,s)&&t[s]!==i[s]){Y.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=s;break}t=ai(new ze({}),i,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const i=new Date(this.attr["END-DATE"]);Wt(i.getTime())&&(this._endDate=i)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const t=this.duration;return t!==null?new Date(this._startDate.getTime()+t*1e3):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(Wt(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&Wt(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class To{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 Le={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Zu{constructor(t){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Le.AUDIO]:null,[Le.VIDEO]:null,[Le.AUDIOVIDEO]:null},this.baseurl=t}setByteRange(t,e){const i=t.split("@",2),s=[];i.length===1?s[0]=e?e.byteRangeEndOffset:0:s[0]=parseInt(i[1]),s[1]=parseInt(i[0])+s[0],this._byteRange=s}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=oc.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}}class cc extends Zu{constructor(t,e){super(e),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new To,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=t}get decryptdata(){const{levelkeys:t}=this;if(!t&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const i=Object.keys(this.levelkeys);if(i.length===1)return this._decryptdata=this.levelkeys[i[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Wt(this.programDateTime))return null;const t=Wt(this.duration)?this.duration:0;return this.programDateTime+t*1e3}get encrypted(){var t;if((t=this._decryptdata)!=null&&t.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),i=e.length;if(i>1||i===1&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(t){if(this.levelkeys){const e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}}abortRequests(){var t,e;(t=this.loader)==null||t.abort(),(e=this.keyLoader)==null||e.abort()}setElementaryStreamInfo(t,e,i,s,o,c=!1){const{elementaryStreams:d}=this,f=d[t];if(!f){d[t]={startPTS:e,endPTS:i,startDTS:s,endDTS:o,partial:c};return}f.startPTS=Math.min(f.startPTS,e),f.endPTS=Math.max(f.endPTS,i),f.startDTS=Math.min(f.startDTS,s),f.endDTS=Math.max(f.endDTS,o)}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[Le.AUDIO]=null,t[Le.VIDEO]=null,t[Le.AUDIOVIDEO]=null}}class fv extends Zu{constructor(t,e,i,s,o){super(i),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new To,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=s;const c=t.enumeratedString("BYTERANGE");c&&this.setByteRange(c,o),o&&(this.fragOffset=o.fragOffset+o.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}const pv=10;class gv{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t){this.advanced=!0,this.updated=!0;return}const e=this.lastPartSn-t.lastPartSn,i=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!i||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||e===0&&i>0,this.updated||this.advanced?this.misses=Math.floor(t.misses*.6):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Wt(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||pv}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?(this.driftEnd-this.driftStart)*1e3/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var t;return(t=this.fragments)!=null&&t.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var t;return(t=this.partList)!=null&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function hc(n){return Uint8Array.from(atob(n),t=>t.charCodeAt(0))}function mv(n){const t=qu(n).subarray(0,16),e=new Uint8Array(16);return e.set(t,16-t.length),e}function vv(n){const t=function(e,i,s){const o=e[i];e[i]=e[s],e[s]=o};t(n,0,3),t(n,1,2),t(n,4,5),t(n,6,7)}function yv(n){const t=n.split(":");let e=null;if(t[0]==="data"&&t.length===2){const i=t[1].split(";"),s=i[i.length-1].split(",");if(s.length===2){const o=s[0]==="base64",c=s[1];o?(i.splice(-1,1),e=hc(c)):e=mv(c)}}return e}function qu(n){return Uint8Array.from(unescape(encodeURIComponent(n)),t=>t.charCodeAt(0))}var Ye={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ji={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Qu(n){switch(n){case ji.FAIRPLAY:return Ye.FAIRPLAY;case ji.PLAYREADY:return Ye.PLAYREADY;case ji.WIDEVINE:return Ye.WIDEVINE;case ji.CLEARKEY:return Ye.CLEARKEY}}var Ju={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function bv(n){if(n===Ju.WIDEVINE)return Ye.WIDEVINE}function t0(n){switch(n){case Ye.FAIRPLAY:return ji.FAIRPLAY;case Ye.PLAYREADY:return ji.PLAYREADY;case Ye.WIDEVINE:return ji.WIDEVINE;case Ye.CLEARKEY:return ji.CLEARKEY}}function dc(n){const{drmSystems:t,widevineLicenseUrl:e}=n,i=t?[Ye.FAIRPLAY,Ye.WIDEVINE,Ye.PLAYREADY,Ye.CLEARKEY].filter(s=>!!t[s]):[];return!i[Ye.WIDEVINE]&&e&&i.push(Ye.WIDEVINE),i}const e0=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function Av(n,t,e,i){let s;switch(n){case Ye.FAIRPLAY:s=["cenc","sinf"];break;case Ye.WIDEVINE:case Ye.PLAYREADY:s=["cenc"];break;case Ye.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${n}`)}return Ev(s,t,e,i)}function Ev(n,t,e,i){return[{initDataTypes:n,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(s=>({contentType:`audio/mp4; codecs="${s}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:e.map(s=>({contentType:`video/mp4; codecs="${s}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}function on(n,t,e){return Uint8Array.prototype.slice?n.slice(t,e):new Uint8Array(Array.prototype.slice.call(n,t,e))}const uc=(n,t)=>t+10<=n.length&&n[t]===73&&n[t+1]===68&&n[t+2]===51&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,i0=(n,t)=>t+10<=n.length&&n[t]===51&&n[t+1]===68&&n[t+2]===73&&n[t+3]<255&&n[t+4]<255&&n[t+6]<128&&n[t+7]<128&&n[t+8]<128&&n[t+9]<128,ko=(n,t)=>{const e=t;let i=0;for(;uc(n,t);){i+=10;const s=wo(n,t+6);i+=s,i0(n,t+10)&&(i+=10),t+=i}if(i>0)return n.subarray(e,e+i)},wo=(n,t)=>{let e=0;return e=(n[t]&127)<<21,e|=(n[t+1]&127)<<14,e|=(n[t+2]&127)<<7,e|=n[t+3]&127,e},Tv=(n,t)=>uc(n,t)&&wo(n,t+6)+10<=n.length-t,kv=n=>{const t=s0(n);for(let e=0;e<t.length;e++){const i=t[e];if(r0(i))return Cv(i)}},r0=n=>n&&n.key==="PRIV"&&n.info==="com.apple.streaming.transportStreamTimestamp",wv=n=>{const t=String.fromCharCode(n[0],n[1],n[2],n[3]),e=wo(n,4),i=10;return{type:t,size:e,data:n.subarray(i,i+e)}},s0=n=>{let t=0;const e=[];for(;uc(n,t);){const i=wo(n,t+6);t+=10;const s=t+i;for(;t+8<s;){const o=wv(n.subarray(t)),c=Sv(o);c&&e.push(c),t+=o.size+10}i0(n,t)&&(t+=10)}return e},Sv=n=>n.type==="PRIV"?Rv(n):n.type[0]==="W"?Lv(n):_v(n),Rv=n=>{if(n.size<2)return;const t=Pr(n.data,!0),e=new Uint8Array(n.data.subarray(t.length+1));return{key:n.type,info:t,data:e.buffer}},_v=n=>{if(n.size<2)return;if(n.type==="TXXX"){let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data.subarray(1));return{key:n.type,data:t}},Lv=n=>{if(n.type==="WXXX"){if(n.size<2)return;let e=1;const i=Pr(n.data.subarray(e),!0);e+=i.length+1;const s=Pr(n.data.subarray(e));return{key:n.type,info:i,data:s}}const t=Pr(n.data);return{key:n.type,data:t}},Cv=n=>{if(n.data.byteLength===8){const t=new Uint8Array(n.data),e=t[3]&1;let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,e&&(i+=4772185884e-2),Math.round(i)}},Pr=(n,t=!1)=>{const e=Iv();if(e){const p=e.decode(n);if(t){const g=p.indexOf("\0");return g!==-1?p.substring(0,g):p}return p.replace(/\0/g,"")}const i=n.length;let s,o,c,d="",f=0;for(;f<i;){if(s=n[f++],s===0&&t)return d;if(!(s===0||s===3))switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:d+=String.fromCharCode(s);break;case 12:case 13:o=n[f++],d+=String.fromCharCode((s&31)<<6|o&63);break;case 14:o=n[f++],c=n[f++],d+=String.fromCharCode((s&15)<<12|(o&63)<<6|(c&63)<<0);break}}return d};let fc;function Iv(){return!fc&&typeof self.TextDecoder<"u"&&(fc=new self.TextDecoder("utf-8")),fc}const Or={hexDump:function(n){let t="";for(let e=0;e<n.length;e++){let i=n[e].toString(16);i.length<2&&(i="0"+i),t+=i}return t}},So=Math.pow(2,32)-1,xv=[].push,n0={video:1,audio:2,id3:3,text:4};function Ai(n){return String.fromCharCode.apply(null,n)}function a0(n,t){const e=n[t]<<8|n[t+1];return e<0?65536+e:e}function ie(n,t){const e=o0(n,t);return e<0?4294967296+e:e}function o0(n,t){return n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function pc(n,t,e){n[t]=e>>24,n[t+1]=e>>16&255,n[t+2]=e>>8&255,n[t+3]=e&255}function ye(n,t){const e=[];if(!t.length)return e;const i=n.byteLength;for(let s=0;s<i;){const o=ie(n,s),c=Ai(n.subarray(s+4,s+8)),d=o>1?s+o:i;if(c===t[0])if(t.length===1)e.push(n.subarray(s+8,d));else{const f=ye(n.subarray(s+8,d),t.slice(1));f.length&&xv.apply(e,f)}s=d}return e}function Dv(n){const t=[],e=n[0];let i=8;const s=ie(n,i);i+=4;const o=0,c=0;e===0?i+=8:i+=16,i+=2;let d=n.length+c;const f=a0(n,i);i+=2;for(let p=0;p<f;p++){let g=i;const v=ie(n,g);g+=4;const b=v&2147483647;if((v&2147483648)>>>31===1)return Y.warn("SIDX has hierarchical references (not supported)"),null;const E=ie(n,g);g+=4,t.push({referenceSize:b,subsegmentDuration:E,info:{duration:E/s,start:d,end:d+b-1}}),d+=b,g+=4,i=g}return{earliestPresentationTime:o,timescale:s,version:e,referencesCount:f,references:t}}function l0(n){const t=[],e=ye(n,["moov","trak"]);for(let i=0;i<e.length;i++){const s=e[i],o=ye(s,["tkhd"])[0];if(o){let c=o[0],d=c===0?12:20;const f=ie(o,d),p=ye(s,["mdia","mdhd"])[0];if(p){c=p[0],d=c===0?12:20;const g=ie(p,d),v=ye(s,["mdia","hdlr"])[0];if(v){const b=Ai(v.subarray(8,12)),E={soun:Le.AUDIO,vide:Le.VIDEO}[b];if(E){const T=ye(s,["mdia","minf","stbl","stsd"])[0];let w;T&&(w=Ai(T.subarray(12,16))),t[f]={timescale:g,type:E},t[E]={timescale:g,id:f,codec:w}}}}}}return ye(n,["moov","mvex","trex"]).forEach(i=>{const s=ie(i,4),o=t[s];o&&(o.default={duration:ie(i,12),flags:ie(i,20)})}),t}function Pv(n,t){if(!n||!t)return n;const e=t.keyId;return e&&t.isCommonEncryption&&ye(n,["moov","trak"]).forEach(i=>{const s=ye(i,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=ye(s,["enca"]);const c=o.length>0;c||(o=ye(s,["encv"])),o.forEach(d=>{const f=c?d.subarray(28):d.subarray(78);ye(f,["sinf"]).forEach(p=>{const g=c0(p);if(g){const v=g.subarray(8,24);v.some(b=>b!==0)||(Y.log(`[eme] Patching keyId in 'enc${c?"a":"v"}>sinf>>tenc' box: ${Or.hexDump(v)} -> ${Or.hexDump(e)}`),g.set(e,8))}})})}),n}function c0(n){const t=ye(n,["schm"])[0];if(t){const e=Ai(t.subarray(4,8));if(e==="cbcs"||e==="cenc")return ye(n,["schi","tenc"])[0]}return Y.error("[eme] missing 'schm' box"),null}function Ov(n,t){return ye(t,["moof","traf"]).reduce((e,i)=>{const s=ye(i,["tfdt"])[0],o=s[0],c=ye(i,["tfhd"]).reduce((d,f)=>{const p=ie(f,4),g=n[p];if(g){let v=ie(s,4);if(o===1){if(v===So)return Y.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),d;v*=So+1,v+=ie(s,8)}const b=g.timescale||9e4,E=v/b;if(isFinite(E)&&(d===null||E<d))return E}return d},null);return c!==null&&isFinite(c)&&(e===null||c<e)?c:e},null)}function Mv(n,t){let e=0,i=0,s=0;const o=ye(n,["moof","traf"]);for(let c=0;c<o.length;c++){const d=o[c],f=ye(d,["tfhd"])[0],p=ie(f,4),g=t[p];if(!g)continue;const v=g.default,b=ie(f,0)|(v==null?void 0:v.flags);let E=v==null?void 0:v.duration;b&8&&(b&2?E=ie(f,12):E=ie(f,8));const T=g.timescale||9e4,w=ye(d,["trun"]);for(let C=0;C<w.length;C++){if(e=$v(w[C]),!e&&E){const D=ie(w[C],4);e=E*D}g.type===Le.VIDEO?i+=e/T:g.type===Le.AUDIO&&(s+=e/T)}}if(i===0&&s===0){let c=0;const d=ye(n,["sidx"]);for(let f=0;f<d.length;f++){const p=Dv(d[f]);p!=null&&p.references&&(c+=p.references.reduce((g,v)=>g+v.info.duration||0,0))}return c}return i||s}function $v(n){const t=ie(n,0);let e=8;t&1&&(e+=4),t&4&&(e+=4);let i=0;const s=ie(n,4);for(let o=0;o<s;o++){if(t&256){const c=ie(n,e);i+=c,e+=4}t&512&&(e+=4),t&1024&&(e+=4),t&2048&&(e+=4)}return i}function Nv(n,t,e){ye(t,["moof","traf"]).forEach(i=>{ye(i,["tfhd"]).forEach(s=>{const o=ie(s,4),c=n[o];if(!c)return;const d=c.timescale||9e4;ye(i,["tfdt"]).forEach(f=>{const p=f[0];let g=ie(f,4);if(p===0)g-=e*d,g=Math.max(g,0),pc(f,4,g);else{g*=Math.pow(2,32),g+=ie(f,8),g-=e*d,g=Math.max(g,0);const v=Math.floor(g/(So+1)),b=Math.floor(g%(So+1));pc(f,4,v),pc(f,8,b)}})})})}function Fv(n){const t={valid:null,remainder:null},e=ye(n,["moof"]);if(e){if(e.length<2)return t.remainder=n,t}else return t;const i=e[e.length-1];return t.valid=on(n,0,i.byteOffset-8),t.remainder=on(n,i.byteOffset-8),t}function ln(n,t){const e=new Uint8Array(n.length+t.length);return e.set(n),e.set(t,n.length),e}function h0(n,t){const e=[],i=t.samples,s=t.timescale,o=t.id;let c=!1;return ye(i,["moof"]).map(d=>{const f=d.byteOffset-8;ye(d,["traf"]).map(p=>{const g=ye(p,["tfdt"]).map(v=>{const b=v[0];let E=ie(v,4);return b===1&&(E*=Math.pow(2,32),E+=ie(v,8)),E/s})[0];return g!==void 0&&(n=g),ye(p,["tfhd"]).map(v=>{const b=ie(v,4),E=ie(v,0)&16777215,T=(E&1)!==0,w=(E&2)!==0,C=(E&8)!==0;let D=0;const O=(E&16)!==0;let F=0;const x=(E&32)!==0;let N=8;b===o&&(T&&(N+=8),w&&(N+=4),C&&(D=ie(v,N),N+=4),O&&(F=ie(v,N),N+=4),x&&(N+=4),t.type==="video"&&(c=Uv(t.codec)),ye(p,["trun"]).map(H=>{const j=H[0],nt=ie(H,0)&16777215,st=(nt&1)!==0;let Q=0;const kt=(nt&4)!==0,gt=(nt&256)!==0;let Mt=0;const Vt=(nt&512)!==0;let V=0;const J=(nt&1024)!==0,St=(nt&2048)!==0;let $=0;const U=ie(H,4);let Z=8;st&&(Q=ie(H,Z),Z+=4),kt&&(Z+=4);let ft=Q+f;for(let bt=0;bt<U;bt++){if(gt?(Mt=ie(H,Z),Z+=4):Mt=D,Vt?(V=ie(H,Z),Z+=4):V=F,J&&(Z+=4),St&&(j===0?$=ie(H,Z):$=o0(H,Z),Z+=4),t.type===Le.VIDEO){let xt=0;for(;xt<V;){const Ut=ie(i,ft);if(ft+=4,Bv(c,i[ft])){const Qt=i.subarray(ft,ft+Ut);d0(Qt,c?2:1,n+$/s,e)}ft+=Ut,xt+=Ut+4}}n+=Mt/s}}))})})}),e}function Uv(n){if(!n)return!1;const t=n.indexOf("."),e=t<0?n:n.substring(0,t);return e==="hvc1"||e==="hev1"||e==="dvh1"||e==="dvhe"}function Bv(n,t){if(n){const e=t>>1&63;return e===39||e===40}else return(t&31)===6}function d0(n,t,e,i){const s=u0(n);let o=0;o+=t;let c=0,d=0,f=!1,p=0;for(;o<s.length;){c=0;do{if(o>=s.length)break;p=s[o++],c+=p}while(p===255);d=0;do{if(o>=s.length)break;p=s[o++],d+=p}while(p===255);const g=s.length-o;if(!f&&c===4&&o<s.length){if(f=!0,s[o++]===181){const v=a0(s,o);if(o+=2,v===49){const b=ie(s,o);if(o+=4,b===1195456820){const E=s[o++];if(E===3){const T=s[o++],w=31&T,C=64&T,D=C?2+w*3:0,O=new Uint8Array(D);if(C){O[0]=T;for(let F=1;F<D;F++)O[F]=s[o++]}i.push({type:E,payloadType:c,pts:e,bytes:O})}}}}}else if(c===5&&d<g){if(f=!0,d>16){const v=[];for(let T=0;T<16;T++){const w=s[o++].toString(16);v.push(w.length==1?"0"+w:w),(T===3||T===5||T===7||T===9)&&v.push("-")}const b=d-16,E=new Uint8Array(b);for(let T=0;T<b;T++)E[T]=s[o++];i.push({payloadType:c,pts:e,uuid:v.join(""),userData:Pr(E),userDataBytes:E})}}else if(d<g)o+=d;else if(d>g)break}}function u0(n){const t=n.byteLength,e=[];let i=1;for(;i<t-2;)n[i]===0&&n[i+1]===0&&n[i+2]===3?(e.push(i+2),i+=2):i++;if(e.length===0)return n;const s=t-e.length,o=new Uint8Array(s);let c=0;for(i=0;i<s;c++,i++)c===e[0]&&(c++,e.shift()),o[i]=n[c];return o}function Gv(n){const t=n[0];let e="",i="",s=0,o=0,c=0,d=0,f=0,p=0;if(t===0){for(;Ai(n.subarray(p,p+1))!=="\0";)e+=Ai(n.subarray(p,p+1)),p+=1;for(e+=Ai(n.subarray(p,p+1)),p+=1;Ai(n.subarray(p,p+1))!=="\0";)i+=Ai(n.subarray(p,p+1)),p+=1;i+=Ai(n.subarray(p,p+1)),p+=1,s=ie(n,12),o=ie(n,16),d=ie(n,20),f=ie(n,24),p=28}else if(t===1){p+=4,s=ie(n,p),p+=4;const v=ie(n,p);p+=4;const b=ie(n,p);for(p+=4,c=4294967296*v+b,Number.isSafeInteger(c)||(c=Number.MAX_SAFE_INTEGER,Y.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),d=ie(n,p),p+=4,f=ie(n,p),p+=4;Ai(n.subarray(p,p+1))!=="\0";)e+=Ai(n.subarray(p,p+1)),p+=1;for(e+=Ai(n.subarray(p,p+1)),p+=1;Ai(n.subarray(p,p+1))!=="\0";)i+=Ai(n.subarray(p,p+1)),p+=1;i+=Ai(n.subarray(p,p+1)),p+=1}const g=n.subarray(p,n.byteLength);return{schemeIdUri:e,value:i,timeScale:s,presentationTime:c,presentationTimeDelta:o,eventDuration:d,id:f,payload:g}}function Hv(n,...t){const e=t.length;let i=8,s=e;for(;s--;)i+=t[s].byteLength;const o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=i&255,o.set(n,4),s=0,i=8;s<e;s++)o.set(t[s],i),i+=t[s].byteLength;return o}function Vv(n,t,e){if(n.byteLength!==16)throw new RangeError("Invalid system id");let i,s;if(t){i=1,s=new Uint8Array(t.length*16);for(let d=0;d<t.length;d++){const f=t[d];if(f.byteLength!==16)throw new RangeError("Invalid key");s.set(f,d*16)}}else i=0,s=new Uint8Array;let o;i>0?(o=new Uint8Array(4),t.length>0&&new DataView(o.buffer).setUint32(0,t.length,!1)):o=new Uint8Array;const c=new Uint8Array(4);return e&&e.byteLength>0&&new DataView(c.buffer).setUint32(0,e.byteLength,!1),Hv([112,115,115,104],new Uint8Array([i,0,0,0]),n,o,s,c,e||new Uint8Array)}function Wv(n){if(!(n instanceof ArrayBuffer)||n.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},e=new DataView(n),i=e.getUint32(0);if(n.byteLength!==i&&i>44||e.getUint32(4)!==1886614376||(t.version=e.getUint32(8)>>>24,t.version>1))return null;t.systemId=Or.hexDump(new Uint8Array(n,12,16));const s=e.getUint32(28);if(t.version===0){if(i-32<s)return null;t.data=new Uint8Array(n,32,s)}else if(t.version===1){t.kids=[];for(let o=0;o<s;o++)t.kids.push(new Uint8Array(n,32+o*16,16))}return t}let Ro={};class wa{static clearKeyUriToKeyIdMap(){Ro={}}constructor(t,e,i,s=[1],o=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=i,this.keyFormatVersions=s,this.iv=o,this.encrypted=t?t!=="NONE":!1,this.isCommonEncryption=this.encrypted&&t!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case ji.FAIRPLAY:case ji.WIDEVINE:case ji.PLAYREADY:case ji.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(t){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof t!="number"&&(this.method==="AES-128"&&!this.iv&&Y.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0);const i=jv(t);return new wa(this.method,this.uri,"identity",this.keyFormatVersions,i)}const e=yv(this.uri);if(e)switch(this.keyFormat){case ji.WIDEVINE:this.pssh=e,e.length>=22&&(this.keyId=e.subarray(e.length-22,e.length-6));break;case ji.PLAYREADY:{const i=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Vv(i,null,e);const s=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),o=String.fromCharCode.apply(null,Array.from(s)),c=o.substring(o.indexOf("<"),o.length),d=new DOMParser().parseFromString(c,"text/xml").getElementsByTagName("KID")[0];if(d){const f=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(f){const p=hc(f).subarray(0,16);vv(p),this.keyId=p}}break}default:{let i=e.subarray(0,16);if(i.length!==16){const s=new Uint8Array(16);s.set(i,16-i.length),i=s}this.keyId=i;break}}if(!this.keyId||this.keyId.byteLength!==16){let i=Ro[this.uri];if(!i){const s=Object.keys(Ro).length%Number.MAX_SAFE_INTEGER;i=new Uint8Array(16),new DataView(i.buffer,12,4).setUint32(0,s),Ro[this.uri]=i}this.keyId=i}return this}}function jv(n){const t=new Uint8Array(16);for(let e=12;e<16;e++)t[e]=n>>8*(15-e)&255;return t}const f0=/\{\$([a-zA-Z0-9-_]+)\}/g;function p0(n){return f0.test(n)}function Ki(n,t,e){if(n.variableList!==null||n.hasVariableRefs)for(let i=e.length;i--;){const s=e[i],o=t[s];o&&(t[s]=gc(n,o))}}function gc(n,t){if(n.variableList!==null||n.hasVariableRefs){const e=n.variableList;return t.replace(f0,i=>{const s=i.substring(2,i.length-1),o=e==null?void 0:e[s];return o===void 0?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),i):o})}return t}function g0(n,t,e){let i=n.variableList;i||(n.variableList=i={});let s,o;if("QUERYPARAM"in t){s=t.QUERYPARAM;try{const c=new self.URL(e).searchParams;if(c.has(s))o=c.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${e}"`)}catch(c){n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${c.message}`))}}else s=t.NAME,o=t.VALUE;s in i?n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):i[s]=o||""}function Kv(n,t,e){const i=t.IMPORT;if(e&&i in e){let s=n.variableList;s||(n.variableList=s={}),s[i]=e[i]}else n.playlistParsingError||(n.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function _o(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const zv={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}},m0=_o();function Yv(n,t){const e=zv[t];return!!e&&e[n.slice(0,4)]===!0}function mc(n,t){var e;return(e=m0==null?void 0:m0.isTypeSupported(`${t||"video"}/mp4;codecs="${n}"`))!=null?e:!1}const v0=/#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,y0=/#EXT-X-MEDIA:(.*)/g,Xv=/^#EXT(?:INF|-X-TARGETDURATION):/m,b0=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Zv=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class br{static findGroup(t,e){for(let i=0;i<t.length;i++){const s=t[i];if(s.id===e)return s}}static convertAVC1ToAVCOTI(t){const e=t.split(".");if(e.length>2){let i=e.shift()+".";return i+=parseInt(e.shift()).toString(16),i+=("000"+parseInt(e.shift()).toString(16)).slice(-4),i}return t}static resolve(t,e){return oc.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return Xv.test(t)}static parseMasterPlaylist(t,e){const i=p0(t),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:i},o=[];v0.lastIndex=0;let c;for(;(c=v0.exec(t))!=null;)if(c[1]){var d;const p=new ze(c[1]);Ki(s,p,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const g=gc(s,c[2]),v={attrs:p,bitrate:p.decimalInteger("AVERAGE-BANDWIDTH")||p.decimalInteger("BANDWIDTH"),name:p.NAME,url:br.resolve(g,e)},b=p.decimalResolution("RESOLUTION");b&&(v.width=b.width,v.height=b.height),qv((p.CODECS||"").split(/[ ,]+/).filter(E=>E),v),v.videoCodec&&v.videoCodec.indexOf("avc1")!==-1&&(v.videoCodec=br.convertAVC1ToAVCOTI(v.videoCodec)),(d=v.unknownCodecs)!=null&&d.length||o.push(v),s.levels.push(v)}else if(c[3]){const p=c[3],g=c[4];switch(p){case"SESSION-DATA":{const v=new ze(g);Ki(s,v,["DATA-ID","LANGUAGE","VALUE","URI"]);const b=v["DATA-ID"];b&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[b]=v);break}case"SESSION-KEY":{const v=A0(g,e,s);v.encrypted&&v.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(v)):Y.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${g}"`);break}case"DEFINE":{{const v=new ze(g);Ki(s,v,["NAME","VALUE","QUERYPARAM"]),g0(s,v,e)}break}case"CONTENT-STEERING":{const v=new ze(g);Ki(s,v,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:br.resolve(v["SERVER-URI"],e),pathwayId:v["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=E0(g);break}}}const f=o.length>0&&o.length<s.levels.length;return s.levels=f?o:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,i){let s;const o={},c=i.levels,d={AUDIO:c.map(p=>({id:p.attrs.AUDIO,audioCodec:p.audioCodec})),SUBTITLES:c.map(p=>({id:p.attrs.SUBTITLES,textCodec:p.textCodec})),"CLOSED-CAPTIONS":[]};let f=0;for(y0.lastIndex=0;(s=y0.exec(t))!==null;){const p=new ze(s[1]),g=p.TYPE;if(g){const v=d[g],b=o[g]||[];o[g]=b,Ki(i,p,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const E={attrs:p,bitrate:0,id:f++,groupId:p["GROUP-ID"]||"",instreamId:p["INSTREAM-ID"],name:p.NAME||p.LANGUAGE||"",type:g,default:p.bool("DEFAULT"),autoselect:p.bool("AUTOSELECT"),forced:p.bool("FORCED"),lang:p.LANGUAGE,url:p.URI?br.resolve(p.URI,e):""};if(v!=null&&v.length){const T=br.findGroup(v,E.groupId)||v[0];T0(E,T,"audioCodec"),T0(E,T,"textCodec")}b.push(E)}}return o}static parseLevelPlaylist(t,e,i,s,o,c){const d=new gv(e),f=d.fragments;let p=null,g=0,v=0,b=0,E=0,T=null,w=new cc(s,e),C,D,O,F=-1,x=!1;for(b0.lastIndex=0,d.m3u8=t,d.hasVariableRefs=p0(t);(C=b0.exec(t))!==null;){x&&(x=!1,w=new cc(s,e),w.start=b,w.sn=g,w.cc=E,w.level=i,p&&(w.initSegment=p,w.rawProgramDateTime=p.rawProgramDateTime,p.rawProgramDateTime=null));const nt=C[1];if(nt){w.duration=parseFloat(nt);const st=(" "+C[2]).slice(1);w.title=st||null,w.tagList.push(st?["INF",nt,st]:["INF",nt])}else if(C[3]){if(Wt(w.duration)){w.start=b,O&&S0(w,O,d),w.sn=g,w.level=i,w.cc=E,w.urlId=o,f.push(w);const st=(" "+C[3]).slice(1);w.relurl=gc(d,st),k0(w,T),T=w,b+=w.duration,g++,v=0,x=!0}}else if(C[4]){const st=(" "+C[4]).slice(1);T?w.setByteRange(st,T):w.setByteRange(st)}else if(C[5])w.rawProgramDateTime=(" "+C[5]).slice(1),w.tagList.push(["PROGRAM-DATE-TIME",w.rawProgramDateTime]),F===-1&&(F=f.length);else{if(C=C[0].match(Zv),!C){Y.warn("No matches on slow regex match for level playlist!");continue}for(D=1;D<C.length&&!(typeof C[D]<"u");D++);const st=(" "+C[D]).slice(1),Q=(" "+C[D+1]).slice(1),kt=C[D+2]?(" "+C[D+2]).slice(1):"";switch(st){case"PLAYLIST-TYPE":d.type=Q.toUpperCase();break;case"MEDIA-SEQUENCE":g=d.startSN=parseInt(Q);break;case"SKIP":{const gt=new ze(Q);Ki(d,gt,["RECENTLY-REMOVED-DATERANGES"]);const Mt=gt.decimalInteger("SKIPPED-SEGMENTS");if(Wt(Mt)){d.skippedSegments=Mt;for(let V=Mt;V--;)f.unshift(null);g+=Mt}const Vt=gt.enumeratedString("RECENTLY-REMOVED-DATERANGES");Vt&&(d.recentlyRemovedDateranges=Vt.split(" "));break}case"TARGETDURATION":d.targetduration=Math.max(parseInt(Q),1);break;case"VERSION":d.version=parseInt(Q);break;case"EXTM3U":break;case"ENDLIST":d.live=!1;break;case"#":(Q||kt)&&w.tagList.push(kt?[Q,kt]:[Q]);break;case"DISCONTINUITY":E++,w.tagList.push(["DIS"]);break;case"GAP":w.gap=!0,w.tagList.push([st]);break;case"BITRATE":w.tagList.push([st,Q]);break;case"DATERANGE":{const gt=new ze(Q);Ki(d,gt,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Ki(d,gt,gt.clientAttrs);const Mt=new Xu(gt,d.dateRanges[gt.ID]);Mt.isValid||d.skippedSegments?d.dateRanges[Mt.id]=Mt:Y.warn(`Ignoring invalid DATERANGE tag: "${Q}"`),w.tagList.push(["EXT-X-DATERANGE",Q]);break}case"DEFINE":{{const gt=new ze(Q);Ki(d,gt,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in gt?Kv(d,gt,c):g0(d,gt,e)}break}case"DISCONTINUITY-SEQUENCE":E=parseInt(Q);break;case"KEY":{const gt=A0(Q,e,d);if(gt.isSupported()){if(gt.method==="NONE"){O=void 0;break}O||(O={}),O[gt.keyFormat]&&(O=ai({},O)),O[gt.keyFormat]=gt}else Y.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${Q}"`);break}case"START":d.startTimeOffset=E0(Q);break;case"MAP":{const gt=new ze(Q);if(Ki(d,gt,["BYTERANGE","URI"]),w.duration){const Mt=new cc(s,e);w0(Mt,gt,i,O),p=Mt,w.initSegment=p,p.rawProgramDateTime&&!w.rawProgramDateTime&&(w.rawProgramDateTime=p.rawProgramDateTime)}else w0(w,gt,i,O),p=w,x=!0;break}case"SERVER-CONTROL":{const gt=new ze(Q);d.canBlockReload=gt.bool("CAN-BLOCK-RELOAD"),d.canSkipUntil=gt.optionalFloat("CAN-SKIP-UNTIL",0),d.canSkipDateRanges=d.canSkipUntil>0&&gt.bool("CAN-SKIP-DATERANGES"),d.partHoldBack=gt.optionalFloat("PART-HOLD-BACK",0),d.holdBack=gt.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const gt=new ze(Q);d.partTarget=gt.decimalFloatingPoint("PART-TARGET");break}case"PART":{let gt=d.partList;gt||(gt=d.partList=[]);const Mt=v>0?gt[gt.length-1]:void 0,Vt=v++,V=new ze(Q);Ki(d,V,["BYTERANGE","URI"]);const J=new fv(V,w,e,Vt,Mt);gt.push(J),w.duration+=J.duration;break}case"PRELOAD-HINT":{const gt=new ze(Q);Ki(d,gt,["URI"]),d.preloadHint=gt;break}case"RENDITION-REPORT":{const gt=new ze(Q);Ki(d,gt,["URI"]),d.renditionReports=d.renditionReports||[],d.renditionReports.push(gt);break}default:Y.warn(`line parsed but not handled: ${C}`);break}}}T&&!T.relurl?(f.pop(),b-=T.duration,d.partList&&(d.fragmentHint=T)):d.partList&&(k0(w,T),w.cc=E,d.fragmentHint=w,O&&S0(w,O,d));const N=f.length,H=f[0],j=f[N-1];if(b+=d.skippedSegments*d.targetduration,b>0&&N&&j){d.averagetargetduration=b/N;const nt=j.sn;d.endSN=nt!=="initSegment"?nt:0,d.live||(j.endList=!0),H&&(d.startCC=H.cc)}else d.endSN=0,d.startCC=0;return d.fragmentHint&&(b+=d.fragmentHint.duration),d.totalduration=b,d.endCC=E,F>0&&Qv(f,F),d}}function A0(n,t,e){var i,s;const o=new ze(n);Ki(e,o,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const c=(i=o.METHOD)!=null?i:"",d=o.URI,f=o.hexadecimalInteger("IV"),p=o.KEYFORMATVERSIONS,g=(s=o.KEYFORMAT)!=null?s:"identity";d&&o.IV&&!f&&Y.error(`Invalid IV: ${o.IV}`);const v=d?br.resolve(d,t):"",b=(p||"1").split("/").map(Number).filter(Number.isFinite);return new wa(c,v,g,b,f)}function E0(n){const t=new ze(n).decimalFloatingPoint("TIME-OFFSET");return Wt(t)?t:null}function qv(n,t){["video","audio","text"].forEach(e=>{const i=n.filter(s=>Yv(s,e));if(i.length){const s=i.filter(o=>o.lastIndexOf("avc1",0)===0||o.lastIndexOf("mp4a",0)===0);t[`${e}Codec`]=s.length>0?s[0]:i[0],n=n.filter(o=>i.indexOf(o)===-1)}}),t.unknownCodecs=n}function T0(n,t,e){const i=t[e];i&&(n[e]=i)}function Qv(n,t){let e=n[t];for(let i=t;i--;){const s=n[i];if(!s)return;s.programDateTime=e.programDateTime-s.duration*1e3,e=s}}function k0(n,t){n.rawProgramDateTime?n.programDateTime=Date.parse(n.rawProgramDateTime):t!=null&&t.programDateTime&&(n.programDateTime=t.endProgramDateTime),Wt(n.programDateTime)||(n.programDateTime=null,n.rawProgramDateTime=null)}function w0(n,t,e,i){n.relurl=t.URI,t.BYTERANGE&&n.setByteRange(t.BYTERANGE),n.level=e,n.sn="initSegment",i&&(n.levelkeys=i),n.initSegment=null}function S0(n,t,e){n.levelkeys=t;const{encryptedFragments:i}=e;(!i.length||i[i.length-1].levelkeys!==t)&&Object.keys(t).some(s=>t[s].isCommonEncryption)&&i.push(n)}var Te={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},Jt={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function R0(n){const{type:t}=n;switch(t){case Te.AUDIO_TRACK:return Jt.AUDIO;case Te.SUBTITLE_TRACK:return Jt.SUBTITLE;default:return Jt.MAIN}}function vc(n,t){let e=n.url;return(e===void 0||e.indexOf("data:")===0)&&(e=t.url),e}class Jv{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_LOADING,this.onLevelLoading,this),t.on(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_LOADING,this.onLevelLoading,this),t.off(R.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(R.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(t){const e=this.hls.config,i=e.pLoader,s=e.loader,o=i||s,c=new o(e);return this.loaders[t.type]=c,c}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:i}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Te.MANIFEST,url:i,deliveryDirectives:null})}onLevelLoading(t,e){const{id:i,level:s,url:o,deliveryDirectives:c}=e;this.load({id:i,level:s,responseType:"text",type:Te.LEVEL,url:o,deliveryDirectives:c})}onAudioTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.AUDIO_TRACK,url:o,deliveryDirectives:c})}onSubtitleTrackLoading(t,e){const{id:i,groupId:s,url:o,deliveryDirectives:c}=e;this.load({id:i,groupId:s,level:null,responseType:"text",type:Te.SUBTITLE_TRACK,url:o,deliveryDirectives:c})}load(t){var e;const i=this.hls.config;let s=this.getInternalLoader(t);if(s){const p=s.context;if(p&&p.url===t.url){Y.trace("[playlist-loader]: playlist request ongoing");return}Y.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),s.abort()}let o;if(t.type===Te.MANIFEST?o=i.manifestLoadPolicy.default:o=ai({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),(e=t.deliveryDirectives)!=null&&e.part){let p;if(t.type===Te.LEVEL&&t.level!==null?p=this.hls.levels[t.level].details:t.type===Te.AUDIO_TRACK&&t.id!==null?p=this.hls.audioTracks[t.id].details:t.type===Te.SUBTITLE_TRACK&&t.id!==null&&(p=this.hls.subtitleTracks[t.id].details),p){const g=p.partTarget,v=p.targetduration;if(g&&v){const b=Math.max(g*3,v*.8)*1e3;o=ai({},o,{maxTimeToFirstByteMs:Math.min(b,o.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(b,o.maxTimeToFirstByteMs)})}}}const c=o.errorRetry||o.timeoutRetry||{},d={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},f={onSuccess:(p,g,v,b)=>{const E=this.getInternalLoader(v);this.resetInternalLoader(v.type);const T=p.data;if(T.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(p,v,new Error("no EXTM3U delimiter"),b||null,g);return}g.parsing.start=performance.now(),br.isMediaPlaylist(T)?this.handleTrackOrLevelPlaylist(p,g,v,b||null,E):this.handleMasterPlaylist(p,g,v,b)},onError:(p,g,v,b)=>{this.handleNetworkError(g,v,!1,p,b)},onTimeout:(p,g,v)=>{this.handleNetworkError(g,v,!0,void 0,p)}};s.load(t,d,f)}handleMasterPlaylist(t,e,i,s){const o=this.hls,c=t.data,d=vc(t,i),f=br.parseMasterPlaylist(c,d);if(f.playlistParsingError){this.handleManifestParsingError(t,i,f.playlistParsingError,s,e);return}const{contentSteering:p,levels:g,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T}=f;this.variableList=T;const{AUDIO:w=[],SUBTITLES:C,"CLOSED-CAPTIONS":D}=br.parseMasterPlaylistMedia(c,d,f);w.length&&!w.some(O=>!O.url)&&g[0].audioCodec&&!g[0].attrs.AUDIO&&(Y.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),w.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new ze({}),bitrate:0,url:""})),o.trigger(R.MANIFEST_LOADED,{levels:g,audioTracks:w,subtitles:C,captions:D,contentSteering:p,url:d,stats:e,networkDetails:s,sessionData:v,sessionKeys:b,startTimeOffset:E,variableList:T})}handleTrackOrLevelPlaylist(t,e,i,s,o){const c=this.hls,{id:d,level:f,type:p}=i,g=vc(t,i),v=Wt(d)?d:0,b=Wt(f)?f:v,E=R0(i),T=br.parseLevelPlaylist(t.data,g,b,E,v,this.variableList);if(p===Te.MANIFEST){const w={attrs:new ze({}),bitrate:0,details:T,name:"",url:g};c.trigger(R.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:g,stats:e,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),i.levelDetails=T,this.handlePlaylistLoaded(T,t,e,i,s,o)}handleManifestParsingError(t,e,i,s,o){this.hls.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.MANIFEST_PARSING_ERROR,fatal:e.type===Te.MANIFEST,url:t.url,err:i,error:i,reason:i.message,response:t,context:e,networkDetails:s,stats:o})}handleNetworkError(t,e,i=!1,s,o){let c=`A network ${i?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${t.type}`;t.type===Te.LEVEL?c+=`: ${t.level} id: ${t.id}`:(t.type===Te.AUDIO_TRACK||t.type===Te.SUBTITLE_TRACK)&&(c+=` id: ${t.id} group-id: "${t.groupId}"`);const d=new Error(c);Y.warn(`[playlist-loader]: ${c}`);let f=ut.UNKNOWN,p=!1;const g=this.getInternalLoader(t);switch(t.type){case Te.MANIFEST:f=i?ut.MANIFEST_LOAD_TIMEOUT:ut.MANIFEST_LOAD_ERROR,p=!0;break;case Te.LEVEL:f=i?ut.LEVEL_LOAD_TIMEOUT:ut.LEVEL_LOAD_ERROR,p=!1;break;case Te.AUDIO_TRACK:f=i?ut.AUDIO_TRACK_LOAD_TIMEOUT:ut.AUDIO_TRACK_LOAD_ERROR,p=!1;break;case Te.SUBTITLE_TRACK:f=i?ut.SUBTITLE_TRACK_LOAD_TIMEOUT:ut.SUBTITLE_LOAD_ERROR,p=!1;break}g&&this.resetInternalLoader(t.type);const v={type:qt.NETWORK_ERROR,details:f,fatal:p,url:t.url,loader:g,context:t,error:d,networkDetails:e,stats:o};if(s){const b=(e==null?void 0:e.url)||t.url;v.response=Wi({url:b,data:void 0},s)}this.hls.trigger(R.ERROR,v)}handlePlaylistLoaded(t,e,i,s,o,c){const d=this.hls,{type:f,level:p,id:g,groupId:v,deliveryDirectives:b}=s,E=vc(e,s),T=R0(s),w=typeof s.level=="number"&&T===Jt.MAIN?p:void 0;if(!t.fragments.length){const D=new Error("No Segments found in Playlist");d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_EMPTY_ERROR,fatal:!1,url:E,error:D,reason:D.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));const C=t.playlistParsingError;if(C){d.trigger(R.ERROR,{type:qt.NETWORK_ERROR,details:ut.LEVEL_PARSING_ERROR,fatal:!1,url:E,error:C,reason:C.message,response:e,context:s,level:w,parent:T,networkDetails:o,stats:i});return}switch(t.live&&c&&(c.getCacheAge&&(t.ageHeader=c.getCacheAge()||0),(!c.getCacheAge||isNaN(t.ageHeader))&&(t.ageHeader=0)),f){case Te.MANIFEST:case Te.LEVEL:d.trigger(R.LEVEL_LOADED,{details:t,level:w||0,id:g||0,stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.AUDIO_TRACK:d.trigger(R.AUDIO_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break;case Te.SUBTITLE_TRACK:d.trigger(R.SUBTITLE_TRACK_LOADED,{details:t,id:g||0,groupId:v||"",stats:i,networkDetails:o,deliveryDirectives:b});break}}}function _0(n,t){let e;try{e=new Event("addtrack")}catch{e=document.createEvent("Event"),e.initEvent("addtrack",!1,!1)}e.track=n,t.dispatchEvent(e)}function L0(n,t){const e=n.mode;if(e==="disabled"&&(n.mode="hidden"),n.cues&&!n.cues.getCueById(t.id))try{if(n.addCue(t),!n.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(i){Y.debug(`[texttrack-utils]: ${i}`);try{const s=new self.TextTrackCue(t.startTime,t.endTime,t.text);s.id=t.id,n.addCue(s)}catch(s){Y.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}e==="disabled"&&(n.mode=e)}function Rn(n){const t=n.mode;if(t==="disabled"&&(n.mode="hidden"),n.cues)for(let e=n.cues.length;e--;)n.removeCue(n.cues[e]);t==="disabled"&&(n.mode=t)}function yc(n,t,e,i){const s=n.mode;if(s==="disabled"&&(n.mode="hidden"),n.cues&&n.cues.length>0){const o=ey(n.cues,t,e);for(let c=0;c<o.length;c++)(!i||i(o[c]))&&n.removeCue(o[c])}s==="disabled"&&(n.mode=s)}function ty(n,t){if(t<n[0].startTime)return 0;const e=n.length-1;if(t>n[e].endTime)return-1;let i=0,s=e;for(;i<=s;){const o=Math.floor((s+i)/2);if(t<n[o].startTime)s=o-1;else if(t>n[o].startTime&&i<e)i=o+1;else return o}return n[i].startTime-t<t-n[s].startTime?i:s}function ey(n,t,e){const i=[],s=ty(n,t);if(s>-1)for(let o=s,c=n.length;o<c;o++){const d=n[o];if(d.startTime>=t&&d.endTime<=e)i.push(d);else if(d.startTime>e)return i}return i}var Ar={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const iy=.25;function bc(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const Lo=(()=>{const n=bc();try{new n(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Ac(n,t){return n.getTime()/1e3-t}function ry(n){return Uint8Array.from(n.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class sy{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:t}=this;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(t,e){this.media=e.media}onMediaDetaching(){this.id3Track&&(Rn(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const i=t[e];if(i.kind==="metadata"&&i.label==="id3")return _0(i,this.media),i}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:i,enableID3MetadataCues:s}}}=this;if(!i&&!s)return;const{samples:o}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const c=bc();for(let d=0;d<o.length;d++){const f=o[d].type;if(f===Ar.emsg&&!i||!s)continue;const p=s0(o[d].data);if(p){const g=o[d].pts;let v=g+o[d].duration;v>Lo&&(v=Lo),v-g<=0&&(v=g+iy);for(let b=0;b<p.length;b++){const E=p[b];if(!r0(E)){this.updateId3CueEnds(g,f);const T=new c(g,v,"");T.value=E,f&&(T.type=f),this.id3Track.addCue(T)}}}}}updateId3CueEnds(t,e){var i;const s=(i=this.id3Track)==null?void 0:i.cues;if(s)for(let o=s.length;o--;){const c=s[o];c.type===e&&c.startTime<t&&c.endTime===Lo&&(c.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:i,type:s}){const{id3Track:o,hls:c}=this;if(!c)return;const{config:{enableEmsgMetadataCues:d,enableID3MetadataCues:f}}=c;if(o&&(d||f)){let p;s==="audio"?p=g=>g.type===Ar.audioId3&&f:s==="video"?p=g=>g.type===Ar.emsg&&d:p=g=>g.type===Ar.audioId3&&f||g.type===Ar.emsg&&d,yc(o,e,i,p)}}onLevelUpdated(t,{details:e}){if(!this.media||!e.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:i,id3Track:s}=this,{dateRanges:o}=e,c=Object.keys(o);if(s){const g=Object.keys(i).filter(v=>!c.includes(v));for(let v=g.length;v--;){const b=g[v];Object.keys(i[b].cues).forEach(E=>{s.removeCue(i[b].cues[E])}),delete i[b]}}const d=e.fragments[e.fragments.length-1];if(c.length===0||!Wt(d==null?void 0:d.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const f=d.programDateTime/1e3-d.start,p=bc();for(let g=0;g<c.length;g++){const v=c[g],b=o[v],E=i[v],T=(E==null?void 0:E.cues)||{};let w=(E==null?void 0:E.durationKnown)||!1;const C=Ac(b.startDate,f);let D=Lo;const O=b.endDate;if(O)D=Ac(O,f),w=!0;else if(b.endOnNext&&!w){const x=c.reduce((N,H)=>{const j=o[H];return j.class===b.class&&j.id!==H&&j.startDate>b.startDate&&N.push(j),N},[]).sort((N,H)=>N.startDate.getTime()-H.startDate.getTime())[0];x&&(D=Ac(x.startDate,f),w=!0)}const F=Object.keys(b.attr);for(let x=0;x<F.length;x++){const N=F[x];if(!dv(N))continue;let H=T[N];if(H)w&&!E.durationKnown&&(H.endTime=D);else{let j=b.attr[N];H=new p(C,D,""),uv(N)&&(j=ry(j)),H.value={key:N,data:j},H.type=Ar.dateRange,H.id=v,this.id3Track.addCue(H),T[N]=H}}i[v]={cues:T,dateRange:b,durationKnown:w}}}}class ny{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=t,this.config=t.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:t,levelDetails:e}=this;return t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const{levelDetails:t}=this;if(t===null)return null;const{holdBack:e,partHoldBack:i,targetduration:s}=t,{liveSyncDuration:o,liveSyncDurationCount:c,lowLatencyMode:d}=this.config,f=this.hls.userConfig;let p=d&&i||e;(f.liveSyncDuration||f.liveSyncDurationCount||p===0)&&(p=o!==void 0?o:c*s);const g=s,v=1;return p+Math.min(this.stallCount*v,g)}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency,i=this.levelDetails;if(t===null||e===null||i===null)return null;const s=i.edge,o=t-e-this.edgeStalled,c=s-i.totalduration,d=s-(this.config.lowLatencyMode&&i.partTarget||i.targetduration);return Math.min(Math.max(c,o),d)}get drift(){const{levelDetails:t}=this;return t===null?1:t.drift}get edgeStalled(){const{levelDetails:t}=this;if(t===null)return 0;const e=(this.config.lowLatencyMode&&t.partTarget||t.targetduration)*3;return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t,levelDetails:e}=this;if(!t||!e)return 0;const i=t.buffered.length;return(i?t.buffered.end(i-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(R.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(R.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){this.levelDetails=e,e.advanced&&this.timeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(t,e){var i;e.details===ut.BUFFER_STALLED_ERROR&&(this.stallCount++,(i=this.levelDetails)!=null&&i.live&&Y.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:t,levelDetails:e}=this;if(!t||!e)return;this.currentTime=t.currentTime;const i=this.computeLatency();if(i===null)return;this._latency=i;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:o}=this.config;if(!s||o===1)return;const c=this.targetLatency;if(c===null)return;const d=i-c,f=Math.min(this.maxLatency,c+e.targetduration),p=d<f;if(e.live&&p&&d>.05&&this.forwardBufferLength>1){const g=Math.min(2,Math.max(1,o)),v=Math.round(2/(1+Math.exp(-.75*d-this.edgeStalled))*20)/20;t.playbackRate=Math.min(g,Math.max(1,v))}else t.playbackRate!==1&&t.playbackRate!==0&&(t.playbackRate=1)}estimateLiveEdge(){const{levelDetails:t}=this;return t===null?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return t===null?null:t-this.currentTime}}const Ec=["NONE","TYPE-0","TYPE-1",null];var Sa={No:"",Yes:"YES",v2:"v2"};function ay(n,t){const{canSkipUntil:e,canSkipDateRanges:i,endSN:s}=n,o=t!==void 0?t-s:0;return e&&o<e?i?Sa.v2:Sa.Yes:Sa.No}class C0{constructor(t,e,i){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=i}addDirectives(t){const e=new self.URL(t);return this.msn!==void 0&&e.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Ra{constructor(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(t){const e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var t;return(t=this.audioGroupIds)==null?void 0:t[this.urlId]}get textGroupId(){var t;return(t=this.textGroupIds)==null?void 0:t[this.urlId]}addFallback(t){this.url.push(t.url),this._attrs.push(t.attrs)}}function Tc(n,t){const e=t.startPTS;if(Wt(e)){let i=0,s;t.sn>n.sn?(i=e-n.start,s=n):(i=n.start-e,s=t),s.duration!==i&&(s.duration=i)}else t.sn>n.sn?n.cc===t.cc&&n.minEndPTS?t.start=n.start+(n.minEndPTS-n.start):t.start=n.start+n.duration:t.start=Math.max(n.start-t.duration,0)}function I0(n,t,e,i,s,o){i-e<=0&&(Y.warn("Fragment should have a positive duration",t),i=e+t.duration,o=s+t.duration);let c=e,d=i;const f=t.startPTS,p=t.endPTS;if(Wt(f)){const w=Math.abs(f-e);Wt(t.deltaPTS)?t.deltaPTS=Math.max(w,t.deltaPTS):t.deltaPTS=w,c=Math.max(e,f),e=Math.min(e,f),s=Math.min(s,t.startDTS),d=Math.min(i,p),i=Math.max(i,p),o=Math.max(o,t.endDTS)}const g=e-t.start;t.start!==0&&(t.start=e),t.duration=i-t.start,t.startPTS=e,t.maxStartPTS=c,t.startDTS=s,t.endPTS=i,t.minEndPTS=d,t.endDTS=o;const v=t.sn;if(!n||v<n.startSN||v>n.endSN)return 0;let b;const E=v-n.startSN,T=n.fragments;for(T[E]=t,b=E;b>0;b--)Tc(T[b],T[b-1]);for(b=E;b<T.length-1;b++)Tc(T[b],T[b+1]);return n.fragmentHint&&Tc(T[T.length-1],n.fragmentHint),n.PTSKnown=n.alignedSliding=!0,g}function oy(n,t){let e=null;const i=n.fragments;for(let f=i.length-1;f>=0;f--){const p=i[f].initSegment;if(p){e=p;break}}n.fragmentHint&&delete n.fragmentHint.endPTS;let s=0,o;if(hy(n,t,(f,p)=>{f.relurl&&(s=f.cc-p.cc),Wt(f.startPTS)&&Wt(f.endPTS)&&(p.start=p.startPTS=f.startPTS,p.startDTS=f.startDTS,p.maxStartPTS=f.maxStartPTS,p.endPTS=f.endPTS,p.endDTS=f.endDTS,p.minEndPTS=f.minEndPTS,p.duration=f.endPTS-f.startPTS,p.duration&&(o=p),t.PTSKnown=t.alignedSliding=!0),p.elementaryStreams=f.elementaryStreams,p.loader=f.loader,p.stats=f.stats,p.urlId=f.urlId,f.initSegment&&(p.initSegment=f.initSegment,e=f.initSegment)}),e&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(f=>{var p;(!f.initSegment||f.initSegment.relurl===((p=e)==null?void 0:p.relurl))&&(f.initSegment=e)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(f=>!f),t.deltaUpdateFailed){Y.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let f=t.skippedSegments;f--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=ly(n.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const c=t.fragments;if(s){Y.warn("discontinuity sliding from playlist, take drift into account");for(let f=0;f<c.length;f++)c[f].cc+=s}t.skippedSegments&&(t.startCC=t.fragments[0].cc),cy(n.partList,t.partList,(f,p)=>{p.elementaryStreams=f.elementaryStreams,p.stats=f.stats}),o?I0(t,o,o.startPTS,o.endPTS,o.startDTS,o.endDTS):x0(n,t),c.length&&(t.totalduration=t.edge-c[0].start),t.driftStartTime=n.driftStartTime,t.driftStart=n.driftStart;const d=t.advancedDateTime;if(t.advanced&&d){const f=t.edge;t.driftStart||(t.driftStartTime=d,t.driftStart=f),t.driftEndTime=d,t.driftEnd=f}else t.driftEndTime=n.driftEndTime,t.driftEnd=n.driftEnd,t.advancedDateTime=n.advancedDateTime}function ly(n,t,e){const i=ai({},n);return e&&e.forEach(s=>{delete i[s]}),Object.keys(t).forEach(s=>{const o=new Xu(t[s].attr,i[s]);o.isValid?i[s]=o:Y.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[s].attr)}"`)}),i}function cy(n,t,e){if(n&&t){let i=0;for(let s=0,o=n.length;s<=o;s++){const c=n[s],d=t[s+i];c&&d&&c.index===d.index&&c.fragment.sn===d.fragment.sn?e(c,d):i--}}}function hy(n,t,e){const i=t.skippedSegments,s=Math.max(n.startSN,t.startSN)-t.startSN,o=(n.fragmentHint?1:0)+(i?t.endSN:Math.min(n.endSN,t.endSN))-t.startSN,c=t.startSN-n.startSN,d=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,f=n.fragmentHint?n.fragments.concat(n.fragmentHint):n.fragments;for(let p=s;p<=o;p++){const g=f[c+p];let v=d[p];i&&!v&&p<i&&(v=t.fragments[p]=g),g&&v&&e(g,v)}}function x0(n,t){const e=t.startSN+t.skippedSegments-n.startSN,i=n.fragments;e<0||e>=i.length||kc(t,i[e].start)}function kc(n,t){if(t){const e=n.fragments;for(let i=n.skippedSegments;i<e.length;i++)e[i].start+=t;n.fragmentHint&&(n.fragmentHint.start+=t)}}function dy(n,t=1/0){let e=1e3*n.targetduration;if(n.updated){const i=n.fragments,s=4;if(i.length&&e*s>t){const o=i[i.length-1].duration*1e3;o<e&&(e=o)}}else e/=2;return Math.round(e)}function uy(n,t,e){if(!(n!=null&&n.details))return null;const i=n.details;let s=i.fragments[t-i.startSN];return s||(s=i.fragmentHint,s&&s.sn===t)?s:t<i.startSN&&e&&e.sn===t?e:null}function D0(n,t,e){var i;return n!=null&&n.details?P0((i=n.details)==null?void 0:i.partList,t,e):null}function P0(n,t,e){if(n)for(let i=n.length;i--;){const s=n[i];if(s.index===e&&s.fragment.sn===t)return s}return null}function Co(n){switch(n.details){case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_TIMEOUT:case ut.LEVEL_LOAD_TIMEOUT:case ut.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function O0(n,t){const e=Co(t);return n.default[`${e?"timeout":"error"}Retry`]}function wc(n,t){const e=n.backoff==="linear"?1:Math.pow(2,t);return Math.min(e*n.retryDelayMs,n.maxRetryDelayMs)}function M0(n){return Wi(Wi({},n),{errorRetry:null,timeoutRetry:null})}function Io(n,t,e,i){return!!n&&t<n.maxNumRetry&&(fy(i)||!!e)}function fy(n){return n===0&&navigator.onLine===!1||!!n&&(n<400||n>499)}const $0={search:function(n,t){let e=0,i=n.length-1,s=null,o=null;for(;e<=i;){s=(e+i)/2|0,o=n[s];const c=t(o);if(c>0)e=s+1;else if(c<0)i=s-1;else return o}return null}};function py(n,t,e){if(t===null||!Array.isArray(n)||!n.length||!Wt(t))return null;const i=n[0].programDateTime;if(t<(i||0))return null;const s=n[n.length-1].endProgramDateTime;if(t>=(s||0))return null;e=e||0;for(let o=0;o<n.length;++o){const c=n[o];if(gy(t,e,c))return c}return null}function _a(n,t,e=0,i=0){let s=null;if(n?s=t[n.sn-t[0].sn+1]||null:e===0&&t[0].start===0&&(s=t[0]),s&&Sc(e,i,s)===0)return s;const o=$0.search(t,Sc.bind(null,e,i));return o&&(o!==n||!s)?o:s}function Sc(n=0,t=0,e){if(e.start<=n&&e.start+e.duration>n)return 0;const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0));return e.start+e.duration-i<=n?1:e.start-i>n&&e.start?-1:0}function gy(n,t,e){const i=Math.min(t,e.duration+(e.deltaPTS?e.deltaPTS:0))*1e3;return(e.endProgramDateTime||0)-i>n}function my(n,t){return $0.search(n,e=>e.cc<t?1:e.cc>t?-1:0)}const vy=3e5;var Ri={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},cr={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class yy{constructor(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=Y.log.bind(Y,"[info]:"),this.warn=Y.warn.bind(Y,"[warning]:"),this.error=Y.error.bind(Y,"[error]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.ERROR,this.onError,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.ERROR,this.onError,this),t.off(R.ERROR,this.onErrorOut,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(t){this.playlistError=0}stopLoad(){}getVariantLevelIndex(t){return(t==null?void 0:t.type)===Jt.MAIN?t.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(t,e){var i,s;if(e.fatal)return;const o=this.hls,c=e.context;switch(e.details){case ut.FRAG_LOAD_ERROR:case ut.FRAG_LOAD_TIMEOUT:case ut.KEY_LOAD_ERROR:case ut.KEY_LOAD_TIMEOUT:e.errorAction=this.getFragRetryOrSwitchAction(e);return;case ut.FRAG_PARSING_ERROR:if((i=e.frag)!=null&&i.gap){e.errorAction={action:Ri.DoNothing,flags:cr.None};return}case ut.FRAG_GAP:case ut.FRAG_DECRYPT_ERROR:{e.errorAction=this.getFragRetryOrSwitchAction(e),e.errorAction.action=Ri.SendAlternateToPenaltyBox;return}case ut.LEVEL_EMPTY_ERROR:case ut.LEVEL_PARSING_ERROR:{var d,f;const p=e.parent===Jt.MAIN?e.level:o.loadLevel;e.details===ut.LEVEL_EMPTY_ERROR&&(d=e.context)!=null&&(f=d.levelDetails)!=null&&f.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,p):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p))}return;case ut.LEVEL_LOAD_ERROR:case ut.LEVEL_LOAD_TIMEOUT:typeof(c==null?void 0:c.level)=="number"&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,c.level));return;case ut.AUDIO_TRACK_LOAD_ERROR:case ut.AUDIO_TRACK_LOAD_TIMEOUT:case ut.SUBTITLE_LOAD_ERROR:case ut.SUBTITLE_TRACK_LOAD_TIMEOUT:if(c){const p=o.levels[o.loadLevel];if(p&&(c.type===Te.AUDIO_TRACK&&c.groupId===p.audioGroupId||c.type===Te.SUBTITLE_TRACK&&c.groupId===p.textGroupId)){e.errorAction=this.getPlaylistRetryOrSwitchAction(e,o.loadLevel),e.errorAction.action=Ri.SendAlternateToPenaltyBox,e.errorAction.flags=cr.MoveAllAlternatesMatchingHost;return}}return;case ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const p=o.levels[o.loadLevel],g=p==null?void 0:p.attrs["HDCP-LEVEL"];g&&(e.errorAction={action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHDCP,hdcpLevel:g})}return;case ut.BUFFER_ADD_CODEC_ERROR:case ut.REMUX_ALLOC_ERROR:e.errorAction=this.getLevelSwitchAction(e,(s=e.level)!=null?s:o.loadLevel);return;case ut.INTERNAL_EXCEPTION:case ut.BUFFER_APPENDING_ERROR:case ut.BUFFER_APPEND_ERROR:case ut.BUFFER_FULL_ERROR:case ut.LEVEL_SWITCH_ERROR:case ut.BUFFER_STALLED_ERROR:case ut.BUFFER_SEEK_OVER_HOLE:case ut.BUFFER_NUDGE_ON_STALL:e.errorAction={action:Ri.DoNothing,flags:cr.None};return}if(e.type===qt.KEY_SYSTEM_ERROR){const p=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,p);return}}getPlaylistRetryOrSwitchAction(t,e){var i;const s=this.hls,o=O0(s.config.playlistLoadPolicy,t),c=this.playlistError++,d=(i=t.response)==null?void 0:i.code;if(Io(o,c,Co(t),d))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:o,retryCount:c};const f=this.getLevelSwitchAction(t,e);return o&&(f.retryConfig=o,f.retryCount=c),f}getFragRetryOrSwitchAction(t){const e=this.hls,i=this.getVariantLevelIndex(t.frag),s=e.levels[i],{fragLoadPolicy:o,keyLoadPolicy:c}=e.config,d=O0(t.details.startsWith("key")?c:o,t),f=e.levels.reduce((v,b)=>v+b.fragmentError,0);if(s){var p;t.details!==ut.FRAG_GAP&&s.fragmentError++;const v=(p=t.response)==null?void 0:p.code;if(Io(d,f,Co(t),v))return{action:Ri.RetryRequest,flags:cr.None,retryConfig:d,retryCount:f}}const g=this.getLevelSwitchAction(t,i);return d&&(g.retryConfig=d,g.retryCount=f),g}getLevelSwitchAction(t,e){const i=this.hls;e==null&&(e=i.loadLevel);const s=this.hls.levels[e];if(s&&(s.loadError++,i.autoLevelEnabled)){var o,c;let d=-1;const{levels:f,loadLevel:p,minAutoLevel:g,maxAutoLevel:v}=i,b=(o=t.frag)==null?void 0:o.type,{type:E,groupId:T}=(c=t.context)!=null?c:{};for(let w=f.length;w--;){const C=(w+p)%f.length;if(C!==p&&C>=g&&C<=v&&f[C].loadError===0){const D=f[C];if(t.details===ut.FRAG_GAP&&t.frag){const O=f[C].details;if(O){const F=_a(t.frag,O.fragments,t.frag.start);if(F!=null&&F.gap)continue}}else if(E===Te.AUDIO_TRACK&&T===D.audioGroupId||E===Te.SUBTITLE_TRACK&&T===D.textGroupId||b===Jt.AUDIO&&s.audioGroupId===D.audioGroupId||b===Jt.SUBTITLE&&s.textGroupId===D.textGroupId)continue;d=C;break}}if(d>-1&&i.loadLevel!==d)return t.levelRetry=!0,this.playlistError=0,{action:Ri.SendAlternateToPenaltyBox,flags:cr.None,nextAutoLevel:d}}return{action:Ri.SendAlternateToPenaltyBox,flags:cr.MoveAllAlternatesMatchingHost}}onErrorOut(t,e){var i;switch((i=e.errorAction)==null?void 0:i.action){case Ri.DoNothing:break;case Ri.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(e),!e.errorAction.resolved&&e.details!==ut.FRAG_GAP&&(e.fatal=!0);break}if(e.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(t){const e=this.hls,i=t.errorAction;if(!i)return;const{flags:s,hdcpLevel:o,nextAutoLevel:c}=i;switch(s){case cr.None:this.switchLevel(t,c);break;case cr.MoveAllAlternatesMatchingHost:i.resolved||(i.resolved=this.redundantFailover(t));break;case cr.MoveAllAlternatesMatchingHDCP:o&&(e.maxHdcpLevel=Ec[Ec.indexOf(o)-1],i.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}i.resolved||this.switchLevel(t,c)}switchLevel(t,e){e!==void 0&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(t){const{hls:e,penalizedRenditions:i}=this,s=t.parent===Jt.MAIN?t.level:e.loadLevel,o=e.levels[s],c=o.url.length,d=t.frag?t.frag.urlId:o.urlId;o.urlId===d&&(!t.frag||o.details)&&this.penalizeRendition(o,t);for(let f=1;f<c;f++){const p=(d+f)%c,g=i[p];if(!g||by(g,t,i[d]))return this.warn(`Switching to Redundant Stream ${p+1}/${c}: "${o.url[p]}" after ${t.details}`),this.playlistError=0,e.levels.forEach(v=>{v.urlId=p}),e.nextLoadLevel=s,!0}return!1}penalizeRendition(t,e){const{penalizedRenditions:i}=this,s=i[t.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};s.lastErrorPerfMs=performance.now(),s.errors.push(e),s.details=t.details,i[t.urlId]=s}}function by(n,t,e){if(performance.now()-n.lastErrorPerfMs>vy)return!0;const i=n.details;if(t.details===ut.FRAG_GAP&&i&&t.frag){const s=t.frag.start,o=_a(null,i.fragments,s);if(o&&!o.gap)return!0}if(e&&n.errors.length<e.errors.length){const s=n.errors[n.errors.length-1];if(i&&s.frag&&t.frag&&Math.abs(s.frag.start-t.frag.start)>i.targetduration*3)return!0}return!1}class Rc{constructor(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=Y.log.bind(Y,`${e}:`),this.warn=Y.warn.bind(Y,`${e}:`),this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e){const i=e==null?void 0:e.renditionReports;if(i){let s=-1;for(let o=0;o<i.length;o++){const c=i[o];let d;try{d=new self.URL(c.URI,e.url).href}catch(f){Y.warn(`Could not construct new URL for Rendition Report: ${f}`),d=c.URI||""}if(d===t){s=o;break}else d===t.substring(0,d.length)&&(s=o)}if(s!==-1){const o=i[s],c=parseInt(o["LAST-MSN"])||(e==null?void 0:e.lastPartSn);let d=parseInt(o["LAST-PART"])||(e==null?void 0:e.lastPartIndex);if(this.hls.config.lowLatencyMode){const f=Math.min(e.age-e.partTarget,e.targetduration);d>=0&&f>e.partTarget&&(d+=1)}return new C0(c,d>=0?d:void 0,Sa.No)}}}loadPlaylist(t){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}shouldReloadPlaylist(t){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(t)}playlistLoaded(t,e,i){const{details:s,stats:o}=e,c=self.performance.now(),d=o.loading.first?Math.max(0,c-o.loading.first):0;if(s.advancedDateTime=Date.now()-d,s.live||i!=null&&i.live){if(s.reloaded(i),i&&this.log(`live playlist ${t} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),i&&s.fragments.length>0&&oy(i,s),!this.canLoad||!s.live)return;let f,p,g;if(s.canBlockReload&&s.endSN&&s.advanced){const C=this.hls.config.lowLatencyMode,D=s.lastPartSn,O=s.endSN,F=s.lastPartIndex,x=F!==-1,N=D===O,H=C?0:F;x?(p=N?O+1:D,g=N?H:F+1):p=O+1;const j=s.age,nt=j+s.ageHeader;let st=Math.min(nt-s.partTarget,s.targetduration*1.5);if(st>0){if(i&&st>i.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${i.tuneInGoal} to: ${st} with playlist age: ${s.age}`),st=0;else{const Q=Math.floor(st/s.targetduration);if(p+=Q,g!==void 0){const kt=Math.round(st%s.targetduration/s.partTarget);g+=kt}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${j.toFixed(2)}s goal: ${st} skip sn ${Q} to part ${g}`)}s.tuneInGoal=st}if(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g),C||!N){this.loadPlaylist(f);return}}else(s.canBlockReload||s.canSkipUntil)&&(f=this.getDeliveryDirectives(s,e.deliveryDirectives,p,g));const v=this.hls.mainForwardBufferInfo,b=v?v.end-v.len:0,E=(s.edge-b)*1e3,T=dy(s,E);s.updated&&c>this.requestScheduled+T&&(this.requestScheduled=o.loading.start),p!==void 0&&s.canBlockReload?this.requestScheduled=o.loading.first+T-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+T<c?this.requestScheduled=c:this.requestScheduled-c<=0&&(this.requestScheduled+=T);let w=this.requestScheduled-c;w=Math.max(0,w),this.log(`reload live playlist ${t} in ${Math.round(w)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(f),w)}else this.clearTimer()}getDeliveryDirectives(t,e,i,s){let o=ay(t,i);return e!=null&&e.skip&&t.deltaUpdateFailed&&(i=e.msn,s=e.part,o=Sa.No),new C0(i,s,o)}checkRetry(t){const e=t.details,i=Co(t),s=t.errorAction,{action:o,retryCount:c=0,retryConfig:d}=s||{},f=!!s&&!!d&&(o===Ri.RetryRequest||!s.resolved&&o===Ri.SendAlternateToPenaltyBox);if(f){var p;if(this.requestScheduled=-1,c>=d.maxNumRetry)return!1;if(i&&(p=t.context)!=null&&p.deliveryDirectives)this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const g=wc(d,c);this.timer=self.setTimeout(()=>this.loadPlaylist(),g),this.warn(`Retrying playlist loading ${c+1}/${d.maxNumRetry} after "${e}" in ${g}ms`)}t.levelRetry=!0,s.resolved=!0}return f}}let _c;class Ay extends Rc{constructor(t,e){super(t,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.LEVEL_LOADED,this.onLevelLoaded,this),t.on(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.LEVEL_LOADED,this.onLevelLoaded,this),t.off(R.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(R.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const i=[],s={};let o;e.levels.forEach(c=>{var d;const f=c.attrs;((d=c.audioCodec)==null?void 0:d.indexOf("mp4a.40.34"))!==-1&&(_c||(_c=/chrome|firefox/i.test(navigator.userAgent)),_c&&(c.audioCodec=void 0));const{AUDIO:p,CODECS:g,"FRAME-RATE":v,"PATHWAY-ID":b,RESOLUTION:E,SUBTITLES:T}=f,w=`${`${b||"."}-`}${c.bitrate}-${E}-${v}-${g}`;o=s[w],o?o.addFallback(c):(o=new Ra(c),s[w]=o,i.push(o)),xo(o,"audio",p),xo(o,"text",T)}),this.filterAndSortMediaOptions(i,e)}filterAndSortMediaOptions(t,e){let i=[],s=[],o=!1,c=!1,d=!1,f=t.filter(({audioCodec:E,videoCodec:T,width:w,height:C,unknownCodecs:D})=>(o||(o=!!(w&&C)),c||(c=!!T),d||(d=!!E),!(D!=null&&D.length)&&(!E||mc(E,"audio"))&&(!T||mc(T,"video"))));if((o||c)&&d&&(f=f.filter(({videoCodec:E,width:T,height:w})=>!!E||!!(T&&w))),f.length===0){Promise.resolve().then(()=>{if(this.hls){const E=new Error("no level with compatible codecs found in manifest");this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:E,reason:E.message})}});return}e.audioTracks&&(i=e.audioTracks.filter(E=>!E.audioCodec||mc(E.audioCodec,"audio")),N0(i)),e.subtitles&&(s=e.subtitles,N0(s));const p=f.slice(0);f.sort((E,T)=>E.attrs["HDCP-LEVEL"]!==T.attrs["HDCP-LEVEL"]?(E.attrs["HDCP-LEVEL"]||"")>(T.attrs["HDCP-LEVEL"]||"")?1:-1:E.bitrate!==T.bitrate?E.bitrate-T.bitrate:E.attrs["FRAME-RATE"]!==T.attrs["FRAME-RATE"]?E.attrs.decimalFloatingPoint("FRAME-RATE")-T.attrs.decimalFloatingPoint("FRAME-RATE"):E.attrs.SCORE!==T.attrs.SCORE?E.attrs.decimalFloatingPoint("SCORE")-T.attrs.decimalFloatingPoint("SCORE"):o&&E.height!==T.height?E.height-T.height:0);let g=p[0];if(this.steering&&(f=this.steering.filterParsedLevels(f),f.length!==p.length)){for(let E=0;E<p.length;E++)if(p[E].pathwayId===f[0].pathwayId){g=p[E];break}}this._levels=f;for(let E=0;E<f.length;E++)if(f[E]===g){this._firstLevel=E,this.log(`manifest loaded, ${f.length} level(s) found, first bitrate: ${g.bitrate}`);break}const v=d&&!c,b={levels:f,audioTracks:i,subtitleTracks:s,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:d,video:c,altAudio:!v&&i.some(E=>!!E.url)};this.hls.trigger(R.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(e.length===0)return;if(t<0||t>=e.length){const g=new Error("invalid level idx"),v=t<0;if(this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.LEVEL_SWITCH_ERROR,level:t,fatal:v,error:g,reason:g.message}),v)return;t=Math.min(t,e.length-1)}const i=this.currentLevelIndex,s=this.currentLevel,o=s?s.attrs["PATHWAY-ID"]:void 0,c=e[t],d=c.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=c,i===t&&c.details&&s&&o===d)return;this.log(`Switching to level ${t}${d?" with Pathway "+d:""} from level ${i}${o?" with Pathway "+o:""}`);const f=ai({},c,{level:t,maxBitrate:c.maxBitrate,attrs:c.attrs,uri:c.uri,urlId:c.urlId});delete f._attrs,delete f._urlId,this.hls.trigger(R.LEVEL_SWITCHING,f);const p=c.details;if(!p||p.live){const g=this.switchParams(c.uri,s==null?void 0:s.details);this.loadPlaylist(g)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,this._startLevel===void 0&&(this._startLevel=t),t!==-1&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(this._startLevel===void 0){const t=this.hls.config.startLevel;return t!==void 0?t:this._firstLevel}else return this._startLevel}set startLevel(t){this._startLevel=t}onError(t,e){e.fatal||!e.context||e.context.type===Te.LEVEL&&e.context.level===this.level&&this.checkRetry(e)}onFragLoaded(t,{frag:e}){if(e!==void 0&&e.type===Jt.MAIN){const i=this._levels[e.level];i!==void 0&&(i.loadError=0)}}onLevelLoaded(t,e){var i;const{level:s,details:o}=e,c=this._levels[s];if(!c){var d;this.warn(`Invalid level index ${s}`),(d=e.deliveryDirectives)!=null&&d.skip&&(o.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(c.fragmentError===0&&(c.loadError=0),this.playlistLoaded(s,e,c.details)):(i=e.deliveryDirectives)!=null&&i.skip&&(o.deltaUpdateFailed=!0)}onAudioTrackSwitched(t,e){const i=this.currentLevel;if(!i)return;const s=this.hls.audioTracks[e.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==s){let o=-1;for(let c=0;c<i.audioGroupIds.length;c++)if(i.audioGroupIds[c]===s){o=c;break}o!==-1&&o!==i.urlId&&(i.urlId=o,this.canLoad&&this.startLoad())}}loadPlaylist(t){super.loadPlaylist();const e=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){const s=i.urlId;let o=i.uri;if(t)try{o=t.addDirectives(o)}catch(d){this.warn(`Could not construct new URL with HLS Delivery Directives: ${d}`)}const c=i.attrs["PATHWAY-ID"];this.log(`Loading level index ${e}${(t==null?void 0:t.msn)!==void 0?" at sn "+t.msn+" part "+t.part:""} with${c?" Pathway "+c:""} URI ${s+1}/${i.url.length} ${o}`),this.clearTimer(),this.hls.trigger(R.LEVEL_LOADING,{url:o,level:e,id:s,deliveryDirectives:t||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=t)}removeLevel(t,e){const i=(o,c)=>c!==e,s=this._levels.filter((o,c)=>c!==t?!0:o.url.length>1&&e!==void 0?(o.url=o.url.filter(i),o.audioGroupIds&&(o.audioGroupIds=o.audioGroupIds.filter(i)),o.textGroupIds&&(o.textGroupIds=o.textGroupIds.filter(i)),o.urlId=0,!0):(this.steering&&this.steering.removeLevel(o),!1));this.hls.trigger(R.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){e.forEach((i,s)=>{const{details:o}=i;o!=null&&o.fragments&&o.fragments.forEach(c=>{c.level=s})}),this._levels=e}}function xo(n,t,e){e&&(t==="audio"?(n.audioGroupIds||(n.audioGroupIds=[]),n.audioGroupIds[n.url.length-1]=e):t==="text"&&(n.textGroupIds||(n.textGroupIds=[]),n.textGroupIds[n.url.length-1]=e))}function N0(n){const t={};n.forEach(e=>{const i=e.groupId||"";e.id=t[i]=t[i]||0,t[i]++})}var ui={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class Ey{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(R.BUFFER_APPENDED,this.onBufferAppended,this),t.on(R.FRAG_BUFFERED,this.onFragBuffered,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:t}=this;t.off(R.BUFFER_APPENDED,this.onBufferAppended,this),t.off(R.FRAG_BUFFERED,this.onFragBuffered,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const i=this.activePartLists[e];if(i)for(let s=i.length;s--;){const o=i[s];if(!o)break;const c=o.end;if(o.start<=t&&c!==null&&t<=c)return o}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){const{fragments:i}=this,s=Object.keys(i);for(let o=s.length;o--;){const c=i[s[o]];if((c==null?void 0:c.body.type)===e&&c.buffered){const d=c.body;if(d.start<=t&&t<=d.end)return d}}return null}detectEvictedFragments(t,e,i,s){this.timeRanges&&(this.timeRanges[t]=e);const o=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d||o>=d.body.sn)return;if(!d.buffered&&!d.loaded){d.body.type===i&&this.removeFragment(d.body);return}const f=d.range[t];f&&f.time.some(p=>{const g=!this.isTimeBuffered(p.startPTS,p.endPTS,e);return g&&this.removeFragment(d.body),g})})}detectPartialFragments(t){const e=this.timeRanges,{frag:i,part:s}=t;if(!e||i.sn==="initSegment")return;const o=_n(i),c=this.fragments[o];if(!c||c.buffered&&i.gap)return;const d=!i.relurl;Object.keys(e).forEach(f=>{const p=i.elementaryStreams[f];if(!p)return;const g=e[f],v=d||p.partial===!0;c.range[f]=this.getBufferedTimes(i,s,v,g)}),c.loaded=null,Object.keys(c.range).length?(c.buffered=!0,(c.body.endList=i.endList||c.body.endList)&&(this.endListFragments[c.body.type]=c),Do(c)||this.removeParts(i.sn-1,i.type)):this.removeFragment(c.body)}removeParts(t,e){const i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(s=>s.fragment.sn>=t))}fragBuffered(t,e){const i=_n(t);let s=this.fragments[i];!s&&e&&(s=this.fragments[i]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(t,e,i,s){const o={time:[],partial:i},c=t.start,d=t.end,f=t.minEndPTS||d,p=t.maxStartPTS||c;for(let g=0;g<s.length;g++){const v=s.start(g)-this.bufferPadding,b=s.end(g)+this.bufferPadding;if(p>=v&&f<=b){o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});break}else if(c<b&&d>v)o.partial=!0,o.time.push({startPTS:Math.max(c,s.start(g)),endPTS:Math.min(d,s.end(g))});else if(d<=v)break}return o}getPartialFragment(t){let e=null,i,s,o,c=0;const{bufferPadding:d,fragments:f}=this;return Object.keys(f).forEach(p=>{const g=f[p];g&&Do(g)&&(s=g.body.start-d,o=g.body.end+d,t>=s&&t<=o&&(i=Math.min(t-s,o-t),c<=i&&(e=g.body,c=i)))}),e}isEndListAppended(t){const e=this.endListFragments[t];return e!==void 0&&(e.buffered||Do(e))}getState(t){const e=_n(t),i=this.fragments[e];return i?i.buffered?Do(i)?ui.PARTIAL:ui.OK:ui.APPENDING:ui.NOT_LOADED}isTimeBuffered(t,e,i){let s,o;for(let c=0;c<i.length;c++){if(s=i.start(c)-this.bufferPadding,o=i.end(c)+this.bufferPadding,t>=s&&e<=o)return!0;if(e<=s)return!1}return!1}onFragLoaded(t,e){const{frag:i,part:s}=e;if(i.sn==="initSegment"||i.bitrateTest)return;const o=s?null:e,c=_n(i);this.fragments[c]={body:i,appendedPTS:null,loaded:o,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:i,part:s,timeRanges:o}=e;if(i.sn==="initSegment")return;const c=i.type;if(s){let d=this.activePartLists[c];d||(this.activePartLists[c]=d=[]),d.push(s)}this.timeRanges=o,Object.keys(o).forEach(d=>{const f=o[d];this.detectEvictedFragments(d,f,c,s)})}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=_n(t);return!!this.fragments[e]}hasParts(t){var e;return!!((e=this.activePartLists[t])!=null&&e.length)}removeFragmentsInRange(t,e,i,s,o){s&&!this.hasGaps||Object.keys(this.fragments).forEach(c=>{const d=this.fragments[c];if(!d)return;const f=d.body;f.type!==i||s&&!f.gap||f.start<e&&f.end>t&&(d.buffered||o)&&this.removeFragment(f)})}removeFragment(t){const e=_n(t);t.stats.loaded=0,t.clearElementaryStreamInfo();const i=this.activePartLists[t.type];if(i){const s=t.sn;this.activePartLists[t.type]=i.filter(o=>o.fragment.sn!==s)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Do(n){var t,e,i;return n.buffered&&(n.body.gap||((t=n.range.video)==null?void 0:t.partial)||((e=n.range.audio)==null?void 0:e.partial)||((i=n.range.audiovideo)==null?void 0:i.partial))}function _n(n){return`${n.type}_${n.level}_${n.urlId}_${n.sn}`}const F0=Math.pow(2,17);class Ty{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const i=t.url;if(!i)return Promise.reject(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error(`Fragment does not have a ${i?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap)if(t.tagList.some(E=>E[0]==="GAP")){f(B0(t));return}else t.gap=!1;const p=this.loader=t.loader=o?new o(s):new c(s),g=U0(t),v=M0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:t.sn==="initSegment"?1/0:F0};t.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p);let D=E.data;w.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(D.slice(0,16)),D=D.slice(16)),d({frag:t,part:null,payload:D,networkDetails:C})},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:Wi({url:i,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))},onProgress:(E,T,w,C)=>{e&&e({frag:t,part:null,payload:w,networkDetails:C})}})})}loadPart(t,e,i){this.abort();const s=this.config,o=s.fLoader,c=s.loader;return new Promise((d,f)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap){f(B0(t,e));return}const p=this.loader=t.loader=o?new o(s):new c(s),g=U0(t,e),v=M0(s.fragLoadPolicy.default),b={loadPolicy:v,timeout:v.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:F0};e.stats=p.stats,p.load(g,b,{onSuccess:(E,T,w,C)=>{this.resetLoader(t,p),this.updateStatsFromPart(t,e);const D={frag:t,part:e,payload:E.data,networkDetails:C};i(D),d(D)},onError:(E,T,w,C)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:Wi({url:g.url,data:void 0},E),error:new Error(`HTTP Error ${E.code} ${E.text}`),networkDetails:w,stats:C}))},onAbort:(E,T,w)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:w,stats:E}))},onTimeout:(E,T,w)=>{this.resetLoader(t,p),f(new Jr({type:qt.NETWORK_ERROR,details:ut.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${b.timeout}ms`),networkDetails:w,stats:E}))}})})}updateStatsFromPart(t,e){const i=t.stats,s=e.stats,o=s.total;if(i.loaded+=s.loaded,o){const f=Math.round(t.duration/e.duration),p=Math.min(Math.round(i.loaded/o),f),g=(f-p)*Math.round(i.loaded/p);i.total=i.loaded+g}else i.total=Math.max(i.loaded,i.total);const c=i.loading,d=s.loading;c.start?c.first+=d.first-d.start:(c.start=d.start,c.first=d.first),c.end=d.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function U0(n,t=null){const e=t||n,i={frag:n,part:t,responseType:"arraybuffer",url:e.url,headers:{},rangeStart:0,rangeEnd:0},s=e.byteRangeStartOffset,o=e.byteRangeEndOffset;if(Wt(s)&&Wt(o)){var c;let d=s,f=o;if(n.sn==="initSegment"&&((c=n.decryptdata)==null?void 0:c.method)==="AES-128"){const p=o-s;p%16&&(f=o+(16-p%16)),s!==0&&(i.resetIV=!0,d=s-16)}i.rangeStart=d,i.rangeEnd=f}return i}function B0(n,t){const e=new Error(`GAP ${n.gap?"tag":"attribute"} found`),i={type:qt.MEDIA_ERROR,details:ut.FRAG_GAP,fatal:!1,frag:n,error:e,networkDetails:null};return t&&(i.part=t),(t||n).stats.aborted=!0,new Jr(i)}class Jr extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class ky{constructor(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const e in this.keyUriToKeyInfo){const i=this.keyUriToKeyInfo[e].loader;if(i){if(t&&t!==i.context.frag.type)return;i.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){const e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(t,e=ut.KEY_LOAD_ERROR,i,s,o){return new Jr({type:qt.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:o,error:i,networkDetails:s})}loadClear(t,e){if(this.emeController&&this.config.emeEnabled){const{sn:i,cc:s}=t;for(let o=0;o<e.length;o++){const c=e[o];if(s<=c.cc&&(i==="initSegment"||c.sn==="initSegment"||i<c.sn)){this.emeController.selectKeySystemFormat(c).then(d=>{c.setKeyFormat(d)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var i,s;e&&t.setKeyFormat(e);const o=t.decryptdata;if(!o){const p=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,p))}const c=o.uri;if(!c)return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${c}"`)));let d=this.keyUriToKeyInfo[c];if((i=d)!=null&&i.decryptdata.key)return o.key=d.decryptdata.key,Promise.resolve({frag:t,keyInfo:d});if((s=d)!=null&&s.keyLoadPromise){var f;switch((f=d.mediaKeySessionContext)==null?void 0:f.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return d.keyLoadPromise.then(p=>(o.key=p.keyInfo.decryptdata.key,{frag:t,keyInfo:d}))}}switch(d=this.keyUriToKeyInfo[c]={decryptdata:o,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},o.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return o.keyFormat==="identity"?this.loadKeyHTTP(d,t):this.loadKeyEME(d,t);case"AES-128":return this.loadKeyHTTP(d,t);default:return Promise.reject(this.createKeyLoadError(t,ut.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${o.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(i);if(s)return(t.keyLoadPromise=s.then(o=>(t.mediaKeySessionContext=o,i))).catch(o=>{throw t.keyLoadPromise=null,o})}return Promise.resolve(i)}loadKeyHTTP(t,e){const i=this.config,s=i.loader,o=new s(i);return e.keyLoader=t.loader=o,t.keyLoadPromise=new Promise((c,d)=>{const f={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},p=i.keyLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{const{frag:C,keyInfo:D,url:O}=T;if(!C.decryptdata||D!==this.keyUriToKeyInfo[O])return d(this.createKeyLoadError(C,ut.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),w));D.decryptdata.key=C.decryptdata.key=new Uint8Array(b.data),C.keyLoader=null,D.loader=null,c({frag:C,keyInfo:D})},onError:(b,E,T,w)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_ERROR,new Error(`HTTP Error ${b.code} loading key ${b.text}`),T,Wi({url:f.url,data:void 0},b)))},onTimeout:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),T))},onAbort:(b,E,T)=>{this.resetLoader(E),d(this.createKeyLoadError(e,ut.INTERNAL_ABORTED,new Error("key loading aborted"),T))}};o.load(f,g,v)})}resetLoader(t){const{frag:e,keyInfo:i,url:s}=t,o=i.loader;e.keyLoader===o&&(e.keyLoader=null,i.loader=null),delete this.keyUriToKeyInfo[s],o&&o.destroy()}}class wy{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Sy={length:0,start:()=>0,end:()=>0};class $e{static isBuffered(t,e){try{if(t){const i=$e.getBuffered(t);for(let s=0;s<i.length;s++)if(e>=i.start(s)&&e<=i.end(s))return!0}}catch{}return!1}static bufferInfo(t,e,i){try{if(t){const s=$e.getBuffered(t),o=[];let c;for(c=0;c<s.length;c++)o.push({start:s.start(c),end:s.end(c)});return this.bufferedInfo(o,e,i)}}catch{}return{len:0,start:e,end:e,nextStart:void 0}}static bufferedInfo(t,e,i){e=Math.max(0,e),t.sort(function(p,g){return p.start-g.start||g.end-p.end});let s=[];if(i)for(let p=0;p<t.length;p++){const g=s.length;if(g){const v=s[g-1].end;t[p].start-v<i?t[p].end>v&&(s[g-1].end=t[p].end):s.push(t[p])}else s.push(t[p])}else s=t;let o=0,c,d=e,f=e;for(let p=0;p<s.length;p++){const g=s[p].start,v=s[p].end;if(e+i>=g&&e<v)d=g,f=v,o=f-e;else if(e+i<g){c=g;break}}return{len:o,start:d||0,end:f||0,nextStart:c}}static getBuffered(t){try{return t.buffered}catch(e){return Y.log("failed to get media.buffered",e),Sy}}}class Lc{constructor(t,e,i,s=0,o=-1,c=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing=Po(),this.buffering={audio:Po(),video:Po(),audiovideo:Po()},this.level=t,this.sn=e,this.id=i,this.size=s,this.part=o,this.partial=c}}function Po(){return{start:0,executeStart:0,executeEnd:0,end:0}}function G0(n,t){let e=null;for(let i=0,s=n.length;i<s;i++){const o=n[i];if(o&&o.cc===t){e=o;break}}return e}function Ry(n,t,e){return!!(t.details&&(e.endCC>e.startCC||n&&n.cc<e.startCC))}function _y(n,t,e=0){const i=n.fragments,s=t.fragments;if(!s.length||!i.length){Y.log("No fragments to align");return}const o=G0(i,s[0].cc);if(!o||o&&!o.startPTS){Y.log("No frag in previous level to align on");return}return o}function H0(n,t){if(n){const e=n.start+t;n.start=n.startPTS=e,n.endPTS=e+n.duration}}function Cc(n,t){const e=t.fragments;for(let i=0,s=e.length;i<s;i++)H0(e[i],n);t.fragmentHint&&H0(t.fragmentHint,n),t.alignedSliding=!0}function Ly(n,t,e){t&&(Cy(n,e,t),!e.alignedSliding&&t.details&&Iy(e,t.details),!e.alignedSliding&&t.details&&!e.skippedSegments&&x0(t.details,e))}function Cy(n,t,e){if(Ry(n,e,t)){const i=_y(e.details,t);i&&Wt(i.start)&&(Y.log(`Adjusting PTS using last level due to CC increase within current level ${t.url}`),Cc(i.start,t))}}function Iy(n,t){if(!t.fragments.length||!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=t.fragments[0].programDateTime,i=n.fragments[0].programDateTime,s=(i-e)/1e3+t.fragments[0].start;s&&Wt(s)&&(Y.log(`Adjusting PTS using programDateTime delta ${i-e}ms, sliding:${s.toFixed(3)} ${n.url} `),Cc(s,n))}function V0(n,t){if(!n.hasProgramDateTime||!t.hasProgramDateTime)return;const e=n.fragments,i=t.fragments;if(!e.length||!i.length)return;const s=Math.round(i.length/2)-1,o=i[s],c=G0(e,o.cc)||e[Math.round(e.length/2)-1],d=o.programDateTime,f=c.programDateTime;if(d===null||f===null)return;const p=(f-d)/1e3-(c.start-o.start);Cc(p,n)}class xy{constructor(t,e){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=e}decrypt(t,e){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t)}}class Dy{constructor(t,e){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=e}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Py(n){const t=n.byteLength,e=t&&new DataView(n.buffer).getUint8(t-1);return e?on(n,0,t-e):n}class Oy{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let s=0;s<4;s++)i[s]=e.getUint32(s*4);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],o=i[1],c=i[2],d=i[3],f=this.invSubMix,p=f[0],g=f[1],v=f[2],b=f[3],E=new Uint32Array(256);let T=0,w=0,C=0;for(C=0;C<256;C++)C<128?E[C]=C<<1:E[C]=C<<1^283;for(C=0;C<256;C++){let D=w^w<<1^w<<2^w<<3^w<<4;D=D>>>8^D&255^99,t[T]=D,e[D]=T;const O=E[T],F=E[O],x=E[F];let N=E[D]*257^D*16843008;s[T]=N<<24|N>>>8,o[T]=N<<16|N>>>16,c[T]=N<<8|N>>>24,d[T]=N,N=x*16843009^F*65537^O*257^T*16843008,p[D]=N<<24|N>>>8,g[D]=N<<16|N>>>16,v[D]=N<<8|N>>>24,b[D]=N,T?(T=O^E[E[E[x^O]]],w^=E[E[w]]):T=w=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let i=!0,s=0;for(;s<e.length&&i;)i=e[s]===this.key[s],s++;if(i)return;this.key=e;const o=this.keySize=e.length;if(o!==4&&o!==6&&o!==8)throw new Error("Invalid aes key size="+o);const c=this.ksRows=(o+6+1)*4;let d,f;const p=this.keySchedule=new Uint32Array(c),g=this.invKeySchedule=new Uint32Array(c),v=this.sBox,b=this.rcon,E=this.invSubMix,T=E[0],w=E[1],C=E[2],D=E[3];let O,F;for(d=0;d<c;d++){if(d<o){O=p[d]=e[d];continue}F=O,d%o===0?(F=F<<8|F>>>24,F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255],F^=b[d/o|0]<<24):o>6&&d%o===4&&(F=v[F>>>24]<<24|v[F>>>16&255]<<16|v[F>>>8&255]<<8|v[F&255]),p[d]=O=(p[d-o]^F)>>>0}for(f=0;f<c;f++)d=c-f,f&3?F=p[d]:F=p[d-4],f<4||d<=4?g[f]=F:g[f]=T[v[F>>>24]]^w[v[F>>>16&255]]^C[v[F>>>8&255]]^D[v[F&255]],g[f]=g[f]>>>0}networkToHostOrderSwap(t){return t<<24|(t&65280)<<8|(t&16711680)>>8|t>>>24}decrypt(t,e,i){const s=this.keySize+6,o=this.invKeySchedule,c=this.invSBox,d=this.invSubMix,f=d[0],p=d[1],g=d[2],v=d[3],b=this.uint8ArrayToUint32Array_(i);let E=b[0],T=b[1],w=b[2],C=b[3];const D=new Int32Array(t),O=new Int32Array(D.length);let F,x,N,H,j,nt,st,Q,kt,gt,Mt,Vt,V,J;const St=this.networkToHostOrderSwap;for(;e<D.length;){for(kt=St(D[e]),gt=St(D[e+1]),Mt=St(D[e+2]),Vt=St(D[e+3]),j=kt^o[0],nt=Vt^o[1],st=Mt^o[2],Q=gt^o[3],V=4,J=1;J<s;J++)F=f[j>>>24]^p[nt>>16&255]^g[st>>8&255]^v[Q&255]^o[V],x=f[nt>>>24]^p[st>>16&255]^g[Q>>8&255]^v[j&255]^o[V+1],N=f[st>>>24]^p[Q>>16&255]^g[j>>8&255]^v[nt&255]^o[V+2],H=f[Q>>>24]^p[j>>16&255]^g[nt>>8&255]^v[st&255]^o[V+3],j=F,nt=x,st=N,Q=H,V=V+4;F=c[j>>>24]<<24^c[nt>>16&255]<<16^c[st>>8&255]<<8^c[Q&255]^o[V],x=c[nt>>>24]<<24^c[st>>16&255]<<16^c[Q>>8&255]<<8^c[j&255]^o[V+1],N=c[st>>>24]<<24^c[Q>>16&255]<<16^c[j>>8&255]<<8^c[nt&255]^o[V+2],H=c[Q>>>24]<<24^c[j>>16&255]<<16^c[nt>>8&255]<<8^c[st&255]^o[V+3],O[e]=St(F^E),O[e+1]=St(H^T),O[e+2]=St(N^w),O[e+3]=St(x^C),E=kt,T=gt,w=Mt,C=Vt,e=e+4}return O.buffer}}const My=16;class Ic{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Py(i):i}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,i){return this.useSoftware?new Promise((s,o)=>{this.softwareDecrypt(new Uint8Array(t),e,i);const c=this.flush();c?s(c.buffer):o(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,i)}softwareDecrypt(t,e,i){const{currentIV:s,currentResult:o,remainderData:c}=this;this.logOnce("JS AES decrypt"),c&&(t=ln(c,t),this.remainderData=null);const d=this.getValidChunk(t);if(!d.length)return null;s&&(i=s);let f=this.softwareDecrypter;f||(f=this.softwareDecrypter=new Oy),f.expandKey(e);const p=o;return this.currentResult=f.decrypt(d.buffer,0,i),this.currentIV=on(d,-16).buffer,p||null}webCryptoDecrypt(t,e,i){const s=this.subtle;return(this.key!==e||!this.fastAesKey)&&(this.key=e,this.fastAesKey=new Dy(s,e)),this.fastAesKey.expandKey().then(o=>s?(this.logOnce("WebCrypto AES decrypt"),new xy(s,new Uint8Array(i)).decrypt(t.buffer,o)):Promise.reject(new Error("web crypto not initialized"))).catch(o=>(Y.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${o.name}: ${o.message}`),this.onWebCryptoError(t,e,i)))}onWebCryptoError(t,e,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,i);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(t){let e=t;const i=t.length-t.length%My;return i!==t.length&&(e=on(t,0,i),this.remainderData=on(t,i)),e}logOnce(t){this.logEnabled&&(Y.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const $y={toString:function(n){let t="";const e=n.length;for(let i=0;i<e;i++)t+=`[${n.start(i).toFixed(3)}-${n.end(i).toFixed(3)}]`;return t}},Tt={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class xc extends wy{constructor(t,e,i,s,o){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=Tt.STOPPED,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=o,this.logPrefix=s,this.log=Y.log.bind(Y,`${s}:`),this.warn=Y.warn.bind(Y,`${s}:`),this.hls=t,this.fragmentLoader=new Ty(t.config),this.keyLoader=i,this.fragmentTracker=e,this.config=t.config,this.decrypter=new Ic(t.config),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;t!=null&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=Tt.STOPPED}_streamEnded(t,e){if(e.live||t.nextStart||!t.end||!this.media)return!1;const i=e.partList;if(i!=null&&i.length){const o=i[i.length-1];return $e.isBuffered(this.media,o.start+o.duration/2)}const s=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var t;return(t=this.levels[this.levelLastLoaded])==null?void 0:t.details}}onMediaAttached(t,e){const i=this.media=this.mediaBuffer=e.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),i.addEventListener("seeking",this.onvseeking),i.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===Tt.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const t=this.media;t!=null&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&this.onvseeking&&this.onvended&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:t,fragCurrent:e,media:i,mediaBuffer:s,state:o}=this,c=i?i.currentTime:0,d=$e.bufferInfo(s||i,c,t.maxBufferHole);if(this.log(`media seeking to ${Wt(c)?c.toFixed(3):c}, state: ${o}`),this.state===Tt.ENDED)this.resetLoadingState();else if(e){const f=t.maxFragLookUpTolerance,p=e.start-f,g=e.start+e.duration+f;if(!d.len||g<d.start||p>d.end){const v=c>g;(c<p||v)&&(v&&e.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}i&&(this.fragmentTracker.removeFragmentsInRange(c,1/0,this.playlistType,!0),this.lastCurrentTime=c),!this.loadedmetadata&&!d.len&&(this.nextLoadPosition=this.startPosition=c),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=Tt.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,i){this._loadFragForPlayback(t,e,i)}_loadFragForPlayback(t,e,i){const s=o=>{if(this.fragContextChanged(t)){this.warn(`Fragment ${t.sn}${o.part?" p: "+o.part.index:""} of level ${t.level} was dropped during download.`),this.fragmentTracker.removeFragment(t);return}t.stats.chunkCount++,this._handleFragmentLoadProgress(o)};this._doFragLoad(t,e,i,s).then(o=>{if(!o)return;const c=this.state;if(this.fragContextChanged(t)){(c===Tt.FRAG_LOADING||!this.fragCurrent&&c===Tt.PARSING)&&(this.fragmentTracker.removeFragment(t),this.state=Tt.IDLE);return}"payload"in o&&(this.log(`Loaded fragment ${t.sn} of level ${t.level}`),this.hls.trigger(R.FRAG_LOADED,o)),this._handleFragmentLoadComplete(o)}).catch(o=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(o),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:i}=this;if(i.getState(t)===ui.APPENDING){const s=t.type,o=this.getFwdBufferInfo(this.mediaBuffer,s),c=Math.max(t.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(c)&&i.removeFragment(t)}else((e=this.mediaBuffer)==null?void 0:e.buffered.length)===0?i.removeAllFragments():i.hasParts(t.type)&&(i.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),i.getState(t)===ui.PARTIAL&&i.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}flushMainBuffer(t,e,i=null){if(!(t-e))return;const s={startOffset:t,endOffset:e,type:i};this.hls.trigger(R.BUFFER_FLUSHING,s)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(i=>{if(!i||this.fragContextChanged(t)||!this.levels)throw new Error("init load aborted");return i}).then(i=>{const{hls:s}=this,{payload:o}=i,c=t.decryptdata;if(o&&o.byteLength>0&&c&&c.key&&c.iv&&c.method==="AES-128"){const d=self.performance.now();return this.decrypter.decrypt(new Uint8Array(o),c.key.buffer,c.iv.buffer).catch(f=>{throw s.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_DECRYPT_ERROR,fatal:!1,error:f,reason:f.message,frag:t}),f}).then(f=>{const p=self.performance.now();return s.trigger(R.FRAG_DECRYPTED,{frag:t,payload:f,stats:{tstart:d,tdecrypt:p}}),i.payload=f,i})}return i}).then(i=>{const{fragCurrent:s,hls:o,levels:c}=this;if(!c)throw new Error("init load aborted, missing levels");const d=t.stats;this.state=Tt.IDLE,e.fragmentError=0,t.data=new Uint8Array(i.payload),d.parsing.start=d.buffering.start=self.performance.now(),d.parsing.end=d.buffering.end=self.performance.now(),i.frag===s&&o.trigger(R.FRAG_BUFFERED,{stats:d,frag:s,part:null,id:t.type}),this.tick()}).catch(i=>{this.state===Tt.STOPPED||this.state===Tt.ERROR||(this.warn(i),this.resetFragmentLoading(t))})}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId}fragBufferedComplete(t,e){var i,s,o,c;const d=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.playlistType===Jt.MAIN?"level":"track"} ${t.level} (frag:[${((i=t.startPTS)!=null?i:NaN).toFixed(3)}-${((s=t.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${d?$y.toString($e.getBuffered(d)):"(detached)"})`),this.state=Tt.IDLE,d&&(!this.loadedmetadata&&t.type==Jt.MAIN&&d.buffered.length&&((o=this.fragCurrent)==null?void 0:o.sn)===((c=this.fragPrevious)==null?void 0:c.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:i,part:s,partsLoaded:o}=t,c=!o||o.length===0||o.some(f=>!f),d=new Lc(i.level,i.sn,i.stats.chunkCount+1,0,s?s.index:-1,!c);e.flush(d)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,i=null,s){var o;const c=e==null?void 0:e.details;if(!this.levels||!c)throw new Error(`frag load aborted, missing level${c?"":" detail"}s`);let d=null;if(t.encrypted&&!((o=t.decryptdata)!=null&&o.key)?(this.log(`Loading key for ${t.sn} of [${c.startSN}-${c.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${t.level}`),this.state=Tt.KEY_LOADING,this.fragCurrent=t,d=this.keyLoader.load(t).then(g=>{if(!this.fragContextChanged(g.frag))return this.hls.trigger(R.KEY_LOADED,g),this.state===Tt.KEY_LOADING&&(this.state=Tt.IDLE),g}),this.hls.trigger(R.KEY_LOADING,{frag:t}),this.fragCurrent===null&&(d=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!t.encrypted&&c.encryptedFragments.length&&this.keyLoader.loadClear(t,c.encryptedFragments),i=Math.max(t.start,i||0),this.config.lowLatencyMode&&t.sn!=="initSegment"){const g=c.partList;if(g&&s){i>t.end&&c.fragmentHint&&(t=c.fragmentHint);const v=this.getNextPart(g,t,i);if(v>-1){const b=g[v];this.log(`Loading part sn: ${t.sn} p: ${b.index} cc: ${t.cc} of playlist [${c.startSN}-${c.endSN}] parts [0-${v}-${g.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),this.nextLoadPosition=b.start+b.duration,this.state=Tt.FRAG_LOADING;let E;return d?E=d.then(T=>!T||this.fragContextChanged(T.frag)?null:this.doFragPartsLoad(t,b,e,s)).catch(T=>this.handleFragLoadError(T)):E=this.doFragPartsLoad(t,b,e,s).catch(T=>this.handleFragLoadError(T)),this.hls.trigger(R.FRAG_LOADING,{frag:t,part:b,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):E}else if(!t.url||this.loadedEndOfParts(g,i))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${c?"of ["+c.startSN+"-"+c.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${t.level}, target: ${parseFloat(i.toFixed(3))}`),Wt(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Tt.FRAG_LOADING;const f=this.config.progressive;let p;return f&&d?p=d.then(g=>!g||this.fragContextChanged(g==null?void 0:g.frag)?null:this.fragmentLoader.load(t,s)).catch(g=>this.handleFragLoadError(g)):p=Promise.all([this.fragmentLoader.load(t,f?s:void 0),d]).then(([g])=>(!f&&g&&s&&s(g),g)).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(R.FRAG_LOADING,{frag:t,targetBufferTime:i}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):p}doFragPartsLoad(t,e,i,s){return new Promise((o,c)=>{var d;const f=[],p=(d=i.details)==null?void 0:d.partList,g=v=>{this.fragmentLoader.loadPart(t,v,s).then(b=>{f[v.index]=b;const E=b.part;this.hls.trigger(R.FRAG_LOADED,b);const T=D0(i,t.sn,v.index+1)||P0(p,t.sn,v.index+1);if(T)g(T);else return o({frag:t,part:E,partsLoaded:f})}).catch(c)};g(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;t.data&&e.details===ut.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(R.ERROR,e)}else this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==Tt.PARSING){!this.fragCurrent&&this.state!==Tt.STOPPED&&this.state!==Tt.ERROR&&(this.state=Tt.IDLE);return}const{frag:i,part:s,level:o}=e,c=self.performance.now();i.stats.parsing.end=c,s&&(s.stats.parsing.end=c),this.updateLevelTiming(i,s,o,t.partial)}getCurrentContext(t){const{levels:e,fragCurrent:i}=this,{level:s,sn:o,part:c}=t;if(!(e!=null&&e[s]))return this.warn(`Levels object was unset while buffering fragment ${o} of level ${s}. The current chunk will not be buffered.`),null;const d=e[s],f=c>-1?D0(d,o,c):null,p=f?f.fragment:uy(d,o,i);return p?(i&&i!==p&&(p.stats=i.stats),{frag:p,part:f,level:d}):null}bufferFragmentData(t,e,i,s,o){var c;if(!t||this.state!==Tt.PARSING)return;const{data1:d,data2:f}=t;let p=d;if(d&&f&&(p=ln(d,f)),!((c=p)!=null&&c.length))return;const g={type:t.type,frag:e,part:i,chunkMeta:s,parent:e.type,data:p};if(this.hls.trigger(R.BUFFER_APPENDING,g),t.dropped&&t.independent&&!i){if(o)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!$e.isBuffered(e,e.currentTime)){this.flushMainBuffer(0,t.start);return}const i=e.currentTime,s=$e.bufferInfo(e,i,0),o=t.duration,c=Math.min(this.config.maxFragLookUpTolerance*2,o*.25),d=Math.max(Math.min(t.start-c,s.end-c),i+c);t.start-d>c&&this.flushMainBuffer(d,t.start)}getFwdBufferInfo(t,e){const i=this.getLoadPosition();return Wt(i)?this.getFwdBufferInfoAtPos(t,i,e):null}getFwdBufferInfoAtPos(t,e,i){const{config:{maxBufferHole:s}}=this,o=$e.bufferInfo(t,e,s);if(o.len===0&&o.nextStart!==void 0){const c=this.fragmentTracker.getBufferedFrag(e,i);if(c&&o.nextStart<c.end)return $e.bufferInfo(t,e,Math.max(o.nextStart,s))}return o}getMaxBufferLength(t){const{config:e}=this;let i;return t?i=Math.max(8*e.maxBufferSize/t,e.maxBufferLength):i=e.maxBufferLength,Math.min(i,e.maxMaxBufferLength)}reduceMaxBufferLength(t){const e=this.config,i=t||e.maxBufferLength;return e.maxMaxBufferLength>=i?(e.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${e.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(t,e=Jt.MAIN){const i=this.fragmentTracker.getAppendedFrag(t,Jt.MAIN);return i&&"fragment"in i?i.fragment:i}getNextFragment(t,e){const i=e.fragments,s=i.length;if(!s)return null;const{config:o}=this,c=i[0].start;let d;if(e.live){const f=o.initialLiveManifestSize;if(s<f)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${f})`),null;!e.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(d=this.getInitialLiveFragment(e,i),this.startPosition=d?this.hls.liveSyncPosition||d.start:t)}else t<=c&&(d=i[0]);if(!d){const f=o.lowLatencyMode?e.partEnd:e.fragmentEnd;d=this.getFragmentAtPosition(t,f,e)}return this.mapToInitFragWhenRequired(d)}isLoopLoading(t,e){const i=this.fragmentTracker.getState(t);return(i===ui.OK||i===ui.PARTIAL&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,i,s,o){const c=t.gap,d=this.getNextFragment(this.nextLoadPosition,e);if(d===null)return d;if(t=d,c&&t&&!t.gap&&i.nextStart){const f=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,i.nextStart,s);if(f!==null&&i.len+f.len>=o)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${t.sn}`),null}return t}mapToInitFragWhenRequired(t){return t!=null&&t.initSegment&&!(t!=null&&t.initSegment.data)&&!this.bitrateTest?t.initSegment:t}getNextPart(t,e,i){let s=-1,o=!1,c=!0;for(let d=0,f=t.length;d<f;d++){const p=t[d];if(c=c&&!p.independent,s>-1&&i<p.start)break;const g=p.loaded;g?s=-1:(o||p.independent||c)&&p.fragment===e&&(s=d),o=g}return s}loadedEndOfParts(t,e){const i=t[t.length-1];return i&&e>i.start&&i.loaded}getInitialLiveFragment(t,e){const i=this.fragPrevious;let s=null;if(i){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${i.programDateTime}`),s=py(e,i.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const o=i.sn+1;if(o>=t.startSN&&o<=t.endSN){const c=e[o-t.startSN];i.cc===c.cc&&(s=c,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=my(e,i.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const o=this.hls.liveSyncPosition;o!==null&&(s=this.getFragmentAtPosition(o,this.bitrateTest?t.fragmentEnd:t.edge,t))}return s}getFragmentAtPosition(t,e,i){const{config:s}=this;let{fragPrevious:o}=this,{fragments:c,endSN:d}=i;const{fragmentHint:f}=i,p=s.maxFragLookUpTolerance,g=i.partList,v=!!(s.lowLatencyMode&&g!=null&&g.length&&f);v&&f&&!this.bitrateTest&&(c=c.concat(f),d=f.sn);let b;if(t<e){const E=t>e-p?0:p;b=_a(o,c,t,E)}else b=c[c.length-1];if(b){const E=b.sn-i.startSN,T=this.fragmentTracker.getState(b);if((T===ui.OK||T===ui.PARTIAL&&b.gap)&&(o=b),o&&b.sn===o.sn&&(!v||g[0].fragment.sn>b.sn)&&o&&b.level===o.level){const w=c[E+1];b.sn<d&&this.fragmentTracker.getState(w)!==ui.OK?b=w:b=null}}return b}synchronizeToLiveEdge(t){const{config:e,media:i}=this;if(!i)return;const s=this.hls.liveSyncPosition,o=i.currentTime,c=t.fragments[0].start,d=t.edge,f=o>=c-e.maxFragLookUpTolerance&&o<=d;if(s!==null&&i.duration>s&&(o<s||!f)){const p=e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;(!f&&i.readyState<4||o<d-p)&&(this.loadedmetadata||(this.nextLoadPosition=s),i.readyState&&(this.warn(`Playback: ${o.toFixed(3)} is located too far from the end of live sliding playlist: ${d}, reset currentTime to : ${s.toFixed(3)}`),i.currentTime=s))}}alignPlaylists(t,e){const{levels:i,levelLastLoaded:s,fragPrevious:o}=this,c=s!==null?i[s]:null,d=t.fragments.length;if(!d)return this.warn("No fragments in live playlist"),0;const f=t.fragments[0].start,p=!e,g=t.alignedSliding&&Wt(f);if(p||!g&&!f){Ly(o,c,t);const v=t.fragments[0].start;return this.log(`Live playlist sliding: ${v.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} prev-sn: ${o?o.sn:"na"} fragments: ${d}`),v}return f}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,t.partTarget*3)}setStartPosition(t,e){let i=this.startPosition;if(i<e&&(i=-1),i===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,o=s?this.startTimeOffset:t.startTimeOffset;o!==null&&Wt(o)?(i=e+o,o<0&&(i+=t.totalduration),i=Math.min(Math.max(e,i),e+t.totalduration),this.log(`Start time offset ${o} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${i}`),this.startPosition=i):t.live?i=this.hls.liveSyncPosition||e:this.startPosition=i=0,this.lastCurrentTime=i}this.nextLoadPosition=i}getLoadPosition(){const{media:t}=this;let e=0;return this.loadedmetadata&&t?e=t.currentTime:this.nextLoadPosition&&(e=this.nextLoadPosition),e}handleFragLoadAborted(t,e){this.transmuxer&&t.sn!=="initSegment"&&t.stats.aborted&&(this.warn(`Fragment ${t.sn}${e?" part "+e.index:""} of level ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){(!this.fragCurrent||!this.fragContextChanged(t)&&this.state!==Tt.FRAG_LOADING_WAITING_RETRY)&&(this.state=Tt.IDLE)}onFragmentOrKeyLoadError(t,e){if(e.chunkMeta&&!e.frag){const v=this.getCurrentContext(e.chunkMeta);v&&(e.frag=v.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;if(this.fragContextChanged(i)){var s;this.warn(`Frag load error must match current frag to retry ${i.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const o=e.details===ut.FRAG_GAP;o&&this.fragmentTracker.fragBuffered(i,!0);const c=e.errorAction,{action:d,retryCount:f=0,retryConfig:p}=c||{};if(c&&d===Ri.RetryRequest&&p){var g;this.resetStartWhenNotLoaded((g=this.levelLastLoaded)!=null?g:i.level);const v=wc(p,f);this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${f+1}/${p.maxNumRetry} in ${v}ms`),c.resolved=!0,this.retryDate=self.performance.now()+v,this.state=Tt.FRAG_LOADING_WAITING_RETRY}else p&&c?(this.resetFragmentErrors(t),f<p.maxNumRetry?o||(c.resolved=!0):Y.warn(`${e.details} reached or exceeded max retry (${f})`)):(c==null?void 0:c.action)===Ri.SendAlternateToPenaltyBox?this.state=Tt.WAITING_LEVEL:this.state=Tt.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(t){if(this.state===Tt.PARSING||this.state===Tt.PARSED){const e=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,e),s=i&&i.len>.5;s&&this.reduceMaxBufferLength(i.len);const o=!s;return o&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${e} buffer`),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),o}return!1}resetFragmentErrors(t){t===Jt.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Tt.STOPPED&&(this.state=Tt.IDLE)}afterBufferFlushed(t,e,i){if(!t)return;const s=$e.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,s,i),this.state===Tt.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Tt.IDLE}resetStartWhenNotLoaded(t){if(!this.loadedmetadata){this.startFragRequested=!1;const e=this.levels?this.levels[t].details:null;e!=null&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){var e;this.warn(`The loading context changed while buffering fragment ${t.sn} of level ${t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((e=this.levelLastLoaded)!=null?e:t.level),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,i,s){var o;const c=i.details;if(!c){this.warn("level.details undefined");return}if(Object.keys(t.elementaryStreams).reduce((d,f)=>{const p=t.elementaryStreams[f];if(p){const g=p.endPTS-p.startPTS;if(g<=0)return this.warn(`Could not parse fragment ${t.sn} ${f} duration reliably (${g})`),d||!1;const v=s?0:I0(c,t,p.startPTS,p.endPTS,p.startDTS,p.endDTS);return this.hls.trigger(R.LEVEL_PTS_UPDATED,{details:c,level:i,drift:v,type:f,frag:t,start:p.startPTS,end:p.endPTS}),!0}return d},!1))i.fragmentError=0;else if(((o=this.transmuxer)==null?void 0:o.error)===null){const d=new Error(`Found no media in fragment ${t.sn} of level ${t.level} resetting transmuxer to fallback to playlist timing`);if(i.fragmentError===0&&(i.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(d.message),this.hls.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:d,frag:t,reason:`Found no media in msn ${t.sn} of level "${i.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=Tt.PARSED,this.hls.trigger(R.FRAG_PARSED,{frag:t,part:e})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(t){if(t.event==="demuxerWorker"){var e,i,s;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((e=(i=this.levelLastLoaded)!=null?i:(s=this.fragCurrent)==null?void 0:s.level)!=null?e:0),this.resetLoadingState()}}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function W0(){return self.SourceBuffer||self.WebKitSourceBuffer}function Ny(){const n=_o();if(!n)return!1;const t=W0(),e=n&&typeof n.isTypeSupported=="function"&&n.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&typeof t.prototype.appendBuffer=="function"&&typeof t.prototype.remove=="function";return!!e&&!!i}function Fy(){var n;const t=W0();return typeof(t==null||(n=t.prototype)==null?void 0:n.changeType)=="function"}function Uy(){return typeof __HLS_WORKER_BUNDLE__=="function"}function By(){const n=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(n);return{worker:new self.Worker(t),objectURL:t}}function Gy(n){const t=new self.URL(n,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}function Mr(n="",t=9e4){return{type:n,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class j0{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,i,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,i){}demux(t,e){this.cachedData&&(t=ln(this.cachedData,t),this.cachedData=null);let i=ko(t,0),s=i?i.length:0,o;const c=this._audioTrack,d=this._id3Track,f=i?kv(i):void 0,p=t.length;for((this.basePTS===null||this.frameIndex===0&&Wt(f))&&(this.basePTS=Hy(f,e,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),i&&i.length>0&&d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY});s<p;){if(this.canParse(t,s)){const g=this.appendFrame(c,t,s);g?(this.frameIndex++,this.lastPTS=g.sample.pts,s+=g.length,o=s):s=p}else Tv(t,s)?(i=ko(t,s),d.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ar.audioId3,duration:Number.POSITIVE_INFINITY}),s+=i.length,o=s):s++;if(s===p&&o!==p){const g=on(t,o);this.cachedData?this.cachedData=ln(this.cachedData,g):this.cachedData=g}}return{audioTrack:c,videoTrack:Mr(),id3Track:d,textTrack:Mr()}}demuxSampleAes(t,e,i){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Mr(),id3Track:this._id3Track,textTrack:Mr()}}destroy(){}}const Hy=(n,t,e)=>{if(Wt(n))return n*90;const i=e?e.baseTime*9e4/e.timescale:0;return t*9e4+i};function Vy(n,t,e,i){let s,o,c,d;const f=navigator.userAgent.toLowerCase(),p=i,g=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((t[e+2]&192)>>>6)+1;const v=(t[e+2]&60)>>>2;if(v>g.length-1){n.trigger(R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${v}`});return}return c=(t[e+2]&1)<<2,c|=(t[e+3]&192)>>>6,Y.log(`manifest codec:${i}, ADTS type:${s}, samplingIndex:${v}`),/firefox/i.test(f)?v>=6?(s=5,d=new Array(4),o=v-3):(s=2,d=new Array(2),o=v):f.indexOf("android")!==-1?(s=2,d=new Array(2),o=v):(s=5,d=new Array(4),i&&(i.indexOf("mp4a.40.29")!==-1||i.indexOf("mp4a.40.5")!==-1)||!i&&v>=6?o=v-3:((i&&i.indexOf("mp4a.40.2")!==-1&&(v>=6&&c===1||/vivaldi/i.test(f))||!i&&c===1)&&(s=2,d=new Array(2)),o=v)),d[0]=s<<3,d[0]|=(v&14)>>1,d[1]|=(v&1)<<7,d[1]|=c<<3,s===5&&(d[1]|=(o&14)>>1,d[2]=(o&1)<<7,d[2]|=8,d[3]=0),{config:d,samplerate:g[v],channelCount:c,codec:"mp4a.40."+s,manifestCodec:p}}function K0(n,t){return n[t]===255&&(n[t+1]&246)===240}function z0(n,t){return n[t+1]&1?7:9}function Dc(n,t){return(n[t+3]&3)<<11|n[t+4]<<3|(n[t+5]&224)>>>5}function Wy(n,t){return t+5<n.length}function Oo(n,t){return t+1<n.length&&K0(n,t)}function jy(n,t){return Wy(n,t)&&K0(n,t)&&Dc(n,t)<=n.length-t}function Ky(n,t){if(Oo(n,t)){const e=z0(n,t);if(t+e>=n.length)return!1;const i=Dc(n,t);if(i<=e)return!1;const s=t+i;return s===n.length||Oo(n,s)}return!1}function Y0(n,t,e,i,s){if(!n.samplerate){const o=Vy(t,e,i,s);if(!o)return;n.config=o.config,n.samplerate=o.samplerate,n.channelCount=o.channelCount,n.codec=o.codec,n.manifestCodec=o.manifestCodec,Y.log(`parsed codec:${n.codec}, rate:${o.samplerate}, channels:${o.channelCount}`)}}function X0(n){return 9216e4/n}function zy(n,t){const e=z0(n,t);if(t+e<=n.length){const i=Dc(n,t)-e;if(i>0)return{headerLength:e,frameLength:i}}}function Z0(n,t,e,i,s){const o=X0(n.samplerate),c=i+s*o,d=zy(t,e);let f;if(d){const{frameLength:g,headerLength:v}=d,b=v+g,E=Math.max(0,e+b-t.length);E?(f=new Uint8Array(b-v),f.set(t.subarray(e+v,t.length),0)):f=t.subarray(e+v,e+b);const T={unit:f,pts:c};return E||n.samples.push(T),{sample:T,length:b,missing:E}}const p=t.length-e;return f=new Uint8Array(p),f.set(t.subarray(e,t.length),0),{sample:{unit:f,pts:c},length:p,missing:-1}}class Yy extends j0{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ko(t,0)||[]).length;for(let i=t.length;e<i;e++)if(Ky(t,e))return Y.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return jy(t,e)}appendFrame(t,e,i){Y0(t,this.observer,e,i,t.manifestCodec);const s=Z0(t,e,i,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const Xy=/\/emsg[-/]ID3/i;class Zy{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,i,s){const o=this.videoTrack=Mr("video",1),c=this.audioTrack=Mr("audio",1),d=this.txtTrack=Mr("text",1);if(this.id3Track=Mr("id3",1),this.timeOffset=0,!(t!=null&&t.byteLength))return;const f=l0(t);if(f.video){const{id:p,timescale:g,codec:v}=f.video;o.id=p,o.timescale=d.timescale=g,o.codec=v}if(f.audio){const{id:p,timescale:g,codec:v}=f.audio;c.id=p,c.timescale=g,c.codec=v}d.id=n0.text,o.sampleDuration=0,o.duration=c.duration=s}resetContiguity(){this.remainderData=null}static probe(t){return t=t.length>16384?t.subarray(0,16384):t,ye(t,["moof"]).length>0}demux(t,e){this.timeOffset=e;let i=t;const s=this.videoTrack,o=this.txtTrack;if(this.config.progressive){this.remainderData&&(i=ln(this.remainderData,t));const d=Fv(i);this.remainderData=d.remainder,s.samples=d.valid||new Uint8Array}else s.samples=i;const c=this.extractID3Track(s,e);return o.samples=h0(e,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:c,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,i=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(e,this.timeOffset);return i.samples=h0(t,e),{videoTrack:e,audioTrack:Mr(),id3Track:s,textTrack:Mr()}}extractID3Track(t,e){const i=this.id3Track;if(t.samples.length){const s=ye(t.samples,["emsg"]);s&&s.forEach(o=>{const c=Gv(o);if(Xy.test(c.schemeIdUri)){const d=Wt(c.presentationTime)?c.presentationTime/c.timeScale:e+c.presentationTimeDelta/c.timeScale;let f=c.eventDuration===4294967295?Number.POSITIVE_INFINITY:c.eventDuration/c.timeScale;f<=.001&&(f=Number.POSITIVE_INFINITY);const p=c.payload;i.samples.push({data:p,len:p.byteLength,dts:d,pts:d,type:Ar.emsg,duration:f})}})}return i}demuxSampleAes(t,e,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Mo=null;const qy=[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],Qy=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Jy=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],tb=[0,1,1,4];function q0(n,t,e,i,s){if(e+24>t.length)return;const o=Q0(t,e);if(o&&e+o.frameLength<=t.length){const c=o.samplesPerFrame*9e4/o.sampleRate,d=i+s*c,f={unit:t.subarray(e,e+o.frameLength),pts:d,dts:d};return n.config=[],n.channelCount=o.channelCount,n.samplerate=o.sampleRate,n.samples.push(f),{sample:f,length:o.frameLength,missing:0}}}function Q0(n,t){const e=n[t+1]>>3&3,i=n[t+1]>>1&3,s=n[t+2]>>4&15,o=n[t+2]>>2&3;if(e!==1&&s!==0&&s!==15&&o!==3){const c=n[t+2]>>1&1,d=n[t+3]>>6,f=e===3?3-i:i===3?3:4,p=qy[f*14+s-1]*1e3,g=Qy[(e===3?0:e===2?1:2)*3+o],v=d===3?1:2,b=Jy[e][i],E=tb[i],T=b*8*E,w=Math.floor(b*p/g+c)*E;if(Mo===null){const C=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Mo=C?parseInt(C[1]):0}return Mo&&Mo<=87&&i===2&&p>=224e3&&d===0&&(n[t+3]=n[t+3]|128),{sampleRate:g,channelCount:v,frameLength:w,samplesPerFrame:T}}}function Pc(n,t){return n[t]===255&&(n[t+1]&224)===224&&(n[t+1]&6)!==0}function J0(n,t){return t+1<n.length&&Pc(n,t)}function eb(n,t){return Pc(n,t)&&4<=n.length-t}function ib(n,t){if(t+1<n.length&&Pc(n,t)){const e=Q0(n,t);let i=4;e!=null&&e.frameLength&&(i=e.frameLength);const s=t+i;return s===n.length||J0(n,s)}return!1}class tf{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,i=t.byteLength-e,s=new Uint8Array(4),o=Math.min(4,e);if(o===0)throw new Error("no bytes available");s.set(t.subarray(i,i+o)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=o*8,this.bytesAvailable-=o}skipBits(t){let e;t=Math.min(t,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,e=t>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const i=this.word>>>32-e;if(t>32&&Y.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return e=t-e,e>0&&this.bitsAvailable?i<<e|this.readBits(e):i}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let e=8,i=8,s;for(let o=0;o<t;o++)i!==0&&(s=this.readEG(),i=(e+s+256)%256),e=i===0?e:i}readSPS(){let t=0,e=0,i=0,s=0,o,c,d;const f=this.readUByte.bind(this),p=this.readBits.bind(this),g=this.readUEG.bind(this),v=this.readBoolean.bind(this),b=this.skipBits.bind(this),E=this.skipEG.bind(this),T=this.skipUEG.bind(this),w=this.skipScalingList.bind(this);f();const C=f();if(p(5),b(3),f(),T(),C===100||C===110||C===122||C===244||C===44||C===83||C===86||C===118||C===128){const H=g();if(H===3&&b(1),T(),T(),b(1),v())for(c=H!==3?8:12,d=0;d<c;d++)v()&&(d<6?w(16):w(64))}T();const D=g();if(D===0)g();else if(D===1)for(b(1),E(),E(),o=g(),d=0;d<o;d++)E();T(),b(1);const O=g(),F=g(),x=p(1);x===0&&b(1),b(1),v()&&(t=g(),e=g(),i=g(),s=g());let N=[1,1];if(v()&&v())switch(f()){case 1:N=[1,1];break;case 2:N=[12,11];break;case 3:N=[10,11];break;case 4:N=[16,11];break;case 5:N=[40,33];break;case 6:N=[24,11];break;case 7:N=[20,11];break;case 8:N=[32,11];break;case 9:N=[80,33];break;case 10:N=[18,11];break;case 11:N=[15,11];break;case 12:N=[64,33];break;case 13:N=[160,99];break;case 14:N=[4,3];break;case 15:N=[3,2];break;case 16:N=[2,1];break;case 255:{N=[f()<<8|f(),f()<<8|f()];break}}return{width:Math.ceil((O+1)*16-t*2-e*2),height:(2-x)*(F+1)*16-(x?2:4)*(i+s),pixelRatio:N}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class rb{constructor(t,e,i){this.keyData=void 0,this.decrypter=void 0,this.keyData=i,this.decrypter=new Ic(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(t,e,i){const s=t[e].unit;if(s.length<=16)return;const o=s.subarray(16,s.length-s.length%16),c=o.buffer.slice(o.byteOffset,o.byteOffset+o.length);this.decryptBuffer(c).then(d=>{const f=new Uint8Array(d);s.set(f,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,i)})}decryptAacSamples(t,e,i){for(;;e++){if(e>=t.length){i();return}if(!(t[e].unit.length<32)&&(this.decryptAacSample(t,e,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){const e=Math.floor((t.length-48)/160)*16+16,i=new Int8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)i.set(t.subarray(o,o+16),s);return i}getAvcDecryptedUnit(t,e){const i=new Uint8Array(e);let s=0;for(let o=32;o<t.length-16;o+=160,s+=16)t.set(i.subarray(s,s+16),o);return t}decryptAvcSample(t,e,i,s,o){const c=u0(o.data),d=this.getAvcEncryptedData(c);this.decryptBuffer(d.buffer).then(f=>{o.data=this.getAvcDecryptedUnit(c,f),this.decrypter.isSync()||this.decryptAvcSamples(t,e,i+1,s)})}decryptAvcSamples(t,e,i,s){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,i=0){if(e>=t.length){s();return}const o=t[e].units;for(;!(i>=o.length);i++){const c=o[i];if(!(c.data.length<=48||c.type!==1&&c.type!==5)&&(this.decryptAvcSample(t,e,i,s,c),!this.decrypter.isSync()))return}}}}const _i=188;class Es{constructor(t,e,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=i}static probe(t){const e=Es.syncOffset(t);return e>0&&Y.warn(`MPEG2-TS detected but first sync word found @ offset ${e}`),e!==-1}static syncOffset(t){const e=t.length;let i=Math.min(_i*5,t.length-_i)+1,s=0;for(;s<i;){let o=!1,c=-1,d=0;for(let f=s;f<e;f+=_i)if(t[f]===71){if(d++,c===-1&&(c=f,c!==0&&(i=Math.min(c+_i*99,t.length-_i)+1)),o||(o=Oc(t,f)===0),o&&d>1&&(c===0&&d>2||f+_i>i))return c}else{if(d)return-1;break}s++}return-1}static createTrack(t,e){return{container:t==="video"||t==="audio"?"video/mp2t":void 0,type:t,id:n0[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:t==="audio"?e:void 0}}resetInitSegment(t,e,i,s){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Es.createTrack("video"),this._audioTrack=Es.createTrack("audio",s),this._id3Track=Es.createTrack("id3"),this._txtTrack=Es.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=i,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_avcTrack:e,_id3Track:i}=this;t&&(t.pesData=null),e&&(e.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(t,e,i=!1,s=!1){i||(this.sampleAes=null);let o;const c=this._avcTrack,d=this._audioTrack,f=this._id3Track,p=this._txtTrack;let g=c.pid,v=c.pesData,b=d.pid,E=f.pid,T=d.pesData,w=f.pesData,C=null,D=this.pmtParsed,O=this._pmtId,F=t.length;if(this.remainderData&&(t=ln(this.remainderData,t),F=t.length,this.remainderData=null),F<_i&&!s)return this.remainderData=t,{audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};const x=Math.max(0,Es.syncOffset(t));F-=(F-x)%_i,F<t.byteLength&&!s&&(this.remainderData=new Uint8Array(t.buffer,F,t.buffer.byteLength-F));let N=0;for(let j=x;j<F;j+=_i)if(t[j]===71){const nt=!!(t[j+1]&64),st=Oc(t,j),Q=(t[j+3]&48)>>4;let kt;if(Q>1){if(kt=j+5+t[j+4],kt===j+_i)continue}else kt=j+4;switch(st){case g:nt&&(v&&(o=Ln(v))&&this.parseAVCPES(c,p,o,!1),v={data:[],size:0}),v&&(v.data.push(t.subarray(kt,j+_i)),v.size+=j+_i-kt);break;case b:if(nt){if(T&&(o=Ln(T)))switch(d.segmentCodec){case"aac":this.parseAACPES(d,o);break;case"mp3":this.parseMPEGPES(d,o);break}T={data:[],size:0}}T&&(T.data.push(t.subarray(kt,j+_i)),T.size+=j+_i-kt);break;case E:nt&&(w&&(o=Ln(w))&&this.parseID3PES(f,o),w={data:[],size:0}),w&&(w.data.push(t.subarray(kt,j+_i)),w.size+=j+_i-kt);break;case 0:nt&&(kt+=t[kt]+1),O=this._pmtId=sb(t,kt);break;case O:{nt&&(kt+=t[kt]+1);const gt=nb(t,kt,this.typeSupported,i);g=gt.avc,g>0&&(c.pid=g),b=gt.audio,b>0&&(d.pid=b,d.segmentCodec=gt.segmentCodec),E=gt.id3,E>0&&(f.pid=E),C!==null&&!D&&(Y.warn(`MPEG-TS PMT found at ${j} after unknown PID '${C}'. Backtracking to sync byte @${x} to parse all TS packets.`),C=null,j=x-188),D=this.pmtParsed=!0;break}case 17:case 8191:break;default:C=st;break}}else N++;if(N>0){const j=new Error(`Found ${N} TS packet/s that do not start with 0x47`);this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:j,reason:j.message})}c.pesData=v,d.pesData=T,f.pesData=w;const H={audioTrack:d,videoTrack:c,id3Track:f,textTrack:p};return s&&this.extractRemainingSamples(H),H}flush(){const{remainderData:t}=this;this.remainderData=null;let e;return t?e=this.demux(t,-1,!1,!0):e={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:i,id3Track:s,textTrack:o}=t,c=i.pesData,d=e.pesData,f=s.pesData;let p;if(c&&(p=Ln(c))?(this.parseAVCPES(i,o,p,!0),i.pesData=null):i.pesData=c,d&&(p=Ln(d))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,p);break;case"mp3":this.parseMPEGPES(e,p);break}e.pesData=null}else d!=null&&d.size&&Y.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=d;f&&(p=Ln(f))?(this.parseID3PES(s,p),s.pesData=null):s.pesData=f}demuxSampleAes(t,e,i){const s=this.demux(t,i,!0,!this.config.progressive),o=this.sampleAes=new rb(this.observer,this.config,e);return this.decrypt(s,o)}decrypt(t,e){return new Promise(i=>{const{audioTrack:s,videoTrack:o}=t;s.samples&&s.segmentCodec==="aac"?e.decryptAacSamples(s.samples,0,()=>{o.samples?e.decryptAvcSamples(o.samples,0,0,()=>{i(t)}):i(t)}):o.samples&&e.decryptAvcSamples(o.samples,0,0,()=>{i(t)})})}destroy(){this._duration=0}parseAVCPES(t,e,i,s){const o=this.parseAVCNALu(t,i.data);let c=this.avcSample,d,f=!1;i.data=null,c&&o.length&&!t.audFound&&(La(c,t),c=this.avcSample=$o(!1,i.pts,i.dts,"")),o.forEach(p=>{var g;switch(p.type){case 1:{let b=!1;d=!0;const E=p.data;if(f&&E.length>4){const T=new tf(E).readSliceType();(T===2||T===4||T===7||T===9)&&(b=!0)}if(b){var v;(v=c)!=null&&v.frame&&!c.key&&(La(c,t),c=this.avcSample=null)}c||(c=this.avcSample=$o(!0,i.pts,i.dts,"")),c.frame=!0,c.key=b;break}case 5:d=!0,(g=c)!=null&&g.frame&&!c.key&&(La(c,t),c=this.avcSample=null),c||(c=this.avcSample=$o(!0,i.pts,i.dts,"")),c.key=!0,c.frame=!0;break;case 6:{d=!0,d0(p.data,1,i.pts,e.samples);break}case 7:if(d=!0,f=!0,!t.sps){const b=p.data,E=new tf(b).readSPS();t.width=E.width,t.height=E.height,t.pixelRatio=E.pixelRatio,t.sps=[b],t.duration=this._duration;const T=b.subarray(1,4);let w="avc1.";for(let C=0;C<3;C++){let D=T[C].toString(16);D.length<2&&(D="0"+D),w+=D}t.codec=w}break;case 8:d=!0,t.pps||(t.pps=[p.data]);break;case 9:d=!1,t.audFound=!0,c&&La(c,t),c=this.avcSample=$o(!1,i.pts,i.dts,"");break;case 12:d=!0;break;default:d=!1,c&&(c.debug+="unknown NAL "+p.type+" ");break}c&&d&&c.units.push(p)}),s&&c&&(La(c,t),this.avcSample=null)}getLastNalUnit(t){var e;let i=this.avcSample,s;if((!i||i.units.length===0)&&(i=t[t.length-1]),(e=i)!=null&&e.units){const o=i.units;s=o[o.length-1]}return s}parseAVCNALu(t,e){const i=e.byteLength;let s=t.naluState||0;const o=s,c=[];let d=0,f,p,g,v=-1,b=0;for(s===-1&&(v=0,b=e[0]&31,s=0,d=1);d<i;){if(f=e[d++],!s){s=f?0:1;continue}if(s===1){s=f?0:2;continue}if(!f)s=3;else if(f===1){if(v>=0){const E={data:e.subarray(v,d-s-1),type:b};c.push(E)}else{const E=this.getLastNalUnit(t.samples);if(E&&(o&&d<=4-o&&E.state&&(E.data=E.data.subarray(0,E.data.byteLength-o)),p=d-s-1,p>0)){const T=new Uint8Array(E.data.byteLength+p);T.set(E.data,0),T.set(e.subarray(0,p),E.data.byteLength),E.data=T,E.state=0}}d<i?(g=e[d]&31,v=d,b=g,s=0):s=-1}else s=0}if(v>=0&&s>=0){const E={data:e.subarray(v,i),type:b,state:s};c.push(E)}if(c.length===0){const E=this.getLastNalUnit(t.samples);if(E){const T=new Uint8Array(E.data.byteLength+e.byteLength);T.set(E.data,0),T.set(e,E.data.byteLength),E.data=T}}return t.naluState=s,c}parseAACPES(t,e){let i=0;const s=this.aacOverFlow;let o=e.data;if(s){this.aacOverFlow=null;const v=s.missing,b=s.sample.unit.byteLength;if(v===-1){const E=new Uint8Array(b+o.byteLength);E.set(s.sample.unit,0),E.set(o,b),o=E}else{const E=b-v;s.sample.unit.set(o.subarray(0,v),E),t.samples.push(s.sample),i=s.missing}}let c,d;for(c=i,d=o.length;c<d-1&&!Oo(o,c);c++);if(c!==i){let v;const b=c<d-1;b?v=`AAC PES did not start with ADTS header,offset:${c}`:v="No ADTS header found in AAC PES";const E=new Error(v);if(Y.warn(`parsing error: ${v}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,levelRetry:b,error:E,reason:v}),!b)return}Y0(t,this.observer,o,c,this.audioCodec);let f;if(e.pts!==void 0)f=e.pts;else if(s){const v=X0(t.samplerate);f=s.sample.pts+v}else{Y.warn("[tsdemuxer]: AAC PES unknown PTS");return}let p=0,g;for(;c<d;)if(g=Z0(t,o,c,f,p),c+=g.length,g.missing){this.aacOverFlow=g;break}else for(p++;c<d-1&&!Oo(o,c);c++);}parseMPEGPES(t,e){const i=e.data,s=i.length;let o=0,c=0;const d=e.pts;if(d===void 0){Y.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;c<s;)if(J0(i,c)){const f=q0(t,i,c,d,o);if(f)c+=f.length,o++;else break}else c++}parseID3PES(t,e){if(e.pts===void 0){Y.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const i=ai({},e,{type:this._avcTrack?Ar.emsg:Ar.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(i)}}function $o(n,t,e,i){return{key:n,frame:!1,pts:t,dts:e,units:[],debug:i,length:0}}function Oc(n,t){return((n[t+1]&31)<<8)+n[t+2]}function sb(n,t){return(n[t+10]&31)<<8|n[t+11]}function nb(n,t,e,i){const s={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},o=(n[t+1]&15)<<8|n[t+2],c=t+3+o-4,d=(n[t+10]&15)<<8|n[t+11];for(t+=12+d;t<c;){const f=Oc(n,t);switch(n[t]){case 207:if(!i){Y.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:s.audio===-1&&(s.audio=f);break;case 21:s.id3===-1&&(s.id3=f);break;case 219:if(!i){Y.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:s.avc===-1&&(s.avc=f);break;case 3:case 4:e.mpeg!==!0&&e.mp3!==!0?Y.log("MPEG audio found, not supported in this browser"):s.audio===-1&&(s.audio=f,s.segmentCodec="mp3");break;case 36:Y.warn("Unsupported HEVC stream type found");break}t+=((n[t+3]&15)<<8|n[t+4])+5}return s}function Ln(n){let t=0,e,i,s,o,c;const d=n.data;if(!n||n.size===0)return null;for(;d[0].length<19&&d.length>1;){const f=new Uint8Array(d[0].length+d[1].length);f.set(d[0]),f.set(d[1],d[0].length),d[0]=f,d.splice(1,1)}if(e=d[0],(e[0]<<16)+(e[1]<<8)+e[2]===1){if(i=(e[4]<<8)+e[5],i&&i>n.size-6)return null;const f=e[7];f&192&&(o=(e[9]&14)*536870912+(e[10]&255)*4194304+(e[11]&254)*16384+(e[12]&255)*128+(e[13]&254)/2,f&64?(c=(e[14]&14)*536870912+(e[15]&255)*4194304+(e[16]&254)*16384+(e[17]&255)*128+(e[18]&254)/2,o-c>54e5&&(Y.warn(`${Math.round((o-c)/9e4)}s delta between PTS and DTS, align them`),o=c)):c=o),s=e[8];let p=s+9;if(n.size<=p)return null;n.size-=p;const g=new Uint8Array(n.size);for(let v=0,b=d.length;v<b;v++){e=d[v];let E=e.byteLength;if(p)if(p>E){p-=E;continue}else e=e.subarray(p),E-=p,p=0;g.set(e,t),t+=E}return i&&(i-=s+3),{data:g,pts:o,dts:c,len:i}}return null}function La(n,t){if(n.units.length&&n.frame){if(n.pts===void 0){const e=t.samples,i=e.length;if(i){const s=e[i-1];n.pts=s.pts,n.dts=s.dts}else{t.dropped++;return}}t.samples.push(n)}n.debug.length&&Y.log(n.pts+"/"+n.dts+":"+n.debug)}class ab extends j0{resetInitSegment(t,e,i,s){super.resetInitSegment(t,e,i,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:s,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;let e=(ko(t,0)||[]).length;for(let i=t.length;e<i;e++)if(ib(t,e))return Y.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return eb(t,e)}appendFrame(t,e,i){if(this.basePTS!==null)return q0(t,e,i,this.basePTS,this.frameIndex)}}class ef{static getSilentFrame(t,e){switch(t){case"mp4a.40.2":if(e===1)return new Uint8Array([0,200,0,128,35,128]);if(e===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(e===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(e===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(e===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(e===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(e===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(e===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Ts=Math.pow(2,32)-1;class rt{static init(){rt.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let t;for(t in rt.types)rt.types.hasOwnProperty(t)&&(rt.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),i=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);rt.HDLR_TYPES={video:e,audio:i};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),o=new Uint8Array([0,0,0,0,0,0,0,0]);rt.STTS=rt.STSC=rt.STCO=o,rt.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),rt.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),rt.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),rt.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const c=new Uint8Array([105,115,111,109]),d=new Uint8Array([97,118,99,49]),f=new Uint8Array([0,0,0,1]);rt.FTYP=rt.box(rt.types.ftyp,c,f,c,d),rt.DINF=rt.box(rt.types.dinf,rt.box(rt.types.dref,s))}static box(t,...e){let i=8,s=e.length;const o=s;for(;s--;)i+=e[s].byteLength;const c=new Uint8Array(i);for(c[0]=i>>24&255,c[1]=i>>16&255,c[2]=i>>8&255,c[3]=i&255,c.set(t,4),s=0,i=8;s<o;s++)c.set(e[s],i),i+=e[s].byteLength;return c}static hdlr(t){return rt.box(rt.types.hdlr,rt.HDLR_TYPES[t])}static mdat(t){return rt.box(rt.types.mdat,t)}static mdhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1));return rt.box(rt.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(t){return rt.box(rt.types.mdia,rt.mdhd(t.timescale,t.duration),rt.hdlr(t.type),rt.minf(t))}static mfhd(t){return rt.box(rt.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]))}static minf(t){return t.type==="audio"?rt.box(rt.types.minf,rt.box(rt.types.smhd,rt.SMHD),rt.DINF,rt.stbl(t)):rt.box(rt.types.minf,rt.box(rt.types.vmhd,rt.VMHD),rt.DINF,rt.stbl(t))}static moof(t,e,i){return rt.box(rt.types.moof,rt.mfhd(t),rt.traf(i,e))}static moov(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trak(t[e]);return rt.box.apply(null,[rt.types.moov,rt.mvhd(t[0].timescale,t[0].duration)].concat(i).concat(rt.mvex(t)))}static mvex(t){let e=t.length;const i=[];for(;e--;)i[e]=rt.trex(t[e]);return rt.box.apply(null,[rt.types.mvex,...i])}static mvhd(t,e){e*=t;const i=Math.floor(e/(Ts+1)),s=Math.floor(e%(Ts+1)),o=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24,i>>16&255,i>>8&255,i&255,s>>24,s>>16&255,s>>8&255,s&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return rt.box(rt.types.mvhd,o)}static sdtp(t){const e=t.samples||[],i=new Uint8Array(4+e.length);let s,o;for(s=0;s<e.length;s++)o=e[s].flags,i[s+4]=o.dependsOn<<4|o.isDependedOn<<2|o.hasRedundancy;return rt.box(rt.types.sdtp,i)}static stbl(t){return rt.box(rt.types.stbl,rt.stsd(t),rt.box(rt.types.stts,rt.STTS),rt.box(rt.types.stsc,rt.STSC),rt.box(rt.types.stsz,rt.STSZ),rt.box(rt.types.stco,rt.STCO))}static avc1(t){let e=[],i=[],s,o,c;for(s=0;s<t.sps.length;s++)o=t.sps[s],c=o.byteLength,e.push(c>>>8&255),e.push(c&255),e=e.concat(Array.prototype.slice.call(o));for(s=0;s<t.pps.length;s++)o=t.pps[s],c=o.byteLength,i.push(c>>>8&255),i.push(c&255),i=i.concat(Array.prototype.slice.call(o));const d=rt.box(rt.types.avcC,new Uint8Array([1,e[3],e[4],e[5],255,224|t.sps.length].concat(e).concat([t.pps.length]).concat(i))),f=t.width,p=t.height,g=t.pixelRatio[0],v=t.pixelRatio[1];return rt.box(rt.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,f>>8&255,f&255,p>>8&255,p&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),d,rt.box(rt.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),rt.box(rt.types.pasp,new Uint8Array([g>>24,g>>16&255,g>>8&255,g&255,v>>24,v>>16&255,v>>8&255,v&255])))}static esds(t){const e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))}static mp4a(t){const e=t.samplerate;return rt.box(rt.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]),rt.box(rt.types.esds,rt.esds(t)))}static mp3(t){const e=t.samplerate;return rt.box(rt.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,e&255,0,0]))}static stsd(t){return t.type==="audio"?t.segmentCodec==="mp3"&&t.codec==="mp3"?rt.box(rt.types.stsd,rt.STSD,rt.mp3(t)):rt.box(rt.types.stsd,rt.STSD,rt.mp4a(t)):rt.box(rt.types.stsd,rt.STSD,rt.avc1(t))}static tkhd(t){const e=t.id,i=t.duration*t.timescale,s=t.width,o=t.height,c=Math.floor(i/(Ts+1)),d=Math.floor(i%(Ts+1));return rt.box(rt.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,0,0,0,0,c>>24,c>>16&255,c>>8&255,c&255,d>>24,d>>16&255,d>>8&255,d&255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,s>>8&255,s&255,0,0,o>>8&255,o&255,0,0]))}static traf(t,e){const i=rt.sdtp(t),s=t.id,o=Math.floor(e/(Ts+1)),c=Math.floor(e%(Ts+1));return rt.box(rt.types.traf,rt.box(rt.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),rt.box(rt.types.tfdt,new Uint8Array([1,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,c>>24,c>>16&255,c>>8&255,c&255])),rt.trun(t,i.length+16+20+8+16+8+8),i)}static trak(t){return t.duration=t.duration||4294967295,rt.box(rt.types.trak,rt.tkhd(t),rt.mdia(t))}static trex(t){const e=t.id;return rt.box(rt.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const i=t.samples||[],s=i.length,o=12+16*s,c=new Uint8Array(o);let d,f,p,g,v,b;for(e+=8+o,c.set([t.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,e>>>24&255,e>>>16&255,e>>>8&255,e&255],0),d=0;d<s;d++)f=i[d],p=f.duration,g=f.size,v=f.flags,b=f.cts,c.set([p>>>24&255,p>>>16&255,p>>>8&255,p&255,g>>>24&255,g>>>16&255,g>>>8&255,g&255,v.isLeading<<2|v.dependsOn,v.isDependedOn<<6|v.hasRedundancy<<4|v.paddingValue<<1|v.isNonSync,v.degradPrio&61440,v.degradPrio&15,b>>>24&255,b>>>16&255,b>>>8&255,b&255],12+16*d);return rt.box(rt.types.trun,c)}static initSegment(t){rt.types||rt.init();const e=rt.moov(t),i=new Uint8Array(rt.FTYP.byteLength+e.byteLength);return i.set(rt.FTYP),i.set(e,rt.FTYP.byteLength),i}}rt.types=void 0,rt.HDLR_TYPES=void 0,rt.STTS=void 0,rt.STSC=void 0,rt.STCO=void 0,rt.STSZ=void 0,rt.VMHD=void 0,rt.SMHD=void 0,rt.STSD=void 0,rt.FTYP=void 0,rt.DINF=void 0;const rf=9e4;function Mc(n,t,e=1,i=!1){const s=n*t*e;return i?Math.round(s):s}function ob(n,t,e=1,i=!1){return Mc(n,t,1/e,i)}function Ca(n,t=!1){return Mc(n,1e3,1/rf,t)}function lb(n,t=1){return Mc(n,rf,1/t)}const cb=10*1e3,sf=1024,hb=1152;let No=null,$c=null;class Nc{constructor(t,e,i,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=i,this.ISGenerated=!1,No===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);No=o?parseInt(o[1]):0}if($c===null){const o=navigator.userAgent.match(/Safari\/(\d+)/i);$c=o?parseInt(o[1]):0}}destroy(){}resetTimeStamp(t){Y.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t}resetNextTimestamp(){Y.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){Y.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(t){let e=!1;const i=t.reduce((s,o)=>{const c=o.pts-s;return c<-4294967296?(e=!0,hr(s,o.pts)):c>0?s:o.pts},t[0].pts);return e&&Y.debug("PTS rollover detected"),i}remux(t,e,i,s,o,c,d,f){let p,g,v,b,E,T,w=o,C=o;const D=t.pid>-1,O=e.pid>-1,F=e.samples.length,x=t.samples.length>0,N=d&&F>0||F>1;if((!D||x)&&(!O||N)||this.ISGenerated||d){this.ISGenerated||(v=this.generateIS(t,e,o,c));const H=this.isVideoContiguous;let j=-1,nt;if(N&&(j=db(e.samples),!H&&this.config.forceKeyFrameOnDiscontinuity))if(T=!0,j>0){Y.warn(`[mp4-remuxer]: Dropped ${j} out of ${F} video samples due to a missing keyframe`);const st=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(j),e.dropped+=j,C+=(e.samples[0].pts-st)/e.inputTimeScale,nt=C}else j===-1&&(Y.warn(`[mp4-remuxer]: No keyframe found out of ${F} video samples`),T=!1);if(this.ISGenerated){if(x&&N){const st=this.getVideoStartPts(e.samples),Q=(hr(t.samples[0].pts,st)-st)/e.inputTimeScale;w+=Math.max(0,Q),C+=Math.max(0,-Q)}if(x){if(t.samplerate||(Y.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),v=this.generateIS(t,e,o,c)),g=this.remuxAudio(t,w,this.isAudioContiguous,c,O||N||f===Jt.AUDIO?C:void 0),N){const st=g?g.endPTS-g.startPTS:0;e.inputTimeScale||(Y.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),v=this.generateIS(t,e,o,c)),p=this.remuxVideo(e,C,H,st)}}else N&&(p=this.remuxVideo(e,C,H,0));p&&(p.firstKeyFrame=j,p.independent=j!==-1,p.firstKeyFramePTS=nt)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(i.samples.length&&(E=nf(i,o,this._initPTS,this._initDTS)),s.samples.length&&(b=af(s,o,this._initPTS))),{audio:g,video:p,initSegment:v,independent:T,text:b,id3:E}}generateIS(t,e,i,s){const o=t.samples,c=e.samples,d=this.typeSupported,f={},p=this._initPTS;let g=!p||s,v="audio/mp4",b,E,T;if(g&&(b=E=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":d.mpeg?(v="audio/mpeg",t.codec=""):d.mp3&&(t.codec="mp3");break}f.audio={id:"audio",container:v,codec:t.codec,initSegment:t.segmentCodec==="mp3"&&d.mpeg?new Uint8Array(0):rt.initSegment([t]),metadata:{channelCount:t.channelCount}},g&&(T=t.inputTimeScale,!p||T!==p.timescale?b=E=o[0].pts-Math.round(T*i):g=!1)}if(e.sps&&e.pps&&c.length&&(e.timescale=e.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:rt.initSegment([e]),metadata:{width:e.width,height:e.height}},g))if(T=e.inputTimeScale,!p||T!==p.timescale){const w=this.getVideoStartPts(c),C=Math.round(T*i);E=Math.min(E,hr(c[0].dts,w)-C),b=Math.min(b,w-C)}else g=!1;if(Object.keys(f).length)return this.ISGenerated=!0,g?(this._initPTS={baseTime:b,timescale:T},this._initDTS={baseTime:E,timescale:T}):b=T=void 0,{tracks:f,initPTS:b,timescale:T}}remuxVideo(t,e,i,s){const o=t.inputTimeScale,c=t.samples,d=[],f=c.length,p=this._initPTS;let g=this.nextAvcDts,v=8,b=this.videoSampleDuration,E,T,w=Number.POSITIVE_INFINITY,C=Number.NEGATIVE_INFINITY,D=!1;if(!i||g===null){const $=e*o,U=c[0].pts-hr(c[0].dts,c[0].pts);g=$-U}const O=p.baseTime*o/p.timescale;for(let $=0;$<f;$++){const U=c[$];U.pts=hr(U.pts-O,g),U.dts=hr(U.dts-O,g),U.dts<c[$>0?$-1:$].dts&&(D=!0)}D&&c.sort(function($,U){const Z=$.dts-U.dts,ft=$.pts-U.pts;return Z||ft}),E=c[0].dts,T=c[c.length-1].dts;const F=T-E,x=F?Math.round(F/(f-1)):b||t.inputTimeScale/30;if(i){const $=E-g,U=$>x,Z=$<-1;if((U||Z)&&(U?Y.warn(`AVC: ${Ca($,!0)} ms (${$}dts) hole between fragments detected, filling it`):Y.warn(`AVC: ${Ca(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!Z||g>=c[0].pts)){E=g;const ft=c[0].pts-$;c[0].dts=E,c[0].pts=ft,Y.log(`Video: First PTS/DTS adjusted: ${Ca(ft,!0)}/${Ca(E,!0)}, delta: ${Ca($,!0)} ms`)}}E=Math.max(0,E);let N=0,H=0;for(let $=0;$<f;$++){const U=c[$],Z=U.units,ft=Z.length;let bt=0;for(let xt=0;xt<ft;xt++)bt+=Z[xt].data.length;H+=bt,N+=ft,U.length=bt,U.dts=Math.max(U.dts,E),w=Math.min(U.pts,w),C=Math.max(U.pts,C)}T=c[f-1].dts;const j=H+4*N+8;let nt;try{nt=new Uint8Array(j)}catch($){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:j,reason:`fail allocating video mdat ${j}`});return}const st=new DataView(nt.buffer);st.setUint32(0,j),nt.set(rt.types.mdat,4);let Q=!1,kt=Number.POSITIVE_INFINITY,gt=Number.POSITIVE_INFINITY,Mt=Number.NEGATIVE_INFINITY,Vt=Number.NEGATIVE_INFINITY;for(let $=0;$<f;$++){const U=c[$],Z=U.units;let ft=0;for(let Ut=0,Qt=Z.length;Ut<Qt;Ut++){const ue=Z[Ut],se=ue.data,Yt=ue.data.byteLength;st.setUint32(v,Yt),v+=4,nt.set(se,v),v+=Yt,ft+=4+Yt}let bt;if($<f-1)b=c[$+1].dts-U.dts,bt=c[$+1].pts-U.pts;else{const Ut=this.config,Qt=$>0?U.dts-c[$-1].dts:x;if(bt=$>0?U.pts-c[$-1].pts:x,Ut.stretchShortVideoTrack&&this.nextAudioPts!==null){const ue=Math.floor(Ut.maxBufferHole*o),se=(s?w+s*o:this.nextAudioPts)-U.pts;se>ue?(b=se-Qt,b<0?b=Qt:Q=!0,Y.log(`[mp4-remuxer]: It is approximately ${se/90} ms to the next segment; using duration ${b/90} ms for the last video frame.`)):b=Qt}else b=Qt}const xt=Math.round(U.pts-U.dts);kt=Math.min(kt,b),Mt=Math.max(Mt,b),gt=Math.min(gt,bt),Vt=Math.max(Vt,bt),d.push(new of(U.key,b,ft,xt))}if(d.length){if(No){if(No<70){const $=d[0].flags;$.dependsOn=2,$.isNonSync=0}}else if($c&&Vt-gt<Mt-kt&&x/Mt<.025&&d[0].cts===0){Y.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=E;for(let U=0,Z=d.length;U<Z;U++){const ft=$+d[U].duration,bt=$+d[U].cts;if(U<Z-1){const xt=ft+d[U+1].cts;d[U].duration=xt-bt}else d[U].duration=U?d[U-1].duration:x;d[U].cts=0,$=ft}}}b=Q||!b?x:b,this.nextAvcDts=g=T+b,this.videoSampleDuration=b,this.isVideoContiguous=!0;const V=rt.moof(t.sequenceNumber++,E,ai({},t,{samples:d})),J="video",St={data1:V,data2:nt,startPTS:w/o,endPTS:(C+b)/o,startDTS:E/o,endDTS:g/o,type:J,hasAudio:!1,hasVideo:!0,nb:d.length,dropped:t.dropped};return t.samples=[],t.dropped=0,St}remuxAudio(t,e,i,s,o){const c=t.inputTimeScale,d=t.samplerate?t.samplerate:c,f=c/d,p=t.segmentCodec==="aac"?sf:hb,g=p*f,v=this._initPTS,b=t.segmentCodec==="mp3"&&this.typeSupported.mpeg,E=[],T=o!==void 0;let w=t.samples,C=b?0:8,D=this.nextAudioPts||-1;const O=e*c,F=v.baseTime*c/v.timescale;if(this.isAudioContiguous=i=i||w.length&&D>0&&(s&&Math.abs(O-D)<9e3||Math.abs(hr(w[0].pts-F,O)-D)<20*g),w.forEach(function(V){V.pts=hr(V.pts-F,O)}),!i||D<0){if(w=w.filter(V=>V.pts>=0),!w.length)return;o===0?D=0:s&&!T?D=Math.max(0,O):D=w[0].pts}if(t.segmentCodec==="aac"){const V=this.config.maxAudioFramesDrift;for(let J=0,St=D;J<w.length;J++){const $=w[J],U=$.pts,Z=U-St,ft=Math.abs(1e3*Z/c);if(Z<=-V*g&&T)J===0&&(Y.warn(`Audio frame @ ${(U/c).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*Z/c)} ms.`),this.nextAudioPts=D=St=U);else if(Z>=V*g&&ft<cb&&T){let bt=Math.round(Z/g);St=U-bt*g,St<0&&(bt--,St+=g),J===0&&(this.nextAudioPts=D=St),Y.warn(`[mp4-remuxer]: Injecting ${bt} audio frame @ ${(St/c).toFixed(3)}s due to ${Math.round(1e3*Z/c)} ms gap.`);for(let xt=0;xt<bt;xt++){const Ut=Math.max(St,0);let Qt=ef.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);Qt||(Y.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Qt=$.unit.subarray()),w.splice(J,0,{unit:Qt,pts:Ut}),St+=g,J++}}$.pts=St,St+=g}}let x=null,N=null,H,j=0,nt=w.length;for(;nt--;)j+=w[nt].unit.byteLength;for(let V=0,J=w.length;V<J;V++){const St=w[V],$=St.unit;let U=St.pts;if(N!==null){const ft=E[V-1];ft.duration=Math.round((U-N)/f)}else if(i&&t.segmentCodec==="aac"&&(U=D),x=U,j>0){j+=C;try{H=new Uint8Array(j)}catch(ft){this.observer.emit(R.ERROR,R.ERROR,{type:qt.MUX_ERROR,details:ut.REMUX_ALLOC_ERROR,fatal:!1,error:ft,bytes:j,reason:`fail allocating audio mdat ${j}`});return}b||(new DataView(H.buffer).setUint32(0,j),H.set(rt.types.mdat,4))}else return;H.set($,C);const Z=$.byteLength;C+=Z,E.push(new of(!0,p,Z,0)),N=U}const st=E.length;if(!st)return;const Q=E[E.length-1];this.nextAudioPts=D=N+f*Q.duration;const kt=b?new Uint8Array(0):rt.moof(t.sequenceNumber++,x/f,ai({},t,{samples:E}));t.samples=[];const gt=x/c,Mt=D/c,Vt={data1:kt,data2:H,startPTS:gt,endPTS:Mt,startDTS:gt,endDTS:Mt,type:"audio",hasAudio:!0,hasVideo:!1,nb:st};return this.isAudioContiguous=!0,Vt}remuxEmptyAudio(t,e,i,s){const o=t.inputTimeScale,c=t.samplerate?t.samplerate:o,d=o/c,f=this.nextAudioPts,p=this._initDTS,g=p.baseTime*9e4/p.timescale,v=(f!==null?f:s.startDTS*o)+g,b=s.endDTS*o+g,E=d*sf,T=Math.ceil((b-v)/E),w=ef.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(Y.warn("[mp4-remuxer]: remux empty Audio"),!w){Y.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const C=[];for(let D=0;D<T;D++){const O=v+D*E;C.push({unit:w,pts:O,dts:O})}return t.samples=C,this.remuxAudio(t,e,i,!1)}}function hr(n,t){let e;if(t===null)return n;for(t<n?e=-8589934592:e=8589934592;Math.abs(n-t)>4294967296;)n+=e;return n}function db(n){for(let t=0;t<n.length;t++)if(n[t].key)return t;return-1}function nf(n,t,e,i){const s=n.samples.length;if(!s)return;const o=n.inputTimeScale;for(let d=0;d<s;d++){const f=n.samples[d];f.pts=hr(f.pts-e.baseTime*o/e.timescale,t*o)/o,f.dts=hr(f.dts-i.baseTime*o/i.timescale,t*o)/o}const c=n.samples;return n.samples=[],{samples:c}}function af(n,t,e){const i=n.samples.length;if(!i)return;const s=n.inputTimeScale;for(let c=0;c<i;c++){const d=n.samples[c];d.pts=hr(d.pts-e.baseTime*s/e.timescale,t*s)/s}n.samples.sort((c,d)=>c.pts-d.pts);const o=n.samples;return n.samples=[],{samples:o}}class of{constructor(t,e,i,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=e,this.size=i,this.cts=s,this.flags=new ub(t)}}class ub{constructor(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}}class fb{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(t){this.initPTS=t,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(t,e,i,s){this.audioCodec=e,this.videoCodec=i,this.generateInitSegment(Pv(t,s)),this.emitInitSegment=!0}generateInitSegment(t){let{audioCodec:e,videoCodec:i}=this;if(!(t!=null&&t.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=l0(t);e||(e=lf(s.audio,Le.AUDIO)),i||(i=lf(s.video,Le.VIDEO));const o={};s.audio&&s.video?o.audiovideo={container:"video/mp4",codec:e+","+i,initSegment:t,id:"main"}:s.audio?o.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:s.video?o.video={container:"video/mp4",codec:i,initSegment:t,id:"main"}:Y.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o}remux(t,e,i,s,o,c){var d,f;let{initPTS:p,lastEndTime:g}=this;const v={audio:void 0,video:void 0,text:s,id3:i,initSegment:void 0};Wt(g)||(g=this.lastEndTime=o||0);const b=e.samples;if(!(b!=null&&b.length))return v;const E={initPTS:void 0,timescale:1};let T=this.initData;if((d=T)!=null&&d.length||(this.generateInitSegment(b),T=this.initData),!((f=T)!=null&&f.length))return Y.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),v;this.emitInitSegment&&(E.tracks=this.initTracks,this.emitInitSegment=!1);const w=Mv(b,T),C=Ov(T,b),D=C===null?o:C;(pb(p,D,o,w)||E.timescale!==p.timescale&&c)&&(E.initPTS=D-o,p&&p.timescale===1&&Y.warn(`Adjusting initPTS by ${E.initPTS-p.baseTime}`),this.initPTS=p={baseTime:E.initPTS,timescale:1});const O=t?D-p.baseTime/p.timescale:g,F=O+w;Nv(T,b,p.baseTime/p.timescale),w>0?this.lastEndTime=F:(Y.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!T.audio,N=!!T.video;let H="";x&&(H+="audio"),N&&(H+="video");const j={data1:b,startPTS:O,startDTS:O,endPTS:F,endDTS:F,type:H,hasAudio:x,hasVideo:N,nb:1,dropped:0};return v.audio=j.type==="audio"?j:void 0,v.video=j.type!=="audio"?j:void 0,v.initSegment=E,v.id3=nf(i,o,p,p),s.samples.length&&(v.text=af(s,o,p)),v}}function pb(n,t,e,i){if(n===null)return!0;const s=Math.max(i,1),o=t-n.baseTime/n.timescale;return Math.abs(o-e)>s}function lf(n,t){const e=n==null?void 0:n.codec;return e&&e.length>4?e:e==="hvc1"||e==="hev1"?"hvc1.1.6.L120.90":e==="av01"?"av01.0.04M.08":e==="avc1"||t===Le.VIDEO?"avc1.42e01e":"mp4a.40.5"}let ts;try{ts=self.performance.now.bind(self.performance)}catch{Y.debug("Unable to use Performance API on this environment"),ts=typeof self<"u"&&self.Date.now}const Fc=[{demux:Zy,remux:fb},{demux:Es,remux:Nc},{demux:Yy,remux:Nc},{demux:ab,remux:Nc}];class cf{constructor(t,e,i,s,o){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=i,this.vendor=s,this.id=o}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,i,s){const o=i.transmuxing;o.executeStart=ts();let c=new Uint8Array(t);const{currentTransmuxState:d,transmuxConfig:f}=this;s&&(this.currentTransmuxState=s);const{contiguous:p,discontinuity:g,trackSwitch:v,accurateTimeOffset:b,timeOffset:E,initSegmentChange:T}=s||d,{audioCodec:w,videoCodec:C,defaultInitPts:D,duration:O,initSegmentData:F}=f,x=gb(c,e);if(x&&x.method==="AES-128"){const nt=this.getDecrypter();if(nt.isSync()){let st=nt.softwareDecrypt(c,x.key.buffer,x.iv.buffer);if(i.part>-1&&(st=nt.flush()),!st)return o.executeEnd=ts(),Uc(i);c=new Uint8Array(st)}else return this.decryptionPromise=nt.webCryptoDecrypt(c,x.key.buffer,x.iv.buffer).then(st=>{const Q=this.push(st,null,i);return this.decryptionPromise=null,Q}),this.decryptionPromise}const N=this.needsProbing(g,v);if(N){const nt=this.configureTransmuxer(c);if(nt)return Y.warn(`[transmuxer] ${nt.message}`),this.observer.emit(R.ERROR,R.ERROR,{type:qt.MEDIA_ERROR,details:ut.FRAG_PARSING_ERROR,fatal:!1,error:nt,reason:nt.message}),o.executeEnd=ts(),Uc(i)}(g||v||T||N)&&this.resetInitSegment(F,w,C,O,e),(g||T||N)&&this.resetInitialTimestamp(D),p||this.resetContiguity();const H=this.transmux(c,x,E,b,i),j=this.currentTransmuxState;return j.contiguous=!0,j.discontinuity=!1,j.trackSwitch=!1,o.executeEnd=ts(),H}flush(t){const e=t.transmuxing;e.executeStart=ts();const{decrypter:i,currentTransmuxState:s,decryptionPromise:o}=this;if(o)return o.then(()=>this.flush(t));const c=[],{timeOffset:d}=s;if(i){const v=i.flush();v&&c.push(this.push(v,null,t))}const{demuxer:f,remuxer:p}=this;if(!f||!p)return e.executeEnd=ts(),[Uc(t)];const g=f.flush(d);return Fo(g)?g.then(v=>(this.flushRemux(c,v,t),c)):(this.flushRemux(c,g,t),c)}flushRemux(t,e,i){const{audioTrack:s,videoTrack:o,id3Track:c,textTrack:d}=e,{accurateTimeOffset:f,timeOffset:p}=this.currentTransmuxState;Y.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${i.part>-1?" p: "+i.part:""} of level ${i.level}`);const g=this.remuxer.remux(s,o,c,d,p,f,!0,this.id);t.push({remuxResult:g,chunkMeta:i}),i.transmuxing.executeEnd=ts()}resetInitialTimestamp(t){const{demuxer:e,remuxer:i}=this;!e||!i||(e.resetTimeStamp(t),i.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;!t||!e||(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,i,s,o){const{demuxer:c,remuxer:d}=this;!c||!d||(c.resetInitSegment(t,e,i,s),d.resetInitSegment(t,e,i,o))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,i,s,o){let c;return e&&e.method==="SAMPLE-AES"?c=this.transmuxSampleAes(t,e,i,s,o):c=this.transmuxUnencrypted(t,i,s,o),c}transmuxUnencrypted(t,e,i,s){const{audioTrack:o,videoTrack:c,id3Track:d,textTrack:f}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(o,c,d,f,e,i,!1,this.id),chunkMeta:s}}transmuxSampleAes(t,e,i,s,o){return this.demuxer.demuxSampleAes(t,e,i).then(c=>({remuxResult:this.remuxer.remux(c.audioTrack,c.videoTrack,c.id3Track,c.textTrack,i,s,!1,this.id),chunkMeta:o}))}configureTransmuxer(t){const{config:e,observer:i,typeSupported:s,vendor:o}=this;let c;for(let v=0,b=Fc.length;v<b;v++)if(Fc[v].demux.probe(t)){c=Fc[v];break}if(!c)return new Error("Failed to find demuxer by probing fragment data");const d=this.demuxer,f=this.remuxer,p=c.remux,g=c.demux;(!f||!(f instanceof p))&&(this.remuxer=new p(i,e,s,o)),(!d||!(d instanceof g))&&(this.demuxer=new g(i,e,s),this.probe=g.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new Ic(this.config)),t}}function gb(n,t){let e=null;return n.byteLength>0&&t!=null&&t.key!=null&&t.iv!==null&&t.method!=null&&(e=t),e}const Uc=n=>({remuxResult:{},chunkMeta:n});function Fo(n){return"then"in n&&n.then instanceof Function}class mb{constructor(t,e,i,s,o){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=i,this.duration=s,this.defaultInitPts=o||null}}class vb{constructor(t,e,i,s,o,c){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=i,this.trackSwitch=s,this.timeOffset=o,this.initSegmentChange=c}}var hf={exports:{}};(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function s(f,p,g){this.fn=f,this.context=p,this.once=g||!1}function o(f,p,g,v,b){if(typeof g!="function")throw new TypeError("The listener must be a function");var E=new s(g,v||f,b),T=e?e+p:p;return f._events[T]?f._events[T].fn?f._events[T]=[f._events[T],E]:f._events[T].push(E):(f._events[T]=E,f._eventsCount++),f}function c(f,p){--f._eventsCount===0?f._events=new i:delete f._events[p]}function d(){this._events=new i,this._eventsCount=0}d.prototype.eventNames=function(){var f=[],p,g;if(this._eventsCount===0)return f;for(g in p=this._events)t.call(p,g)&&f.push(e?g.slice(1):g);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(p)):f},d.prototype.listeners=function(f){var p=e?e+f:f,g=this._events[p];if(!g)return[];if(g.fn)return[g.fn];for(var v=0,b=g.length,E=new Array(b);v<b;v++)E[v]=g[v].fn;return E},d.prototype.listenerCount=function(f){var p=e?e+f:f,g=this._events[p];return g?g.fn?1:g.length:0},d.prototype.emit=function(f,p,g,v,b,E){var T=e?e+f:f;if(!this._events[T])return!1;var w=this._events[T],C=arguments.length,D,O;if(w.fn){switch(w.once&&this.removeListener(f,w.fn,void 0,!0),C){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,p),!0;case 3:return w.fn.call(w.context,p,g),!0;case 4:return w.fn.call(w.context,p,g,v),!0;case 5:return w.fn.call(w.context,p,g,v,b),!0;case 6:return w.fn.call(w.context,p,g,v,b,E),!0}for(O=1,D=new Array(C-1);O<C;O++)D[O-1]=arguments[O];w.fn.apply(w.context,D)}else{var F=w.length,x;for(O=0;O<F;O++)switch(w[O].once&&this.removeListener(f,w[O].fn,void 0,!0),C){case 1:w[O].fn.call(w[O].context);break;case 2:w[O].fn.call(w[O].context,p);break;case 3:w[O].fn.call(w[O].context,p,g);break;case 4:w[O].fn.call(w[O].context,p,g,v);break;default:if(!D)for(x=1,D=new Array(C-1);x<C;x++)D[x-1]=arguments[x];w[O].fn.apply(w[O].context,D)}}return!0},d.prototype.on=function(f,p,g){return o(this,f,p,g,!1)},d.prototype.once=function(f,p,g){return o(this,f,p,g,!0)},d.prototype.removeListener=function(f,p,g,v){var b=e?e+f:f;if(!this._events[b])return this;if(!p)return c(this,b),this;var E=this._events[b];if(E.fn)E.fn===p&&(!v||E.once)&&(!g||E.context===g)&&c(this,b);else{for(var T=0,w=[],C=E.length;T<C;T++)(E[T].fn!==p||v&&!E[T].once||g&&E[T].context!==g)&&w.push(E[T]);w.length?this._events[b]=w.length===1?w[0]:w:c(this,b)}return this},d.prototype.removeAllListeners=function(f){var p;return f?(p=e?e+f:f,this._events[p]&&c(this,p)):(this._events=new i,this._eventsCount=0),this},d.prototype.off=d.prototype.removeListener,d.prototype.addListener=d.prototype.on,d.prefixed=e,d.EventEmitter=d,n.exports=d})(hf);var yb=hf.exports,Bc=rv(yb);const Gc=_o()||{isTypeSupported:()=>!1};class df{constructor(t,e,i,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const o=t.config;this.hls=t,this.id=e,this.useWorker=!!o.enableWorker,this.onTransmuxComplete=i,this.onFlush=s;const c=(p,g)=>{g=g||{},g.frag=this.frag,g.id=this.id,p===R.ERROR&&(this.error=g.error),this.hls.trigger(p,g)};this.observer=new Bc,this.observer.on(R.FRAG_DECRYPTED,c),this.observer.on(R.ERROR,c);const d={mp4:Gc.isTypeSupported("video/mp4"),mpeg:Gc.isTypeSupported("audio/mpeg"),mp3:Gc.isTypeSupported('audio/mp4; codecs="mp3"')},f=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(o.workerPath||Uy())){try{o.workerPath?(Y.log(`loading Web Worker ${o.workerPath} for "${e}"`),this.workerContext=Gy(o.workerPath)):(Y.log(`injecting Web Worker for "${e}"`),this.workerContext=By()),this.onwmsg=g=>this.onWorkerMessage(g);const{worker:p}=this.workerContext;p.addEventListener("message",this.onwmsg),p.onerror=g=>{const v=new Error(`${g.message} (${g.filename}:${g.lineno})`);o.enableWorker=!1,Y.warn(`Error in "${e}" Web Worker, fallback to inline`),this.hls.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:v})},p.postMessage({cmd:"init",typeSupported:d,vendor:f,id:e,config:JSON.stringify(o)})}catch(p){Y.warn(`Error setting up "${e}" Web Worker, fallback to inline`,p),this.resetWorker(),this.error=null,this.transmuxer=new cf(this.observer,d,o,f,e)}return}this.transmuxer=new cf(this.observer,d,o,f,e)}resetWorker(){if(this.workerContext){const{worker:t,objectURL:e}=this.workerContext;e&&self.URL.revokeObjectURL(e),t.removeEventListener("message",this.onwmsg),t.onerror=null,t.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(t,e,i,s,o,c,d,f,p,g){var v,b;p.transmuxing.start=self.performance.now();const{transmuxer:E}=this,T=c?c.start:o.start,w=o.decryptdata,C=this.frag,D=!(C&&o.cc===C.cc),O=!(C&&p.level===C.level),F=C?p.sn-C.sn:-1,x=this.part?p.part-this.part.index:-1,N=F===0&&p.id>1&&p.id===(C==null?void 0:C.stats.chunkCount),H=!O&&(F===1||F===0&&(x===1||N&&x<=0)),j=self.performance.now();(O||F||o.stats.parsing.start===0)&&(o.stats.parsing.start=j),c&&(x||!H)&&(c.stats.parsing.start=j);const nt=!(C&&((v=o.initSegment)==null?void 0:v.url)===((b=C.initSegment)==null?void 0:b.url)),st=new vb(D,H,f,O,T,nt);if(!H||D||nt){Y.log(`[transmuxer-interface, ${o.type}]: Starting new transmux session for sn: ${p.sn} p: ${p.part} level: ${p.level} id: ${p.id}
184
184
  discontinuity: ${D}
185
185
  trackSwitch: ${O}
186
186
  contiguous: ${H}
@@ -205,7 +205,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
205
205
  `),p=[],g=t?lb(t.baseTime,t.timescale):0;let v="00:00.000",b=0,E=0,T,w=!0;d.oncue=function(C){const D=e[i];let O=e.ccOffset;const F=(b-g)/9e4;if(D!=null&&D.new&&(E!==void 0?O=e.ccOffset=D.start:Zb(e,i,F)),F){if(!t){T=new Error("Missing initPTS for VTT MPEGTS");return}O=F-e.presentationOffset}const x=C.endTime-C.startTime,N=hr((C.startTime+O-E)*9e4,s*9e4)/9e4;C.startTime=Math.max(N,0),C.endTime=Math.max(N+x,0);const H=C.text.trim();C.text=decodeURIComponent(encodeURIComponent(H)),C.id||(C.id=Xc(C.startTime,C.endTime,H)),C.endTime>0&&p.push(C)},d.onparsingerror=function(C){T=C},d.onflush=function(){if(T){c(T);return}o(p)},f.forEach(C=>{if(w)if(zc(C,"X-TIMESTAMP-MAP=")){w=!1,C.slice(16).split(",").forEach(D=>{zc(D,"LOCAL:")?v=D.slice(6):zc(D,"MPEGTS:")&&(b=parseInt(D.slice(7)))});try{E=Xb(v)/1e3}catch(D){T=D}return}else C===""&&(w=!1);d.parse(C+`
206
206
  `)}),d.flush()}const Zc="stpp.ttml.im1t",Lf=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Cf=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Qb={left:"start",center:"center",right:"end",start:"start",end:"end"};function If(n,t,e,i){const s=ye(new Uint8Array(n),["mdat"]);if(s.length===0){i(new Error("Could not parse IMSC1 mdat"));return}const o=s.map(d=>Pr(d)),c=ob(t.baseTime,1,t.timescale);try{o.forEach(d=>e(Jb(d,c)))}catch(d){i(d)}}function Jb(n,t){const e=new DOMParser().parseFromString(n,"text/xml").getElementsByTagName("tt")[0];if(!e)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(i).reduce((p,g)=>(p[g]=e.getAttribute(`ttp:${g}`)||i[g],p),{}),o=e.getAttribute("xml:space")!=="preserve",c=xf(qc(e,"styling","style")),d=xf(qc(e,"layout","region")),f=qc(e,"body","[begin]");return[].map.call(f,p=>{const g=Df(p,o);if(!g||!p.hasAttribute("begin"))return null;const v=Jc(p.getAttribute("begin"),s),b=Jc(p.getAttribute("dur"),s);let E=Jc(p.getAttribute("end"),s);if(v===null)throw Pf(p);if(E===null){if(b===null)throw Pf(p);E=v+b}const T=new jc(v-t,E-t,g);T.id=Xc(T.startTime,T.endTime,T.text);const w=d[p.getAttribute("region")],C=c[p.getAttribute("style")],D=t4(w,C,c),{textAlign:O}=D;if(O){const F=Qb[O];F&&(T.lineAlign=F),T.align=O}return ai(T,D),T}).filter(p=>p!==null)}function qc(n,t,e){const i=n.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(e)):[]}function xf(n){return n.reduce((t,e)=>{const i=e.getAttribute("xml:id");return i&&(t[i]=e),t},{})}function Df(n,t){return[].slice.call(n.childNodes).reduce((e,i,s)=>{var o;return i.nodeName==="br"&&s?e+`
207
207
  `:(o=i.childNodes)!=null&&o.length?Df(i,t):t?e+i.textContent.trim().replace(/\s+/g," "):e+i.textContent},"")}function t4(n,t,e){const i="http://www.w3.org/ns/ttml#styling";let s=null;const o=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],c=n!=null&&n.hasAttribute("style")?n.getAttribute("style"):null;return c&&e.hasOwnProperty(c)&&(s=e[c]),o.reduce((d,f)=>{const p=Qc(t,i,f)||Qc(n,i,f)||Qc(s,i,f);return p&&(d[f]=p),d},{})}function Qc(n,t,e){return n&&n.hasAttributeNS(t,e)?n.getAttributeNS(t,e):null}function Pf(n){return new Error(`Could not parse ttml timestamp ${n}`)}function Jc(n,t){if(!n)return null;let e=Sf(n);return e===null&&(Lf.test(n)?e=e4(n,t):Cf.test(n)&&(e=i4(n,t))),e}function e4(n,t){const e=Lf.exec(n),i=(e[4]|0)+(e[5]|0)/t.subFrameRate;return(e[1]|0)*3600+(e[2]|0)*60+(e[3]|0)+i/t.frameRate}function i4(n,t){const e=Cf.exec(n),i=Number(e[1]);switch(e[2]){case"h":return i*3600;case"m":return i*60;case"ms":return i*1e3;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}class r4{constructor(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Of(),this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const e=new Uo(this,"textTrack1"),i=new Uo(this,"textTrack2"),s=new Uo(this,"textTrack3"),o=new Uo(this,"textTrack4");this.cea608Parser1=new Tf(1,e,i),this.cea608Parser2=new Tf(3,s,o)}t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(R.FRAG_LOADING,this.onFragLoading,this),t.on(R.FRAG_LOADED,this.onFragLoaded,this),t.on(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(R.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(R.FRAG_LOADING,this.onFragLoading,this),t.off(R.FRAG_LOADED,this.onFragLoaded,this),t.off(R.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(R.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(R.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(R.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(R.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(t,e,i,s,o){let c=!1;for(let d=o.length;d--;){const f=o[d],p=n4(f[0],f[1],e,i);if(p>=0&&(f[0]=Math.min(f[0],e),f[1]=Math.max(f[1],i),c=!0,p/(i-e)>.5))return}if(c||o.push([e,i]),this.config.renderTextTracksNatively){const d=this.captionsTracks[t];this.Cues.newCue(d,e,i,s)}else{const d=this.Cues.newCue(null,e,i,s);this.hls.trigger(R.CUES_PARSED,{type:"captions",cues:d,track:t})}}onInitPtsFound(t,{frag:e,id:i,initPTS:s,timescale:o}){const{unparsedVttFrags:c}=this;i==="main"&&(this.initPTS[e.cc]={baseTime:s,timescale:o}),c.length&&(this.unparsedVttFrags=[],c.forEach(d=>{this.onFragLoaded(R.FRAG_LOADED,d)}))}getExistingTrack(t){const{media:e}=this;if(e)for(let i=0;i<e.textTracks.length;i++){const s=e.textTracks[i];if(s[t])return s}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:i,media:s}=this,{label:o,languageCode:c}=e[t],d=this.getExistingTrack(t);if(d)i[t]=d,Rn(i[t]),_0(i[t],s);else{const f=this.createTextTrack("captions",o,c);f&&(f[t]=!0,i[t]=f)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const i=e.label,s={_id:t,label:i,kind:"captions",default:e.media?!!e.media.default:!1,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,i){const s=this.media;if(s)return s.addTextTrack(t,e,i)}onMediaAttaching(t,e){this.media=e.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:t}=this;Object.keys(t).forEach(e=>{Rn(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Of(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let i=0;i<e.length;i++)Rn(e[i])}onSubtitleTracksUpdated(t,e){const i=e.subtitleTracks||[],s=i.some(o=>o.textCodec===Zc);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(pf(this.tracks,i)){this.tracks=i;return}if(this.textTracks=[],this.tracks=i,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((c,d)=>{let f;if(o&&d<o.length){let p=null;for(let g=0;g<o.length;g++)if(s4(o[g],c)){p=o[g];break}p&&(f=p)}if(f)Rn(f);else{const p=this._captionsOrSubtitlesFromCharacteristics(c);f=this.createTextTrack(p,c.name,c.lang),f&&(f.mode="disabled")}f&&(f.groupId=c.groupId,this.textTracks.push(f))})}else if(this.tracks.length){const o=this.tracks.map(c=>({label:c.name,kind:c.type.toLowerCase(),default:c.default,subtitleTrack:c}));this.hls.trigger(R.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(t){if(t.attrs.CHARACTERISTICS){const e=/transcribes-spoken-dialog/gi.test(t.attrs.CHARACTERISTICS),i=/describes-music-and-sound/gi.test(t.attrs.CHARACTERISTICS);if(e&&i)return"captions"}return"subtitles"}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(i=>{const s=/(?:CC|SERVICE)([1-4])/.exec(i.instreamId);if(!s)return;const o=`textTrack${s[1]}`,c=this.captionsProperties[o];c&&(c.label=i.name,i.lang&&(c.languageCode=i.lang),c.media=i)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return e==null?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){const{cea608Parser1:i,cea608Parser2:s,lastSn:o,lastPartIndex:c}=this;if(!(!this.enabled||!(i&&s))&&e.frag.type===Jt.MAIN){var d,f;const p=e.frag.sn,g=(d=e==null||(f=e.part)==null?void 0:f.index)!=null?d:-1;p===o+1||p===o&&g===c+1||(i.reset(),s.reset()),this.lastSn=p,this.lastPartIndex=g}}onFragLoaded(t,e){const{frag:i,payload:s}=e;if(i.type===Jt.SUBTITLE)if(s.byteLength){const o=i.decryptdata,c="stats"in e;if(o==null||!o.encrypted||c){const d=this.tracks[i.level],f=this.vttCCs;f[i.cc]||(f[i.cc]={start:i.start,prevCC:this.prevCC,new:!0},this.prevCC=i.cc),d&&d.textCodec===Zc?this._parseIMSC1(i,s):this._parseVTTs(e)}}else this.hls.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const i=this.hls;If(e,this.initPTS[t.cc],s=>{this._appendCues(s,t.level),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},s=>{Y.log(`Failed to parse IMSC1: ${s}`),i.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:s})})}_parseVTTs(t){var e;const{frag:i,payload:s}=t,{initPTS:o,unparsedVttFrags:c}=this,d=o.length-1;if(!o[i.cc]&&d===-1){c.push(t);return}const f=this.hls,p=(e=i.initSegment)!=null&&e.data?ln(i.initSegment.data,new Uint8Array(s)):s;qb(p,this.initPTS[i.cc],this.vttCCs,i.cc,i.start,g=>{this._appendCues(g,i.level),f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:i})},g=>{const v=g.message==="Missing initPTS for VTT MPEGTS";v?c.push(t):this._fallbackToIMSC1(i,s),Y.log(`Failed to parse VTT cue: ${g}`),!(v&&d>i.cc)&&f.trigger(R.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:g})})}_fallbackToIMSC1(t,e){const i=this.tracks[t.level];i.textCodec||If(e,this.initPTS[t.cc],()=>{i.textCodec=Zc,this._parseIMSC1(t,e)},()=>{i.textCodec="wvtt"})}_appendCues(t,e){const i=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||s.mode==="disabled")return;t.forEach(o=>L0(s,o))}else{const s=this.tracks[e];if(!s)return;const o=s.default?"default":"subtitles"+e;i.trigger(R.CUES_PARSED,{type:"subtitles",cues:t,track:o})}}onFragDecrypted(t,e){const{frag:i}=e;i.type===Jt.SUBTITLE&&this.onFragLoaded(R.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){const{cea608Parser1:i,cea608Parser2:s}=this;if(!this.enabled||!(i&&s))return;const{frag:o,samples:c}=e;if(!(o.type===Jt.MAIN&&this.closedCaptionsForLevel(o)==="NONE"))for(let d=0;d<c.length;d++){const f=c[d].bytes;if(f){const p=this.extractCea608Data(f);i.addData(c[d].pts,p[0]),s.addData(c[d].pts,p[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:i,endOffsetSubtitles:s,type:o}){const{media:c}=this;if(!(!c||c.currentTime<i)){if(!o||o==="video"){const{captionsTracks:d}=this;Object.keys(d).forEach(f=>yc(d[f],e,i))}if(this.config.renderTextTracksNatively&&e===0&&s!==void 0){const{textTracks:d}=this;Object.keys(d).forEach(f=>yc(d[f],e,s))}}}extractCea608Data(t){const e=[[],[]],i=t[0]&31;let s=2;for(let o=0;o<i;o++){const c=t[s++],d=127&t[s++],f=127&t[s++];if(!(d===0&&f===0)&&4&c){const p=3&c;(p===0||p===1)&&(e[p].push(d),e[p].push(f))}}return e}}function s4(n,t){return!!n&&n.label===t.name&&!(n.textTrack1||n.textTrack2)}function n4(n,t,e,i){return Math.min(t,i)-Math.max(n,e)}function Of(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class th{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.BUFFER_CODECS,this.onBufferCodecs,this),t.on(R.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(R.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.BUFFER_CODECS,this.onBufferCodecs,this),t.off(R.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const i=this.hls.levels[e.droppedLevel];this.isLevelAllowed(i)&&this.restrictedLevels.push({bitrate:i.bitrate,height:i.height,width:i.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null}onManifestParsed(t,e){const i=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,i.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const t=this.hls.levels;if(t.length){const e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const i=e.filter((s,o)=>this.isLevelAllowed(s)&&o<=t);return this.clientRect=null,th.getMaxLevelByMediaSize(i,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const i=t.getBoundingClientRect();e.width=i.width,e.height=i.height,!e.width&&!e.height&&(e.width=i.right-i.left||t.width||0,e.height=i.bottom-i.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch{}return t}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,i){if(!(t!=null&&t.length))return-1;const s=(c,d)=>d?c.width!==d.width||c.height!==d.height:!0;let o=t.length-1;for(let c=0;c<t.length;c+=1){const d=t[c];if((d.width>=e||d.height>=i)&&s(d,t[c+1])){o=c;break}}return o}}class a4{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const i=this.hls.config;if(i.capLevelOnFPSDrop){const s=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod)}}checkFPS(t,e,i){const s=performance.now();if(e){if(this.lastTime){const o=s-this.lastTime,c=i-this.lastDroppedFrames,d=e-this.lastDecodedFrames,f=1e3*c/o,p=this.hls;if(p.trigger(R.FPS_DROP,{currentDropped:c,currentDecoded:d,totalDroppedFrames:i}),f>0&&c>p.config.fpsDroppedMonitoringThreshold*d){let g=p.currentLevel;Y.warn("drop FPS ratio greater than max allowed value for currentLevel: "+g),g>0&&(p.autoLevelCapping===-1||p.autoLevelCapping>=g)&&(g=g-1,p.trigger(R.FPS_DROP_LEVEL_CAPPING,{level:g,droppedLevel:p.currentLevel}),p.autoLevelCapping=g,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=i,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}}const Go="[eme]";class xn{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=xn.CDMCleanupPromise?[xn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=Y.debug.bind(Y,Go),this.log=Y.log.bind(Y,Go),this.warn=Y.warn.bind(Y,Go),this.error=Y.error.bind(Y,Go),this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(R.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(R.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(R.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(R.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:i}=this.config,s=e[t];if(s)return s.licenseUrl;if(t===Ye.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${t}"`)}getServerCertificateUrl(t){const{drmSystems:e}=this.config,i=e[t];if(i)return i.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,i=(c,d,f)=>!!c&&f.indexOf(c)===d,s=e.map(c=>c.audioCodec).filter(i),o=e.map(c=>c.videoCodec).filter(i);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((c,d)=>{const f=p=>{const g=p.shift();this.getMediaKeysPromise(g,s,o).then(v=>c({keySystem:g,mediaKeys:v})).catch(v=>{p.length?f(p):v instanceof dr?d(v):d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_ACCESS,error:v,fatal:!0},v.message))})};f(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:i}=this.config;if(typeof i!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${i}`;return e0===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return i(t,e)}getMediaKeysPromise(t,e,i){const s=Av(t,e,i,this.config.drmSystemOptions),o=this.keySystemAccessPromises[t];let c=o==null?void 0:o.keySystemAccess;if(!c){this.log(`Requesting encrypted media "${t}" key-system access with config: ${JSON.stringify(s)}`),c=this.requestMediaKeySystemAccess(t,s);const d=this.keySystemAccessPromises[t]={keySystemAccess:c};return c.catch(f=>{this.log(`Failed to obtain access to key-system "${t}": ${f}`)}),c.then(f=>{this.log(`Access for key-system "${f.keySystem}" obtained`);const p=this.fetchServerCertificate(t);return this.log(`Create media-keys for "${t}"`),d.mediaKeys=f.createMediaKeys().then(g=>(this.log(`Media-keys created for "${t}"`),p.then(v=>v?this.setMediaKeysServerCertificate(g,t,v):g))),d.mediaKeys.catch(g=>{this.error(`Failed to create media-keys for "${t}"}: ${g}`)}),d.mediaKeys})}return c.then(()=>o.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:i}){this.log(`Creating key-system session "${e}" keyId: ${Or.hexDump(t.keyId||[])}`);const s=i.createSession(),o={decryptdata:t,keySystem:e,mediaKeys:i,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(o),o}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const i=this.createMediaKeySessionContext(t),s=this.getKeyIdString(e),o="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(i,o,e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}getKeyIdString(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(t.keyId===null)throw new Error("keyId is null");return Or.hexDump(t.keyId)}updateKeySession(t,e){var i;const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${Or.hexDump(((i=t.decryptdata)==null?void 0:i.keyId)||[])}
208
- } (data length: ${e&&e.byteLength})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const s=dc(this.config),o=t.map(Qu).filter(c=>!!c&&s.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=t0(c);d?e(d):i(new Error(`Unable to find format for key-system "${c}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(c=>this.handleError(c))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof dr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=Qu(t.keyFormat),o=s?[s]:dc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=dc(this.config)),t.length===0)throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let s,o;if(e==="sinf"&&this.config.drmSystems[Ye.FAIRPLAY]){const g=Ei(new Uint8Array(i));try{const v=hc(JSON.parse(g).sinf),b=c0(new Uint8Array(v));if(!b)return;s=b.subarray(8,24),o=Ye.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Wv(i);if(g===null)return;g.version===0&&g.systemId===Ju.WIDEVINE&&g.data&&(s=g.data.subarray(8,24)),o=bv(g.systemId)}if(!o||!s)return;const c=Or.hexDump(s),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[c];for(let g=0;g<f.length;g++){const v=f[g],b=v.decryptdata;if(b.pssh||!b.keyId)continue;const E=Or.hexDump(b.keyId);if(c===E||b.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],b.pssh=new Uint8Array(i),b.keyId=s,p=d[c]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[c]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var b;this.throwIfDestroyed();const E=new wa("ISO-23001-7",c,(b=t0(g))!=null?b:"");return E.pssh=new Uint8Array(i),E.keyId=s,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,e,i,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var o,c;const d=(o=this.config.drmSystems)==null||(c=o[t.keySystem])==null?void 0:c.generateRequest;if(d)try{const b=d.call(this.hls,e,i,t);if(!b)throw new Error("Invalid response from configured generateRequest filter");e=b.initDataType,i=t.decryptdata.pssh=b.initData?new Uint8Array(b.initData):null}catch(b){var f;if(this.warn(b.message),(f=this.hls)!=null&&f.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Bc;t.mediaKeysSession.onmessage=b=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=b;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===Ye.FAIRPLAY&&(this.updateKeySession(t,qu("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=b=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const E=t.keyStatus;g.emit("keyStatus",E),E==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((b,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?b():T==="output-restricted"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var b;this.log(`Request generated for key-session "${(b=t.mediaKeysSession)==null?void 0:b.sessionId}" keyId: ${p}`)}).catch(b=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:b,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>{throw g.removeAllListeners(),this.removeSession(t),b}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Or.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Or.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,s=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((c,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{c(b.data)},onError:(b,E,T,w)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Wi({url:f.url,data:void 0},b)},`"${t}" certificate request failed (${o}). Status: ${b.code} (${b.text})`))},onTimeout:(b,E,T)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(b,E,T)=>{d(new Error("aborted"))}};s.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(c=>{o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,i,s)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,s)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||s})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((s,o)=>{const c=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${c}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,c,t)}catch(g){this.error(g)}s(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:c,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${c}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(s,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,c,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},wa.clearKeyUriToKeyIdMap();const i=e.length;xn.CDMCleanupPromise=Promise.all(e.map(s=>this.removeSession(s)).concat(t==null?void 0:t.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.reduce((s,o)=>(s.indexOf(o.keyFormat)===-1&&s.push(o.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);return s>-1&&this.mediaKeySessions.splice(s,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}xn.CDMCleanupPromise=void 0;class dr extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const o4=1;var zi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const l4="h";class ks{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:zi.MANIFEST,su:!this.initialized})}catch(o){Y.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=s=>{try{const o=s.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===zi.VIDEO||d===zi.AUDIO||d==zi.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(s,f)}catch(o){Y.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||ks.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var i,s;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=e.tracks.video)==null?void 0:s.buffer}createData(){var t;return{v:o4,sf:l4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ai(e,this.createData());const i=e.ot===zi.INIT||e.ot===zi.VIDEO||e.ot===zi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const s=ks.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),ai(t.headers,s)}else{const s=ks.toQuery(e);if(!s)return;t.url=ks.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return zi.TIMED_TEXT;if(t.sn==="initSegment")return zi.INIT;if(e==="audio")return zi.AUDIO;if(e==="main")return this.hls.audioTracks.length?zi.VIDEO:zi.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===zi.AUDIO)i=s.audioTracks;else{const o=s.maxAutoLevel,c=o>-1?o+1:s.levels.length;i=s.levels.slice(0,c)}for(const o of i)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===zi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:$e.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,s=f=>Math.round(f),o=f=>s(f/100)*100,c={br:s,d:s,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:s},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!i(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=c[f];g&&(p=g(p));const v=typeof p;let b;f==="ot"||f==="sf"||f==="st"?b=`${f}=${p}`:v==="boolean"?b=f:v==="number"?b=`${f}=${p}`:b=`${f}=${JSON.stringify(p)}`,e.push(b)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],o=[{},{},{},{}],c={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=c[d]!=null?c[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=ks.serialize(o[d]);f&&(i[`CMCD-${s[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(ks.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const c4=3e5;class h4{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=Y.log.bind(Y,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ri.SendAlternateToPenaltyBox&&i.flags===cr.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(o=>{s-i[o]>c4&&delete i[o]});for(let o=0;o<t.length;o++){const c=t[o];if(i[c])continue;if(c===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(c),e.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(o=>{const{ID:c,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===c))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ai({},g);v.details=void 0,v.url=$f(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const b=new ze(g.attrs);b["PATHWAY-ID"]=c;const E=b.AUDIO&&`${b.AUDIO}_clone_${c}`,T=b.SUBTITLES&&`${b.SUBTITLES}_clone_${c}`;E&&(i[b.AUDIO]=E,b.AUDIO=E),T&&(s[b.SUBTITLES]=T,b.SUBTITLES=T),v.attrs=b;const w=new Ra(v);return xo(w,"audio",E),xo(w,"text",T),w});e.push(...p),Mf(this.audioTracks,i,f,c),Mf(this.subtitleTracks,s,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(s.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:s.href},c=e.steeringManifestLoadPolicy.default,d=c.errorRetry||c.timeoutRetry||{},f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,b,E)=>{this.log(`Loaded steering manifest: "${s}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||b.url),C&&this.clonePathways(C),D&&this.updatePathwayPriority(D)},onError:(g,v,b,E)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,b)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Mf(n,t,e,i){n&&Object.keys(t).forEach(s=>{const o=n.filter(c=>c.groupId===s).map(c=>{const d=ai({},c);return d.details=void 0,d.attrs=new ze(d.attrs),d.url=d.attrs.URI=$f(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[s],d.attrs["PATHWAY-ID"]=i,d});n.push(...o)})}function $f(n,t,e,i){const{HOST:s,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(n=d));const f=new self.URL(n);return s&&!d&&(f.host=s),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const d4=/^age:\s*[\d.]+\s*$/im;class Nf{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new To,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(c=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(c=>{this.callbacks.onError({code:i.status,text:c.message},e,i,s)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(s)for(const d in s)t.setRequestHeader(d,s[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=o&&Wt(o)?o:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,o=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const c=e.status,d=e.responseType!=="text";if(c>=200&&c<300&&(d&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(i,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:c};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;Io(f,p,!1,c)?this.retry(f):(Y.error(`${c} while loading ${t.url}`),this.callbacks.onError({code:c,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(Io(e,i,!0))this.retry(e);else{Y.warn(`timeout while loading ${this.context.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=wc(t,i.retry),i.retry++,Y.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&d4.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function u4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const f4=/(\d+)-(\d+)\/(\d+)/;class Ff{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||v4,this.controller=new self.AbortController,this.stats=new To}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const o=p4(t,this.controller.signal),c=i.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const b=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},g-(b-s.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new y4(T||"fetch, bad network response",E,v)}return s.loading.first=b,s.total=m4(v.headers)||s.total,c&&Wt(e.highWaterMark)?this.loadProgressively(v,s,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:b}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=v[f];E&&(s.loaded=s.total=E);const T={url:b.url,data:v,code:b.status};c&&!Wt(e.highWaterMark)&&c(s,t,v,b),i.onSuccess(T,s,t,b)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const b=v&&v.code||0,E=v?v.message:null;i.onError({code:b,text:E},t,v?v.details:null,s)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,o){const c=new uf,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return c.dataLength&&o(e,i,c.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<s||c.dataLength?(c.push(g),c.dataLength>=s&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function p4(n,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ai({},n.headers))};return n.rangeEnd&&e.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),e}function g4(n){const t=f4.exec(n);if(t)return parseInt(t[2])-parseInt(t[1])+1}function m4(n){const t=n.get("Content-Range");if(t){const i=g4(t);if(Wt(i))return i}const e=n.get("Content-Length");if(e)return parseInt(e)}function v4(n,t){return new self.Request(n.url,t)}class y4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const b4=/\s/,A4={newCue(n,t,e,i){const s=[];let o,c,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let b=0;b<i.rows.length;b++)if(o=i.rows[b],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)b4.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const E=_f(p.trim()),T=Xc(t,e,E);n!=null&&(v=n.cues)!=null&&v.getCueById(T)||(c=new g(t,e,E),c.id=T,c.line=b+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),s.push(c))}return n&&s.length&&(s.sort((b,E)=>b.line==="auto"||E.line==="auto"?0:b.line>8&&E.line>8?E.line-b.line:b.line-E.line),s.forEach(b=>L0(n,b))),s}},E4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},T4=Wi(Wi({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:Nf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Rb,bufferController:Mb,capLevelController:th,errorController:yy,fpsController:a4,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:e0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:E4},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},k4()),{},{subtitleStreamController:xb,subtitleTrackController:Pb,timelineController:r4,audioStreamController:Lb,audioTrackController:Cb,emeController:xn,cmcdController:ks,contentSteeringController:h4});function k4(){return{cueHandler:A4,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 w4(n,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=eh(n),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];s.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const b=e[c].default;switch(t[c]={default:b},p){case"TimeOut":b.maxLoadTimeMs=v,b.maxTimeToFirstByteMs=v;break;case"MaxRetry":b.errorRetry.maxNumRetry=v,b.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":b.errorRetry.retryDelayMs=v,b.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":b.errorRetry.maxRetryDelayMs=v,b.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&Y.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Wi(Wi({},e),t)}function eh(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(eh):Object.keys(n).reduce((t,e)=>(t[e]=eh(n[e]),t),{}):n}function S4(n){const t=n.loader;t!==Ff&&t!==Nf?(Y.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):u4()&&(n.loader=Ff,n.progressive=!0,n.enableSoftwareAES=!0,Y.log("[config]: Progressive streaming enabled, using FetchLoader"))}class is{static get version(){return"1.4.12"}static isSupported(){return Ny()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return is.defaultConfig?is.defaultConfig:T4}static set DefaultConfig(t){is.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Bc,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,cv(t.debug||!1,"Hls instance");const e=this.config=w4(is.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&S4(e);const{abrController:i,bufferController:s,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new s(this),v=this.capLevelController=new o(this),b=new d(this),E=new Jv(this),T=new sy(this),w=e.contentSteeringController,C=w?new w(this):null,D=this.levelController=new Ay(this,C),O=new Ey(this),F=new ky(this.config),x=this.streamController=new wb(this,O,F);v.setStreamController(x),b.setStreamController(x);const N=[E,D,x];C&&N.splice(1,0,C),this.networkControllers=N;const H=[p,g,v,b,T,O];this.audioTrackController=this.createController(e.audioTrackController,N);const j=e.audioStreamController;j&&N.push(new j(this,O,F)),this.subtitleTrackController=this.createController(e.subtitleTrackController,N);const nt=e.subtitleStreamController;nt&&N.push(new nt(this,O,F)),this.createController(e.timelineController,H),F.emeController=this.emeController=this.createController(e.emeController,H),this.cmcdController=this.createController(e.cmcdController,H),this.latencyController=this.createController(ny,H),this.coreComponents=H,N.push(f);const st=f.onErrorOut;typeof st=="function"&&this.on(R.ERROR,st,f)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){Y.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Y.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){Y.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){Y.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=oc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});Y.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Y.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){Y.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){Y.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Y.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){Y.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Y.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Y.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){Y.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){Y.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(Y.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Ec.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s<i;s++)if(t[s].maxBitrate>=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(e===-1&&t&&t.length?s=t.length-1:s=e,i)for(let o=s;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}is.defaultConfig=void 0;function R4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function _4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Uf(n){const{id:t,key:e,src:i,playlist:s,duration:o}=n;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,s&&!R4()&&is.isSupported()){let p=!1;d=new is({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,b=s.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+b),v.apply(this,[E,T,w])}}}),d.loadSource(s),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const b=d==null?void 0:d.levels.findIndex(E=>Math.min(E.height,E.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=b!==-1?b:d.firstLevel}},d.on(is.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:n,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",c({id:t,key:e,hls:d,config:n,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:n,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Bf(n){return n.duration===1/0?new Promise(t=>{n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,t(n.duration),n.currentTime=0}}):n.duration}const L4=ys(async function(n){return new FontFace(n.name,`url(${n.url})`,{style:n.style,weight:n.weight}).load()},{cacheKey:([n])=>JSON.stringify(n)});let C4=class{constructor(n){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ys(async t=>{const{id:e,key:i}=t,s=await Uf(t);s.node.volume=this.host.volume,s.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},c=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:s.node});return d[p]=g,s.node.addEventListener(f,g),d},{});return{...s,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:s}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=ys(async(t,e)=>{const{id:i,captions:s,duration:o,startOffset:c,endOffset:d}=t,f=o??await Bf(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:s,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var s,o;const c=this.videoState[e];if(!(c!=null&&c.initialised)){this.videoState={...this.videoState,[e]:{...c,initialised:!0,waiting:!1,buffered:(c==null?void 0:c.buffered)??[]}};const d=(o=(s=this.scenes)==null?void 0:s.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:i}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const i=this.videoState[t],s=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:s}}},this._handleSeeking=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:i}}))},this._handleSeeked=({id:t,key:e,node:i})=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:i}})))},this._handlePlay=({id:t,key:e,node:i})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:i}}))},this._handlePlaying=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:i}}))},this._handlePause=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:i}}))},this._handleStalled=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:i}}))},this._handleTimeUpdate=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:i}}))},this._handleEnded=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:i}}))},this._handleError=({id:t,key:e,node:i})=>()=>{const s=new Qr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:s,message:s.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:i}}))},this._cleanupVideo=t=>{var e;const i=this.videos[t];i&&(i.node.pause(),i.node.src="",(e=i.hls)==null||e.destroy(),Object.keys(i.listeners??{}).forEach(s=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[s];d&&i.node.removeEventListener(s,d)}}),delete this.videos[t])},this.host=n,this.host.addController(this)}set hasPlayed(n){n!==this._hasPlayed&&(this._hasPlayed=n,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(n){!isNaN(n)&&n!==this._duration&&(this._duration=n,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(n){n!==this._scenes&&(this._scenes=n,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(n){n!==this._videos&&(this._videos=n,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(n){n!==this._videoMeta&&(this._videoMeta=n,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(n){n!==this._videoState&&(this._videoState=n,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:n,node:t,duration:e}){var i;const s=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>n===(p==null?void 0:p.key)))??{};if(t&&s&&d&&f&&typeof c<"u")for(let p=0;p<s.length;p++){const g=s.start(p),v=s.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+c)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+c)/e*100,100)})}return o}_setupTask(){new qa(this.host,async([n,t,e,i,s,o])=>{try{if(this.host._errors=[],e||n){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new Qr("Track failed to fetch");this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:f,message:f.message}))}try{const f=e.includes(".m3u8")?"playlist":"video";this.scenes=await po({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new Qr(`Source template error - ${f.message}`,!0)}}else try{this.scenes=await po({data:n,template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Qr(`Data template error - ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new Qr("Template error - no scenes created",!0);Object.keys(this.videos).forEach(d=>{this.scenes.scenes.find(({video:f})=>d===(f==null?void 0:f.key))||this._videos[d].node.pause()});const c=this.scenes.scenes.reduce((d,{video:f})=>(f&&(d[f.key]=f),d),{});Object.keys(this.videos).join("|")!==Object.keys(c).join("|")&&this.host.reset(0,!1),this.videos=c,this.videoState={...this.videoState,...this.scenes.scenes.reduce((d,{video:f,start:p,duration:g})=>{var v;const b=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:b,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[b]={initialised:!f,waiting:!!f,...this.videoState[b],buffered:f?E:(v=this.videoState[b])==null?void 0:v.buffered},d},{})},this.videoMeta=this.scenes.scenes.reduce((d,{video:f,videoMeta:p})=>(f&&p&&(d[f.key]=p),d),{}),(await Promise.all(this.scenes.fonts.map(d=>L4(d)))).forEach(d=>{document.fonts.add(d)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}}catch(c){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.message}))}finally{this.host._processing=!1}},()=>{const n=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions,debug:this.host.debug});if(this._lastDeps&&this._memoKey===n)return this._lastDeps;const t=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions,this.host.debug];return this._memoKey=n,this._lastDeps=t,t})}_setVideoCurrentTime({time:n,scene:t}){const{start:e,video:i,videoMeta:s}=t;if(i&&i.node&&s&&typeof e<"u"){const o=n-e;i.node.currentTime=Math.max(s.start,Math.min(s.start+s.duration,o+s.start))}}setVideosCurrentTime(n){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:n,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(n=>{this._cleanupVideo(n)}),this.videos={}}};function I4(n){n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen&&n.msRequestFullscreen()}function x4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const ih=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],D4={id:"captions",event:"captions:click",label:"Closed Captions"},P4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Gf={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}]},O4={id:"playbackRate",label:"Playback playbackRate",subItems:Gf};class M4 extends Cd{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==bn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),ms}}const rh=An(M4);var Hf=Number.isNaN||function(n){return typeof n=="number"&&n!==n};function $4(n,t){return!!(n===t||Hf(n)&&Hf(t))}function N4(n,t){if(n.length!==t.length)return!1;for(var e=0;e<n.length;e++)if(!$4(n[e],t[e]))return!1;return!0}function F4(n,t){t===void 0&&(t=N4);var e=null;function i(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];if(e&&e.lastThis===this&&t(s,e.lastArgs))return e.lastResult;var c=n.apply(this,s);return e={lastResult:c,lastArgs:s,lastThis:this},c}return i.clear=function(){e=null},i}const U4=F4(()=>{const n=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=Qd.map(s=>({load:!1,font:new FontFace(s.family,`url(${s.url})`,{style:s.style})}));return[{load:!0,font:n},{load:!0,font:t},{load:!0,font:e},...i]}),$r={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-100":"#a5e9ed","teal-600":"#006776","purple-100":"#d7cfff","purple-700":"#5f2fe9","green-200":"#a4d7aa","green-500":"#38b319","green-800":"#2b3c2f","grey-100":"#f0f0f0","light-50":"rgba(255, 255, 255, .05)","light-100":"rgba(255, 255, 255, .1)","light-200":"rgba(255, 255, 255, .2)","light-400":"rgba(255, 255, 255, .4)","light-500":"rgba(255, 255, 255, .5)","light-640":"rgba(255, 255, 255, .64)","light-800":"rgba(255, 255, 255, .8)","light-1000":"#fff","dark-50":"rgba(0, 0, 0, .05)","dark-80":"rgba(0, 0, 0, .08)","dark-100":"rgba(0, 0, 0, .1)","dark-200":"rgba(0, 0, 0, .2)","dark-250":"rgba(0, 0, 0, .25)","dark-400":"rgba(0, 0, 0, .4)","dark-500":"rgba(0, 0, 0, .5)","dark-640":"rgba(0, 0, 0, .64)","dark-800":"rgba(0, 0, 0, .8)","dark-900":"rgba(0, 0, 0, .9)","dark-1000":"#000"},B4={colors:$r,space:{xxs:".25rem",xs:".5rem",small:".75rem",medium:"1rem",large:"1.5rem",xl:"2.5rem"},sizes:{xxs:"1rem",xs:"1.5rem",small:"2rem",medium:"2.5rem",large:"3rem"},fontWeights:{regular:400,semibold:600},lineHeights:{small:1.1,medium:1.25,large:1.4},letterSpacings:{xxs:"-.04rem",xs:"-.03rem",small:"-.02rem",medium:"-.01rem",large:0},fontSizes:{micro:".625rem",small:".75rem",medium:".875rem",large:"1rem",xl:"1.25rem",xxl:"1.5rem",xxxl:"2rem",huge:"2.75rem"},fontFamilies:{sans:'Roobert, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", "Noto Color Emoji", sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji"',mono:'"Maison Neue Mono", Menlo, Monaco, Consolas, Liberation Mono, "Courier New", monospace'},borderWidths:{thin:".0625rem"},radii:{small:".25rem",medium:".5rem",large:".75rem",xl:"1rem"},shadows:{small:`.25rem .25rem .25rem ${$r["dark-100"]}`,medium:`0 .125rem .625rem ${$r["dark-100"]}`,large:`0 .25rem 1rem ${$r["dark-50"]}`,xl:`.25rem .25rem 1rem ${$r["dark-250"]}`,xxl:`0 .25rem 2rem ${$r["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${$r["dark-250"]}`,toolbar:`0 -.625rem .625rem ${$r["dark-50"]}`,text:`0 0 .25rem ${$r["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:$r["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Vf=Sm.flatten(B4,{delimiter:"-"}),G4=Object.keys(Vf).map(n=>qn(`:host { --${n}: ${Vf[n]}; }`)),H4=n=>{class t extends n{firstUpdated(){U4().forEach(({load:i,font:s})=>{document.fonts.add(s),i&&s.load()})}}return t.styles=[(n==null?void 0:n.styles)??[],G4,yi`
208
+ } (data length: ${e&&e.byteLength})`),s.update(e)}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){return new Promise((e,i)=>{const s=dc(this.config),o=t.map(Qu).filter(c=>!!c&&s.indexOf(c)!==-1);return this.getKeySystemSelectionPromise(o).then(({keySystem:c})=>{const d=t0(c);d?e(d):i(new Error(`Unable to find format for key-system "${c}"`))}).catch(i)})}loadKey(t){const e=t.keyInfo.decryptdata,i=this.getKeyIdString(e),s=`(keyId: ${i} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${s}`);let o=this.keyIdToKeySessionPromise[i];return o||(o=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(e).then(({keySystem:c,mediaKeys:d})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${s}`),this.attemptSetMediaKeys(c,d).then(()=>{this.throwIfDestroyed();const f=this.createMediaKeySessionContext({keySystem:c,mediaKeys:d,decryptdata:e}),p="cenc";return this.generateRequestWithPreferredKeySession(f,p,e.pssh,"playlist-key")}))),o.catch(c=>this.handleError(c))),o}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t){this.hls&&(this.error(t.message),t instanceof dr?this.hls.trigger(R.ERROR,t.data):this.hls.trigger(R.ERROR,{type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))}getKeySystemForKeyPromise(t){const e=this.getKeyIdString(t),i=this.keyIdToKeySessionPromise[e];if(!i){const s=Qu(t.keyFormat),o=s?[s]:dc(this.config);return this.attemptKeySystemAccess(o)}return i}getKeySystemSelectionPromise(t){if(t.length||(t=dc(this.config)),t.length===0)throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}_onMediaEncrypted(t){const{initDataType:e,initData:i}=t;if(this.debug(`"${t.type}" event: init data type: "${e}"`),i===null)return;let s,o;if(e==="sinf"&&this.config.drmSystems[Ye.FAIRPLAY]){const g=Ai(new Uint8Array(i));try{const v=hc(JSON.parse(g).sinf),b=c0(new Uint8Array(v));if(!b)return;s=b.subarray(8,24),o=Ye.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const g=Wv(i);if(g===null)return;g.version===0&&g.systemId===Ju.WIDEVINE&&g.data&&(s=g.data.subarray(8,24)),o=bv(g.systemId)}if(!o||!s)return;const c=Or.hexDump(s),{keyIdToKeySessionPromise:d,mediaKeySessions:f}=this;let p=d[c];for(let g=0;g<f.length;g++){const v=f[g],b=v.decryptdata;if(b.pssh||!b.keyId)continue;const E=Or.hexDump(b.keyId);if(c===E||b.uri.replace(/-/g,"").indexOf(c)!==-1){p=d[E],delete d[E],b.pssh=new Uint8Array(i),b.keyId=s,p=d[c]=p.then(()=>this.generateRequestWithPreferredKeySession(v,e,i,"encrypted-event-key-match"));break}}p||(p=d[c]=this.getKeySystemSelectionPromise([o]).then(({keySystem:g,mediaKeys:v})=>{var b;this.throwIfDestroyed();const E=new wa("ISO-23001-7",c,(b=t0(g))!=null?b:"");return E.pssh=new Uint8Array(i),E.keyId=s,this.attemptSetMediaKeys(g,v).then(()=>{this.throwIfDestroyed();const T=this.createMediaKeySessionContext({decryptdata:E,keySystem:g,mediaKeys:v});return this.generateRequestWithPreferredKeySession(T,e,i,"encrypted-event-no-match")})})),p.catch(g=>this.handleError(g))}_onWaitingForKey(t){this.log(`"${t.type}" event`)}attemptSetMediaKeys(t,e){const i=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const s=Promise.all(i).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(e)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${t}"`),i.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(o=>i.indexOf(o)===-1)})}generateRequestWithPreferredKeySession(t,e,i,s){var o,c;const d=(o=this.config.drmSystems)==null||(c=o[t.keySystem])==null?void 0:c.generateRequest;if(d)try{const b=d.call(this.hls,e,i,t);if(!b)throw new Error("Invalid response from configured generateRequest filter");e=b.initDataType,i=t.decryptdata.pssh=b.initData?new Uint8Array(b.initData):null}catch(b){var f;if(this.warn(b.message),(f=this.hls)!=null&&f.config.debug)throw b}if(i===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(t);const p=this.getKeyIdString(t.decryptdata);this.log(`Generating key-session request for "${s}": ${p} (init data type: ${e} length: ${i?i.byteLength:null})`);const g=new Bc;t.mediaKeysSession.onmessage=b=>{const E=t.mediaKeysSession;if(!E){g.emit("error",new Error("invalid state"));return}const{messageType:T,message:w}=b;this.log(`"${T}" message event for session "${E.sessionId}" message size: ${w.byteLength}`),T==="license-request"||T==="license-renewal"?this.renewLicense(t,w).catch(C=>{this.handleError(C),g.emit("error",C)}):T==="license-release"?t.keySystem===Ye.FAIRPLAY&&(this.updateKeySession(t,qu("acknowledged")),this.removeSession(t)):this.warn(`unhandled media key message type "${T}"`)},t.mediaKeysSession.onkeystatuseschange=b=>{if(!t.mediaKeysSession){g.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(t);const E=t.keyStatus;g.emit("keyStatus",E),E==="expired"&&(this.warn(`${t.keySystem} expired for key ${p}`),this.renewKeySession(t))};const v=new Promise((b,E)=>{g.on("error",E),g.on("keyStatus",T=>{T.startsWith("usable")?b():T==="output-restricted"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):T==="internal-error"?E(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${T}"`)):T==="expired"?E(new Error("key expired while generating request")):this.warn(`unhandled key status change "${T}"`)})});return t.mediaKeysSession.generateRequest(e,i).then(()=>{var b;this.log(`Request generated for key-session "${(b=t.mediaKeysSession)==null?void 0:b.sessionId}" keyId: ${p}`)}).catch(b=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_NO_SESSION,error:b,fatal:!1},`Error generating key-session request: ${b}`)}).then(()=>v).catch(b=>{throw g.removeAllListeners(),this.removeSession(t),b}).then(()=>(g.removeAllListeners(),t))}onKeyStatusChange(t){t.mediaKeysSession.keyStatuses.forEach((e,i)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${Or.hexDump("buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i))} session keyId: ${Or.hexDump(new Uint8Array(t.decryptdata.keyId||[]))} uri: ${t.decryptdata.uri}`),t.keyStatus=e})}fetchServerCertificate(t){const e=this.config,i=e.loader,s=new i(e),o=this.getServerCertificateUrl(t);return o?(this.log(`Fetching serverCertificate for "${t}"`),new Promise((c,d)=>{const f={responseType:"arraybuffer",url:o},p=e.certLoadPolicy.default,g={loadPolicy:p,timeout:p.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},v={onSuccess:(b,E,T,w)=>{c(b.data)},onError:(b,E,T,w)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:Wi({url:f.url,data:void 0},b)},`"${t}" certificate request failed (${o}). Status: ${b.code} (${b.text})`))},onTimeout:(b,E,T)=>{d(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:T,response:{url:f.url,data:void 0}},`"${t}" certificate request timed out (${o})`))},onAbort:(b,E,T)=>{d(new Error("aborted"))}};s.load(f,g,v)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,i){return new Promise((s,o)=>{t.setServerCertificate(i).then(c=>{this.log(`setServerCertificate ${c?"success":"not supported by CDM"} (${i==null?void 0:i.byteLength}) on "${e}"`),s(t)}).catch(c=>{o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:c,fatal:!0},c.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(i=>this.updateKeySession(t,new Uint8Array(i)).catch(s=>{throw new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}setupLicenseXHR(t,e,i,s){const o=this.config.licenseXhrSetup;return o?Promise.resolve().then(()=>{if(!i.decryptdata)throw new Error("Key removed");return o.call(this.hls,t,e,i,s)}).catch(c=>{if(!i.decryptdata)throw c;return t.open("POST",e,!0),o.call(this.hls,t,e,i,s)}).then(c=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:c||s})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:s}))}requestLicense(t,e){const i=this.config.keyLoadPolicy.default;return new Promise((s,o)=>{const c=this.getLicenseServerUrl(t.keySystem);this.log(`Sending license request to URL: ${c}`);const d=new XMLHttpRequest;d.responseType="arraybuffer",d.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return o(new Error("invalid state"));if(d.readyState===4)if(d.status===200){this._requestLicenseFailureCount=0;let f=d.response;this.log(`License received ${f instanceof ArrayBuffer?f.byteLength:f}`);const p=this.config.licenseResponseCallback;if(p)try{f=p.call(this.hls,d,c,t)}catch(g){this.error(g)}s(f)}else{const f=i.errorRetry,p=f?f.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>p||d.status>=400&&d.status<500)o(new dr({type:qt.KEY_SYSTEM_ERROR,details:ut.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:d,response:{url:c,data:void 0,code:d.status,text:d.statusText}},`License Request XHR failed (${c}). Status: ${d.status} (${d.statusText})`));else{const g=p-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${g} attempts left`),this.requestLicense(t,e).then(s,o)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=d,this.setupLicenseXHR(d,c,t,e).then(({xhr:f,licenseChallenge:p})=>{f.send(p)})})}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const i=e.media;this.media=i,i.addEventListener("encrypted",this.onMediaEncrypted),i.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const t=this.media,e=this.mediaKeySessions;t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},wa.clearKeyUriToKeyIdMap();const i=e.length;xn.CDMCleanupPromise=Promise.all(e.map(s=>this.removeSession(s)).concat(t==null?void 0:t.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}. media.src: ${t==null?void 0:t.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(t,{sessionKeys:e}){if(!(!e||!this.config.emeEnabled)&&!this.keyFormatPromise){const i=e.reduce((s,o)=>(s.indexOf(o.keyFormat)===-1&&s.push(o.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${i.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(i)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:i}=t;if(e){this.log(`Remove licenses and keys and close session ${e.sessionId}`),e.onmessage=null,e.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(t);return s>-1&&this.mediaKeySessions.splice(s,1),e.remove().catch(o=>{this.log(`Could not remove session: ${o}`)}).then(()=>e.close()).catch(o=>{this.log(`Could not close session: ${o}`)})}}}xn.CDMCleanupPromise=void 0;class dr extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}const o4=1;var zi={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const l4="h";class ks{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=s=>{try{this.apply(s,{ot:zi.MANIFEST,su:!this.initialized})}catch(o){Y.warn("Could not generate manifest CMCD data.",o)}},this.applyFragmentData=s=>{try{const o=s.frag,c=this.hls.levels[o.level],d=this.getObjectType(o),f={d:o.duration*1e3,ot:d};(d===zi.VIDEO||d===zi.AUDIO||d==zi.MUXED)&&(f.br=c.bitrate/1e3,f.tb=this.getTopBandwidth(d)/1e3,f.bl=this.getBufferLength(d)),this.apply(s,f)}catch(o){Y.warn("Could not generate segment CMCD data.",o)}},this.hls=t;const e=this.config=t.config,{cmcd:i}=e;i!=null&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||ks.uuid(),this.cid=i.contentId,this.useHeaders=i.useHeaders===!0,this.registerListeners())}registerListeners(){const t=this.hls;t.on(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(R.MEDIA_DETACHED,this.onMediaDetached,this),t.on(R.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(R.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(R.MEDIA_DETACHED,this.onMediaDetached,this),t.off(R.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var i,s;this.audioBuffer=(i=e.tracks.audio)==null?void 0:i.buffer,this.videoBuffer=(s=e.tracks.video)==null?void 0:s.buffer}createData(){var t;return{v:o4,sf:l4,sid:this.sid,cid:this.cid,pr:(t=this.media)==null?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){ai(e,this.createData());const i=e.ot===zi.INIT||e.ot===zi.VIDEO||e.ot===zi.MUXED;if(this.starved&&i&&(e.bs=!0,e.su=!0,this.starved=!1),e.su==null&&(e.su=this.buffering),this.useHeaders){const s=ks.toHeaders(e);if(!Object.keys(s).length)return;t.headers||(t.headers={}),ai(t.headers,s)}else{const s=ks.toQuery(e);if(!s)return;t.url=ks.appendQueryToUri(t.url,s)}}getObjectType(t){const{type:e}=t;if(e==="subtitle")return zi.TIMED_TEXT;if(t.sn==="initSegment")return zi.INIT;if(e==="audio")return zi.AUDIO;if(e==="main")return this.hls.audioTracks.length?zi.VIDEO:zi.MUXED}getTopBandwidth(t){let e=0,i;const s=this.hls;if(t===zi.AUDIO)i=s.audioTracks;else{const o=s.maxAutoLevel,c=o>-1?o+1:s.levels.length;i=s.levels.slice(0,c)}for(const o of i)o.bitrate>e&&(e=o.bitrate);return e>0?e:NaN}getBufferLength(t){const e=this.hls.media,i=t===zi.AUDIO?this.audioBuffer:this.videoBuffer;return!i||!e?NaN:$e.bufferInfo(i,e.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,i=t||this.config.loader;return class{constructor(s){this.loader=void 0,this.loader=new i(s)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(s,o,c){e(s),this.loader.load(s,o,c)}}}static uuid(){const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}static serialize(t){const e=[],i=f=>!Number.isNaN(f)&&f!=null&&f!==""&&f!==!1,s=f=>Math.round(f),o=f=>s(f/100)*100,c={br:s,d:s,bl:o,dl:o,mtp:o,nor:f=>encodeURIComponent(f),rtp:o,tb:s},d=Object.keys(t||{}).sort();for(const f of d){let p=t[f];if(!i(p)||f==="v"&&p===1||f=="pr"&&p===1)continue;const g=c[f];g&&(p=g(p));const v=typeof p;let b;f==="ot"||f==="sf"||f==="st"?b=`${f}=${p}`:v==="boolean"?b=f:v==="number"?b=`${f}=${p}`:b=`${f}=${JSON.stringify(p)}`,e.push(b)}return e.join(",")}static toHeaders(t){const e=Object.keys(t),i={},s=["Object","Request","Session","Status"],o=[{},{},{},{}],c={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const d of e){const f=c[d]!=null?c[d]:1;o[f][d]=t[d]}for(let d=0;d<o.length;d++){const f=ks.serialize(o[d]);f&&(i[`CMCD-${s[d]}`]=f)}return i}static toQuery(t){return`CMCD=${encodeURIComponent(ks.serialize(t))}`}static appendQueryToUri(t,e){if(!e)return t;const i=t.includes("?")?"&":"?";return`${t}${i}${e}`}}const c4=3e5;class h4{constructor(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=Y.log.bind(Y,"[content-steering]:"),this.registerListeners()}registerListeners(){const t=this.hls;t.on(R.MANIFEST_LOADING,this.onManifestLoading,this),t.on(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(R.MANIFEST_PARSED,this.onManifestParsed,this),t.on(R.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(R.MANIFEST_LOADING,this.onManifestLoading,this),t.off(R.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(R.MANIFEST_PARSED,this.onManifestParsed,this),t.off(R.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const t=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,t)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(i=>i!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:i}=e;i!==null&&(this.pathwayId=i.pathwayId,this.uri=i.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:i}=e;if((i==null?void 0:i.action)===Ri.SendAlternateToPenaltyBox&&i.flags===cr.MoveAllAlternatesMatchingHost){let s=this.pathwayPriority;const o=this.pathwayId;this.penalizedPathways[o]||(this.penalizedPathways[o]=performance.now()),!s&&this.levels&&(s=this.levels.reduce((c,d)=>(c.indexOf(d.pathwayId)===-1&&c.push(d.pathwayId),c),[])),s&&s.length>1&&(this.updatePathwayPriority(s),i.resolved=this.pathwayId!==o)}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(e.length===0){const i=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${i}"`),e=this.getLevelsForPathway(i),this.pathwayId=i}return e.length!==t.length?(this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e):t}getLevelsForPathway(t){return this.levels===null?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;let e;const i=this.penalizedPathways,s=performance.now();Object.keys(i).forEach(o=>{s-i[o]>c4&&delete i[o]});for(let o=0;o<t.length;o++){const c=t[o];if(i[c])continue;if(c===this.pathwayId)return;const d=this.hls.nextLoadLevel,f=this.hls.levels[d];if(e=this.getLevelsForPathway(c),e.length>0){this.log(`Setting Pathway to "${c}"`),this.pathwayId=c,this.hls.trigger(R.LEVELS_UPDATED,{levels:e});const p=this.hls.levels[d];f&&p&&this.levels&&(p.attrs["STABLE-VARIANT-ID"]!==f.attrs["STABLE-VARIANT-ID"]&&p.bitrate!==f.bitrate&&this.log(`Unstable Pathways change from bitrate ${f.bitrate} to ${p.bitrate}`),this.hls.nextLoadLevel=d);break}}}clonePathways(t){const e=this.levels;if(!e)return;const i={},s={};t.forEach(o=>{const{ID:c,"BASE-ID":d,"URI-REPLACEMENT":f}=o;if(e.some(g=>g.pathwayId===c))return;const p=this.getLevelsForPathway(d).map(g=>{const v=ai({},g);v.details=void 0,v.url=$f(g.uri,g.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",f);const b=new ze(g.attrs);b["PATHWAY-ID"]=c;const E=b.AUDIO&&`${b.AUDIO}_clone_${c}`,T=b.SUBTITLES&&`${b.SUBTITLES}_clone_${c}`;E&&(i[b.AUDIO]=E,b.AUDIO=E),T&&(s[b.SUBTITLES]=T,b.SUBTITLES=T),v.attrs=b;const w=new Ra(v);return xo(w,"audio",E),xo(w,"text",T),w});e.push(...p),Mf(this.audioTracks,i,f,c),Mf(this.subtitleTracks,s,f,c)})}loadSteeringManifest(t){const e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${t}`);return}if(s.protocol!=="data:"){const g=(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+g)}const o={responseType:"json",url:s.href},c=e.steeringManifestLoadPolicy.default,d=c.errorRetry||c.timeoutRetry||{},f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:d.maxNumRetry||0,retryDelay:d.retryDelayMs||0,maxRetryDelay:d.maxRetryDelayMs||0},p={onSuccess:(g,v,b,E)=>{this.log(`Loaded steering manifest: "${s}"`);const T=g.data;if(T.VERSION!==1){this.log(`Steering VERSION ${T.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=T.TTL;const{"RELOAD-URI":w,"PATHWAY-CLONES":C,"PATHWAY-PRIORITY":D}=T;if(w)try{this.uri=new self.URL(w,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${w}`);return}this.scheduleRefresh(this.uri||b.url),C&&this.clonePathways(C),D&&this.updatePathwayPriority(D)},onError:(g,v,b,E)=>{if(this.log(`Error loading steering manifest: ${g.code} ${g.text} (${v.url})`),this.stopLoad(),g.code===410){this.enabled=!1,this.log(`Steering manifest ${v.url} no longer available`);return}let T=this.timeToLoad*1e3;if(g.code===429){const w=this.loader;if(typeof(w==null?void 0:w.getResponseHeader)=="function"){const C=w.getResponseHeader("Retry-After");C&&(T=parseFloat(C)*1e3)}this.log(`Steering manifest ${v.url} rate limited`);return}this.scheduleRefresh(this.uri||v.url,T)},onTimeout:(g,v,b)=>{this.log(`Timeout loading steering manifest (${v.url})`),this.scheduleRefresh(this.uri||v.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(o,f,p)}scheduleRefresh(t,e=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(t)},e)}}function Mf(n,t,e,i){n&&Object.keys(t).forEach(s=>{const o=n.filter(c=>c.groupId===s).map(c=>{const d=ai({},c);return d.details=void 0,d.attrs=new ze(d.attrs),d.url=d.attrs.URI=$f(c.url,c.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",e),d.groupId=d.attrs["GROUP-ID"]=t[s],d.attrs["PATHWAY-ID"]=i,d});n.push(...o)})}function $f(n,t,e,i){const{HOST:s,PARAMS:o,[e]:c}=i;let d;t&&(d=c==null?void 0:c[t],d&&(n=d));const f=new self.URL(n);return s&&!d&&(f.host=s),o&&Object.keys(o).sort().forEach(p=>{p&&f.searchParams.set(p,o[p])}),f.href}const d4=/^age:\s*[\d.]+\s*$/im;class Nf{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new To,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,t.readyState!==4&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t)return;const i=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const o=this.xhrSetup;o?Promise.resolve().then(()=>{if(!this.stats.aborted)return o(i,e.url)}).catch(c=>(i.open("GET",e.url,!0),o(i,e.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,e,t)}).catch(c=>{this.callbacks.onError({code:i.status,text:c.message},e,i,s)}):this.openAndSendXhr(i,e,t)}openAndSendXhr(t,e,i){t.readyState||t.open("GET",e.url,!0);const s=this.context.headers,{maxTimeToFirstByteMs:o,maxLoadTimeMs:c}=i.loadPolicy;if(s)for(const d in s)t.setRequestHeader(d,s[d]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),i.timeout=o&&Wt(o)?o:c,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:i}=this;if(!t||!e)return;const s=e.readyState,o=this.config;if(!i.aborted&&s>=2&&(i.loading.first===0&&(i.loading.first=Math.max(self.performance.now(),i.loading.start),o.timeout!==o.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),o.timeout=o.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),o.loadPolicy.maxLoadTimeMs-(i.loading.first-i.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const c=e.status,d=e.responseType!=="text";if(c>=200&&c<300&&(d&&e.response||e.responseText!==null)){i.loading.end=Math.max(self.performance.now(),i.loading.first);const f=d?e.response:e.responseText,p=e.responseType==="arraybuffer"?f.byteLength:f.length;if(i.loaded=i.total=p,i.bwEstimate=i.total*8e3/(i.loading.end-i.loading.first),!this.callbacks)return;const g=this.callbacks.onProgress;if(g&&g(i,t,f,e),!this.callbacks)return;const v={url:e.responseURL,data:f,code:c};this.callbacks.onSuccess(v,i,t,e)}else{const f=o.loadPolicy.errorRetry,p=i.retry;Io(f,p,!1,c)?this.retry(f):(Y.error(`${c} while loading ${t.url}`),this.callbacks.onError({code:c,text:e.statusText},t,e,i))}}}loadtimeout(){var t;const e=(t=this.config)==null?void 0:t.loadPolicy.timeoutRetry,i=this.stats.retry;if(Io(e,i,!0))this.retry(e);else{Y.warn(`timeout while loading ${this.context.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:i}=this;this.retryDelay=wc(t,i.retry),i.retry++,Y.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${e.url}, retrying ${i.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&d4.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}function u4(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const f4=/(\d+)-(\d+)\/(\d+)/;class Ff{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||v4,this.controller=new self.AbortController,this.stats=new To}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const t=this.response;t!=null&&t.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),(t=this.callbacks)!=null&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,i){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const o=p4(t,this.controller.signal),c=i.onProgress,d=t.responseType==="arraybuffer",f=d?"byteLength":"length",{maxTimeToFirstByteMs:p,maxLoadTimeMs:g}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=i,this.request=this.fetchSetup(t,o),self.clearTimeout(this.requestTimeout),e.timeout=p&&Wt(p)?p:g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},e.timeout),self.fetch(this.request).then(v=>{this.response=this.loader=v;const b=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=g,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),i.onTimeout(s,t,this.response)},g-(b-s.loading.start)),!v.ok){const{status:E,statusText:T}=v;throw new y4(T||"fetch, bad network response",E,v)}return s.loading.first=b,s.total=m4(v.headers)||s.total,c&&Wt(e.highWaterMark)?this.loadProgressively(v,s,t,e.highWaterMark,c):d?v.arrayBuffer():t.responseType==="json"?v.json():v.text()}).then(v=>{const{response:b}=this;self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const E=v[f];E&&(s.loaded=s.total=E);const T={url:b.url,data:v,code:b.status};c&&!Wt(e.highWaterMark)&&c(s,t,v,b),i.onSuccess(T,s,t,b)}).catch(v=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const b=v&&v.code||0,E=v?v.message:null;i.onError({code:b,text:E},t,v?v.details:null,s)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,i,s=0,o){const c=new uf,d=t.body.getReader(),f=()=>d.read().then(p=>{if(p.done)return c.dataLength&&o(e,i,c.flush(),t),Promise.resolve(new ArrayBuffer(0));const g=p.value,v=g.length;return e.loaded+=v,v<s||c.dataLength?(c.push(g),c.dataLength>=s&&o(e,i,c.flush(),t)):o(e,i,g,t),f()}).catch(()=>Promise.reject());return f()}}function p4(n,t){const e={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ai({},n.headers))};return n.rangeEnd&&e.headers.set("Range","bytes="+n.rangeStart+"-"+String(n.rangeEnd-1)),e}function g4(n){const t=f4.exec(n);if(t)return parseInt(t[2])-parseInt(t[1])+1}function m4(n){const t=n.get("Content-Range");if(t){const i=g4(t);if(Wt(i))return i}const e=n.get("Content-Length");if(e)return parseInt(e)}function v4(n,t){return new self.Request(n.url,t)}class y4 extends Error{constructor(t,e,i){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=i}}const b4=/\s/,A4={newCue(n,t,e,i){const s=[];let o,c,d,f,p;const g=self.VTTCue||self.TextTrackCue;for(let b=0;b<i.rows.length;b++)if(o=i.rows[b],d=!0,f=0,p="",!o.isEmpty()){var v;for(let w=0;w<o.chars.length;w++)b4.test(o.chars[w].uchar)&&d?f++:(p+=o.chars[w].uchar,d=!1);o.cueStartTime=t,t===e&&(e+=1e-4),f>=16?f--:f++;const E=_f(p.trim()),T=Xc(t,e,E);n!=null&&(v=n.cues)!=null&&v.getCueById(T)||(c=new g(t,e,E),c.id=T,c.line=b+1,c.align="left",c.position=10+Math.min(80,Math.floor(f*8/32)*10),s.push(c))}return n&&s.length&&(s.sort((b,E)=>b.line==="auto"||E.line==="auto"?0:b.line>8&&E.line>8?E.line-b.line:b.line-E.line),s.forEach(b=>L0(n,b))),s}},E4={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},T4=Wi(Wi({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:Nf,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Rb,bufferController:Mb,capLevelController:th,errorController:yy,fpsController:a4,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:e0,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:E4},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},k4()),{},{subtitleStreamController:xb,subtitleTrackController:Pb,timelineController:r4,audioStreamController:Lb,audioTrackController:Cb,emeController:xn,cmcdController:ks,contentSteeringController:h4});function k4(){return{cueHandler:A4,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 w4(n,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(t.liveMaxLatencyDurationCount!==void 0&&(t.liveSyncDurationCount===void 0||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(t.liveMaxLatencyDuration!==void 0&&(t.liveSyncDuration===void 0||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const e=eh(n),i=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return i.forEach(o=>{const c=`${o==="level"?"playlist":o}LoadPolicy`,d=t[c]===void 0,f=[];s.forEach(p=>{const g=`${o}Loading${p}`,v=t[g];if(v!==void 0&&d){f.push(g);const b=e[c].default;switch(t[c]={default:b},p){case"TimeOut":b.maxLoadTimeMs=v,b.maxTimeToFirstByteMs=v;break;case"MaxRetry":b.errorRetry.maxNumRetry=v,b.timeoutRetry.maxNumRetry=v;break;case"RetryDelay":b.errorRetry.retryDelayMs=v,b.timeoutRetry.retryDelayMs=v;break;case"MaxRetryTimeout":b.errorRetry.maxRetryDelayMs=v,b.timeoutRetry.maxRetryDelayMs=v;break}}}),f.length&&Y.warn(`hls.js config: "${f.join('", "')}" setting(s) are deprecated, use "${c}": ${JSON.stringify(t[c])}`)}),Wi(Wi({},e),t)}function eh(n){return n&&typeof n=="object"?Array.isArray(n)?n.map(eh):Object.keys(n).reduce((t,e)=>(t[e]=eh(n[e]),t),{}):n}function S4(n){const t=n.loader;t!==Ff&&t!==Nf?(Y.log("[config]: Custom loader detected, cannot enable progressive streaming"),n.progressive=!1):u4()&&(n.loader=Ff,n.progressive=!0,n.enableSoftwareAES=!0,Y.log("[config]: Progressive streaming enabled, using FetchLoader"))}class is{static get version(){return"1.4.12"}static isSupported(){return Ny()}static get Events(){return R}static get ErrorTypes(){return qt}static get ErrorDetails(){return ut}static get DefaultConfig(){return is.defaultConfig?is.defaultConfig:T4}static set DefaultConfig(t){is.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Bc,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,cv(t.debug||!1,"Hls instance");const e=this.config=w4(is.DefaultConfig,t);this.userConfig=t,this._autoLevelCapping=-1,e.progressive&&S4(e);const{abrController:i,bufferController:s,capLevelController:o,errorController:c,fpsController:d}=e,f=new c(this),p=this.abrController=new i(this),g=this.bufferController=new s(this),v=this.capLevelController=new o(this),b=new d(this),E=new Jv(this),T=new sy(this),w=e.contentSteeringController,C=w?new w(this):null,D=this.levelController=new Ay(this,C),O=new Ey(this),F=new ky(this.config),x=this.streamController=new wb(this,O,F);v.setStreamController(x),b.setStreamController(x);const N=[E,D,x];C&&N.splice(1,0,C),this.networkControllers=N;const H=[p,g,v,b,T,O];this.audioTrackController=this.createController(e.audioTrackController,N);const j=e.audioStreamController;j&&N.push(new j(this,O,F)),this.subtitleTrackController=this.createController(e.subtitleTrackController,N);const nt=e.subtitleStreamController;nt&&N.push(new nt(this,O,F)),this.createController(e.timelineController,H),F.emeController=this.emeController=this.createController(e.emeController,H),this.cmcdController=this.createController(e.cmcdController,H),this.latencyController=this.createController(ny,H),this.coreComponents=H,N.push(f);const st=f.onErrorOut;typeof st=="function"&&this.on(R.ERROR,st,f)}createController(t,e){if(t){const i=new t(this);return e&&e.push(i),i}return null}on(t,e,i=this){this._emitter.on(t,e,i)}once(t,e,i=this){this._emitter.once(t,e,i)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,i=this,s){this._emitter.off(t,e,i,s)}listeners(t){return this._emitter.listeners(t)}emit(t,e,i){return this._emitter.emit(t,e,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(i){Y.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(R.ERROR,{type:qt.OTHER_ERROR,details:ut.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){Y.log("destroy"),this.trigger(R.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){Y.log("attachMedia"),this._media=t,this.trigger(R.MEDIA_ATTACHING,{media:t})}detachMedia(){Y.log("detachMedia"),this.trigger(R.MEDIA_DETACHING,void 0),this._media=null}loadSource(t){this.stopLoad();const e=this.media,i=this.url,s=this.url=oc.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});Y.log(`loadSource:${s}`),e&&i&&(i!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(R.MANIFEST_LOADING,{url:t})}startLoad(t=-1){Y.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){Y.log("stopLoad"),this.networkControllers.forEach(t=>{t.stopLoad()})}swapAudioCodec(){Y.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){Y.log("recoverMediaError");const t=this._media;this.detachMedia(),t&&this.attachMedia(t)}removeLevel(t,e=0){this.levelController.removeLevel(t,e)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){Y.log(`set currentLevel:${t}`),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){Y.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){Y.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){Y.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){return this.levelController.startLevel}set startLevel(t){Y.log(`set startLevel:${t}`),t!==-1&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(Y.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){Ec.indexOf(t)>-1&&(this._maxHdcpLevel=t)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const i=t.length;for(let s=0;s<i;s++)if(t[s].maxBitrate>=e)return s;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let s;if(e===-1&&t&&t.length?s=t.length-1:s=e,i)for(let o=s;o--;){const c=t[o].attrs["HDCP-LEVEL"];if(c&&c<=i)return o}return s}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return t?t.subtitleDisplay:!1}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}is.defaultConfig=void 0;function R4(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)}function _4(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Uf(n){const{id:t,key:e,src:i,playlist:s,duration:o}=n;return new Promise(c=>{let d=null;const f=document.createElement("video");if(f.playsInline=!0,f.muted=!0,f.loop=!1,s&&!R4()&&is.isSupported()){let p=!1;d=new is({autoStartLoad:!0,xhrSetup:g=>{const{open:v}=g,b=s.split("?")[1];g.open=function(E,T,w){T.toString().includes("?")||(T+="?"+b),v.apply(this,[E,T,w])}}}),d.loadSource(s),d.attachMedia(f),d.startLoadOnce=(g=-1,v)=>{if(d&&!p){const b=d==null?void 0:d.levels.findIndex(E=>Math.min(E.height,E.width)===v);d.startLevel=d.firstLevel,d.startLoad(g),p=!0,d.currentLevel=b!==-1?b:d.firstLevel}},d.on(is.Events.LEVEL_LOADED,async()=>{p||d==null||d.stopLoad(),c({id:t,key:e,hls:d,config:n,node:f})})}else{f.src=i;let p=!1;if(f.startLoadOnce=()=>{p||(f.preload="auto",f.load(),p=!0)},o)f.preload="none",c({id:t,key:e,hls:d,config:n,node:f});else{f.preload="metadata";const g=async()=>{c({id:t,key:e,hls:d,config:n,node:f}),f.removeEventListener("loadedmetadata",g)};f.addEventListener("loadedmetadata",g)}}})}async function Bf(n){return n.duration===1/0?new Promise(t=>{n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,t(n.duration),n.currentTime=0}}):n.duration}const L4=ys(async function(n){return new FontFace(n.name,`url(${n.url})`,{style:n.style,weight:n.weight}).load()},{cacheKey:([n])=>JSON.stringify(n)});let C4=class{constructor(n){this._hasPlayed=!1,this._memoKey=null,this._lastDeps=null,this._duration=0,this._scenes=null,this._videos={},this._videoMeta={},this._videoState={},this._resolveVideo=ys(async t=>{const{id:e,key:i}=t,s=await Uf(t);s.node.volume=this.host.volume,s.node.playbackRate=this.host.playbackRate;const o={loadeddata:this._handleLoadedData,waiting:this._handleWaiting,canplay:this._handleCanPlay,progress:this._handleProgress,seeking:this._handleSeeking,seeked:this._handleSeeked,play:this._handlePlay,playing:this._handlePlaying,pause:this._handlePause,stalled:this._handleStalled,timeupdate:this._handleTimeUpdate,ended:this._handleEnded,error:this._handleError},c=Object.keys(o).reduce((d,f)=>{const p=f,g=o[p]({id:e,key:i,node:s.node});return d[p]=g,s.node.addEventListener(f,g),d},{});return{...s,listeners:c}},{cacheKey:([{id:t,key:e,src:i,playlist:s}])=>JSON.stringify({id:t,key:e,src:i==null?void 0:i.split("?")[0],playlist:s==null?void 0:s.split("?")[0]})}),this._resolveVideoMeta=ys(async(t,e)=>{const{id:i,captions:s,duration:o,startOffset:c,endOffset:d}=t,f=o??await Bf(e),p=(c??0)*f,g=(1-(d??0))*f;return{id:i,captions:s,start:p,duration:g-p}},{cacheKey:([{id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c}])=>JSON.stringify({id:t,key:e,captions:i,duration:s,startOffset:o,endOffset:c})}),this._handleLoadedData=({id:t,key:e,node:i})=>()=>{var s,o;const c=this.videoState[e];if(!(c!=null&&c.initialised)){this.videoState={...this.videoState,[e]:{...c,initialised:!0,waiting:!1,buffered:(c==null?void 0:c.buffered)??[]}};const d=(o=(s=this.scenes)==null?void 0:s.scenes)==null?void 0:o.find(({video:f})=>{f==null||f.key});d&&this._setVideoCurrentTime({scene:d,time:this.host.currentTime}),this.host.dispatchEvent(new CustomEvent("video:loadeddata",{detail:{id:t,key:e,node:i}}))}},this._handleWaiting=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&!(e!=null&&e.waiting)&&(this.videoState={...this.videoState,[t]:{...e,waiting:!0}})},this._handleCanPlay=({key:t})=>()=>{const e=this.videoState[t];e!=null&&e.initialised&&e!=null&&e.waiting&&(this.videoState={...this.videoState,[t]:{...e,waiting:!1}}),this.host.paused&&this.host.draw()},this._handleProgress=({key:t,node:e})=>()=>{const i=this.videoState[t],s=this._getBufferSegments({key:t,node:e,duration:this.host.duration});this.videoState={...this.videoState,[t]:{...i,buffered:s}}},this._handleSeeking=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:seeking",{detail:{id:t,key:e,node:i}}))},this._handleSeeked=({id:t,key:e,node:i})=>()=>{const s=this.videoState[e];s!=null&&s.initialised&&(this.host.draw(),this.host.dispatchEvent(new CustomEvent("video:seeked",{detail:{id:t,key:e,node:i}})))},this._handlePlay=({id:t,key:e,node:i})=>()=>{this.hasPlayed=!0,this.host.dispatchEvent(new CustomEvent("video:play",{detail:{id:t,key:e,node:i}}))},this._handlePlaying=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:playing",{detail:{id:t,key:e,node:i}}))},this._handlePause=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:pause",{detail:{id:t,key:e,node:i}}))},this._handleStalled=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:stalled",{detail:{id:t,key:e,node:i}}))},this._handleTimeUpdate=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:timeupdate",{detail:{id:t,key:e,node:i}}))},this._handleEnded=({id:t,key:e,node:i})=>()=>{this.host.dispatchEvent(new CustomEvent("video:ended",{detail:{id:t,key:e,node:i}}))},this._handleError=({id:t,key:e,node:i})=>()=>{const s=new Qr(`Video error - answer ${t} failed to load`);this.host.dispatchEvent(new ErrorEvent("error",{bubbles:!0,composed:!0,error:s,message:s.message})),this.host.dispatchEvent(new CustomEvent("video:error",{detail:{id:t,key:e,node:i}}))},this._cleanupVideo=t=>{var e;const i=this.videos[t];i&&(i.node.pause(),i.node.src="",(e=i.hls)==null||e.destroy(),Object.keys(i.listeners??{}).forEach(s=>{var o,c;if((o=this.videos)!=null&&o[t]){const d=(c=i.listeners)==null?void 0:c[s];d&&i.node.removeEventListener(s,d)}}),delete this.videos[t])},this.host=n,this.host.addController(this)}set hasPlayed(n){n!==this._hasPlayed&&(this._hasPlayed=n,this.host.requestUpdate())}get hasPlayed(){return this._hasPlayed}set duration(n){!isNaN(n)&&n!==this._duration&&(this._duration=n,this.host.requestUpdate(),this.host.dispatchEvent(new CustomEvent("durationchange",{detail:this._duration})))}get duration(){return this._duration}set scenes(n){n!==this._scenes&&(this._scenes=n,this.host.requestUpdate())}get scenes(){return this._scenes}set videos(n){n!==this._videos&&(this._videos=n,this.host.requestUpdate())}get videos(){return this._videos}set videoMeta(n){n!==this._videoMeta&&(this._videoMeta=n,this.host.requestUpdate())}get videoMeta(){return this._videoMeta}set videoState(n){n!==this._videoState&&(this._videoState=n,this.host.requestUpdate())}get videoState(){return this._videoState}_getBufferSegments({key:n,node:t,duration:e}){var i;const s=t==null?void 0:t.buffered,o=[],{start:c,video:d,videoMeta:f}=((i=this.scenes)==null?void 0:i.scenes.find(({video:p})=>n===(p==null?void 0:p.key)))??{};if(t&&s&&d&&f&&typeof c<"u")for(let p=0;p<s.length;p++){const g=s.start(p),v=s.end(p);Math.max(g,f.start)<=Math.min(v,f.start+f.duration)&&o.push({start:Math.max(0,(Math.max(g-f.start,0)+c)/e*100),end:Math.min((Math.min(v-f.start,f.duration)+c)/e*100,100)})}return o}_setupTask(){new qa(this.host,async([n,t,e,i,s,o])=>{try{if(this.host._errors=[],e||n){if(this.host._processing=!0,e){let d=null;if(i)try{d=await(await fetch(i,{method:"GET"})).text()}catch{const f=new Qr("Track failed to fetch");this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:f,message:f.message}))}try{const f=e.includes(".m3u8")?"playlist":"video";this.scenes=await po({data:{questions:{items:[{answer:{id:"source",media:{[f]:e},captions:{current:d}}}]}},template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(f){throw new Qr(`Source template error - ${f.message}`,!0)}}else try{this.scenes=await po({data:n,template:t,burnCaptions:s,debug:o},this._resolveVideo,this._resolveVideoMeta)}catch(d){throw new Qr(`Data template error - ${d.message}`,!0)}if(this.scenes.scenes.length===0)throw new Qr("Template error - no scenes created",!0);Object.keys(this.videos).forEach(d=>{this.scenes.scenes.find(({video:f})=>d===(f==null?void 0:f.key))||this._videos[d].node.pause()});const c=this.scenes.scenes.reduce((d,{video:f})=>(f&&(d[f.key]=f),d),{});Object.keys(this.videos).join("|")!==Object.keys(c).join("|")&&this.host.reset(0,!1),this.videos=c,this.videoState={...this.videoState,...this.scenes.scenes.reduce((d,{video:f,start:p,duration:g})=>{var v;const b=(f==null?void 0:f.key)??`${p}-${g}`,E=this._getBufferSegments({key:b,node:f==null?void 0:f.node,duration:this.scenes.duration});return d[b]={initialised:!f,waiting:!!f,...this.videoState[b],buffered:f?E:(v=this.videoState[b])==null?void 0:v.buffered},d},{})},this.videoMeta=this.scenes.scenes.reduce((d,{video:f,videoMeta:p})=>(f&&p&&(d[f.key]=p),d),{}),(await Promise.all(this.scenes.fonts.map(d=>L4(d)))).forEach(d=>{document.fonts.add(d)}),this.duration=this.scenes.duration,this.host.paused&&this.host.reset(this.host.currentTime,!this.host.paused)}}catch(c){this.scenes=null,this.duration=0,this.host.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:c,message:c.message}))}finally{this.host._processing=!1}},()=>{const n=JSON.stringify({data:this.host.data,template:this.host.template,src:this.host.src,track:this.host.track,burnCaptions:this.host.burnCaptions,debug:this.host.debug});if(this._lastDeps&&this._memoKey===n)return this._lastDeps;const t=[this.host.data,this.host.template,this.host.src,this.host.track,this.host.burnCaptions,this.host.debug];return this._memoKey=n,this._lastDeps=t,t})}_setVideoCurrentTime({time:n,scene:t}){const{start:e,video:i,videoMeta:s}=t;if(i&&i.node&&s&&typeof e<"u"){const o=n-e;i.node.currentTime=Math.max(s.start,Math.min(s.start+s.duration,o+s.start))}}setVideosCurrentTime(n){var t;(t=this.scenes)==null||t.scenes.forEach(e=>{this._setVideoCurrentTime({time:n,scene:e})})}hostConnected(){this._setupTask()}hostDisconnected(){Object.keys(this.videos).forEach(n=>{this._cleanupVideo(n)}),this.videos={}}};function I4(n){n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen&&n.msRequestFullscreen()}function x4(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}const ih=["progress","play-large","navigation","play","volume","current-time","duration","speed","captions","fullscreen","preview"],D4={id:"captions",event:"captions:click",label:"Closed Captions"},P4={id:"fullscreen",event:"fullscreen:click",label:"Full Screen"},Gf={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}]},O4={id:"playbackRate",label:"Playback playbackRate",subItems:Gf};class M4 extends Cd{constructor(t){if(super(t),this.element=null,this.observer=void 0,t.type!==bn.ELEMENT)throw new Error("Resize directive must be used in an Element expression")}disconnected(){var t;(t=this.observer)==null||t.disconnect(),this.observer=void 0}reconnected(){var t;this.element&&((t=this.observer)==null||t.observe(this.element))}update(t,[e]){return this.isConnected&&!this.observer&&(this.observer=new ResizeObserver(e),this.element=t.element,this.observer.observe(this.element)),ms}}const rh=An(M4);var Hf=Number.isNaN||function(n){return typeof n=="number"&&n!==n};function $4(n,t){return!!(n===t||Hf(n)&&Hf(t))}function N4(n,t){if(n.length!==t.length)return!1;for(var e=0;e<n.length;e++)if(!$4(n[e],t[e]))return!1;return!0}function F4(n,t){t===void 0&&(t=N4);var e=null;function i(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];if(e&&e.lastThis===this&&t(s,e.lastArgs))return e.lastResult;var c=n.apply(this,s);return e={lastResult:c,lastArgs:s,lastThis:this},c}return i.clear=function(){e=null},i}const U4=F4(()=>{const n=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),t=new FontFace("Roobert","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-SemiBold.woff2)",{style:"normal",weight:"600"}),e=new FontFace("Roobert Captions","url(https://media-player-fonts.s3.ap-southeast-2.amazonaws.com/Roobert-Regular.woff2)",{style:"normal",weight:"400"}),i=Qd.map(s=>({load:!1,font:new FontFace(s.family,`url(${s.url})`,{style:s.style})}));return[{load:!0,font:n},{load:!0,font:t},{load:!0,font:e},...i]}),$r={"red-120":"#feeded","red-130":"#fcd5d0","red-400":"#e84a4a","red-500":"#c51c3a","red-700":"#a21c39","red-800":"#850231","red-900":"#580A2D","teal-100":"#a5e9ed","teal-600":"#006776","purple-100":"#d7cfff","purple-700":"#5f2fe9","green-200":"#a4d7aa","green-500":"#38b319","green-800":"#2b3c2f","grey-100":"#f0f0f0","light-50":"rgba(255, 255, 255, .05)","light-100":"rgba(255, 255, 255, .1)","light-200":"rgba(255, 255, 255, .2)","light-400":"rgba(255, 255, 255, .4)","light-500":"rgba(255, 255, 255, .5)","light-640":"rgba(255, 255, 255, .64)","light-800":"rgba(255, 255, 255, .8)","light-1000":"#fff","dark-50":"rgba(0, 0, 0, .05)","dark-80":"rgba(0, 0, 0, .08)","dark-100":"rgba(0, 0, 0, .1)","dark-200":"rgba(0, 0, 0, .2)","dark-250":"rgba(0, 0, 0, .25)","dark-400":"rgba(0, 0, 0, .4)","dark-500":"rgba(0, 0, 0, .5)","dark-640":"rgba(0, 0, 0, .64)","dark-800":"rgba(0, 0, 0, .8)","dark-900":"rgba(0, 0, 0, .9)","dark-1000":"#000"},B4={colors:$r,space:{xxs:".25rem",xs:".5rem",small:".75rem",medium:"1rem",large:"1.5rem",xl:"2.5rem"},sizes:{xxs:"1rem",xs:"1.5rem",small:"2rem",medium:"2.5rem",large:"3rem"},fontWeights:{regular:400,semibold:600},lineHeights:{small:1.1,medium:1.25,large:1.4},letterSpacings:{xxs:"-.04rem",xs:"-.03rem",small:"-.02rem",medium:"-.01rem",large:0},fontSizes:{micro:".625rem",small:".75rem",medium:".875rem",large:"1rem",xl:"1.25rem",xxl:"1.5rem",xxxl:"2rem",huge:"2.75rem"},fontFamilies:{sans:'Roobert, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,"Noto Sans", "Noto Color Emoji", sans-serif, "Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji"',mono:'"Maison Neue Mono", Menlo, Monaco, Consolas, Liberation Mono, "Courier New", monospace'},borderWidths:{thin:".0625rem"},radii:{small:".25rem",medium:".5rem",large:".75rem",xl:"1rem"},shadows:{small:`.25rem .25rem .25rem ${$r["dark-100"]}`,medium:`0 .125rem .625rem ${$r["dark-100"]}`,large:`0 .25rem 1rem ${$r["dark-50"]}`,xl:`.25rem .25rem 1rem ${$r["dark-250"]}`,xxl:`0 .25rem 2rem ${$r["dark-100"]}`,xxxl:`.25rem .25rem 3rem ${$r["dark-250"]}`,toolbar:`0 -.625rem .625rem ${$r["dark-50"]}`,text:`0 0 .25rem ${$r["dark-250"]}`},timings:{fast:".1s",normal:".2s",slow:".3s"},easings:{linear:"linear"},focusOutline:{width:".2rem",color:$r["dark-400"]},iconSizes:{small:"0.75rem",medium:"1rem",large:"1.5rem"}},Vf=Sm.flatten(B4,{delimiter:"-"}),G4=Object.keys(Vf).map(n=>qn(`:host { --${n}: ${Vf[n]}; }`)),H4=n=>{class t extends n{firstUpdated(){U4().forEach(({load:i,font:s})=>{document.fonts.add(s),i&&s.load()})}}return t.styles=[(n==null?void 0:n.styles)??[],G4,yi`
209
209
  :host {
210
210
  font-family: var(--fontFamilies-sans);
211
211
  font-size: var(--fontSizes-medium);
@@ -740,7 +740,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
740
740
  height: 20px;
741
741
  width: 20px;
742
742
  }
743
- `],xa([It({type:Object})],dn.prototype,"items",2),xa([It({type:Array})],dn.prototype,"activeItems",2),xa([bi()],dn.prototype,"visibleItems",2),xa([bi()],dn.prototype,"subItemsActive",2),dn=xa([Oi("vmp-menu")],dn);var aA=Object.defineProperty,oA=Object.getOwnPropertyDescriptor,ah=(n,t,e,i)=>{for(var s=i>1?void 0:i?oA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&aA(t,e,s),s};let Da=class extends Re{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wi()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=nn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}updated(){var n,t;this.disabled?(n=this.tippy)==null||n.disable():(t=this.tippy)==null||t.enable()}render(){return ee`
743
+ `],xa([It({type:Object})],dn.prototype,"items",2),xa([It({type:Array})],dn.prototype,"activeItems",2),xa([ki()],dn.prototype,"visibleItems",2),xa([ki()],dn.prototype,"subItemsActive",2),dn=xa([Oi("vmp-menu")],dn);var aA=Object.defineProperty,oA=Object.getOwnPropertyDescriptor,ah=(n,t,e,i)=>{for(var s=i>1?void 0:i?oA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&aA(t,e,s),s};let Da=class extends Re{constructor(){super(...arguments),this.content="",this.disabled=!1,this.tippy=null,this._contentRef=wi()}connectedCallback(){super.connectedCallback(),requestAnimationFrame(()=>{var n;const t=(n=this.shadowRoot)==null?void 0:n.querySelector("slot"),e=t==null?void 0:t.assignedElements()[0];e&&this._contentRef.value&&(this.tippy=nn(e,{content:this._contentRef.value,allowHTML:!0,arrow:!1,animation:"shift-away-subtle",interactive:!1,placement:"top",zIndex:1e4,appendTo:()=>this.shadowRoot}))})}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this.tippy)==null||n.destroy()}updated(){var n,t;this.disabled?(n=this.tippy)==null||n.disable():(t=this.tippy)==null||t.enable()}render(){return ee`
744
744
  <slot></slot>
745
745
  <div ${Si(this._contentRef)} class="content">
746
746
  <vmp-text content=${this.content}></vmp-text>
@@ -1055,7 +1055,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1055
1055
  --player-scrubber-height: 16px;
1056
1056
  color: var(--colors-light-800);
1057
1057
  }
1058
- `],Vo([It({type:Number})],On.prototype,"duration",2),Vo([It({type:Number})],On.prototype,"currentTime",2),Vo([It({type:Array})],On.prototype,"buffer",2),On=Vo([Oi("vmp-progress-scrubber")],On);var uA=Object.defineProperty,fA=Object.getOwnPropertyDescriptor,Ti=(n,t,e,i)=>{for(var s=i>1?void 0:i?fA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&uA(t,e,s),s};let oi=class extends Re{constructor(){super(...arguments),this.resizeHider=new eA(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=ih,this.volumeMenuOpen=!1,this.levelsMenuOpen=!1,this.playbackRateMenuOpen=!1,this.settingsMenuOpen=!1}_handleNavigateBackClick(){this.dispatchEvent(new CustomEvent("navigate:back",{bubbles:!0,composed:!0}))}_handleNavigateForwardClick(){this.dispatchEvent(new CustomEvent("navigate:forward",{bubbles:!0,composed:!0}))}_handlePlayClick(){this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}_handleCaptionsClick(){this.dispatchEvent(new CustomEvent("captions:click",{bubbles:!0,composed:!0,detail:this.captions}))}_handleFullscreenClick(){this.dispatchEvent(new CustomEvent("fullscreen:click",{bubbles:!0,composed:!0,detail:this.fullscreen}))}_handleVolumeMenuToggle({detail:n}){this.volumeMenuOpen=n}_handleLevelsMenuOpen({detail:n}){this.levelsMenuOpen=n}_handlePlaybackMenuToggle({detail:n}){this.playbackRateMenuOpen=n}_handleSettingsMenuToggle({detail:n}){this.settingsMenuOpen=n}hideMenus(){var n,t;(t=Array.from((n=this.shadowRoot)==null?void 0:n.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var n,t,e,i,s,o,c,d,f,p,g,v,b;const E=((n=this.levels)==null?void 0:n.map((V,J)=>{const St=Math.min(V.width,V.height);return{id:`level-${J.toString()}`,event:"level:click",label:`${St}p`,value:{resolution:St,level:J}}}))??[],T={title:"Quality",items:[...E.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},C=(t=T.items)==null?void 0:t.find(({value:V})=>V.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(V=>{var J;return(J=this.controls)==null?void 0:J.includes(V)}),O={title:"Settings",items:[D4,P4,w,O4].filter(({id:V})=>D.includes(V)&&this.resizeHider.hiddenControls.includes(V))},F=(e=this.controls)==null?void 0:e.includes("progress"),x=(i=this.controls)==null?void 0:i.includes("navigation"),N=(s=this.controls)==null?void 0:s.includes("play"),H=(o=this.controls)==null?void 0:o.includes("volume"),j=(c=this.controls)==null?void 0:c.includes("current-time"),nt=(d=this.controls)==null?void 0:d.includes("duration"),st=(f=this.controls)==null?void 0:f.includes("levels"),Q=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),gt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Mt=N||H||j||nt||st||Q||kt||gt,Vt=[`level-${(b=this.level)==null?void 0:b.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return ee`
1058
+ `],Vo([It({type:Number})],On.prototype,"duration",2),Vo([It({type:Number})],On.prototype,"currentTime",2),Vo([It({type:Array})],On.prototype,"buffer",2),On=Vo([Oi("vmp-progress-scrubber")],On);var uA=Object.defineProperty,fA=Object.getOwnPropertyDescriptor,Ei=(n,t,e,i)=>{for(var s=i>1?void 0:i?fA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&uA(t,e,s),s};let oi=class extends Re{constructor(){super(...arguments),this.resizeHider=new eA(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=ih,this.volumeMenuOpen=!1,this.levelsMenuOpen=!1,this.playbackRateMenuOpen=!1,this.settingsMenuOpen=!1}_handleNavigateBackClick(){this.dispatchEvent(new CustomEvent("navigate:back",{bubbles:!0,composed:!0}))}_handleNavigateForwardClick(){this.dispatchEvent(new CustomEvent("navigate:forward",{bubbles:!0,composed:!0}))}_handlePlayClick(){this.dispatchEvent(new CustomEvent("play:click",{bubbles:!0,composed:!0,detail:this.playing}))}_handleCaptionsClick(){this.dispatchEvent(new CustomEvent("captions:click",{bubbles:!0,composed:!0,detail:this.captions}))}_handleFullscreenClick(){this.dispatchEvent(new CustomEvent("fullscreen:click",{bubbles:!0,composed:!0,detail:this.fullscreen}))}_handleVolumeMenuToggle({detail:n}){this.volumeMenuOpen=n}_handleLevelsMenuOpen({detail:n}){this.levelsMenuOpen=n}_handlePlaybackMenuToggle({detail:n}){this.playbackRateMenuOpen=n}_handleSettingsMenuToggle({detail:n}){this.settingsMenuOpen=n}hideMenus(){var n,t;(t=Array.from((n=this.shadowRoot)==null?void 0:n.querySelectorAll("vmp-menu, vmp-tooltip, vmp-volume-button")))==null||t.forEach(e=>{var i;(i=e.tippy)==null||i.hide()})}render(){var n,t,e,i,s,o,c,d,f,p,g,v,b;const E=((n=this.levels)==null?void 0:n.map((V,J)=>{const St=Math.min(V.width,V.height);return{id:`level-${J.toString()}`,event:"level:click",label:`${St}p`,value:{resolution:St,level:J}}}))??[],T={title:"Quality",items:[...E.reverse(),{id:"level--1",event:"level:click",label:"Auto",value:{level:-1,resolution:"auto"}}]},w={id:"levels",label:"Quality",subItems:T},C=(t=T.items)==null?void 0:t.find(({value:V})=>V.level===this.level),D=["levels","playback-rate","captions","fullscreen"].filter(V=>{var J;return(J=this.controls)==null?void 0:J.includes(V)}),O={title:"Settings",items:[D4,P4,w,O4].filter(({id:V})=>D.includes(V)&&this.resizeHider.hiddenControls.includes(V))},F=(e=this.controls)==null?void 0:e.includes("progress"),x=(i=this.controls)==null?void 0:i.includes("navigation"),N=(s=this.controls)==null?void 0:s.includes("play"),H=(o=this.controls)==null?void 0:o.includes("volume"),j=(c=this.controls)==null?void 0:c.includes("current-time"),nt=(d=this.controls)==null?void 0:d.includes("duration"),st=(f=this.controls)==null?void 0:f.includes("levels"),Q=(p=this.controls)==null?void 0:p.includes("speed"),kt=(g=this.controls)==null?void 0:g.includes("captions"),gt=(v=this.controls)==null?void 0:v.includes("fullscreen"),Mt=N||H||j||nt||st||Q||kt||gt,Vt=[`level-${(b=this.level)==null?void 0:b.toString()}`,`playback-rate-${this.playbackRate.toString()}`,this.captions&&"captions",this.fullscreen&&"fullscreen"].filter(Boolean);return ee`
1059
1059
  <div
1060
1060
  ${this.resizeHider.measure()}
1061
1061
  ${this.resizeHider.contain()}
@@ -1256,7 +1256,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1256
1256
  .hidden {
1257
1257
  display: none;
1258
1258
  }
1259
- `],Ti([It({type:Boolean})],oi.prototype,"playing",2),Ti([It({type:Number})],oi.prototype,"volume",2),Ti([It({type:Boolean})],oi.prototype,"muted",2),Ti([It({type:Number})],oi.prototype,"currentTime",2),Ti([It({type:Number})],oi.prototype,"duration",2),Ti([It({type:Number})],oi.prototype,"level",2),Ti([It({type:Number})],oi.prototype,"playbackRate",2),Ti([It({type:Array})],oi.prototype,"buffer",2),Ti([It({type:Array,attribute:!1})],oi.prototype,"levels",2),Ti([It({type:Boolean})],oi.prototype,"captions",2),Ti([It({type:Boolean})],oi.prototype,"fullscreen",2),Ti([It({type:Array})],oi.prototype,"controls",2),Ti([bi()],oi.prototype,"volumeMenuOpen",2),Ti([bi()],oi.prototype,"levelsMenuOpen",2),Ti([bi()],oi.prototype,"playbackRateMenuOpen",2),Ti([bi()],oi.prototype,"settingsMenuOpen",2),oi=Ti([Oi("vmp-player-controls")],oi);var pA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,mA=(n,t,e,i)=>{for(var s=i>1?void 0:i?gA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&pA(t,e,s),s};let lh=class extends Re{render(){return ee`<vmp-icon icon="loading"></vmp-icon>`}};lh.styles=[Re.styles??[],yi`
1259
+ `],Ei([It({type:Boolean})],oi.prototype,"playing",2),Ei([It({type:Number})],oi.prototype,"volume",2),Ei([It({type:Boolean})],oi.prototype,"muted",2),Ei([It({type:Number})],oi.prototype,"currentTime",2),Ei([It({type:Number})],oi.prototype,"duration",2),Ei([It({type:Number})],oi.prototype,"level",2),Ei([It({type:Number})],oi.prototype,"playbackRate",2),Ei([It({type:Array})],oi.prototype,"buffer",2),Ei([It({type:Array,attribute:!1})],oi.prototype,"levels",2),Ei([It({type:Boolean})],oi.prototype,"captions",2),Ei([It({type:Boolean})],oi.prototype,"fullscreen",2),Ei([It({type:Array})],oi.prototype,"controls",2),Ei([ki()],oi.prototype,"volumeMenuOpen",2),Ei([ki()],oi.prototype,"levelsMenuOpen",2),Ei([ki()],oi.prototype,"playbackRateMenuOpen",2),Ei([ki()],oi.prototype,"settingsMenuOpen",2),oi=Ei([Oi("vmp-player-controls")],oi);var pA=Object.defineProperty,gA=Object.getOwnPropertyDescriptor,mA=(n,t,e,i)=>{for(var s=i>1?void 0:i?gA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&pA(t,e,s),s};let lh=class extends Re{render(){return ee`<vmp-icon icon="loading"></vmp-icon>`}};lh.styles=[Re.styles??[],yi`
1260
1260
  :host {
1261
1261
  display: flex;
1262
1262
  align-items: center;
@@ -1403,7 +1403,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1403
1403
  vmp-captions.hiddenControls {
1404
1404
  transform: translateY(calc(var(--space-small) * -1));
1405
1405
  }
1406
- `],Li([It({type:Boolean})],fi.prototype,"loading",2),Li([It({type:Boolean})],fi.prototype,"playing",2),Li([It({type:Number})],fi.prototype,"volume",2),Li([It({type:Boolean})],fi.prototype,"muted",2),Li([It({type:Number})],fi.prototype,"currentTime",2),Li([It({type:Number})],fi.prototype,"duration",2),Li([It({type:Array,attribute:!1})],fi.prototype,"levels",2),Li([It({type:Number})],fi.prototype,"level",2),Li([It({type:Number})],fi.prototype,"playbackRate",2),Li([It({type:String})],fi.prototype,"caption",2),Li([It({type:Array})],fi.prototype,"buffer",2),Li([It({type:Boolean})],fi.prototype,"captions",2),Li([It({type:Boolean})],fi.prototype,"fullscreen",2),Li([It({type:Array})],fi.prototype,"controls",2),Li([bi()],fi.prototype,"showControls",2),fi=Li([Oi("vmp-player-overlay")],fi);var TA=Object.defineProperty,kA=Object.getOwnPropertyDescriptor,Je=(n,t,e,i)=>{for(var s=i>1?void 0:i?kA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&TA(t,e,s),s};let Xe=class extends Re{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Pl,this._sceneController=new C4(this),this._drawController=new iv(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=wi(),this._canvasRef=wi(),this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var n;(n=this.shadowRoot)!=null&&n.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._seeker=n=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,i=this.videoState[e];return!i||!i.initialised||i.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),n-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(n-(this._lastTimestamp??n))/1e3*this.playbackRate,this._lastTimestamp=n),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||(this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleError=n=>{this._errors=[...this.errors,n.error],n.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get initialised(){return this._initialised!==null?Promise.resolve(this._initialised):new Promise(n=>{setInterval(()=>{this.errors.find(t=>t.fatal)&&(this._initialised=!1,n(!1)),!this.loading&&!this.processing&&!this.waiting&&this.scenes.length>0&&(this._initialised=!0,n(!0))},500)})}get duration(){return this._sceneController.duration}get scene(){return this._drawController.activeScenes[this._drawController.activeScenes.length-1]}get scenes(){var n;return((n=this._sceneController.scenes)==null?void 0:n.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((n,{video:t,start:e,duration:i})=>{const s=(t==null?void 0:t.key)??`${e}-${i}`;return n[s]=this.videoState[s],n},{})}set paused(n){n!==this._paused&&(this._paused=n,this.requestUpdate(),this.dispatchEvent(new CustomEvent(n?"pause":"play")))}get paused(){return this._paused}set playbackRate(n){n!==this._playbackRate&&(this._playbackRate=n,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=n)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:n})))}get playbackRate(){return this._playbackRate}set volume(n){const t=Math.min(1,Math.max(0,n));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(n){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=n)}),n!==this._muted&&(this._muted=n,localStorage.setItem("vmp-player-muted",n.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(n){n!==this._videoResolution&&(this._videoResolution=n,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===n);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(n){n!==this._drawController.currentTime&&(this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n))}get currentTime(){return this._drawController.currentTime}reset(n=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._seekerRAF||(this._seekerRAF=requestAnimationFrame(this._seeker))}pause(){this._seekerRAF&&(cancelAnimationFrame(this._seekerRAF),this._seekerRAF=null),this.paused=!0,this.scenes.forEach(({video:n})=>{n&&n.node.pause()})}draw(n){return this._drawController.draw(n)}setScene(n){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[n];if(!i){const s=new Qr(`No scene at index: ${n}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:s,message:s.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(n){n??this.fullscreen?x4():this._playerRef.value&&I4(this._playerRef.value)}connectedCallback(){var n;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),(n=this.shadowRoot)!=null&&n.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(n){n.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&n.has("_processing")&&this.play()}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this._observer)==null||n.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?ee`
1406
+ `],Li([It({type:Boolean})],fi.prototype,"loading",2),Li([It({type:Boolean})],fi.prototype,"playing",2),Li([It({type:Number})],fi.prototype,"volume",2),Li([It({type:Boolean})],fi.prototype,"muted",2),Li([It({type:Number})],fi.prototype,"currentTime",2),Li([It({type:Number})],fi.prototype,"duration",2),Li([It({type:Array,attribute:!1})],fi.prototype,"levels",2),Li([It({type:Number})],fi.prototype,"level",2),Li([It({type:Number})],fi.prototype,"playbackRate",2),Li([It({type:String})],fi.prototype,"caption",2),Li([It({type:Array})],fi.prototype,"buffer",2),Li([It({type:Boolean})],fi.prototype,"captions",2),Li([It({type:Boolean})],fi.prototype,"fullscreen",2),Li([It({type:Array})],fi.prototype,"controls",2),Li([ki()],fi.prototype,"showControls",2),fi=Li([Oi("vmp-player-overlay")],fi);var TA=Object.defineProperty,kA=Object.getOwnPropertyDescriptor,si=(n,t,e,i)=>{for(var s=i>1?void 0:i?kA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&TA(t,e,s),s};let Ze=class extends Re{constructor(){super(...arguments),this.burnCaptions=!1,this.debug=!1,this.propAspectRatio=0,this.preload="auto",this.autoplay=!1,this.loading=!1,this.compilation=Pl,this._sceneController=new C4(this),this._drawController=new iv(this),this._observer=null,this._wasPlaying=!1,this._manualMute=this.muted,this._seekerRAF=null,this._lastWaiting=!1,this._lastTimestamp=null,this._playerRef=wi(),this._canvasRef=wi(),this._aspectRatio=this.propAspectRatio,this._processing=!1,this._waiting=!1,this._errors=[],this._seeking=!1,this._captions=!1,this._fullscreen=!1,this._initialised=null,this._paused=!0,this._playbackRate=1,this._volume=null,this._muted=null,this._videoResolution=-1,this._handleContainerResize=()=>{var n;(n=this.shadowRoot)!=null&&n.host&&!this.propAspectRatio&&(this._aspectRatio=this.shadowRoot.host.clientWidth/this.shadowRoot.host.clientHeight)},this._handleCanvasResize=()=>{this.draw()},this._seeker=n=>{this.sceneConfig&&this.scenes.length>0&&(this._waiting=this._drawController.activeScenes.some(({video:t})=>{if(t){const{key:e}=t,i=this.videoState[e];return!i||!i.initialised||i.waiting||t.node.readyState<3}}),this.waiting?(this._lastTimestamp=null,this._lastWaiting||this.dispatchEvent(new CustomEvent("waiting"))):this._lastWaiting&&this.dispatchEvent(new CustomEvent("playing")),n-(this._lastTimestamp??0)>1e3/this.sceneConfig.frameRate&&(this._drawController.currentTime=this._drawController.currentTime+(n-(this._lastTimestamp??n))/1e3*this.playbackRate,this._lastTimestamp=n),this._lastWaiting=this._waiting,this._drawController.currentTime>=this.duration&&(this.pause(),this.dispatchEvent(new CustomEvent("ended")))),this.paused||(this._seekerRAF=requestAnimationFrame(this._seeker))},this._handleError=n=>{this._errors=[...this.errors,n.error],n.error.fatal&&this.pause()},this._handleFullscreenChange=()=>{document.fullscreenElement?this._fullscreen=!0:this._fullscreen=!1}}get aspectRatio(){return this._aspectRatio}get processing(){return this._processing}get waiting(){return!this.paused&&this._waiting}get errors(){return this._errors}get seeking(){return this._seeking}get captions(){return this._captions}get fullscreen(){return this._fullscreen}get initialised(){return this._initialised=this._initialised??new Promise(n=>{const t=setInterval(()=>{this.errors.find(e=>e.fatal)&&n(!1),!this.loading&&!this.processing&&!this.waiting&&this.scenes.length>0&&n(!0)},500);setTimeout(()=>{clearInterval(t),n(!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 n;return((n=this._sceneController.scenes)==null?void 0:n.scenes)??[]}get sceneConfig(){return this._sceneController.scenes}get videos(){return this._sceneController.videos??{}}get videoState(){return this._sceneController.videoState}get sceneVideoState(){return this.scenes.reduce((n,{video:t,start:e,duration:i})=>{const s=(t==null?void 0:t.key)??`${e}-${i}`;return n[s]=this.videoState[s],n},{})}set paused(n){n!==this._paused&&(this._paused=n,this.requestUpdate(),this.dispatchEvent(new CustomEvent(n?"pause":"play")))}get paused(){return this._paused}set playbackRate(n){n!==this._playbackRate&&(this._playbackRate=n,this.scenes.forEach(({video:t})=>{t&&(t.node.playbackRate=n)}),this.requestUpdate(),this.dispatchEvent(new CustomEvent("ratechange",{detail:n})))}get playbackRate(){return this._playbackRate}set volume(n){const t=Math.min(1,Math.max(0,n));t!==this._volume&&(this.scenes.forEach(({video:e})=>{e&&(e.node.volume=t)}),localStorage.setItem("vmp-player-volume",t.toString()),this._volume=t,t>0&&(this.muted=!1),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n})))}get volume(){return this._volume??(this._volume=parseFloat(localStorage.getItem("vmp-player-volume")??"1"))}set muted(n){this.scenes.forEach(({video:t})=>{t&&(t.node.muted=n)}),n!==this._muted&&(this._muted=n,localStorage.setItem("vmp-player-muted",n.toString()),this.requestUpdate(),this.dispatchEvent(new CustomEvent("volumechange",{detail:n?0:this.volume})))}get muted(){return this._muted??(this._muted=this.autoplay||localStorage.getItem("vmp-player-muted")==="true")}set videoResolution(n){n!==this._videoResolution&&(this._videoResolution=n,this.scenes.forEach(({video:t})=>{if(t!=null&&t.hls){const e=t.hls.levels.findIndex(i=>Math.min(i.height,i.width)===n);t.hls.currentLevel=e??-1}}),this.requestUpdate())}get videoResolution(){return this._videoResolution}set currentTime(n){n!==this._drawController.currentTime&&(this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n))}get currentTime(){return this._drawController.currentTime}reset(n=0,t=!1){this._lastTimestamp=null,this._drawController.currentTime=n,this._sceneController.setVideosCurrentTime(n),t?this.play():this.pause()}clear(){this._drawController.clear()}play(){this.paused=!1,this._lastTimestamp=null,this.duration>0&&this._drawController.currentTime>=this.duration&&this.reset(0,!0),this._seekerRAF||(this._seekerRAF=requestAnimationFrame(this._seeker))}pause(){this._seekerRAF&&(cancelAnimationFrame(this._seekerRAF),this._seekerRAF=null),this.paused=!0,this.scenes.forEach(({video:n})=>{n&&n.node.pause()})}draw(n){return this._drawController.draw(n)}setScene(n){var t,e;if((t=this._sceneController)!=null&&t.scenes){const i=(e=this.scenes)==null?void 0:e[n];if(!i){const s=new Qr(`No scene at index: ${n}`);return this.dispatchEvent(new ErrorEvent("error",{composed:!0,bubbles:!0,error:s,message:s.message}))}this.reset(i.start+this._sceneController.scenes.transitionDuration,!this.paused)}}toggleFullscreen(n){n??this.fullscreen?x4():this._playerRef.value&&I4(this._playerRef.value)}connectedCallback(){var n;super.connectedCallback(),this.addEventListener("error",this._handleError),document.addEventListener("fullscreenchange",this._handleFullscreenChange),(n=this.shadowRoot)!=null&&n.host&&(this._observer=new ResizeObserver(this._handleContainerResize),this._observer.observe(this.shadowRoot.host))}willUpdate(){this.propAspectRatio&&(this._aspectRatio=this.propAspectRatio)}updated(n){n.has("propAspectRatio")&&!this.propAspectRatio&&this._handleContainerResize(),this.autoplay&&!this.processing&&!this._sceneController.hasPlayed&&n.has("_processing")&&this.play()}disconnectedCallback(){var n;super.disconnectedCallback(),(n=this._observer)==null||n.disconnect(),document.removeEventListener("fullscreenchange",this._handleFullscreenChange)}_renderStyles(){return this.propAspectRatio?typeof this.propAspectRatio=="number"?ee`
1407
1407
  <style>
1408
1408
  :host {
1409
1409
  aspect-ratio: ${this.propAspectRatio};
@@ -1477,7 +1477,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1477
1477
  .compilation=${this.compilation}
1478
1478
  ></vmp-video-preview>`}
1479
1479
  </div>
1480
- `}};Xe.styles=[Re.styles??[],yi`
1480
+ `}};Ze.styles=[Re.styles??[],yi`
1481
1481
  :host {
1482
1482
  --player-border-radius: var(--vouch-media-player-border-radius, 0px);
1483
1483
 
@@ -1538,7 +1538,7 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1538
1538
  top: 0;
1539
1539
  left: 0;
1540
1540
  }
1541
- `],Je([It({type:Object})],Xe.prototype,"data",2),Je([It({type:Object})],Xe.prototype,"template",2),Je([It({type:Boolean})],Xe.prototype,"burnCaptions",2),Je([It({type:Boolean})],Xe.prototype,"debug",2),Je([It({type:String})],Xe.prototype,"src",2),Je([It({type:String})],Xe.prototype,"track",2),Je([It({type:Number,attribute:"aspectratio"})],Xe.prototype,"propAspectRatio",2),Je([It({type:String})],Xe.prototype,"preload",2),Je([It({type:Boolean})],Xe.prototype,"autoplay",2),Je([It({type:Boolean})],Xe.prototype,"loading",2),Je([It({type:Array})],Xe.prototype,"controls",2),Je([It({attribute:!1})],Xe.prototype,"compilation",2),Je([bi()],Xe.prototype,"_aspectRatio",2),Je([bi()],Xe.prototype,"_processing",2),Je([bi()],Xe.prototype,"_waiting",2),Je([bi()],Xe.prototype,"_errors",2),Je([bi()],Xe.prototype,"_seeking",2),Je([bi()],Xe.prototype,"_captions",2),Je([bi()],Xe.prototype,"_fullscreen",2),Je([bi()],Xe.prototype,"_initialised",2),Xe=Je([Oi("vmp-media-player")],Xe);var wA=Object.defineProperty,SA=Object.getOwnPropertyDescriptor,Mi=(n,t,e,i)=>{for(var s=i>1?void 0:i?SA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&wA(t,e,s),s};Oe.Embed=class extends yn{constructor(){super(...arguments),this._mediaPlayerRef=wi(),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new ug(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 $g(this),this._trackingController=new Tm(this)}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get sceneConfig(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.sceneConfig)??null}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}render(){return ee`
1541
+ `],si([It({type:Object})],Ze.prototype,"data",2),si([It({type:Object})],Ze.prototype,"template",2),si([It({type:Boolean})],Ze.prototype,"burnCaptions",2),si([It({type:Boolean})],Ze.prototype,"debug",2),si([It({type:String})],Ze.prototype,"src",2),si([It({type:String})],Ze.prototype,"track",2),si([It({type:Number,attribute:"aspectratio"})],Ze.prototype,"propAspectRatio",2),si([It({type:String})],Ze.prototype,"preload",2),si([It({type:Boolean})],Ze.prototype,"autoplay",2),si([It({type:Boolean})],Ze.prototype,"loading",2),si([It({type:Array})],Ze.prototype,"controls",2),si([It({attribute:!1})],Ze.prototype,"compilation",2),si([ki()],Ze.prototype,"_aspectRatio",2),si([ki()],Ze.prototype,"_processing",2),si([ki()],Ze.prototype,"_waiting",2),si([ki()],Ze.prototype,"_errors",2),si([ki()],Ze.prototype,"_seeking",2),si([ki()],Ze.prototype,"_captions",2),si([ki()],Ze.prototype,"_fullscreen",2),Ze=si([Oi("vmp-media-player")],Ze);var wA=Object.defineProperty,SA=Object.getOwnPropertyDescriptor,Mi=(n,t,e,i)=>{for(var s=i>1?void 0:i?SA(t,e):t,o=n.length-1,c;o>=0;o--)(c=n[o])&&(s=(i?c(t,e,s):c(s))||s);return i&&s&&wA(t,e,s),s};Oe.Embed=class extends yn{constructor(){super(...arguments),this._mediaPlayerRef=wi(),this.env="prod",this.apiKey="",this.disableTracking=!1,this.trackingSource="embedded_player",this.preload="auto",this.autoplay=!1,this.aspectRatio=0,this.eventController=new ug(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 $g(this),this._trackingController=new Tm(this)}get fetching(){return this._fetcherController.fetching}get waiting(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.waiting}get seeking(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.seeking}get paused(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.paused}get captions(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.captions}get fullscreen(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.fullscreen}get duration(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.duration}set currentTime(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.currentTime=t)}get currentTime(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.currentTime)??0}set playbackRate(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.playbackRate=t)}get playbackRate(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.playbackRate)??1}set volume(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.volume=t)}get volume(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.volume)??1}set muted(t){this._mediaPlayerRef.value&&(this._mediaPlayerRef.value.muted=t)}get muted(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.muted)??!1}get scene(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scene)??null}get scenes(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.scenes)??[]}get sceneConfig(){var t;return((t=this._mediaPlayerRef.value)==null?void 0:t.sceneConfig)??null}get videoState(){var t;return(t=this._mediaPlayerRef.value)==null?void 0:t.videoState}get mediaPlayer(){return this._mediaPlayerRef.value}play(){var t;(t=this._mediaPlayerRef.value)==null||t.play()}pause(){var t;(t=this._mediaPlayerRef.value)==null||t.pause()}setScene(t){var e;(e=this._mediaPlayerRef.value)==null||e.setScene(t)}render(){return ee`
1542
1542
  <vmp-media-player
1543
1543
  ${Si(this._mediaPlayerRef)}
1544
1544
  ${this.eventController.register()}
@@ -1554,5 +1554,5 @@ ${t}`,em=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),im=Objec
1554
1554
  :host {
1555
1555
  display: flex;
1556
1556
  }
1557
- `],Mi([It({type:Object})],Oe.Embed.prototype,"data",2),Mi([It({type:String})],Oe.Embed.prototype,"vouchId",2),Mi([It({type:String})],Oe.Embed.prototype,"templateId",2),Mi([It({type:Array})],Oe.Embed.prototype,"questions",2),Mi([It({type:String})],Oe.Embed.prototype,"env",2),Mi([It({type:String})],Oe.Embed.prototype,"apiKey",2),Mi([It({type:Boolean})],Oe.Embed.prototype,"disableTracking",2),Mi([It({type:String})],Oe.Embed.prototype,"trackingSource",2),Mi([It({type:Array})],Oe.Embed.prototype,"controls",2),Mi([It({type:String})],Oe.Embed.prototype,"preload",2),Mi([It({type:Boolean})],Oe.Embed.prototype,"autoplay",2),Mi([It({type:Number})],Oe.Embed.prototype,"aspectRatio",2),Mi([bi()],Oe.Embed.prototype,"vouch",2),Mi([bi()],Oe.Embed.prototype,"template",2),Oe.Embed=Mi([J2("vouch-embed")],Oe.Embed);function Nr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Xf(n,t){for(var e="",i=0,s=-1,o=0,c,d=0;d<=n.length;++d){if(d<n.length)c=n.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",i=0):(e=e.slice(0,f),i=e.length-1-e.lastIndexOf("/")),s=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+n.slice(s+1,d):e=n.slice(s+1,d),i=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function RA(n,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+n+i:i}var Mn={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var o;s>=0?o=arguments[s]:(i===void 0&&(i=process.cwd()),o=i),Nr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Xf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Nr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Xf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Nr(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];Nr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Mn.normalize(t)},relative:function(t,e){if(Nr(t),Nr(e),t===e||(t=Mn.resolve(t),e=Mn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,o=s-i,c=1;c<e.length&&e.charCodeAt(c)===47;++c);for(var d=e.length,f=d-c,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(c+v)===47)return e.slice(c+v+1);if(v===0)return e.slice(c+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var b=t.charCodeAt(i+v),E=e.charCodeAt(c+v);if(b!==E)break;b===47&&(g=v)}var T="";for(v=i+g+1;v<=s;++v)(v===s||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if(Nr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){s=c;break}}else o=!1;return s===-1?i?"/":".":i&&s===1?"//":t.slice(0,s)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Nr(t);var i=0,s=-1,o=!0,c;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(c=t.length-1;c>=0;--c){var p=t.charCodeAt(c);if(p===47){if(!o){i=c+1;break}}else f===-1&&(o=!1,f=c+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(s=c):(d=-1,s=f))}return i===s?s=f:s===-1&&(s=t.length),t.slice(i,s)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else s===-1&&(o=!1,s=c+1);return s===-1?"":t.slice(i,s)}},extname:function(t){Nr(t);for(var e=-1,i=0,s=-1,o=!0,c=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}s===-1&&(o=!1,s=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||s===-1||c===0||c===1&&e===s-1&&e===i+1?"":t.slice(e,s)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return RA("/",t)},parse:function(t){Nr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,o;s?(e.root="/",o=1):o=0;for(var c=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(i=t.charCodeAt(g),i===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),i===46?c===-1?c=g:v!==1&&(v=1):c!==-1&&(v=-1)}return c===-1||f===-1||v===0||v===1&&c===f-1&&c===d+1?f!==-1&&(d===0&&s?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&s?(e.name=t.slice(1,c),e.base=t.slice(1,f)):(e.name=t.slice(d,c),e.base=t.slice(d,f)),e.ext=t.slice(c,f)),d>0?e.dir=t.slice(0,d-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Mn.posix=Mn;var _A=Mn;const{basename:Zf,extname:LA}=_A;class CA{constructor(){let t=(()=>typeof to>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",o="image/webp",c="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:s,webp:o}:{png:e,jpg:i,jpeg:s,pdf:c,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[c]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function IA(n,{filename:t="",extension:e="",format:w,page:s,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:b}=new CA,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||LA(t),w=g(v(T)||T),C=v(w),D=n.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${b})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let O,F,x=t.replace(/{(\d*)}/g,(H,j)=>(F=!0,j=parseInt(j,10),O=isFinite(j)?j:isFinite(O)?O:-1,"{}")),N=s>0?s-1:s<0?D+s:void 0;if(isFinite(N)&&N<0||N>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${N} is out of bounds)`:`Canvas has pages 1–${D} (${N} is out of bounds)`);if(n=isFinite(N)?[n[N]]:F||w=="pdf"?n:n.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let H=(e||Zf(t,T)).match(/@(\d+)x$/i);d=H?parseInt(H[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:x,format:w,mime:C,pages:n,padding:O,quality:o,matte:c,density:d,outline:f,archive:E}}class jo{static for(t){return new jo().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,o=t.length|0;s<o;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}jo.prototype.table=(()=>{var n,t,e,i=[];for(n=0;n<256;n++){for(e=n,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[n]=e}return i})();function ch(n){let t=new Uint8Array(n),e=new DataView(t.buffer),i={array:t,view:e,size:n,set8(s,o){return e.setUint8(s,o),i},set16(s,o){return e.setUint16(s,o,!0),i},set32(s,o){return e.setUint32(s,o,!0),i},bytes(s,o){return t.set(o,s),i}};return i}const Ko=class Ko{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,s=Ko.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+s.length,d=c+o.length,f=16,{offset:p}=this,g=ch(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,jo.for(o)).set32(14,o.length).set32(18,o.length).set16(22,s.length);p+=c;let v=ch(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,s).bytes(c,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:s,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:b})=>46+b.length+v,0),e=ch(t+22),i=0;for(var{offset:s,name:o,header:c,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,c.array).set8(i+38,d?16:0).set32(i+42,s).bytes(i+46,o),i+=46+o.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};b2(Ko,"encoder",new TextEncoder);let hh=Ko;const dh=(n,t,e,i)=>{if(i){let{width:s,height:o}=n,c=Object.assign(document.createElement("canvas"),{width:s,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,s,o),d.drawImage(n,0,0),n=c}return new Promise((s,o)=>n.toBlob(s,t,e))},xA=(...n)=>dh(...n).then(t=>t.arrayBuffer()),DA=async(n,t,e,i,s)=>{qf(s,await dh(n,t,e,i))},PA=async(n,t,e,i,s,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=Zf(s,".zip")||"archive",p=new hh(f);await Promise.all(n.map(async(g,v)=>{let b=d(v);await p.add(b,await dh(g,t,e,i))})),qf(`${f}.zip`,p.blob)},qf=(n,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",n),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var OA={asBuffer:xA,asDownload:DA,asZipDownload:PA,atScale:(n,t,e)=>n.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),o=s.getContext("2d"),c=i.canvas?i.canvas:i;return s.width=c.width*t,s.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,s.width,s.height)),o.scale(t,t),o.drawImage(c,0,0),s}),options:IA};const{asBuffer:uh,asDownload:MA,asZipDownload:$A,atScale:fh,options:ph}=OA,Qf=Symbol.for("toDataURL"),NA=n=>{let t=Object.assign(new Jf,{crossOrigin:"Anonymous",src:n});return t.decode().then(()=>t)};class FA{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>uh(i,"image/png"),jpg:()=>uh(i,"image/jpeg"),pages:()=>s.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:c});return Object.assign(i,{width:t,height:e,newPage(...d){var{width:p,height:g}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(i,0,0),s.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(i,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:b,quality:E,matte:T,density:w,archive:C}=p,D=fh(p.pages,w);return v==null?MA(D[0],b,E,T,d):$A(D,b,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=fh(E,T,b)[0];return uh(w,g,v,b)},[Qf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=fh(E,T,b)[0],C=w[w===i?Qf:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:UA,CanvasGradient:BA,CanvasPattern:GA,Image:Jf,ImageData:HA,Path2D:VA,DOMMatrix:WA,DOMRect:jA,DOMPoint:KA}=window;var tp={Canvas:FA,loadImage:NA,CanvasRenderingContext2D:UA,CanvasGradient:BA,CanvasPattern:GA,Image:Jf,ImageData:HA,Path2D:VA,DOMMatrix:WA,DOMRect:jA,DOMPoint:KA};const ep=zr({__proto__:null,default:Il(tp)},[tp]);return Object.defineProperty(Oe,Symbol.toStringTag,{value:"Module"}),Oe}({});
1557
+ `],Mi([It({type:Object})],Oe.Embed.prototype,"data",2),Mi([It({type:String})],Oe.Embed.prototype,"vouchId",2),Mi([It({type:String})],Oe.Embed.prototype,"templateId",2),Mi([It({type:Array})],Oe.Embed.prototype,"questions",2),Mi([It({type:String})],Oe.Embed.prototype,"env",2),Mi([It({type:String})],Oe.Embed.prototype,"apiKey",2),Mi([It({type:Boolean})],Oe.Embed.prototype,"disableTracking",2),Mi([It({type:String})],Oe.Embed.prototype,"trackingSource",2),Mi([It({type:Array})],Oe.Embed.prototype,"controls",2),Mi([It({type:String})],Oe.Embed.prototype,"preload",2),Mi([It({type:Boolean})],Oe.Embed.prototype,"autoplay",2),Mi([It({type:Number})],Oe.Embed.prototype,"aspectRatio",2),Mi([ki()],Oe.Embed.prototype,"vouch",2),Mi([ki()],Oe.Embed.prototype,"template",2),Oe.Embed=Mi([J2("vouch-embed")],Oe.Embed);function Nr(n){if(typeof n!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(n))}function Xf(n,t){for(var e="",i=0,s=-1,o=0,c,d=0;d<=n.length;++d){if(d<n.length)c=n.charCodeAt(d);else{if(c===47)break;c=47}if(c===47){if(!(s===d-1||o===1))if(s!==d-1&&o===2){if(e.length<2||i!==2||e.charCodeAt(e.length-1)!==46||e.charCodeAt(e.length-2)!==46){if(e.length>2){var f=e.lastIndexOf("/");if(f!==e.length-1){f===-1?(e="",i=0):(e=e.slice(0,f),i=e.length-1-e.lastIndexOf("/")),s=d,o=0;continue}}else if(e.length===2||e.length===1){e="",i=0,s=d,o=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+="/"+n.slice(s+1,d):e=n.slice(s+1,d),i=d-s-1;s=d,o=0}else c===46&&o!==-1?++o:o=-1}return e}function RA(n,t){var e=t.dir||t.root,i=t.base||(t.name||"")+(t.ext||"");return e?e===t.root?e+i:e+n+i:i}var Mn={resolve:function(){for(var t="",e=!1,i,s=arguments.length-1;s>=-1&&!e;s--){var o;s>=0?o=arguments[s]:(i===void 0&&(i=process.cwd()),o=i),Nr(o),o.length!==0&&(t=o+"/"+t,e=o.charCodeAt(0)===47)}return t=Xf(t,!e),e?t.length>0?"/"+t:"/":t.length>0?t:"."},normalize:function(t){if(Nr(t),t.length===0)return".";var e=t.charCodeAt(0)===47,i=t.charCodeAt(t.length-1)===47;return t=Xf(t,!e),t.length===0&&!e&&(t="."),t.length>0&&i&&(t+="/"),e?"/"+t:t},isAbsolute:function(t){return Nr(t),t.length>0&&t.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var t,e=0;e<arguments.length;++e){var i=arguments[e];Nr(i),i.length>0&&(t===void 0?t=i:t+="/"+i)}return t===void 0?".":Mn.normalize(t)},relative:function(t,e){if(Nr(t),Nr(e),t===e||(t=Mn.resolve(t),e=Mn.resolve(e),t===e))return"";for(var i=1;i<t.length&&t.charCodeAt(i)===47;++i);for(var s=t.length,o=s-i,c=1;c<e.length&&e.charCodeAt(c)===47;++c);for(var d=e.length,f=d-c,p=o<f?o:f,g=-1,v=0;v<=p;++v){if(v===p){if(f>p){if(e.charCodeAt(c+v)===47)return e.slice(c+v+1);if(v===0)return e.slice(c+v)}else o>p&&(t.charCodeAt(i+v)===47?g=v:v===0&&(g=0));break}var b=t.charCodeAt(i+v),E=e.charCodeAt(c+v);if(b!==E)break;b===47&&(g=v)}var T="";for(v=i+g+1;v<=s;++v)(v===s||t.charCodeAt(v)===47)&&(T.length===0?T+="..":T+="/..");return T.length>0?T+e.slice(c+g):(c+=g,e.charCodeAt(c)===47&&++c,e.slice(c))},_makeLong:function(t){return t},dirname:function(t){if(Nr(t),t.length===0)return".";for(var e=t.charCodeAt(0),i=e===47,s=-1,o=!0,c=t.length-1;c>=1;--c)if(e=t.charCodeAt(c),e===47){if(!o){s=c;break}}else o=!1;return s===-1?i?"/":".":i&&s===1?"//":t.slice(0,s)},basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');Nr(t);var i=0,s=-1,o=!0,c;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";var d=e.length-1,f=-1;for(c=t.length-1;c>=0;--c){var p=t.charCodeAt(c);if(p===47){if(!o){i=c+1;break}}else f===-1&&(o=!1,f=c+1),d>=0&&(p===e.charCodeAt(d)?--d===-1&&(s=c):(d=-1,s=f))}return i===s?s=f:s===-1&&(s=t.length),t.slice(i,s)}else{for(c=t.length-1;c>=0;--c)if(t.charCodeAt(c)===47){if(!o){i=c+1;break}}else s===-1&&(o=!1,s=c+1);return s===-1?"":t.slice(i,s)}},extname:function(t){Nr(t);for(var e=-1,i=0,s=-1,o=!0,c=0,d=t.length-1;d>=0;--d){var f=t.charCodeAt(d);if(f===47){if(!o){i=d+1;break}continue}s===-1&&(o=!1,s=d+1),f===46?e===-1?e=d:c!==1&&(c=1):e!==-1&&(c=-1)}return e===-1||s===-1||c===0||c===1&&e===s-1&&e===i+1?"":t.slice(e,s)},format:function(t){if(t===null||typeof t!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof t);return RA("/",t)},parse:function(t){Nr(t);var e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;var i=t.charCodeAt(0),s=i===47,o;s?(e.root="/",o=1):o=0;for(var c=-1,d=0,f=-1,p=!0,g=t.length-1,v=0;g>=o;--g){if(i=t.charCodeAt(g),i===47){if(!p){d=g+1;break}continue}f===-1&&(p=!1,f=g+1),i===46?c===-1?c=g:v!==1&&(v=1):c!==-1&&(v=-1)}return c===-1||f===-1||v===0||v===1&&c===f-1&&c===d+1?f!==-1&&(d===0&&s?e.base=e.name=t.slice(1,f):e.base=e.name=t.slice(d,f)):(d===0&&s?(e.name=t.slice(1,c),e.base=t.slice(1,f)):(e.name=t.slice(d,c),e.base=t.slice(d,f)),e.ext=t.slice(c,f)),d>0?e.dir=t.slice(0,d-1):s&&(e.dir="/"),e},sep:"/",delimiter:":",win32:null,posix:null};Mn.posix=Mn;var _A=Mn;const{basename:Zf,extname:LA}=_A;class CA{constructor(){let t=(()=>typeof to>"u")(),e="image/png",i="image/jpeg",s="image/jpeg",o="image/webp",c="application/pdf",d="image/svg+xml";Object.assign(this,{toMime:this.toMime.bind(this),fromMime:this.fromMime.bind(this),expected:t?'"png", "jpg", or "webp"':'"png", "jpg", "pdf", or "svg"',formats:t?{png:e,jpg:i,jpeg:s,webp:o}:{png:e,jpg:i,jpeg:s,pdf:c,svg:d},mimes:t?{[e]:"png",[i]:"jpg",[o]:"webp"}:{[e]:"png",[i]:"jpg",[c]:"pdf",[d]:"svg"}})}toMime(t){return this.formats[(t||"").replace(/^\./,"").toLowerCase()]}fromMime(t){return this.mimes[t]}}function IA(n,{filename:t="",extension:e="",format:w,page:s,quality:o,matte:c,density:d,outline:f,archive:E}={}){var{fromMime:g,toMime:v,expected:b}=new CA,E=E||"canvas",T=w||e.replace(/@\d+x$/i,"")||LA(t),w=g(v(T)||T),C=v(w),D=n.length;if(!T)throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");if(!w)throw new Error(`Unsupported file format "${T}" (expected ${b})`);if(!D)throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");let O,F,x=t.replace(/{(\d*)}/g,(H,j)=>(F=!0,j=parseInt(j,10),O=isFinite(j)?j:isFinite(O)?O:-1,"{}")),N=s>0?s-1:s<0?D+s:void 0;if(isFinite(N)&&N<0||N>=D)throw new RangeError(D==1?`Canvas only has a ‘page 1’ (${N} is out of bounds)`:`Canvas has pages 1–${D} (${N} is out of bounds)`);if(n=isFinite(N)?[n[N]]:F||w=="pdf"?n:n.slice(-1),o===void 0)o=.92;else if(typeof o!="number"||!isFinite(o)||o<0||o>1)throw new TypeError("The quality option must be an number in the 0.0–1.0 range");if(d===void 0){let H=(e||Zf(t,T)).match(/@(\d+)x$/i);d=H?parseInt(H[1],10):1}else if(typeof d!="number"||!Number.isInteger(d)||d<1)throw new TypeError("The density option must be a non-negative integer");return f===void 0?f=!0:w=="svg"&&(f=!!f),{filename:t,pattern:x,format:w,mime:C,pages:n,padding:O,quality:o,matte:c,density:d,outline:f,archive:E}}class jo{static for(t){return new jo().append(t).get()}constructor(){this.crc=-1}get(){return~this.crc}append(t){for(var e=this.crc|0,i=this.table,s=0,o=t.length|0;s<o;s++)e=e>>>8^i[(e^t[s])&255];return this.crc=e,this}}jo.prototype.table=(()=>{var n,t,e,i=[];for(n=0;n<256;n++){for(e=n,t=0;t<8;t++)e=e&1?e>>>1^3988292384:e>>>1;i[n]=e}return i})();function ch(n){let t=new Uint8Array(n),e=new DataView(t.buffer),i={array:t,view:e,size:n,set8(s,o){return e.setUint8(s,o),i},set16(s,o){return e.setUint16(s,o,!0),i},set32(s,o){return e.setUint32(s,o,!0),i},bytes(s,o){return t.set(o,s),i}};return i}const Ko=class Ko{constructor(t){let e=new Date;Object.assign(this,{directory:t,offset:0,files:[],time:(e.getHours()<<6|e.getMinutes())<<5|e.getSeconds()/2,date:(e.getFullYear()-1980<<4|e.getMonth()+1)<<5|e.getDate()}),this.add(t)}async add(t,e){let i=!e,s=Ko.encoder.encode(`${this.directory}/${i?"":t}`),o=new Uint8Array(i?0:await e.arrayBuffer()),c=30+s.length,d=c+o.length,f=16,{offset:p}=this,g=ch(26).set32(0,134742036).set16(6,this.time).set16(8,this.date).set32(10,jo.for(o)).set32(14,o.length).set32(18,o.length).set16(22,s.length);p+=c;let v=ch(c+o.length+f).set32(0,67324752).bytes(4,g.array).bytes(30,s).bytes(c,o);p+=o.length,v.set32(d,134695760).bytes(d+4,g.array.slice(10,22)),p+=f,this.files.push({offset:p,folder:i,name:s,header:g,payload:v}),this.offset=p}toBuffer(){let t=this.files.reduce((v,{name:b})=>46+b.length+v,0),e=ch(t+22),i=0;for(var{offset:s,name:o,header:c,folder:d}of this.files)e.set32(i,33639248).set16(i+4,20).bytes(i+6,c.array).set8(i+38,d?16:0).set32(i+42,s).bytes(i+46,o),i+=46+o.length;e.set32(i,101010256).set16(i+8,this.files.length).set16(i+10,this.files.length).set32(i+12,t).set32(i+16,this.offset);let f=new Uint8Array(this.offset+e.size),p=0;for(var{payload:g}of this.files)f.set(g.array,p),p+=g.size;return f.set(e.array,p),f}get blob(){return new Blob([this.toBuffer()],{type:"application/zip"})}};b2(Ko,"encoder",new TextEncoder);let hh=Ko;const dh=(n,t,e,i)=>{if(i){let{width:s,height:o}=n,c=Object.assign(document.createElement("canvas"),{width:s,height:o}),d=c.getContext("2d");d.fillStyle=i,d.fillRect(0,0,s,o),d.drawImage(n,0,0),n=c}return new Promise((s,o)=>n.toBlob(s,t,e))},xA=(...n)=>dh(...n).then(t=>t.arrayBuffer()),DA=async(n,t,e,i,s)=>{qf(s,await dh(n,t,e,i))},PA=async(n,t,e,i,s,o,c)=>{let d=g=>o.replace("{}",String(g+1).padStart(c,"0")),f=Zf(s,".zip")||"archive",p=new hh(f);await Promise.all(n.map(async(g,v)=>{let b=d(v);await p.add(b,await dh(g,t,e,i))})),qf(`${f}.zip`,p.blob)},qf=(n,t)=>{const e=window.URL.createObjectURL(t),i=document.createElement("a");i.style.display="none",i.href=e,i.setAttribute("download",n),typeof i.download>"u"&&i.setAttribute("target","_blank"),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>window.URL.revokeObjectURL(e),100)};var OA={asBuffer:xA,asDownload:DA,asZipDownload:PA,atScale:(n,t,e)=>n.map(i=>{if(t==1&&!e)return i.canvas;let s=document.createElement("canvas"),o=s.getContext("2d"),c=i.canvas?i.canvas:i;return s.width=c.width*t,s.height=c.height*t,e&&(o.fillStyle=e,o.fillRect(0,0,s.width,s.height)),o.scale(t,t),o.drawImage(c,0,0),s}),options:IA};const{asBuffer:uh,asDownload:MA,asZipDownload:$A,atScale:fh,options:ph}=OA,Qf=Symbol.for("toDataURL"),NA=n=>{let t=Object.assign(new Jf,{crossOrigin:"Anonymous",src:n});return t.decode().then(()=>t)};class FA{constructor(t,e){let i=document.createElement("canvas"),s=[];Object.defineProperty(i,"async",{value:!0,writable:!1,enumerable:!0});for(var[o,c]of Object.entries({png:()=>uh(i,"image/png"),jpg:()=>uh(i,"image/jpeg"),pages:()=>s.concat(i).map(d=>d.getContext("2d"))}))Object.defineProperty(i,o,{get:c});return Object.assign(i,{width:t,height:e,newPage(...d){var{width:p,height:g}=i,f=Object.assign(document.createElement("canvas"),{width:p,height:g});f.getContext("2d").drawImage(i,0,0),s.push(f);var[p,g]=d.length?d:[p,g];return Object.assign(i,{width:p,height:g}).getContext("2d")},saveAs(d,f){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{filename:d,...f}),{pattern:g,padding:v,mime:b,quality:E,matte:T,density:w,archive:C}=p,D=fh(p.pages,w);return v==null?MA(D[0],b,E,T,d):$A(D,b,E,T,C,g,v)},toBuffer(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=fh(E,T,b)[0];return uh(w,g,v,b)},[Qf]:i.toDataURL.bind(i),toDataURL(d="png",f={}){f=typeof f=="number"?{quality:f}:f;let p=ph(this.pages,{extension:d,...f}),{mime:g,quality:v,matte:b,pages:E,density:T}=p,w=fh(E,T,b)[0],C=w[w===i?Qf:"toDataURL"](g,v);return Promise.resolve(C)}})}}const{CanvasRenderingContext2D:UA,CanvasGradient:BA,CanvasPattern:GA,Image:Jf,ImageData:HA,Path2D:VA,DOMMatrix:WA,DOMRect:jA,DOMPoint:KA}=window;var tp={Canvas:FA,loadImage:NA,CanvasRenderingContext2D:UA,CanvasGradient:BA,CanvasPattern:GA,Image:Jf,ImageData:HA,Path2D:VA,DOMMatrix:WA,DOMRect:jA,DOMPoint:KA};const ep=zr({__proto__:null,default:Il(tp)},[tp]);return Object.defineProperty(Oe,Symbol.toStringTag,{value:"Module"}),Oe}({});
1558
1558
  //# sourceMappingURL=embeds.iife.js.map