index-32f34d24.js 456.8 KB
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))s(r);new MutationObserver(r=>{for(const n of r)if(n.type==="childList")for(const o of n.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const n={};return r.integrity&&(n.integrity=r.integrity),r.referrerPolicy&&(n.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?n.credentials="include":r.crossOrigin==="anonymous"?n.credentials="omit":n.credentials="same-origin",n}function s(r){if(r.ep)return;r.ep=!0;const n=t(r);fetch(r.href,n)}})();function Pn(i,e){const t=Object.create(null),s=i.split(",");for(let r=0;r<s.length;r++)t[s[r]]=!0;return e?r=>!!t[r.toLowerCase()]:r=>!!t[r]}const Ie={},ys=[],pt=()=>{},Yu=()=>!1,ju=/^on[^a-z]/,qi=i=>ju.test(i),kn=i=>i.startsWith("onUpdate:"),Ue=Object.assign,On=(i,e)=>{const t=i.indexOf(e);t>-1&&i.splice(t,1)},qu=Object.prototype.hasOwnProperty,ge=(i,e)=>qu.call(i,e),le=Array.isArray,Gs=i=>zi(i)==="[object Map]",zu=i=>zi(i)==="[object Set]",ce=i=>typeof i=="function",Ge=i=>typeof i=="string",Fn=i=>typeof i=="symbol",Pe=i=>i!==null&&typeof i=="object",Al=i=>Pe(i)&&ce(i.then)&&ce(i.catch),Xu=Object.prototype.toString,zi=i=>Xu.call(i),Qu=i=>zi(i).slice(8,-1),Ju=i=>zi(i)==="[object Object]",Nn=i=>Ge(i)&&i!=="NaN"&&i[0]!=="-"&&""+parseInt(i,10)===i,Ri=Pn(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Xi=i=>{const e=Object.create(null);return t=>e[t]||(e[t]=i(t))},Zu=/-(\w)/g,It=Xi(i=>i.replace(Zu,(e,t)=>t?t.toUpperCase():"")),ef=/\B([A-Z])/g,Ds=Xi(i=>i.replace(ef,"-$1").toLowerCase()),Qi=Xi(i=>i.charAt(0).toUpperCase()+i.slice(1)),yr=Xi(i=>i?`on${Qi(i)}`:""),qs=(i,e)=>!Object.is(i,e),Tr=(i,e)=>{for(let t=0;t<i.length;t++)i[t](e)},Fi=(i,e,t)=>{Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value:t})},tf=i=>{const e=parseFloat(i);return isNaN(e)?i:e};let bo;const en=()=>bo||(bo=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{});function Mn(i){if(le(i)){const e={};for(let t=0;t<i.length;t++){const s=i[t],r=Ge(s)?of(s):Mn(s);if(r)for(const n in r)e[n]=r[n]}return e}else{if(Ge(i))return i;if(Pe(i))return i}}const sf=/;(?![^(]*\))/g,rf=/:([^]+)/,nf=/\/\*[^]*?\*\//g;function of(i){const e={};return i.replace(nf,"").split(sf).forEach(t=>{if(t){const s=t.split(rf);s.length>1&&(e[s[0].trim()]=s[1].trim())}}),e}function Ji(i){let e="";if(Ge(i))e=i;else if(le(i))for(let t=0;t<i.length;t++){const s=Ji(i[t]);s&&(e+=s+" ")}else if(Pe(i))for(const t in i)i[t]&&(e+=t+" ");return e.trim()}const af="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",lf=Pn(af);function Rl(i){return!!i||i===""}let lt;class cf{constructor(e=!1){this.detached=e,this._active=!0,this.effects=[],this.cleanups=[],this.parent=lt,!e&&lt&&(this.index=(lt.scopes||(lt.scopes=[])).push(this)-1)}get active(){return this._active}run(e){if(this._active){const t=lt;try{return lt=this,e()}finally{lt=t}}}on(){lt=this}off(){lt=this.parent}stop(e){if(this._active){let t,s;for(t=0,s=this.effects.length;t<s;t++)this.effects[t].stop();for(t=0,s=this.cleanups.length;t<s;t++)this.cleanups[t]();if(this.scopes)for(t=0,s=this.scopes.length;t<s;t++)this.scopes[t].stop(!0);if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0,this._active=!1}}}function uf(i,e=lt){e&&e.active&&e.effects.push(i)}function ff(){return lt}const Un=i=>{const e=new Set(i);return e.w=0,e.n=0,e},Ll=i=>(i.w&zt)>0,bl=i=>(i.n&zt)>0,hf=({deps:i})=>{if(i.length)for(let e=0;e<i.length;e++)i[e].w|=zt},df=i=>{const{deps:e}=i;if(e.length){let t=0;for(let s=0;s<e.length;s++){const r=e[s];Ll(r)&&!bl(r)?r.delete(i):e[t++]=r,r.w&=~zt,r.n&=~zt}e.length=t}},tn=new WeakMap;let Bs=0,zt=1;const sn=30;let ft;const is=Symbol(""),rn=Symbol("");class Bn{constructor(e,t=null,s){this.fn=e,this.scheduler=t,this.active=!0,this.deps=[],this.parent=void 0,uf(this,s)}run(){if(!this.active)return this.fn();let e=ft,t=jt;for(;e;){if(e===this)return;e=e.parent}try{return this.parent=ft,ft=this,jt=!0,zt=1<<++Bs,Bs<=sn?hf(this):Io(this),this.fn()}finally{Bs<=sn&&df(this),zt=1<<--Bs,ft=this.parent,jt=t,this.parent=void 0,this.deferStop&&this.stop()}}stop(){ft===this?this.deferStop=!0:this.active&&(Io(this),this.onStop&&this.onStop(),this.active=!1)}}function Io(i){const{deps:e}=i;if(e.length){for(let t=0;t<e.length;t++)e[t].delete(i);e.length=0}}let jt=!0;const Il=[];function _s(){Il.push(jt),jt=!1}function Cs(){const i=Il.pop();jt=i===void 0?!0:i}function Ze(i,e,t){if(jt&&ft){let s=tn.get(i);s||tn.set(i,s=new Map);let r=s.get(t);r||s.set(t,r=Un()),Dl(r)}}function Dl(i,e){let t=!1;Bs<=sn?bl(i)||(i.n|=zt,t=!Ll(i)):t=!i.has(ft),t&&(i.add(ft),ft.deps.push(i))}function Mt(i,e,t,s,r,n){const o=tn.get(i);if(!o)return;let a=[];if(e==="clear")a=[...o.values()];else if(t==="length"&&le(i)){const l=Number(s);o.forEach((c,u)=>{(u==="length"||u>=l)&&a.push(c)})}else switch(t!==void 0&&a.push(o.get(t)),e){case"add":le(i)?Nn(t)&&a.push(o.get("length")):(a.push(o.get(is)),Gs(i)&&a.push(o.get(rn)));break;case"delete":le(i)||(a.push(o.get(is)),Gs(i)&&a.push(o.get(rn)));break;case"set":Gs(i)&&a.push(o.get(is));break}if(a.length===1)a[0]&&nn(a[0]);else{const l=[];for(const c of a)c&&l.push(...c);nn(Un(l))}}function nn(i,e){const t=le(i)?i:[...i];for(const s of t)s.computed&&Do(s);for(const s of t)s.computed||Do(s)}function Do(i,e){(i!==ft||i.allowRecurse)&&(i.scheduler?i.scheduler():i.run())}const gf=Pn("__proto__,__v_isRef,__isVue"),_l=new Set(Object.getOwnPropertyNames(Symbol).filter(i=>i!=="arguments"&&i!=="caller").map(i=>Symbol[i]).filter(Fn)),mf=$n(),pf=$n(!1,!0),yf=$n(!0),_o=Tf();function Tf(){const i={};return["includes","indexOf","lastIndexOf"].forEach(e=>{i[e]=function(...t){const s=Ee(this);for(let n=0,o=this.length;n<o;n++)Ze(s,"get",n+"");const r=s[e](...t);return r===-1||r===!1?s[e](...t.map(Ee)):r}}),["push","pop","shift","unshift","splice"].forEach(e=>{i[e]=function(...t){_s();const s=Ee(this)[e].apply(this,t);return Cs(),s}}),i}function Ef(i){const e=Ee(this);return Ze(e,"has",i),e.hasOwnProperty(i)}function $n(i=!1,e=!1){return function(s,r,n){if(r==="__v_isReactive")return!i;if(r==="__v_isReadonly")return i;if(r==="__v_isShallow")return e;if(r==="__v_raw"&&n===(i?e?Ff:Ol:e?kl:Pl).get(s))return s;const o=le(s);if(!i){if(o&&ge(_o,r))return Reflect.get(_o,r,n);if(r==="hasOwnProperty")return Ef}const a=Reflect.get(s,r,n);return(Fn(r)?_l.has(r):gf(r))||(i||Ze(s,"get",r),e)?a:Ye(a)?o&&Nn(r)?a:a.value:Pe(a)?i?Nl(a):er(a):a}}const xf=Cl(),Sf=Cl(!0);function Cl(i=!1){return function(t,s,r,n){let o=t[s];if(vs(o)&&Ye(o)&&!Ye(r))return!1;if(!i&&(!Ni(r)&&!vs(r)&&(o=Ee(o),r=Ee(r)),!le(t)&&Ye(o)&&!Ye(r)))return o.value=r,!0;const a=le(t)&&Nn(s)?Number(s)<t.length:ge(t,s),l=Reflect.set(t,s,r,n);return t===Ee(n)&&(a?qs(r,o)&&Mt(t,"set",s,r):Mt(t,"add",s,r)),l}}function vf(i,e){const t=ge(i,e);i[e];const s=Reflect.deleteProperty(i,e);return s&&t&&Mt(i,"delete",e,void 0),s}function Af(i,e){const t=Reflect.has(i,e);return(!Fn(e)||!_l.has(e))&&Ze(i,"has",e),t}function Rf(i){return Ze(i,"iterate",le(i)?"length":is),Reflect.ownKeys(i)}const wl={get:mf,set:xf,deleteProperty:vf,has:Af,ownKeys:Rf},Lf={get:yf,set(i,e){return!0},deleteProperty(i,e){return!0}},bf=Ue({},wl,{get:pf,set:Sf}),Gn=i=>i,Zi=i=>Reflect.getPrototypeOf(i);function li(i,e,t=!1,s=!1){i=i.__v_raw;const r=Ee(i),n=Ee(e);t||(e!==n&&Ze(r,"get",e),Ze(r,"get",n));const{has:o}=Zi(r),a=s?Gn:t?Vn:zs;if(o.call(r,e))return a(i.get(e));if(o.call(r,n))return a(i.get(n));i!==r&&i.get(e)}function ci(i,e=!1){const t=this.__v_raw,s=Ee(t),r=Ee(i);return e||(i!==r&&Ze(s,"has",i),Ze(s,"has",r)),i===r?t.has(i):t.has(i)||t.has(r)}function ui(i,e=!1){return i=i.__v_raw,!e&&Ze(Ee(i),"iterate",is),Reflect.get(i,"size",i)}function Co(i){i=Ee(i);const e=Ee(this);return Zi(e).has.call(e,i)||(e.add(i),Mt(e,"add",i,i)),this}function wo(i,e){e=Ee(e);const t=Ee(this),{has:s,get:r}=Zi(t);let n=s.call(t,i);n||(i=Ee(i),n=s.call(t,i));const o=r.call(t,i);return t.set(i,e),n?qs(e,o)&&Mt(t,"set",i,e):Mt(t,"add",i,e),this}function Po(i){const e=Ee(this),{has:t,get:s}=Zi(e);let r=t.call(e,i);r||(i=Ee(i),r=t.call(e,i)),s&&s.call(e,i);const n=e.delete(i);return r&&Mt(e,"delete",i,void 0),n}function ko(){const i=Ee(this),e=i.size!==0,t=i.clear();return e&&Mt(i,"clear",void 0,void 0),t}function fi(i,e){return function(s,r){const n=this,o=n.__v_raw,a=Ee(o),l=e?Gn:i?Vn:zs;return!i&&Ze(a,"iterate",is),o.forEach((c,u)=>s.call(r,l(c),l(u),n))}}function hi(i,e,t){return function(...s){const r=this.__v_raw,n=Ee(r),o=Gs(n),a=i==="entries"||i===Symbol.iterator&&o,l=i==="keys"&&o,c=r[i](...s),u=t?Gn:e?Vn:zs;return!e&&Ze(n,"iterate",l?rn:is),{next(){const{value:f,done:h}=c.next();return h?{value:f,done:h}:{value:a?[u(f[0]),u(f[1])]:u(f),done:h}},[Symbol.iterator](){return this}}}}function Bt(i){return function(...e){return i==="delete"?!1:this}}function If(){const i={get(n){return li(this,n)},get size(){return ui(this)},has:ci,add:Co,set:wo,delete:Po,clear:ko,forEach:fi(!1,!1)},e={get(n){return li(this,n,!1,!0)},get size(){return ui(this)},has:ci,add:Co,set:wo,delete:Po,clear:ko,forEach:fi(!1,!0)},t={get(n){return li(this,n,!0)},get size(){return ui(this,!0)},has(n){return ci.call(this,n,!0)},add:Bt("add"),set:Bt("set"),delete:Bt("delete"),clear:Bt("clear"),forEach:fi(!0,!1)},s={get(n){return li(this,n,!0,!0)},get size(){return ui(this,!0)},has(n){return ci.call(this,n,!0)},add:Bt("add"),set:Bt("set"),delete:Bt("delete"),clear:Bt("clear"),forEach:fi(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach(n=>{i[n]=hi(n,!1,!1),t[n]=hi(n,!0,!1),e[n]=hi(n,!1,!0),s[n]=hi(n,!0,!0)}),[i,t,e,s]}const[Df,_f,Cf,wf]=If();function Kn(i,e){const t=e?i?wf:Cf:i?_f:Df;return(s,r,n)=>r==="__v_isReactive"?!i:r==="__v_isReadonly"?i:r==="__v_raw"?s:Reflect.get(ge(t,r)&&r in s?t:s,r,n)}const Pf={get:Kn(!1,!1)},kf={get:Kn(!1,!0)},Of={get:Kn(!0,!1)},Pl=new WeakMap,kl=new WeakMap,Ol=new WeakMap,Ff=new WeakMap;function Nf(i){switch(i){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function Mf(i){return i.__v_skip||!Object.isExtensible(i)?0:Nf(Qu(i))}function er(i){return vs(i)?i:Hn(i,!1,wl,Pf,Pl)}function Fl(i){return Hn(i,!1,bf,kf,kl)}function Nl(i){return Hn(i,!0,Lf,Of,Ol)}function Hn(i,e,t,s,r){if(!Pe(i)||i.__v_raw&&!(e&&i.__v_isReactive))return i;const n=r.get(i);if(n)return n;const o=Mf(i);if(o===0)return i;const a=new Proxy(i,o===2?s:t);return r.set(i,a),a}function Ts(i){return vs(i)?Ts(i.__v_raw):!!(i&&i.__v_isReactive)}function vs(i){return!!(i&&i.__v_isReadonly)}function Ni(i){return!!(i&&i.__v_isShallow)}function Ml(i){return Ts(i)||vs(i)}function Ee(i){const e=i&&i.__v_raw;return e?Ee(e):i}function Ul(i){return Fi(i,"__v_skip",!0),i}const zs=i=>Pe(i)?er(i):i,Vn=i=>Pe(i)?Nl(i):i;function Bl(i){jt&&ft&&(i=Ee(i),Dl(i.dep||(i.dep=Un())))}function $l(i,e){i=Ee(i);const t=i.dep;t&&nn(t)}function Ye(i){return!!(i&&i.__v_isRef===!0)}function Li(i){return Gl(i,!1)}function Uf(i){return Gl(i,!0)}function Gl(i,e){return Ye(i)?i:new Bf(i,e)}class Bf{constructor(e,t){this.__v_isShallow=t,this.dep=void 0,this.__v_isRef=!0,this._rawValue=t?e:Ee(e),this._value=t?e:zs(e)}get value(){return Bl(this),this._value}set value(e){const t=this.__v_isShallow||Ni(e)||vs(e);e=t?e:Ee(e),qs(e,this._rawValue)&&(this._rawValue=e,this._value=t?e:zs(e),$l(this))}}function rs(i){return Ye(i)?i.value:i}const $f={get:(i,e,t)=>rs(Reflect.get(i,e,t)),set:(i,e,t,s)=>{const r=i[e];return Ye(r)&&!Ye(t)?(r.value=t,!0):Reflect.set(i,e,t,s)}};function Kl(i){return Ts(i)?i:new Proxy(i,$f)}class Gf{constructor(e,t,s,r){this._setter=t,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new Bn(e,()=>{this._dirty||(this._dirty=!0,$l(this))}),this.effect.computed=this,this.effect.active=this._cacheable=!r,this.__v_isReadonly=s}get value(){const e=Ee(this);return Bl(e),(e._dirty||!e._cacheable)&&(e._dirty=!1,e._value=e.effect.run()),e._value}set value(e){this._setter(e)}}function Kf(i,e,t=!1){let s,r;const n=ce(i);return n?(s=i,r=pt):(s=i.get,r=i.set),new Gf(s,r,n||!r,t)}function qt(i,e,t,s){let r;try{r=s?i(...s):i()}catch(n){tr(n,e,t)}return r}function yt(i,e,t,s){if(ce(i)){const n=qt(i,e,t,s);return n&&Al(n)&&n.catch(o=>{tr(o,e,t)}),n}const r=[];for(let n=0;n<i.length;n++)r.push(yt(i[n],e,t,s));return r}function tr(i,e,t,s=!0){const r=e?e.vnode:null;if(e){let n=e.parent;const o=e.proxy,a=t;for(;n;){const c=n.ec;if(c){for(let u=0;u<c.length;u++)if(c[u](i,o,a)===!1)return}n=n.parent}const l=e.appContext.config.errorHandler;if(l){qt(l,null,10,[i,o,a]);return}}Hf(i,t,r,s)}function Hf(i,e,t,s=!0){console.error(i)}let Xs=!1,on=!1;const We=[];let Rt=0;const Es=[];let wt=null,es=0;const Hl=Promise.resolve();let Wn=null;function Vl(i){const e=Wn||Hl;return i?e.then(this?i.bind(this):i):e}function Vf(i){let e=Rt+1,t=We.length;for(;e<t;){const s=e+t>>>1;Qs(We[s])<i?e=s+1:t=s}return e}function Yn(i){(!We.length||!We.includes(i,Xs&&i.allowRecurse?Rt+1:Rt))&&(i.id==null?We.push(i):We.splice(Vf(i.id),0,i),Wl())}function Wl(){!Xs&&!on&&(on=!0,Wn=Hl.then(jl))}function Wf(i){const e=We.indexOf(i);e>Rt&&We.splice(e,1)}function Yf(i){le(i)?Es.push(...i):(!wt||!wt.includes(i,i.allowRecurse?es+1:es))&&Es.push(i),Wl()}function Oo(i,e=Xs?Rt+1:0){for(;e<We.length;e++){const t=We[e];t&&t.pre&&(We.splice(e,1),e--,t())}}function Yl(i){if(Es.length){const e=[...new Set(Es)];if(Es.length=0,wt){wt.push(...e);return}for(wt=e,wt.sort((t,s)=>Qs(t)-Qs(s)),es=0;es<wt.length;es++)wt[es]();wt=null,es=0}}const Qs=i=>i.id==null?1/0:i.id,jf=(i,e)=>{const t=Qs(i)-Qs(e);if(t===0){if(i.pre&&!e.pre)return-1;if(e.pre&&!i.pre)return 1}return t};function jl(i){on=!1,Xs=!0,We.sort(jf);const e=pt;try{for(Rt=0;Rt<We.length;Rt++){const t=We[Rt];t&&t.active!==!1&&qt(t,null,14)}}finally{Rt=0,We.length=0,Yl(),Xs=!1,Wn=null,(We.length||Es.length)&&jl()}}function qf(i,e,...t){if(i.isUnmounted)return;const s=i.vnode.props||Ie;let r=t;const n=e.startsWith("update:"),o=n&&e.slice(7);if(o&&o in s){const u=`${o==="modelValue"?"model":o}Modifiers`,{number:f,trim:h}=s[u]||Ie;h&&(r=t.map(d=>Ge(d)?d.trim():d)),f&&(r=t.map(tf))}let a,l=s[a=yr(e)]||s[a=yr(It(e))];!l&&n&&(l=s[a=yr(Ds(e))]),l&&yt(l,i,6,r);const c=s[a+"Once"];if(c){if(!i.emitted)i.emitted={};else if(i.emitted[a])return;i.emitted[a]=!0,yt(c,i,6,r)}}function ql(i,e,t=!1){const s=e.emitsCache,r=s.get(i);if(r!==void 0)return r;const n=i.emits;let o={},a=!1;if(!ce(i)){const l=c=>{const u=ql(c,e,!0);u&&(a=!0,Ue(o,u))};!t&&e.mixins.length&&e.mixins.forEach(l),i.extends&&l(i.extends),i.mixins&&i.mixins.forEach(l)}return!n&&!a?(Pe(i)&&s.set(i,null),null):(le(n)?n.forEach(l=>o[l]=null):Ue(o,n),Pe(i)&&s.set(i,o),o)}function sr(i,e){return!i||!qi(e)?!1:(e=e.slice(2).replace(/Once$/,""),ge(i,e[0].toLowerCase()+e.slice(1))||ge(i,Ds(e))||ge(i,e))}let nt=null,zl=null;function Mi(i){const e=nt;return nt=i,zl=i&&i.type.__scopeId||null,e}function zf(i,e=nt,t){if(!e||i._n)return i;const s=(...r)=>{s._d&&Wo(-1);const n=Mi(e);let o;try{o=i(...r)}finally{Mi(n),s._d&&Wo(1)}return o};return s._n=!0,s._c=!0,s._d=!0,s}function Er(i){const{type:e,vnode:t,proxy:s,withProxy:r,props:n,propsOptions:[o],slots:a,attrs:l,emit:c,render:u,renderCache:f,data:h,setupState:d,ctx:g,inheritAttrs:m}=i;let y,T;const x=Mi(i);try{if(t.shapeFlag&4){const R=r||s;y=vt(u.call(R,R,f,n,d,h,g)),T=l}else{const R=e;y=vt(R.length>1?R(n,{attrs:l,slots:a,emit:c}):R(n,null)),T=e.props?l:Xf(l)}}catch(R){Hs.length=0,tr(R,i,1),y=Je(as)}let v=y;if(T&&m!==!1){const R=Object.keys(T),{shapeFlag:b}=v;R.length&&b&7&&(o&&R.some(kn)&&(T=Qf(T,o)),v=As(v,T))}return t.dirs&&(v=As(v),v.dirs=v.dirs?v.dirs.concat(t.dirs):t.dirs),t.transition&&(v.transition=t.transition),y=v,Mi(x),y}const Xf=i=>{let e;for(const t in i)(t==="class"||t==="style"||qi(t))&&((e||(e={}))[t]=i[t]);return e},Qf=(i,e)=>{const t={};for(const s in i)(!kn(s)||!(s.slice(9)in e))&&(t[s]=i[s]);return t};function Jf(i,e,t){const{props:s,children:r,component:n}=i,{props:o,children:a,patchFlag:l}=e,c=n.emitsOptions;if(e.dirs||e.transition)return!0;if(t&&l>=0){if(l&1024)return!0;if(l&16)return s?Fo(s,o,c):!!o;if(l&8){const u=e.dynamicProps;for(let f=0;f<u.length;f++){const h=u[f];if(o[h]!==s[h]&&!sr(c,h))return!0}}}else return(r||a)&&(!a||!a.$stable)?!0:s===o?!1:s?o?Fo(s,o,c):!0:!!o;return!1}function Fo(i,e,t){const s=Object.keys(e);if(s.length!==Object.keys(i).length)return!0;for(let r=0;r<s.length;r++){const n=s[r];if(e[n]!==i[n]&&!sr(t,n))return!0}return!1}function Zf({vnode:i,parent:e},t){for(;e&&e.subTree===i;)(i=e.vnode).el=t,e=e.parent}const eh=i=>i.__isSuspense;function th(i,e){e&&e.pendingBranch?le(i)?e.effects.push(...i):e.effects.push(i):Yf(i)}const di={};function bi(i,e,t){return Xl(i,e,t)}function Xl(i,e,{immediate:t,deep:s,flush:r,onTrack:n,onTrigger:o}=Ie){var a;const l=ff()===((a=$e)==null?void 0:a.scope)?$e:null;let c,u=!1,f=!1;if(Ye(i)?(c=()=>i.value,u=Ni(i)):Ts(i)?(c=()=>i,s=!0):le(i)?(f=!0,u=i.some(R=>Ts(R)||Ni(R)),c=()=>i.map(R=>{if(Ye(R))return R.value;if(Ts(R))return ss(R);if(ce(R))return qt(R,l,2)})):ce(i)?e?c=()=>qt(i,l,2):c=()=>{if(!(l&&l.isUnmounted))return h&&h(),yt(i,l,3,[d])}:c=pt,e&&s){const R=c;c=()=>ss(R())}let h,d=R=>{h=x.onStop=()=>{qt(R,l,4)}},g;if(ei)if(d=pt,e?t&&yt(e,l,3,[c(),f?[]:void 0,d]):c(),r==="sync"){const R=Qh();g=R.__watcherHandles||(R.__watcherHandles=[])}else return pt;let m=f?new Array(i.length).fill(di):di;const y=()=>{if(x.active)if(e){const R=x.run();(s||u||(f?R.some((b,M)=>qs(b,m[M])):qs(R,m)))&&(h&&h(),yt(e,l,3,[R,m===di?void 0:f&&m[0]===di?[]:m,d]),m=R)}else x.run()};y.allowRecurse=!!e;let T;r==="sync"?T=y:r==="post"?T=()=>Xe(y,l&&l.suspense):(y.pre=!0,l&&(y.id=l.uid),T=()=>Yn(y));const x=new Bn(c,T);e?t?y():m=x.run():r==="post"?Xe(x.run.bind(x),l&&l.suspense):x.run();const v=()=>{x.stop(),l&&l.scope&&On(l.scope.effects,x)};return g&&g.push(v),v}function sh(i,e,t){const s=this.proxy,r=Ge(i)?i.includes(".")?Ql(s,i):()=>s[i]:i.bind(s,s);let n;ce(e)?n=e:(n=e.handler,t=e);const o=$e;Rs(this);const a=Xl(r,n.bind(s),t);return o?Rs(o):ns(),a}function Ql(i,e){const t=e.split(".");return()=>{let s=i;for(let r=0;r<t.length&&s;r++)s=s[t[r]];return s}}function ss(i,e){if(!Pe(i)||i.__v_skip||(e=e||new Set,e.has(i)))return i;if(e.add(i),Ye(i))ss(i.value,e);else if(le(i))for(let t=0;t<i.length;t++)ss(i[t],e);else if(zu(i)||Gs(i))i.forEach(t=>{ss(t,e)});else if(Ju(i))for(const t in i)ss(i[t],e);return i}function ih(i,e){const t=nt;if(t===null)return i;const s=or(t)||t.proxy,r=i.dirs||(i.dirs=[]);for(let n=0;n<e.length;n++){let[o,a,l,c=Ie]=e[n];o&&(ce(o)&&(o={mounted:o,updated:o}),o.deep&&ss(a),r.push({dir:o,instance:s,value:a,oldValue:void 0,arg:l,modifiers:c}))}return i}function Xt(i,e,t,s){const r=i.dirs,n=e&&e.dirs;for(let o=0;o<r.length;o++){const a=r[o];n&&(a.oldValue=n[o].value);let l=a.dir[s];l&&(_s(),yt(l,t,8,[i.el,a,i,e]),Cs())}}function Jl(i,e){return ce(i)?(()=>Ue({name:i.name},e,{setup:i}))():i}const Ii=i=>!!i.type.__asyncLoader,Zl=i=>i.type.__isKeepAlive;function rh(i,e){ec(i,"a",e)}function nh(i,e){ec(i,"da",e)}function ec(i,e,t=$e){const s=i.__wdc||(i.__wdc=()=>{let r=t;for(;r;){if(r.isDeactivated)return;r=r.parent}return i()});if(ir(e,s,t),t){let r=t.parent;for(;r&&r.parent;)Zl(r.parent.vnode)&&oh(s,e,t,r),r=r.parent}}function oh(i,e,t,s){const r=ir(e,i,s,!0);tc(()=>{On(s[e],r)},t)}function ir(i,e,t=$e,s=!1){if(t){const r=t[i]||(t[i]=[]),n=e.__weh||(e.__weh=(...o)=>{if(t.isUnmounted)return;_s(),Rs(t);const a=yt(e,t,i,o);return ns(),Cs(),a});return s?r.unshift(n):r.push(n),n}}const Ut=i=>(e,t=$e)=>(!ei||i==="sp")&&ir(i,(...s)=>e(...s),t),ah=Ut("bm"),jn=Ut("m"),lh=Ut("bu"),ch=Ut("u"),uh=Ut("bum"),tc=Ut("um"),fh=Ut("sp"),hh=Ut("rtg"),dh=Ut("rtc");function gh(i,e=$e){ir("ec",i,e)}const sc="components";function mh(i,e){return yh(sc,i,!0,e)||i}const ph=Symbol.for("v-ndc");function yh(i,e,t=!0,s=!1){const r=nt||$e;if(r){const n=r.type;if(i===sc){const a=qh(n,!1);if(a&&(a===e||a===It(e)||a===Qi(It(e))))return n}const o=No(r[i]||n[i],e)||No(r.appContext[i],e);return!o&&s?n:o}}function No(i,e){return i&&(i[e]||i[It(e)]||i[Qi(It(e))])}const an=i=>i?gc(i)?or(i)||i.proxy:an(i.parent):null,Ks=Ue(Object.create(null),{$:i=>i,$el:i=>i.vnode.el,$data:i=>i.data,$props:i=>i.props,$attrs:i=>i.attrs,$slots:i=>i.slots,$refs:i=>i.refs,$parent:i=>an(i.parent),$root:i=>an(i.root),$emit:i=>i.emit,$options:i=>qn(i),$forceUpdate:i=>i.f||(i.f=()=>Yn(i.update)),$nextTick:i=>i.n||(i.n=Vl.bind(i.proxy)),$watch:i=>sh.bind(i)}),xr=(i,e)=>i!==Ie&&!i.__isScriptSetup&&ge(i,e),Th={get({_:i},e){const{ctx:t,setupState:s,data:r,props:n,accessCache:o,type:a,appContext:l}=i;let c;if(e[0]!=="$"){const d=o[e];if(d!==void 0)switch(d){case 1:return s[e];case 2:return r[e];case 4:return t[e];case 3:return n[e]}else{if(xr(s,e))return o[e]=1,s[e];if(r!==Ie&&ge(r,e))return o[e]=2,r[e];if((c=i.propsOptions[0])&&ge(c,e))return o[e]=3,n[e];if(t!==Ie&&ge(t,e))return o[e]=4,t[e];ln&&(o[e]=0)}}const u=Ks[e];let f,h;if(u)return e==="$attrs"&&Ze(i,"get",e),u(i);if((f=a.__cssModules)&&(f=f[e]))return f;if(t!==Ie&&ge(t,e))return o[e]=4,t[e];if(h=l.config.globalProperties,ge(h,e))return h[e]},set({_:i},e,t){const{data:s,setupState:r,ctx:n}=i;return xr(r,e)?(r[e]=t,!0):s!==Ie&&ge(s,e)?(s[e]=t,!0):ge(i.props,e)||e[0]==="$"&&e.slice(1)in i?!1:(n[e]=t,!0)},has({_:{data:i,setupState:e,accessCache:t,ctx:s,appContext:r,propsOptions:n}},o){let a;return!!t[o]||i!==Ie&&ge(i,o)||xr(e,o)||(a=n[0])&&ge(a,o)||ge(s,o)||ge(Ks,o)||ge(r.config.globalProperties,o)},defineProperty(i,e,t){return t.get!=null?i._.accessCache[e]=0:ge(t,"value")&&this.set(i,e,t.value,null),Reflect.defineProperty(i,e,t)}};function Mo(i){return le(i)?i.reduce((e,t)=>(e[t]=null,e),{}):i}let ln=!0;function Eh(i){const e=qn(i),t=i.proxy,s=i.ctx;ln=!1,e.beforeCreate&&Uo(e.beforeCreate,i,"bc");const{data:r,computed:n,methods:o,watch:a,provide:l,inject:c,created:u,beforeMount:f,mounted:h,beforeUpdate:d,updated:g,activated:m,deactivated:y,beforeDestroy:T,beforeUnmount:x,destroyed:v,unmounted:R,render:b,renderTracked:M,renderTriggered:P,errorCaptured:B,serverPrefetch:K,expose:_,inheritAttrs:q,components:W,directives:ue,filters:we}=e;if(c&&xh(c,s,null),o)for(const te in o){const $=o[te];ce($)&&(s[te]=$.bind(t))}if(r){const te=r.call(t,t);Pe(te)&&(i.data=er(te))}if(ln=!0,n)for(const te in n){const $=n[te],z=ce($)?$.bind(t,t):ce($.get)?$.get.bind(t,t):pt,fe=!ce($)&&ce($.set)?$.set.bind(t):pt,he=ht({get:z,set:fe});Object.defineProperty(s,te,{enumerable:!0,configurable:!0,get:()=>he.value,set:ne=>he.value=ne})}if(a)for(const te in a)ic(a[te],s,t,te);if(l){const te=ce(l)?l.call(t):l;Reflect.ownKeys(te).forEach($=>{Di($,te[$])})}u&&Uo(u,i,"c");function ae(te,$){le($)?$.forEach(z=>te(z.bind(t))):$&&te($.bind(t))}if(ae(ah,f),ae(jn,h),ae(lh,d),ae(ch,g),ae(rh,m),ae(nh,y),ae(gh,B),ae(dh,M),ae(hh,P),ae(uh,x),ae(tc,R),ae(fh,K),le(_))if(_.length){const te=i.exposed||(i.exposed={});_.forEach($=>{Object.defineProperty(te,$,{get:()=>t[$],set:z=>t[$]=z})})}else i.exposed||(i.exposed={});b&&i.render===pt&&(i.render=b),q!=null&&(i.inheritAttrs=q),W&&(i.components=W),ue&&(i.directives=ue)}function xh(i,e,t=pt){le(i)&&(i=cn(i));for(const s in i){const r=i[s];let n;Pe(r)?"default"in r?n=Lt(r.from||s,r.default,!0):n=Lt(r.from||s):n=Lt(r),Ye(n)?Object.defineProperty(e,s,{enumerable:!0,configurable:!0,get:()=>n.value,set:o=>n.value=o}):e[s]=n}}function Uo(i,e,t){yt(le(i)?i.map(s=>s.bind(e.proxy)):i.bind(e.proxy),e,t)}function ic(i,e,t,s){const r=s.includes(".")?Ql(t,s):()=>t[s];if(Ge(i)){const n=e[i];ce(n)&&bi(r,n)}else if(ce(i))bi(r,i.bind(t));else if(Pe(i))if(le(i))i.forEach(n=>ic(n,e,t,s));else{const n=ce(i.handler)?i.handler.bind(t):e[i.handler];ce(n)&&bi(r,n,i)}}function qn(i){const e=i.type,{mixins:t,extends:s}=e,{mixins:r,optionsCache:n,config:{optionMergeStrategies:o}}=i.appContext,a=n.get(e);let l;return a?l=a:!r.length&&!t&&!s?l=e:(l={},r.length&&r.forEach(c=>Ui(l,c,o,!0)),Ui(l,e,o)),Pe(e)&&n.set(e,l),l}function Ui(i,e,t,s=!1){const{mixins:r,extends:n}=e;n&&Ui(i,n,t,!0),r&&r.forEach(o=>Ui(i,o,t,!0));for(const o in e)if(!(s&&o==="expose")){const a=Sh[o]||t&&t[o];i[o]=a?a(i[o],e[o]):e[o]}return i}const Sh={data:Bo,props:$o,emits:$o,methods:$s,computed:$s,beforeCreate:je,created:je,beforeMount:je,mounted:je,beforeUpdate:je,updated:je,beforeDestroy:je,beforeUnmount:je,destroyed:je,unmounted:je,activated:je,deactivated:je,errorCaptured:je,serverPrefetch:je,components:$s,directives:$s,watch:Ah,provide:Bo,inject:vh};function Bo(i,e){return e?i?function(){return Ue(ce(i)?i.call(this,this):i,ce(e)?e.call(this,this):e)}:e:i}function vh(i,e){return $s(cn(i),cn(e))}function cn(i){if(le(i)){const e={};for(let t=0;t<i.length;t++)e[i[t]]=i[t];return e}return i}function je(i,e){return i?[...new Set([].concat(i,e))]:e}function $s(i,e){return i?Ue(Object.create(null),i,e):e}function $o(i,e){return i?le(i)&&le(e)?[...new Set([...i,...e])]:Ue(Object.create(null),Mo(i),Mo(e??{})):e}function Ah(i,e){if(!i)return e;if(!e)return i;const t=Ue(Object.create(null),i);for(const s in e)t[s]=je(i[s],e[s]);return t}function rc(){return{app:null,config:{isNativeTag:Yu,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}let Rh=0;function Lh(i,e){return function(s,r=null){ce(s)||(s=Ue({},s)),r!=null&&!Pe(r)&&(r=null);const n=rc(),o=new Set;let a=!1;const l=n.app={_uid:Rh++,_component:s,_props:r,_container:null,_context:n,_instance:null,version:Jh,get config(){return n.config},set config(c){},use(c,...u){return o.has(c)||(c&&ce(c.install)?(o.add(c),c.install(l,...u)):ce(c)&&(o.add(c),c(l,...u))),l},mixin(c){return n.mixins.includes(c)||n.mixins.push(c),l},component(c,u){return u?(n.components[c]=u,l):n.components[c]},directive(c,u){return u?(n.directives[c]=u,l):n.directives[c]},mount(c,u,f){if(!a){const h=Je(s,r);return h.appContext=n,u&&e?e(h,c):i(h,c,f),a=!0,l._container=c,c.__vue_app__=l,or(h.component)||h.component.proxy}},unmount(){a&&(i(null,l._container),delete l._container.__vue_app__)},provide(c,u){return n.provides[c]=u,l},runWithContext(c){Bi=l;try{return c()}finally{Bi=null}}};return l}}let Bi=null;function Di(i,e){if($e){let t=$e.provides;const s=$e.parent&&$e.parent.provides;s===t&&(t=$e.provides=Object.create(s)),t[i]=e}}function Lt(i,e,t=!1){const s=$e||nt;if(s||Bi){const r=s?s.parent==null?s.vnode.appContext&&s.vnode.appContext.provides:s.parent.provides:Bi._context.provides;if(r&&i in r)return r[i];if(arguments.length>1)return t&&ce(e)?e.call(s&&s.proxy):e}}function bh(i,e,t,s=!1){const r={},n={};Fi(n,nr,1),i.propsDefaults=Object.create(null),nc(i,e,r,n);for(const o in i.propsOptions[0])o in r||(r[o]=void 0);t?i.props=s?r:Fl(r):i.type.props?i.props=r:i.props=n,i.attrs=n}function Ih(i,e,t,s){const{props:r,attrs:n,vnode:{patchFlag:o}}=i,a=Ee(r),[l]=i.propsOptions;let c=!1;if((s||o>0)&&!(o&16)){if(o&8){const u=i.vnode.dynamicProps;for(let f=0;f<u.length;f++){let h=u[f];if(sr(i.emitsOptions,h))continue;const d=e[h];if(l)if(ge(n,h))d!==n[h]&&(n[h]=d,c=!0);else{const g=It(h);r[g]=un(l,a,g,d,i,!1)}else d!==n[h]&&(n[h]=d,c=!0)}}}else{nc(i,e,r,n)&&(c=!0);let u;for(const f in a)(!e||!ge(e,f)&&((u=Ds(f))===f||!ge(e,u)))&&(l?t&&(t[f]!==void 0||t[u]!==void 0)&&(r[f]=un(l,a,f,void 0,i,!0)):delete r[f]);if(n!==a)for(const f in n)(!e||!ge(e,f))&&(delete n[f],c=!0)}c&&Mt(i,"set","$attrs")}function nc(i,e,t,s){const[r,n]=i.propsOptions;let o=!1,a;if(e)for(let l in e){if(Ri(l))continue;const c=e[l];let u;r&&ge(r,u=It(l))?!n||!n.includes(u)?t[u]=c:(a||(a={}))[u]=c:sr(i.emitsOptions,l)||(!(l in s)||c!==s[l])&&(s[l]=c,o=!0)}if(n){const l=Ee(t),c=a||Ie;for(let u=0;u<n.length;u++){const f=n[u];t[f]=un(r,l,f,c[f],i,!ge(c,f))}}return o}function un(i,e,t,s,r,n){const o=i[t];if(o!=null){const a=ge(o,"default");if(a&&s===void 0){const l=o.default;if(o.type!==Function&&!o.skipFactory&&ce(l)){const{propsDefaults:c}=r;t in c?s=c[t]:(Rs(r),s=c[t]=l.call(null,e),ns())}else s=l}o[0]&&(n&&!a?s=!1:o[1]&&(s===""||s===Ds(t))&&(s=!0))}return s}function oc(i,e,t=!1){const s=e.propsCache,r=s.get(i);if(r)return r;const n=i.props,o={},a=[];let l=!1;if(!ce(i)){const u=f=>{l=!0;const[h,d]=oc(f,e,!0);Ue(o,h),d&&a.push(...d)};!t&&e.mixins.length&&e.mixins.forEach(u),i.extends&&u(i.extends),i.mixins&&i.mixins.forEach(u)}if(!n&&!l)return Pe(i)&&s.set(i,ys),ys;if(le(n))for(let u=0;u<n.length;u++){const f=It(n[u]);Go(f)&&(o[f]=Ie)}else if(n)for(const u in n){const f=It(u);if(Go(f)){const h=n[u],d=o[f]=le(h)||ce(h)?{type:h}:Ue({},h);if(d){const g=Vo(Boolean,d.type),m=Vo(String,d.type);d[0]=g>-1,d[1]=m<0||g<m,(g>-1||ge(d,"default"))&&a.push(f)}}}const c=[o,a];return Pe(i)&&s.set(i,c),c}function Go(i){return i[0]!=="$"}function Ko(i){const e=i&&i.toString().match(/^\s*(function|class) (\w+)/);return e?e[2]:i===null?"null":""}function Ho(i,e){return Ko(i)===Ko(e)}function Vo(i,e){return le(e)?e.findIndex(t=>Ho(t,i)):ce(e)&&Ho(e,i)?0:-1}const ac=i=>i[0]==="_"||i==="$stable",zn=i=>le(i)?i.map(vt):[vt(i)],Dh=(i,e,t)=>{if(e._n)return e;const s=zf((...r)=>zn(e(...r)),t);return s._c=!1,s},lc=(i,e,t)=>{const s=i._ctx;for(const r in i){if(ac(r))continue;const n=i[r];if(ce(n))e[r]=Dh(r,n,s);else if(n!=null){const o=zn(n);e[r]=()=>o}}},cc=(i,e)=>{const t=zn(e);i.slots.default=()=>t},_h=(i,e)=>{if(i.vnode.shapeFlag&32){const t=e._;t?(i.slots=Ee(e),Fi(e,"_",t)):lc(e,i.slots={})}else i.slots={},e&&cc(i,e);Fi(i.slots,nr,1)},Ch=(i,e,t)=>{const{vnode:s,slots:r}=i;let n=!0,o=Ie;if(s.shapeFlag&32){const a=e._;a?t&&a===1?n=!1:(Ue(r,e),!t&&a===1&&delete r._):(n=!e.$stable,lc(e,r)),o=e}else e&&(cc(i,e),o={default:1});if(n)for(const a in r)!ac(a)&&!(a in o)&&delete r[a]};function fn(i,e,t,s,r=!1){if(le(i)){i.forEach((h,d)=>fn(h,e&&(le(e)?e[d]:e),t,s,r));return}if(Ii(s)&&!r)return;const n=s.shapeFlag&4?or(s.component)||s.component.proxy:s.el,o=r?null:n,{i:a,r:l}=i,c=e&&e.r,u=a.refs===Ie?a.refs={}:a.refs,f=a.setupState;if(c!=null&&c!==l&&(Ge(c)?(u[c]=null,ge(f,c)&&(f[c]=null)):Ye(c)&&(c.value=null)),ce(l))qt(l,a,12,[o,u]);else{const h=Ge(l),d=Ye(l);if(h||d){const g=()=>{if(i.f){const m=h?ge(f,l)?f[l]:u[l]:l.value;r?le(m)&&On(m,n):le(m)?m.includes(n)||m.push(n):h?(u[l]=[n],ge(f,l)&&(f[l]=u[l])):(l.value=[n],i.k&&(u[i.k]=l.value))}else h?(u[l]=o,ge(f,l)&&(f[l]=o)):d&&(l.value=o,i.k&&(u[i.k]=o))};o?(g.id=-1,Xe(g,t)):g()}}}const Xe=th;function wh(i){return Ph(i)}function Ph(i,e){const t=en();t.__VUE__=!0;const{insert:s,remove:r,patchProp:n,createElement:o,createText:a,createComment:l,setText:c,setElementText:u,parentNode:f,nextSibling:h,setScopeId:d=pt,insertStaticContent:g}=i,m=(E,S,L,C=null,O=null,N=null,Y=!1,G=null,H=!!S.dynamicChildren)=>{if(E===S)return;E&&!ks(E,S)&&(C=w(E),ne(E,O,N,!0),E=null),S.patchFlag===-2&&(H=!1,S.dynamicChildren=null);const{type:U,ref:Z,shapeFlag:X}=S;switch(U){case rr:y(E,S,L,C);break;case as:T(E,S,L,C);break;case Sr:E==null&&x(S,L,C,Y);break;case Ot:W(E,S,L,C,O,N,Y,G,H);break;default:X&1?b(E,S,L,C,O,N,Y,G,H):X&6?ue(E,S,L,C,O,N,Y,G,H):(X&64||X&128)&&U.process(E,S,L,C,O,N,Y,G,H,V)}Z!=null&&O&&fn(Z,E&&E.ref,N,S||E,!S)},y=(E,S,L,C)=>{if(E==null)s(S.el=a(S.children),L,C);else{const O=S.el=E.el;S.children!==E.children&&c(O,S.children)}},T=(E,S,L,C)=>{E==null?s(S.el=l(S.children||""),L,C):S.el=E.el},x=(E,S,L,C)=>{[E.el,E.anchor]=g(E.children,S,L,C,E.el,E.anchor)},v=({el:E,anchor:S},L,C)=>{let O;for(;E&&E!==S;)O=h(E),s(E,L,C),E=O;s(S,L,C)},R=({el:E,anchor:S})=>{let L;for(;E&&E!==S;)L=h(E),r(E),E=L;r(S)},b=(E,S,L,C,O,N,Y,G,H)=>{Y=Y||S.type==="svg",E==null?M(S,L,C,O,N,Y,G,H):K(E,S,O,N,Y,G,H)},M=(E,S,L,C,O,N,Y,G)=>{let H,U;const{type:Z,props:X,shapeFlag:ee,transition:oe,dirs:de}=E;if(H=E.el=o(E.type,N,X&&X.is,X),ee&8?u(H,E.children):ee&16&&B(E.children,H,null,C,O,N&&Z!=="foreignObject",Y,G),de&&Xt(E,null,C,"created"),P(H,E,E.scopeId,Y,C),X){for(const Ae in X)Ae!=="value"&&!Ri(Ae)&&n(H,Ae,null,X[Ae],N,E.children,C,O,Se);"value"in X&&n(H,"value",null,X.value),(U=X.onVnodeBeforeMount)&&xt(U,C,E)}de&&Xt(E,null,C,"beforeMount");const be=(!O||O&&!O.pendingBranch)&&oe&&!oe.persisted;be&&oe.beforeEnter(H),s(H,S,L),((U=X&&X.onVnodeMounted)||be||de)&&Xe(()=>{U&&xt(U,C,E),be&&oe.enter(H),de&&Xt(E,null,C,"mounted")},O)},P=(E,S,L,C,O)=>{if(L&&d(E,L),C)for(let N=0;N<C.length;N++)d(E,C[N]);if(O){let N=O.subTree;if(S===N){const Y=O.vnode;P(E,Y,Y.scopeId,Y.slotScopeIds,O.parent)}}},B=(E,S,L,C,O,N,Y,G,H=0)=>{for(let U=H;U<E.length;U++){const Z=E[U]=G?Ht(E[U]):vt(E[U]);m(null,Z,S,L,C,O,N,Y,G)}},K=(E,S,L,C,O,N,Y)=>{const G=S.el=E.el;let{patchFlag:H,dynamicChildren:U,dirs:Z}=S;H|=E.patchFlag&16;const X=E.props||Ie,ee=S.props||Ie;let oe;L&&Qt(L,!1),(oe=ee.onVnodeBeforeUpdate)&&xt(oe,L,S,E),Z&&Xt(S,E,L,"beforeUpdate"),L&&Qt(L,!0);const de=O&&S.type!=="foreignObject";if(U?_(E.dynamicChildren,U,G,L,C,de,N):Y||$(E,S,G,null,L,C,de,N,!1),H>0){if(H&16)q(G,S,X,ee,L,C,O);else if(H&2&&X.class!==ee.class&&n(G,"class",null,ee.class,O),H&4&&n(G,"style",X.style,ee.style,O),H&8){const be=S.dynamicProps;for(let Ae=0;Ae<be.length;Ae++){const ke=be[Ae],at=X[ke],cs=ee[ke];(cs!==at||ke==="value")&&n(G,ke,at,cs,O,E.children,L,C,Se)}}H&1&&E.children!==S.children&&u(G,S.children)}else!Y&&U==null&&q(G,S,X,ee,L,C,O);((oe=ee.onVnodeUpdated)||Z)&&Xe(()=>{oe&&xt(oe,L,S,E),Z&&Xt(S,E,L,"updated")},C)},_=(E,S,L,C,O,N,Y)=>{for(let G=0;G<S.length;G++){const H=E[G],U=S[G],Z=H.el&&(H.type===Ot||!ks(H,U)||H.shapeFlag&70)?f(H.el):L;m(H,U,Z,null,C,O,N,Y,!0)}},q=(E,S,L,C,O,N,Y)=>{if(L!==C){if(L!==Ie)for(const G in L)!Ri(G)&&!(G in C)&&n(E,G,L[G],null,Y,S.children,O,N,Se);for(const G in C){if(Ri(G))continue;const H=C[G],U=L[G];H!==U&&G!=="value"&&n(E,G,U,H,Y,S.children,O,N,Se)}"value"in C&&n(E,"value",L.value,C.value)}},W=(E,S,L,C,O,N,Y,G,H)=>{const U=S.el=E?E.el:a(""),Z=S.anchor=E?E.anchor:a("");let{patchFlag:X,dynamicChildren:ee,slotScopeIds:oe}=S;oe&&(G=G?G.concat(oe):oe),E==null?(s(U,L,C),s(Z,L,C),B(S.children,L,Z,O,N,Y,G,H)):X>0&&X&64&&ee&&E.dynamicChildren?(_(E.dynamicChildren,ee,L,O,N,Y,G),(S.key!=null||O&&S===O.subTree)&&uc(E,S,!0)):$(E,S,L,Z,O,N,Y,G,H)},ue=(E,S,L,C,O,N,Y,G,H)=>{S.slotScopeIds=G,E==null?S.shapeFlag&512?O.ctx.activate(S,L,C,Y,H):we(S,L,C,O,N,Y,H):Te(E,S,H)},we=(E,S,L,C,O,N,Y)=>{const G=E.component=Hh(E,C,O);if(Zl(E)&&(G.ctx.renderer=V),Vh(G),G.asyncDep){if(O&&O.registerDep(G,ae),!E.el){const H=G.subTree=Je(as);T(null,H,S,L)}return}ae(G,E,S,L,O,N,Y)},Te=(E,S,L)=>{const C=S.component=E.component;if(Jf(E,S,L))if(C.asyncDep&&!C.asyncResolved){te(C,S,L);return}else C.next=S,Wf(C.update),C.update();else S.el=E.el,C.vnode=S},ae=(E,S,L,C,O,N,Y)=>{const G=()=>{if(E.isMounted){let{next:Z,bu:X,u:ee,parent:oe,vnode:de}=E,be=Z,Ae;Qt(E,!1),Z?(Z.el=de.el,te(E,Z,Y)):Z=de,X&&Tr(X),(Ae=Z.props&&Z.props.onVnodeBeforeUpdate)&&xt(Ae,oe,Z,de),Qt(E,!0);const ke=Er(E),at=E.subTree;E.subTree=ke,m(at,ke,f(at.el),w(at),E,O,N),Z.el=ke.el,be===null&&Zf(E,ke.el),ee&&Xe(ee,O),(Ae=Z.props&&Z.props.onVnodeUpdated)&&Xe(()=>xt(Ae,oe,Z,de),O)}else{let Z;const{el:X,props:ee}=S,{bm:oe,m:de,parent:be}=E,Ae=Ii(S);if(Qt(E,!1),oe&&Tr(oe),!Ae&&(Z=ee&&ee.onVnodeBeforeMount)&&xt(Z,be,S),Qt(E,!0),X&&xe){const ke=()=>{E.subTree=Er(E),xe(X,E.subTree,E,O,null)};Ae?S.type.__asyncLoader().then(()=>!E.isUnmounted&&ke()):ke()}else{const ke=E.subTree=Er(E);m(null,ke,L,C,E,O,N),S.el=ke.el}if(de&&Xe(de,O),!Ae&&(Z=ee&&ee.onVnodeMounted)){const ke=S;Xe(()=>xt(Z,be,ke),O)}(S.shapeFlag&256||be&&Ii(be.vnode)&&be.vnode.shapeFlag&256)&&E.a&&Xe(E.a,O),E.isMounted=!0,S=L=C=null}},H=E.effect=new Bn(G,()=>Yn(U),E.scope),U=E.update=()=>H.run();U.id=E.uid,Qt(E,!0),U()},te=(E,S,L)=>{S.component=E;const C=E.vnode.props;E.vnode=S,E.next=null,Ih(E,S.props,C,L),Ch(E,S.children,L),_s(),Oo(),Cs()},$=(E,S,L,C,O,N,Y,G,H=!1)=>{const U=E&&E.children,Z=E?E.shapeFlag:0,X=S.children,{patchFlag:ee,shapeFlag:oe}=S;if(ee>0){if(ee&128){fe(U,X,L,C,O,N,Y,G,H);return}else if(ee&256){z(U,X,L,C,O,N,Y,G,H);return}}oe&8?(Z&16&&Se(U,O,N),X!==U&&u(L,X)):Z&16?oe&16?fe(U,X,L,C,O,N,Y,G,H):Se(U,O,N,!0):(Z&8&&u(L,""),oe&16&&B(X,L,C,O,N,Y,G,H))},z=(E,S,L,C,O,N,Y,G,H)=>{E=E||ys,S=S||ys;const U=E.length,Z=S.length,X=Math.min(U,Z);let ee;for(ee=0;ee<X;ee++){const oe=S[ee]=H?Ht(S[ee]):vt(S[ee]);m(E[ee],oe,L,null,O,N,Y,G,H)}U>Z?Se(E,O,N,!0,!1,X):B(S,L,C,O,N,Y,G,H,X)},fe=(E,S,L,C,O,N,Y,G,H)=>{let U=0;const Z=S.length;let X=E.length-1,ee=Z-1;for(;U<=X&&U<=ee;){const oe=E[U],de=S[U]=H?Ht(S[U]):vt(S[U]);if(ks(oe,de))m(oe,de,L,null,O,N,Y,G,H);else break;U++}for(;U<=X&&U<=ee;){const oe=E[X],de=S[ee]=H?Ht(S[ee]):vt(S[ee]);if(ks(oe,de))m(oe,de,L,null,O,N,Y,G,H);else break;X--,ee--}if(U>X){if(U<=ee){const oe=ee+1,de=oe<Z?S[oe].el:C;for(;U<=ee;)m(null,S[U]=H?Ht(S[U]):vt(S[U]),L,de,O,N,Y,G,H),U++}}else if(U>ee)for(;U<=X;)ne(E[U],O,N,!0),U++;else{const oe=U,de=U,be=new Map;for(U=de;U<=ee;U++){const tt=S[U]=H?Ht(S[U]):vt(S[U]);tt.key!=null&&be.set(tt.key,U)}let Ae,ke=0;const at=ee-de+1;let cs=!1,Ao=0;const Ps=new Array(at);for(U=0;U<at;U++)Ps[U]=0;for(U=oe;U<=X;U++){const tt=E[U];if(ke>=at){ne(tt,O,N,!0);continue}let Et;if(tt.key!=null)Et=be.get(tt.key);else for(Ae=de;Ae<=ee;Ae++)if(Ps[Ae-de]===0&&ks(tt,S[Ae])){Et=Ae;break}Et===void 0?ne(tt,O,N,!0):(Ps[Et-de]=U+1,Et>=Ao?Ao=Et:cs=!0,m(tt,S[Et],L,null,O,N,Y,G,H),ke++)}const Ro=cs?kh(Ps):ys;for(Ae=Ro.length-1,U=at-1;U>=0;U--){const tt=de+U,Et=S[tt],Lo=tt+1<Z?S[tt+1].el:C;Ps[U]===0?m(null,Et,L,Lo,O,N,Y,G,H):cs&&(Ae<0||U!==Ro[Ae]?he(Et,L,Lo,2):Ae--)}}},he=(E,S,L,C,O=null)=>{const{el:N,type:Y,transition:G,children:H,shapeFlag:U}=E;if(U&6){he(E.component.subTree,S,L,C);return}if(U&128){E.suspense.move(S,L,C);return}if(U&64){Y.move(E,S,L,V);return}if(Y===Ot){s(N,S,L);for(let X=0;X<H.length;X++)he(H[X],S,L,C);s(E.anchor,S,L);return}if(Y===Sr){v(E,S,L);return}if(C!==2&&U&1&&G)if(C===0)G.beforeEnter(N),s(N,S,L),Xe(()=>G.enter(N),O);else{const{leave:X,delayLeave:ee,afterLeave:oe}=G,de=()=>s(N,S,L),be=()=>{X(N,()=>{de(),oe&&oe()})};ee?ee(N,de,be):be()}else s(N,S,L)},ne=(E,S,L,C=!1,O=!1)=>{const{type:N,props:Y,ref:G,children:H,dynamicChildren:U,shapeFlag:Z,patchFlag:X,dirs:ee}=E;if(G!=null&&fn(G,null,L,E,!0),Z&256){S.ctx.deactivate(E);return}const oe=Z&1&&ee,de=!Ii(E);let be;if(de&&(be=Y&&Y.onVnodeBeforeUnmount)&&xt(be,S,E),Z&6)Ke(E.component,L,C);else{if(Z&128){E.suspense.unmount(L,C);return}oe&&Xt(E,null,S,"beforeUnmount"),Z&64?E.type.remove(E,S,L,O,V,C):U&&(N!==Ot||X>0&&X&64)?Se(U,S,L,!1,!0):(N===Ot&&X&384||!O&&Z&16)&&Se(H,S,L),C&&Le(E)}(de&&(be=Y&&Y.onVnodeUnmounted)||oe)&&Xe(()=>{be&&xt(be,S,E),oe&&Xt(E,null,S,"unmounted")},L)},Le=E=>{const{type:S,el:L,anchor:C,transition:O}=E;if(S===Ot){Fe(L,C);return}if(S===Sr){R(E);return}const N=()=>{r(L),O&&!O.persisted&&O.afterLeave&&O.afterLeave()};if(E.shapeFlag&1&&O&&!O.persisted){const{leave:Y,delayLeave:G}=O,H=()=>Y(L,N);G?G(E.el,N,H):H()}else N()},Fe=(E,S)=>{let L;for(;E!==S;)L=h(E),r(E),E=L;r(S)},Ke=(E,S,L)=>{const{bum:C,scope:O,update:N,subTree:Y,um:G}=E;C&&Tr(C),O.stop(),N&&(N.active=!1,ne(Y,E,S,L)),G&&Xe(G,S),Xe(()=>{E.isUnmounted=!0},S),S&&S.pendingBranch&&!S.isUnmounted&&E.asyncDep&&!E.asyncResolved&&E.suspenseId===S.pendingId&&(S.deps--,S.deps===0&&S.resolve())},Se=(E,S,L,C=!1,O=!1,N=0)=>{for(let Y=N;Y<E.length;Y++)ne(E[Y],S,L,C,O)},w=E=>E.shapeFlag&6?w(E.component.subTree):E.shapeFlag&128?E.suspense.next():h(E.anchor||E.el),j=(E,S,L)=>{E==null?S._vnode&&ne(S._vnode,null,null,!0):m(S._vnode||null,E,S,null,null,null,L),Oo(),Yl(),S._vnode=E},V={p:m,um:ne,m:he,r:Le,mt:we,mc:B,pc:$,pbc:_,n:w,o:i};let Q,xe;return e&&([Q,xe]=e(V)),{render:j,hydrate:Q,createApp:Lh(j,Q)}}function Qt({effect:i,update:e},t){i.allowRecurse=e.allowRecurse=t}function uc(i,e,t=!1){const s=i.children,r=e.children;if(le(s)&&le(r))for(let n=0;n<s.length;n++){const o=s[n];let a=r[n];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=r[n]=Ht(r[n]),a.el=o.el),t||uc(o,a)),a.type===rr&&(a.el=o.el)}}function kh(i){const e=i.slice(),t=[0];let s,r,n,o,a;const l=i.length;for(s=0;s<l;s++){const c=i[s];if(c!==0){if(r=t[t.length-1],i[r]<c){e[s]=r,t.push(s);continue}for(n=0,o=t.length-1;n<o;)a=n+o>>1,i[t[a]]<c?n=a+1:o=a;c<i[t[n]]&&(n>0&&(e[s]=t[n-1]),t[n]=s)}}for(n=t.length,o=t[n-1];n-- >0;)t[n]=o,o=e[o];return t}const Oh=i=>i.__isTeleport,Ot=Symbol.for("v-fgt"),rr=Symbol.for("v-txt"),as=Symbol.for("v-cmt"),Sr=Symbol.for("v-stc"),Hs=[];let gt=null;function Js(i=!1){Hs.push(gt=i?null:[])}function Fh(){Hs.pop(),gt=Hs[Hs.length-1]||null}let Zs=1;function Wo(i){Zs+=i}function fc(i){return i.dynamicChildren=Zs>0?gt||ys:null,Fh(),Zs>0&&gt&&gt.push(i),i}function hn(i,e,t,s,r,n){return fc(xs(i,e,t,s,r,n,!0))}function hc(i,e,t,s,r){return fc(Je(i,e,t,s,r,!0))}function dn(i){return i?i.__v_isVNode===!0:!1}function ks(i,e){return i.type===e.type&&i.key===e.key}const nr="__vInternal",dc=({key:i})=>i??null,_i=({ref:i,ref_key:e,ref_for:t})=>(typeof i=="number"&&(i=""+i),i!=null?Ge(i)||Ye(i)||ce(i)?{i:nt,r:i,k:e,f:!!t}:i:null);function xs(i,e=null,t=null,s=0,r=null,n=i===Ot?0:1,o=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:i,props:e,key:e&&dc(e),ref:e&&_i(e),scopeId:zl,slotScopeIds:null,children:t,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetAnchor:null,staticCount:0,shapeFlag:n,patchFlag:s,dynamicProps:r,dynamicChildren:null,appContext:null,ctx:nt};return a?(Xn(l,t),n&128&&i.normalize(l)):t&&(l.shapeFlag|=Ge(t)?8:16),Zs>0&&!o&&gt&&(l.patchFlag>0||n&6)&&l.patchFlag!==32&&gt.push(l),l}const Je=Nh;function Nh(i,e=null,t=null,s=0,r=null,n=!1){if((!i||i===ph)&&(i=as),dn(i)){const a=As(i,e,!0);return t&&Xn(a,t),Zs>0&&!n&&gt&&(a.shapeFlag&6?gt[gt.indexOf(i)]=a:gt.push(a)),a.patchFlag|=-2,a}if(zh(i)&&(i=i.__vccOpts),e){e=Mh(e);let{class:a,style:l}=e;a&&!Ge(a)&&(e.class=Ji(a)),Pe(l)&&(Ml(l)&&!le(l)&&(l=Ue({},l)),e.style=Mn(l))}const o=Ge(i)?1:eh(i)?128:Oh(i)?64:Pe(i)?4:ce(i)?2:0;return xs(i,e,t,s,r,o,n,!0)}function Mh(i){return i?Ml(i)||nr in i?Ue({},i):i:null}function As(i,e,t=!1){const{props:s,ref:r,patchFlag:n,children:o}=i,a=e?$h(s||{},e):s;return{__v_isVNode:!0,__v_skip:!0,type:i.type,props:a,key:a&&dc(a),ref:e&&e.ref?t&&r?le(r)?r.concat(_i(e)):[r,_i(e)]:_i(e):r,scopeId:i.scopeId,slotScopeIds:i.slotScopeIds,children:o,target:i.target,targetAnchor:i.targetAnchor,staticCount:i.staticCount,shapeFlag:i.shapeFlag,patchFlag:e&&i.type!==Ot?n===-1?16:n|16:n,dynamicProps:i.dynamicProps,dynamicChildren:i.dynamicChildren,appContext:i.appContext,dirs:i.dirs,transition:i.transition,component:i.component,suspense:i.suspense,ssContent:i.ssContent&&As(i.ssContent),ssFallback:i.ssFallback&&As(i.ssFallback),el:i.el,anchor:i.anchor,ctx:i.ctx,ce:i.ce}}function Uh(i=" ",e=0){return Je(rr,null,i,e)}function Bh(i="",e=!1){return e?(Js(),hc(as,null,i)):Je(as,null,i)}function vt(i){return i==null||typeof i=="boolean"?Je(as):le(i)?Je(Ot,null,i.slice()):typeof i=="object"?Ht(i):Je(rr,null,String(i))}function Ht(i){return i.el===null&&i.patchFlag!==-1||i.memo?i:As(i)}function Xn(i,e){let t=0;const{shapeFlag:s}=i;if(e==null)e=null;else if(le(e))t=16;else if(typeof e=="object")if(s&65){const r=e.default;r&&(r._c&&(r._d=!1),Xn(i,r()),r._c&&(r._d=!0));return}else{t=32;const r=e._;!r&&!(nr in e)?e._ctx=nt:r===3&&nt&&(nt.slots._===1?e._=1:(e._=2,i.patchFlag|=1024))}else ce(e)?(e={default:e,_ctx:nt},t=32):(e=String(e),s&64?(t=16,e=[Uh(e)]):t=8);i.children=e,i.shapeFlag|=t}function $h(...i){const e={};for(let t=0;t<i.length;t++){const s=i[t];for(const r in s)if(r==="class")e.class!==s.class&&(e.class=Ji([e.class,s.class]));else if(r==="style")e.style=Mn([e.style,s.style]);else if(qi(r)){const n=e[r],o=s[r];o&&n!==o&&!(le(n)&&n.includes(o))&&(e[r]=n?[].concat(n,o):o)}else r!==""&&(e[r]=s[r])}return e}function xt(i,e,t,s=null){yt(i,e,7,[t,s])}const Gh=rc();let Kh=0;function Hh(i,e,t){const s=i.type,r=(e?e.appContext:i.appContext)||Gh,n={uid:Kh++,vnode:i,type:s,parent:e,appContext:r,root:null,next:null,subTree:null,effect:null,update:null,scope:new cf(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:e?e.provides:Object.create(r.provides),accessCache:null,renderCache:[],components:null,directives:null,propsOptions:oc(s,r),emitsOptions:ql(s,r),emit:null,emitted:null,propsDefaults:Ie,inheritAttrs:s.inheritAttrs,ctx:Ie,data:Ie,props:Ie,attrs:Ie,slots:Ie,refs:Ie,setupState:Ie,setupContext:null,attrsProxy:null,slotsProxy:null,suspense:t,suspenseId:t?t.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return n.ctx={_:n},n.root=e?e.root:n,n.emit=qf.bind(null,n),i.ce&&i.ce(n),n}let $e=null,Qn,us,Yo="__VUE_INSTANCE_SETTERS__";(us=en()[Yo])||(us=en()[Yo]=[]),us.push(i=>$e=i),Qn=i=>{us.length>1?us.forEach(e=>e(i)):us[0](i)};const Rs=i=>{Qn(i),i.scope.on()},ns=()=>{$e&&$e.scope.off(),Qn(null)};function gc(i){return i.vnode.shapeFlag&4}let ei=!1;function Vh(i,e=!1){ei=e;const{props:t,children:s}=i.vnode,r=gc(i);bh(i,t,r,e),_h(i,s);const n=r?Wh(i,e):void 0;return ei=!1,n}function Wh(i,e){const t=i.type;i.accessCache=Object.create(null),i.proxy=Ul(new Proxy(i.ctx,Th));const{setup:s}=t;if(s){const r=i.setupContext=s.length>1?jh(i):null;Rs(i),_s();const n=qt(s,i,0,[i.props,r]);if(Cs(),ns(),Al(n)){if(n.then(ns,ns),e)return n.then(o=>{jo(i,o,e)}).catch(o=>{tr(o,i,0)});i.asyncDep=n}else jo(i,n,e)}else mc(i,e)}function jo(i,e,t){ce(e)?i.type.__ssrInlineRender?i.ssrRender=e:i.render=e:Pe(e)&&(i.setupState=Kl(e)),mc(i,t)}let qo;function mc(i,e,t){const s=i.type;if(!i.render){if(!e&&qo&&!s.render){const r=s.template||qn(i).template;if(r){const{isCustomElement:n,compilerOptions:o}=i.appContext.config,{delimiters:a,compilerOptions:l}=s,c=Ue(Ue({isCustomElement:n,delimiters:a},o),l);s.render=qo(r,c)}}i.render=s.render||pt}Rs(i),_s(),Eh(i),Cs(),ns()}function Yh(i){return i.attrsProxy||(i.attrsProxy=new Proxy(i.attrs,{get(e,t){return Ze(i,"get","$attrs"),e[t]}}))}function jh(i){const e=t=>{i.exposed=t||{}};return{get attrs(){return Yh(i)},slots:i.slots,emit:i.emit,expose:e}}function or(i){if(i.exposed)return i.exposeProxy||(i.exposeProxy=new Proxy(Kl(Ul(i.exposed)),{get(e,t){if(t in e)return e[t];if(t in Ks)return Ks[t](i)},has(e,t){return t in e||t in Ks}}))}function qh(i,e=!0){return ce(i)?i.displayName||i.name:i.name||e&&i.__name}function zh(i){return ce(i)&&"__vccOpts"in i}const ht=(i,e)=>Kf(i,e,ei);function pc(i,e,t){const s=arguments.length;return s===2?Pe(e)&&!le(e)?dn(e)?Je(i,null,[e]):Je(i,e):Je(i,null,e):(s>3?t=Array.prototype.slice.call(arguments,2):s===3&&dn(t)&&(t=[t]),Je(i,e,t))}const Xh=Symbol.for("v-scx"),Qh=()=>Lt(Xh),Jh="3.3.4",Zh="http://www.w3.org/2000/svg",ts=typeof document<"u"?document:null,zo=ts&&ts.createElement("template"),ed={insert:(i,e,t)=>{e.insertBefore(i,t||null)},remove:i=>{const e=i.parentNode;e&&e.removeChild(i)},createElement:(i,e,t,s)=>{const r=e?ts.createElementNS(Zh,i):ts.createElement(i,t?{is:t}:void 0);return i==="select"&&s&&s.multiple!=null&&r.setAttribute("multiple",s.multiple),r},createText:i=>ts.createTextNode(i),createComment:i=>ts.createComment(i),setText:(i,e)=>{i.nodeValue=e},setElementText:(i,e)=>{i.textContent=e},parentNode:i=>i.parentNode,nextSibling:i=>i.nextSibling,querySelector:i=>ts.querySelector(i),setScopeId(i,e){i.setAttribute(e,"")},insertStaticContent(i,e,t,s,r,n){const o=t?t.previousSibling:e.lastChild;if(r&&(r===n||r.nextSibling))for(;e.insertBefore(r.cloneNode(!0),t),!(r===n||!(r=r.nextSibling)););else{zo.innerHTML=s?`<svg>${i}</svg>`:i;const a=zo.content;if(s){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}e.insertBefore(a,t)}return[o?o.nextSibling:e.firstChild,t?t.previousSibling:e.lastChild]}};function td(i,e,t){const s=i._vtc;s&&(e=(e?[e,...s]:[...s]).join(" ")),e==null?i.removeAttribute("class"):t?i.setAttribute("class",e):i.className=e}function sd(i,e,t){const s=i.style,r=Ge(t);if(t&&!r){if(e&&!Ge(e))for(const n in e)t[n]==null&&gn(s,n,"");for(const n in t)gn(s,n,t[n])}else{const n=s.display;r?e!==t&&(s.cssText=t):e&&i.removeAttribute("style"),"_vod"in i&&(s.display=n)}}const Xo=/\s*!important$/;function gn(i,e,t){if(le(t))t.forEach(s=>gn(i,e,s));else if(t==null&&(t=""),e.startsWith("--"))i.setProperty(e,t);else{const s=id(i,e);Xo.test(t)?i.setProperty(Ds(s),t.replace(Xo,""),"important"):i[s]=t}}const Qo=["Webkit","Moz","ms"],vr={};function id(i,e){const t=vr[e];if(t)return t;let s=It(e);if(s!=="filter"&&s in i)return vr[e]=s;s=Qi(s);for(let r=0;r<Qo.length;r++){const n=Qo[r]+s;if(n in i)return vr[e]=n}return e}const Jo="http://www.w3.org/1999/xlink";function rd(i,e,t,s,r){if(s&&e.startsWith("xlink:"))t==null?i.removeAttributeNS(Jo,e.slice(6,e.length)):i.setAttributeNS(Jo,e,t);else{const n=lf(e);t==null||n&&!Rl(t)?i.removeAttribute(e):i.setAttribute(e,n?"":t)}}function nd(i,e,t,s,r,n,o){if(e==="innerHTML"||e==="textContent"){s&&o(s,r,n),i[e]=t??"";return}const a=i.tagName;if(e==="value"&&a!=="PROGRESS"&&!a.includes("-")){i._value=t;const c=a==="OPTION"?i.getAttribute("value"):i.value,u=t??"";c!==u&&(i.value=u),t==null&&i.removeAttribute(e);return}let l=!1;if(t===""||t==null){const c=typeof i[e];c==="boolean"?t=Rl(t):t==null&&c==="string"?(t="",l=!0):c==="number"&&(t=0,l=!0)}try{i[e]=t}catch{}l&&i.removeAttribute(e)}function od(i,e,t,s){i.addEventListener(e,t,s)}function ad(i,e,t,s){i.removeEventListener(e,t,s)}function ld(i,e,t,s,r=null){const n=i._vei||(i._vei={}),o=n[e];if(s&&o)o.value=s;else{const[a,l]=cd(e);if(s){const c=n[e]=hd(s,r);od(i,a,c,l)}else o&&(ad(i,a,o,l),n[e]=void 0)}}const Zo=/(?:Once|Passive|Capture)$/;function cd(i){let e;if(Zo.test(i)){e={};let s;for(;s=i.match(Zo);)i=i.slice(0,i.length-s[0].length),e[s[0].toLowerCase()]=!0}return[i[2]===":"?i.slice(3):Ds(i.slice(2)),e]}let Ar=0;const ud=Promise.resolve(),fd=()=>Ar||(ud.then(()=>Ar=0),Ar=Date.now());function hd(i,e){const t=s=>{if(!s._vts)s._vts=Date.now();else if(s._vts<=t.attached)return;yt(dd(s,t.value),e,5,[s])};return t.value=i,t.attached=fd(),t}function dd(i,e){if(le(e)){const t=i.stopImmediatePropagation;return i.stopImmediatePropagation=()=>{t.call(i),i._stopped=!0},e.map(s=>r=>!r._stopped&&s&&s(r))}else return e}const ea=/^on[a-z]/,gd=(i,e,t,s,r=!1,n,o,a,l)=>{e==="class"?td(i,s,r):e==="style"?sd(i,t,s):qi(e)?kn(e)||ld(i,e,t,s,o):(e[0]==="."?(e=e.slice(1),!0):e[0]==="^"?(e=e.slice(1),!1):md(i,e,s,r))?nd(i,e,s,n,o,a,l):(e==="true-value"?i._trueValue=s:e==="false-value"&&(i._falseValue=s),rd(i,e,s,r))};function md(i,e,t,s){return s?!!(e==="innerHTML"||e==="textContent"||e in i&&ea.test(e)&&ce(t)):e==="spellcheck"||e==="draggable"||e==="translate"||e==="form"||e==="list"&&i.tagName==="INPUT"||e==="type"&&i.tagName==="TEXTAREA"||ea.test(e)&&Ge(t)?!1:e in i}const pd={beforeMount(i,{value:e},{transition:t}){i._vod=i.style.display==="none"?"":i.style.display,t&&e?t.beforeEnter(i):Os(i,e)},mounted(i,{value:e},{transition:t}){t&&e&&t.enter(i)},updated(i,{value:e,oldValue:t},{transition:s}){!e!=!t&&(s?e?(s.beforeEnter(i),Os(i,!0),s.enter(i)):s.leave(i,()=>{Os(i,!1)}):Os(i,e))},beforeUnmount(i,{value:e}){Os(i,e)}};function Os(i,e){i.style.display=e?i._vod:"none"}const yd=Ue({patchProp:gd},ed);let ta;function Td(){return ta||(ta=wh(yd))}const Ed=(...i)=>{const e=Td().createApp(...i),{mount:t}=e;return e.mount=s=>{const r=xd(s);if(!r)return;const n=e._component;!ce(n)&&!n.render&&!n.template&&(n.template=r.innerHTML),r.innerHTML="";const o=t(r,!1,r instanceof SVGElement);return r instanceof Element&&(r.removeAttribute("v-cloak"),r.setAttribute("data-v-app","")),o},e};function xd(i){return Ge(i)?document.querySelector(i):i}/*!
  * vue-router v4.2.4
  * (c) 2023 Eduardo San Martin Morote
  * @license MIT
  */const ms=typeof window<"u";function Sd(i){return i.__esModule||i[Symbol.toStringTag]==="Module"}const ve=Object.assign;function Rr(i,e){const t={};for(const s in e){const r=e[s];t[s]=Tt(r)?r.map(i):i(r)}return t}const Vs=()=>{},Tt=Array.isArray,vd=/\/$/,Ad=i=>i.replace(vd,"");function Lr(i,e,t="/"){let s,r={},n="",o="";const a=e.indexOf("#");let l=e.indexOf("?");return a<l&&a>=0&&(l=-1),l>-1&&(s=e.slice(0,l),n=e.slice(l+1,a>-1?a:e.length),r=i(n)),a>-1&&(s=s||e.slice(0,a),o=e.slice(a,e.length)),s=Id(s??e,t),{fullPath:s+(n&&"?")+n+o,path:s,query:r,hash:o}}function Rd(i,e){const t=e.query?i(e.query):"";return e.path+(t&&"?")+t+(e.hash||"")}function sa(i,e){return!e||!i.toLowerCase().startsWith(e.toLowerCase())?i:i.slice(e.length)||"/"}function Ld(i,e,t){const s=e.matched.length-1,r=t.matched.length-1;return s>-1&&s===r&&Ls(e.matched[s],t.matched[r])&&yc(e.params,t.params)&&i(e.query)===i(t.query)&&e.hash===t.hash}function Ls(i,e){return(i.aliasOf||i)===(e.aliasOf||e)}function yc(i,e){if(Object.keys(i).length!==Object.keys(e).length)return!1;for(const t in i)if(!bd(i[t],e[t]))return!1;return!0}function bd(i,e){return Tt(i)?ia(i,e):Tt(e)?ia(e,i):i===e}function ia(i,e){return Tt(e)?i.length===e.length&&i.every((t,s)=>t===e[s]):i.length===1&&i[0]===e}function Id(i,e){if(i.startsWith("/"))return i;if(!i)return e;const t=e.split("/"),s=i.split("/"),r=s[s.length-1];(r===".."||r===".")&&s.push("");let n=t.length-1,o,a;for(o=0;o<s.length;o++)if(a=s[o],a!==".")if(a==="..")n>1&&n--;else break;return t.slice(0,n).join("/")+"/"+s.slice(o-(o===s.length?1:0)).join("/")}var ti;(function(i){i.pop="pop",i.push="push"})(ti||(ti={}));var Ws;(function(i){i.back="back",i.forward="forward",i.unknown=""})(Ws||(Ws={}));function Dd(i){if(!i)if(ms){const e=document.querySelector("base");i=e&&e.getAttribute("href")||"/",i=i.replace(/^\w+:\/\/[^\/]+/,"")}else i="/";return i[0]!=="/"&&i[0]!=="#"&&(i="/"+i),Ad(i)}const _d=/^[^#]+#/;function Cd(i,e){return i.replace(_d,"#")+e}function wd(i,e){const t=document.documentElement.getBoundingClientRect(),s=i.getBoundingClientRect();return{behavior:e.behavior,left:s.left-t.left-(e.left||0),top:s.top-t.top-(e.top||0)}}const ar=()=>({left:window.pageXOffset,top:window.pageYOffset});function Pd(i){let e;if("el"in i){const t=i.el,s=typeof t=="string"&&t.startsWith("#"),r=typeof t=="string"?s?document.getElementById(t.slice(1)):document.querySelector(t):t;if(!r)return;e=wd(r,i)}else e=i;"scrollBehavior"in document.documentElement.style?window.scrollTo(e):window.scrollTo(e.left!=null?e.left:window.pageXOffset,e.top!=null?e.top:window.pageYOffset)}function ra(i,e){return(history.state?history.state.position-e:-1)+i}const mn=new Map;function kd(i,e){mn.set(i,e)}function Od(i){const e=mn.get(i);return mn.delete(i),e}let Fd=()=>location.protocol+"//"+location.host;function Tc(i,e){const{pathname:t,search:s,hash:r}=e,n=i.indexOf("#");if(n>-1){let a=r.includes(i.slice(n))?i.slice(n).length:1,l=r.slice(a);return l[0]!=="/"&&(l="/"+l),sa(l,"")}return sa(t,i)+s+r}function Nd(i,e,t,s){let r=[],n=[],o=null;const a=({state:h})=>{const d=Tc(i,location),g=t.value,m=e.value;let y=0;if(h){if(t.value=d,e.value=h,o&&o===g){o=null;return}y=m?h.position-m.position:0}else s(d);r.forEach(T=>{T(t.value,g,{delta:y,type:ti.pop,direction:y?y>0?Ws.forward:Ws.back:Ws.unknown})})};function l(){o=t.value}function c(h){r.push(h);const d=()=>{const g=r.indexOf(h);g>-1&&r.splice(g,1)};return n.push(d),d}function u(){const{history:h}=window;h.state&&h.replaceState(ve({},h.state,{scroll:ar()}),"")}function f(){for(const h of n)h();n=[],window.removeEventListener("popstate",a),window.removeEventListener("beforeunload",u)}return window.addEventListener("popstate",a),window.addEventListener("beforeunload",u,{passive:!0}),{pauseListeners:l,listen:c,destroy:f}}function na(i,e,t,s=!1,r=!1){return{back:i,current:e,forward:t,replaced:s,position:window.history.length,scroll:r?ar():null}}function Md(i){const{history:e,location:t}=window,s={value:Tc(i,t)},r={value:e.state};r.value||n(s.value,{back:null,current:s.value,forward:null,position:e.length-1,replaced:!0,scroll:null},!0);function n(l,c,u){const f=i.indexOf("#"),h=f>-1?(t.host&&document.querySelector("base")?i:i.slice(f))+l:Fd()+i+l;try{e[u?"replaceState":"pushState"](c,"",h),r.value=c}catch(d){console.error(d),t[u?"replace":"assign"](h)}}function o(l,c){const u=ve({},e.state,na(r.value.back,l,r.value.forward,!0),c,{position:r.value.position});n(l,u,!0),s.value=l}function a(l,c){const u=ve({},r.value,e.state,{forward:l,scroll:ar()});n(u.current,u,!0);const f=ve({},na(s.value,l,null),{position:u.position+1},c);n(l,f,!1),s.value=l}return{location:s,state:r,push:a,replace:o}}function Ud(i){i=Dd(i);const e=Md(i),t=Nd(i,e.state,e.location,e.replace);function s(n,o=!0){o||t.pauseListeners(),history.go(n)}const r=ve({location:"",base:i,go:s,createHref:Cd.bind(null,i)},e,t);return Object.defineProperty(r,"location",{enumerable:!0,get:()=>e.location.value}),Object.defineProperty(r,"state",{enumerable:!0,get:()=>e.state.value}),r}function Bd(i){return i=location.host?i||location.pathname+location.search:"",i.includes("#")||(i+="#"),Ud(i)}function $d(i){return typeof i=="string"||i&&typeof i=="object"}function Ec(i){return typeof i=="string"||typeof i=="symbol"}const $t={path:"/",name:void 0,params:{},query:{},hash:"",fullPath:"/",matched:[],meta:{},redirectedFrom:void 0},xc=Symbol("");var oa;(function(i){i[i.aborted=4]="aborted",i[i.cancelled=8]="cancelled",i[i.duplicated=16]="duplicated"})(oa||(oa={}));function bs(i,e){return ve(new Error,{type:i,[xc]:!0},e)}function _t(i,e){return i instanceof Error&&xc in i&&(e==null||!!(i.type&e))}const aa="[^/]+?",Gd={sensitive:!1,strict:!1,start:!0,end:!0},Kd=/[.+*?^${}()[\]/\\]/g;function Hd(i,e){const t=ve({},Gd,e),s=[];let r=t.start?"^":"";const n=[];for(const c of i){const u=c.length?[]:[90];t.strict&&!c.length&&(r+="/");for(let f=0;f<c.length;f++){const h=c[f];let d=40+(t.sensitive?.25:0);if(h.type===0)f||(r+="/"),r+=h.value.replace(Kd,"\\$&"),d+=40;else if(h.type===1){const{value:g,repeatable:m,optional:y,regexp:T}=h;n.push({name:g,repeatable:m,optional:y});const x=T||aa;if(x!==aa){d+=10;try{new RegExp(`(${x})`)}catch(R){throw new Error(`Invalid custom RegExp for param "${g}" (${x}): `+R.message)}}let v=m?`((?:${x})(?:/(?:${x}))*)`:`(${x})`;f||(v=y&&c.length<2?`(?:/${v})`:"/"+v),y&&(v+="?"),r+=v,d+=20,y&&(d+=-8),m&&(d+=-20),x===".*"&&(d+=-50)}u.push(d)}s.push(u)}if(t.strict&&t.end){const c=s.length-1;s[c][s[c].length-1]+=.7000000000000001}t.strict||(r+="/?"),t.end?r+="$":t.strict&&(r+="(?:/|$)");const o=new RegExp(r,t.sensitive?"":"i");function a(c){const u=c.match(o),f={};if(!u)return null;for(let h=1;h<u.length;h++){const d=u[h]||"",g=n[h-1];f[g.name]=d&&g.repeatable?d.split("/"):d}return f}function l(c){let u="",f=!1;for(const h of i){(!f||!u.endsWith("/"))&&(u+="/"),f=!1;for(const d of h)if(d.type===0)u+=d.value;else if(d.type===1){const{value:g,repeatable:m,optional:y}=d,T=g in c?c[g]:"";if(Tt(T)&&!m)throw new Error(`Provided param "${g}" is an array but it is not repeatable (* or + modifiers)`);const x=Tt(T)?T.join("/"):T;if(!x)if(y)h.length<2&&(u.endsWith("/")?u=u.slice(0,-1):f=!0);else throw new Error(`Missing required param "${g}"`);u+=x}}return u||"/"}return{re:o,score:s,keys:n,parse:a,stringify:l}}function Vd(i,e){let t=0;for(;t<i.length&&t<e.length;){const s=e[t]-i[t];if(s)return s;t++}return i.length<e.length?i.length===1&&i[0]===40+40?-1:1:i.length>e.length?e.length===1&&e[0]===40+40?1:-1:0}function Wd(i,e){let t=0;const s=i.score,r=e.score;for(;t<s.length&&t<r.length;){const n=Vd(s[t],r[t]);if(n)return n;t++}if(Math.abs(r.length-s.length)===1){if(la(s))return 1;if(la(r))return-1}return r.length-s.length}function la(i){const e=i[i.length-1];return i.length>0&&e[e.length-1]<0}const Yd={type:0,value:""},jd=/[a-zA-Z0-9_]/;function qd(i){if(!i)return[[]];if(i==="/")return[[Yd]];if(!i.startsWith("/"))throw new Error(`Invalid path "${i}"`);function e(d){throw new Error(`ERR (${t})/"${c}": ${d}`)}let t=0,s=t;const r=[];let n;function o(){n&&r.push(n),n=[]}let a=0,l,c="",u="";function f(){c&&(t===0?n.push({type:0,value:c}):t===1||t===2||t===3?(n.length>1&&(l==="*"||l==="+")&&e(`A repeatable param (${c}) must be alone in its segment. eg: '/:ids+.`),n.push({type:1,value:c,regexp:u,repeatable:l==="*"||l==="+",optional:l==="*"||l==="?"})):e("Invalid state to consume buffer"),c="")}function h(){c+=l}for(;a<i.length;){if(l=i[a++],l==="\\"&&t!==2){s=t,t=4;continue}switch(t){case 0:l==="/"?(c&&f(),o()):l===":"?(f(),t=1):h();break;case 4:h(),t=s;break;case 1:l==="("?t=2:jd.test(l)?h():(f(),t=0,l!=="*"&&l!=="?"&&l!=="+"&&a--);break;case 2:l===")"?u[u.length-1]=="\\"?u=u.slice(0,-1)+l:t=3:u+=l;break;case 3:f(),t=0,l!=="*"&&l!=="?"&&l!=="+"&&a--,u="";break;default:e("Unknown state");break}}return t===2&&e(`Unfinished custom RegExp for param "${c}"`),f(),o(),r}function zd(i,e,t){const s=Hd(qd(i.path),t),r=ve(s,{record:i,parent:e,children:[],alias:[]});return e&&!r.record.aliasOf==!e.record.aliasOf&&e.children.push(r),r}function Xd(i,e){const t=[],s=new Map;e=fa({strict:!1,end:!0,sensitive:!1},e);function r(u){return s.get(u)}function n(u,f,h){const d=!h,g=Qd(u);g.aliasOf=h&&h.record;const m=fa(e,u),y=[g];if("alias"in u){const v=typeof u.alias=="string"?[u.alias]:u.alias;for(const R of v)y.push(ve({},g,{components:h?h.record.components:g.components,path:R,aliasOf:h?h.record:g}))}let T,x;for(const v of y){const{path:R}=v;if(f&&R[0]!=="/"){const b=f.record.path,M=b[b.length-1]==="/"?"":"/";v.path=f.record.path+(R&&M+R)}if(T=zd(v,f,m),h?h.alias.push(T):(x=x||T,x!==T&&x.alias.push(T),d&&u.name&&!ua(T)&&o(u.name)),g.children){const b=g.children;for(let M=0;M<b.length;M++)n(b[M],T,h&&h.children[M])}h=h||T,(T.record.components&&Object.keys(T.record.components).length||T.record.name||T.record.redirect)&&l(T)}return x?()=>{o(x)}:Vs}function o(u){if(Ec(u)){const f=s.get(u);f&&(s.delete(u),t.splice(t.indexOf(f),1),f.children.forEach(o),f.alias.forEach(o))}else{const f=t.indexOf(u);f>-1&&(t.splice(f,1),u.record.name&&s.delete(u.record.name),u.children.forEach(o),u.alias.forEach(o))}}function a(){return t}function l(u){let f=0;for(;f<t.length&&Wd(u,t[f])>=0&&(u.record.path!==t[f].record.path||!Sc(u,t[f]));)f++;t.splice(f,0,u),u.record.name&&!ua(u)&&s.set(u.record.name,u)}function c(u,f){let h,d={},g,m;if("name"in u&&u.name){if(h=s.get(u.name),!h)throw bs(1,{location:u});m=h.record.name,d=ve(ca(f.params,h.keys.filter(x=>!x.optional).map(x=>x.name)),u.params&&ca(u.params,h.keys.map(x=>x.name))),g=h.stringify(d)}else if("path"in u)g=u.path,h=t.find(x=>x.re.test(g)),h&&(d=h.parse(g),m=h.record.name);else{if(h=f.name?s.get(f.name):t.find(x=>x.re.test(f.path)),!h)throw bs(1,{location:u,currentLocation:f});m=h.record.name,d=ve({},f.params,u.params),g=h.stringify(d)}const y=[];let T=h;for(;T;)y.unshift(T.record),T=T.parent;return{name:m,path:g,params:d,matched:y,meta:Zd(y)}}return i.forEach(u=>n(u)),{addRoute:n,resolve:c,removeRoute:o,getRoutes:a,getRecordMatcher:r}}function ca(i,e){const t={};for(const s of e)s in i&&(t[s]=i[s]);return t}function Qd(i){return{path:i.path,redirect:i.redirect,name:i.name,meta:i.meta||{},aliasOf:void 0,beforeEnter:i.beforeEnter,props:Jd(i),children:i.children||[],instances:{},leaveGuards:new Set,updateGuards:new Set,enterCallbacks:{},components:"components"in i?i.components||null:i.component&&{default:i.component}}}function Jd(i){const e={},t=i.props||!1;if("component"in i)e.default=t;else for(const s in i.components)e[s]=typeof t=="object"?t[s]:t;return e}function ua(i){for(;i;){if(i.record.aliasOf)return!0;i=i.parent}return!1}function Zd(i){return i.reduce((e,t)=>ve(e,t.meta),{})}function fa(i,e){const t={};for(const s in i)t[s]=s in e?e[s]:i[s];return t}function Sc(i,e){return e.children.some(t=>t===i||Sc(i,t))}const vc=/#/g,eg=/&/g,tg=/\//g,sg=/=/g,ig=/\?/g,Ac=/\+/g,rg=/%5B/g,ng=/%5D/g,Rc=/%5E/g,og=/%60/g,Lc=/%7B/g,ag=/%7C/g,bc=/%7D/g,lg=/%20/g;function Jn(i){return encodeURI(""+i).replace(ag,"|").replace(rg,"[").replace(ng,"]")}function cg(i){return Jn(i).replace(Lc,"{").replace(bc,"}").replace(Rc,"^")}function pn(i){return Jn(i).replace(Ac,"%2B").replace(lg,"+").replace(vc,"%23").replace(eg,"%26").replace(og,"`").replace(Lc,"{").replace(bc,"}").replace(Rc,"^")}function ug(i){return pn(i).replace(sg,"%3D")}function fg(i){return Jn(i).replace(vc,"%23").replace(ig,"%3F")}function hg(i){return i==null?"":fg(i).replace(tg,"%2F")}function $i(i){try{return decodeURIComponent(""+i)}catch{}return""+i}function dg(i){const e={};if(i===""||i==="?")return e;const s=(i[0]==="?"?i.slice(1):i).split("&");for(let r=0;r<s.length;++r){const n=s[r].replace(Ac," "),o=n.indexOf("="),a=$i(o<0?n:n.slice(0,o)),l=o<0?null:$i(n.slice(o+1));if(a in e){let c=e[a];Tt(c)||(c=e[a]=[c]),c.push(l)}else e[a]=l}return e}function ha(i){let e="";for(let t in i){const s=i[t];if(t=ug(t),s==null){s!==void 0&&(e+=(e.length?"&":"")+t);continue}(Tt(s)?s.map(n=>n&&pn(n)):[s&&pn(s)]).forEach(n=>{n!==void 0&&(e+=(e.length?"&":"")+t,n!=null&&(e+="="+n))})}return e}function gg(i){const e={};for(const t in i){const s=i[t];s!==void 0&&(e[t]=Tt(s)?s.map(r=>r==null?null:""+r):s==null?s:""+s)}return e}const mg=Symbol(""),da=Symbol(""),lr=Symbol(""),Ic=Symbol(""),yn=Symbol("");function Fs(){let i=[];function e(s){return i.push(s),()=>{const r=i.indexOf(s);r>-1&&i.splice(r,1)}}function t(){i=[]}return{add:e,list:()=>i.slice(),reset:t}}function Vt(i,e,t,s,r){const n=s&&(s.enterCallbacks[r]=s.enterCallbacks[r]||[]);return()=>new Promise((o,a)=>{const l=f=>{f===!1?a(bs(4,{from:t,to:e})):f instanceof Error?a(f):$d(f)?a(bs(2,{from:e,to:f})):(n&&s.enterCallbacks[r]===n&&typeof f=="function"&&n.push(f),o())},c=i.call(s&&s.instances[r],e,t,l);let u=Promise.resolve(c);i.length<3&&(u=u.then(l)),u.catch(f=>a(f))})}function br(i,e,t,s){const r=[];for(const n of i)for(const o in n.components){let a=n.components[o];if(!(e!=="beforeRouteEnter"&&!n.instances[o]))if(pg(a)){const c=(a.__vccOpts||a)[e];c&&r.push(Vt(c,t,s,n,o))}else{let l=a();r.push(()=>l.then(c=>{if(!c)return Promise.reject(new Error(`Couldn't resolve component "${o}" at "${n.path}"`));const u=Sd(c)?c.default:c;n.components[o]=u;const h=(u.__vccOpts||u)[e];return h&&Vt(h,t,s,n,o)()}))}}return r}function pg(i){return typeof i=="object"||"displayName"in i||"props"in i||"__vccOpts"in i}function ga(i){const e=Lt(lr),t=Lt(Ic),s=ht(()=>e.resolve(rs(i.to))),r=ht(()=>{const{matched:l}=s.value,{length:c}=l,u=l[c-1],f=t.matched;if(!u||!f.length)return-1;const h=f.findIndex(Ls.bind(null,u));if(h>-1)return h;const d=ma(l[c-2]);return c>1&&ma(u)===d&&f[f.length-1].path!==d?f.findIndex(Ls.bind(null,l[c-2])):h}),n=ht(()=>r.value>-1&&xg(t.params,s.value.params)),o=ht(()=>r.value>-1&&r.value===t.matched.length-1&&yc(t.params,s.value.params));function a(l={}){return Eg(l)?e[rs(i.replace)?"replace":"push"](rs(i.to)).catch(Vs):Promise.resolve()}return{route:s,href:ht(()=>s.value.href),isActive:n,isExactActive:o,navigate:a}}const yg=Jl({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"}},useLink:ga,setup(i,{slots:e}){const t=er(ga(i)),{options:s}=Lt(lr),r=ht(()=>({[pa(i.activeClass,s.linkActiveClass,"router-link-active")]:t.isActive,[pa(i.exactActiveClass,s.linkExactActiveClass,"router-link-exact-active")]:t.isExactActive}));return()=>{const n=e.default&&e.default(t);return i.custom?n:pc("a",{"aria-current":t.isExactActive?i.ariaCurrentValue:null,href:t.href,onClick:t.navigate,class:r.value},n)}}}),Tg=yg;function Eg(i){if(!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)&&!i.defaultPrevented&&!(i.button!==void 0&&i.button!==0)){if(i.currentTarget&&i.currentTarget.getAttribute){const e=i.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(e))return}return i.preventDefault&&i.preventDefault(),!0}}function xg(i,e){for(const t in e){const s=e[t],r=i[t];if(typeof s=="string"){if(s!==r)return!1}else if(!Tt(r)||r.length!==s.length||s.some((n,o)=>n!==r[o]))return!1}return!0}function ma(i){return i?i.aliasOf?i.aliasOf.path:i.path:""}const pa=(i,e,t)=>i??e??t,Sg=Jl({name:"RouterView",inheritAttrs:!1,props:{name:{type:String,default:"default"},route:Object},compatConfig:{MODE:3},setup(i,{attrs:e,slots:t}){const s=Lt(yn),r=ht(()=>i.route||s.value),n=Lt(da,0),o=ht(()=>{let c=rs(n);const{matched:u}=r.value;let f;for(;(f=u[c])&&!f.components;)c++;return c}),a=ht(()=>r.value.matched[o.value]);Di(da,ht(()=>o.value+1)),Di(mg,a),Di(yn,r);const l=Li();return bi(()=>[l.value,a.value,i.name],([c,u,f],[h,d,g])=>{u&&(u.instances[f]=c,d&&d!==u&&c&&c===h&&(u.leaveGuards.size||(u.leaveGuards=d.leaveGuards),u.updateGuards.size||(u.updateGuards=d.updateGuards))),c&&u&&(!d||!Ls(u,d)||!h)&&(u.enterCallbacks[f]||[]).forEach(m=>m(c))},{flush:"post"}),()=>{const c=r.value,u=i.name,f=a.value,h=f&&f.components[u];if(!h)return ya(t.default,{Component:h,route:c});const d=f.props[u],g=d?d===!0?c.params:typeof d=="function"?d(c):d:null,y=pc(h,ve({},g,e,{onVnodeUnmounted:T=>{T.component.isUnmounted&&(f.instances[u]=null)},ref:l}));return ya(t.default,{Component:y,route:c})||y}}});function ya(i,e){if(!i)return null;const t=i(e);return t.length===1?t[0]:t}const vg=Sg;function Ag(i){const e=Xd(i.routes,i),t=i.parseQuery||dg,s=i.stringifyQuery||ha,r=i.history,n=Fs(),o=Fs(),a=Fs(),l=Uf($t);let c=$t;ms&&i.scrollBehavior&&"scrollRestoration"in history&&(history.scrollRestoration="manual");const u=Rr.bind(null,w=>""+w),f=Rr.bind(null,hg),h=Rr.bind(null,$i);function d(w,j){let V,Q;return Ec(w)?(V=e.getRecordMatcher(w),Q=j):Q=w,e.addRoute(Q,V)}function g(w){const j=e.getRecordMatcher(w);j&&e.removeRoute(j)}function m(){return e.getRoutes().map(w=>w.record)}function y(w){return!!e.getRecordMatcher(w)}function T(w,j){if(j=ve({},j||l.value),typeof w=="string"){const L=Lr(t,w,j.path),C=e.resolve({path:L.path},j),O=r.createHref(L.fullPath);return ve(L,C,{params:h(C.params),hash:$i(L.hash),redirectedFrom:void 0,href:O})}let V;if("path"in w)V=ve({},w,{path:Lr(t,w.path,j.path).path});else{const L=ve({},w.params);for(const C in L)L[C]==null&&delete L[C];V=ve({},w,{params:f(L)}),j.params=f(j.params)}const Q=e.resolve(V,j),xe=w.hash||"";Q.params=u(h(Q.params));const E=Rd(s,ve({},w,{hash:cg(xe),path:Q.path})),S=r.createHref(E);return ve({fullPath:E,hash:xe,query:s===ha?gg(w.query):w.query||{}},Q,{redirectedFrom:void 0,href:S})}function x(w){return typeof w=="string"?Lr(t,w,l.value.path):ve({},w)}function v(w,j){if(c!==w)return bs(8,{from:j,to:w})}function R(w){return P(w)}function b(w){return R(ve(x(w),{replace:!0}))}function M(w){const j=w.matched[w.matched.length-1];if(j&&j.redirect){const{redirect:V}=j;let Q=typeof V=="function"?V(w):V;return typeof Q=="string"&&(Q=Q.includes("?")||Q.includes("#")?Q=x(Q):{path:Q},Q.params={}),ve({query:w.query,hash:w.hash,params:"path"in Q?{}:w.params},Q)}}function P(w,j){const V=c=T(w),Q=l.value,xe=w.state,E=w.force,S=w.replace===!0,L=M(V);if(L)return P(ve(x(L),{state:typeof L=="object"?ve({},xe,L.state):xe,force:E,replace:S}),j||V);const C=V;C.redirectedFrom=j;let O;return!E&&Ld(s,Q,V)&&(O=bs(16,{to:C,from:Q}),he(Q,Q,!0,!1)),(O?Promise.resolve(O):_(C,Q)).catch(N=>_t(N)?_t(N,2)?N:fe(N):$(N,C,Q)).then(N=>{if(N){if(_t(N,2))return P(ve({replace:S},x(N.to),{state:typeof N.to=="object"?ve({},xe,N.to.state):xe,force:E}),j||C)}else N=W(C,Q,!0,S,xe);return q(C,Q,N),N})}function B(w,j){const V=v(w,j);return V?Promise.reject(V):Promise.resolve()}function K(w){const j=Fe.values().next().value;return j&&typeof j.runWithContext=="function"?j.runWithContext(w):w()}function _(w,j){let V;const[Q,xe,E]=Rg(w,j);V=br(Q.reverse(),"beforeRouteLeave",w,j);for(const L of Q)L.leaveGuards.forEach(C=>{V.push(Vt(C,w,j))});const S=B.bind(null,w,j);return V.push(S),Se(V).then(()=>{V=[];for(const L of n.list())V.push(Vt(L,w,j));return V.push(S),Se(V)}).then(()=>{V=br(xe,"beforeRouteUpdate",w,j);for(const L of xe)L.updateGuards.forEach(C=>{V.push(Vt(C,w,j))});return V.push(S),Se(V)}).then(()=>{V=[];for(const L of E)if(L.beforeEnter)if(Tt(L.beforeEnter))for(const C of L.beforeEnter)V.push(Vt(C,w,j));else V.push(Vt(L.beforeEnter,w,j));return V.push(S),Se(V)}).then(()=>(w.matched.forEach(L=>L.enterCallbacks={}),V=br(E,"beforeRouteEnter",w,j),V.push(S),Se(V))).then(()=>{V=[];for(const L of o.list())V.push(Vt(L,w,j));return V.push(S),Se(V)}).catch(L=>_t(L,8)?L:Promise.reject(L))}function q(w,j,V){a.list().forEach(Q=>K(()=>Q(w,j,V)))}function W(w,j,V,Q,xe){const E=v(w,j);if(E)return E;const S=j===$t,L=ms?history.state:{};V&&(Q||S?r.replace(w.fullPath,ve({scroll:S&&L&&L.scroll},xe)):r.push(w.fullPath,xe)),l.value=w,he(w,j,V,S),fe()}let ue;function we(){ue||(ue=r.listen((w,j,V)=>{if(!Ke.listening)return;const Q=T(w),xe=M(Q);if(xe){P(ve(xe,{replace:!0}),Q).catch(Vs);return}c=Q;const E=l.value;ms&&kd(ra(E.fullPath,V.delta),ar()),_(Q,E).catch(S=>_t(S,12)?S:_t(S,2)?(P(S.to,Q).then(L=>{_t(L,20)&&!V.delta&&V.type===ti.pop&&r.go(-1,!1)}).catch(Vs),Promise.reject()):(V.delta&&r.go(-V.delta,!1),$(S,Q,E))).then(S=>{S=S||W(Q,E,!1),S&&(V.delta&&!_t(S,8)?r.go(-V.delta,!1):V.type===ti.pop&&_t(S,20)&&r.go(-1,!1)),q(Q,E,S)}).catch(Vs)}))}let Te=Fs(),ae=Fs(),te;function $(w,j,V){fe(w);const Q=ae.list();return Q.length?Q.forEach(xe=>xe(w,j,V)):console.error(w),Promise.reject(w)}function z(){return te&&l.value!==$t?Promise.resolve():new Promise((w,j)=>{Te.add([w,j])})}function fe(w){return te||(te=!w,we(),Te.list().forEach(([j,V])=>w?V(w):j()),Te.reset()),w}function he(w,j,V,Q){const{scrollBehavior:xe}=i;if(!ms||!xe)return Promise.resolve();const E=!V&&Od(ra(w.fullPath,0))||(Q||!V)&&history.state&&history.state.scroll||null;return Vl().then(()=>xe(w,j,E)).then(S=>S&&Pd(S)).catch(S=>$(S,w,j))}const ne=w=>r.go(w);let Le;const Fe=new Set,Ke={currentRoute:l,listening:!0,addRoute:d,removeRoute:g,hasRoute:y,getRoutes:m,resolve:T,options:i,push:R,replace:b,go:ne,back:()=>ne(-1),forward:()=>ne(1),beforeEach:n.add,beforeResolve:o.add,afterEach:a.add,onError:ae.add,isReady:z,install(w){const j=this;w.component("RouterLink",Tg),w.component("RouterView",vg),w.config.globalProperties.$router=j,Object.defineProperty(w.config.globalProperties,"$route",{enumerable:!0,get:()=>rs(l)}),ms&&!Le&&l.value===$t&&(Le=!0,R(r.location).catch(xe=>{}));const V={};for(const xe in $t)Object.defineProperty(V,xe,{get:()=>l.value[xe],enumerable:!0});w.provide(lr,j),w.provide(Ic,Fl(V)),w.provide(yn,l);const Q=w.unmount;Fe.add(w),w.unmount=function(){Fe.delete(w),Fe.size<1&&(c=$t,ue&&ue(),ue=null,l.value=$t,Le=!1,te=!1),Q()}}};function Se(w){return w.reduce((j,V)=>j.then(()=>K(V)),Promise.resolve())}return Ke}function Rg(i,e){const t=[],s=[],r=[],n=Math.max(e.matched.length,i.matched.length);for(let o=0;o<n;o++){const a=e.matched[o];a&&(i.matched.find(c=>Ls(c,a))?s.push(a):t.push(a));const l=i.matched[o];l&&(e.matched.find(c=>Ls(c,l))||r.push(l))}return[t,s,r]}function Lg(){return Lt(lr)}const Zn=(i,e)=>{const t=i.__vccOpts||i;for(const[s,r]of e)t[s]=r;return t},bg={__name:"App",setup(i){return Lg(),jn(()=>{}),(e,t)=>{const s=mh("router-view");return Js(),hc(s)}}},Ig=Zn(bg,[["__scopeId","data-v-be9d76f5"]]);function Dc(i,e){return function(){return i.apply(e,arguments)}}const{toString:Dg}=Object.prototype,{getPrototypeOf:eo}=Object,cr=(i=>e=>{const t=Dg.call(e);return i[t]||(i[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Dt=i=>(i=i.toLowerCase(),e=>cr(e)===i),ur=i=>e=>typeof e===i,{isArray:ws}=Array,si=ur("undefined");function _g(i){return i!==null&&!si(i)&&i.constructor!==null&&!si(i.constructor)&&ot(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}const _c=Dt("ArrayBuffer");function Cg(i){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(i):e=i&&i.buffer&&_c(i.buffer),e}const wg=ur("string"),ot=ur("function"),Cc=ur("number"),fr=i=>i!==null&&typeof i=="object",Pg=i=>i===!0||i===!1,Ci=i=>{if(cr(i)!=="object")return!1;const e=eo(i);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in i)&&!(Symbol.iterator in i)},kg=Dt("Date"),Og=Dt("File"),Fg=Dt("Blob"),Ng=Dt("FileList"),Mg=i=>fr(i)&&ot(i.pipe),Ug=i=>{let e;return i&&(typeof FormData=="function"&&i instanceof FormData||ot(i.append)&&((e=cr(i))==="formdata"||e==="object"&&ot(i.toString)&&i.toString()==="[object FormData]"))},Bg=Dt("URLSearchParams"),$g=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function oi(i,e,{allOwnKeys:t=!1}={}){if(i===null||typeof i>"u")return;let s,r;if(typeof i!="object"&&(i=[i]),ws(i))for(s=0,r=i.length;s<r;s++)e.call(null,i[s],s,i);else{const n=t?Object.getOwnPropertyNames(i):Object.keys(i),o=n.length;let a;for(s=0;s<o;s++)a=n[s],e.call(null,i[a],a,i)}}function wc(i,e){e=e.toLowerCase();const t=Object.keys(i);let s=t.length,r;for(;s-- >0;)if(r=t[s],e===r.toLowerCase())return r;return null}const Pc=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),kc=i=>!si(i)&&i!==Pc;function Tn(){const{caseless:i}=kc(this)&&this||{},e={},t=(s,r)=>{const n=i&&wc(e,r)||r;Ci(e[n])&&Ci(s)?e[n]=Tn(e[n],s):Ci(s)?e[n]=Tn({},s):ws(s)?e[n]=s.slice():e[n]=s};for(let s=0,r=arguments.length;s<r;s++)arguments[s]&&oi(arguments[s],t);return e}const Gg=(i,e,t,{allOwnKeys:s}={})=>(oi(e,(r,n)=>{t&&ot(r)?i[n]=Dc(r,t):i[n]=r},{allOwnKeys:s}),i),Kg=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),Hg=(i,e,t,s)=>{i.prototype=Object.create(e.prototype,s),i.prototype.constructor=i,Object.defineProperty(i,"super",{value:e.prototype}),t&&Object.assign(i.prototype,t)},Vg=(i,e,t,s)=>{let r,n,o;const a={};if(e=e||{},i==null)return e;do{for(r=Object.getOwnPropertyNames(i),n=r.length;n-- >0;)o=r[n],(!s||s(o,i,e))&&!a[o]&&(e[o]=i[o],a[o]=!0);i=t!==!1&&eo(i)}while(i&&(!t||t(i,e))&&i!==Object.prototype);return e},Wg=(i,e,t)=>{i=String(i),(t===void 0||t>i.length)&&(t=i.length),t-=e.length;const s=i.indexOf(e,t);return s!==-1&&s===t},Yg=i=>{if(!i)return null;if(ws(i))return i;let e=i.length;if(!Cc(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=i[e];return t},jg=(i=>e=>i&&e instanceof i)(typeof Uint8Array<"u"&&eo(Uint8Array)),qg=(i,e)=>{const s=(i&&i[Symbol.iterator]).call(i);let r;for(;(r=s.next())&&!r.done;){const n=r.value;e.call(i,n[0],n[1])}},zg=(i,e)=>{let t;const s=[];for(;(t=i.exec(e))!==null;)s.push(t);return s},Xg=Dt("HTMLFormElement"),Qg=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,s,r){return s.toUpperCase()+r}),Ta=(({hasOwnProperty:i})=>(e,t)=>i.call(e,t))(Object.prototype),Jg=Dt("RegExp"),Oc=(i,e)=>{const t=Object.getOwnPropertyDescriptors(i),s={};oi(t,(r,n)=>{let o;(o=e(r,n,i))!==!1&&(s[n]=o||r)}),Object.defineProperties(i,s)},Zg=i=>{Oc(i,(e,t)=>{if(ot(i)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const s=i[t];if(ot(s)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},e0=(i,e)=>{const t={},s=r=>{r.forEach(n=>{t[n]=!0})};return ws(i)?s(i):s(String(i).split(e)),t},t0=()=>{},s0=(i,e)=>(i=+i,Number.isFinite(i)?i:e),Ir="abcdefghijklmnopqrstuvwxyz",Ea="0123456789",Fc={DIGIT:Ea,ALPHA:Ir,ALPHA_DIGIT:Ir+Ir.toUpperCase()+Ea},i0=(i=16,e=Fc.ALPHA_DIGIT)=>{let t="";const{length:s}=e;for(;i--;)t+=e[Math.random()*s|0];return t};function r0(i){return!!(i&&ot(i.append)&&i[Symbol.toStringTag]==="FormData"&&i[Symbol.iterator])}const n0=i=>{const e=new Array(10),t=(s,r)=>{if(fr(s)){if(e.indexOf(s)>=0)return;if(!("toJSON"in s)){e[r]=s;const n=ws(s)?[]:{};return oi(s,(o,a)=>{const l=t(o,r+1);!si(l)&&(n[a]=l)}),e[r]=void 0,n}}return s};return t(i,0)},o0=Dt("AsyncFunction"),a0=i=>i&&(fr(i)||ot(i))&&ot(i.then)&&ot(i.catch),k={isArray:ws,isArrayBuffer:_c,isBuffer:_g,isFormData:Ug,isArrayBufferView:Cg,isString:wg,isNumber:Cc,isBoolean:Pg,isObject:fr,isPlainObject:Ci,isUndefined:si,isDate:kg,isFile:Og,isBlob:Fg,isRegExp:Jg,isFunction:ot,isStream:Mg,isURLSearchParams:Bg,isTypedArray:jg,isFileList:Ng,forEach:oi,merge:Tn,extend:Gg,trim:$g,stripBOM:Kg,inherits:Hg,toFlatObject:Vg,kindOf:cr,kindOfTest:Dt,endsWith:Wg,toArray:Yg,forEachEntry:qg,matchAll:zg,isHTMLForm:Xg,hasOwnProperty:Ta,hasOwnProp:Ta,reduceDescriptors:Oc,freezeMethods:Zg,toObjectSet:e0,toCamelCase:Qg,noop:t0,toFiniteNumber:s0,findKey:wc,global:Pc,isContextDefined:kc,ALPHABET:Fc,generateString:i0,isSpecCompliantForm:r0,toJSONObject:n0,isAsyncFn:o0,isThenable:a0};function me(i,e,t,s,r){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=i,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),r&&(this.response=r)}k.inherits(me,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:k.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Nc=me.prototype,Mc={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(i=>{Mc[i]={value:i}});Object.defineProperties(me,Mc);Object.defineProperty(Nc,"isAxiosError",{value:!0});me.from=(i,e,t,s,r,n)=>{const o=Object.create(Nc);return k.toFlatObject(i,o,function(l){return l!==Error.prototype},a=>a!=="isAxiosError"),me.call(o,i.message,e,t,s,r),o.cause=i,o.name=i.name,n&&Object.assign(o,n),o};const l0=null;function En(i){return k.isPlainObject(i)||k.isArray(i)}function Uc(i){return k.endsWith(i,"[]")?i.slice(0,-2):i}function xa(i,e,t){return i?i.concat(e).map(function(r,n){return r=Uc(r),!t&&n?"["+r+"]":r}).join(t?".":""):e}function c0(i){return k.isArray(i)&&!i.some(En)}const u0=k.toFlatObject(k,{},null,function(e){return/^is[A-Z]/.test(e)});function hr(i,e,t){if(!k.isObject(i))throw new TypeError("target must be an object");e=e||new FormData,t=k.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,y){return!k.isUndefined(y[m])});const s=t.metaTokens,r=t.visitor||u,n=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&k.isSpecCompliantForm(e);if(!k.isFunction(r))throw new TypeError("visitor must be a function");function c(g){if(g===null)return"";if(k.isDate(g))return g.toISOString();if(!l&&k.isBlob(g))throw new me("Blob is not supported. Use a Buffer instead.");return k.isArrayBuffer(g)||k.isTypedArray(g)?l&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function u(g,m,y){let T=g;if(g&&!y&&typeof g=="object"){if(k.endsWith(m,"{}"))m=s?m:m.slice(0,-2),g=JSON.stringify(g);else if(k.isArray(g)&&c0(g)||(k.isFileList(g)||k.endsWith(m,"[]"))&&(T=k.toArray(g)))return m=Uc(m),T.forEach(function(v,R){!(k.isUndefined(v)||v===null)&&e.append(o===!0?xa([m],R,n):o===null?m:m+"[]",c(v))}),!1}return En(g)?!0:(e.append(xa(y,m,n),c(g)),!1)}const f=[],h=Object.assign(u0,{defaultVisitor:u,convertValue:c,isVisitable:En});function d(g,m){if(!k.isUndefined(g)){if(f.indexOf(g)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(g),k.forEach(g,function(T,x){(!(k.isUndefined(T)||T===null)&&r.call(e,T,k.isString(x)?x.trim():x,m,h))===!0&&d(T,m?m.concat(x):[x])}),f.pop()}}if(!k.isObject(i))throw new TypeError("data must be an object");return d(i),e}function Sa(i){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(i).replace(/[!'()~]|%20|%00/g,function(s){return e[s]})}function to(i,e){this._pairs=[],i&&hr(i,this,e)}const Bc=to.prototype;Bc.append=function(e,t){this._pairs.push([e,t])};Bc.toString=function(e){const t=e?function(s){return e.call(this,s,Sa)}:Sa;return this._pairs.map(function(r){return t(r[0])+"="+t(r[1])},"").join("&")};function f0(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function $c(i,e,t){if(!e)return i;const s=t&&t.encode||f0,r=t&&t.serialize;let n;if(r?n=r(e,t):n=k.isURLSearchParams(e)?e.toString():new to(e,t).toString(s),n){const o=i.indexOf("#");o!==-1&&(i=i.slice(0,o)),i+=(i.indexOf("?")===-1?"?":"&")+n}return i}class h0{constructor(){this.handlers=[]}use(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){k.forEach(this.handlers,function(s){s!==null&&e(s)})}}const va=h0,Gc={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},d0=typeof URLSearchParams<"u"?URLSearchParams:to,g0=typeof FormData<"u"?FormData:null,m0=typeof Blob<"u"?Blob:null,p0=(()=>{let i;return typeof navigator<"u"&&((i=navigator.product)==="ReactNative"||i==="NativeScript"||i==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),y0=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),mt={isBrowser:!0,classes:{URLSearchParams:d0,FormData:g0,Blob:m0},isStandardBrowserEnv:p0,isStandardBrowserWebWorkerEnv:y0,protocols:["http","https","file","blob","url","data"]};function T0(i,e){return hr(i,new mt.classes.URLSearchParams,Object.assign({visitor:function(t,s,r,n){return mt.isNode&&k.isBuffer(t)?(this.append(s,t.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},e))}function E0(i){return k.matchAll(/\w+|\[(\w*)]/g,i).map(e=>e[0]==="[]"?"":e[1]||e[0])}function x0(i){const e={},t=Object.keys(i);let s;const r=t.length;let n;for(s=0;s<r;s++)n=t[s],e[n]=i[n];return e}function Kc(i){function e(t,s,r,n){let o=t[n++];const a=Number.isFinite(+o),l=n>=t.length;return o=!o&&k.isArray(r)?r.length:o,l?(k.hasOwnProp(r,o)?r[o]=[r[o],s]:r[o]=s,!a):((!r[o]||!k.isObject(r[o]))&&(r[o]=[]),e(t,s,r[o],n)&&k.isArray(r[o])&&(r[o]=x0(r[o])),!a)}if(k.isFormData(i)&&k.isFunction(i.entries)){const t={};return k.forEachEntry(i,(s,r)=>{e(E0(s),r,t,0)}),t}return null}function S0(i,e,t){if(k.isString(i))try{return(e||JSON.parse)(i),k.trim(i)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(i)}const so={transitional:Gc,adapter:mt.isNode?"http":"xhr",transformRequest:[function(e,t){const s=t.getContentType()||"",r=s.indexOf("application/json")>-1,n=k.isObject(e);if(n&&k.isHTMLForm(e)&&(e=new FormData(e)),k.isFormData(e))return r&&r?JSON.stringify(Kc(e)):e;if(k.isArrayBuffer(e)||k.isBuffer(e)||k.isStream(e)||k.isFile(e)||k.isBlob(e))return e;if(k.isArrayBufferView(e))return e.buffer;if(k.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(n){if(s.indexOf("application/x-www-form-urlencoded")>-1)return T0(e,this.formSerializer).toString();if((a=k.isFileList(e))||s.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return hr(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return n||r?(t.setContentType("application/json",!1),S0(e)):e}],transformResponse:[function(e){const t=this.transitional||so.transitional,s=t&&t.forcedJSONParsing,r=this.responseType==="json";if(e&&k.isString(e)&&(s&&!this.responseType||r)){const o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?me.from(a,me.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:mt.classes.FormData,Blob:mt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};k.forEach(["delete","get","head","post","put","patch"],i=>{so.headers[i]={}});const io=so,v0=k.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),A0=i=>{const e={};let t,s,r;return i&&i.split(`
`).forEach(function(o){r=o.indexOf(":"),t=o.substring(0,r).trim().toLowerCase(),s=o.substring(r+1).trim(),!(!t||e[t]&&v0[t])&&(t==="set-cookie"?e[t]?e[t].push(s):e[t]=[s]:e[t]=e[t]?e[t]+", "+s:s)}),e},Aa=Symbol("internals");function Ns(i){return i&&String(i).trim().toLowerCase()}function wi(i){return i===!1||i==null?i:k.isArray(i)?i.map(wi):String(i)}function R0(i){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let s;for(;s=t.exec(i);)e[s[1]]=s[2];return e}const L0=i=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(i.trim());function Dr(i,e,t,s,r){if(k.isFunction(s))return s.call(this,e,t);if(r&&(e=t),!!k.isString(e)){if(k.isString(s))return e.indexOf(s)!==-1;if(k.isRegExp(s))return s.test(e)}}function b0(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,s)=>t.toUpperCase()+s)}function I0(i,e){const t=k.toCamelCase(" "+e);["get","set","has"].forEach(s=>{Object.defineProperty(i,s+t,{value:function(r,n,o){return this[s].call(this,e,r,n,o)},configurable:!0})})}class dr{constructor(e){e&&this.set(e)}set(e,t,s){const r=this;function n(a,l,c){const u=Ns(l);if(!u)throw new Error("header name must be a non-empty string");const f=k.findKey(r,u);(!f||r[f]===void 0||c===!0||c===void 0&&r[f]!==!1)&&(r[f||l]=wi(a))}const o=(a,l)=>k.forEach(a,(c,u)=>n(c,u,l));return k.isPlainObject(e)||e instanceof this.constructor?o(e,t):k.isString(e)&&(e=e.trim())&&!L0(e)?o(A0(e),t):e!=null&&n(t,e,s),this}get(e,t){if(e=Ns(e),e){const s=k.findKey(this,e);if(s){const r=this[s];if(!t)return r;if(t===!0)return R0(r);if(k.isFunction(t))return t.call(this,r,s);if(k.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Ns(e),e){const s=k.findKey(this,e);return!!(s&&this[s]!==void 0&&(!t||Dr(this,this[s],s,t)))}return!1}delete(e,t){const s=this;let r=!1;function n(o){if(o=Ns(o),o){const a=k.findKey(s,o);a&&(!t||Dr(s,s[a],a,t))&&(delete s[a],r=!0)}}return k.isArray(e)?e.forEach(n):n(e),r}clear(e){const t=Object.keys(this);let s=t.length,r=!1;for(;s--;){const n=t[s];(!e||Dr(this,this[n],n,e,!0))&&(delete this[n],r=!0)}return r}normalize(e){const t=this,s={};return k.forEach(this,(r,n)=>{const o=k.findKey(s,n);if(o){t[o]=wi(r),delete t[n];return}const a=e?b0(n):String(n).trim();a!==n&&delete t[n],t[a]=wi(r),s[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return k.forEach(this,(s,r)=>{s!=null&&s!==!1&&(t[r]=e&&k.isArray(s)?s.join(", "):s)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const s=new this(e);return t.forEach(r=>s.set(r)),s}static accessor(e){const s=(this[Aa]=this[Aa]={accessors:{}}).accessors,r=this.prototype;function n(o){const a=Ns(o);s[a]||(I0(r,o),s[a]=!0)}return k.isArray(e)?e.forEach(n):n(e),this}}dr.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);k.reduceDescriptors(dr.prototype,({value:i},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>i,set(s){this[t]=s}}});k.freezeMethods(dr);const Nt=dr;function _r(i,e){const t=this||io,s=e||t,r=Nt.from(s.headers);let n=s.data;return k.forEach(i,function(a){n=a.call(t,n,r.normalize(),e?e.status:void 0)}),r.normalize(),n}function Hc(i){return!!(i&&i.__CANCEL__)}function ai(i,e,t){me.call(this,i??"canceled",me.ERR_CANCELED,e,t),this.name="CanceledError"}k.inherits(ai,me,{__CANCEL__:!0});function D0(i,e,t){const s=t.config.validateStatus;!t.status||!s||s(t.status)?i(t):e(new me("Request failed with status code "+t.status,[me.ERR_BAD_REQUEST,me.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const _0=mt.isStandardBrowserEnv?function(){return{write:function(t,s,r,n,o,a){const l=[];l.push(t+"="+encodeURIComponent(s)),k.isNumber(r)&&l.push("expires="+new Date(r).toGMTString()),k.isString(n)&&l.push("path="+n),k.isString(o)&&l.push("domain="+o),a===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(t){const s=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return s?decodeURIComponent(s[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function C0(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function w0(i,e){return e?i.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):i}function Vc(i,e){return i&&!C0(e)?w0(i,e):e}const P0=mt.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let s;function r(n){let o=n;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return s=r(window.location.href),function(o){const a=k.isString(o)?r(o):o;return a.protocol===s.protocol&&a.host===s.host}}():function(){return function(){return!0}}();function k0(i){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return e&&e[1]||""}function O0(i,e){i=i||10;const t=new Array(i),s=new Array(i);let r=0,n=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),u=s[n];o||(o=c),t[r]=l,s[r]=c;let f=n,h=0;for(;f!==r;)h+=t[f++],f=f%i;if(r=(r+1)%i,r===n&&(n=(n+1)%i),c-o<e)return;const d=u&&c-u;return d?Math.round(h*1e3/d):void 0}}function Ra(i,e){let t=0;const s=O0(50,250);return r=>{const n=r.loaded,o=r.lengthComputable?r.total:void 0,a=n-t,l=s(a),c=n<=o;t=n;const u={loaded:n,total:o,progress:o?n/o:void 0,bytes:a,rate:l||void 0,estimated:l&&o&&c?(o-n)/l:void 0,event:r};u[e?"download":"upload"]=!0,i(u)}}const F0=typeof XMLHttpRequest<"u",N0=F0&&function(i){return new Promise(function(t,s){let r=i.data;const n=Nt.from(i.headers).normalize(),o=i.responseType;let a;function l(){i.cancelToken&&i.cancelToken.unsubscribe(a),i.signal&&i.signal.removeEventListener("abort",a)}k.isFormData(r)&&(mt.isStandardBrowserEnv||mt.isStandardBrowserWebWorkerEnv?n.setContentType(!1):n.setContentType("multipart/form-data;",!1));let c=new XMLHttpRequest;if(i.auth){const d=i.auth.username||"",g=i.auth.password?unescape(encodeURIComponent(i.auth.password)):"";n.set("Authorization","Basic "+btoa(d+":"+g))}const u=Vc(i.baseURL,i.url);c.open(i.method.toUpperCase(),$c(u,i.params,i.paramsSerializer),!0),c.timeout=i.timeout;function f(){if(!c)return;const d=Nt.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),m={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:d,config:i,request:c};D0(function(T){t(T),l()},function(T){s(T),l()},m),c=null}if("onloadend"in c?c.onloadend=f:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(f)},c.onabort=function(){c&&(s(new me("Request aborted",me.ECONNABORTED,i,c)),c=null)},c.onerror=function(){s(new me("Network Error",me.ERR_NETWORK,i,c)),c=null},c.ontimeout=function(){let g=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const m=i.transitional||Gc;i.timeoutErrorMessage&&(g=i.timeoutErrorMessage),s(new me(g,m.clarifyTimeoutError?me.ETIMEDOUT:me.ECONNABORTED,i,c)),c=null},mt.isStandardBrowserEnv){const d=(i.withCredentials||P0(u))&&i.xsrfCookieName&&_0.read(i.xsrfCookieName);d&&n.set(i.xsrfHeaderName,d)}r===void 0&&n.setContentType(null),"setRequestHeader"in c&&k.forEach(n.toJSON(),function(g,m){c.setRequestHeader(m,g)}),k.isUndefined(i.withCredentials)||(c.withCredentials=!!i.withCredentials),o&&o!=="json"&&(c.responseType=i.responseType),typeof i.onDownloadProgress=="function"&&c.addEventListener("progress",Ra(i.onDownloadProgress,!0)),typeof i.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Ra(i.onUploadProgress)),(i.cancelToken||i.signal)&&(a=d=>{c&&(s(!d||d.type?new ai(null,i,c):d),c.abort(),c=null)},i.cancelToken&&i.cancelToken.subscribe(a),i.signal&&(i.signal.aborted?a():i.signal.addEventListener("abort",a)));const h=k0(u);if(h&&mt.protocols.indexOf(h)===-1){s(new me("Unsupported protocol "+h+":",me.ERR_BAD_REQUEST,i));return}c.send(r||null)})},Pi={http:l0,xhr:N0};k.forEach(Pi,(i,e)=>{if(i){try{Object.defineProperty(i,"name",{value:e})}catch{}Object.defineProperty(i,"adapterName",{value:e})}});const Wc={getAdapter:i=>{i=k.isArray(i)?i:[i];const{length:e}=i;let t,s;for(let r=0;r<e&&(t=i[r],!(s=k.isString(t)?Pi[t.toLowerCase()]:t));r++);if(!s)throw s===!1?new me(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(k.hasOwnProp(Pi,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!k.isFunction(s))throw new TypeError("adapter is not a function");return s},adapters:Pi};function Cr(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new ai(null,i)}function La(i){return Cr(i),i.headers=Nt.from(i.headers),i.data=_r.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),Wc.getAdapter(i.adapter||io.adapter)(i).then(function(s){return Cr(i),s.data=_r.call(i,i.transformResponse,s),s.headers=Nt.from(s.headers),s},function(s){return Hc(s)||(Cr(i),s&&s.response&&(s.response.data=_r.call(i,i.transformResponse,s.response),s.response.headers=Nt.from(s.response.headers))),Promise.reject(s)})}const ba=i=>i instanceof Nt?i.toJSON():i;function Is(i,e){e=e||{};const t={};function s(c,u,f){return k.isPlainObject(c)&&k.isPlainObject(u)?k.merge.call({caseless:f},c,u):k.isPlainObject(u)?k.merge({},u):k.isArray(u)?u.slice():u}function r(c,u,f){if(k.isUndefined(u)){if(!k.isUndefined(c))return s(void 0,c,f)}else return s(c,u,f)}function n(c,u){if(!k.isUndefined(u))return s(void 0,u)}function o(c,u){if(k.isUndefined(u)){if(!k.isUndefined(c))return s(void 0,c)}else return s(void 0,u)}function a(c,u,f){if(f in e)return s(c,u);if(f in i)return s(void 0,c)}const l={url:n,method:n,data:n,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,u)=>r(ba(c),ba(u),!0)};return k.forEach(Object.keys(Object.assign({},i,e)),function(u){const f=l[u]||r,h=f(i[u],e[u],u);k.isUndefined(h)&&f!==a||(t[u]=h)}),t}const Yc="1.5.0",ro={};["object","boolean","number","function","string","symbol"].forEach((i,e)=>{ro[i]=function(s){return typeof s===i||"a"+(e<1?"n ":" ")+i}});const Ia={};ro.transitional=function(e,t,s){function r(n,o){return"[Axios v"+Yc+"] Transitional option '"+n+"'"+o+(s?". "+s:"")}return(n,o,a)=>{if(e===!1)throw new me(r(o," has been removed"+(t?" in "+t:"")),me.ERR_DEPRECATED);return t&&!Ia[o]&&(Ia[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(n,o,a):!0}};function M0(i,e,t){if(typeof i!="object")throw new me("options must be an object",me.ERR_BAD_OPTION_VALUE);const s=Object.keys(i);let r=s.length;for(;r-- >0;){const n=s[r],o=e[n];if(o){const a=i[n],l=a===void 0||o(a,n,i);if(l!==!0)throw new me("option "+n+" must be "+l,me.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new me("Unknown option "+n,me.ERR_BAD_OPTION)}}const xn={assertOptions:M0,validators:ro},Gt=xn.validators;class Gi{constructor(e){this.defaults=e,this.interceptors={request:new va,response:new va}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Is(this.defaults,t);const{transitional:s,paramsSerializer:r,headers:n}=t;s!==void 0&&xn.assertOptions(s,{silentJSONParsing:Gt.transitional(Gt.boolean),forcedJSONParsing:Gt.transitional(Gt.boolean),clarifyTimeoutError:Gt.transitional(Gt.boolean)},!1),r!=null&&(k.isFunction(r)?t.paramsSerializer={serialize:r}:xn.assertOptions(r,{encode:Gt.function,serialize:Gt.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=n&&k.merge(n.common,n[t.method]);n&&k.forEach(["delete","get","head","post","put","patch","common"],g=>{delete n[g]}),t.headers=Nt.concat(o,n);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(t)===!1||(l=l&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let u,f=0,h;if(!l){const g=[La.bind(this),void 0];for(g.unshift.apply(g,a),g.push.apply(g,c),h=g.length,u=Promise.resolve(t);f<h;)u=u.then(g[f++],g[f++]);return u}h=a.length;let d=t;for(f=0;f<h;){const g=a[f++],m=a[f++];try{d=g(d)}catch(y){m.call(this,y);break}}try{u=La.call(this,d)}catch(g){return Promise.reject(g)}for(f=0,h=c.length;f<h;)u=u.then(c[f++],c[f++]);return u}getUri(e){e=Is(this.defaults,e);const t=Vc(e.baseURL,e.url);return $c(t,e.params,e.paramsSerializer)}}k.forEach(["delete","get","head","options"],function(e){Gi.prototype[e]=function(t,s){return this.request(Is(s||{},{method:e,url:t,data:(s||{}).data}))}});k.forEach(["post","put","patch"],function(e){function t(s){return function(n,o,a){return this.request(Is(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:n,data:o}))}}Gi.prototype[e]=t(),Gi.prototype[e+"Form"]=t(!0)});const ki=Gi;class no{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(n){t=n});const s=this;this.promise.then(r=>{if(!s._listeners)return;let n=s._listeners.length;for(;n-- >0;)s._listeners[n](r);s._listeners=null}),this.promise.then=r=>{let n;const o=new Promise(a=>{s.subscribe(a),n=a}).then(r);return o.cancel=function(){s.unsubscribe(n)},o},e(function(n,o,a){s.reason||(s.reason=new ai(n,o,a),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new no(function(r){e=r}),cancel:e}}}const U0=no;function B0(i){return function(t){return i.apply(null,t)}}function $0(i){return k.isObject(i)&&i.isAxiosError===!0}const Sn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Sn).forEach(([i,e])=>{Sn[e]=i});const G0=Sn;function jc(i){const e=new ki(i),t=Dc(ki.prototype.request,e);return k.extend(t,ki.prototype,e,{allOwnKeys:!0}),k.extend(t,e,null,{allOwnKeys:!0}),t.create=function(r){return jc(Is(i,r))},t}const Oe=jc(io);Oe.Axios=ki;Oe.CanceledError=ai;Oe.CancelToken=U0;Oe.isCancel=Hc;Oe.VERSION=Yc;Oe.toFormData=hr;Oe.AxiosError=me;Oe.Cancel=Oe.CanceledError;Oe.all=function(e){return Promise.all(e)};Oe.spread=B0;Oe.isAxiosError=$0;Oe.mergeConfig=Is;Oe.AxiosHeaders=Nt;Oe.formToJSON=i=>Kc(k.isHTMLForm(i)?new FormData(i):i);Oe.getAdapter=Wc.getAdapter;Oe.HttpStatusCode=G0;Oe.default=Oe;const Da=Oe;function K0(i){const e=Da.create({baseURL:"https://hk.ynzhsk.cn/api/",timeout:5e3});return Da.defaults.withCredentials=!0,e.interceptors.request.use(t=>t,t=>{}),e.interceptors.response.use(t=>t.data,t=>{}),e(i)}function H0(i){return K0({url:"/reservoir/hkws/Isc/CameraUrlall",method:"post",data:i})}function V0(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var qc={exports:{}};(function(i,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,o=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(l,c,u){if(u=u||{},l=l.trim(),c=c.trim(),!c){if(!u.alwaysNormalize)return l;var f=a.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");return f.path=a.normalizePath(f.path),a.buildURLFromParts(f)}var h=a.parseURL(c);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=a.normalizePath(h.path),a.buildURLFromParts(h)):c;var d=a.parseURL(l);if(!d)throw new Error("Error trying to parse base URL.");if(!d.netLoc&&d.path&&d.path[0]!=="/"){var g=r.exec(d.path);d.netLoc=g[1],d.path=g[2]}d.netLoc&&!d.path&&(d.path="/");var m={scheme:d.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(m.netLoc=d.netLoc,h.path[0]!=="/"))if(!h.path)m.path=d.path,h.params||(m.params=d.params,h.query||(m.query=d.query));else{var y=d.path,T=y.substring(0,y.lastIndexOf("/")+1)+h.path;m.path=a.normalizePath(T)}return m.path===null&&(m.path=u.alwaysNormalize?a.normalizePath(h.path):h.path),a.buildURLFromParts(m)},parseURL:function(l){var c=s.exec(l);return c?{scheme:c[1]||"",netLoc:c[2]||"",path:c[3]||"",params:c[4]||"",query:c[5]||"",fragment:c[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(o,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=a})()})(qc);var oo=qc.exports;function _a(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,s)}return t}function et(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?_a(Object(t),!0).forEach(function(s){W0(i,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):_a(Object(t)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(t,s))})}return i}function W0(i,e,t){return e=j0(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ne(){return Ne=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},Ne.apply(this,arguments)}function Y0(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var s=t.call(i,e||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function j0(i){var e=Y0(i,"string");return typeof e=="symbol"?e:String(e)}const J=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)};let p=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i}({}),se=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),D=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const Zt=function(){},vn={trace:Zt,debug:Zt,log:Zt,warn:Zt,info:Zt,error:Zt};let Ys=vn;function q0(i){const e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Zt}function z0(i,...e){e.forEach(function(t){Ys[t]=i[t]?i[t].bind(i):q0(t)})}function X0(i,e){if(self.console&&i===!0||typeof i=="object"){z0(i,"debug","log","info","warn","error");try{Ys.log(`Debug logs enabled for "${e}" in hls.js version 1.4.12`)}catch{Ys=vn}}else Ys=vn}const A=Ys,Q0=/^(\d+)x(\d+)$/,Ca=/(.+?)=(".*?"|.*?)(?:,|$)/g;class _e{constructor(e){typeof e=="string"&&(e=_e.parseAttrList(e));for(const t in e)e.hasOwnProperty(t)&&(t.substring(0,2)==="X-"&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const s=new Uint8Array(t.length/2);for(let r=0;r<t.length/2;r++)s[r]=parseInt(t.slice(r*2,r*2+2),16);return s}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const s=this[e];return s?parseFloat(s):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=Q0.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const s={},r='"';for(Ca.lastIndex=0;(t=Ca.exec(e))!==null;){let n=t[2];n.indexOf(r)===0&&n.lastIndexOf(r)===n.length-1&&(n=n.slice(1,-1));const o=t[1].trim();s[o]=n}return s}}function J0(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function Z0(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class zc{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const s=t.attr;for(const r in s)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==s[r]){A.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=Ne(new _e({}),s,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const s=new Date(this.attr["END-DATE"]);J(s.getTime())&&(this._endDate=s)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(J(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&J(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class gr{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 Re={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Xc{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Re.AUDIO]:null,[Re.VIDEO]:null,[Re.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const s=e.split("@",2),r=[];s.length===1?r[0]=t?t.byteRangeEndOffset:0:r[0]=parseInt(s[1]),r[1]=parseInt(s[0])+r[0],this._byteRange=r}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=oo.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class wr extends Xc{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new gr,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const s=Object.keys(this.levelkeys);if(s.length===1)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!J(this.programDateTime))return null;const e=J(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,s,r,n,o=!1){const{elementaryStreams:a}=this,l=a[e];if(!l){a[e]={startPTS:t,endPTS:s,startDTS:r,endDTS:n,partial:o};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,s),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[Re.AUDIO]=null,e[Re.VIDEO]=null,e[Re.AUDIOVIDEO]=null}}class em extends Xc{constructor(e,t,s,r,n){super(s),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 gr,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=r;const o=e.enumeratedString("BYTERANGE");o&&this.setByteRange(o,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}const tm=10;class sm{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,s=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!s||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&s>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?J(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||tm}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function ao(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function im(i){const e=Qc(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function rm(i){const e=function(s,r,n){const o=s[r];s[r]=s[n],s[n]=o};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function nm(i){const e=i.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),r=s[s.length-1].split(",");if(r.length===2){const n=r[0]==="base64",o=r[1];n?(s.splice(-1,1),t=ao(o)):t=im(o)}}return t}function Qc(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}var Ce={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Qe={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function wa(i){switch(i){case Qe.FAIRPLAY:return Ce.FAIRPLAY;case Qe.PLAYREADY:return Ce.PLAYREADY;case Qe.WIDEVINE:return Ce.WIDEVINE;case Qe.CLEARKEY:return Ce.CLEARKEY}}var Jc={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function om(i){if(i===Jc.WIDEVINE)return Ce.WIDEVINE}function Pa(i){switch(i){case Ce.FAIRPLAY:return Qe.FAIRPLAY;case Ce.PLAYREADY:return Qe.PLAYREADY;case Ce.WIDEVINE:return Qe.WIDEVINE;case Ce.CLEARKEY:return Qe.CLEARKEY}}function Pr(i){const{drmSystems:e,widevineLicenseUrl:t}=i,s=e?[Ce.FAIRPLAY,Ce.WIDEVINE,Ce.PLAYREADY,Ce.CLEARKEY].filter(r=>!!e[r]):[];return!s[Ce.WIDEVINE]&&t&&s.push(Ce.WIDEVINE),s}const Zc=function(){return typeof self<"u"&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function am(i,e,t,s){let r;switch(i){case Ce.FAIRPLAY:r=["cenc","sinf"];break;case Ce.WIDEVINE:case Ce.PLAYREADY:r=["cenc"];break;case Ce.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return lm(r,e,t,s)}function lm(i,e,t,s){return[{initDataTypes:i,persistentState:s.persistentState||"not-allowed",distinctiveIdentifier:s.distinctiveIdentifier||"not-allowed",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function os(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}const lo=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,eu=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ki=(i,e)=>{const t=e;let s=0;for(;lo(i,e);){s+=10;const r=mr(i,e+6);s+=r,eu(i,e+10)&&(s+=10),e+=s}if(s>0)return i.subarray(t,t+s)},mr=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},cm=(i,e)=>lo(i,e)&&mr(i,e+6)+10<=i.length-e,um=i=>{const e=su(i);for(let t=0;t<e.length;t++){const s=e[t];if(tu(s))return pm(s)}},tu=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",fm=i=>{const e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=mr(i,4),s=10;return{type:e,size:t,data:i.subarray(s,s+t)}},su=i=>{let e=0;const t=[];for(;lo(i,e);){const s=mr(i,e+6);e+=10;const r=e+s;for(;e+8<r;){const n=fm(i.subarray(e)),o=hm(n);o&&t.push(o),e+=n.size+10}eu(i,e)&&(e+=10)}return t},hm=i=>i.type==="PRIV"?dm(i):i.type[0]==="W"?mm(i):gm(i),dm=i=>{if(i.size<2)return;const e=bt(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},gm=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1;const s=bt(i.data.subarray(t),!0);t+=s.length+1;const r=bt(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=bt(i.data.subarray(1));return{key:i.type,data:e}},mm=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1;const s=bt(i.data.subarray(t),!0);t+=s.length+1;const r=bt(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=bt(i.data);return{key:i.type,data:e}},pm=i=>{if(i.data.byteLength===8){const e=new Uint8Array(i.data),t=e[3]&1;let s=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return s/=45,t&&(s+=4772185884e-2),Math.round(s)}},bt=(i,e=!1)=>{const t=ym();if(t){const c=t.decode(i);if(e){const u=c.indexOf("\0");return u!==-1?c.substring(0,u):c}return c.replace(/\0/g,"")}const s=i.length;let r,n,o,a="",l=0;for(;l<s;){if(r=i[l++],r===0&&e)return a;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(r);break;case 12:case 13:n=i[l++],a+=String.fromCharCode((r&31)<<6|n&63);break;case 14:n=i[l++],o=i[l++],a+=String.fromCharCode((r&15)<<12|(n&63)<<6|(o&63)<<0);break}}return a};let kr;function ym(){return!kr&&typeof self.TextDecoder<"u"&&(kr=new self.TextDecoder("utf-8")),kr}const St={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let s=i[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}},Hi=Math.pow(2,32)-1,Tm=[].push,iu={video:1,audio:2,id3:3,text:4};function Be(i){return String.fromCharCode.apply(null,i)}function ru(i,e){const t=i[e]<<8|i[e+1];return t<0?65536+t:t}function re(i,e){const t=nu(i,e);return t<0?4294967296+t:t}function nu(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Or(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function pe(i,e){const t=[];if(!e.length)return t;const s=i.byteLength;for(let r=0;r<s;){const n=re(i,r),o=Be(i.subarray(r+4,r+8)),a=n>1?r+n:s;if(o===e[0])if(e.length===1)t.push(i.subarray(r+8,a));else{const l=pe(i.subarray(r+8,a),e.slice(1));l.length&&Tm.apply(t,l)}r=a}return t}function Em(i){const e=[],t=i[0];let s=8;const r=re(i,s);s+=4;const n=0,o=0;t===0?s+=8:s+=16,s+=2;let a=i.length+o;const l=ru(i,s);s+=2;for(let c=0;c<l;c++){let u=s;const f=re(i,u);u+=4;const h=f&2147483647;if((f&2147483648)>>>31===1)return A.warn("SIDX has hierarchical references (not supported)"),null;const g=re(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:g,info:{duration:g/r,start:a,end:a+h-1}}),a+=h,u+=4,s=u}return{earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function ou(i){const e=[],t=pe(i,["moov","trak"]);for(let r=0;r<t.length;r++){const n=t[r],o=pe(n,["tkhd"])[0];if(o){let a=o[0],l=a===0?12:20;const c=re(o,l),u=pe(n,["mdia","mdhd"])[0];if(u){a=u[0],l=a===0?12:20;const f=re(u,l),h=pe(n,["mdia","hdlr"])[0];if(h){const d=Be(h.subarray(8,12)),g={soun:Re.AUDIO,vide:Re.VIDEO}[d];if(g){const m=pe(n,["mdia","minf","stbl","stsd"])[0];let y;m&&(y=Be(m.subarray(12,16))),e[c]={timescale:f,type:g},e[g]={timescale:f,id:c,codec:y}}}}}}return pe(i,["moov","mvex","trex"]).forEach(r=>{const n=re(r,4),o=e[n];o&&(o.default={duration:re(r,12),flags:re(r,20)})}),e}function xm(i,e){if(!i||!e)return i;const t=e.keyId;return t&&e.isCommonEncryption&&pe(i,["moov","trak"]).forEach(r=>{const o=pe(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let a=pe(o,["enca"]);const l=a.length>0;l||(a=pe(o,["encv"])),a.forEach(c=>{const u=l?c.subarray(28):c.subarray(78);pe(u,["sinf"]).forEach(h=>{const d=au(h);if(d){const g=d.subarray(8,24);g.some(m=>m!==0)||(A.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${St.hexDump(g)} -> ${St.hexDump(t)}`),d.set(t,8))}})})}),i}function au(i){const e=pe(i,["schm"])[0];if(e){const t=Be(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return pe(i,["schi","tenc"])[0]}return A.error("[eme] missing 'schm' box"),null}function Sm(i,e){return pe(e,["moof","traf"]).reduce((t,s)=>{const r=pe(s,["tfdt"])[0],n=r[0],o=pe(s,["tfhd"]).reduce((a,l)=>{const c=re(l,4),u=i[c];if(u){let f=re(r,4);if(n===1){if(f===Hi)return A.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),a;f*=Hi+1,f+=re(r,8)}const h=u.timescale||9e4,d=f/h;if(isFinite(d)&&(a===null||d<a))return d}return a},null);return o!==null&&isFinite(o)&&(t===null||o<t)?o:t},null)}function vm(i,e){let t=0,s=0,r=0;const n=pe(i,["moof","traf"]);for(let o=0;o<n.length;o++){const a=n[o],l=pe(a,["tfhd"])[0],c=re(l,4),u=e[c];if(!u)continue;const f=u.default,h=re(l,0)|(f==null?void 0:f.flags);let d=f==null?void 0:f.duration;h&8&&(h&2?d=re(l,12):d=re(l,8));const g=u.timescale||9e4,m=pe(a,["trun"]);for(let y=0;y<m.length;y++){if(t=Am(m[y]),!t&&d){const T=re(m[y],4);t=d*T}u.type===Re.VIDEO?s+=t/g:u.type===Re.AUDIO&&(r+=t/g)}}if(s===0&&r===0){let o=0;const a=pe(i,["sidx"]);for(let l=0;l<a.length;l++){const c=Em(a[l]);c!=null&&c.references&&(o+=c.references.reduce((u,f)=>u+f.info.duration||0,0))}return o}return s||r}function Am(i){const e=re(i,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const r=re(i,4);for(let n=0;n<r;n++){if(e&256){const o=re(i,t);s+=o,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function Rm(i,e,t){pe(e,["moof","traf"]).forEach(s=>{pe(s,["tfhd"]).forEach(r=>{const n=re(r,4),o=i[n];if(!o)return;const a=o.timescale||9e4;pe(s,["tfdt"]).forEach(l=>{const c=l[0];let u=re(l,4);if(c===0)u-=t*a,u=Math.max(u,0),Or(l,4,u);else{u*=Math.pow(2,32),u+=re(l,8),u-=t*a,u=Math.max(u,0);const f=Math.floor(u/(Hi+1)),h=Math.floor(u%(Hi+1));Or(l,4,f),Or(l,8,h)}})})})}function Lm(i){const e={valid:null,remainder:null},t=pe(i,["moof"]);if(t){if(t.length<2)return e.remainder=i,e}else return e;const s=t[t.length-1];return e.valid=os(i,0,s.byteOffset-8),e.remainder=os(i,s.byteOffset-8),e}function ls(i,e){const t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function ka(i,e){const t=[],s=e.samples,r=e.timescale,n=e.id;let o=!1;return pe(s,["moof"]).map(l=>{const c=l.byteOffset-8;pe(l,["traf"]).map(f=>{const h=pe(f,["tfdt"]).map(d=>{const g=d[0];let m=re(d,4);return g===1&&(m*=Math.pow(2,32),m+=re(d,8)),m/r})[0];return h!==void 0&&(i=h),pe(f,["tfhd"]).map(d=>{const g=re(d,4),m=re(d,0)&16777215,y=(m&1)!==0,T=(m&2)!==0,x=(m&8)!==0;let v=0;const R=(m&16)!==0;let b=0;const M=(m&32)!==0;let P=8;g===n&&(y&&(P+=8),T&&(P+=4),x&&(v=re(d,P),P+=4),R&&(b=re(d,P),P+=4),M&&(P+=4),e.type==="video"&&(o=bm(e.codec)),pe(f,["trun"]).map(B=>{const K=B[0],_=re(B,0)&16777215,q=(_&1)!==0;let W=0;const ue=(_&4)!==0,we=(_&256)!==0;let Te=0;const ae=(_&512)!==0;let te=0;const $=(_&1024)!==0,z=(_&2048)!==0;let fe=0;const he=re(B,4);let ne=8;q&&(W=re(B,ne),ne+=4),ue&&(ne+=4);let Le=W+c;for(let Fe=0;Fe<he;Fe++){if(we?(Te=re(B,ne),ne+=4):Te=v,ae?(te=re(B,ne),ne+=4):te=b,$&&(ne+=4),z&&(K===0?fe=re(B,ne):fe=nu(B,ne),ne+=4),e.type===Re.VIDEO){let Ke=0;for(;Ke<te;){const Se=re(s,Le);if(Le+=4,Im(o,s[Le])){const w=s.subarray(Le,Le+Se);lu(w,o?2:1,i+fe/r,t)}Le+=Se,Ke+=Se+4}}i+=Te/r}}))})})}),t}function bm(i){if(!i)return!1;const e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function Im(i,e){if(i){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function lu(i,e,t,s){const r=cu(i);let n=0;n+=e;let o=0,a=0,l=!1,c=0;for(;n<r.length;){o=0;do{if(n>=r.length)break;c=r[n++],o+=c}while(c===255);a=0;do{if(n>=r.length)break;c=r[n++],a+=c}while(c===255);const u=r.length-n;if(!l&&o===4&&n<r.length){if(l=!0,r[n++]===181){const h=ru(r,n);if(n+=2,h===49){const d=re(r,n);if(n+=4,d===1195456820){const g=r[n++];if(g===3){const m=r[n++],y=31&m,T=64&m,x=T?2+y*3:0,v=new Uint8Array(x);if(T){v[0]=m;for(let R=1;R<x;R++)v[R]=r[n++]}s.push({type:g,payloadType:o,pts:t,bytes:v})}}}}}else if(o===5&&a<u){if(l=!0,a>16){const f=[];for(let g=0;g<16;g++){const m=r[n++].toString(16);f.push(m.length==1?"0"+m:m),(g===3||g===5||g===7||g===9)&&f.push("-")}const h=a-16,d=new Uint8Array(h);for(let g=0;g<h;g++)d[g]=r[n++];s.push({payloadType:o,pts:t,uuid:f.join(""),userData:bt(d),userDataBytes:d})}}else if(a<u)n+=a;else if(a>u)break}}function cu(i){const e=i.byteLength,t=[];let s=1;for(;s<e-2;)i[s]===0&&i[s+1]===0&&i[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return i;const r=e-t.length,n=new Uint8Array(r);let o=0;for(s=0;s<r;o++,s++)o===t[0]&&(o++,t.shift()),n[s]=i[o];return n}function Dm(i){const e=i[0];let t="",s="",r=0,n=0,o=0,a=0,l=0,c=0;if(e===0){for(;Be(i.subarray(c,c+1))!=="\0";)t+=Be(i.subarray(c,c+1)),c+=1;for(t+=Be(i.subarray(c,c+1)),c+=1;Be(i.subarray(c,c+1))!=="\0";)s+=Be(i.subarray(c,c+1)),c+=1;s+=Be(i.subarray(c,c+1)),c+=1,r=re(i,12),n=re(i,16),a=re(i,20),l=re(i,24),c=28}else if(e===1){c+=4,r=re(i,c),c+=4;const f=re(i,c);c+=4;const h=re(i,c);for(c+=4,o=2**32*f+h,Number.isSafeInteger(o)||(o=Number.MAX_SAFE_INTEGER,A.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=re(i,c),c+=4,l=re(i,c),c+=4;Be(i.subarray(c,c+1))!=="\0";)t+=Be(i.subarray(c,c+1)),c+=1;for(t+=Be(i.subarray(c,c+1)),c+=1;Be(i.subarray(c,c+1))!=="\0";)s+=Be(i.subarray(c,c+1)),c+=1;s+=Be(i.subarray(c,c+1)),c+=1}const u=i.subarray(c,i.byteLength);return{schemeIdUri:t,value:s,timeScale:r,presentationTime:o,presentationTimeDelta:n,eventDuration:a,id:l,payload:u}}function _m(i,...e){const t=e.length;let s=8,r=t;for(;r--;)s+=e[r].byteLength;const n=new Uint8Array(s);for(n[0]=s>>24&255,n[1]=s>>16&255,n[2]=s>>8&255,n[3]=s&255,n.set(i,4),r=0,s=8;r<t;r++)n.set(e[r],s),s+=e[r].byteLength;return n}function Cm(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let s,r;if(e){s=1,r=new Uint8Array(e.length*16);for(let a=0;a<e.length;a++){const l=e[a];if(l.byteLength!==16)throw new RangeError("Invalid key");r.set(l,a*16)}}else s=0,r=new Uint8Array;let n;s>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const o=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(o.buffer).setUint32(0,t.byteLength,!1),_m([112,115,115,104],new Uint8Array([s,0,0,0]),i,n,r,o,t||new Uint8Array)}function wm(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),s=t.getUint32(0);if(i.byteLength!==s&&s>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=St.hexDump(new Uint8Array(i,12,16));const n=t.getUint32(28);if(e.version===0){if(s-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let o=0;o<n;o++)e.kids.push(new Uint8Array(i,32+o*16,16))}return e}let gi={};class ii{static clearKeyUriToKeyIdMap(){gi={}}constructor(e,t,s,r=[1],n=null){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=e,this.uri=t,this.keyFormat=s,this.keyFormatVersions=r,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case Qe.FAIRPLAY:case Qe.WIDEVINE:case Qe.PLAYREADY:case Qe.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&A.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const s=Pm(e);return new ii(this.method,this.uri,"identity",this.keyFormatVersions,s)}const t=nm(this.uri);if(t)switch(this.keyFormat){case Qe.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Qe.PLAYREADY:{const s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Cm(s,null,t);const r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),o=n.substring(n.indexOf("<"),n.length),c=new DOMParser().parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(c){const u=c.childNodes[0]?c.childNodes[0].nodeValue:c.getAttribute("VALUE");if(u){const f=ao(u).subarray(0,16);rm(f),this.keyId=f}}break}default:{let s=t.subarray(0,16);if(s.length!==16){const r=new Uint8Array(16);r.set(s,16-s.length),s=r}this.keyId=s;break}}if(!this.keyId||this.keyId.byteLength!==16){let s=gi[this.uri];if(!s){const r=Object.keys(gi).length%Number.MAX_SAFE_INTEGER;s=new Uint8Array(16),new DataView(s.buffer,12,4).setUint32(0,r),gi[this.uri]=s}this.keyId=s}return this}}function Pm(i){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}const uu=/\{\$([a-zA-Z0-9-_]+)\}/g;function Oa(i){return uu.test(i)}function ze(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let s=t.length;s--;){const r=t[s],n=e[r];n&&(e[r]=An(i,n))}}function An(i,e){if(i.variableList!==null||i.hasVariableRefs){const t=i.variableList;return e.replace(uu,s=>{const r=s.substring(2,s.length-1),n=t==null?void 0:t[r];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),s):n})}return e}function Fa(i,e,t){let s=i.variableList;s||(i.variableList=s={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const o=new self.URL(t).searchParams;if(o.has(r))n=o.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(o){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${o.message}`))}}else r=e.NAME,n=e.VALUE;r in s?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=n||""}function km(i,e,t){const s=e.IMPORT;if(t&&s in t){let r=i.variableList;r||(i.variableList=r={}),r[s]=t[s]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function pr(){if(!(typeof self>"u"))return self.MediaSource||self.WebKitMediaSource}const Om={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}},Na=pr();function Fm(i,e){const t=Om[e];return!!t&&t[i.slice(0,4)]===!0}function Fr(i,e){var t;return(t=Na==null?void 0:Na.isTypeSupported(`${e||"video"}/mp4;codecs="${i}"`))!=null?t:!1}const Ma=/#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,Ua=/#EXT-X-MEDIA:(.*)/g,Nm=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ba=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Mm=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 dt{static findGroup(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(r.id===t)return r}}static convertAVC1ToAVCOTI(e){const t=e.split(".");if(t.length>2){let s=t.shift()+".";return s+=parseInt(t.shift()).toString(16),s+=("000"+parseInt(t.shift()).toString(16)).slice(-4),s}return e}static resolve(e,t){return oo.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Nm.test(e)}static parseMasterPlaylist(e,t){const s=Oa(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},n=[];Ma.lastIndex=0;let o;for(;(o=Ma.exec(e))!=null;)if(o[1]){var a;const c=new _e(o[1]);ze(r,c,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const u=An(r,o[2]),f={attrs:c,bitrate:c.decimalInteger("AVERAGE-BANDWIDTH")||c.decimalInteger("BANDWIDTH"),name:c.NAME,url:dt.resolve(u,t)},h=c.decimalResolution("RESOLUTION");h&&(f.width=h.width,f.height=h.height),Um((c.CODECS||"").split(/[ ,]+/).filter(d=>d),f),f.videoCodec&&f.videoCodec.indexOf("avc1")!==-1&&(f.videoCodec=dt.convertAVC1ToAVCOTI(f.videoCodec)),(a=f.unknownCodecs)!=null&&a.length||n.push(f),r.levels.push(f)}else if(o[3]){const c=o[3],u=o[4];switch(c){case"SESSION-DATA":{const f=new _e(u);ze(r,f,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=f["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=f);break}case"SESSION-KEY":{const f=$a(u,t,r);f.encrypted&&f.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(f)):A.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{const f=new _e(u);ze(r,f,["NAME","VALUE","QUERYPARAM"]),Fa(r,f,t)}break}case"CONTENT-STEERING":{const f=new _e(u);ze(r,f,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:dt.resolve(f["SERVER-URI"],t),pathwayId:f["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=Ga(u);break}}}const l=n.length>0&&n.length<r.levels.length;return r.levels=l?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,s){let r;const n={},o=s.levels,a={AUDIO:o.map(c=>({id:c.attrs.AUDIO,audioCodec:c.audioCodec})),SUBTITLES:o.map(c=>({id:c.attrs.SUBTITLES,textCodec:c.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Ua.lastIndex=0;(r=Ua.exec(e))!==null;){const c=new _e(r[1]),u=c.TYPE;if(u){const f=a[u],h=n[u]||[];n[u]=h,ze(s,c,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const d={attrs:c,bitrate:0,id:l++,groupId:c["GROUP-ID"]||"",instreamId:c["INSTREAM-ID"],name:c.NAME||c.LANGUAGE||"",type:u,default:c.bool("DEFAULT"),autoselect:c.bool("AUTOSELECT"),forced:c.bool("FORCED"),lang:c.LANGUAGE,url:c.URI?dt.resolve(c.URI,t):""};if(f!=null&&f.length){const g=dt.findGroup(f,d.groupId)||f[0];Ka(d,g,"audioCodec"),Ka(d,g,"textCodec")}h.push(d)}}return n}static parseLevelPlaylist(e,t,s,r,n,o){const a=new sm(t),l=a.fragments;let c=null,u=0,f=0,h=0,d=0,g=null,m=new wr(r,t),y,T,x,v=-1,R=!1;for(Ba.lastIndex=0,a.m3u8=e,a.hasVariableRefs=Oa(e);(y=Ba.exec(e))!==null;){R&&(R=!1,m=new wr(r,t),m.start=h,m.sn=u,m.cc=d,m.level=s,c&&(m.initSegment=c,m.rawProgramDateTime=c.rawProgramDateTime,c.rawProgramDateTime=null));const B=y[1];if(B){m.duration=parseFloat(B);const K=(" "+y[2]).slice(1);m.title=K||null,m.tagList.push(K?["INF",B,K]:["INF",B])}else if(y[3]){if(J(m.duration)){m.start=h,x&&Wa(m,x,a),m.sn=u,m.level=s,m.cc=d,m.urlId=n,l.push(m);const K=(" "+y[3]).slice(1);m.relurl=An(a,K),Ha(m,g),g=m,h+=m.duration,u++,f=0,R=!0}}else if(y[4]){const K=(" "+y[4]).slice(1);g?m.setByteRange(K,g):m.setByteRange(K)}else if(y[5])m.rawProgramDateTime=(" "+y[5]).slice(1),m.tagList.push(["PROGRAM-DATE-TIME",m.rawProgramDateTime]),v===-1&&(v=l.length);else{if(y=y[0].match(Mm),!y){A.warn("No matches on slow regex match for level playlist!");continue}for(T=1;T<y.length&&!(typeof y[T]<"u");T++);const K=(" "+y[T]).slice(1),_=(" "+y[T+1]).slice(1),q=y[T+2]?(" "+y[T+2]).slice(1):"";switch(K){case"PLAYLIST-TYPE":a.type=_.toUpperCase();break;case"MEDIA-SEQUENCE":u=a.startSN=parseInt(_);break;case"SKIP":{const W=new _e(_);ze(a,W,["RECENTLY-REMOVED-DATERANGES"]);const ue=W.decimalInteger("SKIPPED-SEGMENTS");if(J(ue)){a.skippedSegments=ue;for(let Te=ue;Te--;)l.unshift(null);u+=ue}const we=W.enumeratedString("RECENTLY-REMOVED-DATERANGES");we&&(a.recentlyRemovedDateranges=we.split("	"));break}case"TARGETDURATION":a.targetduration=Math.max(parseInt(_),1);break;case"VERSION":a.version=parseInt(_);break;case"EXTM3U":break;case"ENDLIST":a.live=!1;break;case"#":(_||q)&&m.tagList.push(q?[_,q]:[_]);break;case"DISCONTINUITY":d++,m.tagList.push(["DIS"]);break;case"GAP":m.gap=!0,m.tagList.push([K]);break;case"BITRATE":m.tagList.push([K,_]);break;case"DATERANGE":{const W=new _e(_);ze(a,W,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),ze(a,W,W.clientAttrs);const ue=new zc(W,a.dateRanges[W.ID]);ue.isValid||a.skippedSegments?a.dateRanges[ue.id]=ue:A.warn(`Ignoring invalid DATERANGE tag: "${_}"`),m.tagList.push(["EXT-X-DATERANGE",_]);break}case"DEFINE":{{const W=new _e(_);ze(a,W,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in W?km(a,W,o):Fa(a,W,t)}break}case"DISCONTINUITY-SEQUENCE":d=parseInt(_);break;case"KEY":{const W=$a(_,t,a);if(W.isSupported()){if(W.method==="NONE"){x=void 0;break}x||(x={}),x[W.keyFormat]&&(x=Ne({},x)),x[W.keyFormat]=W}else A.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${_}"`);break}case"START":a.startTimeOffset=Ga(_);break;case"MAP":{const W=new _e(_);if(ze(a,W,["BYTERANGE","URI"]),m.duration){const ue=new wr(r,t);Va(ue,W,s,x),c=ue,m.initSegment=c,c.rawProgramDateTime&&!m.rawProgramDateTime&&(m.rawProgramDateTime=c.rawProgramDateTime)}else Va(m,W,s,x),c=m,R=!0;break}case"SERVER-CONTROL":{const W=new _e(_);a.canBlockReload=W.bool("CAN-BLOCK-RELOAD"),a.canSkipUntil=W.optionalFloat("CAN-SKIP-UNTIL",0),a.canSkipDateRanges=a.canSkipUntil>0&&W.bool("CAN-SKIP-DATERANGES"),a.partHoldBack=W.optionalFloat("PART-HOLD-BACK",0),a.holdBack=W.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const W=new _e(_);a.partTarget=W.decimalFloatingPoint("PART-TARGET");break}case"PART":{let W=a.partList;W||(W=a.partList=[]);const ue=f>0?W[W.length-1]:void 0,we=f++,Te=new _e(_);ze(a,Te,["BYTERANGE","URI"]);const ae=new em(Te,m,t,we,ue);W.push(ae),m.duration+=ae.duration;break}case"PRELOAD-HINT":{const W=new _e(_);ze(a,W,["URI"]),a.preloadHint=W;break}case"RENDITION-REPORT":{const W=new _e(_);ze(a,W,["URI"]),a.renditionReports=a.renditionReports||[],a.renditionReports.push(W);break}default:A.warn(`line parsed but not handled: ${y}`);break}}}g&&!g.relurl?(l.pop(),h-=g.duration,a.partList&&(a.fragmentHint=g)):a.partList&&(Ha(m,g),m.cc=d,a.fragmentHint=m,x&&Wa(m,x,a));const b=l.length,M=l[0],P=l[b-1];if(h+=a.skippedSegments*a.targetduration,h>0&&b&&P){a.averagetargetduration=h/b;const B=P.sn;a.endSN=B!=="initSegment"?B:0,a.live||(P.endList=!0),M&&(a.startCC=M.cc)}else a.endSN=0,a.startCC=0;return a.fragmentHint&&(h+=a.fragmentHint.duration),a.totalduration=h,a.endCC=d,v>0&&Bm(l,v),a}}function $a(i,e,t){var s,r;const n=new _e(i);ze(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=(s=n.METHOD)!=null?s:"",a=n.URI,l=n.hexadecimalInteger("IV"),c=n.KEYFORMATVERSIONS,u=(r=n.KEYFORMAT)!=null?r:"identity";a&&n.IV&&!l&&A.error(`Invalid IV: ${n.IV}`);const f=a?dt.resolve(a,e):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new ii(o,f,u,h,l)}function Ga(i){const t=new _e(i).decimalFloatingPoint("TIME-OFFSET");return J(t)?t:null}function Um(i,e){["video","audio","text"].forEach(t=>{const s=i.filter(r=>Fm(r,t));if(s.length){const r=s.filter(n=>n.lastIndexOf("avc1",0)===0||n.lastIndexOf("mp4a",0)===0);e[`${t}Codec`]=r.length>0?r[0]:s[0],i=i.filter(n=>s.indexOf(n)===-1)}}),e.unknownCodecs=i}function Ka(i,e,t){const s=e[t];s&&(i[t]=s)}function Bm(i,e){let t=i[e];for(let s=e;s--;){const r=i[s];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function Ha(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),J(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function Va(i,e,t,s){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",s&&(i.levelkeys=s),i.initSegment=null}function Wa(i,e,t){i.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&s.push(i)}var ye={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ie={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Ya(i){const{type:e}=i;switch(e){case ye.AUDIO_TRACK:return ie.AUDIO;case ye.SUBTITLE_TRACK:return ie.SUBTITLE;default:return ie.MAIN}}function Nr(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class $m{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(p.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,r=t.loader,n=s||r,o=new n(t);return this.loaders[e.type]=o,o}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:s}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ye.MANIFEST,url:s,deliveryDirectives:null})}onLevelLoading(e,t){const{id:s,level:r,url:n,deliveryDirectives:o}=t;this.load({id:s,level:r,responseType:"text",type:ye.LEVEL,url:n,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:o}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:ye.AUDIO_TRACK,url:n,deliveryDirectives:o})}onSubtitleTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:o}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:ye.SUBTITLE_TRACK,url:n,deliveryDirectives:o})}load(e){var t;const s=this.hls.config;let r=this.getInternalLoader(e);if(r){const c=r.context;if(c&&c.url===e.url){A.trace("[playlist-loader]: playlist request ongoing");return}A.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let n;if(e.type===ye.MANIFEST?n=s.manifestLoadPolicy.default:n=Ne({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),(t=e.deliveryDirectives)!=null&&t.part){let c;if(e.type===ye.LEVEL&&e.level!==null?c=this.hls.levels[e.level].details:e.type===ye.AUDIO_TRACK&&e.id!==null?c=this.hls.audioTracks[e.id].details:e.type===ye.SUBTITLE_TRACK&&e.id!==null&&(c=this.hls.subtitleTracks[e.id].details),c){const u=c.partTarget,f=c.targetduration;if(u&&f){const h=Math.max(u*3,f*.8)*1e3;n=Ne({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const o=n.errorRetry||n.timeoutRetry||{},a={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(c,u,f,h)=>{const d=this.getInternalLoader(f);this.resetInternalLoader(f.type);const g=c.data;if(g.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(c,f,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),dt.isMediaPlaylist(g)?this.handleTrackOrLevelPlaylist(c,u,f,h||null,d):this.handleMasterPlaylist(c,u,f,h)},onError:(c,u,f,h)=>{this.handleNetworkError(u,f,!1,c,h)},onTimeout:(c,u,f)=>{this.handleNetworkError(u,f,!0,void 0,c)}};r.load(e,a,l)}handleMasterPlaylist(e,t,s,r){const n=this.hls,o=e.data,a=Nr(e,s),l=dt.parseMasterPlaylist(o,a);if(l.playlistParsingError){this.handleManifestParsingError(e,s,l.playlistParsingError,r,t);return}const{contentSteering:c,levels:u,sessionData:f,sessionKeys:h,startTimeOffset:d,variableList:g}=l;this.variableList=g;const{AUDIO:m=[],SUBTITLES:y,"CLOSED-CAPTIONS":T}=dt.parseMasterPlaylistMedia(o,a,l);m.length&&!m.some(v=>!v.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(A.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new _e({}),bitrate:0,url:""})),n.trigger(p.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:y,captions:T,contentSteering:c,url:a,stats:t,networkDetails:r,sessionData:f,sessionKeys:h,startTimeOffset:d,variableList:g})}handleTrackOrLevelPlaylist(e,t,s,r,n){const o=this.hls,{id:a,level:l,type:c}=s,u=Nr(e,s),f=J(a)?a:0,h=J(l)?l:f,d=Ya(s),g=dt.parseLevelPlaylist(e.data,u,h,d,f,this.variableList);if(c===ye.MANIFEST){const m={attrs:new _e({}),bitrate:0,details:g,name:"",url:u};o.trigger(p.MANIFEST_LOADED,{levels:[m],audioTracks:[],url:u,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=g,this.handlePlaylistLoaded(g,e,t,s,r,n)}handleManifestParsingError(e,t,s,r,n){this.hls.trigger(p.ERROR,{type:se.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===ye.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:r,stats:n})}handleNetworkError(e,t,s=!1,r,n){let o=`A network ${s?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===ye.LEVEL?o+=`: ${e.level} id: ${e.id}`:(e.type===ye.AUDIO_TRACK||e.type===ye.SUBTITLE_TRACK)&&(o+=` id: ${e.id} group-id: "${e.groupId}"`);const a=new Error(o);A.warn(`[playlist-loader]: ${o}`);let l=D.UNKNOWN,c=!1;const u=this.getInternalLoader(e);switch(e.type){case ye.MANIFEST:l=s?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,c=!0;break;case ye.LEVEL:l=s?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,c=!1;break;case ye.AUDIO_TRACK:l=s?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,c=!1;break;case ye.SUBTITLE_TRACK:l=s?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,c=!1;break}u&&this.resetInternalLoader(e.type);const f={type:se.NETWORK_ERROR,details:l,fatal:c,url:e.url,loader:u,context:e,error:a,networkDetails:t,stats:n};if(r){const h=(t==null?void 0:t.url)||e.url;f.response=et({url:h,data:void 0},r)}this.hls.trigger(p.ERROR,f)}handlePlaylistLoaded(e,t,s,r,n,o){const a=this.hls,{type:l,level:c,id:u,groupId:f,deliveryDirectives:h}=r,d=Nr(t,r),g=Ya(r),m=typeof r.level=="number"&&g===ie.MAIN?c:void 0;if(!e.fragments.length){const T=new Error("No Segments found in Playlist");a.trigger(p.ERROR,{type:se.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:d,error:T,reason:T.message,response:t,context:r,level:m,parent:g,networkDetails:n,stats:s});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const y=e.playlistParsingError;if(y){a.trigger(p.ERROR,{type:se.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:d,error:y,reason:y.message,response:t,context:r,level:m,parent:g,networkDetails:n,stats:s});return}switch(e.live&&o&&(o.getCacheAge&&(e.ageHeader=o.getCacheAge()||0),(!o.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case ye.MANIFEST:case ye.LEVEL:a.trigger(p.LEVEL_LOADED,{details:e,level:m||0,id:u||0,stats:s,networkDetails:n,deliveryDirectives:h});break;case ye.AUDIO_TRACK:a.trigger(p.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:f||"",stats:s,networkDetails:n,deliveryDirectives:h});break;case ye.SUBTITLE_TRACK:a.trigger(p.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:f||"",stats:s,networkDetails:n,deliveryDirectives:h});break}}}function fu(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function hu(i,e){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){A.debug(`[texttrack-utils]: ${s}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,i.addCue(r)}catch(r){A.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(i.mode=t)}function ps(i){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Rn(i,e,t,s){const r=i.mode;if(r==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const n=Km(i.cues,e,t);for(let o=0;o<n.length;o++)(!s||s(n[o]))&&i.removeCue(n[o])}r==="disabled"&&(i.mode=r)}function Gm(i,e){if(e<i[0].startTime)return 0;const t=i.length-1;if(e>i[t].endTime)return-1;let s=0,r=t;for(;s<=r;){const n=Math.floor((r+s)/2);if(e<i[n].startTime)r=n-1;else if(e>i[n].startTime&&s<t)s=n+1;else return n}return i[s].startTime-e<e-i[r].startTime?s:r}function Km(i,e,t){const s=[],r=Gm(i,e);if(r>-1)for(let n=r,o=i.length;n<o;n++){const a=i[n];if(a.startTime>=e&&a.endTime<=t)s.push(a);else if(a.startTime>t)return s}return s}var ut={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const Hm=.25;function Ln(){if(!(typeof self>"u"))return self.WebKitDataCue||self.VTTCue||self.TextTrackCue}const mi=(()=>{const i=Ln();try{new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function Mr(i,e){return i.getTime()/1e3-e}function Vm(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class Wm{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(ps(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const s=e[t];if(s.kind==="metadata"&&s.label==="id3")return fu(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:r}}}=this;if(!s&&!r)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const o=Ln();for(let a=0;a<n.length;a++){const l=n[a].type;if(l===ut.emsg&&!s||!r)continue;const c=su(n[a].data);if(c){const u=n[a].pts;let f=u+n[a].duration;f>mi&&(f=mi),f-u<=0&&(f=u+Hm);for(let d=0;d<c.length;d++){const g=c[d];if(!tu(g)){this.updateId3CueEnds(u,l);const m=new o(u,f,"");m.value=g,l&&(m.type=l),this.id3Track.addCue(m)}}}}}updateId3CueEnds(e,t){var s;const r=(s=this.id3Track)==null?void 0:s.cues;if(r)for(let n=r.length;n--;){const o=r[n];o.type===t&&o.startTime<e&&o.endTime===mi&&(o.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:r}){const{id3Track:n,hls:o}=this;if(!o)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:l}}=o;if(n&&(a||l)){let c;r==="audio"?c=u=>u.type===ut.audioId3&&l:r==="video"?c=u=>u.type===ut.emsg&&a:c=u=>u.type===ut.audioId3&&l||u.type===ut.emsg&&a,Rn(n,t,s,c)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:s,id3Track:r}=this,{dateRanges:n}=t,o=Object.keys(n);if(r){const u=Object.keys(s).filter(f=>!o.includes(f));for(let f=u.length;f--;){const h=u[f];Object.keys(s[h].cues).forEach(d=>{r.removeCue(s[h].cues[d])}),delete s[h]}}const a=t.fragments[t.fragments.length-1];if(o.length===0||!J(a==null?void 0:a.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=a.programDateTime/1e3-a.start,c=Ln();for(let u=0;u<o.length;u++){const f=o[u],h=n[f],d=s[f],g=(d==null?void 0:d.cues)||{};let m=(d==null?void 0:d.durationKnown)||!1;const y=Mr(h.startDate,l);let T=mi;const x=h.endDate;if(x)T=Mr(x,l),m=!0;else if(h.endOnNext&&!m){const R=o.reduce((b,M)=>{const P=n[M];return P.class===h.class&&P.id!==M&&P.startDate>h.startDate&&b.push(P),b},[]).sort((b,M)=>b.startDate.getTime()-M.startDate.getTime())[0];R&&(T=Mr(R.startDate,l),m=!0)}const v=Object.keys(h.attr);for(let R=0;R<v.length;R++){const b=v[R];if(!J0(b))continue;let M=g[b];if(M)m&&!d.durationKnown&&(M.endTime=T);else{let P=h.attr[b];M=new c(y,T,""),Z0(b)&&(P=Vm(P)),M.value={key:b,data:P},M.type=ut.dateRange,M.id=f,this.id3Track.addCue(M),g[b]=M}}s[f]={cues:g,dateRange:h,durationKnown:m}}}}class Ym{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:s,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:o,lowLatencyMode:a}=this.config,l=this.hls.userConfig;let c=a&&s||t;(l.liveSyncDuration||l.liveSyncDurationCount||c===0)&&(c=n!==void 0?n:o*r);const u=r,f=1;return c+Math.min(this.stallCount*f,u)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,s=this.levelDetails;if(e===null||t===null||s===null)return null;const r=s.edge,n=e-t-this.edgeStalled,o=r-s.totalduration,a=r-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(o,n),a)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const s=e.buffered.length;return(s?e.buffered.end(s-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(p.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(p.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var s;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(s=this.levelDetails)!=null&&s.live&&A.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1)return;const o=this.targetLatency;if(o===null)return;const a=s-o,l=Math.min(this.maxLatency,o+t.targetduration),c=a<l;if(t.live&&c&&a>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,n)),f=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,f))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const bn=["NONE","TYPE-0","TYPE-1",null];var js={No:"",Yes:"YES",v2:"v2"};function jm(i,e){const{canSkipUntil:t,canSkipDateRanges:s,endSN:r}=i,n=e!==void 0?e-r:0;return t&&n<t?s?js.v2:js.Yes:js.No}class ja{constructor(e,t,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=s}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class ri{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>t).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return(e=this.audioGroupIds)==null?void 0:e[this.urlId]}get textGroupId(){var e;return(e=this.textGroupIds)==null?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function Ur(i,e){const t=e.startPTS;if(J(t)){let s=0,r;e.sn>i.sn?(s=t-i.start,r=i):(s=i.start-t,r=e),r.duration!==s&&(r.duration=s)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function du(i,e,t,s,r,n){s-t<=0&&(A.warn("Fragment should have a positive duration",e),s=t+e.duration,n=r+e.duration);let a=t,l=s;const c=e.startPTS,u=e.endPTS;if(J(c)){const y=Math.abs(c-t);J(e.deltaPTS)?e.deltaPTS=Math.max(y,e.deltaPTS):e.deltaPTS=y,a=Math.max(t,c),t=Math.min(t,c),r=Math.min(r,e.startDTS),l=Math.min(s,u),s=Math.max(s,u),n=Math.max(n,e.endDTS)}const f=t-e.start;e.start!==0&&(e.start=t),e.duration=s-e.start,e.startPTS=t,e.maxStartPTS=a,e.startDTS=r,e.endPTS=s,e.minEndPTS=l,e.endDTS=n;const h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let d;const g=h-i.startSN,m=i.fragments;for(m[g]=e,d=g;d>0;d--)Ur(m[d],m[d-1]);for(d=g;d<m.length-1;d++)Ur(m[d],m[d+1]);return i.fragmentHint&&Ur(m[m.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,f}function qm(i,e){let t=null;const s=i.fragments;for(let l=s.length-1;l>=0;l--){const c=s[l].initSegment;if(c){t=c;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let r=0,n;if(Qm(i,e,(l,c)=>{l.relurl&&(r=l.cc-c.cc),J(l.startPTS)&&J(l.endPTS)&&(c.start=c.startPTS=l.startPTS,c.startDTS=l.startDTS,c.maxStartPTS=l.maxStartPTS,c.endPTS=l.endPTS,c.endDTS=l.endDTS,c.minEndPTS=l.minEndPTS,c.duration=l.endPTS-l.startPTS,c.duration&&(n=c),e.PTSKnown=e.alignedSliding=!0),c.elementaryStreams=l.elementaryStreams,c.loader=l.loader,c.stats=l.stats,c.urlId=l.urlId,l.initSegment&&(c.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(c=>{var u;(!c.initSegment||c.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(c.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){A.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=zm(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const o=e.fragments;if(r){A.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<o.length;l++)o[l].cc+=r}e.skippedSegments&&(e.startCC=e.fragments[0].cc),Xm(i.partList,e.partList,(l,c)=>{c.elementaryStreams=l.elementaryStreams,c.stats=l.stats}),n?du(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):gu(i,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;const a=e.advancedDateTime;if(e.advanced&&a){const l=e.edge;e.driftStart||(e.driftStartTime=a,e.driftStart=l),e.driftEndTime=a,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function zm(i,e,t){const s=Ne({},i);return t&&t.forEach(r=>{delete s[r]}),Object.keys(e).forEach(r=>{const n=new zc(e[r].attr,s[r]);n.isValid?s[r]=n:A.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`)}),s}function Xm(i,e,t){if(i&&e){let s=0;for(let r=0,n=i.length;r<=n;r++){const o=i[r],a=e[r+s];o&&a&&o.index===a.index&&o.fragment.sn===a.fragment.sn?t(o,a):s--}}}function Qm(i,e,t){const s=e.skippedSegments,r=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(s?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,o=e.startSN-i.startSN,a=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let c=r;c<=n;c++){const u=l[o+c];let f=a[c];s&&!f&&c<s&&(f=e.fragments[c]=u),u&&f&&t(u,f)}}function gu(i,e){const t=e.startSN+e.skippedSegments-i.startSN,s=i.fragments;t<0||t>=s.length||In(e,s[t].start)}function In(i,e){if(e){const t=i.fragments;for(let s=i.skippedSegments;s<t.length;s++)t[s].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function Jm(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){const s=i.fragments,r=4;if(s.length&&t*r>e){const n=s[s.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function Zm(i,e,t){if(!(i!=null&&i.details))return null;const s=i.details;let r=s.fragments[e-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===e)?r:e<s.startSN&&t&&t.sn===e?t:null}function qa(i,e,t){var s;return i!=null&&i.details?mu((s=i.details)==null?void 0:s.partList,e,t):null}function mu(i,e,t){if(i)for(let s=i.length;s--;){const r=i[s];if(r.index===t&&r.fragment.sn===e)return r}return null}function Vi(i){switch(i.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function za(i,e){const t=Vi(e);return i.default[`${t?"timeout":"error"}Retry`]}function co(i,e){const t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function Xa(i){return et(et({},i),{errorRetry:null,timeoutRetry:null})}function Wi(i,e,t,s){return!!i&&e<i.maxNumRetry&&(ep(s)||!!t)}function ep(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const pu={search:function(i,e){let t=0,s=i.length-1,r=null,n=null;for(;t<=s;){r=(t+s)/2|0,n=i[r];const o=e(n);if(o>0)t=r+1;else if(o<0)s=r-1;else return n}return null}};function tp(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!J(e))return null;const s=i[0].programDateTime;if(e<(s||0))return null;const r=i[i.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let n=0;n<i.length;++n){const o=i[n];if(sp(e,t,o))return o}return null}function ni(i,e,t=0,s=0){let r=null;if(i?r=e[i.sn-e[0].sn+1]||null:t===0&&e[0].start===0&&(r=e[0]),r&&Dn(t,s,r)===0)return r;const n=pu.search(e,Dn.bind(null,t,s));return n&&(n!==i||!r)?n:r}function Dn(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=i?1:t.start-s>i&&t.start?-1:0}function sp(i,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>i}function ip(i,e){return pu.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}const rp=3e5;var Ve={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},it={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class np{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=A.log.bind(A,"[info]:"),this.warn=A.warn.bind(A,"[warning]:"),this.error=A.error.bind(A,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.ERROR,this.onError,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.ERROR,this.onError,this),e.off(p.ERROR,this.onErrorOut,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(e==null?void 0:e.type)===ie.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var s,r;if(t.fatal)return;const n=this.hls,o=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction={action:Ve.DoNothing,flags:it.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=Ve.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var a,l;const c=t.parent===ie.MAIN?t.level:n.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((a=t.context)!=null&&(l=a.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,c):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof(o==null?void 0:o.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,o.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(o){const c=n.levels[n.loadLevel];if(c&&(o.type===ye.AUDIO_TRACK&&o.groupId===c.audioGroupId||o.type===ye.SUBTITLE_TRACK&&o.groupId===c.textGroupId)){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=Ve.SendAlternateToPenaltyBox,t.errorAction.flags=it.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const c=n.levels[n.loadLevel],u=c==null?void 0:c.attrs["HDCP-LEVEL"];u&&(t.errorAction={action:Ve.SendAlternateToPenaltyBox,flags:it.MoveAllAlternatesMatchingHDCP,hdcpLevel:u})}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:n.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:Ve.DoNothing,flags:it.None};return}if(t.type===se.KEY_SYSTEM_ERROR){const c=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,c);return}}getPlaylistRetryOrSwitchAction(e,t){var s;const r=this.hls,n=za(r.config.playlistLoadPolicy,e),o=this.playlistError++,a=(s=e.response)==null?void 0:s.code;if(Wi(n,o,Vi(e),a))return{action:Ve.RetryRequest,flags:it.None,retryConfig:n,retryCount:o};const c=this.getLevelSwitchAction(e,t);return n&&(c.retryConfig=n,c.retryCount=o),c}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),r=t.levels[s],{fragLoadPolicy:n,keyLoadPolicy:o}=t.config,a=za(e.details.startsWith("key")?o:n,e),l=t.levels.reduce((f,h)=>f+h.fragmentError,0);if(r){var c;e.details!==D.FRAG_GAP&&r.fragmentError++;const f=(c=e.response)==null?void 0:c.code;if(Wi(a,l,Vi(e),f))return{action:Ve.RetryRequest,flags:it.None,retryConfig:a,retryCount:l}}const u=this.getLevelSwitchAction(e,s);return a&&(u.retryConfig=a,u.retryCount=l),u}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const r=this.hls.levels[t];if(r&&(r.loadError++,s.autoLevelEnabled)){var n,o;let a=-1;const{levels:l,loadLevel:c,minAutoLevel:u,maxAutoLevel:f}=s,h=(n=e.frag)==null?void 0:n.type,{type:d,groupId:g}=(o=e.context)!=null?o:{};for(let m=l.length;m--;){const y=(m+c)%l.length;if(y!==c&&y>=u&&y<=f&&l[y].loadError===0){const T=l[y];if(e.details===D.FRAG_GAP&&e.frag){const x=l[y].details;if(x){const v=ni(e.frag,x.fragments,e.frag.start);if(v!=null&&v.gap)continue}}else{if(d===ye.AUDIO_TRACK&&g===T.audioGroupId||d===ye.SUBTITLE_TRACK&&g===T.textGroupId)continue;if(h===ie.AUDIO&&r.audioGroupId===T.audioGroupId||h===ie.SUBTITLE&&r.textGroupId===T.textGroupId)continue}a=y;break}}if(a>-1&&s.loadLevel!==a)return e.levelRetry=!0,this.playlistError=0,{action:Ve.SendAlternateToPenaltyBox,flags:it.None,nextAutoLevel:a}}return{action:Ve.SendAlternateToPenaltyBox,flags:it.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case Ve.DoNothing:break;case Ve.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP&&(t.fatal=!0);break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,s=e.errorAction;if(!s)return;const{flags:r,hdcpLevel:n,nextAutoLevel:o}=s;switch(r){case it.None:this.switchLevel(e,o);break;case it.MoveAllAlternatesMatchingHost:s.resolved||(s.resolved=this.redundantFailover(e));break;case it.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=bn[bn.indexOf(n)-1],s.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}s.resolved||this.switchLevel(e,o)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:t,penalizedRenditions:s}=this,r=e.parent===ie.MAIN?e.level:t.loadLevel,n=t.levels[r],o=n.url.length,a=e.frag?e.frag.urlId:n.urlId;n.urlId===a&&(!e.frag||n.details)&&this.penalizeRendition(n,e);for(let l=1;l<o;l++){const c=(a+l)%o,u=s[c];if(!u||op(u,e,s[a]))return this.warn(`Switching to Redundant Stream ${c+1}/${o}: "${n.url[c]}" after ${e.details}`),this.playlistError=0,t.levels.forEach(f=>{f.urlId=c}),t.nextLoadLevel=r,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:s}=this,r=s[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};r.lastErrorPerfMs=performance.now(),r.errors.push(t),r.details=e.details,s[e.urlId]=r}}function op(i,e,t){if(performance.now()-i.lastErrorPerfMs>rp)return!0;const s=i.details;if(e.details===D.FRAG_GAP&&s&&e.frag){const r=e.frag.start,n=ni(null,s.fragments,r);if(n&&!n.gap)return!0}if(t&&i.errors.length<t.errors.length){const r=i.errors[i.errors.length-1];if(s&&r.frag&&e.frag&&Math.abs(r.frag.start-e.frag.start)>s.targetduration*3)return!0}return!1}class uo{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=A.log.bind(A,`${t}:`),this.warn=A.warn.bind(A,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const s=t==null?void 0:t.renditionReports;if(s){let r=-1;for(let n=0;n<s.length;n++){const o=s[n];let a;try{a=new self.URL(o.URI,t.url).href}catch(l){A.warn(`Could not construct new URL for Rendition Report: ${l}`),a=o.URI||""}if(a===e){r=n;break}else a===e.substring(0,a.length)&&(r=n)}if(r!==-1){const n=s[r],o=parseInt(n["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let a=parseInt(n["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const l=Math.min(t.age-t.partTarget,t.targetduration);a>=0&&l>t.partTarget&&(a+=1)}return new ja(o,a>=0?a:void 0,js.No)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,s){const{details:r,stats:n}=t,o=self.performance.now(),a=n.loading.first?Math.max(0,o-n.loading.first):0;if(r.advancedDateTime=Date.now()-a,r.live||s!=null&&s.live){if(r.reloaded(s),s&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),s&&r.fragments.length>0&&qm(s,r),!this.canLoad||!r.live)return;let l,c,u;if(r.canBlockReload&&r.endSN&&r.advanced){const y=this.hls.config.lowLatencyMode,T=r.lastPartSn,x=r.endSN,v=r.lastPartIndex,R=v!==-1,b=T===x,M=y?0:v;R?(c=b?x+1:T,u=b?M:v+1):c=x+1;const P=r.age,B=P+r.ageHeader;let K=Math.min(B-r.partTarget,r.targetduration*1.5);if(K>0){if(s&&K>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${K} with playlist age: ${r.age}`),K=0;else{const _=Math.floor(K/r.targetduration);if(c+=_,u!==void 0){const q=Math.round(K%r.targetduration/r.partTarget);u+=q}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${P.toFixed(2)}s goal: ${K} skip sn ${_} to part ${u}`)}r.tuneInGoal=K}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u),y||!b){this.loadPlaylist(l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,c,u));const f=this.hls.mainForwardBufferInfo,h=f?f.end-f.len:0,d=(r.edge-h)*1e3,g=Jm(r,d);r.updated&&o>this.requestScheduled+g&&(this.requestScheduled=n.loading.start),c!==void 0&&r.canBlockReload?this.requestScheduled=n.loading.first+g-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+g<o?this.requestScheduled=o:this.requestScheduled-o<=0&&(this.requestScheduled+=g);let m=this.requestScheduled-o;m=Math.max(0,m),this.log(`reload live playlist ${e} in ${Math.round(m)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),m)}else this.clearTimer()}getDeliveryDirectives(e,t,s,r){let n=jm(e,s);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,r=t.part,n=js.No),new ja(s,r,n)}checkRetry(e){const t=e.details,s=Vi(e),r=e.errorAction,{action:n,retryCount:o=0,retryConfig:a}=r||{},l=!!r&&!!a&&(n===Ve.RetryRequest||!r.resolved&&n===Ve.SendAlternateToPenaltyBox);if(l){var c;if(this.requestScheduled=-1,o>=a.maxNumRetry)return!1;if(s&&(c=e.context)!=null&&c.deliveryDirectives)this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const u=co(a,o);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${o+1}/${a.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,r.resolved=!0}return l}}let Br;class ap extends uo{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const s=[],r={};let n;t.levels.forEach(o=>{var a;const l=o.attrs;((a=o.audioCodec)==null?void 0:a.indexOf("mp4a.40.34"))!==-1&&(Br||(Br=/chrome|firefox/i.test(navigator.userAgent)),Br&&(o.audioCodec=void 0));const{AUDIO:c,CODECS:u,"FRAME-RATE":f,"PATHWAY-ID":h,RESOLUTION:d,SUBTITLES:g}=l,y=`${`${h||"."}-`}${o.bitrate}-${d}-${f}-${u}`;n=r[y],n?n.addFallback(o):(n=new ri(o),r[y]=n,s.push(n)),Yi(n,"audio",c),Yi(n,"text",g)}),this.filterAndSortMediaOptions(s,t)}filterAndSortMediaOptions(e,t){let s=[],r=[],n=!1,o=!1,a=!1,l=e.filter(({audioCodec:d,videoCodec:g,width:m,height:y,unknownCodecs:T})=>(n||(n=!!(m&&y)),o||(o=!!g),a||(a=!!d),!(T!=null&&T.length)&&(!d||Fr(d,"audio"))&&(!g||Fr(g,"video"))));if((n||o)&&a&&(l=l.filter(({videoCodec:d,width:g,height:m})=>!!d||!!(g&&m))),l.length===0){Promise.resolve().then(()=>{if(this.hls){const d=new Error("no level with compatible codecs found in manifest");this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:d,reason:d.message})}});return}t.audioTracks&&(s=t.audioTracks.filter(d=>!d.audioCodec||Fr(d.audioCodec,"audio")),Qa(s)),t.subtitles&&(r=t.subtitles,Qa(r));const c=l.slice(0);l.sort((d,g)=>d.attrs["HDCP-LEVEL"]!==g.attrs["HDCP-LEVEL"]?(d.attrs["HDCP-LEVEL"]||"")>(g.attrs["HDCP-LEVEL"]||"")?1:-1:d.bitrate!==g.bitrate?d.bitrate-g.bitrate:d.attrs["FRAME-RATE"]!==g.attrs["FRAME-RATE"]?d.attrs.decimalFloatingPoint("FRAME-RATE")-g.attrs.decimalFloatingPoint("FRAME-RATE"):d.attrs.SCORE!==g.attrs.SCORE?d.attrs.decimalFloatingPoint("SCORE")-g.attrs.decimalFloatingPoint("SCORE"):n&&d.height!==g.height?d.height-g.height:0);let u=c[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==c.length)){for(let d=0;d<c.length;d++)if(c[d].pathwayId===l[0].pathwayId){u=c[d];break}}this._levels=l;for(let d=0;d<l.length;d++)if(l[d]===u){this._firstLevel=d,this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${u.bitrate}`);break}const f=a&&!o,h={levels:l,audioTracks:s,subtitleTracks:r,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:a,video:o,altAudio:!f&&s.some(d=>!!d.url)};this.hls.trigger(p.MANIFEST_PARSED,h),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),f=e<0;if(this.hls.trigger(p.ERROR,{type:se.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:f,error:u,reason:u.message}),f)return;e=Math.min(e,t.length-1)}const s=this.currentLevelIndex,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,o=t[e],a=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=o,s===e&&o.details&&r&&n===a)return;this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level ${s}${n?" with Pathway "+n:""}`);const l=Ne({},o,{level:e,maxBitrate:o.maxBitrate,attrs:o.attrs,uri:o.uri,urlId:o.urlId});delete l._attrs,delete l._urlId,this.hls.trigger(p.LEVEL_SWITCHING,l);const c=o.details;if(!c||c.live){const u=this.switchParams(o.uri,r==null?void 0:r.details);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this._firstLevel}else return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===ye.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(t!==void 0&&t.type===ie.MAIN){const s=this._levels[t.level];s!==void 0&&(s.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:n}=t,o=this._levels[r];if(!o){var a;this.warn(`Invalid level index ${r}`),(a=t.deliveryDirectives)!=null&&a.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(o.fragmentError===0&&(o.loadError=0),this.playlistLoaded(r,t,o.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const s=this.currentLevel;if(!s)return;const r=this.hls.audioTracks[t.id].groupId;if(s.audioGroupIds&&s.audioGroupId!==r){let n=-1;for(let o=0;o<s.audioGroupIds.length;o++)if(s.audioGroupIds[o]===r){n=o;break}n!==-1&&n!==s.urlId&&(s.urlId=n,this.canLoad&&this.startLoad())}}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){const r=s.urlId;let n=s.uri;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const o=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${o?" Pathway "+o:""} URI ${r+1}/${s.url.length} ${n}`),this.clearTimer(),this.hls.trigger(p.LEVEL_LOADING,{url:n,level:t,id:r,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e,t){const s=(n,o)=>o!==t,r=this._levels.filter((n,o)=>o!==e?!0:n.url.length>1&&t!==void 0?(n.url=n.url.filter(s),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(s)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(s)),n.urlId=0,!0):(this.steering&&this.steering.removeLevel(n),!1));this.hls.trigger(p.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){t.forEach((s,r)=>{const{details:n}=s;n!=null&&n.fragments&&n.fragments.forEach(o=>{o.level=r})}),this._levels=t}}function Yi(i,e,t){t&&(e==="audio"?(i.audioGroupIds||(i.audioGroupIds=[]),i.audioGroupIds[i.url.length-1]=t):e==="text"&&(i.textGroupIds||(i.textGroupIds=[]),i.textGroupIds[i.url.length-1]=t))}function Qa(i){const e={};i.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}var Me={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class lp{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.BUFFER_APPENDED,this.onBufferAppended,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.BUFFER_APPENDED,this.onBufferAppended,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let r=s.length;r--;){const n=s[r];if(!n)break;const o=n.end;if(n.start<=e&&o!==null&&e<=o)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:s}=this,r=Object.keys(s);for(let n=r.length;n--;){const o=s[r[n]];if((o==null?void 0:o.body.type)===t&&o.buffered){const a=o.body;if(a.start<=e&&e<=a.end)return a}}return null}detectEvictedFragments(e,t,s,r){this.timeRanges&&(this.timeRanges[e]=t);const n=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a||n>=a.body.sn)return;if(!a.buffered&&!a.loaded){a.body.type===s&&this.removeFragment(a.body);return}const l=a.range[e];l&&l.time.some(c=>{const u=!this.isTimeBuffered(c.startPTS,c.endPTS,t);return u&&this.removeFragment(a.body),u})})}detectPartialFragments(e){const t=this.timeRanges,{frag:s,part:r}=e;if(!t||s.sn==="initSegment")return;const n=fs(s),o=this.fragments[n];if(!o||o.buffered&&s.gap)return;const a=!s.relurl;Object.keys(t).forEach(l=>{const c=s.elementaryStreams[l];if(!c)return;const u=t[l],f=a||c.partial===!0;o.range[l]=this.getBufferedTimes(s,r,f,u)}),o.loaded=null,Object.keys(o.range).length?(o.buffered=!0,(o.body.endList=s.endList||o.body.endList)&&(this.endListFragments[o.body.type]=o),pi(o)||this.removeParts(s.sn-1,s.type)):this.removeFragment(o.body)}removeParts(e,t){const s=this.activePartLists[t];s&&(this.activePartLists[t]=s.filter(r=>r.fragment.sn>=e))}fragBuffered(e,t){const s=fs(e);let r=this.fragments[s];!r&&t&&(r=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,s,r){const n={time:[],partial:s},o=e.start,a=e.end,l=e.minEndPTS||a,c=e.maxStartPTS||o;for(let u=0;u<r.length;u++){const f=r.start(u)-this.bufferPadding,h=r.end(u)+this.bufferPadding;if(c>=f&&l<=h){n.time.push({startPTS:Math.max(o,r.start(u)),endPTS:Math.min(a,r.end(u))});break}else if(o<h&&a>f)n.partial=!0,n.time.push({startPTS:Math.max(o,r.start(u)),endPTS:Math.min(a,r.end(u))});else if(a<=f)break}return n}getPartialFragment(e){let t=null,s,r,n,o=0;const{bufferPadding:a,fragments:l}=this;return Object.keys(l).forEach(c=>{const u=l[c];u&&pi(u)&&(r=u.body.start-a,n=u.body.end+a,e>=r&&e<=n&&(s=Math.min(e-r,n-e),o<=s&&(t=u.body,o=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||pi(t))}getState(e){const t=fs(e),s=this.fragments[t];return s?s.buffered?pi(s)?Me.PARTIAL:Me.OK:Me.APPENDING:Me.NOT_LOADED}isTimeBuffered(e,t,s){let r,n;for(let o=0;o<s.length;o++){if(r=s.start(o)-this.bufferPadding,n=s.end(o)+this.bufferPadding,e>=r&&t<=n)return!0;if(t<=r)return!1}return!1}onFragLoaded(e,t){const{frag:s,part:r}=t;if(s.sn==="initSegment"||s.bitrateTest)return;const n=r?null:t,o=fs(s);this.fragments[o]={body:s,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:r,timeRanges:n}=t;if(s.sn==="initSegment")return;const o=s.type;if(r){let a=this.activePartLists[o];a||(this.activePartLists[o]=a=[]),a.push(r)}this.timeRanges=n,Object.keys(n).forEach(a=>{const l=n[a];this.detectEvictedFragments(a,l,o,r)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=fs(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(o=>{const a=this.fragments[o];if(!a)return;const l=a.body;l.type!==s||r&&!l.gap||l.start<t&&l.end>e&&(a.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=fs(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const r=e.sn;this.activePartLists[e.type]=s.filter(n=>n.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function pi(i){var e,t,s;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((s=i.range.audiovideo)==null?void 0:s.partial))}function fs(i){return`${i.type}_${i.level}_${i.urlId}_${i.sn}`}const Ja=Math.pow(2,17);class cp{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const s=e.url;if(!s)return Promise.reject(new Pt({type:se.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,n=r.fLoader,o=r.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(d=>d[0]==="GAP")){l(el(e));return}else e.gap=!1;const c=this.loader=e.loader=n?new n(r):new o(r),u=Za(e),f=Xa(r.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Ja};e.stats=c.stats,c.load(u,h,{onSuccess:(d,g,m,y)=>{this.resetLoader(e,c);let T=d.data;m.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(T.slice(0,16)),T=T.slice(16)),a({frag:e,part:null,payload:T,networkDetails:y})},onError:(d,g,m,y)=>{this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:et({url:s,data:void 0},d),error:new Error(`HTTP Error ${d.code} ${d.text}`),networkDetails:m,stats:y}))},onAbort:(d,g,m)=>{this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:m,stats:d}))},onTimeout:(d,g,m)=>{this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:d}))},onProgress:(d,g,m,y)=>{t&&t({frag:e,part:null,payload:m,networkDetails:y})}})})}loadPart(e,t,s){this.abort();const r=this.config,n=r.fLoader,o=r.loader;return new Promise((a,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(el(e,t));return}const c=this.loader=e.loader=n?new n(r):new o(r),u=Za(e,t),f=Xa(r.fragLoadPolicy.default),h={loadPolicy:f,timeout:f.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ja};t.stats=c.stats,c.load(u,h,{onSuccess:(d,g,m,y)=>{this.resetLoader(e,c),this.updateStatsFromPart(e,t);const T={frag:e,part:t,payload:d.data,networkDetails:y};s(T),a(T)},onError:(d,g,m,y)=>{this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:et({url:u.url,data:void 0},d),error:new Error(`HTTP Error ${d.code} ${d.text}`),networkDetails:m,stats:y}))},onAbort:(d,g,m)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:m,stats:d}))},onTimeout:(d,g,m)=>{this.resetLoader(e,c),l(new Pt({type:se.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:m,stats:d}))}})})}updateStatsFromPart(e,t){const s=e.stats,r=t.stats,n=r.total;if(s.loaded+=r.loaded,n){const l=Math.round(e.duration/t.duration),c=Math.min(Math.round(s.loaded/n),l),f=(l-c)*Math.round(s.loaded/c);s.total=s.loaded+f}else s.total=Math.max(s.loaded,s.total);const o=s.loading,a=r.loading;o.start?o.first+=a.first-a.start:(o.start=a.start,o.first=a.first),o.end=a.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Za(i,e=null){const t=e||i,s={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(J(r)&&J(n)){var o;let a=r,l=n;if(i.sn==="initSegment"&&((o=i.decryptdata)==null?void 0:o.method)==="AES-128"){const c=n-r;c%16&&(l=n+(16-c%16)),r!==0&&(s.resetIV=!0,a=r-16)}s.rangeStart=a,s.rangeEnd=l}return s}function el(i,e){const t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),s={type:se.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(s.part=e),(e||i).stats.aborted=!0,new Pt(s)}class Pt extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class up{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[t].loader;if(s){if(e&&e!==s.context.frag.type)return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,s,r,n){return new Pt({type:se.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let n=0;n<t.length;n++){const o=t[n];if(r<=o.cc&&(s==="initSegment"||o.sn==="initSegment"||s<o.sn)){this.emeController.selectKeySystemFormat(o).then(a=>{o.setKeyFormat(a)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const c=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,c))}const o=n.uri;if(!o)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${o}"`)));let a=this.keyUriToKeyInfo[o];if((s=a)!=null&&s.decryptdata.key)return n.key=a.decryptdata.key,Promise.resolve({frag:e,keyInfo:a});if((r=a)!=null&&r.keyLoadPromise){var l;switch((l=a.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return a.keyLoadPromise.then(c=>(n.key=c.keyInfo.decryptdata.key,{frag:e,keyInfo:a}))}}switch(a=this.keyUriToKeyInfo[o]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(a,e):this.loadKeyEME(a,e);case"AES-128":return this.loadKeyHTTP(a,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,s))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,n=new r(s);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((o,a)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},c=s.keyLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(h,d,g,m)=>{const{frag:y,keyInfo:T,url:x}=g;if(!y.decryptdata||T!==this.keyUriToKeyInfo[x])return a(this.createKeyLoadError(y,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),m));T.decryptdata.key=y.decryptdata.key=new Uint8Array(h.data),y.keyLoader=null,T.loader=null,o({frag:y,keyInfo:T})},onError:(h,d,g,m)=>{this.resetLoader(d),a(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),g,et({url:l.url,data:void 0},h)))},onTimeout:(h,d,g)=>{this.resetLoader(d),a(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),g))},onAbort:(h,d,g)=>{this.resetLoader(d),a(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),g))}};n.load(l,u,f)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,n=s.loader;t.keyLoader===n&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}class fp{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const hp={length:0,start:()=>0,end:()=>0};class De{static isBuffered(e,t){try{if(e){const s=De.getBuffered(e);for(let r=0;r<s.length;r++)if(t>=s.start(r)&&t<=s.end(r))return!0}}catch{}return!1}static bufferInfo(e,t,s){try{if(e){const r=De.getBuffered(e),n=[];let o;for(o=0;o<r.length;o++)n.push({start:r.start(o),end:r.end(o)});return this.bufferedInfo(n,t,s)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.sort(function(c,u){const f=c.start-u.start;return f||u.end-c.end});let r=[];if(s)for(let c=0;c<e.length;c++){const u=r.length;if(u){const f=r[u-1].end;e[c].start-f<s?e[c].end>f&&(r[u-1].end=e[c].end):r.push(e[c])}else r.push(e[c])}else r=e;let n=0,o,a=t,l=t;for(let c=0;c<r.length;c++){const u=r[c].start,f=r[c].end;if(t+s>=u&&t<f)a=u,l=f,n=l-t;else if(t+s<u){o=u;break}}return{len:n,start:a||0,end:l||0,nextStart:o}}static getBuffered(e){try{return e.buffered}catch(t){return A.log("failed to get media.buffered",t),hp}}}class fo{constructor(e,t,s,r=0,n=-1,o=!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=yi(),this.buffering={audio:yi(),video:yi(),audiovideo:yi()},this.level=e,this.sn=t,this.id=s,this.size=r,this.part=n,this.partial=o}}function yi(){return{start:0,executeStart:0,executeEnd:0,end:0}}function yu(i,e){let t=null;for(let s=0,r=i.length;s<r;s++){const n=i[s];if(n&&n.cc===e){t=n;break}}return t}function dp(i,e,t){return!!(e.details&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function gp(i,e,t=0){const s=i.fragments,r=e.fragments;if(!r.length||!s.length){A.log("No fragments to align");return}const n=yu(s,r[0].cc);if(!n||n&&!n.startPTS){A.log("No frag in previous level to align on");return}return n}function tl(i,e){if(i){const t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function ho(i,e){const t=e.fragments;for(let s=0,r=t.length;s<r;s++)tl(t[s],i);e.fragmentHint&&tl(e.fragmentHint,i),e.alignedSliding=!0}function mp(i,e,t){e&&(pp(i,t,e),!t.alignedSliding&&e.details&&yp(t,e.details),!t.alignedSliding&&e.details&&!t.skippedSegments&&gu(e.details,t))}function pp(i,e,t){if(dp(i,t,e)){const s=gp(t.details,e);s&&J(s.start)&&(A.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),ho(s.start,e))}}function yp(i,e){if(!e.fragments.length||!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=e.fragments[0].programDateTime,s=i.fragments[0].programDateTime,r=(s-t)/1e3+e.fragments[0].start;r&&J(r)&&(A.log(`Adjusting PTS using programDateTime delta ${s-t}ms, sliding:${r.toFixed(3)} ${i.url} `),ho(r,i))}function Tu(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=i.fragments,s=e.fragments;if(!t.length||!s.length)return;const r=Math.round(s.length/2)-1,n=s[r],o=yu(t,n.cc)||t[Math.round(t.length/2)-1],a=n.programDateTime,l=o.programDateTime;if(a===null||l===null)return;const c=(l-a)/1e3-(o.start-n.start);ho(c,i)}class Tp{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Ep{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function xp(i){const e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?os(i,0,e-t):i}class Sp{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(e){const t=new DataView(e),s=new Uint32Array(4);for(let r=0;r<4;r++)s[r]=t.getUint32(r*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,r=s[0],n=s[1],o=s[2],a=s[3],l=this.invSubMix,c=l[0],u=l[1],f=l[2],h=l[3],d=new Uint32Array(256);let g=0,m=0,y=0;for(y=0;y<256;y++)y<128?d[y]=y<<1:d[y]=y<<1^283;for(y=0;y<256;y++){let T=m^m<<1^m<<2^m<<3^m<<4;T=T>>>8^T&255^99,e[g]=T,t[T]=g;const x=d[g],v=d[x],R=d[v];let b=d[T]*257^T*16843008;r[g]=b<<24|b>>>8,n[g]=b<<16|b>>>16,o[g]=b<<8|b>>>24,a[g]=b,b=R*16843009^v*65537^x*257^g*16843008,c[T]=b<<24|b>>>8,u[T]=b<<16|b>>>16,f[T]=b<<8|b>>>24,h[T]=b,g?(g=x^d[d[d[R^x]]],m^=d[d[m]]):g=m=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,r=0;for(;r<t.length&&s;)s=t[r]===this.key[r],r++;if(s)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const o=this.ksRows=(n+6+1)*4;let a,l;const c=this.keySchedule=new Uint32Array(o),u=this.invKeySchedule=new Uint32Array(o),f=this.sBox,h=this.rcon,d=this.invSubMix,g=d[0],m=d[1],y=d[2],T=d[3];let x,v;for(a=0;a<o;a++){if(a<n){x=c[a]=t[a];continue}v=x,a%n===0?(v=v<<8|v>>>24,v=f[v>>>24]<<24|f[v>>>16&255]<<16|f[v>>>8&255]<<8|f[v&255],v^=h[a/n|0]<<24):n>6&&a%n===4&&(v=f[v>>>24]<<24|f[v>>>16&255]<<16|f[v>>>8&255]<<8|f[v&255]),c[a]=x=(c[a-n]^v)>>>0}for(l=0;l<o;l++)a=o-l,l&3?v=c[a]:v=c[a-4],l<4||a<=4?u[l]=v:u[l]=g[f[v>>>24]]^m[f[v>>>16&255]]^y[f[v>>>8&255]]^T[f[v&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const r=this.keySize+6,n=this.invKeySchedule,o=this.invSBox,a=this.invSubMix,l=a[0],c=a[1],u=a[2],f=a[3],h=this.uint8ArrayToUint32Array_(s);let d=h[0],g=h[1],m=h[2],y=h[3];const T=new Int32Array(e),x=new Int32Array(T.length);let v,R,b,M,P,B,K,_,q,W,ue,we,Te,ae;const te=this.networkToHostOrderSwap;for(;t<T.length;){for(q=te(T[t]),W=te(T[t+1]),ue=te(T[t+2]),we=te(T[t+3]),P=q^n[0],B=we^n[1],K=ue^n[2],_=W^n[3],Te=4,ae=1;ae<r;ae++)v=l[P>>>24]^c[B>>16&255]^u[K>>8&255]^f[_&255]^n[Te],R=l[B>>>24]^c[K>>16&255]^u[_>>8&255]^f[P&255]^n[Te+1],b=l[K>>>24]^c[_>>16&255]^u[P>>8&255]^f[B&255]^n[Te+2],M=l[_>>>24]^c[P>>16&255]^u[B>>8&255]^f[K&255]^n[Te+3],P=v,B=R,K=b,_=M,Te=Te+4;v=o[P>>>24]<<24^o[B>>16&255]<<16^o[K>>8&255]<<8^o[_&255]^n[Te],R=o[B>>>24]<<24^o[K>>16&255]<<16^o[_>>8&255]<<8^o[P&255]^n[Te+1],b=o[K>>>24]<<24^o[_>>16&255]<<16^o[P>>8&255]<<8^o[B&255]^n[Te+2],M=o[_>>>24]<<24^o[P>>16&255]<<16^o[B>>8&255]<<8^o[K&255]^n[Te+3],x[t]=te(v^d),x[t+1]=te(M^g),x[t+2]=te(b^m),x[t+3]=te(R^y),d=q,g=W,m=ue,y=we,t=t+4}return x.buffer}}const vp=16;class go{constructor(e,{removePKCS7Padding:t=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}this.subtle===null&&(this.useSoftware=!0)}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const s=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?xp(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s){return this.useSoftware?new Promise((r,n)=>{this.softwareDecrypt(new Uint8Array(e),t,s);const o=this.flush();o?r(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s)}softwareDecrypt(e,t,s){const{currentIV:r,currentResult:n,remainderData:o}=this;this.logOnce("JS AES decrypt"),o&&(e=ls(o,e),this.remainderData=null);const a=this.getValidChunk(e);if(!a.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Sp),l.expandKey(t);const c=n;return this.currentResult=l.decrypt(a.buffer,0,s),this.currentIV=os(a,-16).buffer,c||null}webCryptoDecrypt(e,t,s){const r=this.subtle;return(this.key!==t||!this.fastAesKey)&&(this.key=t,this.fastAesKey=new Ep(r,t)),this.fastAesKey.expandKey().then(n=>r?(this.logOnce("WebCrypto AES decrypt"),new Tp(r,new Uint8Array(s)).decrypt(e.buffer,n)):Promise.reject(new Error("web crypto not initialized"))).catch(n=>(A.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${n.name}: ${n.message}`),this.onWebCryptoError(e,t,s)))}onWebCryptoError(e,t,s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%vp;return s!==e.length&&(t=os(e,0,s),this.remainderData=os(e,s)),t}logOnce(e){this.logEnabled&&(A.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Ap={toString:function(i){let e="";const t=i.length;for(let s=0;s<t;s++)e+=`[${i.start(s).toFixed(3)}-${i.end(s).toFixed(3)}]`;return e}},F={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 mo extends fp{constructor(e,t,s,r,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=F.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=n,this.logPrefix=r,this.log=A.log.bind(A,`${r}:`),this.warn=A.warn.bind(A,`${r}:`),this.hls=e,this.fragmentLoader=new cp(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new go(e.config),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=F.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const s=t.partList;if(s!=null&&s.length){const n=s[s.length-1];return De.isBuffered(this.media,n.start+n.duration/2)}const r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levels[this.levelLastLoaded])==null?void 0:e.details}}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===F.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:s,mediaBuffer:r,state:n}=this,o=s?s.currentTime:0,a=De.bufferInfo(r||s,o,e.maxBufferHole);if(this.log(`media seeking to ${J(o)?o.toFixed(3):o}, state: ${n}`),this.state===F.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,c=t.start-l,u=t.start+t.duration+l;if(!a.len||u<a.start||c>a.end){const f=o>u;(o<c||f)&&(f&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(o,1/0,this.playlistType,!0),this.lastCurrentTime=o),!this.loadedmetadata&&!a.len&&(this.nextLoadPosition=this.startPosition=o),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.stopLoad(),super.onHandlerDestroying()}onHandlerDestroyed(){this.state=F.STOPPED,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(e,t,s){this._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const r=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,s,r).then(n=>{if(!n)return;const o=this.state;if(this.fragContextChanged(e)){(o===F.FRAG_LOADING||!this.fragCurrent&&o===F.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=F.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(p.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===F.STOPPED||this.state===F.ERROR||(this.warn(n),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===Me.APPENDING){const n=e.type,o=this.getFwdBufferInfo(this.mediaBuffer,n),a=Math.max(e.duration,o?o.len:this.config.maxBufferLength);this.reduceMaxBufferLength(a)&&s.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?s.removeAllFragments():s.hasParts(e.type)&&(s.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),s.getState(e)===Me.PARTIAL&&s.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:s};this.hls.trigger(p.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{if(!s||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:r}=this,{payload:n}=s,o=e.decryptdata;if(n&&n.byteLength>0&&o&&o.key&&o.iv&&o.method==="AES-128"){const a=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),o.key.buffer,o.iv.buffer).catch(l=>{throw r.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const c=self.performance.now();return r.trigger(p.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:a,tdecrypt:c}}),s.payload=l,s})}return s}).then(s=>{const{fragCurrent:r,hls:n,levels:o}=this;if(!o)throw new Error("init load aborted, missing levels");const a=e.stats;this.state=F.IDLE,t.fragmentError=0,e.data=new Uint8Array(s.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),s.frag===r&&n.trigger(p.FRAG_BUFFERED,{stats:a,frag:r,part:null,id:e.type}),this.tick()}).catch(s=>{this.state===F.STOPPED||this.state===F.ERROR||(this.warn(s),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var s,r,n,o;const a=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===ie.MAIN?"level":"track"} ${e.level} (frag:[${((s=e.startPTS)!=null?s:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${a?Ap.toString(De.getBuffered(a)):"(detached)"})`),this.state=F.IDLE,a&&(!this.loadedmetadata&&e.type==ie.MAIN&&a.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((o=this.fragPrevious)==null?void 0:o.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:r,partsLoaded:n}=e,o=!n||n.length===0||n.some(l=>!l),a=new fo(s.level,s.sn,s.stats.chunkCount+1,0,r?r.index:-1,!o);t.flush(a)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,r){var n;const o=t==null?void 0:t.details;if(!this.levels||!o)throw new Error(`frag load aborted, missing level${o?"":" detail"}s`);let a=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${o.startSN}-${o.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=F.KEY_LOADING,this.fragCurrent=e,a=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(p.KEY_LOADED,u),this.state===F.KEY_LOADING&&(this.state=F.IDLE),u}),this.hls.trigger(p.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(a=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&o.encryptedFragments.length&&this.keyLoader.loadClear(e,o.encryptedFragments),s=Math.max(e.start,s||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const u=o.partList;if(u&&r){s>e.end&&o.fragmentHint&&(e=o.fragmentHint);const f=this.getNextPart(u,e,s);if(f>-1){const h=u[f];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${o.startSN}-${o.endSN}] parts [0-${f}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=F.FRAG_LOADING;let d;return a?d=a.then(g=>!g||this.fragContextChanged(g.frag)?null:this.doFragPartsLoad(e,h,t,r)).catch(g=>this.handleFragLoadError(g)):d=this.doFragPartsLoad(e,h,t,r).catch(g=>this.handleFragLoadError(g)),this.hls.trigger(p.FRAG_LOADING,{frag:e,part:h,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):d}else if(!e.url||this.loadedEndOfParts(u,s))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${o?"of ["+o.startSN+"-"+o.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),J(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=F.FRAG_LOADING;const l=this.config.progressive;let c;return l&&a?c=a.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,r)).catch(u=>this.handleFragLoadError(u)):c=Promise.all([this.fragmentLoader.load(e,l?r:void 0),a]).then(([u])=>(!l&&u&&r&&r(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(p.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c}doFragPartsLoad(e,t,s,r){return new Promise((n,o)=>{var a;const l=[],c=(a=s.details)==null?void 0:a.partList,u=f=>{this.fragmentLoader.loadPart(e,f,r).then(h=>{l[f.index]=h;const d=h.part;this.hls.trigger(p.FRAG_LOADED,h);const g=qa(s,e.sn,f.index+1)||mu(c,e.sn,f.index+1);if(g)u(g);else return n({frag:e,part:d,partsLoaded:l})}).catch(o)};u(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(p.ERROR,t)}else this.hls.trigger(p.ERROR,{type:se.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==F.PARSING){!this.fragCurrent&&this.state!==F.STOPPED&&this.state!==F.ERROR&&(this.state=F.IDLE);return}const{frag:s,part:r,level:n}=t,o=self.performance.now();s.stats.parsing.end=o,r&&(r.stats.parsing.end=o),this.updateLevelTiming(s,r,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:r,sn:n,part:o}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${r}. The current chunk will not be buffered.`),null;const a=t[r],l=o>-1?qa(a,n,o):null,c=l?l.fragment:Zm(a,n,s);return c?(s&&s!==c&&(c.stats=s.stats),{frag:c,part:l,level:a}):null}bufferFragmentData(e,t,s,r,n){var o;if(!e||this.state!==F.PARSING)return;const{data1:a,data2:l}=e;let c=a;if(a&&l&&(c=ls(a,l)),!((o=c)!=null&&o.length))return;const u={type:e.type,frag:t,part:s,chunkMeta:r,parent:t.type,data:c};if(this.hls.trigger(p.BUFFER_APPENDING,u),e.dropped&&e.independent&&!s){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!De.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,r=De.bufferInfo(t,s,0),n=e.duration,o=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),a=Math.max(Math.min(e.start-o,r.end-o),s+o);e.start-a>o&&this.flushMainBuffer(a,e.start)}getFwdBufferInfo(e,t){const s=this.getLoadPosition();return J(s)?this.getFwdBufferInfoAtPos(e,s,t):null}getFwdBufferInfoAtPos(e,t,s){const{config:{maxBufferHole:r}}=this,n=De.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){const o=this.fragmentTracker.getBufferedFrag(t,s);if(o&&n.nextStart<o.end)return De.bufferInfo(e,t,Math.max(n.nextStart,r))}return n}getMaxBufferLength(e){const{config:t}=this;let s;return e?s=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):s=t.maxBufferLength,Math.min(s,t.maxMaxBufferLength)}reduceMaxBufferLength(e){const t=this.config,s=e||t.maxBufferLength;return t.maxMaxBufferLength>=s?(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0):!1}getAppendedFrag(e,t=ie.MAIN){const s=this.fragmentTracker.getAppendedFrag(e,ie.MAIN);return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,r=s.length;if(!r)return null;const{config:n}=this,o=s[0].start;let a;if(t.live){const l=n.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1&&(a=this.getInitialLiveFragment(t,s),this.startPosition=a?this.hls.liveSyncPosition||a.start:e)}else e<=o&&(a=s[0]);if(!a){const l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;a=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(a)}isLoopLoading(e,t){const s=this.fragmentTracker.getState(e);return(s===Me.OK||s===Me.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,s,r,n){const o=e.gap,a=this.getNextFragment(this.nextLoadPosition,t);if(a===null)return a;if(e=a,o&&e&&!e.gap&&s.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,r);if(l!==null&&s.len+l.len>=n)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let r=-1,n=!1,o=!0;for(let a=0,l=e.length;a<l;a++){const c=e[a];if(o=o&&!c.independent,r>-1&&s<c.start)break;const u=c.loaded;u?r=-1:(n||c.independent||o)&&c.fragment===t&&(r=a),n=u}return r}loadedEndOfParts(e,t){const s=e[e.length-1];return s&&t>s.start&&s.loaded}getInitialLiveFragment(e,t){const s=this.fragPrevious;let r=null;if(s){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),r=tp(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const n=s.sn+1;if(n>=e.startSN&&n<=e.endSN){const o=t[n-e.startSN];s.cc===o.cc&&(r=o,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=ip(t,s.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,s){const{config:r}=this;let{fragPrevious:n}=this,{fragments:o,endSN:a}=s;const{fragmentHint:l}=s,c=r.maxFragLookUpTolerance,u=s.partList,f=!!(r.lowLatencyMode&&u!=null&&u.length&&l);f&&l&&!this.bitrateTest&&(o=o.concat(l),a=l.sn);let h;if(e<t){const d=e>t-c?0:c;h=ni(n,o,e,d)}else h=o[o.length-1];if(h){const d=h.sn-s.startSN,g=this.fragmentTracker.getState(h);if((g===Me.OK||g===Me.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!f||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){const y=o[d+1];h.sn<a&&this.fragmentTracker.getState(y)!==Me.OK?h=y:h=null}}return h}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const r=this.hls.liveSyncPosition,n=s.currentTime,o=e.fragments[0].start,a=e.edge,l=n>=o-t.maxFragLookUpTolerance&&n<=a;if(r!==null&&s.duration>r&&(n<r||!l)){const c=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&s.readyState<4||n<a-c)&&(this.loadedmetadata||(this.nextLoadPosition=r),s.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${r.toFixed(3)}`),s.currentTime=r))}}alignPlaylists(e,t){const{levels:s,levelLastLoaded:r,fragPrevious:n}=this,o=r!==null?s[r]:null,a=e.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;const l=e.fragments[0].start,c=!t,u=e.alignedSliding&&J(l);if(c||!u&&!l){mp(n,o,e);const f=e.fragments[0].start;return this.log(`Live playlist sliding: ${f.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${a}`),f}return l}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let s=this.startPosition;if(s<t&&(s=-1),s===-1||this.lastCurrentTime===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&J(n)?(s=t+n,n<0&&(s+=e.totalduration),s=Math.min(Math.max(t,s),t+e.totalduration),this.log(`Start time offset ${n} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${s}`),this.startPosition=s):e.live?s=this.hls.liveSyncPosition||t:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==F.FRAG_LOADING_WAITING_RETRY)&&(this.state=F.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const f=this.getCurrentContext(t.chunkMeta);f&&(t.frag=f.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=t.details===D.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(s,!0);const o=t.errorAction,{action:a,retryCount:l=0,retryConfig:c}=o||{};if(o&&a===Ve.RetryRequest&&c){var u;this.resetStartWhenNotLoaded((u=this.levelLastLoaded)!=null?u:s.level);const f=co(c,l);this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${l+1}/${c.maxNumRetry} in ${f}ms`),o.resolved=!0,this.retryDate=self.performance.now()+f,this.state=F.FRAG_LOADING_WAITING_RETRY}else c&&o?(this.resetFragmentErrors(e),l<c.maxNumRetry?n||(o.resolved=!0):A.warn(`${t.details} reached or exceeded max retry (${l})`)):(o==null?void 0:o.action)===Ve.SendAlternateToPenaltyBox?this.state=F.WAITING_LEVEL:this.state=F.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===F.PARSING||this.state===F.PARSED){const t=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===ie.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==F.STOPPED&&(this.state=F.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const r=De.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,s),this.state===F.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=F.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded((t=this.levelLastLoaded)!=null?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,s,r){var n;const o=s.details;if(!o){this.warn("level.details undefined");return}if(Object.keys(e.elementaryStreams).reduce((l,c)=>{const u=e.elementaryStreams[c];if(u){const f=u.endPTS-u.startPTS;if(f<=0)return this.warn(`Could not parse fragment ${e.sn} ${c} duration reliably (${f})`),l||!1;const h=r?0:du(o,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(p.LEVEL_PTS_UPDATED,{details:o,level:s,drift:h,type:c,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1))s.fragmentError=0;else if(((n=this.transmuxer)==null?void 0:n.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(s.fragmentError===0&&(s.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=F.PARSED,this.hls.trigger(p.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){if(e.event==="demuxerWorker"){var t,s,r;this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded((t=(s=this.levelLastLoaded)!=null?s:(r=this.fragCurrent)==null?void 0:r.level)!=null?t:0),this.resetLoadingState()}}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function Eu(){return self.SourceBuffer||self.WebKitSourceBuffer}function Rp(){const i=pr();if(!i)return!1;const e=Eu(),t=i&&typeof i.isTypeSupported=="function"&&i.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),s=!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function";return!!t&&!!s}function Lp(){var i;const e=Eu();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}function bp(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Ip(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function Dp(i){const e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function At(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class xu{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,s,r){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,s){}demux(e,t){this.cachedData&&(e=ls(this.cachedData,e),this.cachedData=null);let s=Ki(e,0),r=s?s.length:0,n;const o=this._audioTrack,a=this._id3Track,l=s?um(s):void 0,c=e.length;for((this.basePTS===null||this.frameIndex===0&&J(l))&&(this.basePTS=_p(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),s&&s.length>0&&a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ut.audioId3,duration:Number.POSITIVE_INFINITY});r<c;){if(this.canParse(e,r)){const u=this.appendFrame(o,e,r);u?(this.frameIndex++,this.lastPTS=u.sample.pts,r+=u.length,n=r):r=c}else cm(e,r)?(s=Ki(e,r),a.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ut.audioId3,duration:Number.POSITIVE_INFINITY}),r+=s.length,n=r):r++;if(r===c&&n!==c){const u=os(e,n);this.cachedData?this.cachedData=ls(this.cachedData,u):this.cachedData=u}}return{audioTrack:o,videoTrack:At(),id3Track:a,textTrack:At()}}demuxSampleAes(e,t,s){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:At(),id3Track:this._id3Track,textTrack:At()}}destroy(){}}const _p=(i,e,t)=>{if(J(i))return i*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};function Cp(i,e,t,s){let r,n,o,a;const l=navigator.userAgent.toLowerCase(),c=s,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;const f=(e[t+2]&60)>>>2;if(f>u.length-1){i.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${f}`});return}return o=(e[t+2]&1)<<2,o|=(e[t+3]&192)>>>6,A.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${f}`),/firefox/i.test(l)?f>=6?(r=5,a=new Array(4),n=f-3):(r=2,a=new Array(2),n=f):l.indexOf("android")!==-1?(r=2,a=new Array(2),n=f):(r=5,a=new Array(4),s&&(s.indexOf("mp4a.40.29")!==-1||s.indexOf("mp4a.40.5")!==-1)||!s&&f>=6?n=f-3:((s&&s.indexOf("mp4a.40.2")!==-1&&(f>=6&&o===1||/vivaldi/i.test(l))||!s&&o===1)&&(r=2,a=new Array(2)),n=f)),a[0]=r<<3,a[0]|=(f&14)>>1,a[1]|=(f&1)<<7,a[1]|=o<<3,r===5&&(a[1]|=(n&14)>>1,a[2]=(n&1)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:u[f],channelCount:o,codec:"mp4a.40."+r,manifestCodec:c}}function Su(i,e){return i[e]===255&&(i[e+1]&246)===240}function vu(i,e){return i[e+1]&1?7:9}function po(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function wp(i,e){return e+5<i.length}function ji(i,e){return e+1<i.length&&Su(i,e)}function Pp(i,e){return wp(i,e)&&Su(i,e)&&po(i,e)<=i.length-e}function kp(i,e){if(ji(i,e)){const t=vu(i,e);if(e+t>=i.length)return!1;const s=po(i,e);if(s<=t)return!1;const r=e+s;return r===i.length||ji(i,r)}return!1}function Au(i,e,t,s,r){if(!i.samplerate){const n=Cp(e,t,s,r);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,A.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Ru(i){return 1024*9e4/i}function Op(i,e){const t=vu(i,e);if(e+t<=i.length){const s=po(i,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function Lu(i,e,t,s,r){const n=Ru(i.samplerate),o=s+r*n,a=Op(e,t);let l;if(a){const{frameLength:f,headerLength:h}=a,d=h+f,g=Math.max(0,t+d-e.length);g?(l=new Uint8Array(d-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+d);const m={unit:l,pts:o};return g||i.samples.push(m),{sample:m,length:d,missing:g}}const c=e.length-t;return l=new Uint8Array(c),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:o},length:c,missing:-1}}class Fp extends xu{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let s=(Ki(e,0)||[]).length;for(let r=e.length;s<r;s++)if(kp(e,s))return A.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Pp(e,t)}appendFrame(e,t,s){Au(e,this.observer,t,s,e.manifestCodec);const r=Lu(e,t,s,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const Np=/\/emsg[-/]ID3/i;class Mp{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,s,r){const n=this.videoTrack=At("video",1),o=this.audioTrack=At("audio",1),a=this.txtTrack=At("text",1);if(this.id3Track=At("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=ou(e);if(l.video){const{id:c,timescale:u,codec:f}=l.video;n.id=c,n.timescale=a.timescale=u,n.codec=f}if(l.audio){const{id:c,timescale:u,codec:f}=l.audio;o.id=c,o.timescale=u,o.codec=f}a.id=iu.text,n.sampleDuration=0,n.duration=o.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return e=e.length>16384?e.subarray(0,16384):e,pe(e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let s=e;const r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=ls(this.remainderData,e));const a=Lm(s);this.remainderData=a.remainder,r.samples=a.valid||new Uint8Array}else r.samples=s;const o=this.extractID3Track(r,t);return n.samples=ka(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:o,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return s.samples=ka(e,t),{videoTrack:t,audioTrack:At(),id3Track:r,textTrack:At()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const r=pe(e.samples,["emsg"]);r&&r.forEach(n=>{const o=Dm(n);if(Np.test(o.schemeIdUri)){const a=J(o.presentationTime)?o.presentationTime/o.timeScale:t+o.presentationTimeDelta/o.timeScale;let l=o.eventDuration===4294967295?Number.POSITIVE_INFINITY:o.eventDuration/o.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const c=o.payload;s.samples.push({data:c,len:c.byteLength,dts:a,pts:a,type:ut.emsg,duration:l})}})}return s}demuxSampleAes(e,t,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}let Ti=null;const Up=[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],Bp=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],$p=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Gp=[0,1,1,4];function bu(i,e,t,s,r){if(t+24>e.length)return;const n=Iu(e,t);if(n&&t+n.frameLength<=e.length){const o=n.samplesPerFrame*9e4/n.sampleRate,a=s+r*o,l={unit:e.subarray(t,t+n.frameLength),pts:a,dts:a};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Iu(i,e){const t=i[e+1]>>3&3,s=i[e+1]>>1&3,r=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){const o=i[e+2]>>1&1,a=i[e+3]>>6,l=t===3?3-s:s===3?3:4,c=Up[l*14+r-1]*1e3,f=Bp[(t===3?0:t===2?1:2)*3+n],h=a===3?1:2,d=$p[t][s],g=Gp[s],m=d*8*g,y=Math.floor(d*c/f+o)*g;if(Ti===null){const v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ti=v?parseInt(v[1]):0}return!!Ti&&Ti<=87&&s===2&&c>=224e3&&a===0&&(i[e+3]=i[e+3]|128),{sampleRate:f,channelCount:h,frameLength:y,samplesPerFrame:m}}}function yo(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Du(i,e){return e+1<i.length&&yo(i,e)}function Kp(i,e){return yo(i,e)&&4<=i.length-e}function Hp(i,e){if(e+1<i.length&&yo(i,e)){const s=Iu(i,e);let r=4;s!=null&&s.frameLength&&(r=s.frameLength);const n=e+r;return n===i.length||Du(i,n)}return!1}class sl{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,s=e.byteLength-t,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(s,s+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const s=this.word>>>32-t;if(e>32&&A.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?s<<t|this.readBits(t):s}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,s=8,r;for(let n=0;n<e;n++)s!==0&&(r=this.readEG(),s=(t+r+256)%256),t=s===0?t:s}readSPS(){let e=0,t=0,s=0,r=0,n,o,a;const l=this.readUByte.bind(this),c=this.readBits.bind(this),u=this.readUEG.bind(this),f=this.readBoolean.bind(this),h=this.skipBits.bind(this),d=this.skipEG.bind(this),g=this.skipUEG.bind(this),m=this.skipScalingList.bind(this);l();const y=l();if(c(5),h(3),l(),g(),y===100||y===110||y===122||y===244||y===44||y===83||y===86||y===118||y===128){const M=u();if(M===3&&h(1),g(),g(),h(1),f())for(o=M!==3?8:12,a=0;a<o;a++)f()&&(a<6?m(16):m(64))}g();const T=u();if(T===0)u();else if(T===1)for(h(1),d(),d(),n=u(),a=0;a<n;a++)d();g(),h(1);const x=u(),v=u(),R=c(1);R===0&&h(1),h(1),f()&&(e=u(),t=u(),s=u(),r=u());let b=[1,1];if(f()&&f())switch(l()){case 1:b=[1,1];break;case 2:b=[12,11];break;case 3:b=[10,11];break;case 4:b=[16,11];break;case 5:b=[40,33];break;case 6:b=[24,11];break;case 7:b=[20,11];break;case 8:b=[32,11];break;case 9:b=[80,33];break;case 10:b=[18,11];break;case 11:b=[15,11];break;case 12:b=[64,33];break;case 13:b=[160,99];break;case 14:b=[4,3];break;case 15:b=[3,2];break;case 16:b=[2,1];break;case 255:{b=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((x+1)*16-e*2-t*2),height:(2-R)*(v+1)*16-(R?2:4)*(s+r),pixelRatio:b}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Vp{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new go(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,s){const r=e[t].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),o=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(o).then(a=>{const l=new Uint8Array(a);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,s)})}decryptAacSamples(e,t,s){for(;;t++){if(t>=e.length){s();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,s),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,s=new Int8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)s.set(e.subarray(n,n+16),r);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(s.subarray(r,r+16),n);return e}decryptAvcSample(e,t,s,r,n){const o=cu(n.data),a=this.getAvcEncryptedData(o);this.decryptBuffer(a.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(o,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,r)})}decryptAvcSamples(e,t,s,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){r();return}const n=e[t].units;for(;!(s>=n.length);s++){const o=n[s];if(!(o.data.length<=48||o.type!==1&&o.type!==5)&&(this.decryptAvcSample(e,t,s,r,o),!this.decrypter.isSync()))return}}}}const He=188;class Wt{constructor(e,t,s){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=s}static probe(e){const t=Wt.syncOffset(e);return t>0&&A.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let s=Math.min(He*5,e.length-He)+1,r=0;for(;r<s;){let n=!1,o=-1,a=0;for(let l=r;l<t;l+=He)if(e[l]===71){if(a++,o===-1&&(o=l,o!==0&&(s=Math.min(o+He*99,e.length-He)+1)),n||(n=_n(e,l)===0),n&&a>1&&(o===0&&a>2||l+He>s))return o}else{if(a)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:iu[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Wt.createTrack("video"),this._audioTrack=Wt.createTrack("audio",r),this._id3Track=Wt.createTrack("id3"),this._txtTrack=Wt.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s,this._duration=r}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:s}=this;e&&(e.pesData=null),t&&(t.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,s=!1,r=!1){s||(this.sampleAes=null);let n;const o=this._avcTrack,a=this._audioTrack,l=this._id3Track,c=this._txtTrack;let u=o.pid,f=o.pesData,h=a.pid,d=l.pid,g=a.pesData,m=l.pesData,y=null,T=this.pmtParsed,x=this._pmtId,v=e.length;if(this.remainderData&&(e=ls(this.remainderData,e),v=e.length,this.remainderData=null),v<He&&!r)return this.remainderData=e,{audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};const R=Math.max(0,Wt.syncOffset(e));v-=(v-R)%He,v<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,v,e.buffer.byteLength-v));let b=0;for(let P=R;P<v;P+=He)if(e[P]===71){const B=!!(e[P+1]&64),K=_n(e,P),_=(e[P+3]&48)>>4;let q;if(_>1){if(q=P+5+e[P+4],q===P+He)continue}else q=P+4;switch(K){case u:B&&(f&&(n=hs(f))&&this.parseAVCPES(o,c,n,!1),f={data:[],size:0}),f&&(f.data.push(e.subarray(q,P+He)),f.size+=P+He-q);break;case h:if(B){if(g&&(n=hs(g)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,n);break;case"mp3":this.parseMPEGPES(a,n);break}g={data:[],size:0}}g&&(g.data.push(e.subarray(q,P+He)),g.size+=P+He-q);break;case d:B&&(m&&(n=hs(m))&&this.parseID3PES(l,n),m={data:[],size:0}),m&&(m.data.push(e.subarray(q,P+He)),m.size+=P+He-q);break;case 0:B&&(q+=e[q]+1),x=this._pmtId=Wp(e,q);break;case x:{B&&(q+=e[q]+1);const W=Yp(e,q,this.typeSupported,s);u=W.avc,u>0&&(o.pid=u),h=W.audio,h>0&&(a.pid=h,a.segmentCodec=W.segmentCodec),d=W.id3,d>0&&(l.pid=d),y!==null&&!T&&(A.warn(`MPEG-TS PMT found at ${P} after unknown PID '${y}'. Backtracking to sync byte @${R} to parse all TS packets.`),y=null,P=R-188),T=this.pmtParsed=!0;break}case 17:case 8191:break;default:y=K;break}}else b++;if(b>0){const P=new Error(`Found ${b} TS packet/s that do not start with 0x47`);this.observer.emit(p.ERROR,p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:P,reason:P.message})}o.pesData=f,a.pesData=g,l.pesData=m;const M={audioTrack:a,videoTrack:o,id3Track:l,textTrack:c};return r&&this.extractRemainingSamples(M),M}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:s,id3Track:r,textTrack:n}=e,o=s.pesData,a=t.pesData,l=r.pesData;let c;if(o&&(c=hs(o))?(this.parseAVCPES(s,n,c,!0),s.pesData=null):s.pesData=o,a&&(c=hs(a))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,c);break;case"mp3":this.parseMPEGPES(t,c);break}t.pesData=null}else a!=null&&a.size&&A.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=a;l&&(c=hs(l))?(this.parseID3PES(r,c),r.pesData=null):r.pesData=l}demuxSampleAes(e,t,s){const r=this.demux(e,s,!0,!this.config.progressive),n=this.sampleAes=new Vp(this.observer,this.config,t);return this.decrypt(r,n)}decrypt(e,t){return new Promise(s=>{const{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{s(e)}):s(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{s(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,s,r){const n=this.parseAVCNALu(e,s.data);let o=this.avcSample,a,l=!1;s.data=null,o&&n.length&&!e.audFound&&(Ms(o,e),o=this.avcSample=Ei(!1,s.pts,s.dts,"")),n.forEach(c=>{var u;switch(c.type){case 1:{let h=!1;a=!0;const d=c.data;if(l&&d.length>4){const g=new sl(d).readSliceType();(g===2||g===4||g===7||g===9)&&(h=!0)}if(h){var f;(f=o)!=null&&f.frame&&!o.key&&(Ms(o,e),o=this.avcSample=null)}o||(o=this.avcSample=Ei(!0,s.pts,s.dts,"")),o.frame=!0,o.key=h;break}case 5:a=!0,(u=o)!=null&&u.frame&&!o.key&&(Ms(o,e),o=this.avcSample=null),o||(o=this.avcSample=Ei(!0,s.pts,s.dts,"")),o.key=!0,o.frame=!0;break;case 6:{a=!0,lu(c.data,1,s.pts,t.samples);break}case 7:if(a=!0,l=!0,!e.sps){const h=c.data,g=new sl(h).readSPS();e.width=g.width,e.height=g.height,e.pixelRatio=g.pixelRatio,e.sps=[h],e.duration=this._duration;const m=h.subarray(1,4);let y="avc1.";for(let T=0;T<3;T++){let x=m[T].toString(16);x.length<2&&(x="0"+x),y+=x}e.codec=y}break;case 8:a=!0,e.pps||(e.pps=[c.data]);break;case 9:a=!1,e.audFound=!0,o&&Ms(o,e),o=this.avcSample=Ei(!1,s.pts,s.dts,"");break;case 12:a=!0;break;default:a=!1,o&&(o.debug+="unknown NAL "+c.type+" ");break}o&&a&&o.units.push(c)}),r&&o&&(Ms(o,e),this.avcSample=null)}getLastNalUnit(e){var t;let s=this.avcSample,r;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const n=s.units;r=n[n.length-1]}return r}parseAVCNALu(e,t){const s=t.byteLength;let r=e.naluState||0;const n=r,o=[];let a=0,l,c,u,f=-1,h=0;for(r===-1&&(f=0,h=t[0]&31,r=0,a=1);a<s;){if(l=t[a++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(f>=0){const d={data:t.subarray(f,a-r-1),type:h};o.push(d)}else{const d=this.getLastNalUnit(e.samples);if(d&&(n&&a<=4-n&&d.state&&(d.data=d.data.subarray(0,d.data.byteLength-n)),c=a-r-1,c>0)){const g=new Uint8Array(d.data.byteLength+c);g.set(d.data,0),g.set(t.subarray(0,c),d.data.byteLength),d.data=g,d.state=0}}a<s?(u=t[a]&31,f=a,h=u,r=0):r=-1}else r=0}if(f>=0&&r>=0){const d={data:t.subarray(f,s),type:h,state:r};o.push(d)}if(o.length===0){const d=this.getLastNalUnit(e.samples);if(d){const g=new Uint8Array(d.data.byteLength+t.byteLength);g.set(d.data,0),g.set(t,d.data.byteLength),d.data=g}}return e.naluState=r,o}parseAACPES(e,t){let s=0;const r=this.aacOverFlow;let n=t.data;if(r){this.aacOverFlow=null;const f=r.missing,h=r.sample.unit.byteLength;if(f===-1){const d=new Uint8Array(h+n.byteLength);d.set(r.sample.unit,0),d.set(n,h),n=d}else{const d=h-f;r.sample.unit.set(n.subarray(0,f),d),e.samples.push(r.sample),s=r.missing}}let o,a;for(o=s,a=n.length;o<a-1&&!ji(n,o);o++);if(o!==s){let f;const h=o<a-1;h?f=`AAC PES did not start with ADTS header,offset:${o}`:f="No ADTS header found in AAC PES";const d=new Error(f);if(A.warn(`parsing error: ${f}`),this.observer.emit(p.ERROR,p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:h,error:d,reason:f}),!h)return}Au(e,this.observer,n,o,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){const f=Ru(e.samplerate);l=r.sample.pts+f}else{A.warn("[tsdemuxer]: AAC PES unknown PTS");return}let c=0,u;for(;o<a;)if(u=Lu(e,n,o,l,c),o+=u.length,u.missing){this.aacOverFlow=u;break}else for(c++;o<a-1&&!ji(n,o);o++);}parseMPEGPES(e,t){const s=t.data,r=s.length;let n=0,o=0;const a=t.pts;if(a===void 0){A.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;o<r;)if(Du(s,o)){const l=bu(e,s,o,a,n);if(l)o+=l.length,n++;else break}else o++}parseID3PES(e,t){if(t.pts===void 0){A.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=Ne({},t,{type:this._avcTrack?ut.emsg:ut.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function Ei(i,e,t,s){return{key:i,frame:!1,pts:e,dts:t,units:[],debug:s,length:0}}function _n(i,e){return((i[e+1]&31)<<8)+i[e+2]}function Wp(i,e){return(i[e+10]&31)<<8|i[e+11]}function Yp(i,e,t,s){const r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},n=(i[e+1]&15)<<8|i[e+2],o=e+3+n-4,a=(i[e+10]&15)<<8|i[e+11];for(e+=12+a;e<o;){const l=_n(i,e);switch(i[e]){case 207:if(!s){A.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:r.audio===-1&&(r.audio=l);break;case 21:r.id3===-1&&(r.id3=l);break;case 219:if(!s){A.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:r.avc===-1&&(r.avc=l);break;case 3:case 4:t.mpeg!==!0&&t.mp3!==!0?A.log("MPEG audio found, not supported in this browser"):r.audio===-1&&(r.audio=l,r.segmentCodec="mp3");break;case 36:A.warn("Unsupported HEVC stream type found");break}e+=((i[e+3]&15)<<8|i[e+4])+5}return r}function hs(i){let e=0,t,s,r,n,o;const a=i.data;if(!i||i.size===0)return null;for(;a[0].length<19&&a.length>1;){const c=new Uint8Array(a[0].length+a[1].length);c.set(a[0]),c.set(a[1],a[0].length),a[0]=c,a.splice(1,1)}if(t=a[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(s=(t[4]<<8)+t[5],s&&s>i.size-6)return null;const c=t[7];c&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,c&64?(o=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-o>60*9e4&&(A.warn(`${Math.round((n-o)/9e4)}s delta between PTS and DTS, align them`),n=o)):o=n),r=t[8];let u=r+9;if(i.size<=u)return null;i.size-=u;const f=new Uint8Array(i.size);for(let h=0,d=a.length;h<d;h++){t=a[h];let g=t.byteLength;if(u)if(u>g){u-=g;continue}else t=t.subarray(u),g-=u,u=0;f.set(t,e),e+=g}return s&&(s-=r+3),{data:f,pts:n,dts:o,len:s}}return null}function Ms(i,e){if(i.units.length&&i.frame){if(i.pts===void 0){const t=e.samples,s=t.length;if(s){const r=t[s-1];i.pts=r.pts,i.dts=r.dts}else{e.dropped++;return}}e.samples.push(i)}i.debug.length&&A.log(i.pts+"/"+i.dts+":"+i.debug)}class jp extends xu{resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let s=(Ki(e,0)||[]).length;for(let r=e.length;s<r;s++)if(Hp(e,s))return A.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Kp(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return bu(e,t,s,this.basePTS,this.frameIndex)}}class il{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}const Kt=Math.pow(2,32)-1;class I{static init(){I.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in I.types)I.types.hasOwnProperty(e)&&(I.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),s=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]);I.HDLR_TYPES={video:t,audio:s};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);I.STTS=I.STSC=I.STCO=n,I.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),I.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),I.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),I.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const o=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);I.FTYP=I.box(I.types.ftyp,o,l,o,a),I.DINF=I.box(I.types.dinf,I.box(I.types.dref,r))}static box(e,...t){let s=8,r=t.length;const n=r;for(;r--;)s+=t[r].byteLength;const o=new Uint8Array(s);for(o[0]=s>>24&255,o[1]=s>>16&255,o[2]=s>>8&255,o[3]=s&255,o.set(e,4),r=0,s=8;r<n;r++)o.set(t[r],s),s+=t[r].byteLength;return o}static hdlr(e){return I.box(I.types.hdlr,I.HDLR_TYPES[e])}static mdat(e){return I.box(I.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(Kt+1)),r=Math.floor(t%(Kt+1));return I.box(I.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return I.box(I.types.mdia,I.mdhd(e.timescale,e.duration),I.hdlr(e.type),I.minf(e))}static mfhd(e){return I.box(I.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?I.box(I.types.minf,I.box(I.types.smhd,I.SMHD),I.DINF,I.stbl(e)):I.box(I.types.minf,I.box(I.types.vmhd,I.VMHD),I.DINF,I.stbl(e))}static moof(e,t,s){return I.box(I.types.moof,I.mfhd(e),I.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=I.trak(e[t]);return I.box.apply(null,[I.types.moov,I.mvhd(e[0].timescale,e[0].duration)].concat(s).concat(I.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=I.trex(e[t]);return I.box.apply(null,[I.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(Kt+1)),r=Math.floor(t%(Kt+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,e&255,s>>24,s>>16&255,s>>8&255,s&255,r>>24,r>>16&255,r>>8&255,r&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 I.box(I.types.mvhd,n)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let r,n;for(r=0;r<t.length;r++)n=t[r].flags,s[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return I.box(I.types.sdtp,s)}static stbl(e){return I.box(I.types.stbl,I.stsd(e),I.box(I.types.stts,I.STTS),I.box(I.types.stsc,I.STSC),I.box(I.types.stsz,I.STSZ),I.box(I.types.stco,I.STCO))}static avc1(e){let t=[],s=[],r,n,o;for(r=0;r<e.sps.length;r++)n=e.sps[r],o=n.byteLength,t.push(o>>>8&255),t.push(o&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],o=n.byteLength,s.push(o>>>8&255),s.push(o&255),s=s.concat(Array.prototype.slice.call(n));const a=I.box(I.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),l=e.width,c=e.height,u=e.pixelRatio[0],f=e.pixelRatio[1];return I.box(I.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,l>>8&255,l&255,c>>8&255,c&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]),a,I.box(I.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),I.box(I.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,f>>24,f>>16&255,f>>8&255,f&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){const t=e.samplerate;return I.box(I.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]),I.box(I.types.esds,I.esds(e)))}static mp3(e){const t=e.samplerate;return I.box(I.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0]))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?I.box(I.types.stsd,I.STSD,I.mp3(e)):I.box(I.types.stsd,I.STSD,I.mp4a(e)):I.box(I.types.stsd,I.STSD,I.avc1(e))}static tkhd(e){const t=e.id,s=e.duration*e.timescale,r=e.width,n=e.height,o=Math.floor(s/(Kt+1)),a=Math.floor(s%(Kt+1));return I.box(I.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,o>>24,o>>16&255,o>>8&255,o&255,a>>24,a>>16&255,a>>8&255,a&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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const s=I.sdtp(e),r=e.id,n=Math.floor(t/(Kt+1)),o=Math.floor(t%(Kt+1));return I.box(I.types.traf,I.box(I.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),I.box(I.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,o>>24,o>>16&255,o>>8&255,o&255])),I.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,I.box(I.types.trak,I.tkhd(e),I.mdia(e))}static trex(e){const t=e.id;return I.box(I.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const s=e.samples||[],r=s.length,n=12+16*r,o=new Uint8Array(n);let a,l,c,u,f,h;for(t+=8+n,o.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),a=0;a<r;a++)l=s[a],c=l.duration,u=l.size,f=l.flags,h=l.cts,o.set([c>>>24&255,c>>>16&255,c>>>8&255,c&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,f.isLeading<<2|f.dependsOn,f.isDependedOn<<6|f.hasRedundancy<<4|f.paddingValue<<1|f.isNonSync,f.degradPrio&61440,f.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*a);return I.box(I.types.trun,o)}static initSegment(e){I.types||I.init();const t=I.moov(e),s=new Uint8Array(I.FTYP.byteLength+t.byteLength);return s.set(I.FTYP),s.set(t,I.FTYP.byteLength),s}}I.types=void 0;I.HDLR_TYPES=void 0;I.STTS=void 0;I.STSC=void 0;I.STCO=void 0;I.STSZ=void 0;I.VMHD=void 0;I.SMHD=void 0;I.STSD=void 0;I.FTYP=void 0;I.DINF=void 0;const _u=9e4;function To(i,e,t=1,s=!1){const r=i*e*t;return s?Math.round(r):r}function qp(i,e,t=1,s=!1){return To(i,e,1/t,s)}function Us(i,e=!1){return To(i,1e3,1/_u,e)}function zp(i,e=1){return To(i,_u,1/e)}const Xp=10*1e3,rl=1024,Qp=1152;let xi=null,$r=null;class Gr{constructor(e,t,s,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=s,this.ISGenerated=!1,xi===null){const o=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);xi=o?parseInt(o[1]):0}if($r===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);$r=n?parseInt(n[1]):0}}destroy(){}resetTimeStamp(e){A.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){A.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){A.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const s=e.reduce((r,n)=>{const o=n.pts-r;return o<-4294967296?(t=!0,rt(r,n.pts)):o>0?r:n.pts},e[0].pts);return t&&A.debug("PTS rollover detected"),s}remux(e,t,s,r,n,o,a,l){let c,u,f,h,d,g,m=n,y=n;const T=e.pid>-1,x=t.pid>-1,v=t.samples.length,R=e.samples.length>0,b=a&&v>0||v>1;if((!T||R)&&(!x||b)||this.ISGenerated||a){this.ISGenerated||(f=this.generateIS(e,t,n,o));const P=this.isVideoContiguous;let B=-1,K;if(b&&(B=Jp(t.samples),!P&&this.config.forceKeyFrameOnDiscontinuity))if(g=!0,B>0){A.warn(`[mp4-remuxer]: Dropped ${B} out of ${v} video samples due to a missing keyframe`);const _=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(B),t.dropped+=B,y+=(t.samples[0].pts-_)/t.inputTimeScale,K=y}else B===-1&&(A.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),g=!1);if(this.ISGenerated){if(R&&b){const _=this.getVideoStartPts(t.samples),W=(rt(e.samples[0].pts,_)-_)/t.inputTimeScale;m+=Math.max(0,W),y+=Math.max(0,-W)}if(R){if(e.samplerate||(A.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),f=this.generateIS(e,t,n,o)),u=this.remuxAudio(e,m,this.isAudioContiguous,o,x||b||l===ie.AUDIO?y:void 0),b){const _=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(A.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),f=this.generateIS(e,t,n,o)),c=this.remuxVideo(t,y,P,_)}}else b&&(c=this.remuxVideo(t,y,P,0));c&&(c.firstKeyFrame=B,c.independent=B!==-1,c.firstKeyFramePTS=K)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(d=Cu(s,n,this._initPTS,this._initDTS)),r.samples.length&&(h=wu(r,n,this._initPTS))),{audio:u,video:c,initSegment:f,independent:g,text:h,id3:d}}generateIS(e,t,s,r){const n=e.samples,o=t.samples,a=this.typeSupported,l={},c=this._initPTS;let u=!c||r,f="audio/mp4",h,d,g;if(u&&(h=d=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":a.mpeg?(f="audio/mpeg",e.codec=""):a.mp3&&(e.codec="mp3");break}l.audio={id:"audio",container:f,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&a.mpeg?new Uint8Array(0):I.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(g=e.inputTimeScale,!c||g!==c.timescale?h=d=n[0].pts-Math.round(g*s):u=!1)}if(t.sps&&t.pps&&o.length&&(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:I.initSegment([t]),metadata:{width:t.width,height:t.height}},u))if(g=t.inputTimeScale,!c||g!==c.timescale){const m=this.getVideoStartPts(o),y=Math.round(g*s);d=Math.min(d,rt(o[0].dts,m)-y),h=Math.min(h,m-y)}else u=!1;if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:g},this._initDTS={baseTime:d,timescale:g}):h=g=void 0,{tracks:l,initPTS:h,timescale:g}}remuxVideo(e,t,s,r){const n=e.inputTimeScale,o=e.samples,a=[],l=o.length,c=this._initPTS;let u=this.nextAvcDts,f=8,h=this.videoSampleDuration,d,g,m=Number.POSITIVE_INFINITY,y=Number.NEGATIVE_INFINITY,T=!1;if(!s||u===null){const $=t*n,z=o[0].pts-rt(o[0].dts,o[0].pts);u=$-z}const x=c.baseTime*n/c.timescale;for(let $=0;$<l;$++){const z=o[$];z.pts=rt(z.pts-x,u),z.dts=rt(z.dts-x,u),z.dts<o[$>0?$-1:$].dts&&(T=!0)}T&&o.sort(function($,z){const fe=$.dts-z.dts,he=$.pts-z.pts;return fe||he}),d=o[0].dts,g=o[o.length-1].dts;const v=g-d,R=v?Math.round(v/(l-1)):h||e.inputTimeScale/30;if(s){const $=d-u,z=$>R,fe=$<-1;if((z||fe)&&(z?A.warn(`AVC: ${Us($,!0)} ms (${$}dts) hole between fragments detected, filling it`):A.warn(`AVC: ${Us(-$,!0)} ms (${$}dts) overlapping between fragments detected`),!fe||u>=o[0].pts)){d=u;const he=o[0].pts-$;o[0].dts=d,o[0].pts=he,A.log(`Video: First PTS/DTS adjusted: ${Us(he,!0)}/${Us(d,!0)}, delta: ${Us($,!0)} ms`)}}d=Math.max(0,d);let b=0,M=0;for(let $=0;$<l;$++){const z=o[$],fe=z.units,he=fe.length;let ne=0;for(let Le=0;Le<he;Le++)ne+=fe[Le].data.length;M+=ne,b+=he,z.length=ne,z.dts=Math.max(z.dts,d),m=Math.min(z.pts,m),y=Math.max(z.pts,y)}g=o[l-1].dts;const P=M+4*b+8;let B;try{B=new Uint8Array(P)}catch($){this.observer.emit(p.ERROR,p.ERROR,{type:se.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:$,bytes:P,reason:`fail allocating video mdat ${P}`});return}const K=new DataView(B.buffer);K.setUint32(0,P),B.set(I.types.mdat,4);let _=!1,q=Number.POSITIVE_INFINITY,W=Number.POSITIVE_INFINITY,ue=Number.NEGATIVE_INFINITY,we=Number.NEGATIVE_INFINITY;for(let $=0;$<l;$++){const z=o[$],fe=z.units;let he=0;for(let Fe=0,Ke=fe.length;Fe<Ke;Fe++){const Se=fe[Fe],w=Se.data,j=Se.data.byteLength;K.setUint32(f,j),f+=4,B.set(w,f),f+=j,he+=4+j}let ne;if($<l-1)h=o[$+1].dts-z.dts,ne=o[$+1].pts-z.pts;else{const Fe=this.config,Ke=$>0?z.dts-o[$-1].dts:R;if(ne=$>0?z.pts-o[$-1].pts:R,Fe.stretchShortVideoTrack&&this.nextAudioPts!==null){const Se=Math.floor(Fe.maxBufferHole*n),w=(r?m+r*n:this.nextAudioPts)-z.pts;w>Se?(h=w-Ke,h<0?h=Ke:_=!0,A.log(`[mp4-remuxer]: It is approximately ${w/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=Ke}else h=Ke}const Le=Math.round(z.pts-z.dts);q=Math.min(q,h),ue=Math.max(ue,h),W=Math.min(W,ne),we=Math.max(we,ne),a.push(new nl(z.key,h,he,Le))}if(a.length){if(xi){if(xi<70){const $=a[0].flags;$.dependsOn=2,$.isNonSync=0}}else if($r&&we-W<ue-q&&R/ue<.025&&a[0].cts===0){A.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let $=d;for(let z=0,fe=a.length;z<fe;z++){const he=$+a[z].duration,ne=$+a[z].cts;if(z<fe-1){const Le=he+a[z+1].cts;a[z].duration=Le-ne}else a[z].duration=z?a[z-1].duration:R;a[z].cts=0,$=he}}}h=_||!h?R:h,this.nextAvcDts=u=g+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const Te=I.moof(e.sequenceNumber++,d,Ne({},e,{samples:a})),ae="video",te={data1:Te,data2:B,startPTS:m/n,endPTS:(y+h)/n,startDTS:d/n,endDTS:u/n,type:ae,hasAudio:!1,hasVideo:!0,nb:a.length,dropped:e.dropped};return e.samples=[],e.dropped=0,te}remuxAudio(e,t,s,r,n){const o=e.inputTimeScale,a=e.samplerate?e.samplerate:o,l=o/a,c=e.segmentCodec==="aac"?rl:Qp,u=c*l,f=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,d=[],g=n!==void 0;let m=e.samples,y=h?0:8,T=this.nextAudioPts||-1;const x=t*o,v=f.baseTime*o/f.timescale;if(this.isAudioContiguous=s=s||m.length&&T>0&&(r&&Math.abs(x-T)<9e3||Math.abs(rt(m[0].pts-v,x)-T)<20*u),m.forEach(function(ae){ae.pts=rt(ae.pts-v,x)}),!s||T<0){if(m=m.filter(ae=>ae.pts>=0),!m.length)return;n===0?T=0:r&&!g?T=Math.max(0,x):T=m[0].pts}if(e.segmentCodec==="aac"){const ae=this.config.maxAudioFramesDrift;for(let te=0,$=T;te<m.length;te++){const z=m[te],fe=z.pts,he=fe-$,ne=Math.abs(1e3*he/o);if(he<=-ae*u&&g)te===0&&(A.warn(`Audio frame @ ${(fe/o).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*he/o)} ms.`),this.nextAudioPts=T=$=fe);else if(he>=ae*u&&ne<Xp&&g){let Le=Math.round(he/u);$=fe-Le*u,$<0&&(Le--,$+=u),te===0&&(this.nextAudioPts=T=$),A.warn(`[mp4-remuxer]: Injecting ${Le} audio frame @ ${($/o).toFixed(3)}s due to ${Math.round(1e3*he/o)} ms gap.`);for(let Fe=0;Fe<Le;Fe++){const Ke=Math.max($,0);let Se=il.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);Se||(A.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),Se=z.unit.subarray()),m.splice(te,0,{unit:Se,pts:Ke}),$+=u,te++}}z.pts=$,$+=u}}let R=null,b=null,M,P=0,B=m.length;for(;B--;)P+=m[B].unit.byteLength;for(let ae=0,te=m.length;ae<te;ae++){const $=m[ae],z=$.unit;let fe=$.pts;if(b!==null){const ne=d[ae-1];ne.duration=Math.round((fe-b)/l)}else if(s&&e.segmentCodec==="aac"&&(fe=T),R=fe,P>0){P+=y;try{M=new Uint8Array(P)}catch(ne){this.observer.emit(p.ERROR,p.ERROR,{type:se.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:ne,bytes:P,reason:`fail allocating audio mdat ${P}`});return}h||(new DataView(M.buffer).setUint32(0,P),M.set(I.types.mdat,4))}else return;M.set(z,y);const he=z.byteLength;y+=he,d.push(new nl(!0,c,he,0)),b=fe}const K=d.length;if(!K)return;const _=d[d.length-1];this.nextAudioPts=T=b+l*_.duration;const q=h?new Uint8Array(0):I.moof(e.sequenceNumber++,R/l,Ne({},e,{samples:d}));e.samples=[];const W=R/o,ue=T/o,Te={data1:q,data2:M,startPTS:W,endPTS:ue,startDTS:W,endDTS:ue,type:"audio",hasAudio:!0,hasVideo:!1,nb:K};return this.isAudioContiguous=!0,Te}remuxEmptyAudio(e,t,s,r){const n=e.inputTimeScale,o=e.samplerate?e.samplerate:n,a=n/o,l=this.nextAudioPts,c=this._initDTS,u=c.baseTime*9e4/c.timescale,f=(l!==null?l:r.startDTS*n)+u,h=r.endDTS*n+u,d=a*rl,g=Math.ceil((h-f)/d),m=il.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(A.warn("[mp4-remuxer]: remux empty Audio"),!m){A.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const y=[];for(let T=0;T<g;T++){const x=f+T*d;y.push({unit:m,pts:x,dts:x})}return e.samples=y,this.remuxAudio(e,t,s,!1)}}function rt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function Jp(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Cu(i,e,t,s){const r=i.samples.length;if(!r)return;const n=i.inputTimeScale;for(let a=0;a<r;a++){const l=i.samples[a];l.pts=rt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=rt(l.dts-s.baseTime*n/s.timescale,e*n)/n}const o=i.samples;return i.samples=[],{samples:o}}function wu(i,e,t){const s=i.samples.length;if(!s)return;const r=i.inputTimeScale;for(let o=0;o<s;o++){const a=i.samples[o];a.pts=rt(a.pts-t.baseTime*r/t.timescale,e*r)/r}i.samples.sort((o,a)=>o.pts-a.pts);const n=i.samples;return i.samples=[],{samples:n}}class nl{constructor(e,t,s,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=s,this.cts=r,this.flags=new Zp(e)}}class Zp{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}class ey{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,s,r){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(xm(e,r)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const r=this.initData=ou(e);t||(t=ol(r.audio,Re.AUDIO)),s||(s=ol(r.video,Re.VIDEO));const n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+s,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:s,initSegment:e,id:"main"}:A.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,s,r,n,o){var a,l;let{initPTS:c,lastEndTime:u}=this;const f={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};J(u)||(u=this.lastEndTime=n||0);const h=t.samples;if(!(h!=null&&h.length))return f;const d={initPTS:void 0,timescale:1};let g=this.initData;if((a=g)!=null&&a.length||(this.generateInitSegment(h),g=this.initData),!((l=g)!=null&&l.length))return A.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(d.tracks=this.initTracks,this.emitInitSegment=!1);const m=vm(h,g),y=Sm(g,h),T=y===null?n:y;(ty(c,T,n,m)||d.timescale!==c.timescale&&o)&&(d.initPTS=T-n,c&&c.timescale===1&&A.warn(`Adjusting initPTS by ${d.initPTS-c.baseTime}`),this.initPTS=c={baseTime:d.initPTS,timescale:1});const x=e?T-c.baseTime/c.timescale:u,v=x+m;Rm(g,h,c.baseTime/c.timescale),m>0?this.lastEndTime=v:(A.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const R=!!g.audio,b=!!g.video;let M="";R&&(M+="audio"),b&&(M+="video");const P={data1:h,startPTS:x,startDTS:x,endPTS:v,endDTS:v,type:M,hasAudio:R,hasVideo:b,nb:1,dropped:0};return f.audio=P.type==="audio"?P:void 0,f.video=P.type!=="audio"?P:void 0,f.initSegment=d,f.id3=Cu(s,n,c,c),r.samples.length&&(f.text=wu(r,n,c)),f}}function ty(i,e,t,s){if(i===null)return!0;const r=Math.max(s,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>r}function ol(i,e){const t=i==null?void 0:i.codec;return t&&t.length>4?t:t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":t==="avc1"||e===Re.VIDEO?"avc1.42e01e":"mp4a.40.5"}let kt;try{kt=self.performance.now.bind(self.performance)}catch{A.debug("Unable to use Performance API on this environment"),kt=typeof self<"u"&&self.Date.now}const Kr=[{demux:Mp,remux:ey},{demux:Wt,remux:Gr},{demux:Fp,remux:Gr},{demux:jp,remux:Gr}];class al{constructor(e,t,s,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=e,this.typeSupported=t,this.config=s,this.vendor=r,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){const n=s.transmuxing;n.executeStart=kt();let o=new Uint8Array(e);const{currentTransmuxState:a,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:c,discontinuity:u,trackSwitch:f,accurateTimeOffset:h,timeOffset:d,initSegmentChange:g}=r||a,{audioCodec:m,videoCodec:y,defaultInitPts:T,duration:x,initSegmentData:v}=l,R=sy(o,t);if(R&&R.method==="AES-128"){const B=this.getDecrypter();if(B.isSync()){let K=B.softwareDecrypt(o,R.key.buffer,R.iv.buffer);if(s.part>-1&&(K=B.flush()),!K)return n.executeEnd=kt(),Hr(s);o=new Uint8Array(K)}else return this.decryptionPromise=B.webCryptoDecrypt(o,R.key.buffer,R.iv.buffer).then(K=>{const _=this.push(K,null,s);return this.decryptionPromise=null,_}),this.decryptionPromise}const b=this.needsProbing(u,f);if(b){const B=this.configureTransmuxer(o);if(B)return A.warn(`[transmuxer] ${B.message}`),this.observer.emit(p.ERROR,p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:B,reason:B.message}),n.executeEnd=kt(),Hr(s)}(u||f||g||b)&&this.resetInitSegment(v,m,y,x,t),(u||g||b)&&this.resetInitialTimestamp(T),c||this.resetContiguity();const M=this.transmux(o,R,d,h,s),P=this.currentTransmuxState;return P.contiguous=!0,P.discontinuity=!1,P.trackSwitch=!1,n.executeEnd=kt(),M}flush(e){const t=e.transmuxing;t.executeStart=kt();const{decrypter:s,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const o=[],{timeOffset:a}=r;if(s){const f=s.flush();f&&o.push(this.push(f,null,e))}const{demuxer:l,remuxer:c}=this;if(!l||!c)return t.executeEnd=kt(),[Hr(e)];const u=l.flush(a);return Oi(u)?u.then(f=>(this.flushRemux(o,f,e),o)):(this.flushRemux(o,u,e),o)}flushRemux(e,t,s){const{audioTrack:r,videoTrack:n,id3Track:o,textTrack:a}=t,{accurateTimeOffset:l,timeOffset:c}=this.currentTransmuxState;A.log(`[transmuxer.ts]: Flushed fragment ${s.sn}${s.part>-1?" p: "+s.part:""} of level ${s.level}`);const u=this.remuxer.remux(r,n,o,a,c,l,!0,this.id);e.push({remuxResult:u,chunkMeta:s}),s.transmuxing.executeEnd=kt()}resetInitialTimestamp(e){const{demuxer:t,remuxer:s}=this;!t||!s||(t.resetTimeStamp(e),s.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,s,r,n){const{demuxer:o,remuxer:a}=this;!o||!a||(o.resetInitSegment(e,t,s,r),a.resetInitSegment(e,t,s,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,r,n){let o;return t&&t.method==="SAMPLE-AES"?o=this.transmuxSampleAes(e,t,s,r,n):o=this.transmuxUnencrypted(e,s,r,n),o}transmuxUnencrypted(e,t,s,r){const{audioTrack:n,videoTrack:o,id3Track:a,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,o,a,l,t,s,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,s,r,n){return this.demuxer.demuxSampleAes(e,t,s).then(o=>({remuxResult:this.remuxer.remux(o.audioTrack,o.videoTrack,o.id3Track,o.textTrack,s,r,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:r,vendor:n}=this;let o;for(let f=0,h=Kr.length;f<h;f++)if(Kr[f].demux.probe(e)){o=Kr[f];break}if(!o)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,l=this.remuxer,c=o.remux,u=o.demux;(!l||!(l instanceof c))&&(this.remuxer=new c(s,t,r,n)),(!a||!(a instanceof u))&&(this.demuxer=new u(s,t,r),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new go(this.config)),e}}function sy(i,e){let t=null;return i.byteLength>0&&e!=null&&e.key!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const Hr=i=>({remuxResult:{},chunkMeta:i});function Oi(i){return"then"in i&&i.then instanceof Function}class iy{constructor(e,t,s,r,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=s,this.duration=r,this.defaultInitPts=n||null}}class ry{constructor(e,t,s,r,n,o){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=s,this.trackSwitch=r,this.timeOffset=n,this.initSegmentChange=o}}var Pu={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,c,u){this.fn=l,this.context=c,this.once=u||!1}function n(l,c,u,f,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var d=new r(u,f||l,h),g=t?t+c:c;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],d]:l._events[g].push(d):(l._events[g]=d,l._eventsCount++),l}function o(l,c){--l._eventsCount===0?l._events=new s:delete l._events[c]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var c=[],u,f;if(this._eventsCount===0)return c;for(f in u=this._events)e.call(u,f)&&c.push(t?f.slice(1):f);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(u)):c},a.prototype.listeners=function(c){var u=t?t+c:c,f=this._events[u];if(!f)return[];if(f.fn)return[f.fn];for(var h=0,d=f.length,g=new Array(d);h<d;h++)g[h]=f[h].fn;return g},a.prototype.listenerCount=function(c){var u=t?t+c:c,f=this._events[u];return f?f.fn?1:f.length:0},a.prototype.emit=function(c,u,f,h,d,g){var m=t?t+c:c;if(!this._events[m])return!1;var y=this._events[m],T=arguments.length,x,v;if(y.fn){switch(y.once&&this.removeListener(c,y.fn,void 0,!0),T){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,u),!0;case 3:return y.fn.call(y.context,u,f),!0;case 4:return y.fn.call(y.context,u,f,h),!0;case 5:return y.fn.call(y.context,u,f,h,d),!0;case 6:return y.fn.call(y.context,u,f,h,d,g),!0}for(v=1,x=new Array(T-1);v<T;v++)x[v-1]=arguments[v];y.fn.apply(y.context,x)}else{var R=y.length,b;for(v=0;v<R;v++)switch(y[v].once&&this.removeListener(c,y[v].fn,void 0,!0),T){case 1:y[v].fn.call(y[v].context);break;case 2:y[v].fn.call(y[v].context,u);break;case 3:y[v].fn.call(y[v].context,u,f);break;case 4:y[v].fn.call(y[v].context,u,f,h);break;default:if(!x)for(b=1,x=new Array(T-1);b<T;b++)x[b-1]=arguments[b];y[v].fn.apply(y[v].context,x)}}return!0},a.prototype.on=function(c,u,f){return n(this,c,u,f,!1)},a.prototype.once=function(c,u,f){return n(this,c,u,f,!0)},a.prototype.removeListener=function(c,u,f,h){var d=t?t+c:c;if(!this._events[d])return this;if(!u)return o(this,d),this;var g=this._events[d];if(g.fn)g.fn===u&&(!h||g.once)&&(!f||g.context===f)&&o(this,d);else{for(var m=0,y=[],T=g.length;m<T;m++)(g[m].fn!==u||h&&!g[m].once||f&&g[m].context!==f)&&y.push(g[m]);y.length?this._events[d]=y.length===1?y[0]:y:o(this,d)}return this},a.prototype.removeAllListeners=function(c){var u;return c?(u=t?t+c:c,this._events[u]&&o(this,u)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,i.exports=a})(Pu);var ny=Pu.exports,Eo=V0(ny);const Vr=pr()||{isTypeSupported:()=>!1};class ku{constructor(e,t,s,r){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 n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=s,this.onFlush=r;const o=(c,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,c===p.ERROR&&(this.error=u.error),this.hls.trigger(c,u)};this.observer=new Eo,this.observer.on(p.FRAG_DECRYPTED,o),this.observer.on(p.ERROR,o);const a={mp4:Vr.isTypeSupported("video/mp4"),mpeg:Vr.isTypeSupported("audio/mpeg"),mp3:Vr.isTypeSupported('audio/mp4; codecs="mp3"')},l=navigator.vendor;if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||bp())){try{n.workerPath?(A.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=Dp(n.workerPath)):(A.log(`injecting Web Worker for "${t}"`),this.workerContext=Ip()),this.onwmsg=f=>this.onWorkerMessage(f);const{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=f=>{const h=new Error(`${f.message}  (${f.filename}:${f.lineno})`);n.enableWorker=!1,A.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(p.ERROR,{type:se.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:a,vendor:l,id:t,config:JSON.stringify(n)})}catch(u){A.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new al(this.observer,a,n,l,t)}return}this.transmuxer=new al(this.observer,a,n,l,t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,s,r,n,o,a,l,c,u){var f,h;c.transmuxing.start=self.performance.now();const{transmuxer:d}=this,g=o?o.start:n.start,m=n.decryptdata,y=this.frag,T=!(y&&n.cc===y.cc),x=!(y&&c.level===y.level),v=y?c.sn-y.sn:-1,R=this.part?c.part-this.part.index:-1,b=v===0&&c.id>1&&c.id===(y==null?void 0:y.stats.chunkCount),M=!x&&(v===1||v===0&&(R===1||b&&R<=0)),P=self.performance.now();(x||v||n.stats.parsing.start===0)&&(n.stats.parsing.start=P),o&&(R||!M)&&(o.stats.parsing.start=P);const B=!(y&&((f=n.initSegment)==null?void 0:f.url)===((h=y.initSegment)==null?void 0:h.url)),K=new ry(T,M,l,x,g,B);if(!M||T||B){A.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${c.sn} p: ${c.part} level: ${c.level} id: ${c.id}
        discontinuity: ${T}
        trackSwitch: ${x}
        contiguous: ${M}
        accurateTimeOffset: ${l}
        timeOffset: ${g}
        initSegmentChange: ${B}`);const _=new iy(s,r,t,a,u);this.configureTransmuxer(_)}if(this.frag=n,this.part=o,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:m,chunkMeta:c,state:K},e instanceof ArrayBuffer?[e]:[]);else if(d){const _=d.push(e,m,c,K);Oi(_)?(d.async=!0,_.then(q=>{this.handleTransmuxComplete(q)}).catch(q=>{this.transmuxerError(q,c,"transmuxer-interface push error")})):(d.async=!1,this.handleTransmuxComplete(_))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let s=t.flush(e);Oi(s)||t.async?(Oi(s)||(s=Promise.resolve(s)),s.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,s=this.hls;switch(t.event){case"init":{var r;const n=(r=this.workerContext)==null?void 0:r.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":A[t.data.logType]&&A[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,s.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}const oy=250,Wr=2,ay=.1,ly=.05;class cy{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:n}=this;if(r===null)return;const{currentTime:o,seeking:a}=r,l=this.seeking&&!a,c=!this.seeking&&a;if(this.seeking=a,o!==e){if(this.moved=!0,n!==null){if(this.stallReported){const T=self.performance.now()-n;A.warn(`playback not stuck anymore @${o}, after ${Math.round(T)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(c||l){this.stalled=null;return}if(r.paused&&!a||r.ended||r.playbackRate===0||!De.getBuffered(r).length)return;const u=De.bufferInfo(r,o,0),f=u.len>0,h=u.nextStart||0;if(!f&&!h)return;if(a){const T=u.len>Wr,x=!h||t&&t.start<=o||h-o>Wr&&!this.fragmentTracker.getPartialFragment(o);if(T||x)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var d;const T=Math.max(h,u.start||0)-o,x=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,R=(x==null||(d=x.details)==null?void 0:d.live)?x.details.targetduration*2:Wr,b=this.fragmentTracker.getPartialFragment(o);if(T>0&&(T<=R||b)){this._trySkipBufferHole(b);return}}const g=self.performance.now();if(n===null){this.stalled=g;return}const m=g-n;if(!a&&m>=oy&&(this._reportStall(u),!this.media))return;const y=De.bufferInfo(r,o,s.maxBufferHole);this._tryFixBufferStall(y,m)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:n}=this;if(n===null)return;const o=n.currentTime,a=r.getPartialFragment(o);a&&(this._trySkipBufferHole(a)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-o<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(A.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const n=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);A.warn(n.message),t.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const n=r.currentTime,o=De.bufferInfo(r,n,0),a=n<o.start?o.start:o.nextStart;if(a){const l=o.len<=t.maxBufferHole,c=o.len>0&&o.len<1&&r.readyState<3,u=a-n;if(u>0&&(l||c)){if(u>t.maxBufferHole){const{fragmentTracker:h}=this;let d=!1;if(n===0){const g=h.getAppendedFrag(0,ie.MAIN);g&&a<g.end&&(d=!0)}if(!d){const g=e||h.getAppendedFrag(n,ie.MAIN);if(g){let m=!1,y=g.end;for(;y<a;){const T=h.getPartialFragment(y);if(T)y+=T.duration;else{m=!0;break}}if(m)return 0}}}const f=Math.max(a+ly,n+ay);if(A.warn(`skipping hole, adjusting currentTime from ${n} to ${f}`),this.moved=!0,this.stalled=null,r.currentTime=f,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${f}`);s.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return f}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const n=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const o=n+(r+1)*e.nudgeOffset,a=new Error(`Nudging 'currentTime' from ${n} to ${o}`);A.warn(a.message),s.currentTime=o,t.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:a,fatal:!1})}else{const o=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);A.error(o.message),t.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:o,fatal:!0})}}}const uy=100;class fy extends mo{constructor(e,t,s){super(e,t,s,"[stream-controller]",ie.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(p.ERROR,this.onError,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(p.ERROR,this.onError,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),this.onMediaDetaching()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(uy),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.nextAutoLevel),this.level=s.nextLoadLevel=r,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=F.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=F.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case F.WAITING_LEVEL:{var e;const{levels:s,level:r}=this,n=s==null||(e=s[r])==null?void 0:e.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=F.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=F.IDLE;break}break}case F.FRAG_LOADING_WAITING_RETRY:{var t;const s=self.performance.now(),r=this.retryDate;(!r||s>=r||(t=this.media)!=null&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=F.IDLE)}break}this.state===F.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this,{config:n,nextLoadLevel:o}=e;if(t===null||!r&&(this.startFragRequested||!n.startFragPrefetch)||this.altAudio&&this.audioOnly||!(s!=null&&s[o]))return;const a=s[o],l=this.getMainFwdBufferInfo();if(l===null)return;const c=this.getLevelDetails();if(c&&this._streamEnded(l,c)){const y={};this.altAudio&&(y.type="video"),this.hls.trigger(p.BUFFER_EOS,y),this.state=F.ENDED;return}e.loadLevel!==o&&e.manualLevel===-1&&this.log(`Adapting to level ${o} from level ${this.level}`),this.level=e.nextLoadLevel=o;const u=a.details;if(!u||this.state===F.WAITING_LEVEL||u.live&&this.levelLastLoaded!==o){this.level=o,this.state=F.WAITING_LEVEL;return}const f=l.len,h=this.getMaxBufferLength(a.maxBitrate);if(f>=h)return;this.backtrackFragment&&this.backtrackFragment.start>l.end&&(this.backtrackFragment=null);const d=this.backtrackFragment?this.backtrackFragment.start:l.end;let g=this.getNextFragment(d,u);if(this.couldBacktrack&&!this.fragPrevious&&g&&g.sn!=="initSegment"&&this.fragmentTracker.getState(g)!==Me.OK){var m;const T=((m=this.backtrackFragment)!=null?m:g).sn-u.startSN,x=u.fragments[T-1];x&&g.cc===x.cc&&(g=x,this.fragmentTracker.removeFragment(x))}else this.backtrackFragment&&l.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,d)){if(!g.gap){const T=this.audioOnly&&!this.altAudio?Re.AUDIO:Re.VIDEO,x=(T===Re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;x&&this.afterBufferFlushed(x,T,ie.MAIN)}g=this.getNextFragmentLoopLoading(g,u,l,ie.MAIN,h)}g&&(g.initSegment&&!g.initSegment.data&&!this.bitrateTest&&(g=g.initSegment),this.loadFragment(g,a,d))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===Me.NOT_LOADED||r===Me.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,ie.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let s;const r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const a=this.getMainFwdBufferInfo();if(!a||a.len<n.targetduration*2)return}if(!t.paused&&e){const a=this.hls.nextLoadLevel,l=e[a],c=this.fragLastKbps;c&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*c)+1:s=0}else s=0;const o=this.getBufferedFrag(t.currentTime+s);if(o){const a=this.followingBufferedFrag(o);if(a){this.abortCurrentFrag();const l=a.maxStartPTS?a.maxStartPTS:a.start,c=a.duration,u=Math.max(o.end,l+Math.min(Math.max(c-this.config.maxFragLookUpTolerance,c*.5),c*.75));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case F.KEY_LOADING:case F.FRAG_LOADING:case F.FRAG_LOADING_WAITING_RETRY:case F.PARSING:case F.PARSED:this.state=F.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new cy(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;J(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(p.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let s=!1,r=!1,n;t.levels.forEach(o=>{n=o.audioCodec,n&&(n.indexOf("mp4a.40.2")!==-1&&(s=!0),n.indexOf("mp4a.40.5")!==-1&&(r=!0))}),this.audioCodecSwitch=s&&r&&!Lp(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:s}=this;if(!s||this.state!==F.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(r.details))&&(this.state=F.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,n=t.level,o=t.details,a=o.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${o.startSN},${o.endSN}]${o.lastPartSn?`[part-${o.lastPartSn}-${o.lastPartIndex}]`:""}, cc [${o.startCC}, ${o.endCC}] duration:${a}`);const l=r[n],c=this.fragCurrent;c&&(this.state===F.FRAG_LOADING||this.state===F.FRAG_LOADING_WAITING_RETRY)&&(c.level!==t.level||c.urlId!==l.urlId)&&c.loader&&this.abortCurrentFrag();let u=0;if(o.live||(s=l.details)!=null&&s.live){if(this.checkLiveUpdate(o),o.deltaUpdateFailed)return;u=this.alignPlaylists(o,l.details)}if(l.details=o,this.levelLastLoaded=n,this.hls.trigger(p.LEVEL_UPDATED,{details:o,level:n}),this.state===F.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=F.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{levels:o}=this;if(!o){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const a=o[s.level],l=a.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const c=a.videoCodec,u=l.PTSKnown||!l.live,f=(t=s.initSegment)==null?void 0:t.data,h=this._getAudioCodec(a),d=this.transmuxer=this.transmuxer||new ku(this.hls,ie.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),g=r?r.index:-1,m=g!==-1,y=new fo(s.level,s.sn,s.stats.chunkCount,n.byteLength,g,m),T=this.initPTS[s.cc];d.push(n,f,h,c,s,r,l.totalduration,u,y,T)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const o=this.fragCurrent;o&&(this.log("Switching to main audio track, cancel main fragment load"),o.abortRequests(),this.fragmentTracker.removeFragment(o)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;s&&(n.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(p.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,n,o=!1;for(const a in s){const l=s[a];if(l.id==="main"){if(n=a,r=l,a==="video"){const c=s[a];c&&(this.videoBuffer=c.buffer)}}else o=!0}o&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==ie.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===F.PARSED&&(this.state=F.IDLE);return}const n=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=F.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ie.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===F.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===ye.LEVEL&&(this.state=F.IDLE);break;case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!De.getBuffered(e).length){const s=this.state!==F.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=F.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==Re.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===Re.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,ie.MAIN)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let s=this.startPosition;if(s>=0&&t<s){if(e.seeking){this.log(`could not seek to ${s}, already seeking at ${t}`);return}const r=De.getBuffered(e),o=(r.length?r.start(0):0)-s;o>0&&(o<this.config.maxBufferHole||o<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${o} to match buffer start`),s+=o,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),e.currentTime=s}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(s=>{const{hls:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=F.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(p.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:n,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:u}=a,{video:f,text:h,id3:d,initSegment:g}=n,{details:m}=u,y=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=F.PARSING,g){if(g!=null&&g.tracks){const v=l.initSegment||l;this._bufferInitSegment(u,g.tracks,v,o),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:v,id:s,tracks:g.tracks})}const T=g.initPTS,x=g.timescale;J(T)&&(this.initPTS[l.cc]={baseTime:T,timescale:x},r.trigger(p.INIT_PTS_FOUND,{frag:l,id:s,initPTS:T,timescale:x}))}if(f&&m&&l.sn!=="initSegment"){const T=m.fragments[l.sn-1-m.startSN],x=l.sn===m.startSN,v=!T||l.cc>T.cc;if(n.independent!==!1){const{startPTS:R,endPTS:b,startDTS:M,endDTS:P}=f;if(c)c.elementaryStreams[f.type]={startPTS:R,endPTS:b,startDTS:M,endDTS:P};else if(f.firstKeyFrame&&f.independent&&o.id===1&&!v&&(this.couldBacktrack=!0),f.dropped&&f.independent){const B=this.getMainFwdBufferInfo(),K=(B?B.end:this.getLoadPosition())+this.config.maxBufferHole,_=f.firstKeyFramePTS?f.firstKeyFramePTS:R;if(!x&&K<_-this.config.maxBufferHole&&!v){this.backtrack(l);return}else v&&(l.gap=!0);l.setElementaryStreamInfo(f.type,l.start,b,l.start,P,!0)}l.setElementaryStreamInfo(f.type,R,b,M,P),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(f,l,c,o,x||v)}else if(x||v)l.gap=!0;else{this.backtrack(l);return}}if(y){const{startPTS:T,endPTS:x,startDTS:v,endDTS:R}=y;c&&(c.elementaryStreams[Re.AUDIO]={startPTS:T,endPTS:x,startDTS:v,endDTS:R}),l.setElementaryStreamInfo(Re.AUDIO,T,x,v,R),this.bufferFragmentData(y,l,c,o)}if(m&&d!=null&&(t=d.samples)!=null&&t.length){const T={id:s,frag:l,details:m,samples:d.samples};r.trigger(p.FRAG_PARSING_METADATA,T)}if(m&&h){const T={id:s,frag:l,details:m,samples:h.samples};r.trigger(p.FRAG_PARSING_USERDATA,T)}}_bufferInitSegment(e,t,s,r){if(this.state!==F.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:o,audiovideo:a}=t;if(n){let l=e.audioCodec;const c=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5"),n.metadata.channelCount!==1&&c.indexOf("firefox")===-1&&(l="mp4a.40.5")),c.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}o&&(o.levelCodec=e.videoCodec,o.id="main",this.log(`Init video buffer, container:${o.container}, codecs[level/parsed]=[${e.videoCodec||""}/${o.codec}]`)),a&&this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${e.attrs.CODECS||""}/${a.codec}]`),this.hls.trigger(p.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(p.BUFFER_APPENDING,{type:l,data:u,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,ie.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=F.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(De.isBuffered(e,s)?t=this.getAppendedFrag(s):De.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n||t.urlId!==r.urlId)&&(this.fragPlaying=t,this.hls.trigger(p.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(p.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&J(t)&&J(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class ds{constructor(e,t=0,s=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=s}sample(e,t){const s=Math.pow(this.alpha_,e);this.estimate_=t*(1-s)+s*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class hy{constructor(e,t,s,r=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new ds(e),this.fast_=new ds(t),this.defaultTTFB_=r,this.ttfb_=new ds(e)}update(e,t){const{slow_:s,fast_:r,ttfb_:n}=this;s.halfLife!==e&&(this.slow_=new ds(e,s.getEstimate(),s.getTotalWeight())),r.halfLife!==t&&(this.fast_=new ds(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new ds(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,r=e/1e3,n=s/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}sampleTTFB(e){const t=e/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(s,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class dy{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;const t=e.config;this.bwEstimator=new hy(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var s;const r=t.frag;this.ignoreFragment(r)||(this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,s,r){const n=e+s/t,o=r?this.lastLevelLoadSec:0;return n+o}onLevelLoaded(e,t){const s=this.hls.config,{total:r,bwEstimate:n}=t.stats;J(r)&&J(n)&&(this.lastLevelLoadSec=8*r/n),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:s}=this,{autoLevelEnabled:r,media:n}=s;if(!e||!n)return;const o=performance.now(),a=t?t.stats:e.stats,l=t?t.duration:e.duration,c=o-a.loading.start;if(a.aborted||a.loaded&&a.loaded===a.total||e.level===0){this.clearTimer(),this._nextAutoLevel=-1;return}if(!r||n.paused||!n.playbackRate||!n.readyState)return;const u=s.mainForwardBufferInfo;if(u===null)return;const f=this.bwEstimator.getEstimateTTFB(),h=Math.abs(n.playbackRate);if(c<=Math.max(f,1e3*(l/(h*2))))return;const d=u.len/h;if(d>=2*l/h)return;const g=a.loading.first?a.loading.first-a.loading.start:-1,m=a.loaded&&g>-1,y=this.bwEstimator.getEstimate(),{levels:T,minAutoLevel:x}=s,v=T[e.level],R=a.total||Math.max(a.loaded,Math.round(l*v.maxBitrate/8));let b=c-g;b<1&&m&&(b=Math.min(c,a.loaded*8/y));const M=m?a.loaded*1e3/b:0,P=M?(R-a.loaded)/M:R*8/y+f/1e3;if(P<=d)return;const B=M?M*8:y;let K=Number.POSITIVE_INFINITY,_;for(_=e.level-1;_>x;_--){const q=T[_].maxBitrate;if(K=this.getTimeToLoadFrag(f/1e3,B,l*q,!T[_].details),K<d)break}K>=P||K>l*10||(s.nextLoadLevel=_,m?this.bwEstimator.sample(c-Math.min(f,g),a.loaded):this.bwEstimator.sampleTTFB(c),this.clearTimer(),A.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;
      Time to underbuffer: ${d.toFixed(3)} s
      Estimated load time for current fragment: ${P.toFixed(3)} s
      Estimated load time for down switch fragment: ${K.toFixed(3)} s
      TTFB estimate: ${g}
      Current BW estimate: ${J(y)?(y/1024).toFixed(3):"Unknown"} Kb/s
      New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s
      Aborting and switching to level ${_}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),s.trigger(p.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:a}))}onFragLoaded(e,{frag:t,part:s}){const r=s?s.stats:t.stats;if(t.type===ie.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const n=s?s.duration:t.duration,o=this.hls.levels[t.level],a=(o.loaded?o.loaded.bytes:0)+r.loaded,l=(o.loaded?o.loaded.duration:0)+n;o.loaded={bytes:a,duration:l},o.realBitrate=Math.round(8*a/l)}if(t.bitrateTest){const n={stats:r,frag:t,part:s,id:t.type};this.onFragBuffered(p.FRAG_BUFFERED,n),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:s,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:s.stats;if(n.aborted||this.ignoreFragment(s))return;const o=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(o,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),s.bitrateTest?this.bitrateTestDelay=o/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==ie.MAIN||e.sn==="initSegment"}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(e!==-1&&!t.canEstimate())return e;let s=this.getNextABRAutoLevel();if(e!==-1){const r=this.hls.levels;if(r.length>Math.max(e,s)&&r[e].loadError<=r[s].loadError)return e}return e!==-1&&(s=Math.min(e,s)),s}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:s}=this,{maxAutoLevel:r,config:n,minAutoLevel:o,media:a}=s,l=t?t.duration:e?e.duration:0,c=a&&a.playbackRate!==0?Math.abs(a.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,f=s.mainForwardBufferInfo,h=(f?f.len:0)/c;let d=this.findBestLevel(u,o,r,h,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(d>=0)return d;A.trace(`[abr] ${h?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let g=l?Math.min(l,n.maxStarvationDelay):n.maxStarvationDelay,m=n.abrBandWidthFactor,y=n.abrBandWidthUpFactor;if(!h){const T=this.bitrateTestDelay;T&&(g=(l?Math.min(l,n.maxLoadingDelay):n.maxLoadingDelay)-T,A.trace(`[abr] bitrate test took ${Math.round(1e3*T)}ms, set first fragment max fetchDuration to ${Math.round(1e3*g)} ms`),m=y=1)}return d=this.findBestLevel(u,o,r,h+g,m,y),Math.max(d,0)}findBestLevel(e,t,s,r,n,o){var a;const{fragCurrent:l,partCurrent:c,lastLoadedFragLevel:u}=this,{levels:f}=this.hls,h=f[u],d=!!(h!=null&&(a=h.details)!=null&&a.live),g=h==null?void 0:h.codecSet,m=c?c.duration:l?l.duration:0,y=this.bwEstimator.getEstimateTTFB()/1e3;let T=t,x=-1;for(let v=s;v>=t;v--){const R=f[v];if(!R||g&&R.codecSet!==g){R&&(T=Math.min(v,T),x=Math.max(v,x));continue}x!==-1&&A.trace(`[abr] Skipped level(s) ${T}-${x} with CODECS:"${f[x].attrs.CODECS}"; not compatible with "${h.attrs.CODECS}"`);const b=R.details,M=(c?b==null?void 0:b.partTarget:b==null?void 0:b.averagetargetduration)||m;let P;v<=u?P=n*e:P=o*e;const B=f[v].maxBitrate,K=this.getTimeToLoadFrag(y,P,B*M,b===void 0);if(A.trace(`[abr] level:${v} adjustedbw-bitrate:${Math.round(P-B)} avgDuration:${M.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:${K.toFixed(1)}`),P>B&&(K===0||!J(K)||d&&!this.bitrateTestDelay||K<r))return v}return-1}set nextAutoLevel(e){this._nextAutoLevel=e}}class Ou{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let s;if(e.length)e.length===1?s=e[0]:s=gy(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function gy(i,e){const t=new Uint8Array(e);let s=0;for(let r=0;r<i.length;r++){const n=i[r];t.set(n,s),s+=n.length}return t}const ll=100;class my extends mo{constructor(e,t,s){super(e,t,s,"[audio-stream-controller]",ie.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this),e.on(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(p.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this),e.off(p.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){if(s==="main"){const o=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${o} found from main: ${r}`),this.videoTrackCC=o,this.state===F.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=F.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(ll),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=F.IDLE):(this.loadedmetadata=!1,this.state=F.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case F.IDLE:this.doTickIdle();break;case F.WAITING_TRACK:{var e;const{levels:s,trackId:r}=this,n=s==null||(e=s[r])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=F.WAITING_INIT_PTS}break}case F.FRAG_LOADING_WAITING_RETRY:{var t;const s=performance.now(),r=this.retryDate;(!r||s>=r||(t=this.media)!=null&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=F.IDLE);break}case F.WAITING_INIT_PTS:{const s=this.waitingData;if(s){const{frag:r,part:n,cache:o,complete:a}=s;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=F.FRAG_LOADING;const l=o.flush(),c={frag:r,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(c),a&&super._handleFragmentLoadComplete(c)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),c=De.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Dn(c.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${c.end} is needed`),this.clearWaitingFragment())}}else this.state=F.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=F.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:s,trackId:r}=this,n=e.config;if(!(t!=null&&t[r])||!s&&(this.startFragRequested||!n.startFragPrefetch))return;const o=t[r],a=o.details;if(!a||a.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(a)){this.state=F.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,Re.AUDIO,ie.AUDIO));const c=this.getFwdBufferInfo(l,ie.AUDIO);if(c===null)return;const{bufferedTrack:u,switchingTrack:f}=this;if(!f&&this._streamEnded(c,a)){e.trigger(p.BUFFER_EOS,{type:"audio"}),this.state=F.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ie.MAIN),d=c.len,g=this.getMaxBufferLength(h==null?void 0:h.len);if(d>=g&&!f)return;const y=a.fragments[0].start;let T=c.end;if(f&&s){const b=this.getLoadPosition();u&&f.attrs!==u.attrs&&(T=b),a.PTSKnown&&b<y&&(c.end>y||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=y+.05)}let x=this.getNextFragment(T,a),v=!1;if(x&&this.isLoopLoading(x,T)&&(v=!!x.gap,x=this.getNextFragmentLoopLoading(x,a,c,ie.MAIN,g)),!x){this.bufferFlushed=!0;return}const R=h&&x.start>h.end+a.targetduration;if(R||!(h!=null&&h.len)&&c.len){const b=this.getAppendedFrag(x.start,ie.MAIN);if(b===null||(v||(v=!!b.gap||!!R&&h.len===0),R&&!v||v&&c.nextStart&&c.nextStart<b.end))return}this.loadFragment(x,o,T)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new ri(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),s?this.setInterval(ll):this.resetTransmuxer(),s?(this.switchingTrack=t,this.state=F.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=F.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(p.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:r}=this,{details:n,id:o}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${o}`);return}this.log(`Track ${o} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const a=r[o];let l=0;if(n.live||(s=a.details)!=null&&s.live){this.checkLiveUpdate(n);const c=this.mainDetails;if(n.deltaUpdateFailed||!c)return;!a.details&&n.hasProgramDateTime&&c.hasProgramDateTime?(Tu(n,c),l=n.fragments[0].start):l=this.alignPlaylists(n,a.details)}a.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(a.details,l),this.state===F.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=F.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{config:o,trackId:a,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const c=l[a];if(!c){this.warn("Audio track is undefined on fragment load progress");return}const u=c.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const f=o.defaultAudioCodec||c.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new ku(this.hls,ie.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const d=this.initPTS[s.cc],g=(t=s.initSegment)==null?void 0:t.data;if(d!==void 0){const y=r?r.index:-1,T=y!==-1,x=new fo(s.level,s.sn,s.stats.chunkCount,n.byteLength,y,T);h.push(n,g,f,"",s,r,u.totalduration,!1,x,d)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${u.startSN} ,${u.endSN}],track ${a}`);const{cache:m}=this.waitingData=this.waitingData||{frag:s,part:r,cache:new Ou,complete:!1};m.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=F.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s.type!==ie.AUDIO){if(!this.loadedmetadata&&s.type===ie.MAIN){const n=this.videoBuffer||this.media;n&&De.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(s.sn!=="initSegment"){this.fragPrevious=s;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(p.AUDIO_TRACK_SWITCHED,et({},n)))}this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=F.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ie.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===F.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===ye.AUDIO_TRACK&&(this.state=F.IDLE);break;case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushed(e,{type:t}){t===Re.AUDIO&&(this.bufferFlushed=!0,this.state===F.ENDED&&(this.state=F.IDLE))}_handleTransmuxComplete(e){var t;const s="audio",{hls:r}=this,{remuxResult:n,chunkMeta:o}=e,a=this.getCurrentContext(o);if(!a){this.resetWhenMissingContext(o);return}const{frag:l,part:c,level:u}=a,{details:f}=u,{audio:h,text:d,id3:g,initSegment:m}=n;if(this.fragContextChanged(l)||!f){this.fragmentTracker.removeFragment(l);return}if(this.state=F.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),m!=null&&m.tracks){const y=l.initSegment||l;this._bufferInitSegment(m.tracks,y,o),r.trigger(p.FRAG_PARSING_INIT_SEGMENT,{frag:y,id:s,tracks:m.tracks})}if(h){const{startPTS:y,endPTS:T,startDTS:x,endDTS:v}=h;c&&(c.elementaryStreams[Re.AUDIO]={startPTS:y,endPTS:T,startDTS:x,endDTS:v}),l.setElementaryStreamInfo(Re.AUDIO,y,T,x,v),this.bufferFragmentData(h,l,c,o)}if(g!=null&&(t=g.samples)!=null&&t.length){const y=Ne({id:s,frag:l,details:f},g);r.trigger(p.FRAG_PARSING_METADATA,y)}if(d){const y=Ne({id:s,frag:l,details:f},d);r.trigger(p.FRAG_PARSING_USERDATA,y)}}_bufferInitSegment(e,t,s){if(this.state!==F.PARSING)return;e.video&&delete e.video;const r=e.audio;if(!r)return;r.levelCodec=r.codec,r.id="audio",this.log(`Init audio buffer, container:${r.container}, codecs[parsed]=[${r.codec}]`),this.hls.trigger(p.BUFFER_CODECS,e);const n=r.initSegment;if(n!=null&&n.byteLength){const o={type:"audio",frag:t,part:null,chunkMeta:s,parent:t.type,data:n};this.hls.trigger(p.BUFFER_APPENDING,o)}this.tick()}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===Me.NOT_LOADED||r===Me.PARTIAL){var n;e.sn==="initSegment"?this._loadInitSegment(e,t):(n=t.details)!=null&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=F.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,s))}else this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:s,bufferedTrack:r}=this,n=r==null?void 0:r.attrs,o=e.attrs;s&&n&&(n.CHANNELS!==o.CHANNELS||n.NAME!==o.NAME||n.LANGUAGE!==o.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(p.AUDIO_TRACK_SWITCHED,et({},e))}}class py extends uo{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(p.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:s,groupId:r,details:n}=t,o=this.tracksInGroup[s];if(!o||o.groupId!==r){this.warn(`Track with id:${s} and group:${r} not found in active group ${o.groupId}`);return}const a=o.details;o.details=t.details,this.log(`audio-track ${s} "${o.name}" lang:${o.lang} group:${r} loaded [${n.startSN}-${n.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.audioGroupIds))return;const s=t.audioGroupIds[t.urlId];if(this.groupId!==s){this.groupId=s||null;const r=this.tracks.filter(o=>!s||o.groupId===s);this.selectDefaultTrack&&!r.some(o=>o.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=r;const n={audioTracks:r};this.log(`Updating audio tracks, ${r.length} track(s) found in group:${s}`),this.hls.trigger(p.AUDIO_TRACKS_UPDATED,n),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===ye.AUDIO_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn("Invalid id passed to audio-track controller");return}this.clearTimer();const s=this.currentTrack;t[this.trackId];const r=t[e],{groupId:n,name:o}=r;if(this.log(`Switching to audio-track ${e} "${o}" lang:${r.lang} group:${n}`),this.trackId=e,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(p.AUDIO_TRACK_SWITCHING,et({},r)),r.details&&!r.details.live)return;const a=this.switchParams(r.url,s==null?void 0:s.details);this.loadPlaylist(a)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(t!==-1)this.setAudioTrack(t);else{const s=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(s.message),this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:s})}}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if((!this.selectDefaultTrack||r.default)&&(!e||e.attrs["STABLE-RENDITION-ID"]!==void 0&&e.attrs["STABLE-RENDITION-ID"]===r.attrs["STABLE-RENDITION-ID"]||e.name===r.name&&e.lang===r.lang))return r.id}return-1}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`loading audio-track playlist ${s} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(p.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}}function Fu(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!yy(i[t].attrs,e[t].attrs))return!1;return!0}function yy(i,e){const t=i["STABLE-RENDITION-ID"];return t?t===e["STABLE-RENDITION-ID"]:!["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED"].some(s=>i[s]!==e[s])}const cl=500;class Ty extends mo{constructor(e,t,s){super(e,t,s,"[subtitle-stream-controller]",ie.SUBTITLE),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.LEVEL_LOADED,this.onLevelLoaded,this),e.on(p.ERROR,this.onError,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.LEVEL_LOADED,this.onLevelLoaded,this),e.off(p.ERROR,this.onError,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=F.IDLE,this.setInterval(cl),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:s,success:r}=t;if(this.fragPrevious=s,this.state=F.IDLE,!r)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let o;const a=s.start;for(let c=0;c<n.length;c++)if(a>=n[c].start&&a<=n[c].end){o=n[c];break}const l=s.start+s.duration;o?o.end=l:(o={start:a,end:l},n.push(o)),this.fragmentTracker.fragBuffered(s)}onBufferFlushing(e,t){const{startOffset:s,endOffset:r}=t;if(s===0&&r!==Number.POSITIVE_INFINITY){const n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(o=>{for(let a=0;a<o.length;){if(o[a].end<=n){o.shift();continue}else if(o[a].start<n)o[a].start=n;else break;a++}}),this.fragmentTracker.removeFragmentsInRange(s,n,ie.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ie.MAIN){var s;(s=this.media)!=null&&s.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const s=t.frag;(s==null?void 0:s.type)===ie.SUBTITLE&&(this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==F.STOPPED&&(this.state=F.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(Fu(this.levels,t)){this.levels=t.map(s=>new ri(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const r=new ri(s);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ie.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(cl)}onSubtitleTrackLoaded(e,t){var s;const{details:r,id:n}=t,{currentTrackId:o,levels:a}=this;if(!a.length)return;const l=a[o];if(n>=a.length||n!==o||!l)return;this.mediaBuffer=this.mediaBufferTimeRanges;let c=0;if(r.live||(s=l.details)!=null&&s.live){const u=this.mainDetails;if(r.deltaUpdateFailed||!u)return;const f=u.fragments[0];l.details?(c=this.alignPlaylists(r,l.details),c===0&&f&&(c=f.start,In(r,c))):r.hasProgramDateTime&&u.hasProgramDateTime?(Tu(r,u),c=r.fragments[0].start):f&&(c=f.start,In(r,c))}l.details=r,this.levelLastLoaded=n,!this.startFragRequested&&(this.mainDetails||!r.live)&&this.setStartPosition(l.details,c),this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===F.IDLE&&(ni(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&r&&r.key&&r.iv&&r.method==="AES-128"){const o=performance.now();this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch(a=>{throw n.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:a,reason:a.message,frag:t}),a}).then(a=>{const l=performance.now();n.trigger(p.FRAG_DECRYPTED,{frag:t,payload:a,stats:{tstart:o,tdecrypt:l}})}).catch(a=>{this.warn(`${a.name}: ${a.message}`),this.state=F.IDLE})}}doTick(){if(!this.media){this.state=F.IDLE;return}if(this.state===F.IDLE){const{currentTrackId:e,levels:t}=this,s=t[e];if(!t.length||!s||!s.details)return;const{config:r}=this,n=this.getLoadPosition(),o=De.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:a,len:l}=o,c=this.getFwdBufferInfo(this.media,ie.MAIN),u=s.details,f=this.getMaxBufferLength(c==null?void 0:c.len)+u.levelTargetDuration;if(l>f)return;const h=u.fragments,d=h.length,g=u.edge;let m=null;const y=this.fragPrevious;if(a<g){const T=r.maxFragLookUpTolerance,x=a>g-T?0:T;m=ni(y,h,Math.max(h[0].start,a),x),!m&&y&&y.start<h[0].start&&(m=h[0])}else m=h[d-1];if(!m)return;if(m=this.mapToInitFragWhenRequired(m),m.sn!=="initSegment"){const T=m.sn-u.startSN,x=h[T-1];x&&x.cc===m.cc&&this.fragmentTracker.getState(x)===Me.NOT_LOADED&&(m=x)}this.fragmentTracker.getState(m)===Me.NOT_LOADED&&this.loadFragment(m,s,a)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,s){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,s))}get mediaBufferTimeRanges(){return new Ey(this.tracksBuffered[this.currentTrackId]||[])}}class Ey{constructor(e){this.buffered=void 0;const t=(s,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}class xy extends uo{constructor(e){super(e,"[subtitle-track-controller]"),this.media=null,this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.trackChangeListener=()=>this.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.LEVEL_LOADING,this.onLevelLoading,this),e.on(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.LEVEL_LOADING,this.onLevelLoading,this),e.off(p.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(p.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(p.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Yr(this.media.textTracks).forEach(t=>{ps(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:s,details:r}=t,{trackId:n}=this,o=this.tracksInGroup[n];if(!o){this.warn(`Invalid subtitle track id ${s}`);return}const a=o.details;o.details=t.details,this.log(`subtitle track ${s} loaded [${r.startSN}-${r.endSN}]`),s===this.trackId&&this.playlistLoaded(s,t,a)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!(t!=null&&t.textGroupIds))return;const s=t.textGroupIds[t.urlId],r=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==s){const n=this.tracks.filter(l=>!s||l.groupId===s);this.tracksInGroup=n;const o=this.findTrackId(r==null?void 0:r.name)||this.findTrackId();this.groupId=s||null;const a={subtitleTracks:n};this.log(`Updating subtitle tracks, ${n.length} track(s) found in "${s}" group-id`),this.hls.trigger(p.SUBTITLE_TRACKS_UPDATED,a),o!==-1&&this.setSubtitleTrack(o,r)}else this.shouldReloadPlaylist(r)&&this.setSubtitleTrack(this.trackId,r)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if((!this.selectDefaultTrack||r.default)&&(!e||e===r.name))return r.id}return-1}onError(e,t){t.fatal||!t.context||t.context.type===ye.SUBTITLE_TRACK&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&this.checkRetry(t)}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1;const t=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(e,t)}loadPlaylist(e){super.loadPlaylist();const t=this.tracksInGroup[this.trackId];if(this.shouldLoadPlaylist(t)){const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(o){this.warn(`Could not construct new URL with HLS Delivery Directives: ${o}`)}this.log(`Loading subtitle playlist for id ${s}`),this.hls.trigger(p.SUBTITLE_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}toggleTrackModes(e){const{media:t,trackId:s}=this;if(!t)return;const r=Yr(t.textTracks),n=r.filter(a=>a.groupId===this.groupId);if(e===-1)[].slice.call(r).forEach(a=>{a.mode="disabled"});else{const a=n[s];a&&(a.mode="disabled")}const o=n[e];o&&(o.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var s;const r=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(e===-1||(s=r[e])!=null&&s.details)||e<-1||e>=r.length)return;this.clearTimer();const n=r[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){const{id:o,groupId:a="",name:l,type:c,url:u}=n;this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:o,groupId:a,name:l,type:c,url:u});const f=this.switchParams(n.url,t==null?void 0:t.details);this.loadPlaylist(f)}else this.hls.trigger(p.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=Yr(this.media.textTracks);for(let s=0;s<t.length;s++)if(t[s].mode==="hidden")e=s;else if(t[s].mode==="showing"){e=s;break}this.subtitleTrack!==e&&(this.subtitleTrack=e)}}function Yr(i){const e=[];for(let t=0;t<i.length;t++){const s=i[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(i[t])}return e}class Sy{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t){const s=this.queues[t];s.push(e),s.length===1&&this.buffers[t]&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const s=new Promise(n=>{t=n}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),s}executeNext(e){const{buffers:t,queues:s}=this,r=t[e],n=s[e];if(n.length){const o=n[0];try{o.execute()}catch(a){A.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),o.onError(a),r!=null&&r.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const ul=pr(),fl=/([ha]vc.)(?:\.[^.,]+)+/;class vy{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=()=>{const{media:t,mediaSource:s}=this;A.log("[buffer-controller]: Media source opened"),t&&(t.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(p.MEDIA_ATTACHED,{media:t})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{A.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{A.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:t,_objectUrl:s}=this;t&&t.src!==s&&A.error(`Media element src was set while attaching MediaSource (${s} > ${t.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:e}=this;e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_RESET,this.onBufferReset,this),e.on(p.BUFFER_APPENDING,this.onBufferAppending,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.BUFFER_EOS,this.onBufferEos,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(p.FRAG_PARSED,this.onFragParsed,this),e.on(p.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_RESET,this.onBufferReset,this),e.off(p.BUFFER_APPENDING,this.onBufferAppending,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.BUFFER_EOS,this.onBufferEos,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(p.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(p.FRAG_PARSED,this.onFragParsed,this),e.off(p.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new Sy(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=s,A.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const s=this.media=t.media;if(s&&ul){const r=this.mediaSource=new ul;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),s.src=self.URL.createObjectURL(r),this._objectUrl=s.src,s.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:s}=this;if(t){if(A.log("[buffer-controller]: media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(r){A.warn(`[buffer-controller]: onMediaDetaching: ${r.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),s&&self.URL.revokeObjectURL(s),e.src===s?(e.removeAttribute("src"),e.load()):A.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(p.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(s){A.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,s)}}),this._initSourceBuffer()}onBufferCodecs(e,t){const s=this.getSourceBufferTypes().length;Object.keys(t).forEach(r=>{if(s){const n=this.tracks[r];if(n&&typeof n.buffer.changeType=="function"){const{id:o,codec:a,levelCodec:l,container:c,metadata:u}=t[r],f=(n.levelCodec||n.codec).replace(fl,"$1"),h=(l||a).replace(fl,"$1");if(f!==h){const d=`${c};codecs=${l||a}`;this.appendChangeType(r,d),A.log(`[buffer-controller]: switching codec ${f} to ${h}`),this.tracks[r]={buffer:n.buffer,codec:a,container:c,levelCodec:l,metadata:u,id:o}}}}else this.pendingTracks[r]=t[r]}),!s&&(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:s}=this,r={execute:()=>{const n=this.sourceBuffer[e];n&&(A.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),s.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{A.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,n)}};s.append(r,e)}onBufferAppending(e,t){const{hls:s,operationQueue:r,tracks:n}=this,{data:o,type:a,frag:l,part:c,chunkMeta:u}=t,f=u.buffering[a],h=self.performance.now();f.start=h;const d=l.stats.buffering,g=c?c.stats.buffering:null;d.start===0&&(d.start=h),g&&g.start===0&&(g.start=h);const m=n.audio;let y=!1;a==="audio"&&(m==null?void 0:m.container)==="audio/mpeg"&&(y=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const T=l.start,x={execute:()=>{if(f.executeStart=self.performance.now(),y){const v=this.sourceBuffer[a];if(v){const R=T-v.timestampOffset;Math.abs(R)>=.1&&(A.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${T} (delta: ${R}) sn: ${l.sn})`),v.timestampOffset=T)}}this.appendExecutor(o,a)},onStart:()=>{},onComplete:()=>{const v=self.performance.now();f.executeEnd=f.end=v,d.first===0&&(d.first=v),g&&g.first===0&&(g.first=v);const{sourceBuffer:R}=this,b={};for(const M in R)b[M]=De.getBuffered(R[M]);this.appendError=0,this.hls.trigger(p.BUFFER_APPENDED,{type:a,frag:l,part:c,chunkMeta:u,parent:l.type,timeRanges:b})},onError:v=>{A.error(`[buffer-controller]: Error encountered while trying to append to the ${a} SourceBuffer`,v);const R={type:se.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,frag:l,part:c,chunkMeta:u,error:v,err:v,fatal:!1};v.code===DOMException.QUOTA_EXCEEDED_ERR?R.details=D.BUFFER_FULL_ERROR:(this.appendError++,R.details=D.BUFFER_APPEND_ERROR,this.appendError>s.config.appendErrorMaxRetry&&(A.error(`[buffer-controller]: Failed ${s.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),R.fatal=!0)),s.trigger(p.ERROR,R)}};r.append(x,a)}onBufferFlushing(e,t){const{operationQueue:s}=this,r=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(p.BUFFER_FLUSHED,{type:n})},onError:o=>{A.warn(`[buffer-controller]: Failed to remove from ${n} SourceBuffer`,o)}});t.type?s.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{s.append(r(n),n)})}onFragParsed(e,t){const{frag:s,part:r}=t,n=[],o=r?r.elementaryStreams:s.elementaryStreams;o[Re.AUDIOVIDEO]?n.push("audiovideo"):(o[Re.AUDIO]&&n.push("audio"),o[Re.VIDEO]&&n.push("video"));const a=()=>{const l=self.performance.now();s.stats.buffering.end=l,r&&(r.stats.buffering.end=l);const c=r?r.stats:s.stats;this.hls.trigger(p.FRAG_BUFFERED,{frag:s,part:r,stats:c,id:s.type})};n.length===0&&A.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(a,n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,n)=>{const o=this.sourceBuffer[n];return o&&(!t.type||t.type===n)&&(o.ending=!0,o.ended||(o.ended=!0,A.log(`[buffer-controller]: ${n} sourceBuffer now EOS`))),r&&!!(!o||o.ended)},!0)&&(A.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const o=this.sourceBuffer[n];o&&(o.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&A.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}A.log("[buffer-controller]: Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:s,sourceBuffer:r}=this;if(!s||t===null)return;const n=this.getSourceBufferTypes();if(!n.length)return;const o=t.live&&e.config.liveBackBufferLength!==null?e.config.liveBackBufferLength:e.config.backBufferLength;if(!J(o)||o<0)return;const a=s.currentTime,l=t.levelTargetDuration,c=Math.max(o,l),u=Math.floor(a/l)*l-c;n.forEach(f=>{const h=r[f];if(h){const d=De.getBuffered(h);if(d.length>0&&u>d.start(0)){if(e.trigger(p.BACK_BUFFER_REACHED,{bufferEnd:u}),t.live)e.trigger(p.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(h.ended&&d.end(d.length-1)-a<l*2){A.info(`[buffer-controller]: Cannot flush ${f} back buffer while SourceBuffer is in ended state`);return}e.trigger(p.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:f})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:s,mediaSource:r}=this,n=e.fragments[0].start+e.totalduration,o=s.duration,a=J(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(A.log("[buffer-controller]: Media Source duration is set to Infinity"),r.duration=1/0,this.updateSeekableRange(e)):(n>a&&n>o||!J(o))&&(A.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),r.duration=n)}updateSeekableRange(e){const t=this.mediaSource,s=e.fragments;if(s.length&&e.live&&t!=null&&t.setLiveSeekableRange){const n=Math.max(0,s[0].start),o=Math.max(n,n+e.totalduration);t.setLiveSeekableRange(n,o)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:s}=this,r=Object.keys(s).length;if(r&&!e||r===2){this.createSourceBuffers(s),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(p.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(o=>{t.executeNext(o)});else{const o=new Error("could not create source buffer for media codec(s)");this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:o,reason:o.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:s}=this;if(!s)throw Error("createSourceBuffers called when mediaSource was null");for(const r in e)if(!t[r]){const n=e[r];if(!n)throw Error(`source buffer exists for track ${r}, however track does not`);const o=n.levelCodec||n.codec,a=`${n.container};codecs=${o}`;A.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{const l=t[r]=s.addSourceBuffer(a),c=r;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.tracks[r]={buffer:l,codec:o,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(l){A.error(`[buffer-controller]: error while trying to add sourceBuffer: ${l.message}`),this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:l,mimeType:a})}}}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const s=new Error(`${e} SourceBuffer error`);A.error(`[buffer-controller]: ${s}`,t),this.hls.trigger(p.ERROR,{type:se.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,error:s,fatal:!1});const r=this.operationQueue.current(e);r&&r.onError(t)}removeExecutor(e,t,s){const{media:r,mediaSource:n,operationQueue:o,sourceBuffer:a}=this,l=a[e];if(!r||!n||!l){A.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),o.shiftAndExecuteNext(e);return}const c=J(r.duration)?r.duration:1/0,u=J(n.duration)?n.duration:1/0,f=Math.max(0,t),h=Math.min(s,c,u);h>f&&!l.ending?(l.ended=!1,A.log(`[buffer-controller]: Removing [${f},${h}] from the ${e} SourceBuffer`),l.remove(f,h)):o.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:s,sourceBuffer:r}=this,n=r[t];if(!n){A.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),s.shiftAndExecuteNext(t);return}n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){A.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:s}=this,r=t.map(n=>s.appendBlocker(n));Promise.all(r).then(()=>{e(),t.forEach(n=>{const o=this.sourceBuffer[n];o!=null&&o.updating||s.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,s){const r=this.sourceBuffer[e];if(!r)return;const n=s.bind(this,e);this.listeners[e].push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(s=>{t.removeEventListener(s.event,s.listener)})}}const hl={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Nu=function(e){let t=e;return hl.hasOwnProperty(e)&&(t=hl[e]),String.fromCharCode(t)},ct=15,Ct=100,Ay={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ry={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ly={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},by={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Iy=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Dy{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;A.log(`${this.time} [${e}] ${s}`)}}}const Jt=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class Mu{constructor(e,t,s,r,n){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=e||"white",this.underline=t||!1,this.italics=s||!1,this.background=r||"black",this.flash=n||!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(e){const t=["foreground","underline","italics","background","flash"];for(let s=0;s<t.length;s++){const r=t[s];e.hasOwnProperty(r)&&(this[r]=e[r])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class _y{constructor(e,t,s,r,n,o){this.uchar=void 0,this.penState=void 0,this.uchar=e||" ",this.penState=new Mu(t,s,r,n,o)}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class Cy{constructor(e){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(let t=0;t<Ct;t++)this.chars.push(new _y);this.logger=e,this.pos=0,this.currPenState=new Mu}equals(e){let t=!0;for(let s=0;s<Ct;s++)if(!this.chars[s].equals(e.chars[s])){t=!1;break}return t}copy(e){for(let t=0;t<Ct;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Ct;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Ct&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Ct)}moveCursor(e){const t=this.pos+e;if(e>1)for(let s=this.pos+1;s<t+1;s++)this.chars[s].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Nu(e);if(this.pos>=Ct){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<Ct;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let s=0;s<Ct;s++){const r=this.chars[s].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class jr{constructor(e){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(let t=0;t<ct;t++)this.rows.push(new Cy(e));this.logger=e,this.currRow=ct-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}reset(){for(let e=0;e<ct;e++)this.rows[e].clear();this.currRow=ct-1}equals(e){let t=!0;for(let s=0;s<ct;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<ct;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<ct;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let a=0;a<ct;a++)this.rows[a].clear();const n=this.currRow+1-this.nrRollUpRows,o=this.lastOutputScreen;if(o){const a=o.rows[n].cueStartTime,l=this.logger.time;if(a&&l!==null&&a<l)for(let c=0;c<this.nrRollUpRows;c++)this.rows[t-this.nrRollUpRows+c+1].copy(o.rows[n+c])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,o=Math.max(n-1,0);s.setCursor(e.indent),e.color=s.chars[o].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let s="",r=-1;for(let n=0;n<ct;n++){const o=this.rows[n].getTextString();o&&(r=n+1,e?t.push("Row "+r+": '"+o+"'"):t.push(o.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join(`
`)),s}getTextAndFormat(){return this.rows}}class dl{constructor(e,t,s){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new jr(s),this.nonDisplayedMemory=new jr(s),this.lastOutputScreen=new jr(s),this.currRollUpRow=this.displayedMemory.rows[ct-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[ct-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let s=0;s<e.length;s++)this.writeScreen.insertChar(e[s]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),this.mode!=="MODE_TEXT"&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const s=Math.floor(e/2)-16,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[s]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class gl{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const r=new Dy;this.channels=[null,new dl(e,t,r),new dl(e+1,s,r)],this.cmdHistory=pl(),this.logger=r}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let s,r,n,o=!1;this.logger.time=e;for(let a=0;a<t.length;a+=2)if(r=t[a]&127,n=t[a+1]&127,!(r===0&&n===0)){if(this.logger.log(3,"["+Jt([t[a],t[a+1]])+"] -> ("+Jt([r,n])+")"),s=this.parseCmd(r,n),s||(s=this.parseMidrow(r,n)),s||(s=this.parsePAC(r,n)),s||(s=this.parseBackgroundAttributes(r,n)),!s&&(o=this.parseChars(r,n),o)){const l=this.currentChannel;l&&l>0?this.channels[l].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!s&&!o&&this.logger.log(2,"Couldn't parse cleaned data "+Jt([r,n])+" orig: "+Jt([t[a],t[a+1]]))}}parseCmd(e,t){const{cmdHistory:s}=this,r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,n=(e===23||e===31)&&t>=33&&t<=35;if(!(r||n))return!1;if(ml(e,t,s))return gs(null,null,s),this.logger.log(3,"Repeated command ("+Jt([e,t])+") is dropped"),!0;const o=e===20||e===21||e===23?1:2,a=this.channels[o];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),gs(e,t,s),this.currentChannel=o,!0}parseMidrow(e,t){let s=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?s=1:s=2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const r=this.channels[s];return r?(r.ccMIDROW(t),this.logger.log(3,"MIDROW ("+Jt([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const r=this.cmdHistory,n=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,o=(e===16||e===24)&&t>=64&&t<=95;if(!(n||o))return!1;if(ml(e,t,r))return gs(null,null,r),!0;const a=e<=23?1:2;t>=64&&t<=95?s=a===1?Ay[e]:Ly[e]:s=a===1?Ry[e]:by[e];const l=this.channels[a];return l?(l.setPAC(this.interpretPAC(s,t)),gs(e,t,r),this.currentChannel=a,!0):!1}interpretPAC(e,t){let s;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,r.underline=(s&1)===1,s<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((s-16)/2)*4,r}parseChars(e,t){let s,r=null,n=null;if(e>=25?(s=2,n=e-8):(s=1,n=e),n>=17&&n<=19){let o;n===17?o=t+80:n===18?o=t+112:o=t+144,this.logger.log(2,"Special char '"+Nu(o)+"' in channel "+s),r=[o]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);if(r){const o=Jt(r);this.logger.log(3,"Char codes =  "+o.join(",")),gs(e,t,this.cmdHistory)}return r}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(s||r))return!1;let n;const o={};e===16||e===24?(n=Math.floor((t-32)/2),o.background=Iy[n],t%2===1&&(o.background=o.background+"_semi")):t===45?o.background="transparent":(o.foreground="black",t===47&&(o.underline=!0));const a=e<=23?1:2;return this.channels[a].setBkgData(o),gs(e,t,this.cmdHistory),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}this.cmdHistory=pl()}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const s=this.channels[t];s&&s.cueSplitAtTime(e)}}}function gs(i,e,t){t.a=i,t.b=e}function ml(i,e,t){return t.a===i&&t.b===e}function pl(){return{a:null,b:null}}class Si{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,s){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var xo=function(){if(typeof self<"u"&&self.VTTCue)return self.VTTCue;const i=["","lr","rl"],e=["start","middle","end","left","right"];function t(a,l){if(typeof l!="string"||!Array.isArray(a))return!1;const c=l.toLowerCase();return~a.indexOf(c)?c:!1}function s(a){return t(i,a)}function r(a){return t(e,a)}function n(a,...l){let c=1;for(;c<arguments.length;c++){const u=arguments[c];for(const f in u)a[f]=u[f]}return a}function o(a,l,c){const u=this,f={enumerable:!0};u.hasBeenReset=!1;let h="",d=!1,g=a,m=l,y=c,T=null,x="",v=!0,R="auto",b="start",M=50,P="middle",B=50,K="middle";Object.defineProperty(u,"id",n({},f,{get:function(){return h},set:function(_){h=""+_}})),Object.defineProperty(u,"pauseOnExit",n({},f,{get:function(){return d},set:function(_){d=!!_}})),Object.defineProperty(u,"startTime",n({},f,{get:function(){return g},set:function(_){if(typeof _!="number")throw new TypeError("Start time must be set to a number.");g=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},f,{get:function(){return m},set:function(_){if(typeof _!="number")throw new TypeError("End time must be set to a number.");m=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},f,{get:function(){return y},set:function(_){y=""+_,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},f,{get:function(){return T},set:function(_){T=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},f,{get:function(){return x},set:function(_){const q=s(_);if(q===!1)throw new SyntaxError("An invalid or illegal string was specified.");x=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},f,{get:function(){return v},set:function(_){v=!!_,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},f,{get:function(){return R},set:function(_){if(typeof _!="number"&&_!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");R=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},f,{get:function(){return b},set:function(_){const q=r(_);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");b=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},f,{get:function(){return M},set:function(_){if(_<0||_>100)throw new Error("Position must be between 0 and 100.");M=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},f,{get:function(){return P},set:function(_){const q=r(_);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");P=q,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},f,{get:function(){return B},set:function(_){if(_<0||_>100)throw new Error("Size must be between 0 and 100.");B=_,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},f,{get:function(){return K},set:function(_){const q=r(_);if(!q)throw new SyntaxError("An invalid or illegal string was specified.");K=q,this.hasBeenReset=!0}})),u.displayState=void 0}return o.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},o}();class wy{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Uu(i){function e(s,r,n,o){return(s|0)*3600+(r|0)*60+(n|0)+parseFloat(o||0)}const t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class Py{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,s){return s?this.has(e)?this.values[e]:t[s]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,s){for(let r=0;r<s.length;++r)if(t===s[r]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const s=parseFloat(t);if(s>=0&&s<=100)return this.set(e,s),!0}return!1}}function Bu(i,e,t,s){const r=s?i.split(s):[i];for(const n in r){if(typeof r[n]!="string")continue;const o=r[n].split(t);if(o.length!==2)continue;const a=o[0],l=o[1];e(a,l)}}const Cn=new xo(0,0,""),vi=Cn.align==="middle"?"middle":"center";function ky(i,e,t){const s=i;function r(){const a=Uu(i);if(a===null)throw new Error("Malformed timestamp: "+s);return i=i.replace(/^[^\sa-zA-Z-]+/,""),a}function n(a,l){const c=new Py;Bu(a,function(h,d){let g;switch(h){case"region":for(let m=t.length-1;m>=0;m--)if(t[m].id===d){c.set(h,t[m].region);break}break;case"vertical":c.alt(h,d,["rl","lr"]);break;case"line":g=d.split(","),c.integer(h,g[0]),c.percent(h,g[0])&&c.set("snapToLines",!1),c.alt(h,g[0],["auto"]),g.length===2&&c.alt("lineAlign",g[1],["start",vi,"end"]);break;case"position":g=d.split(","),c.percent(h,g[0]),g.length===2&&c.alt("positionAlign",g[1],["start",vi,"end","line-left","line-right","auto"]);break;case"size":c.percent(h,d);break;case"align":c.alt(h,d,["start",vi,"end","left","right"]);break}},/:/,/\s/),l.region=c.get("region",null),l.vertical=c.get("vertical","");let u=c.get("line","auto");u==="auto"&&Cn.line===-1&&(u=-1),l.line=u,l.lineAlign=c.get("lineAlign","start"),l.snapToLines=c.get("snapToLines",!0),l.size=c.get("size",100),l.align=c.get("align",vi);let f=c.get("position","auto");f==="auto"&&Cn.position===50&&(f=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=f}function o(){i=i.replace(/^\s+/,"")}if(o(),e.startTime=r(),o(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);i=i.slice(3),o(),e.endTime=r(),o(),n(i,e)}function $u(i){return i.replace(/<br(?: \/)?>/gi,`
`)}class Oy{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new wy,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function s(){let n=t.buffer,o=0;for(n=$u(n);o<n.length&&n[o]!=="\r"&&n[o]!==`
`;)++o;const a=n.slice(0,o);return n[o]==="\r"&&++o,n[o]===`
`&&++o,t.buffer=n.slice(o),a}function r(n){Bu(n,function(o,a){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=s();const a=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(a!=null&&a[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let o=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(o?o=!1:n=s(),t.state){case"HEADER":/:/.test(n)?r(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new xo(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{ky(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const a=n.indexOf("-->")!==-1;if(!n||a&&(o=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
`),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`

`,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const Fy=/\r\n|\n\r|\n|\r/g,qr=function(e,t,s=0){return e.slice(s,s+t.length)===t},Ny=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!J(t)||!J(s)||!J(r)||!J(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*s,t+=60*1e3*r,t+=60*60*1e3*n,t},zr=function(e){let t=5381,s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return(t>>>0).toString()};function So(i,e,t){return zr(i.toString())+zr(e.toString())+zr(t)}const My=function(e,t,s){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(o=n)!=null&&o.new;){var o;e.ccOffset+=r.start-n.start,r.new=!1,r=n,n=e[r.prevCC]}e.presentationOffset=s};function Uy(i,e,t,s,r,n,o){const a=new Oy,l=bt(new Uint8Array(i)).trim().replace(Fy,`
`).split(`
`),c=[],u=e?zp(e.baseTime,e.timescale):0;let f="00:00.000",h=0,d=0,g,m=!0;a.oncue=function(y){const T=t[s];let x=t.ccOffset;const v=(h-u)/9e4;if(T!=null&&T.new&&(d!==void 0?x=t.ccOffset=T.start:My(t,s,v)),v){if(!e){g=new Error("Missing initPTS for VTT MPEGTS");return}x=v-t.presentationOffset}const R=y.endTime-y.startTime,b=rt((y.startTime+x-d)*9e4,r*9e4)/9e4;y.startTime=Math.max(b,0),y.endTime=Math.max(b+R,0);const M=y.text.trim();y.text=decodeURIComponent(encodeURIComponent(M)),y.id||(y.id=So(y.startTime,y.endTime,M)),y.endTime>0&&c.push(y)},a.onparsingerror=function(y){g=y},a.onflush=function(){if(g){o(g);return}n(c)},l.forEach(y=>{if(m)if(qr(y,"X-TIMESTAMP-MAP=")){m=!1,y.slice(16).split(",").forEach(T=>{qr(T,"LOCAL:")?f=T.slice(6):qr(T,"MPEGTS:")&&(h=parseInt(T.slice(7)))});try{d=Ny(f)/1e3}catch(T){g=T}return}else y===""&&(m=!1);a.parse(y+`
`)}),a.flush()}const Xr="stpp.ttml.im1t",Gu=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Ku=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,By={left:"start",center:"center",right:"end",start:"start",end:"end"};function yl(i,e,t,s){const r=pe(new Uint8Array(i),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(a=>bt(a)),o=qp(e.baseTime,1,e.timescale);try{n.forEach(a=>t($y(a,o)))}catch(a){s(a)}}function $y(i,e){const r=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},o=Object.keys(n).reduce((f,h)=>(f[h]=r.getAttribute(`ttp:${h}`)||n[h],f),{}),a=r.getAttribute("xml:space")!=="preserve",l=Tl(Qr(r,"styling","style")),c=Tl(Qr(r,"layout","region")),u=Qr(r,"body","[begin]");return[].map.call(u,f=>{const h=Hu(f,a);if(!h||!f.hasAttribute("begin"))return null;const d=Zr(f.getAttribute("begin"),o),g=Zr(f.getAttribute("dur"),o);let m=Zr(f.getAttribute("end"),o);if(d===null)throw El(f);if(m===null){if(g===null)throw El(f);m=d+g}const y=new xo(d-e,m-e,h);y.id=So(y.startTime,y.endTime,y.text);const T=c[f.getAttribute("region")],x=l[f.getAttribute("style")],v=Gy(T,x,l),{textAlign:R}=v;if(R){const b=By[R];b&&(y.lineAlign=b),y.align=R}return Ne(y,v),y}).filter(f=>f!==null)}function Qr(i,e,t){const s=i.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function Tl(i){return i.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function Hu(i,e){return[].slice.call(i.childNodes).reduce((t,s,r)=>{var n;return s.nodeName==="br"&&r?t+`
`:(n=s.childNodes)!=null&&n.length?Hu(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function Gy(i,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],o=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return o&&t.hasOwnProperty(o)&&(r=t[o]),n.reduce((a,l)=>{const c=Jr(e,s,l)||Jr(i,s,l)||Jr(r,s,l);return c&&(a[l]=c),a},{})}function Jr(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function El(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Zr(i,e){if(!i)return null;let t=Uu(i);return t===null&&(Gu.test(i)?t=Ky(i,e):Ku.test(i)&&(t=Hy(i,e))),t}function Ky(i,e){const t=Gu.exec(i),s=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+s/e.frameRate}function Hy(i,e){const t=Ku.exec(i),s=Number(t[1]);switch(t[2]){case"h":return s*3600;case"m":return s*60;case"ms":return s*1e3;case"f":return s/e.frameRate;case"t":return s/e.tickRate}return s}class Vy{constructor(e){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=xl(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){const t=new Si(this,"textTrack1"),s=new Si(this,"textTrack2"),r=new Si(this,"textTrack3"),n=new Si(this,"textTrack4");this.cea608Parser1=new gl(1,t,s),this.cea608Parser2=new gl(3,r,n)}e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(p.FRAG_LOADING,this.onFragLoading,this),e.on(p.FRAG_LOADED,this.onFragLoaded,this),e.on(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(p.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(p.FRAG_LOADING,this.onFragLoading,this),e.off(p.FRAG_LOADED,this.onFragLoaded,this),e.off(p.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(p.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(p.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(p.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(p.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null}addCues(e,t,s,r,n){let o=!1;for(let a=n.length;a--;){const l=n[a],c=Yy(l[0],l[1],t,s);if(c>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],s),o=!0,c/(s-t)>.5))return}if(o||n.push([t,s]),this.config.renderTextTracksNatively){const a=this.captionsTracks[e];this.Cues.newCue(a,t,s,r)}else{const a=this.Cues.newCue(null,t,s,r);this.hls.trigger(p.CUES_PARSED,{type:"captions",cues:a,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){const{unparsedVttFrags:o}=this;s==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),o.length&&(this.unparsedVttFrags=[],o.forEach(a=>{this.onFragLoaded(p.FRAG_LOADED,a)}))}getExistingTrack(e){const{media:t}=this;if(t)for(let s=0;s<t.textTracks.length;s++){const r=t.textTracks[s];if(r[e])return r}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:s,media:r}=this,{label:n,languageCode:o}=t[e],a=this.getExistingTrack(e);if(a)s[e]=a,ps(s[e]),fu(s[e],r);else{const l=this.createTextTrack("captions",n,o);l&&(l[e]=!0,s[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{ps(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=xl(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let s=0;s<t.length;s++)ps(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(n=>n.textCodec===Xr);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(Fu(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const o=this.media?this.media.textTracks:null;this.tracks.forEach((a,l)=>{let c;if(o&&l<o.length){let u=null;for(let f=0;f<o.length;f++)if(Wy(o[f],a)){u=o[f];break}u&&(c=u)}if(c)ps(c);else{const u=this._captionsOrSubtitlesFromCharacteristics(a);c=this.createTextTrack(u,a.name,a.lang),c&&(c.mode="disabled")}c&&(c.groupId=a.groupId,this.textTracks.push(c))})}else if(this.tracks.length){const o=this.tracks.map(a=>({label:a.name,kind:a.type.toLowerCase(),default:a.default,subtitleTrack:a}));this.hls.trigger(p.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:o})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),s=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&s)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const n=`textTrack${r[1]}`,o=this.captionsProperties[n];o&&(o.label=s.name,s.lang&&(o.languageCode=s.lang),o.media=s)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:s,cea608Parser2:r,lastSn:n,lastPartIndex:o}=this;if(!(!this.enabled||!(s&&r))&&t.frag.type===ie.MAIN){var a,l;const c=t.frag.sn,u=(a=t==null||(l=t.part)==null?void 0:l.index)!=null?a:-1;c===n+1||c===n&&u===o+1||(s.reset(),r.reset()),this.lastSn=c,this.lastPartIndex=u}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===ie.SUBTITLE)if(r.byteLength){const n=s.decryptdata,o="stats"in t;if(n==null||!n.encrypted||o){const a=this.tracks[s.level],l=this.vttCCs;l[s.cc]||(l[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),a&&a.textCodec===Xr?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;yl(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{A.log(`Failed to parse IMSC1: ${r}`),s.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:n,unparsedVttFrags:o}=this,a=n.length-1;if(!n[s.cc]&&a===-1){o.push(e);return}const l=this.hls,c=(t=s.initSegment)!=null&&t.data?ls(s.initSegment.data,new Uint8Array(r)):r;Uy(c,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,u=>{this._appendCues(u,s.level),l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},u=>{const f=u.message==="Missing initPTS for VTT MPEGTS";f?o.push(e):this._fallbackToIMSC1(s,r),A.log(`Failed to parse VTT cue: ${u}`),!(f&&a>s.cc)&&l.trigger(p.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:u})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||yl(t,this.initPTS[e.cc],()=>{s.textCodec=Xr,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>hu(r,n))}else{const r=this.tracks[t];if(!r)return;const n=r.default?"default":"subtitles"+t;s.trigger(p.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===ie.SUBTITLE&&this.onFragLoaded(p.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:s,cea608Parser2:r}=this;if(!this.enabled||!(s&&r))return;const{frag:n,samples:o}=t;if(!(n.type===ie.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let a=0;a<o.length;a++){const l=o[a].bytes;if(l){const c=this.extractCea608Data(l);s.addData(o[a].pts,c[0]),r.addData(o[a].pts,c[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:n}){const{media:o}=this;if(!(!o||o.currentTime<s)){if(!n||n==="video"){const{captionsTracks:a}=this;Object.keys(a).forEach(l=>Rn(a[l],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:a}=this;Object.keys(a).forEach(l=>Rn(a[l],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let n=0;n<s;n++){const o=e[r++],a=127&e[r++],l=127&e[r++];if(a===0&&l===0)continue;if((4&o)!==0){const u=3&o;(u===0||u===1)&&(t[u].push(a),t[u].push(l))}}return t}}function Wy(i,e){return!!i&&i.label===e.name&&!(i.textTrack1||i.textTrack2)}function Yy(i,e,t,s){return Math.min(e,s)-Math.max(i,t)}function xl(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class vo{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.BUFFER_CODECS,this.onBufferCodecs,this),e.on(p.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(p.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.BUFFER_CODECS,this.onBufferCodecs,this),e.off(p.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const s=this.hls.levels[t.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const s=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,s.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const s=t.filter((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,vo.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const s=e.getBoundingClientRect();t.width=s.width,t.height=s.height,!t.width&&!t.height&&(t.width=s.right-s.left||e.width||0,t.height=s.bottom-s.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(s=>e.bitrate===s.bitrate&&e.width===s.width&&e.height===s.height)}static getMaxLevelByMediaSize(e,t,s){if(!(e!=null&&e.length))return-1;const r=(o,a)=>a?o.width!==a.width||o.height!==a.height:!0;let n=e.length-1;for(let o=0;o<e.length;o+=1){const a=e[o];if((a.width>=t||a.height>=s)&&r(a,e[o+1])){n=o;break}}return n}}class jy{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const s=this.hls.config;if(s.capLevelOnFPSDrop){const r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,o=s-this.lastDroppedFrames,a=t-this.lastDecodedFrames,l=1e3*o/n,c=this.hls;if(c.trigger(p.FPS_DROP,{currentDropped:o,currentDecoded:a,totalDroppedFrames:s}),l>0&&o>c.config.fpsDroppedMonitoringThreshold*a){let u=c.currentLevel;A.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(c.autoLevelCapping===-1||c.autoLevelCapping>=u)&&(u=u-1,c.trigger(p.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:c.currentLevel}),c.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=r,this.lastDroppedFrames=s,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const Ai="[eme]";class Ss{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Ss.CDMCleanupPromise?[Ss.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=A.debug.bind(A,Ai),this.log=A.log.bind(A,Ai),this.warn=A.warn.bind(A,Ai),this.error=A.error.bind(A,Ai),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(p.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(p.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(p.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(p.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===Ce.WIDEVINE&&s)return s;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(o,a,l)=>!!o&&l.indexOf(o)===a,r=t.map(o=>o.audioCodec).filter(s),n=t.map(o=>o.videoCodec).filter(s);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((o,a)=>{const l=c=>{const u=c.shift();this.getMediaKeysPromise(u,r,n).then(f=>o({keySystem:u,mediaKeys:f})).catch(f=>{c.length?l(c):f instanceof st?a(f):a(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:f,fatal:!0},f.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return Zc===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){const r=am(e,t,s,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let o=n==null?void 0:n.keySystemAccess;if(!o){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),o=this.requestMediaKeySystemAccess(e,r);const a=this.keySystemAccessPromises[e]={keySystemAccess:o};return o.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),o.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const c=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),a.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),c.then(f=>f?this.setMediaKeysServerCertificate(u,e,f):u))),a.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),a.mediaKeys})}return o.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${St.hexDump(e.keyId||[])}`);const r=s.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return St.hexDump(e.keyId)}updateKeySession(e,t){var s;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${St.hexDump(((s=e.decryptdata)==null?void 0:s.keyId)||[])}
      } (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,s)=>{const r=Pr(this.config),n=e.map(wa).filter(o=>!!o&&r.indexOf(o)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:o})=>{const a=Pa(o);a?t(a):s(new Error(`Unable to find format for key-system "${o}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[s];return n||(n=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:o,mediaKeys:a})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(o,a).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:o,mediaKeys:a,decryptdata:t}),c="cenc";return this.generateRequestWithPreferredKeySession(l,c,t.pssh,"playlist-key")}))),n.catch(o=>this.handleError(o))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof st?this.hls.trigger(p.ERROR,e.data):this.hls.trigger(p.ERROR,{type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=wa(e.keyFormat),n=r?[r]:Pr(this.config);return this.attemptKeySystemAccess(n)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=Pr(this.config)),e.length===0)throw new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:s}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),s===null)return;let r,n;if(t==="sinf"&&this.config.drmSystems[Ce.FAIRPLAY]){const u=Be(new Uint8Array(s));try{const f=ao(JSON.parse(u).sinf),h=au(new Uint8Array(f));if(!h)return;r=h.subarray(8,24),n=Ce.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const u=wm(s);if(u===null)return;u.version===0&&u.systemId===Jc.WIDEVINE&&u.data&&(r=u.data.subarray(8,24)),n=om(u.systemId)}if(!n||!r)return;const o=St.hexDump(r),{keyIdToKeySessionPromise:a,mediaKeySessions:l}=this;let c=a[o];for(let u=0;u<l.length;u++){const f=l[u],h=f.decryptdata;if(h.pssh||!h.keyId)continue;const d=St.hexDump(h.keyId);if(o===d||h.uri.replace(/-/g,"").indexOf(o)!==-1){c=a[d],delete a[d],h.pssh=new Uint8Array(s),h.keyId=r,c=a[o]=c.then(()=>this.generateRequestWithPreferredKeySession(f,t,s,"encrypted-event-key-match"));break}}c||(c=a[o]=this.getKeySystemSelectionPromise([n]).then(({keySystem:u,mediaKeys:f})=>{var h;this.throwIfDestroyed();const d=new ii("ISO-23001-7",o,(h=Pa(u))!=null?h:"");return d.pssh=new Uint8Array(s),d.keyId=r,this.attemptSetMediaKeys(u,f).then(()=>{this.throwIfDestroyed();const g=this.createMediaKeySessionContext({decryptdata:d,keySystem:u,mediaKeys:f});return this.generateRequestWithPreferredKeySession(g,t,s,"encrypted-event-no-match")})})),c.catch(u=>this.handleError(u))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>s.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var n,o;const a=(n=this.config.drmSystems)==null||(o=n[e.keySystem])==null?void 0:o.generateRequest;if(a)try{const h=a.call(this.hls,t,s,e);if(!h)throw new Error("Invalid response from configured generateRequest filter");t=h.initDataType,s=e.decryptdata.pssh=h.initData?new Uint8Array(h.initData):null}catch(h){var l;if(this.warn(h.message),(l=this.hls)!=null&&l.config.debug)throw h}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const c=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${c} (init data type: ${t} length: ${s?s.byteLength:null})`);const u=new Eo;e.mediaKeysSession.onmessage=h=>{const d=e.mediaKeysSession;if(!d){u.emit("error",new Error("invalid state"));return}const{messageType:g,message:m}=h;this.log(`"${g}" message event for session "${d.sessionId}" message size: ${m.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,m).catch(y=>{this.handleError(y),u.emit("error",y)}):g==="license-release"?e.keySystem===Ce.FAIRPLAY&&(this.updateKeySession(e,Qc("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},e.mediaKeysSession.onkeystatuseschange=h=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${c}`),this.renewKeySession(e))};const f=new Promise((h,d)=>{u.on("error",d),u.on("keyStatus",g=>{g.startsWith("usable")?h():g==="output-restricted"?d(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?d(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?d(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var h;this.log(`Request generated for key-session "${(h=e.mediaKeysSession)==null?void 0:h.sessionId}" keyId: ${c}`)}).catch(h=>{throw new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:h,fatal:!1},`Error generating key-session request: ${h}`)}).then(()=>f).catch(h=>{throw u.removeAllListeners(),this.removeSession(e),h}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${St.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${St.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((o,a)=>{const l={responseType:"arraybuffer",url:n},c=t.certLoadPolicy.default,u={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},f={onSuccess:(h,d,g,m)=>{o(h.data)},onError:(h,d,g,m)=>{a(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:et({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,d,g)=>{a(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:g,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,d,g)=>{a(new Error("aborted"))}};r.load(l,u,f)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,n)=>{e.setServerCertificate(s).then(o=>{this.log(`setServerCertificate ${o?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(o=>{n(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:o,fatal:!0},o.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.message)}))}setupLicenseXHR(e,t,s,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,s,r)}).catch(o=>{if(!s.decryptdata)throw o;return e.open("POST",t,!0),n.call(this.hls,e,t,s,r)}).then(o=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:o||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const o=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${o}`);const a=new XMLHttpRequest;a.responseType="arraybuffer",a.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(a.readyState===4)if(a.status===200){this._requestLicenseFailureCount=0;let l=a.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const c=this.config.licenseResponseCallback;if(c)try{l=c.call(this.hls,a,o,e)}catch(u){this.error(u)}r(l)}else{const l=s.errorRetry,c=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||a.status>=400&&a.status<500)n(new st({type:se.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:a,response:{url:o,data:void 0,code:a.status,text:a.statusText}},`License Request XHR failed (${o}). Status: ${a.status} (${a.statusText})`));else{const u=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=a,this.setupLicenseXHR(a,o,e,t).then(({xhr:l,licenseChallenge:c})=>{l.send(c)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ii.clearKeyUriToKeyIdMap();const s=t.length;Ss.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}. media.src: ${e==null?void 0:e.src}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}. media.src: ${e==null?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(e);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}Ss.CDMCleanupPromise=void 0;class st extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}const qy=1;var qe={MANIFEST:"m",AUDIO:"a",VIDEO:"v",MUXED:"av",INIT:"i",CAPTION:"c",TIMED_TEXT:"tt",KEY:"k",OTHER:"o"};const zy="h";class Yt{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=r=>{try{this.apply(r,{ot:qe.MANIFEST,su:!this.initialized})}catch(n){A.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,o=this.hls.levels[n.level],a=this.getObjectType(n),l={d:n.duration*1e3,ot:a};(a===qe.VIDEO||a===qe.AUDIO||a==qe.MUXED)&&(l.br=o.bitrate/1e3,l.tb=this.getTopBandwidth(a)/1e3,l.bl=this.getBufferLength(a)),this.apply(r,l)}catch(n){A.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:s}=t;s!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||Yt.uuid(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.registerListeners())}registerListeners(){const e=this.hls;e.on(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(p.MEDIA_DETACHED,this.onMediaDetached,this),e.on(p.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(p.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(p.MEDIA_DETACHED,this.onMediaDetached,this),e.off(p.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var s,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:qy,sf:zy,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ne(t,this.createData());const s=t.ot===qe.INIT||t.ot===qe.VIDEO||t.ot===qe.MUXED;if(this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering),this.useHeaders){const r=Yt.toHeaders(t);if(!Object.keys(r).length)return;e.headers||(e.headers={}),Ne(e.headers,r)}else{const r=Yt.toQuery(t);if(!r)return;e.url=Yt.appendQueryToUri(e.url,r)}}getObjectType(e){const{type:t}=e;if(t==="subtitle")return qe.TIMED_TEXT;if(e.sn==="initSegment")return qe.INIT;if(t==="audio")return qe.AUDIO;if(t==="main")return this.hls.audioTracks.length?qe.VIDEO:qe.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===qe.AUDIO)s=r.audioTracks;else{const n=r.maxAutoLevel,o=n>-1?n+1:r.levels.length;s=r.levels.slice(0,o)}for(const n of s)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===qe.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:De.bufferInfo(s,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,s=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,a){t(n),this.loader.load(n,o,a)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,o,a){t(n),this.loader.load(n,o,a)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],s=c=>!Number.isNaN(c)&&c!=null&&c!==""&&c!==!1,r=c=>Math.round(c),n=c=>r(c/100)*100,a={br:r,d:r,bl:n,dl:n,mtp:n,nor:c=>encodeURIComponent(c),rtp:n,tb:r},l=Object.keys(e||{}).sort();for(const c of l){let u=e[c];if(!s(u)||c==="v"&&u===1||c=="pr"&&u===1)continue;const f=a[c];f&&(u=f(u));const h=typeof u;let d;c==="ot"||c==="sf"||c==="st"?d=`${c}=${u}`:h==="boolean"?d=c:h==="number"?d=`${c}=${u}`:d=`${c}=${JSON.stringify(u)}`,t.push(d)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),s={},r=["Object","Request","Session","Status"],n=[{},{},{},{}],o={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 a of t){const l=o[a]!=null?o[a]:1;n[l][a]=e[a]}for(let a=0;a<n.length;a++){const l=Yt.serialize(n[a]);l&&(s[`CMCD-${r[a]}`]=l)}return s}static toQuery(e){return`CMCD=${encodeURIComponent(Yt.serialize(e))}`}static appendQueryToUri(e,t){if(!t)return e;const s=e.includes("?")?"&":"?";return`${e}${s}${t}`}}const Xy=3e5;class Qy{constructor(e){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=e,this.log=A.log.bind(A,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(p.MANIFEST_LOADING,this.onManifestLoading,this),e.on(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(p.MANIFEST_PARSED,this.onManifestParsed,this),e.on(p.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(p.MANIFEST_LOADING,this.onManifestLoading,this),e.off(p.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(p.MANIFEST_PARSED,this.onManifestParsed,this),e.off(p.ERROR,this.onError,this))}startLoad(){if(this.started=!0,self.clearTimeout(this.reloadTimer),this.enabled&&this.uri)if(this.updated){const e=Math.max(this.timeToLoad*1e3-(performance.now()-this.updated),0);this.scheduleRefresh(this.uri,e)}else this.loadSteeringManifest(this.uri)}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),self.clearTimeout(this.reloadTimer)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(s=>s!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:s}=t;s!==null&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:s}=t;if((s==null?void 0:s.action)===Ve.SendAlternateToPenaltyBox&&s.flags===it.MoveAllAlternatesMatchingHost){let r=this.pathwayPriority;const n=this.pathwayId;this.penalizedPathways[n]||(this.penalizedPathways[n]=performance.now()),!r&&this.levels&&(r=this.levels.reduce((o,a)=>(o.indexOf(a.pathwayId)===-1&&o.push(a.pathwayId),o),[])),r&&r.length>1&&(this.updatePathwayPriority(r),s.resolved=this.pathwayId!==n)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const s=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(n=>{r-s[n]>Xy&&delete s[n]});for(let n=0;n<e.length;n++){const o=e[n];if(s[o])continue;if(o===this.pathwayId)return;const a=this.hls.nextLoadLevel,l=this.hls.levels[a];if(t=this.getLevelsForPathway(o),t.length>0){this.log(`Setting Pathway to "${o}"`),this.pathwayId=o,this.hls.trigger(p.LEVELS_UPDATED,{levels:t});const c=this.hls.levels[a];l&&c&&this.levels&&(c.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&c.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${c.bitrate}`),this.hls.nextLoadLevel=a);break}}}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(n=>{const{ID:o,"BASE-ID":a,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===o))return;const c=this.getLevelsForPathway(a).map(u=>{const f=Ne({},u);f.details=void 0,f.url=Vu(u.uri,u.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);const h=new _e(u.attrs);h["PATHWAY-ID"]=o;const d=h.AUDIO&&`${h.AUDIO}_clone_${o}`,g=h.SUBTITLES&&`${h.SUBTITLES}_clone_${o}`;d&&(s[h.AUDIO]=d,h.AUDIO=d),g&&(r[h.SUBTITLES]=g,h.SUBTITLES=g),f.attrs=h;const m=new ri(f);return Yi(m,"audio",d),Yi(m,"text",g),m});t.push(...c),Sl(this.audioTracks,s,l,o),Sl(this.subtitleTracks,r,l,o)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+u)}const n={responseType:"json",url:r.href},o=t.steeringManifestLoadPolicy.default,a=o.errorRetry||o.timeoutRetry||{},l={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},c={onSuccess:(u,f,h,d)=>{this.log(`Loaded steering manifest: "${r}"`);const g=u.data;if(g.VERSION!==1){this.log(`Steering VERSION ${g.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=g.TTL;const{"RELOAD-URI":m,"PATHWAY-CLONES":y,"PATHWAY-PRIORITY":T}=g;if(m)try{this.uri=new self.URL(m,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${m}`);return}this.scheduleRefresh(this.uri||h.url),y&&this.clonePathways(y),T&&this.updatePathwayPriority(T)},onError:(u,f,h,d)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${f.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${f.url} no longer available`);return}let g=this.timeToLoad*1e3;if(u.code===429){const m=this.loader;if(typeof(m==null?void 0:m.getResponseHeader)=="function"){const y=m.getResponseHeader("Retry-After");y&&(g=parseFloat(y)*1e3)}this.log(`Steering manifest ${f.url} rate limited`);return}this.scheduleRefresh(this.uri||f.url,g)},onTimeout:(u,f,h)=>{this.log(`Timeout loading steering manifest (${f.url})`),this.scheduleRefresh(this.uri||f.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,c)}scheduleRefresh(e,t=this.timeToLoad*1e3){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}function Sl(i,e,t,s){i&&Object.keys(e).forEach(r=>{const n=i.filter(o=>o.groupId===r).map(o=>{const a=Ne({},o);return a.details=void 0,a.attrs=new _e(a.attrs),a.url=a.attrs.URI=Vu(o.url,o.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),a.groupId=a.attrs["GROUP-ID"]=e[r],a.attrs["PATHWAY-ID"]=s,a});i.push(...n)})}function Vu(i,e,t,s){const{HOST:r,PARAMS:n,[t]:o}=s;let a;e&&(a=o==null?void 0:o[e],a&&(i=a));const l=new self.URL(i);return r&&!a&&(l.host=r),n&&Object.keys(n).sort().forEach(c=>{c&&l.searchParams.set(c,n[c])}),l.href}const Jy=/^age:\s*[\d.]+\s*$/im;class Wu{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new gr,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const s=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(s,t.url)}).catch(o=>(s.open("GET",t.url,!0),n(s,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(o=>{this.callbacks.onError({code:s.status,text:o.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:o}=s.loadPolicy;if(r)for(const a in r)e.setRequestHeader(a,r[a]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),s.timeout=n&&J(n)?n:o,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:s}=this;if(!e||!t)return;const r=t.readyState,n=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const o=t.status,a=t.responseType!=="text";if(o>=200&&o<300&&(a&&t.response||t.responseText!==null)){s.loading.end=Math.max(self.performance.now(),s.loading.first);const l=a?t.response:t.responseText,c=t.responseType==="arraybuffer"?l.byteLength:l.length;if(s.loaded=s.total=c,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const u=this.callbacks.onProgress;if(u&&u(s,e,l,t),!this.callbacks)return;const f={url:t.responseURL,data:l,code:o};this.callbacks.onSuccess(f,s,e,t)}else{const l=n.loadPolicy.errorRetry,c=s.retry;Wi(l,c,!1,o)?this.retry(l):(A.error(`${o} while loading ${e.url}`),this.callbacks.onError({code:o,text:t.statusText},e,t,s))}}}loadtimeout(){var e;const t=(e=this.config)==null?void 0:e.loadPolicy.timeoutRetry,s=this.stats.retry;if(Wi(t,s,!0))this.retry(t);else{A.warn(`timeout while loading ${this.context.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=co(e,s.retry),s.retry++,A.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Jy.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Zy(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const eT=/(\d+)-(\d+)\/(\d+)/;class vl{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||rT,this.controller=new self.AbortController,this.stats=new gr}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;e!=null&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=tT(e,this.controller.signal),o=s.onProgress,a=e.responseType==="arraybuffer",l=a?"byteLength":"length",{maxTimeToFirstByteMs:c,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=c&&J(c)?c:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(f=>{this.response=this.loader=f;const h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},u-(h-r.loading.start)),!f.ok){const{status:d,statusText:g}=f;throw new nT(g||"fetch, bad network response",d,f)}return r.loading.first=h,r.total=iT(f.headers)||r.total,o&&J(t.highWaterMark)?this.loadProgressively(f,r,e,t.highWaterMark,o):a?f.arrayBuffer():e.responseType==="json"?f.json():f.text()}).then(f=>{const{response:h}=this;self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const d=f[l];d&&(r.loaded=r.total=d);const g={url:h.url,data:f,code:h.status};o&&!J(t.highWaterMark)&&o(r,e,f,h),s.onSuccess(g,r,e,h)}).catch(f=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const h=f&&f.code||0,d=f?f.message:null;s.onError({code:h,text:d},e,f?f.details:null,r)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,s,r=0,n){const o=new Ou,a=e.body.getReader(),l=()=>a.read().then(c=>{if(c.done)return o.dataLength&&n(t,s,o.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=c.value,f=u.length;return t.loaded+=f,f<r||o.dataLength?(o.push(u),o.dataLength>=r&&n(t,s,o.flush(),e)):n(t,s,u,e),l()}).catch(()=>Promise.reject());return l()}}function tT(i,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ne({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function sT(i){const e=eT.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function iT(i){const e=i.get("Content-Range");if(e){const s=sT(e);if(J(s))return s}const t=i.get("Content-Length");if(t)return parseInt(t)}function rT(i,e){return new self.Request(i.url,e)}class nT extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const oT=/\s/,aT={newCue(i,e,t,s){const r=[];let n,o,a,l,c;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<s.rows.length;h++)if(n=s.rows[h],a=!0,l=0,c="",!n.isEmpty()){var f;for(let m=0;m<n.chars.length;m++)oT.test(n.chars[m].uchar)&&a?l++:(c+=n.chars[m].uchar,a=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const d=$u(c.trim()),g=So(e,t,d);i!=null&&(f=i.cues)!=null&&f.getCueById(g)||(o=new u(e,t,d),o.id=g,o.line=h+1,o.align="left",o.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(o))}return i&&r.length&&(r.sort((h,d)=>h.line==="auto"||d.line==="auto"?0:h.line>8&&d.line>8?d.line-h.line:h.line-d.line),r.forEach(h=>hu(i,h))),r}},lT={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},cT=et(et({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:Wu,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:dy,bufferController:vy,capLevelController:vo,errorController:np,fpsController:jy,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:Zc,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:lT},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},uT()),{},{subtitleStreamController:Ty,subtitleTrackController:xy,timelineController:Vy,audioStreamController:my,audioTrackController:py,emeController:Ss,cmcdController:Yt,contentSteeringController:Qy});function uT(){return{cueHandler:aT,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 fT(i,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=wn(i),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(n=>{const o=`${n==="level"?"playlist":n}LoadPolicy`,a=e[o]===void 0,l=[];r.forEach(c=>{const u=`${n}Loading${c}`,f=e[u];if(f!==void 0&&a){l.push(u);const h=t[o].default;switch(e[o]={default:h},c){case"TimeOut":h.maxLoadTimeMs=f,h.maxTimeToFirstByteMs=f;break;case"MaxRetry":h.errorRetry.maxNumRetry=f,h.timeoutRetry.maxNumRetry=f;break;case"RetryDelay":h.errorRetry.retryDelayMs=f,h.timeoutRetry.retryDelayMs=f;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=f,h.timeoutRetry.maxRetryDelayMs=f;break}}}),l.length&&A.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${o}": ${JSON.stringify(e[o])}`)}),et(et({},t),e)}function wn(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(wn):Object.keys(i).reduce((e,t)=>(e[t]=wn(i[t]),e),{}):i}function hT(i){const e=i.loader;e!==vl&&e!==Wu?(A.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):Zy()&&(i.loader=vl,i.progressive=!0,i.enableSoftwareAES=!0,A.log("[config]: Progressive streaming enabled, using FetchLoader"))}class Ft{static get version(){return"1.4.12"}static isSupported(){return Rp()}static get Events(){return p}static get ErrorTypes(){return se}static get ErrorDetails(){return D}static get DefaultConfig(){return Ft.defaultConfig?Ft.defaultConfig:cT}static set DefaultConfig(e){Ft.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new Eo,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,X0(e.debug||!1,"Hls instance");const t=this.config=fT(Ft.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&hT(t);const{abrController:s,bufferController:r,capLevelController:n,errorController:o,fpsController:a}=t,l=new o(this),c=this.abrController=new s(this),u=this.bufferController=new r(this),f=this.capLevelController=new n(this),h=new a(this),d=new $m(this),g=new Wm(this),m=t.contentSteeringController,y=m?new m(this):null,T=this.levelController=new ap(this,y),x=new lp(this),v=new up(this.config),R=this.streamController=new fy(this,x,v);f.setStreamController(R),h.setStreamController(R);const b=[d,T,R];y&&b.splice(1,0,y),this.networkControllers=b;const M=[c,u,f,h,g,x];this.audioTrackController=this.createController(t.audioTrackController,b);const P=t.audioStreamController;P&&b.push(new P(this,x,v)),this.subtitleTrackController=this.createController(t.subtitleTrackController,b);const B=t.subtitleStreamController;B&&b.push(new B(this,x,v)),this.createController(t.timelineController,M),v.emeController=this.emeController=this.createController(t.emeController,M),this.cmcdController=this.createController(t.cmcdController,M),this.latencyController=this.createController(Ym,M),this.coreComponents=M,b.push(l);const K=l.onErrorOut;typeof K=="function"&&this.on(p.ERROR,K,l)}createController(e,t){if(e){const s=new e(this);return t&&t.push(s),s}return null}on(e,t,s=this){this._emitter.on(e,t,s)}once(e,t,s=this){this._emitter.once(e,t,s)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,s=this,r){this._emitter.off(e,t,s,r)}listeners(e){return this._emitter.listeners(e)}emit(e,t,s){return this._emitter.emit(e,t,s)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(s){A.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),this.trigger(p.ERROR,{type:se.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:e,error:s})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){A.log("destroy"),this.trigger(p.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){A.log("attachMedia"),this._media=e,this.trigger(p.MEDIA_ATTACHING,{media:e})}detachMedia(){A.log("detachMedia"),this.trigger(p.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=oo.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});A.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(p.MANIFEST_LOADING,{url:e})}startLoad(e=-1){A.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){A.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){A.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){A.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){A.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){A.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){A.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){A.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){A.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(A.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){bn.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const s=e.length;for(let r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e&&e.length?r=e.length-1:r=t,s)for(let n=r;n--;){const o=e[n].attrs["HDCP-LEVEL"];if(o&&o<=s)return n}return r}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Ft.defaultConfig=void 0;const dT={name:"",components:{},props:{sourceUrl:{type:String,default:""},height:{type:String,default:"550px"}},data(){return{hls:null,sourceUrls:this.sourceUrl,loadingVideo:!1,waiting:!1,reloadPlayTime:null}},computed:{},watch:{sourceUrl:{handler(i,e){console.log(i,e),i&&i!==e&&(console.log("执行监听"),this.waiting=!0,this.sourceUrls=i,this.playVideo())}}},created(){},mounted(){this.playVideo()},methods:{playVideo(){this.$nextTick(()=>[this.loadingVideo=!1]),Ft.isSupported()?(console.log("支持hls播放"),this.hls=new Ft,this.hls.loadSource(this.sourceUrls),this.hls.attachMedia(this.$refs.video),this.hls.on(Ft.Events.MANIFEST_PARSED,(i,e)=>{console.log("playing..."),this.loadingVideo=!1,this.waiting=!1,this.$emit("playStatus",!0),this.$refs.video.play()})):this.$refs.video.canPlayType("application/vnd.apple.mpegurl")},videoPause(){this.hls&&(this.$refs.video.pause(),this.hls.destroy(),this.hls=null)}},beforeDestroy(){clearTimeout(this.reloadPlayTime),this.hls=null}},gT={class:"ali-player"},mT={class:"main"},pT={class:"video-center"},yT={key:0,class:"video",style:{"background-color":"#0c0b0b"}},TT={id:"video",controls:"",class:"video",ref:"video",autoplay:"",muted:"",controlslist:"nodownload noplaybackrate",disablePictureInPicture:"",style:{"background-color":"#0c0b0b",width:"100%",height:"100%"}};function ET(i,e,t,s,r,n){return Js(),hn("div",gT,[xs("div",mT,[xs("div",pT,[r.hls?Bh("",!0):(Js(),hn("div",yT)),ih(xs("video",TT,null,512),[[pd,r.hls]])])])])}const xT=Zn(dT,[["render",ET],["__scopeId","data-v-c941aa7d"]]);const ST={class:"liveCon"},vT={__name:"index",setup(i){let e=Li("http://139.9.65.252:83/openUrl/qub0mxW/live.m3u8"),t=Li([]);const s=Li(!1),r=()=>{const a=navigator.userAgent,l=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;s.value=l.test(a)};jn(()=>{r(),o()});const n=a=>{console.log("子组建的状态",a)},o=()=>{H0({protocol:"hls"}).then(a=>{t.value=a.data.map(l=>{let c={url:l.data.url,flag:!1};return{...l,data:c}}),e.value=t.value[9].data.url})};return(a,l)=>(Js(),hn("div",{class:Ji(s.value?"player_box":"player_box1"),ref:"parentElement"},[xs("div",ST,[Je(xT,{sourceUrl:rs(e),onPlayStatus:n},null,8,["sourceUrl"])])],2))}},AT=Zn(vT,[["__scopeId","data-v-fdbd8240"]]),RT=[{path:"/",name:"首页",redirect:"/home"},{path:"/home",name:"home",component:AT}],LT=Ag({routes:RT,history:Bd()});Ed(Ig).use(LT).mount("#app");